context.performBooleanBranch(trueBranch, falseBranch);
}
public void compileClass(Node node, BodyCompiler context) {
final ClassNode classNode = (ClassNode) node;
final Node superNode = classNode.getSuperNode();
final Node cpathNode = classNode.getCPath();
CompilerCallback superCallback = new CompilerCallback() {
public void call(BodyCompiler context) {
compile(superNode, context);
}
};
if (superNode == null) {
superCallback = null;
}
CompilerCallback bodyCallback = new CompilerCallback() {
public void call(BodyCompiler context) {
boolean oldIsAtRoot = isAtRoot;
isAtRoot = false;
if (classNode.getBodyNode() != null) {
compile(classNode.getBodyNode(), context);
} else {
context.loadNil();
}
isAtRoot = oldIsAtRoot;
}
};
CompilerCallback pathCallback = new CompilerCallback() {
public void call(BodyCompiler context) {
if (cpathNode instanceof Colon2Node) {
Node leftNode = ((Colon2Node) cpathNode).getLeftNode();
if (leftNode != null) {
compile(leftNode, context);
} else {
context.loadNil();
}
} else if (cpathNode instanceof Colon3Node) {
context.loadObject();
} else {
context.loadNil();
}
}
};
context.defineClass(classNode.getCPath().getName(), classNode.getScope(), superCallback, pathCallback, bodyCallback, null);
}