]> gerrit.simantics Code Review - simantics/platform.git/blob
20298b45c3e5ff080488c037a113a0f3f791b19f
[simantics/platform.git] /
1 package org.simantics.scl.compiler.internal.elaboration.matching;\r
2 \r
3 \r
4 import org.simantics.scl.compiler.elaboration.expressions.Expression;\r
5 \r
6 public class Row {\r
7     Expression[] patterns;\r
8     Expression value;\r
9     \r
10     public Row(Expression[] patterns, Expression value) {\r
11         this.patterns = patterns;\r
12         this.value = value;\r
13     }\r
14     \r
15     public Row replace(int columnToReplace, Expression[] substitution) {\r
16         Expression[] newPatterns = new Expression[patterns.length-1+substitution.length];\r
17         int j=0;\r
18         for(int i=0;i<columnToReplace;++i)\r
19             newPatterns[j++] = patterns[i];\r
20         for(int i=0;i<substitution.length;++i)\r
21             newPatterns[j++] = substitution[i];\r
22         for(int i=columnToReplace+1;i<patterns.length;++i)\r
23             newPatterns[j++] = patterns[i];\r
24         return new Row(newPatterns, value);\r
25     }\r
26 }\r