The IL instructions for a method
示例#1
0
文件: FCodeEmit.cs 项目: nomit007/f4
        internal FMethodVar[] vars; // method variables must be set for loadVar/storeVar

        #endregion Fields

        #region Constructors

        //////////////////////////////////////////////////////////////////////////
        // Constructor
        //////////////////////////////////////////////////////////////////////////
        public FCodeEmit(FTypeEmit parent, FMethod fmethod, CILInstructions code)
            : this(parent, fmethod.m_code, code,
         initRegs(parent.pod,  fmethod.isStatic(), fmethod.m_vars),
         parent.pod.typeRef(fmethod.m_ret))
        {
            this.fmethod    = fmethod;
              this.vars       = fmethod.m_vars;
              this.isStatic   = (fmethod.m_flags & FConst.Static) != 0;
              this.paramCount = fmethod.m_paramCount;
              if (!isStatic) paramCount++;
        }
示例#2
0
文件: FCodeEmit.cs 项目: nomit007/f4
 public FCodeEmit(FTypeEmit parent, FBuf fcode, CILInstructions code, Reg[] regs, FTypeRef ret)
 {
     this.pod      = parent.pod;
       this.emitter  = parent.emitter;
       this.parent   = parent;
       this.buf      = fcode.m_buf;
       this.len      = fcode.m_len;
       this.code     = code;
       this.podClass = FanUtil.toDotnetTypeName(pod.m_podName, "$Pod", false);
       this.jumps    = new Jumps(code);
       this.regs     = regs;
       this.ret      = ret;
 }
示例#3
0
文件: PERWAPI.cs 项目: nomit007/f4
 /// <summary>
 /// Create a new code block definition
 /// </summary>
 /// <param name="instructions">The buffer the code block relates to</param>
 internal CodeBlock(CILInstructions instructions)
 {
     cilInstr = instructions;
 }
示例#4
0
文件: PERWAPI.cs 项目: nomit007/f4
 internal uint AddCode(CILInstructions byteCode)
 {
     byteCodes.Add(byteCode);
     uint offset = codeSize;
     codeSize += byteCode.GetCodeSize();
     return offset;
 }
示例#5
0
文件: PERWAPI.cs 项目: nomit007/f4
 internal override sealed void BuildTables(MetaDataOut md)
 {
     md.AddToTable(MDTable.Method,this);
     nameIx = md.AddToStringsHeap(name);
     if (genericParams != null) {
         for (int i=0; i < genericParams.Count; i++) {
             ((GenericParam)genericParams[i]).BuildMDTables(md);
         }
     }
     if (security != null) {
         for (int i=0; i < security.Count; i++) {
             ((DeclSecurity)security[i]).BuildMDTables(md);
         }
     }
     if (pinvokeImpl != null) pinvokeImpl.BuildMDTables(md);
     if (entryPoint) md.SetEntryPoint(this);
     if (locals != null) {
         localSig = new LocalSig(locals);
         localSig.BuildMDTables(md);
     }
     try {
         if (code != null) {
             if (code.IsEmpty()) {
                 code = null;
             } else {
                 code.BuildTables(md);
             }
         }
     } catch (InstructionException ex) {
         throw new Exception(ex.AddMethodName(name));
     }
     parIx = md.TableIndex(MDTable.Param);
     for (int i=0; i < sig.numPars; i++) {
         parList[i].seqNo = (ushort)(i+1);
         parList[i].BuildMDTables(md);
     }
     sig.BuildTables(md);
 }
示例#6
0
文件: PERWAPI.cs 项目: nomit007/f4
 /// <summary>
 /// Create a code buffer for this method to add the IL instructions to
 /// </summary>
 /// <returns>a buffer for this method's IL instructions</returns>
 public CILInstructions CreateCodeBuffer()
 {
     code = new CILInstructions(this);
     return code;
 }
示例#7
0
文件: FCodeEmit.cs 项目: nomit007/f4
 private static void loadVar(CILInstructions code, int stackType, int index, int paramCount)
 {
     if (index < paramCount)
       {
     switch (index)
     {
       case 0:  code.Inst(Op.ldarg_0); break;
       case 1:  code.Inst(Op.ldarg_1); break;
       case 2:  code.Inst(Op.ldarg_2); break;
       case 3:  code.Inst(Op.ldarg_3); break;
       default: code.IntInst(IntOp.ldarg, index); break;
     }
       }
       else
       {
     index -= paramCount;
     switch (index)
     {
       case 0:  code.Inst(Op.ldloc_0); break;
       case 1:  code.Inst(Op.ldloc_1); break;
       case 2:  code.Inst(Op.ldloc_2); break;
       case 3:  code.Inst(Op.ldloc_3); break;
       default: code.IntInst(IntOp.ldloc, index); break;
     }
       }
 }
示例#8
0
文件: FCodeEmit.cs 项目: nomit007/f4
 /// <summary>
 /// Load variable onto stack using Java type and java index (which might
 /// not map to Fantom index.  Return next available java index
 /// </summary>
 internal static void loadVar(CILInstructions code, int stackType, int index)
 {
     loadVar(code, stackType, index, Int32.MaxValue);
 }
示例#9
0
文件: FCodeEmit.cs 项目: nomit007/f4
 public Jumps(CILInstructions code)
 {
     this.code = code;
 }