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


C# runtime.Runtime类代码示例

本文整理汇总了C#中org.mbarbon.p.runtime.Runtime的典型用法代码示例。如果您正苦于以下问题:C# org.mbarbon.p.runtime.Runtime类的具体用法?C# org.mbarbon.p.runtime.Runtime怎么用?C# org.mbarbon.p.runtime.Runtime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


org.mbarbon.p.runtime.Runtime类属于命名空间,在下文中一共展示了org.mbarbon.p.runtime.Runtime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: P5MainSymbolTable

        public P5MainSymbolTable(Runtime runtime, string name)
            : base(runtime, name)
        {
            var stdout = GetStashGlob(runtime, "STDOUT", true);
            stdout.Handle = new P5Handle(runtime, null, System.Console.Out);

            var stdin = GetStashGlob(runtime, "STDIN", true);
            stdin.Handle = new P5Handle(runtime, System.Console.In, null);

            var stderr = GetStashGlob(runtime, "STDERR", true);
            stderr.Handle = new P5Handle(runtime, null, System.Console.Error);

            var dquote = GetStashGlob(runtime, "\"", true);
            dquote.Scalar = new P5Scalar(runtime, " ");

            var version = GetStashGlob(runtime, "]", true);
            version.Scalar = new P5Scalar(runtime, 5.008);

            // UNIVERSAL
            universal = GetPackage(runtime, "UNIVERSAL", true);

            var isa = universal.GetStashGlob(runtime, "isa", true);
            isa.Code = new P5NativeCode("UNIVERSAL::isa", new P5Code.Sub(WrapIsa));

            // Internals
            var internals = GetPackage(runtime, "Internals", true);

            var add_overload = internals.GetStashGlob(runtime, "add_overload", true);
            add_overload.Code = new P5NativeCode("Internals::add_overload", new P5Code.Sub(WrapAddOverload));

            // Internals::Net (TODO move to external assembly)
            var internals_net = GetPackage(runtime, "Internals::Net", true);

            var get_class = internals_net.GetStashGlob(runtime, "get_class", true);
            get_class.Code = new P5NativeCode("Internals::Net::get_class", new P5Code.Sub(WrapGetClass));

            var specialize_type = internals_net.GetStashGlob(runtime, "specialize_type", true);
            specialize_type.Code = new P5NativeCode("Internals::Net::specialize_type", new P5Code.Sub(WrapSpecializeType));

            var create = internals_net.GetStashGlob(runtime, "create", true);
            create.Code = new P5NativeCode("Internals::Net::create", new P5Code.Sub(WrapCreate));

            var call_method = internals_net.GetStashGlob(runtime, "call_method", true);
            call_method.Code = new P5NativeCode("Internals::Net::call_mehtod", new P5Code.Sub(WrapCallMethod));

            var call_static = internals_net.GetStashGlob(runtime, "call_static", true);
            call_static.Code = new P5NativeCode("Internals::Net::call_static", new P5Code.Sub(WrapCallStatic));

            var get_property = internals_net.GetStashGlob(runtime, "get_property", true);
            get_property.Code = new P5NativeCode("Internals::Net::get_property", new P5Code.Sub(WrapGetProperty));

            var set_property = internals_net.GetStashGlob(runtime, "set_property", true);
            set_property.Code = new P5NativeCode("Internals::Net::set_property", new P5Code.Sub(WrapSetProperty));

            var extend = internals_net.GetStashGlob(runtime, "extend", true);
            extend.Code = new P5NativeCode("Internals::Net::extend", new P5Code.Sub(WrapExtend));

            var compile = internals_net.GetStashGlob(runtime, "compile_assembly", true);
            compile.Code = new P5NativeCode("Internals::Net::compile_assembly", new P5Code.Sub(WrapCompileAssembly));
        }
开发者ID:mbarbon,项目名称:language-p-net,代码行数:60,代码来源:SymbolTable.cs

示例2: Assign

        public override P5Scalar Assign(Runtime runtime, IP5Any other)
        {
            var ob = other.AsScalar(runtime).Body;
            var obr = ob as P5Reference;
            var obb = ob as P5TypeglobBody;

            if (obb != null)
                body = globBody = obb;
            else if (obr != null)
            {
                var referred = obr.Referred;
                var code = referred as P5Code;
                var scalar = referred as P5Scalar;
                var array = referred as P5Array;
                var hash = referred as P5Hash;

                if (code != null)
                    globBody.Code = code;
                else if (scalar != null)
                    globBody.Scalar = scalar;
                else if (array != null)
                    globBody.Array = array;
                else if (hash != null)
                    globBody.Hash = hash;
            }
            else
            {
                throw new System.NotImplementedException("Assign either glob or reference");
            }

            return this;
        }
开发者ID:mbarbon,项目名称:language-p-net,代码行数:32,代码来源:Typeglob.cs

示例3: AsString

        public string AsString(Runtime runtime)
        {
            if (reference != null)
                return reference.AsString(runtime);

            return Message;
        }
开发者ID:mbarbon,项目名称:language-p-net,代码行数:7,代码来源:Exception.cs

示例4: P5StringNumber

 private P5StringNumber(Runtime runtime, int f, int ival, string sval, double fval)
 {
     flags = f;
     integerValue = ival;
     stringValue = sval;
     floatValue = fval;
 }
开发者ID:mbarbon,项目名称:language-p-net,代码行数:7,代码来源:StringNumber.cs

示例5: AsInteger

        public virtual int AsInteger(Runtime runtime)
        {
            if ((flags & HasString) != 0) return Builtins.ParseInteger(stringValue);
            if ((flags & HasInteger) != 0) return integerValue;
            if ((flags & HasFloat) != 0) return (int)floatValue;

            throw new System.Exception();
        }
开发者ID:mbarbon,项目名称:language-p-net,代码行数:8,代码来源:StringNumber.cs

示例6: Assign

        public virtual IP5ScalarBody Assign(Runtime runtime, IP5ScalarBody other)
        {
            var osn = other as P5Reference;

            if (osn == null)
                return other.CloneBody(runtime);

            referred = osn.referred;

            return this;
        }
开发者ID:mbarbon,项目名称:language-p-net,代码行数:11,代码来源:Reference.cs

示例7: AssignIterator

        public override IP5Any AssignIterator(Runtime runtime, IEnumerator<IP5Any> e)
        {
            for (int i = 0; i < array.Count; ++i)
            {
                if (e.MoveNext())
                    array[i] = NetGlue.UnwrapValue<object>(runtime, e.Current);
                else
                    array[i] = null;
            }

            return this;
        }
开发者ID:mbarbon,项目名称:language-p-net,代码行数:12,代码来源:NetArray.cs

示例8: AsInteger

        public virtual int AsInteger(Runtime runtime)
        {
            if (referred as P5Scalar != null)
            {
                var wrapper = (referred as P5Scalar).Body as P5NetWrapper;

                if (wrapper != null)
                    return (int)IdDispenser.GetId(wrapper.Object);
            }

            // TODO maybe use long everywhere
            return (int)IdDispenser.GetId(referred);
        }
开发者ID:mbarbon,项目名称:language-p-net,代码行数:13,代码来源:Reference.cs

示例9: AsBoolean

        public bool AsBoolean(Runtime runtime)
        {
            var type = obj.GetType();

            if (type == typeof(double))
                return (double)obj != 0.0;
            if (type == typeof(int))
                return (int)obj != 0;
            if (type == typeof(string))
                return (string)obj != "";
            if (type == typeof(bool))
                return (bool)obj;

            return obj != null;
        }
开发者ID:mbarbon,项目名称:language-p-net,代码行数:15,代码来源:NetWrapper.cs

示例10: Assign

        public virtual IP5ScalarBody Assign(Runtime runtime, IP5ScalarBody other)
        {
            var osb = other as P5StringNumber;

            if (osb == null)
                return other.CloneBody(runtime);

            flags = osb.flags;
            pos = -1;
            pos_set = false;
            stringValue = osb.stringValue;
            integerValue = osb.integerValue;
            floatValue = osb.floatValue;

            return this;
        }
开发者ID:mbarbon,项目名称:language-p-net,代码行数:16,代码来源:StringNumber.cs

示例11: AsString

        public virtual string AsString(Runtime runtime)
        {
            var rx = referred as IP5Regex;

            // TODO use overloading
            if (rx != null)
                return rx.GetOriginal();
            if (referred.IsBlessed(runtime))
                return string.Format("{2:s}={0:s}(0x{1:x8})",
                                     referred.ReferenceTypeString(runtime),
                                     AsInteger(runtime),
                                     referred.Blessed(runtime).GetName(runtime));
            else
                return string.Format("{0:s}(0x{1:x8})",
                                     referred.ReferenceTypeString(runtime),
                                     AsInteger(runtime));
        }
开发者ID:mbarbon,项目名称:language-p-net,代码行数:17,代码来源:Reference.cs

示例12: AsInteger

        public int AsInteger(Runtime runtime)
        {
            var type = obj.GetType();

            if (type == typeof(int))
                return (int)obj;
            if (type == typeof(double))
                return (int)(double)obj;
            if (type == typeof(char))
                return (int)(char)obj;
            if (type == typeof(bool))
                return (bool)obj ? 1 : 0;
            if (type == typeof(string))
                return Builtins.ParseInteger((string)obj);
            if (type.IsEnum)
                return System.Convert.ToInt32(obj);

            throw new System.NotImplementedException(string.Format("Integer coercion not implemented for {0:S}", type));
        }
开发者ID:mbarbon,项目名称:language-p-net,代码行数:19,代码来源:NetWrapper.cs

示例13: AsFloat

        public double AsFloat(Runtime runtime)
        {
            var type = obj.GetType();

            if (type == typeof(double))
                return (double)obj;
            if (type == typeof(int))
                return (double)(int)obj;
            if (type == typeof(char))
                return (double)(char)obj;
            if (type == typeof(bool))
                return (bool)obj ? 1.0 : 0.0;
            if (type.IsEnum)
                return System.Convert.ToDouble(obj);

            // TODO string

            throw new System.NotImplementedException(string.Format("Float coercion not implemented for {0:S}", type));
        }
开发者ID:mbarbon,项目名称:language-p-net,代码行数:19,代码来源:NetWrapper.cs

示例14: AssignArray

        public override int AssignArray(Runtime runtime, IP5Value other)
        {
            // FIXME multiple dispatch
            P5Scalar s = other as P5Scalar;
            P5Array a = other as P5Array;
            IEnumerator<IP5Any> e = null;
            int c = 0;

            if (s != null)
            {
                e = s.GetEnumerator(runtime);
                c = 1;
            }
            else if (a != null)
            {
                e = a.GetEnumerator(runtime);
                c = a.GetCount(runtime);
            }

            foreach (var i in array)
                i.AssignIterator(runtime, e);

            return c;
        }
开发者ID:mbarbon,项目名称:language-p-net,代码行数:24,代码来源:List.cs

示例15: P5LvalueList

 public P5LvalueList(Runtime runtime, params IP5Any[] data)
     : base(runtime, data)
 {
     flattened = false;
 }
开发者ID:mbarbon,项目名称:language-p-net,代码行数:5,代码来源:List.cs


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