]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/interpreted/IListLiteral.java
Merge commit 'c46f0ff'
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / internal / interpreted / IListLiteral.java
1 package org.simantics.scl.compiler.internal.interpreted;
2
3 import java.util.Arrays;
4
5 public class IListLiteral implements IExpression {
6
7     private final IExpression[] componentExpressions;
8
9     public IListLiteral(IExpression[] componentExpressions) {
10         this.componentExpressions = componentExpressions;
11     }
12
13     @Override
14     public Object execute(Object[] variableBindings) {
15         Object[] components = new Object[componentExpressions.length];
16         for(int i=0;i<componentExpressions.length;++i)
17             components[i] = componentExpressions[i].execute(variableBindings);
18         return Arrays.asList(components);
19     }
20     
21     @Override
22     public String toString() {
23         StringBuilder b = new StringBuilder();
24         b.append('[');
25         for(int i=0;i<componentExpressions.length;++i) {
26             if(i > 0)
27                 b.append(", ");
28             b.append(componentExpressions[i]);
29         }
30         b.append(']');
31         return b.toString();
32     }
33 }