callOn() public method

public callOn ( object target, List args ) : object
target object
args List
return object
Example #1
0
File: Fan.cs Project: xored/f4
        static int callMain(Type t, Method m)
        {
            // check parameter type and build main arguments
              List args;
              List pars = m.@params();
              if (pars.sz() == 0)
              {
            args = null;
              }
              else if (((Param)pars.get(0)).type().@is(Sys.StrType.toListOf()) &&
               (pars.sz() == 1 || ((Param)pars.get(1)).hasDefault()))
              {
            args = new List(Sys.ObjType, new object[] { Env.cur().args() });
              }
              else
              {
            System.Console.WriteLine("ERROR: Invalid parameters for main: " + m.signature());
            return -1;
              }

              // invoke
              try
              {
            if (m.isStatic())
              return toResult(m.callList(args));
            else
              return toResult(m.callOn(t.make(), args));
              }
              catch (Err.Val ex)
              {
            ex.err().trace();
            return -1;
              }
        }