diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-04-17 15:33:54 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-04-17 15:33:54 +0100 |
| commit | ecfac0740033b048b55001332eb11131b64ddcaf (patch) | |
| tree | bd499f42accc622a1da57b0a63a67f2fdeb139f7 /src/main/java/org/zwobble/couscous/ast/ExceptionHandlerNode.java | |
| parent | bafd17e14f610511cd7a191223a3561b1602892a (diff) | |
Add try nodes
Diffstat (limited to 'src/main/java/org/zwobble/couscous/ast/ExceptionHandlerNode.java')
| -rw-r--r-- | src/main/java/org/zwobble/couscous/ast/ExceptionHandlerNode.java | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/main/java/org/zwobble/couscous/ast/ExceptionHandlerNode.java b/src/main/java/org/zwobble/couscous/ast/ExceptionHandlerNode.java new file mode 100644 index 0000000..a7e307b --- /dev/null +++ b/src/main/java/org/zwobble/couscous/ast/ExceptionHandlerNode.java @@ -0,0 +1,54 @@ +package org.zwobble.couscous.ast; + +import org.zwobble.couscous.types.Type; + +import java.util.List; + +public class ExceptionHandlerNode { + public static ExceptionHandlerNode exceptionhandler(Type type, List<StatementNode> body) { + return new ExceptionHandlerNode(type, body); + } + + private final Type type; + private final List<StatementNode> body; + + public ExceptionHandlerNode(Type type, List<StatementNode> body) { + this.type = type; + this.body = body; + } + + public Type getExceptionType() { + return type; + } + + public List<StatementNode> getBody() { + return body; + } + + @Override + public String toString() { + return "ExceptionHandlerNode(" + + "type=" + type + + ", body=" + body + + ')'; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + ExceptionHandlerNode that = (ExceptionHandlerNode) o; + + if (!type.equals(that.type)) return false; + return body.equals(that.body); + + } + + @Override + public int hashCode() { + int result = type.hashCode(); + result = 31 * result + body.hashCode(); + return result; + } +} |
