Skip to content

Loading…

Komax codestyle override annotations #848

Closed
wants to merge 4 commits into from

2 participants

@komax
JRuby Team member

PR on consistent code style (long lines) and addition of @Override annotation.

komax added some commits
@komax komax addition of @Override annotations to some classes; rewriting to code …
…style in

JRuby and java
869288b
@komax komax removal of not required imports; add of @Override annotation for thes…
…e files;

comparing Strings by equals not on == in Java
263b871
@komax komax addition of many @Override. Refactoring on some conditions using
String.equals(). Moved checks out of if conditions to extra variable, if it
used at least twice

Conflicts:
	src/org/jruby/compiler/ASTCompiler.java
b08a8fa
@komax komax comments and code style on IRBuilder, IRScope and JVMVistitor 1b52efb
@komax komax referenced this pull request
Closed

Komax codereview #847

@enebo
JRuby Team member

Max, perhaps we will need to start with a smaller set than even this. Perhaps gist me over IM with changes and I can help pre-approve those changes.

@enebo enebo closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 2, 2013
  1. @komax

    addition of @Override annotations to some classes; rewriting to code …

    komax committed
    …style in
    
    JRuby and java
  2. @komax

    removal of not required imports; add of @Override annotation for thes…

    komax committed
    …e files;
    
    comparing Strings by equals not on == in Java
  3. @komax

    addition of many @Override. Refactoring on some conditions using

    komax committed
    String.equals(). Moved checks out of if conditions to extra variable, if it
    used at least twice
    
    Conflicts:
    	src/org/jruby/compiler/ASTCompiler.java
  4. @komax
View
12 ext/readline/src/main/java/org/jruby/JRubyApplet.java
@@ -237,6 +237,7 @@ public void init() {
try {
final JRubyApplet applet = this;
safeInvokeAndWait(new Runnable() {
+ @Override
public void run() {
applet.setLayout(new BorderLayout());
applet.facade.attach(applet.runtime, applet);
@@ -261,6 +262,7 @@ private void invokeCallback(final RubyProc proc, final IRubyObject[] args) {
final Ruby ruby = this.runtime;
try {
safeInvokeAndWait(new Runnable() {
+ @Override
public void run() {
proc.call(ruby.getCurrentContext(), args);
}
@@ -374,14 +376,19 @@ private synchronized void paintUnbuffered(Graphics g) {
private static class TrivialFacade implements Facade {
public TrivialFacade() {}
+ @Override
public InputStream getInputStream() { return System.in; }
+ @Override
public PrintStream getOutputStream() { return System.out; }
+ @Override
public PrintStream getErrorStream() { return System.err; }
+ @Override
public void attach(Ruby runtime, Applet applet) {
final IRubyObject wrappedApplet = JavaEmbedUtils.javaToRuby(runtime, applet);
runtime.defineGlobalConstant("JRUBY_APPLET", wrappedApplet);
wrappedApplet.getMetaClass().defineAnnotatedMethods(RubyMethods.class);
}
+ @Override
public void destroy() {}
}
@@ -416,16 +423,21 @@ public ConsoleFacade(String bannerText) {
errorStream = new PrintStream(adaptor.getOutputStream());
}
+ @Override
public InputStream getInputStream() { return inputStream; }
+ @Override
public PrintStream getOutputStream() { return outputStream; }
+ @Override
public PrintStream getErrorStream() { return errorStream; }
+ @Override
public void attach(Ruby runtime, Applet applet) {
adaptor.hookIntoRuntime(runtime);
applet.add(scrollPane);
applet.validate();
}
+ @Override
public void destroy() {
Container parent = scrollPane.getParent();
adaptor.shutdown();
View
17 src/org/jruby/BasicObjectStub.java
@@ -332,42 +332,52 @@ public DummyInstanceVariables(IRubyObject nil) {
this.nil = nil;
}
+ @Override
public boolean hasInstanceVariable(String name) {
return false;
}
+ @Override
public boolean fastHasInstanceVariable(String internedName) {
return false;
}
+ @Override
public IRubyObject getInstanceVariable(String name) {
return nil;
}
+ @Override
public IRubyObject fastGetInstanceVariable(String internedName) {
return nil;
}
+ @Override
public IRubyObject setInstanceVariable(String name, IRubyObject value) {
return value;
}
+ @Override
public IRubyObject fastSetInstanceVariable(String internedName, IRubyObject value) {
return value;
}
+ @Override
public IRubyObject removeInstanceVariable(String name) {
return nil;
}
+ @Override
public List<Variable<IRubyObject>> getInstanceVariableList() {
return Collections.EMPTY_LIST;
}
+ @Override
public List<String> getInstanceVariableNameList() {
return Collections.EMPTY_LIST;
}
+ @Override
public void copyInstanceVariablesInto(InstanceVariables other) {
}
@@ -380,28 +390,35 @@ public static InstanceVariables getInstanceVariables(IRubyObject self) {
@SuppressWarnings("deprecation")
public static class DummyInternalVariables implements InternalVariables {
+ @Override
public boolean hasInternalVariable(String name) {
return false;
}
+ @Override
public boolean fastHasInternalVariable(String internedName) {
return false;
}
+ @Override
public Object getInternalVariable(String name) {
return null;
}
+ @Override
public Object fastGetInternalVariable(String internedName) {
return null;
}
+ @Override
public void setInternalVariable(String name, Object value) {
}
+ @Override
public void fastSetInternalVariable(String internedName, Object value) {
}
+ @Override
public Object removeInternalVariable(String name) {
return null;
}
View
1 src/org/jruby/MetaClass.java
@@ -46,6 +46,7 @@ public boolean isSingleton() {
return true;
}
+ @Override
public final IRubyObject allocate(){
throw runtime.newTypeError("can't create instance of virtual class");
}
View
2 src/org/jruby/NativeException.java
@@ -59,6 +59,7 @@ private NativeException(Ruby runtime, RubyClass rubyClass) {
}
private static ObjectAllocator NATIVE_EXCEPTION_ALLOCATOR = new ObjectAllocator() {
+ @Override
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
NativeException instance = new NativeException(runtime, klazz);
instance.setMetaClass(klazz);
@@ -79,6 +80,7 @@ public IRubyObject cause(Block unusedBlock) {
return Java.getInstance(getRuntime(), cause);
}
+ @Override
public IRubyObject backtrace() {
IRubyObject rubyTrace = super.backtrace();
if (rubyTrace.isNil()) {
View
1 src/org/jruby/ast/AndNode.java
@@ -40,7 +40,6 @@
import org.jruby.runtime.Block;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
-import org.jruby.util.ByteList;
import org.jruby.util.DefinedMessage;
/**
View
1 src/org/jruby/ast/ArgAuxillaryNode.java
@@ -44,6 +44,7 @@ public ArgAuxillaryNode(ISourcePosition position, String name, int offset) {
this.offset = offset;
}
+ @Override
public NodeType getNodeType() {
return NodeType.ARGAUXILIARYNODE;
}
View
3 src/org/jruby/ast/ArgumentNode.java
@@ -55,10 +55,12 @@ public ArgumentNode(ISourcePosition position, String identifier, int location) {
this.location = location; // All variables should be depth 0 in this case
}
+ @Override
public NodeType getNodeType() {
return NodeType.ARGUMENTNODE;
}
+ @Override
public Object accept(NodeVisitor visitor) {
return null;
}
@@ -82,6 +84,7 @@ public int getIndex() {
return location & 0xffff;
}
+ @Override
public String getName() {
return identifier;
}
View
3 src/org/jruby/ast/Node.java
@@ -46,7 +46,6 @@
import org.jruby.runtime.Block;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
-import org.jruby.util.ByteList;
import org.jruby.util.DefinedMessage;
/**
@@ -66,10 +65,12 @@ public Node(ISourcePosition position) {
/**
* Location of this node within the source
*/
+ @Override
public ISourcePosition getPosition() {
return position;
}
+ @Override
public void setPosition(ISourcePosition position) {
this.position = position;
}
View
1 src/org/jruby/ast/visitor/InstanceVariableFinder.java
@@ -46,6 +46,7 @@
*
* @return a Set of all instance variable names found
*/
+ @Override
public Set<String> getFoundVariables() {
return foundVariables;
}
View
223 src/org/jruby/compiler/ASTCompiler.java
@@ -382,10 +382,12 @@ public VariableArityArguments(Node node) {
this.node = node;
}
+ @Override
public int getArity() {
return -1;
}
+ @Override
public void call(BodyCompiler context) {
compileArguments(node, context);
}
@@ -406,10 +408,12 @@ public SpecificArityArguments(Node node) {
this.node = node;
}
+ @Override
public int getArity() {
return arity;
}
+ @Override
public void call(BodyCompiler context) {
if (node.getNodeType() == NodeType.ARRAYNODE) {
ArrayNode arrayNode = (ArrayNode)node;
@@ -536,6 +540,7 @@ public void compileArray(Node node, BodyCompiler context, boolean expr) {
if (expr) {
ArrayCallback callback = new ArrayCallback() {
+ @Override
public void nextValue(BodyCompiler context, Object sourceArray, int index) {
Node node = (Node) ((Object[]) sourceArray)[index];
compile(node, context, true);
@@ -876,6 +881,7 @@ private FastSwitchType getHomogeneousSwitchType(List<Node> whenNodes) {
public void compileWhen(final Node value, List<Node> whenNodes, final Node elseNode, BodyCompiler context, final boolean expr, final boolean hasCase) {
CompilerCallback caseValue = null;
if (value != null) caseValue = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
compile(value, context, true);
context.pollThreadEvents();
@@ -1132,12 +1138,14 @@ public void compileConstDecl(Node node, BodyCompiler context, boolean expr) {
if (constNode == null) {
context.assignConstantInCurrent(constDeclNode.getName(), new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
compile(constDeclNode.getValueNode(), context, true);
}
});
} else if (constNode.getNodeType() == NodeType.COLON2NODE) {
context.assignConstantInModule(constDeclNode.getName(), new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
compile(constDeclNode.getValueNode(), context, true);
compile(((Colon2Node) constNode).getLeftNode(), context, true);
@@ -1145,6 +1153,7 @@ public void call(BodyCompiler context) {
});
} else {// colon3, assign in Object
context.assignConstantInObject(constDeclNode.getName(), new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
compile(constDeclNode.getValueNode(), context, true);
}
@@ -1194,6 +1203,7 @@ public void compileColon2(Node node, BodyCompiler context, boolean expr) {
context.retrieveConstantFromModule(name);
} else if (node instanceof Colon2MethodNode) {
final CompilerCallback receiverCallback = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
compile(iVisited.getLeftNode(), context,true);
}
@@ -1219,6 +1229,9 @@ public void compileColon3(Node node, BodyCompiler context, boolean expr) {
public void compileGetDefinitionBase(final Node node, BodyCompiler context) {
switch (node.getNodeType()) {
+ case NEWLINENODE:
+ compileGetDefinitionBase(((NewlineNode)node).getNextNode(), context);
+ break;
case CLASSVARASGNNODE:
case CLASSVARDECLNODE:
case CONSTDECLNODE:
@@ -1245,13 +1258,9 @@ public void compileGetDefinitionBase(final Node node, BodyCompiler context) {
case COLON3NODE:
case CALLNODE:
// these are all simple cases that don't require the heavier defined logic
- compileGetDefinition(node, context);
- break;
- case NEWLINENODE:
- compileGetDefinitionBase(((NewlineNode)node).getNextNode(), context);
- break;
default:
compileGetDefinition(node, context);
+ break;
}
}
@@ -1317,14 +1326,14 @@ public void compileGetDefinition(final Node node, BodyCompiler context) {
case NOTNODE: // evaluates, and under 1.9 flips to "method" if result is nonnull
{
context.rescue(new BranchCallback() {
-
+ @Override
public void branch(BodyCompiler context) {
compile(node, context, false);
context.pushDefinedMessage(DefinedMessage.EXPRESSION);
}
}, JumpException.class,
new BranchCallback() {
-
+ @Override
public void branch(BodyCompiler context) {
context.pushNull();
}
@@ -1364,13 +1373,13 @@ public void branch(BodyCompiler context) {
context.loadSelf();
context.isMethodBound(((VCallNode) node).getName(),
new BranchCallback() {
-
+ @Override
public void branch(BodyCompiler context) {
context.pushDefinedMessage(DefinedMessage.METHOD);
}
},
new BranchCallback() {
-
+ @Override
public void branch(BodyCompiler context) {
context.pushNull();
}
@@ -1378,13 +1387,14 @@ public void branch(BodyCompiler context) {
break;
case YIELDNODE:
context.hasBlock(new BranchCallback() {
-
+ @Override
public void branch(BodyCompiler context) {
context.pushDefinedMessage(DefinedMessage.YIELD);
}
},
new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
context.pushNull();
}
@@ -1394,12 +1404,14 @@ public void branch(BodyCompiler context) {
context.isGlobalDefined(((GlobalVarNode) node).getName(),
new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
context.pushDefinedMessage(DefinedMessage.GLOBAL_VARIABLE);
}
},
new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
context.pushNull();
}
@@ -1416,12 +1428,14 @@ public void branch(BodyCompiler context) {
context.isMethodBound(((FCallNode) node).getName(),
new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
compileGetArgumentDefinition(((FCallNode) node).getArgsNode(), context, "method");
}
},
new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
context.pushNull();
}
@@ -1436,6 +1450,7 @@ public void branch(BodyCompiler context) {
BranchCallback setup = new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
if (iVisited instanceof Colon2Node) {
final Node leftNode = ((Colon2Node) iVisited).getLeftNode();
@@ -1470,6 +1485,7 @@ public void branch(BodyCompiler context) {
context.isClassVarDefined(iVisited.getName(),
new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
context.consumeCurrentValue();
context.pushDefinedMessage(DefinedMessage.CLASS_VARIABLE);
@@ -1478,6 +1494,7 @@ public void branch(BodyCompiler context) {
},
new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
}
});
@@ -1486,6 +1503,7 @@ public void branch(BodyCompiler context) {
context.isClassVarDefined(iVisited.getName(),
new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
context.consumeCurrentValue();
context.pushDefinedMessage(DefinedMessage.CLASS_VARIABLE);
@@ -1494,6 +1512,7 @@ public void branch(BodyCompiler context) {
},
new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
}
});
@@ -1510,8 +1529,8 @@ public void branch(BodyCompiler context) {
context.setEnding(failure);
context.pushNull();
context.setEnding(ending);
+ break;
}
- break;
case ZSUPERNODE:
{
Object fail = context.getNewEnding();
@@ -1578,6 +1597,7 @@ public void branch(BodyCompiler context) {
context.rescue(new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
compile(iVisited.getReceiverNode(), context,true); //[IRubyObject]
context.duplicateCurrentValue(); //[IRubyObject, IRubyObject]
@@ -1595,14 +1615,16 @@ public void branch(BodyCompiler context) {
context.go(isfalse);
context.setEnding(isreal); //[]
- context.isMethodBound(iVisited.getName(), new BranchCallback() {
-
+ context.isMethodBound(iVisited.getName(),
+ new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
compileGetArgumentDefinition(iVisited.getArgsNode(), context, "assignment");
}
},
new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
context.go(isfalse);
}
@@ -1615,6 +1637,7 @@ public void branch(BodyCompiler context) {
}, JumpException.class,
new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
context.pushNull();
}
@@ -1629,14 +1652,16 @@ public void branch(BodyCompiler context) {
default:
context.rescue(new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
- compile(node, context,true);
+ compile(node, context, true);
context.consumeCurrentValue();
context.pushNull();
}
}, JumpException.class,
new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
context.pushNull();
}
@@ -1649,6 +1674,7 @@ public void branch(BodyCompiler context) {
protected void compileDefinedAndOrDStrDRegexp(final Node node, BodyCompiler context) {
context.rescue(new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
compile(node, context, false);
context.pushDefinedMessage(DefinedMessage.EXPRESSION);
@@ -1656,6 +1682,7 @@ public void branch(BodyCompiler context) {
}, JumpException.class,
new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
context.pushNull();
}
@@ -1671,6 +1698,7 @@ protected void compileDefinedCall(final Node node, BodyCompiler context) {
context.rescue(new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
compile(iVisited.getReceiverNode(), context, true); //[IRubyObject]
context.definedCall(iVisited.getName());
@@ -1678,13 +1706,14 @@ public void branch(BodyCompiler context) {
}, JumpException.class,
new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
context.pushNull();
}
}, RubyString.class);
- // context.swapValues();
- //context.consumeCurrentValue();
+// context.swapValues();
+// context.consumeCurrentValue();
context.go(ending);
context.setEnding(isnull);
context.pushNull();
@@ -1700,12 +1729,14 @@ protected void compileDefinedBackref(final Node node, BodyCompiler context) {
context.isInstanceOf(RubyMatchData.class,
new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
context.pushDefinedMessage(DefinedMessage.byText("$" + ((BackRefNode) node).getType()));
}
},
new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
context.pushNull();
}
@@ -1716,12 +1747,14 @@ protected void compileDefinedNthref(final Node node, BodyCompiler context) {
context.isCaptured(((NthRefNode) node).getMatchNumber(),
new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
context.pushDefinedMessage(DefinedMessage.byText("$" + ((NthRefNode) node).getMatchNumber()));
}
},
new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
context.pushNull();
}
@@ -1732,6 +1765,7 @@ public void compileDAsgn(Node node, BodyCompiler context, boolean expr) {
final DAsgnNode dasgnNode = (DAsgnNode) node;
CompilerCallback value = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
compile(dasgnNode.getValueNode(), context, true);
}
@@ -1754,6 +1788,7 @@ public void compileDefn(Node node, BodyCompiler context, boolean expr) {
CompilerCallback body = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
if (defnNode.getBodyNode() != null) {
Node oldBodyNode = currentBodyNode;
@@ -1773,6 +1808,7 @@ public void call(BodyCompiler context) {
CompilerCallback args = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
compileArgs(argsNode, context, true);
}
@@ -1809,6 +1845,7 @@ public void compileDefs(Node node, BodyCompiler context, boolean expr) {
CompilerCallback receiver = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
compile(defsNode.getReceiverNode(), context, true);
}
@@ -1816,6 +1853,7 @@ public void call(BodyCompiler context) {
CompilerCallback body = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
if (defsNode.getBodyNode() != null) {
if (defsNode.getBodyNode() instanceof RescueNode) {
@@ -1832,6 +1870,7 @@ public void call(BodyCompiler context) {
CompilerCallback args = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
compileArgs(argsNode, context, true);
}
@@ -1877,6 +1916,7 @@ public void compileArgs(Node node, BodyCompiler context, boolean expr) {
if (required > 0) {
requiredAssignment = new ArrayCallback() {
+ @Override
public void nextValue(BodyCompiler context, Object object, int index) {
// FIXME: Somehow I'd feel better if this could get the appropriate var index from the ArgumentNode
context.getVariableCompiler().assignLocalVariable(index, false);
@@ -1887,6 +1927,7 @@ public void nextValue(BodyCompiler context, Object object, int index) {
if (opt > 0) {
optionalGiven = new ArrayCallback() {
+ @Override
public void nextValue(BodyCompiler context, Object object, int index) {
Node optArg = ((ListNode) object).get(index);
@@ -1895,6 +1936,7 @@ public void nextValue(BodyCompiler context, Object object, int index) {
};
optionalNotGiven = new ArrayCallback() {
+ @Override
public void nextValue(BodyCompiler context, Object object, int index) {
Node optArg = ((ListNode) object).get(index);
@@ -1906,6 +1948,7 @@ public void nextValue(BodyCompiler context, Object object, int index) {
if (rest > -1) {
restAssignment = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
context.getVariableCompiler().assignLocalVariable(argsNode.getRestArg(), false);
}
@@ -1915,6 +1958,7 @@ public void call(BodyCompiler context) {
if (argsNode.getBlock() != null) {
blockAssignment = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
context.getVariableCompiler().assignLocalVariable(argsNode.getBlock().getCount(), false);
}
@@ -1940,6 +1984,7 @@ public void compileDot(Node node, BodyCompiler context, boolean expr) {
if (expr) {
CompilerCallback beginEndCallback = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
compile(dotNode.getBeginNode(), context, true);
compile(dotNode.getEndNode(), context, true);
@@ -1955,9 +2000,11 @@ public void compileDRegexp(Node node, BodyCompiler context, boolean expr) {
CompilerCallback createStringCallback = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
ArrayCallback dstrCallback = new ArrayCallback() {
+ @Override
public void nextValue(BodyCompiler context, Object sourceArray,
int index) {
compile(dregexpNode.get(index), context, true);
@@ -1986,6 +2033,7 @@ public void compileDNode(Node node, BodyCompiler context, boolean expr) {
final DNode dNode = (DNode) node;
ArrayCallback dstrCallback = new ArrayCallback() {
+ @Override
public void nextValue(BodyCompiler context, Object sourceArray,
int index) {
Node nextNode = dNode.get(index);
@@ -2044,10 +2092,12 @@ public void compileDXStr(Node node, BodyCompiler context, boolean expr) {
final DXStrNode dxstrNode = (DXStrNode) node;
ArgumentsCallback argsCallback = new ArgumentsCallback() {
+ @Override
public int getArity() {
return 1;
}
+ @Override
public void call(BodyCompiler context) {
compileDNode(dxstrNode, context, true);
}
@@ -2064,6 +2114,7 @@ public void compileEnsureNode(Node node, BodyCompiler context, boolean expr) {
if (ensureNode.getEnsureNode() != null) {
context.performEnsure(new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
if (ensureNode.getBodyNode() != null) {
compile(ensureNode.getBodyNode(), context, true);
@@ -2074,6 +2125,7 @@ public void branch(BodyCompiler context) {
},
new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
compile(ensureNode.getEnsureNode(), context, false);
}
@@ -2113,9 +2165,13 @@ public void compileFCall(Node node, BodyCompiler context, boolean expr) {
CompilerCallback closureArg = getBlock(fcallNode.getIterNode());
if (fcallNode instanceof SpecialArgs) {
- context.getInvocationCompiler().invokeDynamicVarargs(fcallNode.getName(), null, argsCallback, CallType.FUNCTIONAL, closureArg, fcallNode.getIterNode() instanceof IterNode);
+ context.getInvocationCompiler().invokeDynamicVarargs(fcallNode.getName(),
+ null, argsCallback, CallType.FUNCTIONAL,
+ closureArg, fcallNode.getIterNode() instanceof IterNode);
} else {
- context.getInvocationCompiler().invokeDynamic(fcallNode.getName(), null, argsCallback, CallType.FUNCTIONAL, closureArg, fcallNode.getIterNode() instanceof IterNode);
+ context.getInvocationCompiler().invokeDynamic(fcallNode.getName(),
+ null, argsCallback, CallType.FUNCTIONAL,
+ closureArg, fcallNode.getIterNode() instanceof IterNode);
}
// TODO: don't require pop
@@ -2133,6 +2189,7 @@ private CompilerCallback getBlock(Node node) {
return new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
compile(iterNode, context,true);
}
@@ -2142,13 +2199,15 @@ public void call(BodyCompiler context) {
return new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
compile(blockPassNode.getBodyNode(), context,true);
context.unwrapPassedBlock();
}
};
default:
- throw new NotCompilableException("ERROR: Encountered a method with a non-block, non-blockpass iter node at: " + node);
+ throw new NotCompilableException(
+ "ERROR: Encountered a method with a non-block, non-blockpass iter node at: " + node);
}
}
@@ -2166,16 +2225,19 @@ public void compileFlip(Node node, BodyCompiler context, boolean expr) {
if (flipNode.isExclusive()) {
context.performBooleanBranch(new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
compile(flipNode.getEndNode(), context,true);
context.performBooleanBranch(new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
context.loadFalse();
context.getVariableCompiler().assignLocalVariable(flipNode.getIndex(), flipNode.getDepth(), false);
}
}, new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
}
});
@@ -2183,6 +2245,7 @@ public void branch(BodyCompiler context) {
}
}, new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
compile(flipNode.getBeginNode(), context,true);
becomeTrueOrFalse(context);
@@ -2192,16 +2255,19 @@ public void branch(BodyCompiler context) {
} else {
context.performBooleanBranch(new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
compile(flipNode.getEndNode(), context,true);
context.performBooleanBranch(new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
context.loadFalse();
context.getVariableCompiler().assignLocalVariable(flipNode.getIndex(), flipNode.getDepth(), false);
}
}, new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
}
});
@@ -2209,10 +2275,12 @@ public void branch(BodyCompiler context) {
}
}, new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
compile(flipNode.getBeginNode(), context,true);
context.performBooleanBranch(new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
compile(flipNode.getEndNode(), context,true);
flipTrueOrFalse(context);
@@ -2221,6 +2289,7 @@ public void branch(BodyCompiler context) {
}
}, new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
context.loadFalse();
}
@@ -2235,11 +2304,13 @@ public void branch(BodyCompiler context) {
private void becomeTrueOrFalse(BodyCompiler context) {
context.performBooleanBranch(new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
context.loadTrue();
}
}, new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
context.loadFalse();
}
@@ -2249,11 +2320,13 @@ public void branch(BodyCompiler context) {
private void flipTrueOrFalse(BodyCompiler context) {
context.performBooleanBranch(new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
context.loadFalse();
}
}, new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
context.loadTrue();
}
@@ -2263,7 +2336,9 @@ public void branch(BodyCompiler context) {
public void compileFloat(Node node, BodyCompiler context, boolean expr) {
FloatNode floatNode = (FloatNode) node;
- if (expr) context.createNewFloat(floatNode.getValue());
+ if (expr) {
+ context.createNewFloat(floatNode.getValue());
+ }
}
public void compileFor(Node node, BodyCompiler context, boolean expr) {
@@ -2271,6 +2346,7 @@ public void compileFor(Node node, BodyCompiler context, boolean expr) {
CompilerCallback receiverCallback = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
compile(forNode.getIterNode(), context, true);
}
@@ -2278,6 +2354,7 @@ public void call(BodyCompiler context) {
final CompilerCallback closureArg = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
compileForIter(forNode, context);
}
@@ -2294,6 +2371,7 @@ public void compileForIter(Node node, BodyCompiler context) {
// create the closure class and instantiate it
final CompilerCallback closureBody = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
if (forNode.getBodyNode() != null) {
compile(forNode.getBodyNode(), context,true);
@@ -2306,6 +2384,7 @@ public void call(BodyCompiler context) {
// create the closure class and instantiate it
final CompilerCallback closureArgs = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
if (forNode.getVarNode() != null) {
compileAssignment(forNode.getVarNode(), context);
@@ -2341,6 +2420,7 @@ public void compileGlobalAsgn(Node node, BodyCompiler context, boolean expr) {
final GlobalAsgnNode globalAsgnNode = (GlobalAsgnNode) node;
CompilerCallback value = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
compile(globalAsgnNode.getValueNode(), context, true);
}
@@ -2420,6 +2500,7 @@ protected void compileHashCommon(HashNode hashNode, BodyCompiler context, boolea
}
ArrayCallback hashCallback = new ArrayCallback() {
+ @Override
public void nextValue(BodyCompiler context, Object sourceArray,
int index) {
ListNode listNode = (ListNode) sourceArray;
@@ -2463,6 +2544,7 @@ public void compileIf(Node node, BodyCompiler context, final boolean expr) {
compile(ifNode.getElseBody(), context, expr);
} else {
BranchCallback trueCallback = new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
if (ifNode.getThenBody() != null) {
compile(ifNode.getThenBody(), context, expr);
@@ -2473,6 +2555,7 @@ public void branch(BodyCompiler context) {
};
BranchCallback falseCallback = new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
if (ifNode.getElseBody() != null) {
compile(ifNode.getElseBody(), context, expr);
@@ -2514,6 +2597,7 @@ public void compileCondition(Node node, BodyCompiler context, boolean expr) {
context.getInvocationCompiler().invokeBinaryBooleanFixnumRHS(
callNode.getName(),
new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
compile(callNode.getReceiverNode(), context, true);
}
@@ -2535,6 +2619,7 @@ public void compileInstAsgn(Node node, BodyCompiler context, boolean expr) {
final InstAsgnNode instAsgnNode = (InstAsgnNode) node;
CompilerCallback value = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
compile(instAsgnNode.getValueNode(), context, true);
}
@@ -2555,7 +2640,9 @@ public void compileInstAsgnAssignment(Node node, BodyCompiler context) {
public void compileInstVar(Node node, BodyCompiler context, boolean expr) {
InstVarNode instVarNode = (InstVarNode) node;
- if (expr) context.retrieveInstanceVariable(instVarNode.getName());
+ if (expr) {
+ context.retrieveInstanceVariable(instVarNode.getName());
+ }
}
public void compileIter(Node node, BodyCompiler context) {
@@ -2564,6 +2651,7 @@ public void compileIter(Node node, BodyCompiler context) {
// create the closure class and instantiate it
final CompilerCallback closureBody = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
if (iterNode.getBodyNode() != null) {
compile(iterNode.getBodyNode(), context, true);
@@ -2575,6 +2663,7 @@ public void call(BodyCompiler context) {
// create the closure class and instantiate it
final CompilerCallback closureArgs = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
if (iterNode.getVarNode() != null) {
compileAssignment(iterNode.getVarNode(), context);
@@ -2617,6 +2706,7 @@ public void compileLocalAsgn(Node node, BodyCompiler context, boolean expr) {
if (expr) context.loadNil();
} else {
CompilerCallback value = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
compile(localAsgnNode.getValueNode(), context,true);
}
@@ -2636,7 +2726,9 @@ public void compileLocalAsgnAssignment(Node node, BodyCompiler context, boolean
public void compileLocalVar(Node node, BodyCompiler context, boolean expr) {
LocalVarNode localVarNode = (LocalVarNode) node;
- if (expr) context.getVariableCompiler().retrieveLocalVariable(localVarNode.getIndex(), localVarNode.getDepth());
+ if (expr) {
+ context.getVariableCompiler().retrieveLocalVariable(localVarNode.getIndex(), localVarNode.getDepth());
+ }
}
public void compileMatch(Node node, BodyCompiler context, boolean expr) {
@@ -2654,6 +2746,7 @@ public void compileMatch2(Node node, BodyCompiler context, boolean expr) {
compile(matchNode.getReceiverNode(), context,true);
CompilerCallback value = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
compile(matchNode.getValueNode(), context,true);
}
@@ -2682,6 +2775,7 @@ public void compileModule(Node node, BodyCompiler context, boolean expr) {
CompilerCallback bodyCallback = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
if (moduleNode.getBodyNode() != null) {
compile(moduleNode.getBodyNode(), context,true);
@@ -2692,6 +2786,7 @@ public void call(BodyCompiler context) {
CompilerCallback pathCallback = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
if (cpathNode instanceof Colon2Node) {
Node leftNode = ((Colon2Node) cpathNode).getLeftNode();
@@ -2807,6 +2902,7 @@ public void compileMultipleAsgnAssignment(Node node, BodyCompiler context, boole
// normal items at the "head" of the masgn
ArrayCallback headAssignCallback = new ArrayCallback() {
+ @Override
public void nextValue(BodyCompiler context, Object sourceArray,
int index) {
ListNode headNode = (ListNode) sourceArray;
@@ -2819,6 +2915,7 @@ public void nextValue(BodyCompiler context, Object sourceArray,
CompilerCallback argsCallback = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
Node argsNode = multipleAsgnNode.getArgsNode();
if (argsNode instanceof StarNode) {
@@ -2833,7 +2930,9 @@ public void call(BodyCompiler context) {
if (multipleAsgnNode.getHeadNode() == null) {
if (multipleAsgnNode.getArgsNode() == null) {
- throw new NotCompilableException("Something's wrong, multiple assignment with no head or args at: " + multipleAsgnNode.getPosition());
+ throw new NotCompilableException(
+ "Something's wrong, multiple assignment with no head or args at: " +
+ multipleAsgnNode.getPosition());
} else {
if (multipleAsgnNode.getArgsNode() instanceof StarNode) {
// do nothing
@@ -2847,9 +2946,11 @@ public void call(BodyCompiler context) {
context.ensureMultipleAssignableRubyArray(multipleAsgnNode.getHeadNode() != null);
if (multipleAsgnNode.getArgsNode() == null) {
- context.forEachInValueArray(0, multipleAsgnNode.getHeadNode().size(), multipleAsgnNode.getHeadNode(), headAssignCallback, null);
+ context.forEachInValueArray(0, multipleAsgnNode.getHeadNode().size(),
+ multipleAsgnNode.getHeadNode(), headAssignCallback, null);
} else {
- context.forEachInValueArray(0, multipleAsgnNode.getHeadNode().size(), multipleAsgnNode.getHeadNode(), headAssignCallback, argsCallback);
+ context.forEachInValueArray(0, multipleAsgnNode.getHeadNode().size(),
+ multipleAsgnNode.getHeadNode(), headAssignCallback, argsCallback);
}
}
// TODO: don't require pop
@@ -2861,7 +2962,9 @@ public void compileNewline(Node node, BodyCompiler context, boolean expr) {
context.setLinePosition(node.getPosition());
- if (RubyInstanceConfig.FULL_TRACE_ENABLED) context.traceLine();
+ if (RubyInstanceConfig.FULL_TRACE_ENABLED) {
+ context.traceLine();
+ }
NewlineNode newlineNode = (NewlineNode) node;
@@ -2873,6 +2976,7 @@ public void compileNext(Node node, BodyCompiler context, boolean expr) {
CompilerCallback valueCallback = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
if (nextNode.getValueNode() != null) {
compile(nextNode.getValueNode(), context,true);
@@ -2891,7 +2995,9 @@ public void call(BodyCompiler context) {
public void compileNthRef(Node node, BodyCompiler context, boolean expr) {
NthRefNode nthRefNode = (NthRefNode) node;
- if (expr) context.nthRef(nthRefNode.getMatchNumber());
+ if (expr) {
+ context.nthRef(nthRefNode.getMatchNumber());
+ }
}
public void compileNil(Node node, BodyCompiler context, boolean expr) {
@@ -2917,6 +3023,7 @@ public void compileOpAsgnAnd(Node node, BodyCompiler context, boolean expr) {
BranchCallback longCallback = new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
compile(andNode.getSecondNode(), context,true);
}
@@ -2936,22 +3043,26 @@ public void compileOpAsgnOr(Node node, BodyCompiler context, boolean expr) {
context.isNull(new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
compile(orNode.getSecondNode(), context,true);
}
}, new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
compile(orNode.getFirstNode(), context,true);
context.duplicateCurrentValue();
context.performBooleanBranch(new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
//Do nothing
}
},
new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
context.consumeCurrentValue();
compile(orNode.getSecondNode(), context,true);
@@ -2963,11 +3074,13 @@ public void branch(BodyCompiler context) {
compile(orNode.getFirstNode(), context,true);
context.duplicateCurrentValue();
context.performBooleanBranch(new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
//Do nothing
}
},
new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
context.consumeCurrentValue();
compile(orNode.getSecondNode(), context,true);
@@ -3035,6 +3148,7 @@ public void compileOpAsgnWithOr(Node node, BodyCompiler context, boolean expr) {
final CompilerCallback receiverCallback = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
compile(opAsgnNode.getReceiverNode(), context, true); // [recv]
}
@@ -3045,6 +3159,7 @@ public void call(BodyCompiler context) {
context.getInvocationCompiler().invokeOpAsgnWithOr(opAsgnNode.getVariableName(), opAsgnNode.getVariableNameAsgn(), receiverCallback, argsCallback);
// TODO: don't require pop
if (!expr) context.consumeCurrentValue();
+
}
public void compileOpAsgnWithAnd(Node node, BodyCompiler context, boolean expr) {
@@ -3052,6 +3167,7 @@ public void compileOpAsgnWithAnd(Node node, BodyCompiler context, boolean expr)
final CompilerCallback receiverCallback = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
compile(opAsgnNode.getReceiverNode(), context, true); // [recv]
}
@@ -3068,6 +3184,7 @@ public void compileOpAsgnWithMethod(Node node, BodyCompiler context, boolean exp
final OpAsgnNode opAsgnNode = (OpAsgnNode) node;
final CompilerCallback receiverCallback = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
compile(opAsgnNode.getReceiverNode(), context, true); // [recv]
}
@@ -3075,10 +3192,12 @@ public void call(BodyCompiler context) {
// eval new value, call operator on old value, and assign
ArgumentsCallback argsCallback = new ArgumentsCallback() {
+ @Override
public int getArity() {
return 1;
}
+ @Override
public void call(BodyCompiler context) {
compile(opAsgnNode.getValueNode(), context, true);
}
@@ -3092,9 +3211,9 @@ public void call(BodyCompiler context) {
public void compileOpElementAsgn(Node node, BodyCompiler context, boolean expr) {
final OpElementAsgnNode opElementAsgnNode = (OpElementAsgnNode) node;
- if (opElementAsgnNode.getOperatorName() == "||") {
+ if ("||".equals(opElementAsgnNode.getOperatorName())) {
compileOpElementAsgnWithOr(node, context, expr);
- } else if (opElementAsgnNode.getOperatorName() == "&&") {
+ } else if ("&&".equals(opElementAsgnNode.getOperatorName())) {
compileOpElementAsgnWithAnd(node, context, expr);
} else {
compileOpElementAsgnWithMethod(node, context, expr);
@@ -3108,6 +3227,7 @@ public OpElementAsgnArgumentsCallback(Node node) {
this.node = node;
}
+ @Override
public int getArity() {
switch (node.getNodeType()) {
case ARGSCATNODE:
@@ -3128,6 +3248,7 @@ public int getArity() {
}
}
+ @Override
public void call(BodyCompiler context) {
if (getArity() == 1) {
// if arity 1, just compile the one element to save us the array cost
@@ -3143,6 +3264,7 @@ public void compileOpElementAsgnWithOr(Node node, BodyCompiler context, boolean
final OpElementAsgnNode opElementAsgnNode = (OpElementAsgnNode) node;
CompilerCallback receiverCallback = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
compile(opElementAsgnNode.getReceiverNode(), context, true);
}
@@ -3151,6 +3273,7 @@ public void call(BodyCompiler context) {
ArgumentsCallback argsCallback = new OpElementAsgnArgumentsCallback(opElementAsgnNode.getArgsNode());
CompilerCallback valueCallback = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
compile(opElementAsgnNode.getValueNode(), context, true);
}
@@ -3165,6 +3288,7 @@ public void compileOpElementAsgnWithAnd(Node node, BodyCompiler context, boolean
final OpElementAsgnNode opElementAsgnNode = (OpElementAsgnNode) node;
CompilerCallback receiverCallback = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
compile(opElementAsgnNode.getReceiverNode(), context, true);
}
@@ -3173,6 +3297,7 @@ public void call(BodyCompiler context) {
ArgumentsCallback argsCallback = new OpElementAsgnArgumentsCallback(opElementAsgnNode.getArgsNode());
CompilerCallback valueCallback = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
compile(opElementAsgnNode.getValueNode(), context, true);
}
@@ -3187,6 +3312,7 @@ public void compileOpElementAsgnWithMethod(Node node, BodyCompiler context, bool
final OpElementAsgnNode opElementAsgnNode = (OpElementAsgnNode) node;
CompilerCallback receiverCallback = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
compile(opElementAsgnNode.getReceiverNode(), context,true);
}
@@ -3195,6 +3321,7 @@ public void call(BodyCompiler context) {
ArgumentsCallback argsCallback = getArgsCallback(opElementAsgnNode.getArgsNode());
CompilerCallback valueCallback = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
compile(opElementAsgnNode.getValueNode(), context,true);
}
@@ -3220,6 +3347,7 @@ public void compileOr(Node node, BodyCompiler context, boolean expr) {
BranchCallback longCallback = new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
compile(orNode.getSecondNode(), context, true);
}
@@ -3237,6 +3365,7 @@ public void compilePostExe(Node node, BodyCompiler context, boolean expr) {
// create the closure class and instantiate it
final CompilerCallback closureBody = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
if (postExeNode.getBodyNode() != null) {
compile(postExeNode.getBodyNode(), context, true);
@@ -3256,6 +3385,7 @@ public void compilePreExe(Node node, BodyCompiler context, boolean expr) {
// create the closure class and instantiate it
final CompilerCallback closureBody = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
if (preExeNode.getBodyNode() != null) {
compile(preExeNode.getBodyNode(), context,true);
@@ -3280,7 +3410,9 @@ public void compileRedo(Node node, BodyCompiler context, boolean expr) {
public void compileRegexp(Node node, BodyCompiler context, boolean expr) {
RegexpNode reNode = (RegexpNode) node;
- if (expr) context.createNewRegexp(reNode.getValue(), reNode.getOptions().toEmbeddedOptions());
+ if (expr) {
+ context.createNewRegexp(reNode.getValue(), reNode.getOptions().toEmbeddedOptions());
+ }
}
public void compileRescue(Node node, BodyCompiler context, boolean expr) {
@@ -3294,6 +3426,7 @@ private void compileRescueInternal(Node node, BodyCompiler context, final boolea
final RescueNode rescueNode = (RescueNode) node;
BranchCallback body = new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
if (rescueNode.getBodyNode() != null) {
compile(rescueNode.getBodyNode(), context, true);
@@ -3306,6 +3439,7 @@ public void branch(BodyCompiler context) {
BranchCallback elseBody = null;
if (rescueNode.getElseNode() != null) {
elseBody = new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
context.consumeCurrentValue();
compile(rescueNode.getElseNode(), context, true);
@@ -3314,6 +3448,7 @@ public void branch(BodyCompiler context) {
}
BranchCallback rubyHandler = new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
compileRescueBodyInternal(rescueNode.getRescueNode(), context, light);
}
@@ -3336,10 +3471,12 @@ private void compileRescueBodyInternal(Node node, BodyCompiler context, final bo
final Node exceptionList = rescueBodyNode.getExceptionNodes();
ArgumentsCallback rescueArgs = getArgsCallback(exceptionList);
if (rescueArgs == null) rescueArgs = new ArgumentsCallback() {
+ @Override
public int getArity() {
return 1;
}
+ @Override
public void call(BodyCompiler context) {
context.loadStandardError();
}
@@ -3348,6 +3485,7 @@ public void call(BodyCompiler context) {
context.checkIsExceptionHandled(rescueArgs);
BranchCallback trueBranch = new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
// check if it's an immediate, and don't outline
Node realBody = rescueBodyNode.getBodyNode();
@@ -3397,6 +3535,7 @@ public void branch(BodyCompiler context) {
};
BranchCallback falseBranch = new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
if (rescueBodyNode.getOptRescueNode() != null) {
compileRescueBodyInternal(rescueBodyNode.getOptRescueNode(), context, light);
@@ -3508,12 +3647,15 @@ public void compileSuper(Node node, BodyCompiler context, boolean expr) {
ArgumentsCallback argsCallback = getArgsCallback(superNode.getArgsNode());
CompilerCallback closureArg = getBlock(superNode.getIterNode());
+ final boolean superNodeHasIterNode = superNode.getIterNode() instanceof IterNode;
// this is a hacky check; would prefer arity-split Super nodes like Call and FCall
if (superNode.getArgsNode() instanceof ArgsCatNode) {
- context.getInvocationCompiler().invokeDynamicVarargs(null, null, argsCallback, CallType.SUPER, closureArg, superNode.getIterNode() instanceof IterNode);
+ context.getInvocationCompiler().invokeDynamicVarargs(null, null,
+ argsCallback, CallType.SUPER, closureArg, superNodeHasIterNode);
} else {
- context.getInvocationCompiler().invokeDynamic(null, null, argsCallback, CallType.SUPER, closureArg, superNode.getIterNode() instanceof IterNode);
+ context.getInvocationCompiler().invokeDynamic(null, null,
+ argsCallback, CallType.SUPER, closureArg, superNodeHasIterNode);
}
// TODO: don't require pop
@@ -3555,6 +3697,7 @@ public void compileTrue(Node node, BodyCompiler context, boolean expr) {
public void compileUndef(final UndefNode undef, BodyCompiler context, boolean expr) {
CompilerCallback nameArg = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
compile(undef.getName(), context, true);
}
@@ -3575,6 +3718,7 @@ public void compileUntil(Node node, BodyCompiler context, boolean expr) {
} else {
BranchCallback condition = new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
compile(untilNode.getConditionNode(), context, true);
context.negateCurrentValue();
@@ -3583,6 +3727,7 @@ public void branch(BodyCompiler context) {
BranchCallback body = new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
if (untilNode.getBodyNode() != null) {
compile(untilNode.getBodyNode(), context, true);
@@ -3616,6 +3761,7 @@ public void compileVCall(Node node, BodyCompiler context, boolean expr) {
context.getInvocationCompiler().invokeDynamic(vcallNode.getName(), null, null, CallType.VARIABLE, null, false);
// TODO: don't require pop
if (!expr) context.consumeCurrentValue();
+
}
public void compileWhile(Node node, BodyCompiler context, boolean expr) {
@@ -3624,10 +3770,13 @@ public void compileWhile(Node node, BodyCompiler context, boolean expr) {
if (whileNode.getConditionNode().getNodeType().alwaysFalse() &&
whileNode.evaluateAtStart()) {
// do nothing
- if (expr) context.loadNil();
+ if (expr) {
+ context.loadNil();
+ }
} else {
BranchCallback condition = new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
compile(whileNode.getConditionNode(), context, true);
}
@@ -3635,6 +3784,7 @@ public void branch(BodyCompiler context) {
BranchCallback body = new BranchCallback() {
+ @Override
public void branch(BodyCompiler context) {
if (whileNode.getBodyNode() != null) {
compile(whileNode.getBodyNode(), context, true);
@@ -3658,10 +3808,12 @@ public void compileXStr(Node node, BodyCompiler context, boolean expr) {
final XStrNode xstrNode = (XStrNode) node;
ArgumentsCallback argsCallback = new ArgumentsCallback() {
+ @Override
public int getArity() {
return 1;
}
+ @Override
public void call(BodyCompiler context) {
// FIXME: shouldn't this have codeRange like StrNode?
context.createNewString(xstrNode.getValue(), StringSupport.CR_UNKNOWN);
@@ -3676,17 +3828,19 @@ public void compileYield(Node node, BodyCompiler context, boolean expr) {
final YieldNode yieldNode = (YieldNode) node;
ArgumentsCallback argsCallback = getArgsCallback(yieldNode.getArgsNode());
+ final boolean argsCallbackArity1To3 = argsCallback.getArity() == 1 || argsCallback.getArity() == 2 || argsCallback.getArity() == 3;
// TODO: This filtering is kind of gross...it would be nice to get some parser help here
if (argsCallback == null || argsCallback.getArity() == 0) {
context.getInvocationCompiler().yieldSpecific(argsCallback);
- } else if ((argsCallback.getArity() == 1 || argsCallback.getArity() == 2 || argsCallback.getArity() == 3) && yieldNode.getExpandArguments()) {
+ } else if (argsCallbackArity1To3 && yieldNode.getExpandArguments()) {
// send it along as arity-specific, we don't need the array
context.getInvocationCompiler().yieldSpecific(argsCallback);
} else {
CompilerCallback argsCallback2 = null;
if (yieldNode.getArgsNode() != null) {
argsCallback2 = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
compile(yieldNode.getArgsNode(), context,true);
}
@@ -3747,6 +3901,7 @@ public void compileArrayArguments(Node node, BodyCompiler context, boolean expr)
ArrayCallback callback = new ArrayCallback() {
+ @Override
public void nextValue(BodyCompiler context, Object sourceArray, int index) {
Node node = (Node) ((Object[]) sourceArray)[index];
compile(node, context,true);
View
1 src/org/jruby/compiler/ASTCompiler19.java
@@ -327,6 +327,7 @@ public void compileLambda(Node node, BodyCompiler context, boolean expr) {
if (expr) {
context.createNewLambda(new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
compileIter(lambdaNode, context);
}
View
4 src/org/jruby/compiler/ASTInspector.java
@@ -322,9 +322,9 @@ public void inspect(Node node) {
CallNode callNode = (CallNode)node;
inspect(callNode.getReceiverNode());
// check for Proc.new, an especially magic method
- if (callNode.getName() == "new" &&
+ if ("new".equals(callNode.getName()) &&
callNode.getReceiverNode() instanceof ConstNode &&
- ((ConstNode)callNode.getReceiverNode()).getName() == "Proc") {
+ "Proc".equals(((ConstNode)callNode.getReceiverNode()).getName())) {
// Proc.new needs the caller's block to instantiate a proc
setFlag(node, FRAME_BLOCK);
}
View
14 src/org/jruby/compiler/JITCompiler.java
@@ -132,38 +132,47 @@ public JITCompiler(Ruby runtime) {
runtime.getBeanManager().register(this);
}
+ @Override
public long getSuccessCount() {
return counts.successCount.get();
}
+ @Override
public long getCompileCount() {
return counts.compiledCount.get();
}
+ @Override
public long getFailCount() {
return counts.failCount.get();
}
+ @Override
public long getCompileTime() {
return counts.compileTime.get() / 1000;
}
+ @Override
public long getAbandonCount() {
return counts.abandonCount.get();
}
+ @Override
public long getCodeSize() {
return counts.codeSize.get();
}
+ @Override
public long getAverageCodeSize() {
return counts.averageCodeSize.get();
}
+ @Override
public long getAverageCompileTime() {
return counts.averageCompileTime.get() / 1000;
}
+ @Override
public long getLargestCodeSize() {
return counts.largestCodeSize.get();
}
@@ -406,14 +415,17 @@ protected void compile() {
final ASTCompiler compiler = ruby.getInstanceConfig().newCompiler();
CompilerCallback args = new CompilerCallback() {
+ @Override
public void call(BodyCompiler context) {
compiler.compileArgs(argsNode, context, true);
}
};
- ASTInspector inspector = new ASTInspector();
+ ASTInspector inspector = null;
if (ruby.getInstanceConfig().isJitDumping()) {
inspector = new ASTInspector(className, true);
+ } else {
+ inspector = new ASTInspector();
}
// check args first, since body inspection can depend on args
inspector.inspect(argsNode);
View
15 src/org/jruby/ir/IRBuilder.java
@@ -99,7 +99,8 @@
// copy propagation and dead-code elimination.
//
// Something to pay attention to and if this extra pass becomes a concern (not convinced that it is yet),
-// this smart can be built in here. Right now, the goal is to do something simple and straightforward that is going to be correct.
+// this smart can be built in here. Right now, the goal is to do something simple and straightforward
+// that is going to be correct.
//
// 2. Returning null vs manager.getNil()
// ----------------------------
@@ -262,7 +263,9 @@ public static Node buildAST(boolean isCommandLineScript, String arg) {
ruby.getInstanceConfig().setCompileMode(CompileMode.OFFIR);
// inline script
- if (isCommandLineScript) return ruby.parse(ByteList.create(arg), "-e", null, 0, false);
+ if (isCommandLineScript) {
+ return ruby.parse(ByteList.create(arg), "-e", null, 0, false);
+ }
// from file
FileInputStream fis = null;
@@ -281,6 +284,14 @@ public static Node buildAST(boolean isCommandLineScript, String arg) {
}
}
+ /**
+ * factory method creates IR Builder based on specified Ruby version and the
+ * IRManager.
+ * Default is Ruby 1.8.X
+ * @param manager
+ * @param is19 -- is Ruby 1.9.x ?
+ * @return -- Builder object for IR
+ */
public static IRBuilder createIRBuilder(IRManager manager, boolean is19) {
return is19 ? new IRBuilder19(manager) : new IRBuilder(manager);
}
View
20 src/org/jruby/ir/IRScope.java
@@ -675,7 +675,9 @@ private void runCompilerPasses() {
/** Run any necessary passes to get the IR ready for compilation */
public Tuple<Instr[], Map<Integer,Label[]>> prepareForCompilation() {
// Build CFG and run compiler passes, if necessary
- if (getCFG() == null) runCompilerPasses();
+ if (getCFG() == null) {
+ runCompilerPasses();
+ }
// Add this always since we dont re-JIT a previously
// JIT-ted closure. But, check if there are other
@@ -746,7 +748,9 @@ private void runCompilerPasses() {
}
private static Label[] catLabels(Label[] labels, Label cat) {
- if (labels == null) return new Label[] {cat};
+ if (labels == null) {
+ return new Label[] {cat};
+ }
Label[] newLabels = new Label[labels.length + 1];
System.arraycopy(labels, 0, newLabels, 0, labels.length);
newLabels[labels.length] = cat;
@@ -764,7 +768,9 @@ private boolean computeScopeFlags(boolean receivesClosureArg, List<Instr> instrs
} else if (i instanceof CallBase) {
CallBase call = (CallBase) i;
- if (call.targetRequiresCallersBinding()) this.bindingHasEscaped = true;
+ if (call.targetRequiresCallersBinding()) {
+ this.bindingHasEscaped = true;
+ }
if (call.canBeEval()) {
this.usesEval = true;
@@ -1299,9 +1305,11 @@ protected void resetVariableCounter(String prefix) {
protected int getPrefixCountSize(String prefix) {
Integer index = nextVarIndex.get(prefix);
- if (index == null) return 0;
-
- return index.intValue();
+ if (index == null) {
+ return 0;
+ } else {
+ return index.intValue();
+ }
}
public RubyModule getContainerModule() {