本文整理汇总了C#中IronRuby.Compiler.Ast.AstGenerator.EnterModuleDefinition方法的典型用法代码示例。如果您正苦于以下问题:C# AstGenerator.EnterModuleDefinition方法的具体用法?C# AstGenerator.EnterModuleDefinition怎么用?C# AstGenerator.EnterModuleDefinition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IronRuby.Compiler.Ast.AstGenerator
的用法示例。
在下文中一共展示了AstGenerator.EnterModuleDefinition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TransformRead
internal sealed override MSA.Expression/*!*/ TransformRead(AstGenerator/*!*/ gen) {
string debugString = (IsSingletonDeclaration) ? "SINGLETON" : ((this is ClassDefinition) ? "CLASS" : "MODULE") + " " + QualifiedName.Name;
ScopeBuilder outerLocals = gen.CurrentScope;
// definition needs to take place outside the defined lexical scope:
var definition = MakeDefinitionExpression(gen);
var selfVariable = outerLocals.DefineHiddenVariable("#module", typeof(RubyModule));
var parentScope = gen.CurrentScopeVariable;
// inner locals:
ScopeBuilder scope = DefineLocals();
var scopeVariable = scope.DefineHiddenVariable("#scope", typeof(RubyScope));
gen.EnterModuleDefinition(
scope,
selfVariable,
scopeVariable,
IsSingletonDeclaration
);
// transform body:
MSA.Expression transformedBody = Body.TransformRead(gen);
// outer local:
MSA.Expression resultVariable = outerLocals.DefineHiddenVariable("#result", transformedBody.Type);
// begin with new scope
// self = DefineModule/Class(... parent scope here ...)
// <body>
// end
MSA.Expression result = new AstBlock {
gen.DebugMarker(debugString),
Ast.Assign(selfVariable, definition),
scope.CreateScope(
scopeVariable,
Methods.CreateModuleScope.OpCall(
scope.MakeLocalsStorage(),
scope.GetVariableNamesExpression(),
parentScope,
selfVariable
),
Ast.Block(
Ast.Assign(resultVariable, transformedBody),
AstUtils.Empty()
)
),
gen.DebugMarker("END OF " + debugString),
resultVariable
};
gen.LeaveModuleDefinition();
return result;
}