1.1 --- a/src/compiler/CompileContext.h Sat Dec 29 00:55:38 2012 -0800
1.2 +++ b/src/compiler/CompileContext.h Tue Jan 01 15:34:07 2013 -0800
1.3 @@ -1,19 +1,19 @@
1.4 /*
1.5 * Copyright (C) 2012 David Anderson
1.6 *
1.7 - * This file is part of JITCraft.
1.8 + * This file is part of SourcePawn.
1.9 *
1.10 - * JITCraft is free software: you can redistribute it and/or modify it under
1.11 + * SourcePawn is free software: you can redistribute it and/or modify it under
1.12 * the terms of the GNU General Public License as published by the Free
1.13 * Software Foundation, either version 3 of the License, or (at your option)
1.14 * any later version.
1.15 *
1.16 - * Foobar is distributed in the hope that it will be useful, but WITHOUT ANY
1.17 + * SourcePawn is distributed in the hope that it will be useful, but WITHOUT ANY
1.18 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1.19 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
1.20 *
1.21 * You should have received a copy of the GNU General Public License along with
1.22 - * JITCraft. If not, see http://www.gnu.org/licenses/.
1.23 + * SourcePawn. If not, see http://www.gnu.org/licenses/.
1.24 */
1.25 #ifndef _include_jitcraft_compile_context_h_
1.26 #define _include_jitcraft_compile_context_h_
1.27 @@ -24,6 +24,7 @@
1.28 #include "../PoolAllocator.h"
1.29 #include "../Handles.h"
1.30 #include "../Modules.h"
1.31 +#include "../Packages.h"
1.32
1.33 namespace ke {
1.34
1.35 @@ -54,20 +55,21 @@
1.36 const char *message;
1.37 };
1.38
1.39 -struct TranslationUnit
1.40 +struct TranslationUnit : public PoolObject
1.41 {
1.42 - TranslationUnit()
1.43 + TranslationUnit(Handle<Module> module)
1.44 : tree_(NULL),
1.45 importScope_(NULL),
1.46 globalScope_(NULL),
1.47 + module_(module),
1.48 oom_(false),
1.49 dependencyFailed_(false)
1.50 {
1.51 }
1.52 - ~TranslationUnit();
1.53 +
1.54 + void destroy();
1.55
1.56 ParseTree *tree_;
1.57 - const char *path_;
1.58 PoolList<TranslationUnit *> dependents_;
1.59 ImportScope *importScope_;
1.60 GlobalScope *globalScope_;
1.61 @@ -98,6 +100,9 @@
1.62 GlobalScope *globalScope() const {
1.63 return globalScope_;
1.64 }
1.65 + Handle<Module> module() {
1.66 + return module_;
1.67 + }
1.68
1.69 void setDependencyFailed() {
1.70 dependencyFailed_ = true;
1.71 @@ -127,16 +132,17 @@
1.72 TranslationUnit *active_;
1.73
1.74 private:
1.75 - char *loadSource(const char *file, size_t *length);
1.76 + char *loadSource(Handle<Module> module, size_t *length);
1.77 bool parse(TranslationUnit *unit);
1.78 - void evaluateImports(TranslationUnit *unit);
1.79 + bool evaluateImports(TranslationUnit *unit);
1.80 bool propagateFailure();
1.81 + bool add(Handle<Module> module);
1.82
1.83 public:
1.84 CompileContext(Zone *zone, const char *file);
1.85 ~CompileContext();
1.86
1.87 - bool addTranslationUnit(TranslationUnit *unit);
1.88 + bool initialize(Handle<Package> package, const char *name);
1.89 bool compile();
1.90 void enter(TranslationUnit *unit);
1.91 void leave();