本文整理汇总了C#中IronRuby.Runtime.RubyScope.GetInnerMostMethodScope方法的典型用法代码示例。如果您正苦于以下问题:C# RubyScope.GetInnerMostMethodScope方法的具体用法?C# RubyScope.GetInnerMostMethodScope怎么用?C# RubyScope.GetInnerMostMethodScope使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IronRuby.Runtime.RubyScope
的用法示例。
在下文中一共展示了RubyScope.GetInnerMostMethodScope方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HasBlock
public static bool HasBlock(RubyScope/*!*/ scope, object self) {
var methodScope = scope.GetInnerMostMethodScope();
return methodScope != null && methodScope.BlockParameter != null;
}
示例2: CreateNew
public static Proc/*!*/ CreateNew(CallSiteStorage<Func<CallSite, Proc, Proc, object>>/*!*/ storage,
RubyScope/*!*/ scope, RubyClass/*!*/ self) {
RubyMethodScope methodScope = scope.GetInnerMostMethodScope();
if (methodScope == null || methodScope.BlockParameter == null) {
throw RubyExceptions.CreateArgumentError("tried to create Proc object without a block");
}
return CreateNew(storage, self, methodScope.BlockParameter);
}
示例3: Evaluate
public static object Evaluate(MutableString/*!*/ code, RubyScope/*!*/ targetScope, object self, RubyModule module, MutableString file, int line) {
Assert.NotNull(code, targetScope);
RubyContext context = targetScope.RubyContext;
RubyMethodScope methodScope = targetScope.GetInnerMostMethodScope();
Utils.Log(Interlocked.Increment(ref _stringEvalCounter).ToString(), "EVAL");
// we want to create a new top-level local scope:
var options = CreateCompilerOptionsForEval(targetScope, methodScope, module != null, line);
SourceUnit source = context.CreateSnippet(code.ConvertToString(), file != null ? file.ConvertToString() : "(eval)", SourceCodeKind.Statements);
Expression<EvalEntryPointDelegate> lambda;
try {
lambda = context.ParseSourceCode<EvalEntryPointDelegate>(source, options, context.RuntimeErrorSink);
} catch (SyntaxError e) {
Utils.Log(e.Message, "EVAL_ERROR");
Utils.Log(new String('-', 50), "EVAL_ERROR");
Utils.Log(source.GetCode(), "EVAL_ERROR");
Utils.Log(new String('-', 50), "EVAL_ERROR");
throw;
}
Debug.Assert(lambda != null);
Proc blockParameter;
RubyMethodInfo methodDefinition;
if (methodScope != null) {
blockParameter = methodScope.BlockParameter;
methodDefinition = methodScope.Method;
} else {
blockParameter = null;
methodDefinition = null;
}
if (context.Options.InterpretedMode) {
return Interpreter.TopLevelExecute(new InterpretedScriptCode(lambda, source),
targetScope,
self,
module,
blockParameter,
methodDefinition,
targetScope.RuntimeFlowControl
);
} else {
return lambda.Compile(source.EmitDebugSymbols)(
targetScope,
self,
module,
blockParameter,
methodDefinition,
targetScope.RuntimeFlowControl
);
}
}
示例4: CreateNew
public static Proc/*!*/ CreateNew(CallSiteStorage<Func<CallSite, object, object>>/*!*/ storage,
RubyScope/*!*/ scope, RubyClass/*!*/ self) {
RubyMethodScope methodScope = scope.GetInnerMostMethodScope();
if (methodScope == null || methodScope.BlockParameter == null) {
throw RubyExceptions.CreateArgumentError("tried to create Proc object without a block");
}
var proc = methodScope.BlockParameter;
// an instance of Proc class, the identity is preserved:
if (self.GetUnderlyingSystemType() == typeof(Proc)) {
return proc;
}
// an instance of a Proc subclass:
var result = new Proc.Subclass(self, proc);
var initialize = storage.GetCallSite("initialize", new RubyCallSignature(0, RubyCallFlags.HasImplicitSelf));
initialize.Target(initialize, result);
return result;
}
示例5: CreateCompilerOptionsForEval
public static RubyCompilerOptions/*!*/ CreateCompilerOptionsForEval(RubyScope/*!*/ targetScope, int line) {
return CreateCompilerOptionsForEval(targetScope, targetScope.GetInnerMostMethodScope(), false, line);
}