Skip to content

Commit

Permalink
Merge pull request #12 from mtrberzi/schematic-value-visitor
Browse files Browse the repository at this point in the history
Add interface for SchematicValueVisitor
  • Loading branch information
mtrberzi committed Sep 9, 2014
2 parents da8c0a9 + 5f75217 commit 080ee0d
Show file tree
Hide file tree
Showing 21 changed files with 109 additions and 20 deletions.
8 changes: 5 additions & 3 deletions src/main/java/org/manifold/compiler/ArrayTypeValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ public class ArrayTypeValue extends TypeValue {

private final TypeValue elementType;

public TypeValue getElementType(){
public TypeValue getElementType() {
return this.elementType;
}

public ArrayTypeValue(TypeValue elementType){
public ArrayTypeValue(TypeValue elementType) {
this.elementType = elementType;
}


public void accept(SchematicValueVisitor visitor) {
visitor.visit(this);
}

}
4 changes: 3 additions & 1 deletion src/main/java/org/manifold/compiler/ArrayValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public boolean isRuntimeKnowable() {
return true;
}


public void accept(SchematicValueVisitor visitor) {
visitor.visit(this);
}

}
4 changes: 3 additions & 1 deletion src/main/java/org/manifold/compiler/BooleanTypeValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public static BooleanTypeValue getInstance() {

private BooleanTypeValue() { }


public void accept(SchematicValueVisitor visitor) {
visitor.visit(this);
}

}
4 changes: 3 additions & 1 deletion src/main/java/org/manifold/compiler/BooleanValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public boolean isRuntimeKnowable() {
return true;
}


public void accept(SchematicValueVisitor visitor) {
visitor.visit(this);
}

}
4 changes: 3 additions & 1 deletion src/main/java/org/manifold/compiler/ConnectionType.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public ImmutableMap<String, TypeValue> getAttributes() {
return attributes;
}


public void accept(SchematicValueVisitor visitor) {
visitor.visit(this);
}

}
4 changes: 3 additions & 1 deletion src/main/java/org/manifold/compiler/ConnectionValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public boolean isRuntimeKnowable() {
return true;
}


public void accept(SchematicValueVisitor visitor) {
visitor.visit(this);
}

}
4 changes: 3 additions & 1 deletion src/main/java/org/manifold/compiler/ConstraintType.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public ImmutableMap<String, TypeValue> getAttributes() {
return attributes;
}


public void accept(SchematicValueVisitor visitor) {
visitor.visit(this);
}

}
4 changes: 3 additions & 1 deletion src/main/java/org/manifold/compiler/ConstraintValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public boolean isRuntimeKnowable() {
return true;
}


public void accept(SchematicValueVisitor visitor) {
visitor.visit(this);
}

}
4 changes: 3 additions & 1 deletion src/main/java/org/manifold/compiler/IntegerTypeValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public static IntegerTypeValue getInstance() {
return instance;
}


public void accept(SchematicValueVisitor visitor) {
visitor.visit(this);
}

}
4 changes: 3 additions & 1 deletion src/main/java/org/manifold/compiler/IntegerValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public boolean isRuntimeKnowable() {
return false;
}


public void accept(SchematicValueVisitor visitor) {
visitor.visit(this);
}

}
4 changes: 3 additions & 1 deletion src/main/java/org/manifold/compiler/NilTypeValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public static NilTypeValue getInstance() {

private NilTypeValue() { }


public void accept(SchematicValueVisitor visitor) {
visitor.visit(this);
}

}
4 changes: 3 additions & 1 deletion src/main/java/org/manifold/compiler/NodeTypeValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public Map<String, PortTypeValue> getPorts() {
return this.ports;
}


public void accept(SchematicValueVisitor visitor) {
visitor.visit(this);
}

}
4 changes: 3 additions & 1 deletion src/main/java/org/manifold/compiler/NodeValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public boolean isRuntimeKnowable() {
return true;
}


public void accept(SchematicValueVisitor visitor) {
visitor.visit(this);
}

}
4 changes: 3 additions & 1 deletion src/main/java/org/manifold/compiler/PortTypeValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public Map<String, TypeValue> getAttributes() {
return this.attributes;
}


public void accept(SchematicValueVisitor visitor) {
visitor.visit(this);
}

}
4 changes: 3 additions & 1 deletion src/main/java/org/manifold/compiler/PortValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public boolean isRuntimeKnowable() {
return true;
}


public void accept(SchematicValueVisitor visitor) {
visitor.visit(this);
}

}
41 changes: 41 additions & 0 deletions src/main/java/org/manifold/compiler/SchematicValueVisitor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.manifold.compiler;

public interface SchematicValueVisitor {

void visit(ArrayTypeValue arrayTypeValue);

void visit(TypeTypeValue typeTypeValue);

void visit(StringValue stringValue);

void visit(StringTypeValue stringTypeValue);

void visit(PortValue portValue);

void visit(PortTypeValue portTypeValue);

void visit(NodeValue nodeValue);

void visit(NodeTypeValue nodeTypeValue);

void visit(NilTypeValue nilTypeValue);

void visit(IntegerValue integerValue);

void visit(ConstraintValue constraintValue);

void visit(IntegerTypeValue integerTypeValue);

void visit(ConstraintType constraintType);

void visit(ConnectionValue connectionValue);

void visit(ConnectionType connectionType);

void visit(BooleanValue booleanValue);

void visit(BooleanTypeValue booleanTypeValue);

void visit(ArrayValue arrayValue);

}
4 changes: 3 additions & 1 deletion src/main/java/org/manifold/compiler/StringTypeValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public static StringTypeValue getInstance() {
return instance;
}


public void accept(SchematicValueVisitor visitor) {
visitor.visit(this);
}

}
4 changes: 3 additions & 1 deletion src/main/java/org/manifold/compiler/StringValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public boolean isRuntimeKnowable() {
return false;
}


public void accept(SchematicValueVisitor visitor) {
visitor.visit(this);
}

}
4 changes: 3 additions & 1 deletion src/main/java/org/manifold/compiler/TypeTypeValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public boolean isSubtypeOf(TypeValue type) {
return this == type;
}


public void accept(SchematicValueVisitor visitor) {
visitor.visit(this);
}

}
8 changes: 8 additions & 0 deletions src/main/java/org/manifold/compiler/Value.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,12 @@ public void verify() throws Exception {}
*/
public abstract boolean isRuntimeKnowable();

/*
* Allows SchematicValueVisitors to process this Value.
* Must be overridden in every subclass of Value that can be instantiated,
* usually with code of the form "visitor.visit(this);".
*/

public abstract void accept(SchematicValueVisitor visitor);

}
4 changes: 4 additions & 0 deletions src/test/java/org/manifold/compiler/TestTypeValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ private FacadeTypeValue() {}

@Override
public void verify() {}

// Not tested.
public void accept(SchematicValueVisitor visitor) {}

}

private TypeValue getInstance() {
Expand Down

0 comments on commit 080ee0d

Please sign in to comment.