Fix linux/mac support.
2 * Copyright (C) 2012 David Anderson
4 * This file is part of SourcePawn.
6 * SourcePawn is free software: you can redistribute it and/or modify it under
7 * the terms of the GNU General Public License as published by the Free
8 * Software Foundation, either version 3 of the License, or (at your option)
11 * SourcePawn is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along with
16 * SourcePawn. If not, see http://www.gnu.org/licenses/.
18 #ifndef _include_jitcraft_compile_context_h_
19 #define _include_jitcraft_compile_context_h_
23 #include "../Messages.h"
24 #include "../PoolAllocator.h"
25 #include "../Handles.h"
26 #include "../Modules.h"
27 #include "../Packages.h"
36 struct SourcePosition;
37 struct TranslationUnit;
38 class ImportStatement;
46 CompileError(unsigned line, unsigned col, const char *message)
58 struct TranslationUnit : public PoolObject
60 TranslationUnit(Handle<Module> module)
66 dependencyFailed_(false)
73 PoolList<TranslationUnit *> dependents_;
74 ImportScope *importScope_;
75 GlobalScope *globalScope_;
76 ScopedRoot<Module> module_;
78 ParseTree *tree() const {
81 PoolList<TranslationUnit *> &dependents() {
85 return errors_.length() ||
89 void setImportScope(ImportScope *scope) {
90 assert(!importScope_);
93 void setGlobalScope(GlobalScope *scope) {
94 assert(!globalScope_);
97 ImportScope *importScope() const {
100 GlobalScope *globalScope() const {
103 Handle<Module> module() {
107 void setDependencyFailed() {
108 dependencyFailed_ = true;
110 void setOutOfMemory() {
113 void appendError(const char *report, unsigned line, unsigned col) {
114 oom_ |= errors_.append(CompileError(line, col, report));
116 const Vector<CompileError> *errors() {
122 bool dependencyFailed_;
123 Vector<CompileError> errors_;
130 Vector<TranslationUnit *> units_;
131 Vector<TranslationUnit *> unparsed_;
132 TranslationUnit *active_;
135 char *loadSource(Handle<Module> module, size_t *length);
136 bool parse(TranslationUnit *unit);
137 bool evaluateImports(TranslationUnit *unit);
138 bool propagateFailure();
139 bool add(Handle<Module> module);
142 CompileContext(Zone *zone, const char *file);
145 bool initialize(Handle<Package> package, const char *name);
147 void enter(TranslationUnit *unit);
150 void reportErrorVa(const SourcePosition &pos, Message msg, va_list ap);
151 void reportError(const SourcePosition &pos, Message msg, ...);
154 class AutoEnterCompileContext
159 AutoEnterCompileContext(CompileContext &cc, TranslationUnit *unit)
164 ~AutoEnterCompileContext() {
171 #endif // _include_jitcraft_compile_context_h_