Handleize NameBinding.
authorDavid Anderson <dvander@alliedmods.net>
Tue Jul 03 00:54:40 2012 -0700 (2012-07-03)
changeset 37abb03d835b53
parent 36 fbc7363dc96f
child 38 88049d677e3f
Handleize NameBinding.
jitcraft/NameBinding.h
jitcraft/Scopes.cpp
jitcraft/SemanticAnalysis.cpp
     1.1 --- a/jitcraft/NameBinding.h	Tue Jul 03 00:50:36 2012 -0700
     1.2 +++ b/jitcraft/NameBinding.h	Tue Jul 03 00:54:40 2012 -0700
     1.3 @@ -36,7 +36,7 @@
     1.4  {
     1.5      Scope *scope_;
     1.6      Name *name_;
     1.7 -    Type *type_;
     1.8 +    ScopedRoot<Type> type_;
     1.9      SourcePosition pos_;
    1.10  
    1.11    public:
    1.12 @@ -72,7 +72,7 @@
    1.13      Type *type() const {
    1.14          return type_;
    1.15      }
    1.16 -    void setType(Type *type) {
    1.17 +    void setType(Handle<Type> type) {
    1.18          type_ = type;
    1.19      }
    1.20      const SourcePosition &pos() {
     2.1 --- a/jitcraft/Scopes.cpp	Tue Jul 03 00:50:36 2012 -0700
     2.2 +++ b/jitcraft/Scopes.cpp	Tue Jul 03 00:54:40 2012 -0700
     2.3 @@ -1,4 +1,5 @@
     2.4 -/*
     2.5 +/* vim: set ts=4 sw=4 tw=99 et:
     2.6 + *
     2.7   * Copyright (C) 2012 David Anderson
     2.8   *
     2.9   * This file is part of JITCraft.
    2.10 @@ -222,6 +223,10 @@
    2.11      if (kind() == FUNCTION || enclosing()->kind() == FUNCTION)
    2.12          return;
    2.13  
    2.14 +    Local<Type> type(ZONE(), ZONE()->types()->getPrimitive(PrimitiveType_Native));
    2.15 +    if (!type)
    2.16 +        return;
    2.17 +
    2.18      lifoSlot_ = new (pool_) Variable(this, NULL, SourcePosition());
    2.19 -    lifoSlot_->setType(ZONE()->types()->getPrimitive(PrimitiveType_Native));
    2.20 +    lifoSlot_->setType(type);
    2.21  }
     3.1 --- a/jitcraft/SemanticAnalysis.cpp	Tue Jul 03 00:50:36 2012 -0700
     3.2 +++ b/jitcraft/SemanticAnalysis.cpp	Tue Jul 03 00:54:40 2012 -0700
     3.3 @@ -391,13 +391,12 @@
     3.4  void
     3.5  SemanticAnalysis::visit(VariableDeclaration *node)
     3.6  {
     3.7 -    // :TODO: use locals
     3.8 -    Type *type = zone_->types()->getPrimitiveForTag(node->tag());
     3.9 +    Local<Type> type(zone_, zone_->types()->getPrimitiveForTag(node->tag()));
    3.10      if (!type)
    3.11          return;
    3.12  
    3.13      if (node->postDimensions()) {
    3.14 -        Type *init = NULL;
    3.15 +        Local<Type> init(zone_);
    3.16          if (node->initialization()) {
    3.17              if ((init = visitAndApplyType(node->initialization())) == NULL)
    3.18                  return;
    3.19 @@ -414,13 +413,13 @@
    3.20              return;
    3.21          }
    3.22  
    3.23 -        Type *check = init;
    3.24 +        Local<Type> check(zone_, init);
    3.25          for (size_t i = node->postDimensions()->size() - 1; i < node->postDimensions()->size(); i--) {
    3.26              Expression *expr = node->postDimensions()->at(i);
    3.27              int size = -1;
    3.28  
    3.29              if (expr) {
    3.30 -                Type *exprType = visitForLoad(expr);
    3.31 +                Local<Type> exprType(zone_, visitForLoad(expr));
    3.32                  if (!exprType)
    3.33                      return;
    3.34  
    3.35 @@ -524,9 +523,7 @@
    3.36  bool
    3.37  SemanticAnalysis::preanalyze(FunctionStatement *node)
    3.38  {
    3.39 -    // :TODO: use Local
    3.40 -
    3.41 -    FixedArray *args = FixedArray::New(zone_, node->parameters()->size(), Heap::Tenure_Old);
    3.42 +    Local<FixedArray> args(zone_, FixedArray::New(zone_, node->parameters()->size(), Heap::Tenure_Old));
    3.43      if (!args)
    3.44          return false;
    3.45  
    3.46 @@ -534,7 +531,7 @@
    3.47      for (size_t i = 0; i < node->parameters()->size(); i++) {
    3.48          Parameter *parameter = node->parameters()->at(i);
    3.49          
    3.50 -        Type *type = zone_->types()->getPrimitiveForTag(parameter->tag());
    3.51 +        Local<Type> type(zone_, zone_->types()->getPrimitiveForTag(parameter->tag()));
    3.52          if (!type)
    3.53              return false;
    3.54  
    3.55 @@ -553,11 +550,11 @@
    3.56          parameter->variable()->setType(type);
    3.57      }
    3.58  
    3.59 -    Type *returnType = zone_->types()->getPrimitive(PrimitiveType_Int32);
    3.60 +    Local<Type> returnType(zone_, zone_->types()->getPrimitive(PrimitiveType_Int32));
    3.61      if (!returnType)
    3.62          return false;
    3.63  
    3.64 -    Type *funtype = zone_->types()->newFunction(returnType, args);
    3.65 +    Local<Type> funtype(zone_, zone_->types()->newFunction(returnType, args));
    3.66      if (!funtype)
    3.67          return false;
    3.68