• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# runtime.Runtime类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: BitAnd

        public static P5Scalar BitAnd(Runtime runtime, P5Scalar res,
                                      P5Scalar a, P5Scalar b)
        {
            if (a.IsString(runtime) && b.IsString(runtime))
            {
                string sa = a.AsString(runtime), sb = b.AsString(runtime);
                System.Text.StringBuilder t;

                if (sa.Length > sb.Length)
                {
                    t = new System.Text.StringBuilder(sa);

                    for (int i = 0; i < sb.Length; ++i)
                        t[i] &= sb[i];
                }
                else
                {
                    t = new System.Text.StringBuilder(sb);

                    for (int i = 0; i < sa.Length; ++i)
                        t[i] &= sa[i];
                }

                res.SetString(runtime, t.ToString());
            }
            else
            {
                // TODO take into account signed/unsigned?
                res.SetInteger(runtime, a.AsInteger(runtime) & b.AsInteger(runtime));
            }

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


示例2: P5VecBody

 public P5VecBody(Runtime runtime, P5Scalar _value,
                  int _offset, int _bits)
 {
     value = _value;
     offset = _offset;
     bits = _bits;
 }
开发者ID:mbarbon,项目名称:language-p-net,代码行数:7,代码来源:Vec.cs


示例3: ParseString

        public P5Code ParseString(Runtime runtime, string program, string file, int line)
        {
            var parser = SafeInstance(runtime);
            var reader = new P5Handle(
                parser_runtime, new System.IO.StringReader(program), null);
            P5Array arglist_parse_stream =
                new P5Array(parser_runtime,
                            parser,
                            new P5Scalar(parser_runtime, reader),
                            new P5Scalar(parser_runtime, file),
                            new P5Scalar(parser_runtime, 3),
                            new P5Scalar(parser_runtime));

            IP5Any res;
            try
            {
                res = arglist_parse_stream.CallMethod(parser_runtime, Opcode.ContextValues.SCALAR, "parse_stream");
            }
            catch (System.Reflection.TargetInvocationException te)
            {
                var e = te.InnerException as P5Exception;

                if (e == null)
                    throw te;
                else
                    throw FixupException(e);
            }
            catch (P5Exception e)
            {
                throw FixupException(e);
            }

            return NetGlue.UnwrapValue(res, typeof(P5Code)) as P5Code;
        }
开发者ID:mbarbon,项目名称:language-p-net,代码行数:34,代码来源:Parser.cs


示例4: Parser

        public Parser(Runtime runtime)
        {
            parser_runtime = new Runtime();
            parser_runtime.NativeRegex = true;

            // find compiled code
            var parser_assembly = System.Reflection.Assembly.Load("Language.P.Net.Parser");

            parser_runtime.ModuleLoaders.Insert(0, new AssemblyModuleLoader(parser_assembly));

            // load Language::P frontend
            Builtins.RequireFile(parser_runtime,
                                 Opcode.ContextValues.VOID,
                                 new P5Scalar(parser_runtime, "Language/P.pm"));

            // create generator
            generator = new DynamicGenerator(runtime, parser_runtime);

            // instantiate parser
            P5Array arglist_parser =
                new P5Array(parser_runtime,
                            new P5Scalar(parser_runtime, "Language::P::Parser"),
                            GetInit(runtime));
            parser_template = arglist_parser.CallMethod(parser_runtime, Opcode.ContextValues.SCALAR, "new") as P5Scalar;
        }
开发者ID:mbarbon,项目名称:language-p-net,代码行数:25,代码来源:Parser.cs


示例5: ParseFile

        public P5Code ParseFile(Runtime runtime, string program, bool is_main)
        {
            var parser = SafeInstance(runtime);
            P5Array arglist_parse_file =
                new P5Array(parser_runtime,
                            parser,
                            new P5Scalar(parser_runtime, program),
                            new P5Scalar(parser_runtime, 3));

            IP5Any res;
            try
            {
                res = arglist_parse_file.CallMethod(parser_runtime, Opcode.ContextValues.SCALAR, "parse_file");
            }
            catch (System.Reflection.TargetInvocationException te)
            {
                var e = te.InnerException as P5Exception;

                if (e == null)
                    throw te;
                else
                    throw FixupException(e);
            }
            catch (P5Exception e)
            {
                throw FixupException(e);
            }

            return NetGlue.UnwrapValue(res, typeof(P5Code)) as P5Code;
        }
开发者ID:mbarbon,项目名称:language-p-net,代码行数:30,代码来源:Parser.cs


示例6: Close

        public static P5Scalar Close(Runtime runtime, P5Scalar arg)
        {
            var handle = arg.DereferenceHandle(runtime);
            bool res = handle.Close(runtime);

            return new P5Scalar(runtime, res);
        }
开发者ID:mbarbon,项目名称:language-p-net,代码行数:7,代码来源:IO.cs


示例7: DynamicModuleGenerator

 internal DynamicModuleGenerator(Runtime _runtime)
 {
     runtime = _runtime;
     subroutines = new Dictionary<Subroutine, P5Code>();
     regexes = new Dictionary<Subroutine, IP5Regex>();
     main_pad = new P5ScratchPad();
 }
开发者ID:mbarbon,项目名称:language-p-net,代码行数:7,代码来源:DynamicModuleGenerator.cs


示例8: Close

        public bool Close(Runtime runtime)
        {
            bool ok = true;

            if (input != null)
                try
                {
                    input.Close();
                }
                catch (IOException)
                {
                    ok = false;
                }

            if (output != null)
                try
                {
                    output.Close();
                }
                catch (IOException)
                {
                    ok = false;
                }

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


示例9: Set

 public override void Set(Runtime runtime, IP5Any other)
 {
     if (length.HasValue)
         value.SpliceSubstring(runtime, offset, length.Value, other);
     else
         value.SpliceSubstring(runtime, offset, other);
 }
开发者ID:mbarbon,项目名称:language-p-net,代码行数:7,代码来源:Substr.cs


示例10: Get

 public override P5Scalar Get(Runtime runtime)
 {
     if (length.HasValue)
         return value.Substring(runtime, offset, length.Value);
     else
         return value.Substring(runtime, offset);
 }
开发者ID:mbarbon,项目名称:language-p-net,代码行数:7,代码来源:Substr.cs


示例11: ParseCommandLine

        // TODO handle stacked options
        public static void ParseCommandLine(Runtime runtime, string[] args,
                                            out string[] argv)
        {
            for (int i = 0; i < args.Length; ++i)
            {
                string arg = args[i];

                switch (arg)
                {
                // standard Perl flags
                case "-c":
                    runtime.CompileOnly = true;
                    break;
                // code generation options
                case "-Znative-regex":
                    runtime.NativeRegex = true;
                    break;
                case "-Zignore-bytecode":
                    runtime.IgnoreBytecode = true;
                    break;
                default:
                    argv = new string[args.Length - i];
                    for (int j = i; j < args.Length; ++j)
                        argv[j - i] = args[j];

                    return;
                }
            }

            argv = null;

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


示例12: AssignArray

        public virtual int AssignArray(Runtime runtime, IP5Value other)
        {
            // FIXME multiple dispatch
            P5Array a = other as P5Array;
            P5Hash h = other as P5Hash;

            iterator = null;

            if (a != null)
            {
                AssignIterator(runtime, a.GetEnumerator(runtime));

                return a.GetCount(runtime);
            }
            else if (h != null)
            {
                hash.Clear();
                foreach (var e in h.hash)
                    hash[e.Key] = e.Value.Clone(runtime, 0);

                return h.GetCount(runtime) * 2;
            }

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


示例13: DynamicGenerator

 public DynamicGenerator(Runtime _runtime, Runtime _parser_runtime,
                         P5Scalar _intermediate, P5Scalar _transform)
     : this(_runtime)
 {
     parser_runtime = _parser_runtime;
     intermediate = _intermediate;
     transform = _transform;
 }
开发者ID:mbarbon,项目名称:language-p-net,代码行数:8,代码来源:GeneratorGlue.cs


示例14: P5Handle

        public P5Handle(Runtime _runtime, TextReader _input, TextWriter _output)
        {
            input = _input;
            output = _output;

            if (input != null)
                read_buffer = new char[BUFFER_SIZE];
        }
开发者ID:mbarbon,项目名称:language-p-net,代码行数:8,代码来源:Handle.cs


示例15: Get

 public override P5Scalar Get(Runtime runtime)
 {
     if (   runtime.LastMatch.StringCaptures != null
         && Index < runtime.LastMatch.StringCaptures.Length
         && runtime.LastMatch.StringCaptures[Index] != null)
         return new P5Scalar(runtime, runtime.LastMatch.StringCaptures[Index]);
     else
         return new P5Scalar(runtime);
 }
开发者ID:mbarbon,项目名称:language-p-net,代码行数:9,代码来源:Capture.cs


示例16: Open

        public static P5Scalar Open(Runtime runtime, P5Array args)
        {
            if (args.GetCount(runtime) == 3)
                return Open3Args(runtime,
                                 args.GetItem(runtime, 0) as P5Scalar,
                                 args.GetItem(runtime, 1).AsString(runtime),
                                 args.GetItem(runtime, 2) as P5Scalar);

            throw new System.Exception("Unhandled arg count in open");
        }
开发者ID:mbarbon,项目名称:language-p-net,代码行数:10,代码来源:IO.cs


示例17: Readline

        public bool Readline(Runtime runtime, out P5Scalar result)
        {
            System.Text.StringBuilder builder = null;

            for (;;)
            {
                if (rdbuf_start < rdbuf_end)
                {
                    int newline = System.Array.IndexOf(read_buffer, '\n', rdbuf_start, rdbuf_end - rdbuf_start);

                    if (newline < 0 && rdbuf_end != BUFFER_SIZE)
                        newline = rdbuf_end - 1;

                    if (newline >= 0)
                    {
                        if (builder != null)
                        {
                            builder.Append(read_buffer, rdbuf_start, newline + 1 - rdbuf_start);

                            result = new P5Scalar(runtime, builder.ToString());
                        }
                        else
                            result = new P5Scalar(runtime, new string(read_buffer, rdbuf_start, newline + 1 - rdbuf_start));

                        rdbuf_start = newline + 1;

                        return true;
                    }

                    if (builder == null)
                        builder = new System.Text.StringBuilder(2 * BUFFER_SIZE);

                    builder.Append(read_buffer, rdbuf_start, rdbuf_end - rdbuf_start);
                }

                rdbuf_start = 0;
                rdbuf_end = input.Read(read_buffer, 0, BUFFER_SIZE);

                if (rdbuf_start == rdbuf_end)
                {
                    if (builder != null)
                    {
                        result = new P5Scalar(runtime, builder.ToString());

                        return true;
                    }
                    else
                    {
                        result = new P5Scalar(runtime);

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


示例18: IsFile

        public static P5Scalar IsFile(Runtime runtime, IP5Any path)
        {
            var str = path.AsString(runtime);

            if (System.IO.File.Exists(str))
                return new P5Scalar(runtime, true);

            if (System.IO.Directory.Exists(str))
                return new P5Scalar(runtime, false);

            return new P5Scalar(runtime);
        }
开发者ID:mbarbon,项目名称:language-p-net,代码行数:12,代码来源:FileSystem.cs


示例19: DoFile

        public static IP5Any DoFile(Runtime runtime,
                                    Opcode.ContextValues context,
                                    P5Scalar file)
        {
            var file_s = file.AsString(runtime);

            var ret = LoadFile(runtime, context, file_s);
            if (ret == null)
                return new P5Scalar(runtime);

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


示例20: ArrayReplace

        public static IP5Any ArrayReplace(Runtime runtime, IP5Array array,
                                          IP5Any offset, IP5Any count,
                                          params IP5Any[] values)
        {
            int start = offset.AsInteger(runtime);
            int length = count.AsInteger(runtime);
            int max = array.GetCount(runtime);

            if (start < 0)
                start = max + start;
            if (length < 0)
                length = max + length - start;

            return array.Replace(runtime, start, length, values);
        }
开发者ID:mbarbon,项目名称:language-p-net,代码行数:15,代码来源:Builtins.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# include.Point2I类代码示例发布时间:2022-05-26
下一篇:
C# oncrpc.XdrEncodingStream类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap