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


C# Runtime.RubyScope类代码示例

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


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

示例1: Load

 public static object Load(RubyScope/*!*/ scope, RubyModule/*!*/ self, MutableString/*!*/ libraryName)
 {
     object loaded;
     scope.RubyContext.Loader.LoadFile(null, self, libraryName, LoadFlags.ResolveLoaded | LoadFlags.AnyLanguage, out loaded);
     Debug.Assert(loaded != null);
     return loaded;
 }
开发者ID:TerabyteX,项目名称:main,代码行数:7,代码来源:IronRubyOps.cs

示例2: ToProc

        public virtual Proc/*!*/ ToProc(RubyScope/*!*/ scope) {
            ContractUtils.RequiresNotNull(scope, "scope");

            // TODO: 
            // This should pass a proc parameter (use BlockDispatcherUnsplatProcN).
            // MRI 1.9.2 doesn't do so though (see http://redmine.ruby-lang.org/issues/show/3792).

            if (_procDispatcher == null) {
                var site = CallSite<Func<CallSite, object, object, object>>.Create(
                    // TODO: use InvokeBinder
                    RubyCallAction.Make(
                        scope.RubyContext, "call",
                        new RubyCallSignature(1, RubyCallFlags.HasImplicitSelf | RubyCallFlags.HasSplattedArgument)
                    )
                );

                var block = new BlockCallTargetUnsplatN((blockParam, self, args, unsplat) => {
                    // block takes no parameters but unsplat => all actual arguments are added to unsplat:
                    Debug.Assert(args.Length == 0);

                    return site.Target(site, this, unsplat);
                });

                _procDispatcher = new BlockDispatcherUnsplatN(0, 
                    BlockDispatcher.MakeAttributes(BlockSignatureAttributes.HasUnsplatParameter, _info.GetArity()),
                    null, 0
                );

                _procDispatcher.SetMethod(block);
            }

            // TODO: 
            // MRI: source file/line are that of the to_proc method call:
            return new Proc(ProcKind.Block, scope.SelfObject, scope, _procDispatcher);
        }
开发者ID:Jirapong,项目名称:main,代码行数:35,代码来源:RubyMethod.cs

示例3: MethodRetry

 public static object MethodRetry(RubyScope/*!*/ scope, Proc proc) {
     if (proc != null) {
         return RetrySingleton;
     } else {
         throw new LocalJumpError("retry used out of rescue", scope.FlowControlScope);
     }
 }
开发者ID:andreakn,项目名称:ironruby,代码行数:7,代码来源:RubyOps.FlowControl.cs

示例4: Proc

 internal Proc(ProcKind kind, object self, RubyScope/*!*/ scope, BlockDispatcher/*!*/ dispatcher) {
     Assert.NotNull(scope, dispatcher);
     _kind = kind;
     _self = self;
     _scope = scope;
     _dispatcher = dispatcher;
 }
开发者ID:joshholmes,项目名称:ironruby,代码行数:7,代码来源:Proc.cs

示例5: CaptureExceptionTrace

 /// <summary>
 /// Builds backtrace for the exception if it wasn't built yet. 
 /// Captures a full stack trace starting with the current frame and combines it with the trace of the exception.
 /// Called from compiled code.
 /// </summary>
 internal void CaptureExceptionTrace(RubyScope/*!*/ scope) {
     if (_backtrace == null) {
         StackTrace catchSiteTrace = RubyStackTraceBuilder.ExceptionDebugInfoAvailable ? new StackTrace(true) : new StackTrace();
         _backtrace = new RubyStackTraceBuilder(scope.RubyContext, _exception, catchSiteTrace, scope.InterpretedFrame != null).RubyTrace;
         DynamicSetBacktrace(scope.RubyContext, _backtrace);
     }
 }
开发者ID:yarrow2,项目名称:ironruby,代码行数:12,代码来源:RubyExceptionData.cs

示例6: GetModule

 private static RubyModule GetModule(RubyScope scope, String className)
 {
     RubyModule module;
     if (!scope.RubyContext.TryGetModule(scope.GlobalScope, className, out module)) {
         throw RubyExceptions.CreateNameError(className);
     }
     return module;
 }
开发者ID:nrk,项目名称:ironruby-json,代码行数:8,代码来源:Helpers.cs

示例7: IsMethodUnwinderTargetFrame

 public static bool IsMethodUnwinderTargetFrame(RubyScope/*!*/ scope, Exception/*!*/ exception) {
     var unwinder = exception as MethodUnwinder;
     if (unwinder == null) {
         RubyExceptionData.GetInstance(exception).CaptureExceptionTrace(scope);
         return false;
     } else {
         return unwinder.TargetFrame == scope.RuntimeFlowControl;
     }
 }
开发者ID:Hank923,项目名称:ironruby,代码行数:9,代码来源:RuntimeFlowControl.cs

示例8: CreateModuleScope

        public static RubyModuleScope/*!*/ CreateModuleScope(LocalsDictionary/*!*/ locals, RubyScope/*!*/ parent,
            RuntimeFlowControl/*!*/ rfc, RubyModule/*!*/ module) {
            Assert.NotNull(locals, parent, rfc, module);

            RubyModuleScope scope = new RubyModuleScope(parent, module, false, rfc, module);
            scope.SetDebugName((module.IsClass ? "class" : "module") + " " + module.Name);

            scope.Frame = locals;
            return scope;
        }
开发者ID:teejayvanslyke,项目名称:ironruby,代码行数:10,代码来源:RubyOps.cs

示例9: Require

        public static object/*!*/ Require(RubyScope/*!*/ scope, RubyModule/*!*/ self, MutableString/*!*/ libraryName) {
            object loaded;
            
            scope.RubyContext.Loader.LoadFile(
                null, self, libraryName, LoadFlags.LoadOnce | LoadFlags.AppendExtensions | LoadFlags.ResolveLoaded, out loaded
            );

            Debug.Assert(loaded != null);
            return loaded;
        }
开发者ID:gregmalcolm,项目名称:ironruby,代码行数:10,代码来源:IronRubyOps.cs

示例10: MethodRetry

 public static object MethodRetry(RubyScope/*!*/ scope, Proc proc) {
     if (proc != null) {
         return BlockReturnResult.Retry;
     } else {
         // TODO: can this happen? 
         // If proc was null then the block argument passed to the call-with-block that returned RetrySingleton would be null and thus 
         // the call cannot yield to any block that retries.
         throw new LocalJumpError("retry used out of rescue", scope.FlowControlScope);
     }
 }
开发者ID:BenHall,项目名称:ironruby,代码行数:10,代码来源:RubyOps.FlowControl.cs

示例11: InitializeLibrary

        public void InitializeLibrary(RubyScope scope)
        {
            KernelOps.Require(scope, this, MutableString.CreateAscii("json/common"));

            _maxNesting = scope.RubyContext.CreateAsciiSymbol("max_nesting");
            _allowNan = scope.RubyContext.CreateAsciiSymbol("allow_nan");
            _jsonCreatable = scope.RubyContext.CreateAsciiSymbol("json_creatable?");
            _jsonCreate = scope.RubyContext.CreateAsciiSymbol("json_create");
            _createId = scope.RubyContext.CreateAsciiSymbol("create_id");
            _createAdditions = scope.RubyContext.CreateAsciiSymbol("create_additions");
            _chr = scope.RubyContext.CreateAsciiSymbol("chr");
        }
开发者ID:nrk,项目名称:ironruby-json,代码行数:12,代码来源:Parser.cs

示例12: BlockReplaceAll

        public static object BlockReplaceAll(ConversionStorage<MutableString>/*!*/ tosConversion, 
            RubyScope/*!*/ scope, [NotNull]BlockParam/*!*/ block, MutableString/*!*/ self, 
            [NotNull]RubyRegex pattern)
        {
            object blockResult;
            MutableString result;
            self.TrackChanges();
            object r = BlockReplaceAll(tosConversion, scope, self, block, pattern, out blockResult, out result) ? blockResult : (result ?? self.Clone());

            RequireNoVersionChange(self);
            return r;
        }
开发者ID:TerabyteX,项目名称:main,代码行数:12,代码来源:MutableStringOps.cs

示例13: SetDataConstant

        public static void SetDataConstant(RubyScope/*!*/ scope, string/*!*/ dataPath, int dataOffset) {
            Debug.Assert(dataOffset >= 0);
            RubyFile dataFile;
            RubyContext context = scope.RubyContext;
            if (context.DomainManager.Platform.FileExists(dataPath)) {
                dataFile = new RubyFile(context, dataPath, RubyFileMode.RDONLY);
                dataFile.Seek(dataOffset, SeekOrigin.Begin);
            } else {
                dataFile = null;
            }

            context.ObjectClass.SetConstant("DATA", dataFile);
        }
开发者ID:teejayvanslyke,项目名称:ironruby,代码行数:13,代码来源:RubyOps.cs

示例14: ParserEngineState

        public ParserEngineState(Parser parser, RubyScope scope, MutableString source)
        {
            Parser = parser;
            Scope = scope;
            OriginalSource = source;
            Source = source.ConvertToString();

            CreateID = Helpers.GetCreateId(scope);
            AllowNaN = DEFAULT_ALLOW_NAN;
            MaxNesting = DEFAULT_MAX_NESTING;
            CurrentNesting = 0;
            Memo = 0;
        }
开发者ID:nrk,项目名称:ironruby-json,代码行数:13,代码来源:ParserEngineState.cs

示例15: Parser

        public Parser(RubyScope scope, MutableString source, Hash options)
        {
            InitializeLibrary(scope);

            _json = new ParserEngineState(this, scope, source);
            if (options.Count > 0) {
                if (options.ContainsKey(_maxNesting)) {
                    _json.MaxNesting = options[_maxNesting] is int ? (int)options[_maxNesting] : 0;
                }
                _json.AllowNaN = options.ContainsKey(_allowNan) ? (bool)options[_allowNan] : ParserEngineState.DEFAULT_ALLOW_NAN;
                // TODO: check needed, create_id could be TrueClass, FalseClass, NilClass or String
                _json.CreateID = options.ContainsKey(_createAdditions) && (bool)options[_createAdditions] ? Helpers.GetCreateId(scope) : null;
            }
        }
开发者ID:nrk,项目名称:ironruby-json,代码行数:14,代码来源:Parser.cs


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