src/sys/dotnet/fanx/emit/Emitter.cs
/// <summary>
/// Define a new method to emit for the current class.
/// </summary>
Define a new method to emit for the current class.
Define a new method to emit for the current class .
public CILInstructions emitMethod(
      string name, string retType, string[] paramNames, string[] paramTypes,
      MethAttr attr, string[] localNames, string[] localTypes)
    {
      Param[] pars = new Param[paramNames.Length];
      for (int i=0; i<pars.Length; i++)
        pars[i] = new Param(ParamAttr.Default, paramNames[i], findType(paramTypes[i]));
      methodDef = (MethodDef)methods[getMethodKey(className, name, paramTypes)];
      if (methodDef == null)
      {
        methodDef = classDef.AddMethod(attr, ImplAttr.IL, name, findType(retType), pars);
      }
      else
      {
        methodDef.SetMethAttributes(attr);
      }
      if ((attr & MethAttr.Static) != MethAttr.Static)
        methodDef.AddCallConv(CallConv.Instance);
      if (localNames.Length > 0)
      {
        Local[] locals = new Local[localNames.Length];
        for (int i=0; i<locals.Length; i++)
          locals[i] = new Local(localNames[i], findType(localTypes[i]));
        methodDef.AddLocals(locals, true);
      }
      methodDef.SetMaxStack(16 + pars.Length + localNames.Length);
      addToMethodMap(className, name, paramTypes, methodDef);
      if ((attr & MethAttr.Abstract) == MethAttr.Abstract)
        return null;
      return methodDef.CreateCodeBuffer();
    }
public CILInstructions emitMethod ( string name , string retType , string [ ] paramNames , string [ ] paramTypes , MethAttr attr , string [ ] localNames , string [ ] localTypes ) { Param [ ] pars = new Param [ paramNames . Length ] ; for ( int i = 0 ; i < pars . Length ; i ++ ) pars [ i ] = new Param ( ParamAttr . Default , paramNames [ i ] , findType ( paramTypes [ i ] ) ) ; methodDef = ( MethodDef ) methods [ getMethodKey ( className , name , paramTypes ) ] ; if ( methodDef == null ) { methodDef = classDef . AddMethod ( attr , ImplAttr . IL , name , findType ( retType ) , pars ) ; } else { methodDef . SetMethAttributes ( attr ) ; } if ( ( attr & MethAttr . Static ) != MethAttr . Static ) methodDef . AddCallConv ( CallConv . Instance ) ; if ( localNames . Length > 0 ) { Local [ ] locals = new Local [ localNames . Length ] ; for ( int i = 0 ; i < locals . Length ; i ++ ) locals [ i ] = new Local ( localNames [ i ] , findType ( localTypes [ i ] ) ) ; methodDef . AddLocals ( locals , true ) ; } methodDef . SetMaxStack ( 16 + pars . Length + localNames . Length ) ; addToMethodMap ( className , name , paramTypes , methodDef ) ; if ( ( attr & MethAttr . Abstract ) == MethAttr . Abstract ) return null ; return methodDef . CreateCodeBuffer ( ) ; }
Define a new method to emit for the current class.
Define a new method to emit for the current class .
// first check if this method was already stubbed out // if not, we need to create it // if stubbed out, make sure we define the method correctly // TODO - what the fuck should this be? // add to lookup table // don't create code buffer if abstract
name
string
retType
string
paramNames
string[]
paramTypes
string[]
attr
MethAttr
localNames
string[]
localTypes
string[]