X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Fcommands%2FCommandSession.java;fp=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Fcommands%2FCommandSession.java;h=00a7714a63640a3f2ae31bd29df0625c7f455ff4;hp=d0e44a9c7b263a36c0a75b60cc5f678432081165;hb=08a43c849e0bed256394e3861326af9ce26a9917;hpb=fcb5a762af707ecef245fb3b83a36e8b24bc4b47 diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/commands/CommandSession.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/commands/CommandSession.java index d0e44a9c7..00a7714a6 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/commands/CommandSession.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/commands/CommandSession.java @@ -17,6 +17,7 @@ import java.util.Set; import org.simantics.scl.compiler.common.names.Names; import org.simantics.scl.compiler.constants.StringConstant; +import org.simantics.scl.compiler.dynamic.SafeDynamic; import org.simantics.scl.compiler.elaboration.expressions.EApply; import org.simantics.scl.compiler.elaboration.expressions.EBlock; import org.simantics.scl.compiler.elaboration.expressions.EConstant; @@ -84,6 +85,10 @@ public class CommandSession { */ private boolean validateOnly; + public CommandSession(ModuleRepository moduleRepository) { + this(moduleRepository, SCLReporting.getCurrentReportingHandler()); + } + public CommandSession(ModuleRepository moduleRepository, SCLReportingHandler handler) { this.moduleRepository = moduleRepository; this.defaultHandler = new PrintDecorator( @@ -615,6 +620,11 @@ public class CommandSession { variableTypes.put(name, type); } + public void setVariable(String name, SafeDynamic typeAndValue) { + variableValues.put(name, typeAndValue.value); + variableTypes.put(name, typeAndValue.type_); + } + public Object getVariableValue(String name) { return variableValues.get(name); } @@ -623,6 +633,14 @@ public class CommandSession { return variableTypes.get(name); } + public SafeDynamic getVariableValueAndType(String name) { + Type type = variableTypes.get(name); + if(type == null) + return null; + Object value = variableValues.get(name); + return new SafeDynamic(type, value); + } + public void removeVariable(String name) { variableValues.remove(name); variableTypes.remove(name);