diff options
Diffstat (limited to 'src/cli/runtime/Reflector.cs')
-rw-r--r-- | src/cli/runtime/Reflector.cs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/cli/runtime/Reflector.cs b/src/cli/runtime/Reflector.cs index e198661b..483c4029 100644 --- a/src/cli/runtime/Reflector.cs +++ b/src/cli/runtime/Reflector.cs @@ -154,7 +154,7 @@ public static Object invokeInstanceMember(String name, Object target) //throws E return methods;
}
-static Object boxArg(Type paramType, Object arg)
{
Type argType = arg.GetType();
if(paramType == argType)
return arg;
if(paramType == typeof(bool))
{
return arg != null;
}
else if(paramType.IsPrimitive && arg is Num)
{
Num n = (Num) arg;
if(paramType == typeof(int))
return RT.box(n.intValue());
else if(paramType == typeof(float))
return RT.box(n.floatValue());
else if(paramType == typeof(double))
return RT.box(n.doubleValue());
else if(paramType == typeof(long))
return RT.box(n.longValue());
else if(paramType == typeof(char))
return RT.box((char) n.intValue());
else if(paramType == typeof(short))
return RT.box(n.shortValue());
else if(paramType == typeof(byte))
return RT.box(n.byteValue());
else
throw new ArgumentException("Cannot convert to primitive type: " + paramType.Name);
}
else
return arg;
}
static Object[] boxArgs(ParameterInfo[] parms, Object[] args)
{
if(parms.Length == 0)
return null;
Object[] ret = new Object[parms.Length];
for(int i = 0; i < parms.Length; i++)
{
Object arg = args[i];
Type paramType = parms[i].ParameterType;
ret[i] = boxArg(paramType, arg);
}
return ret;
}
+static Object boxArg(Type paramType, Object arg)
{
Type argType = arg.GetType();
if(paramType == argType)
return arg;
if(paramType == typeof(bool))
{
return arg != null;
}
else if(paramType.IsPrimitive && arg is Num)
{
Num n = (Num) arg;
if(paramType == typeof(int))
return n.intValue();
else if(paramType == typeof(float))
return n.floatValue();
else if(paramType == typeof(double))
return n.doubleValue();
else if(paramType == typeof(long))
return n.longValue();
else if(paramType == typeof(char))
return (char) n.intValue();
else if(paramType == typeof(short))
return n.shortValue();
else if(paramType == typeof(byte))
return n.byteValue();
else
throw new ArgumentException("Cannot convert to primitive type: " + paramType.Name);
}
else
return arg;
}
static Object[] boxArgs(ParameterInfo[] parms, Object[] args)
{
if(parms.Length == 0)
return null;
Object[] ret = new Object[parms.Length];
for(int i = 0; i < parms.Length; i++)
{
Object arg = args[i];
Type paramType = parms[i].ParameterType;
ret[i] = boxArg(paramType, arg);
}
return ret;
}
static Object prepRet(Object x)
{
|