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

C# Runtime.RubyScope类代码示例

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

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



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


示例16: SetVisibility

        private static RubyModule/*!*/ SetVisibility(RubyScope/*!*/ scope, object/*!*/ self, string/*!*/[]/*!*/ methodNames, RubyMethodAttributes attributes) {
            Assert.NotNull(scope, self, methodNames);
            RubyModule module;

            // MRI: Method is searched in the class of self (Object), not in the main singleton class.
            // IronRuby specific: If we are in a top-level scope with redirected method lookup module we use that module (hosted scopes).
            var topScope = scope.Top.GlobalScope.TopLocalScope;
            if (scope == topScope && topScope.MethodLookupModule != null) {
                module = topScope.MethodLookupModule;
            } else {
                module = scope.RubyContext.GetClassOf(self);
            }
            ModuleOps.SetMethodAttributes(scope, module, methodNames, attributes);
            return module;
        }
开发者ID:rudimk,项目名称:dlr-dotnet,代码行数:15,代码来源:SingletonOps.cs


示例17: ToJsonRawObject

        public static Hash ToJsonRawObject(RubyScope scope, MutableString self)
        {
            byte[] selfBuffer = self.ToByteArray();
            var array = new RubyArray(selfBuffer.Length);
            foreach (byte b in selfBuffer) {
                array.Add(b & 0xFF);
            }

            var context = scope.RubyContext;
            var result = new Hash(context);
            var createId = Helpers.GetCreateId(scope);

            result.Add(createId, MutableString.Create(context.GetClassName(self), RubyEncoding.Binary));
            result.Add(MutableString.CreateAscii("raw"), array);
            return result;
        }
开发者ID:nrk,项目名称:ironruby-json,代码行数:16,代码来源:Generator.String.cs


示例18: EvalRetry

        public static void EvalRetry(RubyScope/*!*/ scope) {
            if (scope.InRescue) {
                throw new EvalUnwinder(BlockReturnReason.Retry, RetrySingleton);
            }

            RubyBlockScope blockScope;
            RubyMethodScope methodScope;
            scope.GetInnerMostBlockOrMethodScope(out blockScope, out methodScope);

            if (methodScope != null && methodScope.BlockParameter != null) {
                throw new EvalUnwinder(BlockReturnReason.Retry, RetrySingleton);
            } else if (blockScope != null) {
                if (blockScope.BlockFlowControl.CallerKind == BlockCallerKind.Yield) {
                    throw new EvalUnwinder(BlockReturnReason.Retry, null, blockScope.BlockFlowControl.Proc.Kind, RetrySingleton);
                }
                //if (blockScope.BlockFlowControl.IsMethod) {
                throw new LocalJumpError("retry from proc-closure");// TODO: RFC
            }

            throw new LocalJumpError("retry used out of rescue", scope.FlowControlScope);
        }
开发者ID:andreakn,项目名称:ironruby,代码行数:21,代码来源:RubyOps.FlowControl.cs


示例19: GetValue

        public override object GetValue(RubyContext/*!*/ context, RubyScope scope) {
            switch (_id) {
                
                // regular expressions:
                case GlobalVariableId.MatchData:
                    return (scope != null) ? scope.GetInnerMostClosureScope().CurrentMatch : null;

                case GlobalVariableId.MatchLastGroup:
                    return (scope != null) ? scope.GetInnerMostClosureScope().GetCurrentMatchLastGroup() : null;

                case GlobalVariableId.MatchPrefix:
                    // TODO:
                    throw new NotImplementedException();

                case GlobalVariableId.MatchSuffix:
                    // TODO:
                    throw new NotImplementedException();

                case GlobalVariableId.EntireMatch:
                    return (scope != null) ? scope.GetInnerMostClosureScope().GetCurrentMatchGroup(0) : null;


                // exceptions:
                case GlobalVariableId.CurrentException:
                    return context.CurrentException;

                case GlobalVariableId.CurrentExceptionBacktrace:
                    return context.GetCurrentExceptionBacktrace();


                // input:
                case GlobalVariableId.InputContent:
                    return context.InputProvider.Singleton;

                case GlobalVariableId.InputFileName:
                    return context.InputProvider.CurrentFileName;

                case GlobalVariableId.LastInputLine:
                    return (scope != null) ? scope.GetInnerMostClosureScope().LastInputLine : null;

                case GlobalVariableId.LastInputLineNumber:
                    return context.InputProvider.LastInputLineNumber;

                case GlobalVariableId.CommandLineArguments:
                    return context.InputProvider.CommandLineArguments;


                // output:
                case GlobalVariableId.OutputStream:
                    return context.StandardOutput;

                case GlobalVariableId.ErrorOutputStream:
                    return context.StandardErrorOutput;

                case GlobalVariableId.InputStream:
                    return context.StandardInput;


                // separators:
                case GlobalVariableId.InputSeparator:
                    return context.InputSeparator;

                case GlobalVariableId.OutputSeparator:
                    return context.OutputSeparator;

                case GlobalVariableId.StringSeparator:
                    return context.StringSeparator;

                case GlobalVariableId.ItemSeparator:
                    return context.ItemSeparator;

                
                // loader:
                case GlobalVariableId.LoadPath:
                    return context.Loader.LoadPaths;

                case GlobalVariableId.LoadedFiles:
                    return context.Loader.LoadedFiles;


                // misc:
                case GlobalVariableId.SafeLevel:
                    return context.CurrentSafeLevel;

                case GlobalVariableId.Verbose:
                    return context.Verbose;

                case GlobalVariableId.KCode:
#if !SILVERLIGHT
                    if (context.RubyOptions.Compatibility == RubyCompatibility.Ruby18) {
                        return MutableString.Create(KCoding.GetKCodeName(context.KCode));
                    }
#endif
                    context.ReportWarning("variable $KCODE is no longer effective");
                    return null;

                case GlobalVariableId.ChildProcessExitStatus:
                    return context.ChildProcessExitStatus;

                case GlobalVariableId.CommandLineProgramPath:
//.........这里部分代码省略.........
开发者ID:toddb,项目名称:ironruby,代码行数:101,代码来源:SpecialGlobalVariableInfo.cs


示例20: SetValue

        public override void SetValue(RubyContext/*!*/ context, RubyScope scope, string/*!*/ name, object value) {
            switch (_id) {
                // regex:
                case GlobalVariableId.MatchData:
                    if (scope == null) {
                        throw ReadOnlyError(name);
                    }

                    scope.GetInnerMostClosureScope().CurrentMatch = (value != null) ? RequireType<MatchData>(value, name, "MatchData") : null;
                    return;

                case GlobalVariableId.MatchLastGroup:
                case GlobalVariableId.MatchPrefix:
                case GlobalVariableId.MatchSuffix:
                case GlobalVariableId.EntireMatch:
                    throw ReadOnlyError(name);
                
                
                // exceptions:
                case GlobalVariableId.CurrentException:
                    context.SetCurrentException(value);
                    return;

                case GlobalVariableId.CurrentExceptionBacktrace:
                    context.SetCurrentExceptionBacktrace(value);
                    return;


                // input:
                case GlobalVariableId.LastInputLine:
                    if (scope == null) {
                        throw ReadOnlyError(name);
                    }
                    scope.GetInnerMostClosureScope().LastInputLine = value;
                    return;

                case GlobalVariableId.LastInputLineNumber:
                    context.InputProvider.LastInputLineNumber = RequireType<int>(value, name, "Fixnum");
                    return;

                case GlobalVariableId.CommandLineArguments:
                case GlobalVariableId.InputFileName:
                    throw ReadOnlyError(name);

                // output:
                case GlobalVariableId.OutputStream:
                    context.StandardOutput = RequireWriteProtocol(context, value, name);
                    return;

                case GlobalVariableId.ErrorOutputStream:
                    context.StandardErrorOutput = RequireWriteProtocol(context, value, name);
                    break;

                case GlobalVariableId.InputStream:
                    context.StandardInput = value;
                    return;

                // separators:
                case GlobalVariableId.InputContent:
                    throw ReadOnlyError(name);

                case GlobalVariableId.InputSeparator:
                    context.InputSeparator = (value != null) ? RequireType<MutableString>(value, name, "String") : null;
                    return;

                case GlobalVariableId.OutputSeparator:
                    context.OutputSeparator = (value != null) ? RequireType<MutableString>(value, name, "String") : null;
                    return;

                case GlobalVariableId.StringSeparator:
                    // type not enforced:
                    context.StringSeparator = value;
                    return;

                case GlobalVariableId.ItemSeparator:
                    context.ItemSeparator = (value != null) ? RequireType<MutableString>(value, name, "String") : null;
                    return;


                // loader:
                case GlobalVariableId.LoadedFiles:
                case GlobalVariableId.LoadPath:
                    throw ReadOnlyError(name);


                // misc:
                case GlobalVariableId.SafeLevel:
                    context.SetSafeLevel(RequireType<int>(value, name, "Fixnum"));
                    return;

                case GlobalVariableId.Verbose:
                    context.Verbose = value;
                    return;

                case GlobalVariableId.CommandLineProgramPath:
                    context.CommandLineProgramPath = (value != null) ? RequireType<MutableString>(value, name, "String") : null;
                    return;
                
                case GlobalVariableId.KCode:
#if !SILVERLIGHT
//.........这里部分代码省略.........
开发者ID:toddb,项目名称:ironruby,代码行数:101,代码来源:SpecialGlobalVariableInfo.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Runtime.RuntimeFlowControl类代码示例发布时间:2022-05-26
下一篇:
C# Runtime.RubyGlobalScope类代码示例发布时间: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