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


C# runtime.Runtime类代码示例

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


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


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