]> gerrit.simantics Code Review - simantics/platform.git/blob
3ea3d5e6c5945c02b13fb0a06cf9f2e90ec3227f
[simantics/platform.git] /
1 package org.simantics.scl.compiler.elaboration.expressions;
2
3 import org.simantics.scl.compiler.common.names.Names;
4 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
5 import org.simantics.scl.compiler.elaboration.modules.SCLValue;
6 import org.simantics.scl.compiler.errors.Locations;
7
8 public class ERange extends ASTExpression {
9     Expression from;
10     Expression to;
11     
12     public ERange(Expression from, Expression to) {
13         this.from = from;
14         this.to = to;
15     }
16     
17     @Override
18     public Expression resolve(TranslationContext context) {
19         from = from.resolve(context);
20         to = to.resolve(context);
21         SCLValue rangeFunction = context.getEnvironment().getValue(Names.Prelude_range);
22         return new EApply(location, new EConstant(rangeFunction), from, to);
23     }    
24     
25     @Override
26     public void setLocationDeep(long loc) {
27         if(location == Locations.NO_LOCATION) {
28             location = loc;
29             from.setLocationDeep(loc);
30             to.setLocationDeep(loc);
31         }
32     }
33     
34     @Override
35     public Expression accept(ExpressionTransformer transformer) {
36         return transformer.transform(this);
37     }
38
39 }