From a5f76463dfc74d9b126f65416a51905a995c711d Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 17 Apr 2016 15:47:28 +0100 Subject: C# serializer: serialize try statements --- .../zwobble/couscous/ast/ExceptionHandlerNode.java | 28 ++++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'src/main/java/org/zwobble/couscous/ast/ExceptionHandlerNode.java') diff --git a/src/main/java/org/zwobble/couscous/ast/ExceptionHandlerNode.java b/src/main/java/org/zwobble/couscous/ast/ExceptionHandlerNode.java index a7e307b..5e80fcf 100644 --- a/src/main/java/org/zwobble/couscous/ast/ExceptionHandlerNode.java +++ b/src/main/java/org/zwobble/couscous/ast/ExceptionHandlerNode.java @@ -5,30 +5,38 @@ import org.zwobble.couscous.types.Type; import java.util.List; public class ExceptionHandlerNode { - public static ExceptionHandlerNode exceptionhandler(Type type, List body) { - return new ExceptionHandlerNode(type, body); + public static ExceptionHandlerNode exceptionhandler(VariableDeclaration declaration, List body) { + return new ExceptionHandlerNode(declaration, body); } - private final Type type; + private final VariableDeclaration declaration; private final List body; - public ExceptionHandlerNode(Type type, List body) { - this.type = type; + public ExceptionHandlerNode(VariableDeclaration declaration, List body) { + this.declaration = declaration; this.body = body; } - public Type getExceptionType() { - return type; + public VariableDeclaration getDeclaration() { + return declaration; } public List getBody() { return body; } + public Type getExceptionType() { + return declaration.getType(); + } + + public String getExceptionName() { + return declaration.getName(); + } + @Override public String toString() { return "ExceptionHandlerNode(" + - "type=" + type + + "declaration=" + declaration + ", body=" + body + ')'; } @@ -40,14 +48,14 @@ public class ExceptionHandlerNode { ExceptionHandlerNode that = (ExceptionHandlerNode) o; - if (!type.equals(that.type)) return false; + if (!declaration.equals(that.declaration)) return false; return body.equals(that.body); } @Override public int hashCode() { - int result = type.hashCode(); + int result = declaration.hashCode(); result = 31 * result + body.hashCode(); return result; } -- cgit v1.2.3