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


C# Runtime.RubyGlobalScope类代码示例

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


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

示例1: RubyConstructor

        public RubyConstructor(RubyGlobalScope/*!*/ scope, NodeProvider/*!*/ nodeProvider)
            : base(nodeProvider, scope) {
            
            _newSite = CallSite<Func<CallSite, RubyModule, object, object, object, object>>.Create(
                RubyCallAction.Make(scope.Context, "new", RubyCallSignature.WithImplicitSelf(3))
            ); 

            _yamlInitializeSite = CallSite<Func<CallSite, object, object, Hash, object>>.Create(
                RubyCallAction.Make(scope.Context, "yaml_initialize", RubyCallSignature.WithImplicitSelf(3))
            );
        }
开发者ID:atczyc,项目名称:ironruby,代码行数:11,代码来源:RubyConstructor.cs

示例2: OverloadResolution_Block

        public void OverloadResolution_Block() {
            var t = GetType();

            var gse = new RubyGlobalScope(Context, new Scope(), new object(), true);
            var scope = new RubyTopLevelScope(gse, null, new SymbolDictionary());
            var proc = new Proc(ProcKind.Proc, null, scope, new BlockDispatcher0((x, y) => null, BlockSignatureAttributes.None));

            var scopeArg = new DynamicMetaObject(Ast.Constant(proc.LocalScope), BindingRestrictions.Empty, proc.LocalScope);
            var contextArg = new DynamicMetaObject(Ast.Constant(Context), BindingRestrictions.Empty, Context);
            var instanceInt = new DynamicMetaObject(Ast.Constant(1), BindingRestrictions.Empty, 1);
            var str = "foo";
            var instanceStr = new DynamicMetaObject(Ast.Constant(str), BindingRestrictions.Empty, str);
            var procArg = new DynamicMetaObject(Ast.Constant(proc), BindingRestrictions.Empty, proc);
            var nullArg = new DynamicMetaObject(Ast.Constant(Ast.Constant(null)), BindingRestrictions.Empty, null);

            var arguments = new[] {
                // 1.times
                new CallArguments(scopeArg, instanceInt, new DynamicMetaObject[0], RubyCallSignature.WithScope(0)),
                // 1.times &nil             
                new CallArguments(scopeArg, instanceInt, new[] {  nullArg }, RubyCallSignature.WithScopeAndBlock(0)),
                // 1.times &p                            
                new CallArguments(contextArg, instanceInt, new[] {  procArg }, RubyCallSignature.WithBlock(0)),
                // obj.times &p                          
                new CallArguments(contextArg, instanceStr, new[] {  procArg }, RubyCallSignature.WithBlock(0)),
            };

            var results = new[] {
                "Times2",
                "Times1",
                "Times3",
                "Times4",
            };

            for (int i = 0; i < arguments.Length; i++) {
                var bindingTarget = RubyMethodGroupInfo.ResolveOverload("times", new[] {
                    t.GetMethod("Times1"),
                    t.GetMethod("Times2"),
                    t.GetMethod("Times3"),
                    t.GetMethod("Times4"),
                }, arguments[i], true, false);

                Assert(bindingTarget.Success);
                Assert(bindingTarget.Method.Name == results[i]);
            }
        }
开发者ID:joshholmes,项目名称:ironruby,代码行数:45,代码来源:OverloadResolutionTests.cs

示例3: TryResolveConstant

 /// <summary>
 /// Get constant defined in this module or any of its ancestors. 
 /// Autoloads if autoloadScope is not null.
 /// </summary>
 /// <remarks>
 /// Thread safe.
 /// </remarks>
 internal bool TryResolveConstant(RubyGlobalScope autoloadScope, string/*!*/ name, out ConstantStorage value) {
     using (Context.ClassHierarchyLocker()) {
         return TryResolveConstantNoLock(autoloadScope, name, out value);
     }
 }        
开发者ID:bclubb,项目名称:ironruby,代码行数:12,代码来源:RubyModule.cs

示例4: TryGetConstant

 public bool TryGetConstant(RubyGlobalScope autoloadScope, string/*!*/ name, out object value) {
     ConstantStorage storage;
     var result = TryGetConstant(autoloadScope, name, out storage);
     value = storage.Value;
     return result;
 }
开发者ID:bclubb,项目名称:ironruby,代码行数:6,代码来源:RubyModule.cs

示例5: Load

            public bool Load(RubyGlobalScope/*!*/ autoloadScope) {
                if (_loaded) {
                    return false;
                }

                 using (autoloadScope.Context.ClassHierarchyUnlocker()) {
                     _loaded = true;
                     return autoloadScope.Context.Loader.LoadFile(autoloadScope.Scope, null, _path, LoadFlags.LoadOnce | LoadFlags.AppendExtensions);
                 }
            }
开发者ID:bclubb,项目名称:ironruby,代码行数:10,代码来源:RubyModule.cs

示例6: TryResolveConstant

 /// <summary>
 /// Get constant defined in this module or any of its ancestors.
 /// </summary>
 public bool TryResolveConstant(RubyGlobalScope autoloadScope, string/*!*/ name, out object value) {
     return TryLookupConstant(true, true, autoloadScope, name, out value) != ConstantLookupResult.NotFound;
 }
开发者ID:joshholmes,项目名称:ironruby,代码行数:6,代码来源:RubyModule.cs

示例7: TryResolveConstantNoLock

        // thread-safe:
        // Returns null on success, the lexically inner-most module on failure.
        internal RubyModule TryResolveConstantNoLock(RubyGlobalScope autoloadScope, string/*!*/ name, out ConstantStorage result) {
            var context = RubyContext;
            context.RequiresClassHierarchyLock();
            
            RubyScope scope = this;

            // lexical lookup first:
            RubyModule innerMostModule = null;
            do {
                RubyModule module = scope.Module;

                if (module != null) {
                    if (module.TryGetConstant(context, autoloadScope, name, out result)) {
                        return null;
                    }

                    // remember the module:
                    if (innerMostModule == null) {
                        innerMostModule = module;
                    }
                }

                scope = scope.Parent;
            } while (scope != null);

            // check the inner most module and it's base classes/mixins:
            if (innerMostModule != null) {
                if (innerMostModule.TryResolveConstant(context, autoloadScope, name, out result)) {
                    return null;
                }
            } else {
                innerMostModule = context.ObjectClass;
            }

            if (context.ObjectClass.TryResolveConstant(context, autoloadScope, name, out result)) {
                return null;
            }

            return innerMostModule;
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:42,代码来源:RubyScope.cs

示例8: MakeConstructor

 private static RubyConstructor/*!*/ MakeConstructor(RubyGlobalScope/*!*/ scope, TextReader/*!*/ reader) {
     return new RubyConstructor(scope, MakeComposer(reader));
 }
开发者ID:bclubb,项目名称:ironruby,代码行数:3,代码来源:RubyYaml.cs

示例9: SafeConstructor

 public SafeConstructor(/*!*/NodeProvider nodeProvider, RubyGlobalScope/*!*/ scope)
     : base(nodeProvider, scope) {
 }
开发者ID:bclubb,项目名称:ironruby,代码行数:3,代码来源:SafeConstructor.cs

示例10: RubyConstructor

        public RubyConstructor(RubyGlobalScope/*!*/ scope, NodeProvider/*!*/ nodeProvider)
            : base(nodeProvider, scope) {            
            AddConstructor("tag:yaml.org,2002:str", ConstructRubyScalar);
            AddConstructor("tag:ruby.yaml.org,2002:range", ConstructRubyRange);
            AddConstructor("tag:ruby.yaml.org,2002:regexp", ConstructRubyRegexp);
            AddMultiConstructor("tag:ruby.yaml.org,2002:object:", ConstructPrivateObject);            
            AddMultiConstructor("tag:ruby.yaml.org,2002:struct:", ConstructRubyStruct);
            AddConstructor("tag:yaml.org,2002:binary", ConstructRubyBinary);
            AddConstructor("tag:yaml.org,2002:timestamp#ymd", ConstructRubyTimestampYMD);

            //AddConstructor("tag:yaml.org,2002:omap", ConstructRubyOmap);
            //AddMultiConstructor("tag:yaml.org,2002:seq:", ConstructSpecializedRubySequence);
            //AddMultiConstructor("tag:yaml.org,2002:map:", ConstructSpecializedRubyMap);
        }
开发者ID:bclubb,项目名称:ironruby,代码行数:14,代码来源:RubyConstructor.cs

示例11: TryGetConstantNoLock

 /// <summary>
 /// Get constant defined in this module.
 /// </summary>
 public bool TryGetConstantNoLock(RubyGlobalScope autoloadScope, string/*!*/ name, out object value) {
     Context.RequiresClassHierarchyLock();
     return TryLookupConstantNoLock(false, false, autoloadScope, name, out value) != ConstantLookupResult.NotFound;
 }
开发者ID:tnachen,项目名称:ironruby,代码行数:7,代码来源:RubyModule.cs

示例12: TryGetConstant

 /// <summary>
 /// Get constant defined in this module.
 /// </summary>
 public bool TryGetConstant(RubyGlobalScope autoloadScope, string/*!*/ name, out object value) {
     using (Context.ClassHierarchyLocker()) {
         return TryGetConstantNoLock(autoloadScope, name, out value);
     }
 }
开发者ID:tnachen,项目名称:ironruby,代码行数:8,代码来源:RubyModule.cs

示例13: RubyConstructor

 public RubyConstructor(RubyGlobalScope/*!*/ scope, NodeProvider/*!*/ nodeProvider)
     : base(nodeProvider, scope) {
 }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:3,代码来源:RubyConstructor.cs

示例14: TryLookupConstant

        private ConstantLookupResult TryLookupConstant(bool included, bool inherited, RubyGlobalScope autoloadScope, 
            string/*!*/ name, out object value) {

            Debug.Assert(included || !inherited);

            value = null;
            while (true) {
                object result;

                bool found = included ? 
                    TryResolveConstantNoAutoloadCheck(inherited, name, out result) :
                    TryGetConstantNoAutoloadCheck(name, out result);

                if (!found) {
                    return ConstantLookupResult.NotFound;
                }

                var autoloaded = result as AutoloadedConstant;
                if (autoloaded == null) {
                    value = result;
                    return ConstantLookupResult.Found;
                }

                if (autoloadScope == null) {
                    return ConstantLookupResult.FoundAutoload;
                }

                // autoloaded constants are removed before the associated file is loaded:
                RemoveConstant(name);

                // load file and try lookup again:
                if (!autoloaded.Load(autoloadScope)) {
                    return ConstantLookupResult.NotFound;
                }
            }
        }
开发者ID:joshholmes,项目名称:ironruby,代码行数:36,代码来源:RubyModule.cs

示例15: TryResolveConstantNoLock

 /// <summary>
 /// Get constant defined in this module or any of its ancestors.
 /// </summary>
 internal bool TryResolveConstantNoLock(RubyGlobalScope autoloadScope, string/*!*/ name, out ConstantStorage value) {
     Context.RequiresClassHierarchyLock();
     return TryLookupConstantNoLock(true, true, autoloadScope, name, out value) != ConstantLookupResult.NotFound;
 }
开发者ID:bclubb,项目名称:ironruby,代码行数:7,代码来源:RubyModule.cs


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