aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/zwobble/couscous/ast/StaticMethodCallNode.java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2015-10-31 16:07:19 +0000
committerMichael Williamson <mike@zwobble.org>2015-10-31 16:07:19 +0000
commitad4903f04c757779b2e9a875298ef8418cb140b4 (patch)
tree49c28509587633d484e6fbcdd8537e15e854a567 /src/main/java/org/zwobble/couscous/ast/StaticMethodCallNode.java
parent4e13a3a626f630eb1031f32b1c3405cbf40952bc (diff)
Support equality on reference types
Diffstat (limited to 'src/main/java/org/zwobble/couscous/ast/StaticMethodCallNode.java')
-rw-r--r--src/main/java/org/zwobble/couscous/ast/StaticMethodCallNode.java42
1 files changed, 29 insertions, 13 deletions
diff --git a/src/main/java/org/zwobble/couscous/ast/StaticMethodCallNode.java b/src/main/java/org/zwobble/couscous/ast/StaticMethodCallNode.java
index 2b63948..4af0701 100644
--- a/src/main/java/org/zwobble/couscous/ast/StaticMethodCallNode.java
+++ b/src/main/java/org/zwobble/couscous/ast/StaticMethodCallNode.java
@@ -3,36 +3,46 @@ package org.zwobble.couscous.ast;
import java.util.List;
import org.zwobble.couscous.ast.visitors.ExpressionNodeMapper;
+import org.zwobble.couscous.values.BooleanValue;
+import org.zwobble.couscous.values.InternalCouscousValue;
import static java.util.Arrays.asList;
public class StaticMethodCallNode implements ExpressionNode {
- public static StaticMethodCallNode staticMethodCall(String className, String methodName, ExpressionNode... arguments) {
- return staticMethodCall(className, methodName, asList(arguments));
+ public static ExpressionNode same(ExpressionNode left, ExpressionNode right) {
+ return staticMethodCall(InternalCouscousValue.REF, "same", asList(left, right), BooleanValue.REF);
}
- public static StaticMethodCallNode staticMethodCall(String className, String methodName, List<ExpressionNode> arguments) {
- return staticMethodCall(TypeName.of(className), methodName, arguments);
+ public static StaticMethodCallNode staticMethodCall(
+ String className,
+ String methodName,
+ List<ExpressionNode> arguments,
+ TypeName type) {
+ return staticMethodCall(TypeName.of(className), methodName, arguments, type);
}
public static StaticMethodCallNode staticMethodCall(
TypeName className,
String methodName,
- List<ExpressionNode> arguments) {
- return new StaticMethodCallNode(className, methodName, arguments);
+ List<ExpressionNode> arguments,
+ TypeName type) {
+ return new StaticMethodCallNode(className, methodName, arguments, type);
}
private final TypeName className;
private final String methodName;
private final List<ExpressionNode> arguments;
+ private final TypeName type;
public StaticMethodCallNode(
TypeName className,
String methodName,
- List<ExpressionNode> arguments) {
+ List<ExpressionNode> arguments,
+ TypeName type) {
this.className = className;
this.methodName = methodName;
this.arguments = arguments;
+ this.type = type;
}
public TypeName getClassName() {
@@ -47,20 +57,20 @@ public class StaticMethodCallNode implements ExpressionNode {
return arguments;
}
+ public TypeName getType() {
+ return type;
+ }
+
@Override
public <T> T accept(ExpressionNodeMapper<T> visitor) {
return visitor.visit(this);
}
@Override
- public TypeName getType() {
- throw new UnsupportedOperationException();
- }
-
- @Override
public String toString() {
return "StaticMethodCallNode(className=" + className + ", methodName="
- + methodName + ", arguments=" + arguments + ")";
+ + methodName + ", arguments=" + arguments + ", type=" + type
+ + ")";
}
@Override
@@ -73,6 +83,7 @@ public class StaticMethodCallNode implements ExpressionNode {
+ ((className == null) ? 0 : className.hashCode());
result = prime * result
+ ((methodName == null) ? 0 : methodName.hashCode());
+ result = prime * result + ((type == null) ? 0 : type.hashCode());
return result;
}
@@ -100,6 +111,11 @@ public class StaticMethodCallNode implements ExpressionNode {
return false;
} else if (!methodName.equals(other.methodName))
return false;
+ if (type == null) {
+ if (other.type != null)
+ return false;
+ } else if (!type.equals(other.type))
+ return false;
return true;
}
}