Beispiel #1
0
        public override void Generate(ILProcessor il, SemanticEnvironment environment)
        {
            var list = new ExpList();

            if (ExpList is ExpList expList)
            {
                list = expList;
            }

            foreach (var node in list.Nodes)
            {
                node.Generate(il, environment);
            }

            PostfixNode.Generate(il, environment);

            if (PostfixNode is Id id) // Push null to stack if function return void.
            {
                var type = (environment.GetSymbol(id.IdName) as FuncSymbol).Type as FuncType;
                if (type.ReturnType.SymbolTypeKind == SymbolTypeKind.VOID)
                {
                    il.Emit(OpCodes.Ldnull);
                }
            }
            else
            {
                throw new NotImplementedException();
            }
        }
Beispiel #2
0
 public override string ToString(string indent, bool last)
 {
     return
         (indent + NodePrefix(last) + $"[]" + "\r\n" +
          PostfixNode.ToString(indent + ChildrenPrefix(last), false) +
          Exp.ToString(indent + ChildrenPrefix(last), true));
 }
Beispiel #3
0
 public override string ToString(string indent, bool last)
 {
     return
         (indent + NodePrefix(last) + (TypeOfCall == CallType.VALUE ? "." : "->") + "\r\n" +
          PostfixNode.ToString(indent + ChildrenPrefix(last), false) +
          Id.ToString(indent + ChildrenPrefix(last), true));
 }
Beispiel #4
0
 public override string ToString(string indent, bool last)
 {
     return
         (indent + NodePrefix(last) + $"()" + "\r\n" +
          PostfixNode.ToString(indent + ChildrenPrefix(last), ExpList is NullStat) +
          ExpList.ToString(indent + ChildrenPrefix(last), true));
 }
Beispiel #5
0
        public override void Generate(ILProcessor il, SemanticEnvironment environment)
        {
            PostfixNode.Generate(il, environment);
            StructType structType;

            if (TypeOfCall == CallType.VALUE)
            {
                structType = PostfixNode.GetType(ref environment) as StructType;
            }
            else
            {
                structType = (PostfixNode.GetType(ref environment) as PointerType).PointerToType as StructType;
            }
            var id     = Id as Id;
            var member = structType.Members.Get(id.IdName) as VarSymbol;

            il.Emit(OpCodes.Ldfld, member.FieldDefinition);
        }
Beispiel #6
0
 public void Visit(PostfixNode postfix)
 {
     postfix.Left.Parent = postfix;
     postfix.Left.Accept(this);
 }