src/Modules.h
changeset 256 3c184218462d
parent 251 ca99a81745fe
child 263 ba85a47ee414
     1.1 --- a/src/Modules.h	Tue Jan 01 20:08:34 2013 -0800
     1.2 +++ b/src/Modules.h	Sun Jan 06 13:52:21 2013 -0800
     1.3 @@ -21,6 +21,7 @@
     1.4  #include "Heap.h"
     1.5  #include "Code.h"
     1.6  #include "Functions.h"
     1.7 +#include "FixedArray.h"
     1.8  #include "Packages.h"
     1.9  
    1.10  namespace ke {
    1.11 @@ -36,6 +37,7 @@
    1.12      Barriered<Struct> globals_;
    1.13      void *nativeIdentity_;
    1.14      TranslationUnit *unit_;
    1.15 +    Barriered<FixedArray> imports_;
    1.16  
    1.17    public:
    1.18      static Module *New(Zone *zone, Handle<Package> package, Handle<String> path, Handle<String> name);
    1.19 @@ -63,6 +65,18 @@
    1.20          unit_ = unit;
    1.21      }
    1.22  
    1.23 +    unsigned imports() {
    1.24 +        return imports_ ? imports_->length() / 2 : 0;
    1.25 +    }
    1.26 +    Importable *getImportAt(unsigned index) {
    1.27 +        return Importable::cast(imports_->at(index * 2));
    1.28 +    }
    1.29 +    FixedArray *importPathAt(unsigned index) {
    1.30 +        return FixedArray::cast(imports_->at(index * 2 + 1));
    1.31 +    }
    1.32 +    void setImports(Handle<FixedArray> imports) {
    1.33 +        imports_ = imports;
    1.34 +    }
    1.35      void setCode(Handle<Code> code) {
    1.36          code_ = code;
    1.37      }
    1.38 @@ -77,6 +91,9 @@
    1.39      static inline size_t offsetOfGlobals() {
    1.40          return OFFSETOF(Module, globals_);
    1.41      }
    1.42 +    static inline size_t offsetOfImports() {
    1.43 +        return OFFSETOF(Module, imports_);
    1.44 +    }
    1.45      // End GC Descriptor.
    1.46  
    1.47      static inline Module *cast(Object *obj) {