Skip to content

Commit a5015a4

Browse files
committed
Merged dev
2 parents e4d1ee8 + dd5890b commit a5015a4

28 files changed

+1419
-88
lines changed

checkstyle-SP.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,6 @@
274274
<module name="LineLength">
275275
<property name="fileExtensions" value="java"/>
276276
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
277-
<property name="max" value="100"/>
277+
<property name="max" value="120"/>
278278
</module>
279279
</module>

rosetta-lang/model/Rosetta.xcore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ class TypeCallArgument {
9090
contains RosettaExpression value
9191
}
9292

93+
abstract class RosettaInterpreterBaseEnvironment {
94+
}
95+
9396

9497
/**********************************************************************
9598
* Built-in

rosetta-lang/model/RosettaExpression.xcore

Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@ import org.eclipse.emf.common.util.BasicEList
1919
import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue
2020
import com.regnosys.rosetta.rosetta.interpreter.InterpreterVisitor
2121

22+
import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment
23+
2224

2325
interface RosettaExpression {
2426
// Whether the expression was generated
2527
boolean generated
2628
op RosettaInterpreterValue accept(InterpreterVisitor v)
29+
op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment env)
2730
}
2831

2932
/**
@@ -59,6 +62,9 @@ class RosettaBooleanLiteral extends RosettaLiteral {
5962
op RosettaInterpreterValue accept(InterpreterVisitor v) {
6063
v.interp(this)
6164
}
65+
op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) {
66+
v.interp(this,nv)
67+
}
6268
}
6369

6470
class RosettaStringLiteral extends RosettaLiteral {
@@ -73,6 +79,9 @@ class RosettaStringLiteral extends RosettaLiteral {
7379
op RosettaInterpreterValue accept(InterpreterVisitor v) {
7480
v.interp(this)
7581
}
82+
op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) {
83+
v.interp(this,nv)
84+
}
7685
}
7786

7887
class RosettaNumberLiteral extends RosettaLiteral {
@@ -87,6 +96,9 @@ class RosettaNumberLiteral extends RosettaLiteral {
8796
op RosettaInterpreterValue accept(InterpreterVisitor v) {
8897
v.interp(this)
8998
}
99+
op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) {
100+
v.interp(this,nv)
101+
}
90102
}
91103

92104
class RosettaIntLiteral extends RosettaLiteral {
@@ -101,6 +113,9 @@ class RosettaIntLiteral extends RosettaLiteral {
101113
op RosettaInterpreterValue accept(InterpreterVisitor v) {
102114
v.interp(this)
103115
}
116+
op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) {
117+
v.interp(this,nv)
118+
}
104119
}
105120

106121
// Not supported - see issue https://github.com/finos/rune-dsl/issues/524
@@ -128,6 +143,9 @@ class ListLiteral extends RosettaExpression {
128143
op RosettaInterpreterValue accept(InterpreterVisitor v) {
129144
v.interp(this)
130145
}
146+
op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) {
147+
v.interp(this,nv)
148+
}
131149
}
132150

133151
/*
@@ -158,6 +176,10 @@ class RosettaSymbolReference extends RosettaReference {
158176
}
159177
return rawArgs
160178
}
179+
180+
op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) {
181+
v.interp(this, nv)
182+
}
161183
}
162184

163185
class RosettaImplicitVariable extends RosettaReference, RosettaNamed {
@@ -178,6 +200,9 @@ class RosettaConditionalExpression extends RosettaExpression {
178200
op RosettaInterpreterValue accept(InterpreterVisitor v) {
179201
v.interp(this)
180202
}
203+
op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) {
204+
v.interp(this,nv)
205+
}
181206
}
182207

183208
class RosettaConstructorExpression extends RosettaExpression, RosettaTyped {
@@ -222,12 +247,22 @@ interface RosettaBinaryOperation extends RosettaOperation, HasGeneratedInput {
222247
}
223248

224249
class ArithmeticOperation extends RosettaBinaryOperation {
250+
251+
op RosettaInterpreterValue accept(InterpreterVisitor v) {
252+
v.interp(this)
253+
}
254+
op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) {
255+
v.interp(this,nv)
256+
}
225257
}
226258

227259
class LogicalOperation extends RosettaBinaryOperation {
228260
op RosettaInterpreterValue accept(InterpreterVisitor v) {
229261
v.interp(this)
230262
}
263+
op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) {
264+
v.interp(this,nv)
265+
}
231266
}
232267

233268
enum CardinalityModifier {
@@ -244,31 +279,44 @@ class EqualityOperation extends ModifiableBinaryOperation {
244279
op RosettaInterpreterValue accept(InterpreterVisitor v) {
245280
v.interp(this)
246281
}
282+
op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) {
283+
v.interp(this,nv)
284+
}
247285
}
248286

249287
class ComparisonOperation extends ModifiableBinaryOperation {
250-
op RosettaInterpreterValue accept(InterpreterVisitor v) {
251-
v.interp(this)
288+
op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) {
289+
v.interp(this,nv)
252290
}
291+
253292
}
254293

255294
class RosettaContainsExpression extends RosettaBinaryOperation {
256295
op RosettaInterpreterValue accept(InterpreterVisitor v) {
257296
v.interp(this)
258297
}
298+
op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) {
299+
v.interp(this,nv)
300+
}
259301
}
260302

261303
class RosettaDisjointExpression extends RosettaBinaryOperation {
262304
op RosettaInterpreterValue accept(InterpreterVisitor v) {
263305
v.interp(this)
264306
}
307+
op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) {
308+
v.interp(this,nv)
309+
}
265310
}
266311

267312
class JoinOperation extends RosettaBinaryOperation {
268313
boolean explicitSeparator
269314
op RosettaInterpreterValue accept(InterpreterVisitor v) {
270315
v.interp(this)
271316
}
317+
op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) {
318+
v.interp(this,nv)
319+
}
272320
}
273321

274322
/**
@@ -325,12 +373,18 @@ class RosettaExistsExpression extends RosettaUnaryOperation {
325373
op RosettaInterpreterValue accept(InterpreterVisitor v) {
326374
v.interp(this)
327375
}
376+
op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) {
377+
v.interp(this,nv)
378+
}
328379
}
329380

330381
class RosettaAbsentExpression extends RosettaUnaryOperation {
331382
op RosettaInterpreterValue accept(InterpreterVisitor v) {
332383
v.interp(this)
333384
}
385+
op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) {
386+
v.interp(this,nv)
387+
}
334388
}
335389

336390
class RosettaOnlyElement extends ListOperation {
@@ -340,30 +394,57 @@ class RosettaCountOperation extends RosettaUnaryOperation {
340394
op RosettaInterpreterValue accept(InterpreterVisitor v) {
341395
v.interp(this)
342396
}
397+
op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) {
398+
v.interp(this,nv)
399+
}
343400
}
344401

345402
class FlattenOperation extends ListOperation, CanHandleListOfLists {
346403
}
347404

348405
class DistinctOperation extends ListOperation {
406+
op RosettaInterpreterValue accept(InterpreterVisitor v) {
407+
v.interp(this)
408+
}
409+
op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) {
410+
v.interp(this, nv)
411+
}
349412
}
350413

351414
class ReverseOperation extends ListOperation {
415+
op RosettaInterpreterValue accept(InterpreterVisitor v) {
416+
v.interp(this)
417+
}
418+
op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) {
419+
v.interp(this, nv)
420+
}
352421
}
353422

354423
class FirstOperation extends ListOperation {
355424
op RosettaInterpreterValue accept(InterpreterVisitor v) {
356425
v.interp(this)
357426
}
427+
op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) {
428+
v.interp(this,nv)
429+
}
358430
}
359431

360432
class LastOperation extends ListOperation {
361433
op RosettaInterpreterValue accept(InterpreterVisitor v) {
362434
v.interp(this)
363435
}
436+
op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) {
437+
v.interp(this,nv)
438+
}
364439
}
365440

366441
class SumOperation extends ListOperation {
442+
op RosettaInterpreterValue accept(InterpreterVisitor v) {
443+
v.interp(this)
444+
}
445+
op RosettaInterpreterValue accept(InterpreterVisitor v, RosettaInterpreterBaseEnvironment nv) {
446+
v.interp(this, nv)
447+
}
367448
}
368449

369450
class AsKeyOperation extends RosettaUnaryOperation {

rosetta-lang/model/RosettaInterpreter.xcore

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ import com.regnosys.rosetta.rosetta.expression.RosettaConditionalExpression
1515
import com.regnosys.rosetta.rosetta.expression.LogicalOperation
1616
import com.regnosys.rosetta.rosetta.expression.EqualityOperation
1717
import com.regnosys.rosetta.rosetta.expression.ComparisonOperation
18+
19+
import com.regnosys.rosetta.rosetta.expression.RosettaSymbolReference
20+
import com.regnosys.rosetta.rosetta.RosettaInterpreterBaseEnvironment
21+
import com.regnosys.rosetta.rosetta.expression.ArithmeticOperation
1822
import com.regnosys.rosetta.rosetta.expression.RosettaContainsExpression
1923
import com.regnosys.rosetta.rosetta.expression.RosettaDisjointExpression
2024
import com.regnosys.rosetta.rosetta.expression.JoinOperation
@@ -23,6 +27,9 @@ import com.regnosys.rosetta.rosetta.expression.RosettaAbsentExpression
2327
import com.regnosys.rosetta.rosetta.expression.RosettaCountOperation
2428
import com.regnosys.rosetta.rosetta.expression.FirstOperation
2529
import com.regnosys.rosetta.rosetta.expression.LastOperation
30+
import com.regnosys.rosetta.rosetta.expression.DistinctOperation
31+
import com.regnosys.rosetta.rosetta.expression.ReverseOperation
32+
import com.regnosys.rosetta.rosetta.expression.SumOperation
2633

2734
class RosettaInterpreterBaseError{
2835
String message
@@ -42,12 +49,47 @@ interface InterpreterVisitor {
4249
op RosettaInterpreterValue interp (LogicalOperation exp)
4350
op RosettaInterpreterValue interp (EqualityOperation exp)
4451
op RosettaInterpreterValue interp (ComparisonOperation exp)
52+
op RosettaInterpreterValue interp (ArithmeticOperation exp)
53+
op RosettaInterpreterValue interp (RosettaSymbolReference exp)
54+
55+
4556
op RosettaInterpreterValue interp (RosettaContainsExpression exp)
4657
op RosettaInterpreterValue interp (RosettaDisjointExpression exp)
4758
op RosettaInterpreterValue interp (JoinOperation exp)
4859
op RosettaInterpreterValue interp (RosettaExistsExpression exp)
4960
op RosettaInterpreterValue interp (RosettaAbsentExpression exp)
5061
op RosettaInterpreterValue interp (RosettaCountOperation exp)
51-
op RosettaInterpreterValue interp (FirstOperation exp)
52-
op RosettaInterpreterValue interp (LastOperation exp)
62+
op RosettaInterpreterValue interp (FirstOperation exp)
63+
op RosettaInterpreterValue interp (LastOperation exp)
64+
op RosettaInterpreterValue interp (DistinctOperation exp)
65+
op RosettaInterpreterValue interp (ReverseOperation exp)
66+
op RosettaInterpreterValue interp (SumOperation exp)
67+
68+
69+
op RosettaInterpreterValue interp (RosettaBooleanLiteral exp, RosettaInterpreterBaseEnvironment env)
70+
op RosettaInterpreterValue interp (RosettaStringLiteral exp, RosettaInterpreterBaseEnvironment env)
71+
op RosettaInterpreterValue interp (RosettaNumberLiteral exp, RosettaInterpreterBaseEnvironment env)
72+
op RosettaInterpreterValue interp (RosettaIntLiteral exp, RosettaInterpreterBaseEnvironment env)
73+
op RosettaInterpreterValue interp (RosettaPatternLiteral exp, RosettaInterpreterBaseEnvironment env)
74+
op RosettaInterpreterValue interp (ListLiteral exp, RosettaInterpreterBaseEnvironment env)
75+
op RosettaInterpreterValue interp (RosettaConditionalExpression exp, RosettaInterpreterBaseEnvironment env)
76+
op RosettaInterpreterValue interp (LogicalOperation exp, RosettaInterpreterBaseEnvironment env)
77+
op RosettaInterpreterValue interp (EqualityOperation exp, RosettaInterpreterBaseEnvironment env)
78+
op RosettaInterpreterValue interp (ComparisonOperation exp, RosettaInterpreterBaseEnvironment env)
79+
op RosettaInterpreterValue interp (ArithmeticOperation exp, RosettaInterpreterBaseEnvironment env)
80+
op RosettaInterpreterValue interp (RosettaSymbolReference exp, RosettaInterpreterBaseEnvironment env)
81+
82+
op RosettaInterpreterValue interp (RosettaContainsExpression exp, RosettaInterpreterBaseEnvironment env)
83+
op RosettaInterpreterValue interp (RosettaDisjointExpression exp, RosettaInterpreterBaseEnvironment env)
84+
op RosettaInterpreterValue interp (JoinOperation exp, RosettaInterpreterBaseEnvironment env)
85+
op RosettaInterpreterValue interp (RosettaExistsExpression exp, RosettaInterpreterBaseEnvironment env)
86+
op RosettaInterpreterValue interp (RosettaAbsentExpression exp, RosettaInterpreterBaseEnvironment env)
87+
op RosettaInterpreterValue interp (RosettaCountOperation exp, RosettaInterpreterBaseEnvironment env)
88+
op RosettaInterpreterValue interp (FirstOperation exp, RosettaInterpreterBaseEnvironment env)
89+
op RosettaInterpreterValue interp (LastOperation exp, RosettaInterpreterBaseEnvironment env)
90+
op RosettaInterpreterValue interp (DistinctOperation exp, RosettaInterpreterBaseEnvironment env)
91+
op RosettaInterpreterValue interp (ReverseOperation exp, RosettaInterpreterBaseEnvironment env)
92+
op RosettaInterpreterValue interp (SumOperation exp, RosettaInterpreterBaseEnvironment env)
93+
94+
5395
}

rosetta-lang/src/main/java/com/regnosys/rosetta/interpreternew/RosettaInterpreterNew.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import javax.inject.Inject;
44

5+
import com.regnosys.rosetta.interpreternew.values.RosettaInterpreterEnvironment;
56
import com.regnosys.rosetta.rosetta.expression.RosettaExpression;
67
import com.regnosys.rosetta.rosetta.interpreter.RosettaInterpreterValue;
78

@@ -18,6 +19,11 @@ public class RosettaInterpreterNew {
1819
* @return value of RosettaIntLiteral otherwise exception
1920
*/
2021
public RosettaInterpreterValue interp(RosettaExpression expression) {
21-
return expression.accept(visitor);
22+
return expression.accept(visitor, new RosettaInterpreterEnvironment());
23+
}
24+
25+
public RosettaInterpreterValue interp(RosettaExpression expression,
26+
RosettaInterpreterEnvironment env) {
27+
return expression.accept(visitor, env);
2228
}
2329
}

0 commit comments

Comments
 (0)