]> gerrit.simantics Code Review - simantics/platform.git/blob
79d464b7b459a35cd3fc921b8f745f3b487bce57
[simantics/platform.git] /
1 package org.simantics.scl.compiler.elaboration.expressions;\r
2 \r
3 import org.simantics.scl.compiler.common.names.Name;\r
4 import org.simantics.scl.compiler.constants.StringInterpolation;\r
5 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;\r
6 import org.simantics.scl.compiler.elaboration.modules.SCLValue;\r
7 import org.simantics.scl.compiler.errors.Locations;\r
8 \r
9 public class EStringLiteral extends ASTExpression {\r
10     \r
11     String[] strings;\r
12     Expression[] expressions;\r
13    \r
14     public EStringLiteral(String[] strings, Expression[] expressions) {\r
15         this.strings = strings;\r
16         this.expressions = expressions;\r
17     }\r
18 \r
19     @Override\r
20     public Expression resolve(TranslationContext context) {\r
21         Expression[] components = new Expression[expressions.length];\r
22         SCLValue showForPrinting = context.getEnvironment().getValue(Name.create("Prelude", "showForPrinting"));\r
23         for(int i=0;i<expressions.length;++i)\r
24             components[i] = new EApply(new EConstant(showForPrinting), expressions[i]);\r
25         return new EApply(new ELiteral(new StringInterpolation(strings)), components).resolve(context);\r
26     }\r
27 \r
28     @Override\r
29     public void setLocationDeep(long loc) {\r
30         if(location == Locations.NO_LOCATION) {\r
31             location = loc;\r
32             for(Expression expression : expressions)\r
33                 expression.setLocationDeep(loc);\r
34         }\r
35     }\r
36     \r
37     @Override\r
38     public Expression accept(ExpressionTransformer transformer) {\r
39         return transformer.transform(this);\r
40     }\r
41 \r
42 \r
43 }\r