1.1 --- a/src/compiler/SemanticAnalysis.cpp Mon Nov 19 01:13:44 2012 -0800
1.2 +++ b/src/compiler/SemanticAnalysis.cpp Mon Nov 19 02:12:13 2012 -0800
1.3 @@ -193,6 +193,7 @@
1.4
1.5 for (size_t i = 0; i < node->statements()->length(); i++) {
1.6 Statement *stmt = node->statements()->at(i);
1.7 + __ note_position(stmt->pos());
1.8 stmt->accept(this);
1.9 assert(__ stackDepth() == 0);
1.10 }
1.11 @@ -395,7 +396,7 @@
1.12 if (!left || !right)
1.13 return;
1.14
1.15 - hir_ = binary(node->token(), left, right);
1.16 + hir_ = binary(node, node->token(), left, right);
1.17 }
1.18
1.19 bool
1.20 @@ -432,18 +433,18 @@
1.21 Scope *in = sym->scope();
1.22 switch (in->kind()) {
1.23 case Scope::GLOBAL:
1.24 - hir_ = new (pool_) HGlobal(sym);
1.25 + hir_ = new (pool_) HGlobal(proxy, sym);
1.26 return;
1.27
1.28 case Scope::FUNCTION:
1.29 assert(var->storage() == VariableSymbol::Arg);
1.30 - hir_ = new (pool_) HLocal(var);
1.31 + hir_ = new (pool_) HLocal(proxy, var);
1.32 return;
1.33
1.34 default:
1.35 assert(in->kind() == Scope::BLOCK);
1.36 assert(var->storage() == VariableSymbol::Local);
1.37 - hir_ = new (pool_) HLocal(var);
1.38 + hir_ = new (pool_) HLocal(proxy, var);
1.39 return;
1.40 }
1.41 }
1.42 @@ -452,14 +453,14 @@
1.43 SemanticAnalysis::visitIntegerLiteral(IntegerLiteral *lit)
1.44 {
1.45 Local<Type> type(zone_, zone_->types()->getPrimitive(PrimitiveType_Int32));
1.46 - hir_ = new (pool_) HInteger(type, lit->value());
1.47 + hir_ = new (pool_) HInteger(lit, type, lit->value());
1.48 }
1.49
1.50 void
1.51 SemanticAnalysis::visitFloatLiteral(FloatLiteral *node)
1.52 {
1.53 Local<Type> type(zone_, zone_->types()->getPrimitive(PrimitiveType_Float));
1.54 - hir_ = new (pool_) HFloat(type, (float)node->value());
1.55 + hir_ = new (pool_) HFloat(node, type, (float)node->value());
1.56 }
1.57
1.58 void
1.59 @@ -530,7 +531,7 @@
1.60 return;
1.61 }
1.62
1.63 - hir_ = new (pool_) HCall(fun->returnType(), callee, args);
1.64 + hir_ = new (pool_) HCall(node, fun->returnType(), callee, args);
1.65 }
1.66
1.67 void
1.68 @@ -544,7 +545,7 @@
1.69 if ((hir = coerce(hir, lval->type(), Coerce_Assign)) == NULL)
1.70 return;
1.71
1.72 - hir_ = new (pool_) HStore(node->token(), lval, hir);
1.73 + hir_ = new (pool_) HStore(node, node->token(), lval, hir);
1.74 }
1.75
1.76 void
1.77 @@ -593,7 +594,8 @@
1.78 return;
1.79 }
1.80
1.81 - hir_ = new (pool_) HIndex(ArrayType::cast(left->type())->contained(),
1.82 + hir_ = new (pool_) HIndex(node,
1.83 + ArrayType::cast(left->type())->contained(),
1.84 left,
1.85 right);
1.86 }
1.87 @@ -612,14 +614,14 @@
1.88
1.89 HIR *rval;
1.90 if (lval->type()->isInt32())
1.91 - rval = new (pool_) HInteger(lval->type(), 1);
1.92 + rval = new (pool_) HInteger(node, lval->type(), 1);
1.93 else
1.94 - rval = new (pool_) HFloat(lval->type(), 1.0);
1.95 + rval = new (pool_) HFloat(node, lval->type(), 1.0);
1.96
1.97 if (node->postfix())
1.98 - hir_ = new (pool_) HPostIncDec(node->token(), lval, rval);
1.99 + hir_ = new (pool_) HPostIncDec(node, node->token(), lval, rval);
1.100 else
1.101 - hir_ = new (pool_) HStore(node->token(), lval, rval);
1.102 + hir_ = new (pool_) HStore(node, node->token(), lval, rval);
1.103 }
1.104
1.105 Type *
1.106 @@ -730,15 +732,17 @@
1.107 Handle<Type> from = hir->type();
1.108
1.109 if (from->isInt32() && to->isFloat())
1.110 - return new (pool_) HConvert(to, OP_CVT_I2F, hir);
1.111 + return new (pool_) HConvert(hir->node(), to, OP_CVT_I2F, hir);
1.112 if (from->isInt32() && to->isBool())
1.113 - return new (pool_) HConvert(to, OP_CVT_I2B, hir);
1.114 + return new (pool_) HConvert(hir->node(), to, OP_CVT_I2B, hir);
1.115
1.116 if (to->isArray()) {
1.117 if (!typeCheckArray(SourcePosition(), from, to, kind))
1.118 return NULL;
1.119 return hir;
1.120 }
1.121 +
1.122 + assert(from == to);
1.123
1.124 return hir;
1.125 }
1.126 @@ -755,7 +759,7 @@
1.127 }
1.128
1.129 HIR *
1.130 -SemanticAnalysis::binary(TokenKind token, HIR *left, HIR *right)
1.131 +SemanticAnalysis::binary(AstNode *node, TokenKind token, HIR *left, HIR *right)
1.132 {
1.133 Local<Type> coercion(zone_, coercionType(token, left, right));
1.134 if (!coercion)
1.135 @@ -777,7 +781,7 @@
1.136 case TOK_SHR:
1.137 case TOK_USHR:
1.138 case TOK_SHL:
1.139 - return new (pool_) HBinary(left->type(), token, left, right);
1.140 + return new (pool_) HBinary(node, left->type(), token, left, right);
1.141
1.142 case TOK_EQUALS:
1.143 case TOK_NOTEQUALS:
1.144 @@ -789,7 +793,7 @@
1.145 case TOK_OR:
1.146 {
1.147 Local<Type> result(zone_, zone_->types()->getPrimitive(PrimitiveType_Bool));
1.148 - return new (pool_) HBinary(result, token, left, right);
1.149 + return new (pool_) HBinary(node, result, token, left, right);
1.150 }
1.151
1.152 default:
1.153 @@ -857,7 +861,7 @@
1.154 if (!left || !right)
1.155 return;
1.156
1.157 - HIR *hir = binary(bin->token(), left, right);
1.158 + HIR *hir = binary(bin, bin->token(), left, right);
1.159 if (!hir)
1.160 return;
1.161 if ((hir = coerce(hir, boolType, Coerce_Assign)) == NULL)