src/sys/dotnet/fanx/emit/Emitter.cs
/// <summary>
/// Find the Method for this method on the given type.
/// </summary>
Find the Method for this method on the given type.
Find the Method for this method on the given type .
internal Method findMethod(string qname, string methodName, string[] paramTypes, string returnType)
    {
      string key = getMethodKey(qname, methodName, paramTypes);
      Method method = (Method)methods[key];
      if (method == null)
      {
        PERWAPI.Type rtype = findType(returnType);
        PERWAPI.Type[] pars = new PERWAPI.Type[paramTypes.Length];
        for (int i=0; i<paramTypes.Length; i++)
          pars[i] = findType(paramTypes[i]);
        object obj = findType(qname);
        if (obj is ClassDef)
        {
          ClassDef cdef = obj as ClassDef;
          Param[] mpars = new Param[pars.Length];
          for (int i=0; i<mpars.Length; i++)
            mpars[i] = new Param(ParamAttr.Default, "v"+i, pars[i]);
          method = cdef.AddMethod(MethAttr.Public, ImplAttr.IL, methodName, rtype, mpars);
        }
        else if (obj is ClassRef)
        {
          ClassRef cref = obj as ClassRef;
          method = cref.GetMethod(methodName, pars, new PERWAPI.Type[0]);
          if (method == null) method = cref.AddMethod(methodName, rtype, pars);
        }
        else throw new System.Exception("Don't know how to handle: " + obj.GetType());
        methods[key] = method;
      }
      return method;
    }
internal Method findMethod ( string qname , string methodName , string [ ] paramTypes , string returnType ) { string key = getMethodKey ( qname , methodName , paramTypes ) ; Method method = ( Method ) methods [ key ] ; if ( method == null ) { PERWAPI . Type rtype = findType ( returnType ) ; PERWAPI . Type [ ] pars = new PERWAPI . Type [ paramTypes . Length ] ; for ( int i = 0 ; i < paramTypes . Length ; i ++ ) pars [ i ] = findType ( paramTypes [ i ] ) ; object obj = findType ( qname ) ; if ( obj is ClassDef ) { ClassDef cdef = obj as ClassDef ; Param [ ] mpars = new Param [ pars . Length ] ; for ( int i = 0 ; i < mpars . Length ; i ++ ) mpars [ i ] = new Param ( ParamAttr . Default , " " + i , pars [ i ] ) ; method = cdef . AddMethod ( MethAttr . Public , ImplAttr . IL , methodName , rtype , mpars ) ; } else if ( obj is ClassRef ) { ClassRef cref = obj as ClassRef ; method = cref . GetMethod ( methodName , pars , new PERWAPI . Type [ 0 ] ) ; if ( method == null ) method = cref . AddMethod ( methodName , rtype , pars ) ; } else throw new System . Exception ( " " + obj . GetType ( ) ) ; methods [ key ] = method ; } return method ; }
Find the Method for this method on the given type.
Find the Method for this method on the given type .
// this stuff should be the same for both cases // check for stubs // class is an internal stub, so we need to stub this // method out too, which should get flushed out later // TODO - need to fix attrs // TODO - fix param names // Use Public here for stub - real MethAttr will be set // when method is flushed out // class is external, just get or add ref // make sure we add method to hashtable
qname
string
methodName
string
paramTypes
string[]
returnType
string