当前位置: 首页>>代码示例>>C#>>正文


C# Variable.Fetch方法代码示例

本文整理汇总了C#中Variable.Fetch方法的典型用法代码示例。如果您正苦于以下问题:C# Variable.Fetch方法的具体用法?C# Variable.Fetch怎么用?C# Variable.Fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Variable的用法示例。


在下文中一共展示了Variable.Fetch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetRanges

        public override int[] GetRanges(Variable filter) {
            bool[] cfilter = new bool[values.Length];
            var setting = filter.Fetch().mo.setting;
            // minor hack to make :BoolProp work - converts to True/False
            if (filter.Fetch().Isa(setting.BoolMO))
                filter = filter.Fetch().mo.mro_Str.Get(filter);
            for (int i = 0; i < values.Length; i++) {
                foreach (string s in values[i]) {
                    if (DoMatch(s, filter)) {
                        cfilter[i] = true;
                        break;
                    }
                }
            }

            List<int> res = new List<int>();
            for (int i = 0; i < data.Length; i += 2) {
                if (cfilter[data[i+1]]) {
                    int upto = (i+2 == data.Length) ? 0x110000 : data[i+2];
                    if (res.Count > 0 && res[res.Count-1] == data[i]) {
                        res[res.Count-1] = upto;
                    } else {
                        res.Add(data[i]);
                        res.Add(upto);
                    }
                }
            }

            return res.ToArray();
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-niecza-sorear,代码行数:30,代码来源:UCD.cs

示例2: DCArg

 internal static object DCArg(Variable v) {
     P6any o = v.Fetch();
     var s = o.mo.setting;
     if (o is BoxObject<object>)
         return Kernel.UnboxAny<object>(o);
     else if (o.IsDefined()) {
         if (o.Isa(s.StrMO))
             return (string) o.mo.mro_raw_Str.Get(v);
         else if (o.Isa(s.BoolMO))
             return (bool) o.mo.mro_raw_Bool.Get(v);
         else if (o.Isa(s.NumMO)) {
             double d = Kernel.UnboxAny<double>(o);
             if ((d % 1) == 0 && d <= int.MaxValue && d >= int.MinValue)
                 return (object)(int)d;
             return (object)d;
         } else if (o.Isa(s.ListMO)) {
             VarDeque it = o.mo.mro_raw_iterator.Get(v);
             var lo = new List<object>();
             while (Kernel.IterHasFlat(it, true))
                 lo.Add(DCArg(it.Shift()));
             return lo.ToArray();
         } else
             return (int) o.mo.mro_raw_Numeric.Get(v);
     } else
         return null;
 }
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-niecza-sorear,代码行数:26,代码来源:CompilerBinding.cs

示例3: AssignV

 public static void AssignV(Variable lhs, IP6 rhs)
 {
     if (!lhs.islist) {
         lhs.Store(rhs);
     } else {
         Frame n = lhs.Fetch().InvokeMethod(Kernel.GetInferiorRoot(),
                 "LISTSTORE",
                 new Variable[2] { lhs, Kernel.NewROScalar(rhs) }, null);
         Kernel.RunInferior(n);
     }
 }
开发者ID:pmurias,项目名称:niecza,代码行数:11,代码来源:Builtins.cs

示例4: CompileCClass

 public static object CompileCClass(Variable pair)
 {
     P6any pairo = pair.Fetch();
     Variable tbl = (Variable)pairo.GetSlot(Kernel.EnumMO, "$!key");
     Variable sm =  (Variable)pairo.GetSlot(Kernel.EnumMO, "$!value");
     Property p = (Property)DataSet.GetTable(
             tbl.Fetch().mo.mro_raw_Str.Get(tbl));
     int[] rranges = p.GetRanges(sm);
     object[] cranges = new object[rranges.Length * 2];
     for (int i = 0; i < rranges.Length; i++) {
         cranges[2*i] = rranges[i];
         cranges[2*i+1] = ((i & 1) != 0) ? 0 : 0x3FFFFFFF;
     }
     return cranges;
 }
开发者ID:FROGGS,项目名称:niecza,代码行数:15,代码来源:UCD.cs

示例5: tan

    [ImplicitConsts] public static Variable tan(Constants c, Variable a1) {
        P6any o1 = a1.Fetch();
        int r1;
        if (!o1.mo.is_any)
            return HandleSpecial1(c, a1,o1, tan_d);
        P6any n1 = GetNumber(a1, o1, out r1);

        if (r1 == NR_COMPLEX) {
            Complex v1 = PromoteToComplex(r1, n1);
            return c.setting.MakeComplex(v1.Tan());
        }
        {
            double v1 = PromoteToFloat(r1, n1);
            return c.setting.MakeFloat(Math.Tan(v1));
        }
    }
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-niecza-sorear,代码行数:16,代码来源:GeneratedTrigFunctions.cs

示例6: acosec

    public static Variable acosec(Variable a1)
    {
        P6any o1 = a1.Fetch();
        int r1;
        if (!o1.mo.is_any)
            return HandleSpecial1(a1,o1, acosec_d);
        P6any n1 = GetNumber(a1, o1, out r1);

        if (r1 == NR_COMPLEX) {
            Complex v1 = PromoteToComplex(r1, n1);
            return MakeComplex(v1.Acosec());
        }
        {
            double v1 = PromoteToFloat(r1, n1);
            return MakeFloat(Math.Asin(1 / v1));
        }
    }
开发者ID:nbrown,项目名称:niecza,代码行数:17,代码来源:GeneratedTrigFunctions.cs

示例7: cursor_allcaps

    public static Variable cursor_allcaps(Variable cv)
    {
        Cursor c = (Cursor) cv.Fetch();
        VarDeque dq = new VarDeque();

        for (CapInfo it = c.captures; it != null; it = it.prev) {
            if (it.names[0] == null || it.cap == null)
                continue; // special node
            if (!it.cap.Fetch().Isa(Kernel.MatchMO))
                continue;
            foreach (string name in it.names)
                dq.Unshift(pair(MakeStr(name), it.cap));
        }

        P6opaque lst = new P6opaque(Kernel.ListMO);
        lst.slots[0 /*items*/] = dq;
        lst.slots[1 /*rest*/ ] = new VarDeque();
        return Kernel.NewRWListVar(lst);
    }
开发者ID:nbrown,项目名称:niecza,代码行数:19,代码来源:Cursor.cs

示例8: acosech

    public static Variable acosech(Variable a1)
    {
        P6any o1 = a1.Fetch();
        int r1;
        if (!o1.mo.is_any)
            return HandleSpecial1(a1,o1, acosech_d);
        P6any n1 = GetNumber(a1, o1, out r1);

        if (r1 == NR_COMPLEX) {
            Complex v1 = PromoteToComplex(r1, n1);
            return MakeComplex(v1.Acosech());
        }
        {
            Complex v1 = PromoteToComplex(r1, n1);
            Complex v2 = v1.Acosech();
            if (v2.im < -1e-15 || v2.im > 1e-15) {
                return MakeFloat(double.NaN);
            } else {
                return MakeFloat(v2.re);
            }
        }
    }
开发者ID:nbrown,项目名称:niecza,代码行数:22,代码来源:GeneratedTrigFunctions.cs

示例9: divide

    public static Variable divide(Variable a1, Variable a2)
    {
        int r1, r2;
        P6any o1 = a1.Fetch(), o2 = a2.Fetch();
        if (!(o1.mo.is_any && o2.mo.is_any))
            return HandleSpecial2(a1,a2, o1,o2, divide_d);
        P6any n1 = GetNumber(a1, o1, out r1);
        P6any n2 = GetNumber(a2, o2, out r2);

        if (r1 == NR_COMPLEX || r2 == NR_COMPLEX) {
            Complex v1 = PromoteToComplex(r1, n1);
            Complex v2 = PromoteToComplex(r2, n2);
            double sn2 = v2.re*v2.re + v2.im*v2.im;
            return MakeComplex((v1.re*v2.re + v1.im*v2.im)/sn2,
                    (v2.re*v1.im - v2.im*v1.re)/sn2);
        }
        if (r1 == NR_FLOAT || r2 == NR_FLOAT) {
            return MakeFloat(PromoteToFloat(r1, n1) / PromoteToFloat(r2, n2));
        }
        if (r1 == NR_FATRAT || r2 == NR_FATRAT) {
            FatRat v1 = PromoteToFatRat(r1, n1);
            FatRat v2 = PromoteToFatRat(r2, n2);

            return MakeFatRat(v1.num*v2.den, v1.den*v2.num);
        }
        if (r1 == NR_FIXRAT || r2 == NR_FIXRAT) {
            Rat v1 = PromoteToFixRat(r1, n1);
            Rat v2 = PromoteToFixRat(r2, n2);

            return MakeFixRat(v1.num*v2.den, v2.num*v1.den);
        }
        if (r1 == NR_BIGINT || r2 == NR_BIGINT) {
            return MakeFixRat(PromoteToBigInt(r1, n1), PromoteToBigInt(r2, n2));
        }
        return MakeFixRat(PromoteToFixInt(r1, n1), PromoteToFixInt(r2, n2));
    }
开发者ID:ebassi,项目名称:niecza,代码行数:36,代码来源:Builtins.cs

示例10: sech

    [ImplicitConsts] public static Variable sech(Constants c, Variable a1) {
        P6any o1 = a1.Fetch();
        int r1;
        if (!o1.mo.is_any)
            return HandleSpecial1(c, a1,o1, sech_d);
        P6any n1 = GetNumber(a1, o1, out r1);

        if (r1 == NR_COMPLEX) {
            Complex v1 = PromoteToComplex(r1, n1);
            return c.setting.MakeComplex(v1.Sech());
        }
        {
            Complex v1 = PromoteToComplex(r1, n1);
            Complex v2 = v1.Sech();
            if (v2.im < -1e-15 || v2.im > 1e-15) {
                return c.setting.MakeFloat(double.NaN);
            } else {
                return c.setting.MakeFloat(v2.re);
            }
        }
    }
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-niecza-sorear,代码行数:21,代码来源:GeneratedTrigFunctions.cs

示例11: GetAsRational

    // Coerce a number to a real rational value - note that this loses
    // the "inexact" annotation carried by Nums
    public static void GetAsRational(Variable v,
            out BigInteger num, out BigInteger den)
    {
        int rk;
        P6any n = GetNumber(v, v.Fetch(), out rk);

        if (rk == NR_COMPLEX || rk == NR_FLOAT) {
            double dbl = 0;
            if (rk == NR_COMPLEX) {
                Complex c = Kernel.UnboxAny<Complex>(n);
                if (c.im != 0)
                    throw new NieczaException("Complex cannot be used here");
                dbl = c.re;
            } else {
                dbl = Kernel.UnboxAny<double>(n);
            }
            ulong bits = (ulong)BitConverter.DoubleToInt64Bits(dbl);
            num = (bits & ((1UL << 52) - 1)) + (1UL << 52);
            den = (1UL << 52);
            if ((bits & (1UL << 63)) != 0) num = -num;
            int power = ((int)((bits >> 52) & 0x7FF)) - 0x3FF;
            if (power > 0) num <<= power;
            else den <<= -power;
            SimplifyFrac(ref num, ref den);
        }
        else if (rk == NR_FATRAT) {
            FatRat r = Kernel.UnboxAny<FatRat>(n);
            num = r.num; den = r.den;
        }
        else if (rk == NR_FIXRAT) {
            Rat r = Kernel.UnboxAny<Rat>(n);
            num = r.num; den = r.den;
        }
        else if (rk == NR_BIGINT) {
            num = Kernel.UnboxAny<BigInteger>(n); den = BigInteger.One;
        }
        else {
            num = Kernel.UnboxAny<int>(n); den = BigInteger.One;
        }
    }
开发者ID:ebassi,项目名称:niecza,代码行数:42,代码来源:Builtins.cs

示例12: GetAsInteger

    // Coerce a real number to an integer, truncating towards 0
    public static bool GetAsInteger(Variable v, out int small,
            out BigInteger big)
    {
        int rk;
        P6any n = GetNumber(v, v.Fetch(), out rk);
        small = 0;

        if (rk == NR_COMPLEX || rk == NR_FLOAT) {
            double dbl = 0;
            if (rk == NR_COMPLEX) {
                Complex c = Kernel.UnboxAny<Complex>(n);
                if (c.im != 0)
                    throw new NieczaException("Complex cannot be used here");
                dbl = c.re;
            } else {
                dbl = Kernel.UnboxAny<double>(n);
            }
            ulong bits = (ulong)BitConverter.DoubleToInt64Bits(dbl);
            big = (bits & ((1UL << 52) - 1)) + (1UL << 52);
            int power = ((int)((bits >> 52) & 0x7FF)) - 0x433;
            if (power > 0) big <<= power;
            else big >>= -power;
            if ((bits & (1UL << 63)) != 0) big = -big;
        }
        else if (rk == NR_FATRAT) {
            FatRat r = Kernel.UnboxAny<FatRat>(n);
            big = r.num / r.den;
        }
        else if (rk == NR_FIXRAT) {
            Rat r = Kernel.UnboxAny<Rat>(n);
            big = r.num / r.den;
        }
        else if (rk == NR_BIGINT) {
            big = Kernel.UnboxAny<BigInteger>(n);
        }
        else {
            big = BigInteger.Zero; small = Kernel.UnboxAny<int>(n); return false;
        }
        return true;
    }
开发者ID:ebassi,项目名称:niecza,代码行数:41,代码来源:Builtins.cs

示例13: cb_finish

 public static Variable cb_finish(Variable si, Variable nam) {
     StringBuilder sb = new StringBuilder();
     List<object> refs = new List<object>();
     Downcaller.SerializeNam(nam, sb, refs);
     object[] args = new object[refs.Count + 3];
     args[0] = "sub_finish";
     args[1] = Kernel.UnboxAny<object>(si.Fetch());
     args[2] = sb.ToString();
     refs.CopyTo(args, 3);
     return Downcaller.DCResult(si.Fetch().mo.setting, Downcaller.RawDowncall(args));
 }
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-niecza-sorear,代码行数:11,代码来源:CompilerBinding.cs

示例14: cb_init_slave

    // Better, but still fudgy.  Relies too much on path structure.
    public static void cb_init_slave(Variable cb, P6any cmd_obj_dir, Variable unit,
            Variable staticSub, Variable type, Variable param, Variable value) {
        if (Downcaller.responder != null) return;

        Downcaller.UnitP = unit.Fetch();
        Downcaller.StaticSubP = staticSub.Fetch();
        Downcaller.TypeP = type.Fetch();
        Downcaller.ParamP = param.Fetch();
        Downcaller.ValueP = value.Fetch();

        string[] obj_dirs =
            !cmd_obj_dir.IsDefined() ? new string[0] :
            cmd_obj_dir.Isa(cmd_obj_dir.mo.setting.StrMO) ?
                new string[] { cmd_obj_dir.mo.mro_raw_Str.Get(cmd_obj_dir) } :
            Builtins.UnboxLoS(Kernel.NewRWListVar(cmd_obj_dir)) ;

        if (obj_dirs.Length == 0) {
            obj_dirs = new string[2];
            obj_dirs[0] = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Path.Combine("..", "obj"));
            obj_dirs[1] = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "NieczaModuleCache");
        }

        for (int i = 0; i < obj_dirs.Length; i++) {
            Directory.CreateDirectory(obj_dirs[i]); // mkdir -p
            obj_dirs[i] = Path.GetFullPath(obj_dirs[i]);
        }

        Downcaller.obj_dirs = obj_dirs;

        Downcaller.upcall_cb = cb;
        Downcaller.responder = (IDictionary) new Niecza.CLRBackend.DowncallReceiver();
    }
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-niecza-sorear,代码行数:33,代码来源:CompilerBinding.cs

示例15: SerializeNam

        internal static void SerializeNam(Variable v, StringBuilder sb,
                List<object> refs) {

            P6any o = v.Fetch();
            if (o is BoxObject<int>) { /* includes bool */
                sb.Append(Kernel.UnboxAny<int>(o));
            } else if (o is BoxObject<double>) {
                sb.Append(Utils.N2S(Kernel.UnboxAny<double>(o)));
            } else if (o is BoxObject<string>) {
                string s = Kernel.UnboxAny<string>(o);
                sb.Append('"');
                foreach (char c in s) {
                    if (c >= ' ' && c <= '~' && c != '\\' && c != '"')
                        sb.Append(c);
                    else {
                        sb.Append("\\u");
                        sb.AppendFormat("{0:X4}", (int)c);
                    }
                }
                sb.Append('"');
            } else if (!o.IsDefined()) {
                sb.Append("null");
            } else if (o.Isa(o.mo.setting.ListMO)) {
                VarDeque d = o.mo.mro_raw_iterator.Get(v);
                bool comma = false;
                sb.Append('[');
                while (Kernel.IterHasFlat(d, true)) {
                    if (comma) sb.Append(',');
                    SerializeNam(d.Shift(), sb, refs);
                    comma = true;
                }
                sb.Append(']');
            } else if (o is BoxObject<object>) {
                sb.Append('!');
                sb.Append(refs.Count);
                refs.Add(Kernel.UnboxAny<object>(o));
            } else {
                throw new NieczaException("weird object in sub_finish " + o.mo.name);
            }
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-niecza-sorear,代码行数:40,代码来源:CompilerBinding.cs


注:本文中的Variable.Fetch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。