Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make remaining AST classes public. Fixes jkuhnert/ognl#102 #115

Merged
merged 1 commit into from
Dec 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/ognl/ASTAdd.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* @author Luke Blanshard ([email protected])
* @author Drew Davidson ([email protected])
*/
class ASTAdd extends NumericExpression
public class ASTAdd extends NumericExpression
{
public ASTAdd(int id)
{
Expand Down
34 changes: 17 additions & 17 deletions src/main/java/ognl/ASTAssign.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* @author Luke Blanshard ([email protected])
* @author Drew Davidson ([email protected])
*/
class ASTAssign extends SimpleNode
public class ASTAssign extends SimpleNode
{
public ASTAssign(int id) {
super(id);
Expand All @@ -58,20 +58,20 @@ public String toString()
{
return _children[0] + " = " + _children[1];
}

public String toGetSourceString(OgnlContext context, Object target)
{
String result = "";

String first = _children[0].toGetSourceString(context, target);
String second = "";

if (ASTProperty.class.isInstance(_children[1])) {
second += "((" + OgnlRuntime.getCompiler().getClassName(target.getClass()) + ")$2).";
}

second += _children[1].toGetSourceString(context, target);

if (ASTSequence.class.isAssignableFrom(_children[1].getClass())) {
ASTSequence seq = (ASTSequence)_children[1];

Expand All @@ -89,10 +89,10 @@ public String toGetSourceString(OgnlContext context, Object target)
if (NodeType.class.isInstance(_children[1])
&& !ASTProperty.class.isInstance(_children[1])
&& ((NodeType)_children[1]).getGetterClass() != null && !OrderedReturn.class.isInstance(_children[1])) {

second = "new " + ((NodeType)_children[1]).getGetterClass().getName() + "(" + second + ")";
}

if (OrderedReturn.class.isAssignableFrom(_children[0].getClass())
&& ((OrderedReturn)_children[0]).getCoreExpression() != null) {
context.setCurrentType(Object.class);
Expand All @@ -108,35 +108,35 @@ public String toGetSourceString(OgnlContext context, Object target)

return result;
}

public String toSetSourceString(OgnlContext context, Object target)
{
String result = "";

result += _children[0].toSetSourceString(context, target);

if (ASTProperty.class.isInstance(_children[1])) {
result += "((" + OgnlRuntime.getCompiler().getClassName(target.getClass()) + ")$2).";
}

String value =_children[1].toSetSourceString(context, target);

if (value == null)
throw new UnsupportedCompilationException("Value for assignment is null, can't enhance statement to bytecode.");

if (ASTSequence.class.isAssignableFrom(_children[1].getClass())) {
ASTSequence seq = (ASTSequence)_children[1];
result = seq.getCoreExpression() + result;
value = seq.getLastExpression();
}
if (NodeType.class.isInstance(_children[1])

if (NodeType.class.isInstance(_children[1])
&& !ASTProperty.class.isInstance(_children[1])
&& ((NodeType)_children[1]).getGetterClass() != null) {

value = "new " + ((NodeType)_children[1]).getGetterClass().getName() + "(" + value + ")";
}

return result + value + ")";
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/ognl/ASTBitAnd.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* @author Luke Blanshard ([email protected])
* @author Drew Davidson ([email protected])
*/
class ASTBitAnd extends NumericExpression
public class ASTBitAnd extends NumericExpression
{
public ASTBitAnd(int id) {
super(id);
Expand All @@ -60,7 +60,7 @@ public String getExpressionOperator(int index)
{
return "&";
}

public String coerceToNumeric(String source, OgnlContext context, Node child)
{
return "(long)" + super.coerceToNumeric(source, context, child);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ognl/ASTBitNegate.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* @author Luke Blanshard ([email protected])
* @author Drew Davidson ([email protected])
*/
class ASTBitNegate extends NumericExpression
public class ASTBitNegate extends NumericExpression
{
public ASTBitNegate(int id) {
super(id);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ognl/ASTBitOr.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* @author Luke Blanshard ([email protected])
* @author Drew Davidson ([email protected])
*/
class ASTBitOr extends NumericExpression
public class ASTBitOr extends NumericExpression
{
public ASTBitOr(int id) {
super(id);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/ognl/ASTDivide.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* @author Luke Blanshard ([email protected])
* @author Drew Davidson ([email protected])
*/
class ASTDivide extends NumericExpression
public class ASTDivide extends NumericExpression
{
public ASTDivide(int id) {
super(id);
Expand All @@ -55,5 +55,5 @@ public String getExpressionOperator(int index)
{
return "/";
}

}
6 changes: 3 additions & 3 deletions src/main/java/ognl/ASTEq.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* @author Luke Blanshard ([email protected])
* @author Drew Davidson ([email protected])
*/
class ASTEq extends ComparisonExpression
public class ASTEq extends ComparisonExpression
{
public ASTEq(int id) {
super(id);
Expand All @@ -51,12 +51,12 @@ protected Object getValueBody( OgnlContext context, Object source ) throws OgnlE
Object v2 = _children[1].getValue( context, source );
return OgnlOps.equal( v1, v2 )? Boolean.TRUE : Boolean.FALSE;
}

public String getExpressionOperator(int index)
{
return "==";
}

public String getComparisonFunction()
{
return "ognl.OgnlOps.equal";
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/ognl/ASTEval.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* @author Luke Blanshard ([email protected])
* @author Drew Davidson ([email protected])
*/
class ASTEval extends SimpleNode
public class ASTEval extends SimpleNode
{

public ASTEval(int id)
Expand Down Expand Up @@ -91,12 +91,12 @@ public String toString()
{
return "(" + _children[0] + ")(" + _children[1] + ")";
}

public String toGetSourceString(OgnlContext context, Object target)
{
throw new UnsupportedCompilationException("Eval expressions not supported as native java yet.");
}

public String toSetSourceString(OgnlContext context, Object target)
{
throw new UnsupportedCompilationException("Map expressions not supported as native java yet.");
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/ognl/ASTGreater.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* @author Luke Blanshard ([email protected])
* @author Drew Davidson ([email protected])
*/
class ASTGreater extends ComparisonExpression
public class ASTGreater extends ComparisonExpression
{
public ASTGreater(int id) {
super(id);
Expand All @@ -49,15 +49,15 @@ protected Object getValueBody( OgnlContext context, Object source ) throws OgnlE
{
Object v1 = _children[0].getValue( context, source );
Object v2 = _children[1].getValue( context, source );

return OgnlOps.greater( v1, v2 )? Boolean.TRUE : Boolean.FALSE;
}

public String getExpressionOperator(int index)
{
return ">";
}

public String getComparisonFunction()
{
return "ognl.OgnlOps.greater";
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/ognl/ASTGreaterEq.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* @author Luke Blanshard ([email protected])
* @author Drew Davidson ([email protected])
*/
class ASTGreaterEq extends ComparisonExpression
public class ASTGreaterEq extends ComparisonExpression
{
public ASTGreaterEq(int id) {
super(id);
Expand All @@ -56,7 +56,7 @@ public String getExpressionOperator(int index)
{
return ">=";
}

public String getComparisonFunction()
{
return "!ognl.OgnlOps.less";
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/ognl/ASTIn.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* @author Luke Blanshard ([email protected])
* @author Drew Davidson ([email protected])
*/
class ASTIn extends SimpleNode implements NodeType
public class ASTIn extends SimpleNode implements NodeType
{
public ASTIn(int id) {
super(id);
Expand All @@ -46,7 +46,7 @@ public ASTIn(OgnlParser p, int id) {
super(p, id);
}

protected Object getValueBody( OgnlContext context, Object source )
protected Object getValueBody( OgnlContext context, Object source )
throws OgnlException
{
Object v1 = _children[0].getValue( context, source );
Expand All @@ -59,41 +59,41 @@ public String toString()
{
return _children[0] + " in " + _children[1];
}

public Class getGetterClass()
{
return Boolean.TYPE;
}

public Class getSetterClass()
{
return null;
}

public String toGetSourceString(OgnlContext context, Object target)
{
try {
String result = "ognl.OgnlOps.in( ($w) ";

result += OgnlRuntime.getChildSource(context, target, _children[0]) + ", ($w) " + OgnlRuntime.getChildSource(context, target, _children[1]);

result += ")";

context.setCurrentType(Boolean.TYPE);

return result;
} catch (NullPointerException e) {

// expected to happen in some instances
e.printStackTrace();

throw new UnsupportedCompilationException("evaluation resulted in null expression.");
} catch (Throwable t)
{
throw OgnlOps.castToRuntime(t);
}
}

public String toSetSourceString(OgnlContext context, Object target)
{
throw new UnsupportedCompilationException("Map expressions not supported as native java yet.");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ognl/ASTKeyValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* @author Luke Blanshard ([email protected])
* @author Drew Davidson ([email protected])
*/
class ASTKeyValue extends SimpleNode
public class ASTKeyValue extends SimpleNode
{
public ASTKeyValue(int id) {
super(id);
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/ognl/ASTLessEq.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
* @author Luke Blanshard ([email protected])
* @author Drew Davidson ([email protected])
*/
class ASTLessEq extends ComparisonExpression
{
public class ASTLessEq extends ComparisonExpression
{
public ASTLessEq(int id) {
super(id);
}
Expand All @@ -51,15 +51,15 @@ protected Object getValueBody( OgnlContext context, Object source ) throws OgnlE
Object v2 = _children[1].getValue( context, source );
return OgnlOps.greater( v1, v2 )? Boolean.FALSE : Boolean.TRUE;
}

public String getExpressionOperator(int index)
{
return "<=";
}

public String getComparisonFunction()
{
return "!ognl.OgnlOps.greater";
}

}
Loading