コード例 #1
0
 public override void Visit(NewIntegerArrayExpressionNode node)
 {
     node.expression.Accept(this);
     Gen("push", "eax");
     Gen("push", "ecx");
     Gen("shl", "eax", "2", "Determining bytes needed for array of integers");
     Gen("add", "eax", "4", "Add 4 bytes to store Array length at location 0");
     Gen("push", "eax");
     Gen("call", "memalloc", "", "Allocating memory for array of integers");
     Gen("add", "esp", "4");
     Gen("pop", "ecx");
     Gen("pop", "edx", "", "Recover number of array elements int eax");
     Gen("mov", "[eax]", "edx", "Store number of array elements into start of array memory");
 }
コード例 #2
0
        public override void Visit(NewIntegerArrayExpressionNode node)
        {
            node.expression.Accept(this);

            if (!AreTypeCompatible(node.expression.ExpressionType.GetType(), typeof(IntType)))
                throw new Exception("Integer Array Size Expression's Type is not Int!");

            ArrayType nodeType = new ArrayType("int[]");
            nodeType.ElementType = IntType.Instance;
            nodeType.NoOfDimensions = 1;
            node.ExpressionType = nodeType;
        }
コード例 #3
0
ファイル: BaseVisitor.cs プロジェクト: ssarangi/minijava
 public virtual void Visit(NewIntegerArrayExpressionNode node)
 {
     node.expression.Accept(this);
 }
コード例 #4
0
 public override void Visit(NewIntegerArrayExpressionNode node)
 {
     Console.WriteLine(this.indentation + "New Integer[<Length>]");
     indentation = indentation + "   ";
     Console.WriteLine(this.indentation + "Length");
     indentation = indentation + "   ";
     node.expression.Accept(this);
     indentation = indentation.Substring(0, indentation.Length - 6);
 }