本文整理汇总了C#中IronRuby.Runtime.RubyGlobalScope类的典型用法代码示例。如果您正苦于以下问题:C# RubyGlobalScope类的具体用法?C# RubyGlobalScope怎么用?C# RubyGlobalScope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RubyGlobalScope类属于IronRuby.Runtime命名空间,在下文中一共展示了RubyGlobalScope类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: TryLookupConstantNoLock
private ConstantLookupResult TryLookupConstantNoLock(bool included, bool inherited, RubyGlobalScope autoloadScope,
string/*!*/ name, out ConstantStorage value) {
Context.RequiresClassHierarchyLock();
Debug.Assert(included || !inherited);
value = default(ConstantStorage);
while (true) {
ConstantStorage result;
RubyModule owner = included ?
TryResolveConstantNoAutoloadCheck(inherited, name, out result) :
(TryGetConstantNoAutoloadCheck(name, out result) ? this : null);
if (owner == null) {
return ConstantLookupResult.NotFound;
}
var autoloaded = result.Value as AutoloadedConstant;
if (autoloaded == null) {
value = result;
return ConstantLookupResult.Found;
}
if (autoloadScope == null) {
return ConstantLookupResult.FoundAutoload;
}
if (autoloadScope.Context != Context) {
throw RubyExceptions.CreateTypeError(String.Format("Cannot autoload constants to a foreign runtime #{0}", autoloadScope.Context.RuntimeId));
}
// autoloaded constants are removed before the associated file is loaded:
object _;
owner.TryRemoveConstantNoLock(name, out _);
// load file and try lookup again (releases the class hierarchy lock when loading the file):
if (!autoloaded.Load(autoloadScope)) {
return ConstantLookupResult.NotFound;
}
}
}
开发者ID:bclubb,项目名称:ironruby,代码行数:42,代码来源:RubyModule.cs
示例17: Constructor
public Constructor(NodeProvider/*!*/ nodeProvider, RubyGlobalScope/*!*/ scope)
: base(nodeProvider, scope) {
}
开发者ID:bclubb,项目名称:ironruby,代码行数:3,代码来源:Constructor.cs
示例18: MakeConstructor
private static RubyConstructor/*!*/ MakeConstructor(RubyGlobalScope/*!*/ scope, Stream/*!*/ stream) {
return new RubyConstructor(scope, MakeComposer(scope.Context, stream));
}
开发者ID:ExpertsInside,项目名称:IronSP,代码行数:3,代码来源:RubyYaml.cs
示例19: MarshalReader
internal MarshalReader(ReaderSites/*!*/ sites, BinaryReader/*!*/ reader,
RubyGlobalScope/*!*/ globalScope, Proc proc) {
_sites = sites;
_reader = reader;
_globalScope = globalScope;
_proc = proc;
_symbols = new Dictionary<int, Symbol>();
_objects = new Dictionary<int, object>();
}
开发者ID:rafacv,项目名称:iron_languages,代码行数:9,代码来源:Marshal.cs
示例20: SetGlobalScope
internal void SetGlobalScope(RubyGlobalScope/*!*/ value) {
Assert.NotNull(value);
_globalScope = value;
}
开发者ID:kashano,项目名称:main,代码行数:4,代码来源:RubyClass.cs
注:本文中的IronRuby.Runtime.RubyGlobalScope类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论