Example #1
0
 public void RevertContextualsIn(FrameScope fs, CodeGen cg)
 {
     foreach (var varname in MangledContextuals.Values)
     {
         if (fs.AssignedContextuals.Contains(varname))
         {
             if (cg.This().Type.Name != "TopLevelFrame")
             {
                 cg.If(cg.This().Field("_assigned_" + fs.ID + "_" + varname) > 0);
                 {
                     cg.Assign(cg.This().Field("TopLevelFrame").Field("_ctxl_" + varname), cg.This().Field("TopLevelFrame").Field("_stack_" + varname).Invoke("Pop"));
                     cg.Assign(cg.This().Field("_assigned_" + fs.ID + "_" + varname), 0);
                 }
                 cg.End();
             }
             else
             {
                 cg.If(cg.This().Field("_assigned_" + fs.ID + "_" + varname) > 0);
                 {
                     cg.Assign(cg.This().Field("_ctxl_" + varname), cg.This().Field("_stack_" + varname).Invoke("Pop"));
                     cg.Assign(cg.This().Field("_assigned_" + fs.ID + "_" + varname), 0);
                 }
                 cg.End();
             }
         }
     }
 }
Example #2
0
        public FieldGen Field(Type type, string name, Operand initialValue)
        {
            FieldGen fld = Field(type, name);

            CodeGen initCode = fld.IsStatic ? StaticConstructor().GetCode(): CommonConstructor().GetCode();

            initCode.Assign(fld, initialValue);
            return(fld);
        }
Example #3
0
 // generates code that resets the lexical slots in the enclosing frame for re-entering
 //   a block (such as in a loop).  Effectively emulates a parameterless closure.
 public void RevertLexicalsIn(FrameScope fs, CodeGen cg)
 {
     foreach (var varname in fs.OwnKeysList)
     {
         if (fs[varname].Type.IsValueType)
         {
             cg.This().Field(fs[varname].MangledName).ForceEmitAddress(cg);
             cg.IL.Emit(OpCodes.Initobj, fs[varname].Type);
         }
         else
         {
             cg.Assign(cg.This().Field(fs[varname].MangledName), null);
         }
     }
 }