Ejemplo n.º 1
0
 public virtual void Visit(FieldAccessExpressionNode node)
 {
     node.expression.Accept(this);
     node.identifier.Accept(this);
 }
Ejemplo n.º 2
0
 public override void Visit(FieldAccessExpressionNode node)
 {
     node.expression.Accept(this);
     ClassDefinition classDefinition = Analysis.Environment.Classes.Lookup(node.expression.ExpressionType.Name);
     FieldDefinition fieldDefinition = Analysis.Environment.LookupFieldInClass(node.identifier.name, classDefinition);
     Gen("mov", "eax", "[eax+" + fieldDefinition.Location.ToString() + "]", "Accessing field " + classDefinition.Name + "." + fieldDefinition.Name + "()");
 }
Ejemplo n.º 3
0
        public override void Visit(FieldAccessExpressionNode node)
        {
            node.expression.Accept(this);

            if (node.expression.ExpressionType.GetType() != typeof(ClassType))
                throw new Exception("Object used for field access is not an instance of any Class");

            ClassDefinition classDefinition = Analysis.Environment.Classes.Lookup(node.expression.ExpressionType.Name);
            FieldDefinition fieldDefinition;

            try
            {
                fieldDefinition = Analysis.Environment.LookupFieldInClass(node.identifier.name, classDefinition);
            }
            catch (Exception)
            {
                throw new Exception("Field '" + node.identifier.name + "' not found in class '" + node.expression.ExpressionType.Name + "'");
            }

            node.ExpressionType = fieldDefinition.FieldType;
        }