While.AST.Statements.Call.Compile C# (CSharp) Method

Compile() public method

public Compile ( ILGenerator il ) : void
il System.Reflection.Emit.ILGenerator
return void
        public override void Compile(ILGenerator il)
        {
            EmitDebugInfo(il, 0, false);
            SanityCheck();
            if (this.ChildNodes.Count > 0) {
                for (int i = 0; i < ChildNodes.Count - 1; i++) {
                    this[i].Compile(il);
                }
                Procedure proc = WhileProgram.Instance.Procedures.GetByName(ProcedureName);
                if (proc.HasResultArgument) {
                    Variable v = (Variable)this[ChildNodes.Count - 1];
                    //Create at first use
                    if (Options.BookVersion && !SymbolTable.IsInScope(v.Name)) {
                        SymbolTable.DefineVariable(v.Name);
                        LocalBuilder lb = il.DeclareLocal(typeof(int));
                        if (Options.Debug) {
                            lb.SetLocalSymInfo(v.Name);
                        }
                    }

                    if (SymbolTable.IsResultArgument(v.Name)) {
                        il.Emit(OpCodes.Ldarg, SymbolTable.GetValue(v.Name));
                    } else if (SymbolTable.IsArgument(v.Name)) {
                        il.Emit(OpCodes.Ldarga, SymbolTable.GetValue(v.Name));
                    } else {
                        il.Emit(OpCodes.Ldloca, SymbolTable.GetValue(v.Name));
                    }

                } else {
                    this[ChildNodes.Count - 1].Compile(il);
                }
            }
            il.Emit(OpCodes.Call, WhileProgram.Instance.Procedures.Compiled[ProcedureName]);
        }