// TODO: don't require pop
if (!expr) context.consumeCurrentValue();
}
public void compileModule(Node node, BodyCompiler context, boolean expr) {
final ModuleNode moduleNode = (ModuleNode) node;
final Node cpathNode = moduleNode.getCPath();
CompilerCallback bodyCallback = new CompilerCallback() {
public void call(BodyCompiler context) {
if (moduleNode.getBodyNode() != null) {
compile(moduleNode.getBodyNode(), context,true);
}
context.loadNil();
}
};
CompilerCallback pathCallback = new CompilerCallback() {
public void call(BodyCompiler context) {
if (cpathNode instanceof Colon2Node) {
Node leftNode = ((Colon2Node) cpathNode).getLeftNode();
if (leftNode != null) {
compile(leftNode, context,true);
} else {
context.loadNil();
}
} else if (cpathNode instanceof Colon3Node) {
context.loadObject();
} else {
context.loadNil();
}
}
};
ASTInspector inspector = new ASTInspector();
inspector.inspect(moduleNode.getBodyNode());
context.defineModule(moduleNode.getCPath().getName(), moduleNode.getScope(), pathCallback, bodyCallback, inspector);
// TODO: don't require pop
if (!expr) context.consumeCurrentValue();
}