import org.simantics.scl.compiler.types.util.ProcedureType;
import org.simantics.scl.runtime.function.FunctionImpl1;
import org.simantics.scl.runtime.tuple.Tuple0;
+import org.slf4j.LoggerFactory;
+import org.slf4j.Logger;
import gnu.trove.set.hash.THashSet;
public class ExpressionEvaluator {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ExpressionEvaluator.class);
+
public static final boolean TRACE_INTERPRETATION_VS_COMPILATION = false;
private static final String COMPUTATION_METHOD_NAME = "main";
}
} catch(SCLSyntaxErrorException e) {
errorLog.log(e.location, e.getMessage());
- //System.out.println(errorLog.getErrorsAsString());
+ //LOGGER.info(errorLog.getErrorsAsString());
throw new SCLExpressionCompilationException(errorLog.getErrors());
} catch(Exception e) {
errorLog.log(e);
throw new SCLExpressionCompilationException(errorLog.getErrors());
if(SCLCompilerConfiguration.SHOW_EXPRESSION_BEFORE_EVALUATION)
- System.out.println(expression);
+ LOGGER.info("{}", expression);
if(interpretIfPossible) {
// Try to interpret
new TransientClassBuilder(classLoader, javaTypeTranslator));
IExpression iexp = expression.toIExpression(expressionInterpretationContext);
if(TRACE_INTERPRETATION_VS_COMPILATION)
- System.out.println("INTERPRETED " + expressionText);
+ LOGGER.info("INTERPRETED " + expressionText);
if(SCLCompilerConfiguration.SHOW_INTERPRETED_EXPRESSION)
- System.out.println("INTERPRETED AS: " + iexp);
+ LOGGER.info("INTERPRETED AS: " + iexp);
return iexp.execute(new Object[expressionInterpretationContext.getMaxVariableId()]);
} catch(UnsupportedOperationException e) {
// This is normal when expression cannot be interpreted. We compile it instead.
SSAModule ssaModule = mw.getModule();
if(SCLCompilerConfiguration.SHOW_SSA_BEFORE_OPTIMIZATION) {
- System.out.println("=== SSA before optimization ==================================");
- System.out.println(ssaModule);
+ LOGGER.info("=== SSA before optimization ==================================");
+ LOGGER.info("{}", ssaModule);
}
if(SCLCompilerConfiguration.DEBUG)
ssaModule.validate();
for(int phase=0;phase<CodeGeneration.OPTIMIZATION_PHASES;++phase) {
int optCount = 0;
while(optCount++ < 4 && ssaModule.simplify(environment, phase)) {
- //System.out.println("simplify " + optCount);
+ //LOGGER.info("simplify " + optCount);
}
}
if(SCLCompilerConfiguration.SHOW_SSA_BEFORE_LAMBDA_LIFTING) {
- System.out.println("=== SSA before lambda lifting ==================================");
- System.out.println(ssaModule);
+ LOGGER.info("=== SSA before lambda lifting ==================================");
+ LOGGER.info("{}", ssaModule);
}
//ssaModule.saveInlinableDefinitions();
ssaModule.lambdaLift(errorLog);
// Generate code
if(SCLCompilerConfiguration.SHOW_FINAL_SSA)
- System.out.println(ssaModule);
+ LOGGER.info("{}", ssaModule);
try {
ssaModule.generateCode(moduleBuilder);
} catch (CodeBuildingException e) {