예제 #1
0
 internal static Variable DCResult(Compartment s, object r)
 {
     if (r == null)
     {
         return(s.AnyMO.typeObj);
     }
     else if (r is string)
     {
         return(s.MakeStr((string)r));
     }
     else if (r is int)
     {
         return(s.MakeInt((int)r));
     }
     else if (r is bool)
     {
         return(((bool)r) ? s.TrueV : s.FalseV);
     }
     else if (r is Exception)
     {
         throw new NieczaException(((Exception)r).Message);
     }
     else if (r is object[])
     {
         object[]   ra = (object[])r;
         Variable[] ba = new Variable[ra.Length];
         for (int i = 0; i < ba.Length; i++)
         {
             ba[i] = DCResult(s, ra[i]);
         }
         return(s.MakeParcel(ba));
     }
     else
     {
         string t  = (string)RawDowncall("gettype", r);
         P6any  pr = (t == "type") ? TypeP :
                     (t == "sub") ? StaticSubP :
                     (t == "param") ? ParamP :
                     (t == "value") ? ValueP :
                     (t == "unit") ? UnitP : s.AnyMO.typeObj;
         return(Kernel.BoxAnyMO(r, pr.mo));
     }
 }
 internal static Variable DCResult(Compartment s, object r) {
     if (r == null) return s.AnyMO.typeObj;
     else if (r is string) return s.MakeStr((string)r);
     else if (r is int) return s.MakeInt((int)r);
     else if (r is bool) return ((bool)r) ? s.TrueV : s.FalseV;
     else if (r is Exception) throw new NieczaException(((Exception)r).Message);
     else if (r is object[]) {
         object[] ra = (object[])r;
         Variable[] ba = new Variable[ra.Length];
         for (int i = 0; i < ba.Length; i++) ba[i] = DCResult(s,ra[i]);
         return s.MakeParcel(ba);
     }
     else {
         string t = (string)RawDowncall("gettype", r);
         P6any pr = (t == "type") ? TypeP :
             (t == "sub") ? StaticSubP :
             (t == "param") ? ParamP :
             (t == "value") ? ValueP :
             (t == "unit") ? UnitP : s.AnyMO.typeObj;
         return Kernel.BoxAnyMO(r, pr.mo);
     }
 }