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); } }
private static int substr_pos(Compartment s, Variable v1, Variable v2) { P6any o1 = v1.Fetch(), o2 = v2.Fetch(); int r2; if (o2.Does(s.CodeMO)) { string s1 = o1.mo.mro_raw_Str.Get(v1); Variable no2 = InvokeSub(o2, s.MakeInt(s1.Length)); r2 = (int)no2.Fetch().mo.mro_raw_Numeric.Get(no2); } else { r2 = (int)o2.mo.mro_raw_Numeric.Get(v2); } return r2; }
private static int substr_len(Compartment s, Variable v1, int pos, Variable v3) { P6any o1 = v1.Fetch(), o3 = v3.Fetch(); int r3; if (o3.Does(s.CodeMO)) { string s1 = o1.mo.mro_raw_Str.Get(v1); Variable no3 = InvokeSub(o3, s.MakeInt(s1.Length)); r3 = (int)no3.Fetch().mo.mro_raw_Numeric.Get(no3) - pos; } else { r3 = (int)o3.mo.mro_raw_Numeric.Get(v3); } return r3; }