1.1 --- a/src/Modules.h Sat Dec 29 00:55:38 2012 -0800
1.2 +++ b/src/Modules.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_jc_module_h_
1.26 #define _include_jc_module_h_
1.27 @@ -21,25 +21,25 @@
1.28 #include "Heap.h"
1.29 #include "Code.h"
1.30 #include "Functions.h"
1.31 +#include "Packages.h"
1.32
1.33 namespace ke {
1.34
1.35 class Environment;
1.36 class Struct;
1.37 +class Package;
1.38 +struct TranslationUnit;
1.39
1.40 -class Module : public Object
1.41 +class Module : public Importable
1.42 {
1.43 - Barriered<String> file_;
1.44 Barriered<Code> code_;
1.45 Barriered<Struct> globals_;
1.46 void *nativeIdentity_;
1.47 + TranslationUnit *unit_;
1.48
1.49 public:
1.50 - static Module *New(Zone *zone);
1.51 + static Module *New(Zone *zone, Handle<Package> package, Handle<String> path, Handle<String> name);
1.52
1.53 - String *file() {
1.54 - return file_;
1.55 - }
1.56 Code *code() {
1.57 return code_;
1.58 }
1.59 @@ -47,9 +47,22 @@
1.60 return globals_;
1.61 }
1.62
1.63 - void setPath(Handle<String> path) {
1.64 - file_ = path;
1.65 + bool compiled() {
1.66 + return !!code_;
1.67 }
1.68 +
1.69 + // Modules are pre-created, and may have their intermediate compilation
1.70 + // data attached while they are being compiled.
1.71 + bool compiling() {
1.72 + return !!unit_;
1.73 + }
1.74 + TranslationUnit *translationUnit() {
1.75 + return unit_;
1.76 + }
1.77 + void setTranslationUnit(TranslationUnit *unit) {
1.78 + unit_ = unit;
1.79 + }
1.80 +
1.81 void setCode(Handle<Code> code) {
1.82 code_ = code;
1.83 }
1.84 @@ -57,17 +70,7 @@
1.85 globals_ = globals;
1.86 }
1.87
1.88 - void *nativeIdentity() {
1.89 - return nativeIdentity_;
1.90 - }
1.91 - void setNativeIdentity(void *identity) {
1.92 - nativeIdentity_ = identity;
1.93 - }
1.94 -
1.95 // Begin GC Descriptor.
1.96 - static inline size_t offsetOfFile() {
1.97 - return OFFSETOF(Module, file_);
1.98 - }
1.99 static inline size_t offsetOfCode() {
1.100 return OFFSETOF(Module, code_);
1.101 }