Microsoft.JScript.FunctionObject.TranslateBodyToIL C# (CSharp) Method

TranslateBodyToIL() private method

private TranslateBodyToIL ( ILGenerator il, CompilerGlobals compilerGlobals ) : void
il ILGenerator
compilerGlobals CompilerGlobals
return void
      internal void TranslateBodyToIL(ILGenerator il, CompilerGlobals compilerGlobals){
        this.returnLabel = il.DefineLabel();
        // Emit all the namespaces used by this function
        if (this.body.Engine.GenerateDebugInfo){
          ScriptObject ns = this.enclosing_scope.GetParent();
          while (ns != null){
            if (ns is PackageScope)
              il.UsingNamespace(((PackageScope)ns).name);
            else if (ns is WrappedNamespace && !((WrappedNamespace)ns).name.Equals(""))
              il.UsingNamespace(((WrappedNamespace)ns).name);
            ns = ns.GetParent();
          }
        }
        int startLine = this.body.context.StartLine;
        int startCol = this.body.context.StartColumn;
        this.body.context.document.EmitLineInfo(il, startLine, startCol, startLine, startCol + 1);
        if (this.body.context.document.debugOn)
          il.Emit(OpCodes.Nop);
        //set up the compiler to emit direct accesses to the locals and pars.
        int n = this.fields.Length;
        for (int i = 0; i < n; i++){
          if (!this.fields[i].IsLiteral || this.fields[i].value is FunctionObject){
            Type t = this.fields[i].FieldType;
            LocalBuilder tok = il.DeclareLocal(t);
            if (this.fields[i].debugOn)
              tok.SetLocalSymInfo(this.fields[i].debuggerName);
            this.fields[i].metaData = tok;
          }
        }
        globals.ScopeStack.Push(this.own_scope);
        try{
          if (this.must_save_stack_locals){
            this.TranslateToMethodWithStackFrame(il, compilerGlobals, true);
            return;
          }
          this.body.TranslateToILInitializer(il);
          this.body.TranslateToIL(il, Typeob.Void);
          il.MarkLabel(this.returnLabel);
        }finally{
          globals.ScopeStack.Pop();
        }
      }