From a82ecb60d6ee7ee46e5800088f1769f86872077b Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Mon, 29 Aug 2016 17:13:03 +0100 Subject: Initial support for static methods/fields on interfaces --- .../org/zwobble/couscous/ast/InterfaceNode.java | 50 ++++++++++++++++------ 1 file changed, 37 insertions(+), 13 deletions(-) (limited to 'src/main/java/org/zwobble/couscous/ast/InterfaceNode.java') diff --git a/src/main/java/org/zwobble/couscous/ast/InterfaceNode.java b/src/main/java/org/zwobble/couscous/ast/InterfaceNode.java index de151e4..c0444a4 100644 --- a/src/main/java/org/zwobble/couscous/ast/InterfaceNode.java +++ b/src/main/java/org/zwobble/couscous/ast/InterfaceNode.java @@ -12,26 +12,34 @@ public class InterfaceNode implements TypeNode { ScalarType name, List typeParameters, Set superTypes, + List fields, + List staticConstructor, List methods) { - return new InterfaceNode(name, typeParameters, superTypes, methods); + return new InterfaceNode(name, typeParameters, superTypes, fields, staticConstructor, methods); } private final ScalarType name; private final List typeParameters; private final Set superTypes; + private final List fields; + private final List staticConstructor; private final List methods; private InterfaceNode( ScalarType name, List typeParameters, Set superTypes, - List methodNodes) + List fields, + List staticConstructor, + List methods) { this.name = name; this.typeParameters = typeParameters; this.superTypes = superTypes; - methods = methodNodes; + this.fields = fields; + this.staticConstructor = staticConstructor; + this.methods = methods; } @Override @@ -49,19 +57,17 @@ public class InterfaceNode implements TypeNode { return superTypes; } - @Override - public List getMethods() { - return methods; + public List getFields() { + return fields; + } + + public List getStaticConstructor() { + return staticConstructor; } @Override - public String toString() { - return "InterfaceNode(" + - "name=" + name + - ", typeParameters=" + typeParameters + - ", superTypes=" + superTypes + - ", methods=" + methods + - ')'; + public List getMethods() { + return methods; } @Override @@ -80,9 +86,23 @@ public class InterfaceNode implements TypeNode { transformer.transform(name), transformer.transformFormalTypeParameters(typeParameters), transformer.transformTypes(superTypes), + transformer.transformFields(fields), + transformer.transformStatements(staticConstructor), transformer.transformMethods(methods)); } + @Override + public String toString() { + return "InterfaceNode(" + + "name=" + name + + ", typeParameters=" + typeParameters + + ", superTypes=" + superTypes + + ", fields=" + fields + + ", staticConstructor=" + staticConstructor + + ", methods=" + methods + + ')'; + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -93,6 +113,8 @@ public class InterfaceNode implements TypeNode { if (!name.equals(that.name)) return false; if (!typeParameters.equals(that.typeParameters)) return false; if (!superTypes.equals(that.superTypes)) return false; + if (!fields.equals(that.fields)) return false; + if (!staticConstructor.equals(that.staticConstructor)) return false; return methods.equals(that.methods); } @@ -102,6 +124,8 @@ public class InterfaceNode implements TypeNode { int result = name.hashCode(); result = 31 * result + typeParameters.hashCode(); result = 31 * result + superTypes.hashCode(); + result = 31 * result + fields.hashCode(); + result = 31 * result + staticConstructor.hashCode(); result = 31 * result + methods.hashCode(); return result; } -- cgit v1.2.3