jitcraft/TypeManager.cpp
changeset 14 0784ac5cc347
parent 12 75e385f68b7e
child 20 e020a14e21be
     1.1 --- a/jitcraft/TypeManager.cpp	Sat Jun 30 20:20:39 2012 -0700
     1.2 +++ b/jitcraft/TypeManager.cpp	Sat Jun 30 22:31:14 2012 -0700
     1.3 @@ -17,6 +17,7 @@
     1.4   */
     1.5  #include "Types.h"
     1.6  #include "TypeManager.h"
     1.7 +#include "Zone.h"
     1.8  
     1.9  using namespace jc;
    1.10  
    1.11 @@ -35,6 +36,12 @@
    1.12          return false;
    1.13      if ((primitiveTypes_[PrimitiveType_Native] = Type::NewPrimitive(zone_, PrimitiveType_Native)) == NULL)
    1.14          return false;
    1.15 +
    1.16 +    for (unsigned i = 0; i < PrimitiveTypes_Total; i++) {
    1.17 +        if ((referenceTypes_[i] = Type::NewReference(zone_, primitiveTypes_[i])) == NULL)
    1.18 +            return false;
    1.19 +    }
    1.20 +
    1.21      return true;
    1.22  }
    1.23  
    1.24 @@ -55,3 +62,20 @@
    1.25      // :TODO: cache this.
    1.26      return Type::NewUnsafeArray(zone_, contained, elements);
    1.27  }
    1.28 +
    1.29 +Type *
    1.30 +TypeManager::getReference(Type *type)
    1.31 +{
    1.32 +    if (type->isFloat() || (type->isInt() && !type->tag()))
    1.33 +        return referenceTypes_[type->primitive()];
    1.34 +
    1.35 +    // :TODO: cache this.
    1.36 +    return Type::NewReference(zone_, type);
    1.37 +}
    1.38 +
    1.39 +Type *
    1.40 +TypeManager::newFunction(Type *returnType, FixedArray *args)
    1.41 +{
    1.42 +    // :TODO: cache this.
    1.43 +    return Type::NewFunction(zone_, returnType, args);
    1.44 +}