src/BytecodeCompiler.cpp
changeset 158 91071a2255bf
parent 157 b760e8cb29a8
child 164 3bf7c007883d
     1.1 --- a/src/BytecodeCompiler.cpp	Sun Aug 05 01:10:49 2012 -0700
     1.2 +++ b/src/BytecodeCompiler.cpp	Sun Aug 05 01:15:35 2012 -0700
     1.3 @@ -249,23 +249,14 @@
     1.4          IndexExpression *index = node->lvalue()->toIndexExpression();
     1.5          __ note_position(index->pos());
     1.6  
     1.7 -        // Note: Eventually, watch out for a hole here. An expression like:
     1.8 -        //
     1.9 -        //   (a[4] = (5, a = []))
    1.10 -        //
    1.11 -        // Could shrink array, so we need to either bind a[i] to a Reference,
    1.12 -        // or keep the bounds check near the set. This is just a semantic
    1.13 -        // decision.
    1.14          index->left()->accept(this);
    1.15          index->right()->accept(this);
    1.16  
    1.17          if (node->token() != TOK_ASSIGN)
    1.18              __ dup2();
    1.19  
    1.20 -        if (node->token() != TOK_ASSIGN || (type->isStruct() || type->isArray())) {
    1.21 -            __ bounds();
    1.22 +        if (node->token() != TOK_ASSIGN || (type->isStruct() || type->isArray()))
    1.23              __ getelem(index->type());
    1.24 -        }
    1.25      }
    1.26  
    1.27      if (node->token() == TOK_ASSIGN) {
    1.28 @@ -302,9 +293,6 @@
    1.29          __ setfield(expr->fieldIndex(), expr->type());
    1.30      } else {
    1.31          IndexExpression *index = node->lvalue()->toIndexExpression();
    1.32 -        // :TODO: get rid of the BOUNDS instruction, embed it in g/setelem*?
    1.33 -        // We can't emit it here because the stack is slightly out of position.
    1.34 -        // __ bounds();
    1.35          __ setelem(index->type());
    1.36      }
    1.37  }
    1.38 @@ -382,7 +370,6 @@
    1.39          index->right()->accept(this);
    1.40  
    1.41          assert(!node->type()->isArray());
    1.42 -        __ bounds();
    1.43          __ dup2();
    1.44          __ getelem(node->type());
    1.45  
    1.46 @@ -538,7 +525,6 @@
    1.47      node->left()->accept(this);
    1.48      node->right()->accept(this);
    1.49      __ note_position(node->pos());
    1.50 -    __ bounds();
    1.51      __ getelem(node->type());
    1.52  }
    1.53  
    1.54 @@ -887,7 +873,6 @@
    1.55                  expr->left()->accept(this);
    1.56                  expr->right()->accept(this);
    1.57                  __ note_position(expr->pos());
    1.58 -                __ bounds();
    1.59                  __ arrayref_lifo();
    1.60              } else {
    1.61                  // We don't know how to, or can't, build a direct reference to