Skip to content
Permalink
Browse files
Raise embedded if into parent if.
  • Loading branch information
garydgregory committed Feb 28, 2021
1 parent 0e3b07c commit e76e0ca09e495b9ae707ae29e9e43bde83f547c8
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 43 deletions.
@@ -517,13 +517,11 @@ protected Object visit(final ASTUnaryMinusNode node, final Object data) {
}
Object number = arithmetic.negate(val);
// attempt to recoerce to literal class
if ((number instanceof Number)) {
// cache if number literal and negate is idempotent
if (valNode instanceof ASTNumberLiteral) {
number = arithmetic.narrowNumber((Number) number, ((ASTNumberLiteral) valNode).getLiteralClass());
if (arithmetic.isNegateStable()) {
node.jjtSetValue(number);
}
// cache if number literal and negate is idempotent
if (number instanceof Number && valNode instanceof ASTNumberLiteral) {
number = arithmetic.narrowNumber((Number) number, ((ASTNumberLiteral) valNode).getLiteralClass());
if (arithmetic.isNegateStable()) {
node.jjtSetValue(number);
}
}
return number;
@@ -223,17 +223,15 @@ protected Object resolveNamespace(final String prefix, final JexlNode node) {
}
}
// try again; use a class, namespace of static methods
if (functor == null) {
// try to find a class with that name
if (namespace instanceof String) {
try {
namespace = uberspect.getClassLoader().loadClass((String) namespace);
} catch (final ClassNotFoundException xignore) {
// not a class
namespace = null;
}
} // we know its a class
}
// try to find a class with that name
if (functor == null && namespace instanceof String) {
try {
namespace = uberspect.getClassLoader().loadClass((String) namespace);
} catch (final ClassNotFoundException xignore) {
// not a class
namespace = null;
}
} // we know its a class
}
}
}
@@ -305,12 +303,10 @@ protected Object getVariable(final Frame frame, final LexicalScope block, final
if (options.isLexicalShade() && identifier.isShaded()) {
return undefinedVariable(identifier, identifier.getName());
}
if (symbol >= 0) {
if (frame.has(symbol)) {
final Object value = frame.get(symbol);
if (value != Scope.UNDEFINED) {
return value;
}
if ((symbol >= 0) && frame.has(symbol)) {
final Object value = frame.get(symbol);
if (value != Scope.UNDEFINED) {
return value;
}
}
final String name = identifier.getName();
@@ -197,20 +197,18 @@ private static Scope scopeOf(final JexlNode.Info info) {
*/
private static void collectPrintScope(final JexlNode node, final Map<Integer, JexlNode.Info> minfo) {
final int nc = node.jjtGetNumChildren();
if (node instanceof ASTFunctionNode) {
if (nc == 2) {
// 0 must be the prefix jexl:
final ASTIdentifier nameNode = (ASTIdentifier) node.jjtGetChild(0);
if ("print".equals(nameNode.getName()) && "jexl".equals(nameNode.getNamespace())) {
final ASTArguments argNode = (ASTArguments) node.jjtGetChild(1);
if (argNode.jjtGetNumChildren() == 1) {
// seek the epression number
final JexlNode arg0 = argNode.jjtGetChild(0);
if (arg0 instanceof ASTNumberLiteral) {
final int exprNumber = ((ASTNumberLiteral) arg0).getLiteral().intValue();
minfo.put(exprNumber, new JexlNode.Info(nameNode));
return;
}
if (node instanceof ASTFunctionNode && nc == 2) {
// 0 must be the prefix jexl:
final ASTIdentifier nameNode = (ASTIdentifier) node.jjtGetChild(0);
if ("print".equals(nameNode.getName()) && "jexl".equals(nameNode.getNamespace())) {
final ASTArguments argNode = (ASTArguments) node.jjtGetChild(1);
if (argNode.jjtGetNumChildren() == 1) {
// seek the epression number
final JexlNode arg0 = argNode.jjtGetChild(0);
if (arg0 instanceof ASTNumberLiteral) {
final int exprNumber = ((ASTNumberLiteral) arg0).getLiteral().intValue();
minfo.put(exprNumber, new JexlNode.Info(nameNode));
return;
}
}
}
@@ -575,11 +575,9 @@ private AmbiguousException ambiguousException (final Class<?>[] classes, final L
for (final T app : applicables) {
final Class<?>[] parmClasses = getParameterTypes(app);
final Class<?> parmClass = parmClasses[c];
if (Object.class.equals(parmClass)) {
if (objectParmCount++ == 2) {
severe = true;
break;
}
if (Object.class.equals(parmClass) && (objectParmCount++ == 2)) {
severe = true;
break;
}
}
} else {

0 comments on commit e76e0ca

Please sign in to comment.