add context analysis and custom visitors

This commit is contained in:
2019-11-04 17:35:15 +01:00
parent bef26434c6
commit c26cb6ddf5
22 changed files with 355 additions and 123 deletions

View File

@@ -1,55 +1,13 @@
package de.hsrm.compiler.Klang;
public class Value {
private Object value;
public static Value VOID = new Value(new Object());
public Value(Object value) {
this.value = value;
}
final Object value;
public Value(Object value) {
this.value = value;
}
public Integer asInteger() {
return (Integer)value;
}
public String asString() {
return String.valueOf(value);
}
public boolean isDouble() {
return value instanceof Double;
}
@Override
public int hashCode() {
if(value == null) {
return 0;
}
return this.value.hashCode();
}
@Override
public boolean equals(Object o) {
if(value == o) {
return true;
}
if(value == null || o == null || o.getClass() != value.getClass()) {
return false;
}
Value that = (Value)o;
return this.value.equals(that.value);
}
@Override
public String toString() {
return String.valueOf(value);
}
public int asInteger() {
return (int) this.value;
}
}