diff options
Diffstat (limited to 'src')
3 files changed, 57 insertions, 5 deletions
diff --git a/src/main/com/jantuomi/tunkki/core/parser/ast/ObjectDefinitionNode.java b/src/main/com/jantuomi/tunkki/core/parser/ast/ObjectDefinitionNode.java index 2a9a19d..d02fb0c 100644 --- a/src/main/com/jantuomi/tunkki/core/parser/ast/ObjectDefinitionNode.java +++ b/src/main/com/jantuomi/tunkki/core/parser/ast/ObjectDefinitionNode.java @@ -2,7 +2,7 @@ package com.jantuomi.tunkki.core.parser.ast; import com.jantuomi.tunkki.core.parser.datatype.CallableDatatype; import com.jantuomi.tunkki.core.parser.datatype.Datatype; -import com.jantuomi.tunkki.core.parser.datatype.ObjectDatatype; +import com.jantuomi.tunkki.core.parser.datatype.ObjectPrototypeDatatype; import com.jantuomi.tunkki.core.parser.tokenizer.token.Token; import com.jantuomi.tunkki.core.runtime.Function; import com.jantuomi.tunkki.core.runtime.State; @@ -29,14 +29,15 @@ public class ObjectDefinitionNode extends NullaryOperatorNode { @Override public Datatype evaluate() throws TunkkiError { - ObjectDatatype obj = new ObjectDatatype(); + ObjectPrototypeDatatype prototype = new ObjectPrototypeDatatype(); State state = new State(); constructor.call(Collections.emptyList()); Function func = constructor.getData(); func.setState(state); - obj.setData(func.getState().getGlobalScope()); - return obj; + prototype.setData(func); + State.getGlobalState().addSymbolToScope(name); + return prototype; } } diff --git a/src/main/com/jantuomi/tunkki/core/parser/datatype/Datatype.java b/src/main/com/jantuomi/tunkki/core/parser/datatype/Datatype.java index 9983d64..1e4dafc 100644 --- a/src/main/com/jantuomi/tunkki/core/parser/datatype/Datatype.java +++ b/src/main/com/jantuomi/tunkki/core/parser/datatype/Datatype.java @@ -19,7 +19,8 @@ abstract public class Datatype<T> { Nada, Void, Callable, - Object + Object, + ObjectPrototype } abstract public Type getType(); diff --git a/src/main/com/jantuomi/tunkki/core/parser/datatype/ObjectPrototypeDatatype.java b/src/main/com/jantuomi/tunkki/core/parser/datatype/ObjectPrototypeDatatype.java new file mode 100644 index 0000000..5177d20 --- /dev/null +++ b/src/main/com/jantuomi/tunkki/core/parser/datatype/ObjectPrototypeDatatype.java @@ -0,0 +1,50 @@ +package com.jantuomi.tunkki.core.parser.datatype; + +import com.jantuomi.tunkki.core.runtime.Function; +import com.jantuomi.tunkki.exception.types.TunkkiError; + +/** + * Created by jan on 29.8.2016. + */ +public class ObjectPrototypeDatatype extends Datatype<Function> { + @Override + public Type getType() { + return Type.ObjectPrototype; + } + + @Override + public String toString() { + return "Object prototype"; + } + + public ObjectDatatype instantiate() { + ObjectDatatype obj = new ObjectDatatype(); + obj.setData(getData().getState().getGlobalScope()); + return obj; + } + + @Override + public Datatype add(Datatype other) throws TunkkiError { + return null; + } + + @Override + public Datatype subtract(Datatype other) throws TunkkiError { + return null; + } + + @Override + public Datatype multiply(Datatype other) throws TunkkiError { + return null; + } + + @Override + public Datatype divide(Datatype other) throws TunkkiError { + return null; + } + + @Override + public BooleanDatatype equals(Datatype other) throws TunkkiError { + return null; + } +} |
