예제 #1
0
 public override void Visit(ArrayLookupExpressionNode node)
 {
     Console.WriteLine(this.indentation + "<Array>[<Index>]");
     indentation = indentation + "   ";
     Console.WriteLine(this.indentation + "Array");
     indentation = indentation + "   ";
     node.arrayExpression.Accept(this);
     indentation = indentation.Substring(0, indentation.Length - 3);
     Console.WriteLine(this.indentation + "Index");
     indentation = indentation + "   ";
     node.indexExpression.Accept(this);
     indentation = indentation.Substring(0, indentation.Length - 6);
 }
예제 #2
0
 public override void Visit(ArrayLookupExpressionNode node)
 {
     GetValueOfIdentifier(((IdentifierExpressionNode)node.arrayExpression).identifier.name, "edx");
     Gen("push", "edx");
     node.indexExpression.Accept(this);
     Gen("pop", "edx");
     Gen("mov", "eax", "[edx+4*eax+4]");
 }
예제 #3
0
 public virtual void Visit(ArrayLookupExpressionNode node)
 {
     node.arrayExpression.Accept(this);
     node.indexExpression.Accept(this);
 }
예제 #4
0
        public override void Visit(ArrayLookupExpressionNode node)
        {
            if (!AreTypeCompatible(node.arrayExpression.GetType(), typeof(IdentifierExpressionNode)))
                throw new Exception("Array Lookup Expression must be an Identifier!");

            node.arrayExpression.Accept(this);
            node.indexExpression.Accept(this);

            if (!AreTypeCompatible(node.arrayExpression.ExpressionType.GetType(), typeof(ArrayType)))
                throw new Exception("Array Identifier '" + ((IdentifierExpressionNode)node.arrayExpression).identifier.name + "' is not an array!");
            if (!AreTypeCompatible(node.indexExpression.ExpressionType.GetType(), typeof(IntType)))
                throw new Exception("Index Expression's Type is not Int!");

            node.ExpressionType = IntType.Instance;
        }