コード例 #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();
            }
        }
コード例 #2
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);
        }