Skip to content

Commit ec86cdb

Browse files
Merge branch 'develop' into feature/dsl-bundle-upgrade
2 parents d7228e5 + 9bf8888 commit ec86cdb

File tree

3 files changed

+17
-19
lines changed

3 files changed

+17
-19
lines changed

EXPRESSION_SUPPORT.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
| Feature | Handled |
88
|----------------------------------------|---------|
9-
| ArithmeticOperation | ? |
9+
| ArithmeticOperation | |
1010
| AsKeyOperation ||
1111
| CanHandleListOfLists | |
1212
| ChoiceOperation ||
@@ -65,4 +65,4 @@
6565
| RosettaNumberLiteral ||
6666
| RosettaOnlyElement ||
6767
| RosettaOnlyExistsExpression ||
68-
| RosettaReference ||
68+
| RosettaReference ||

src/main/java/com/regnosys/rosetta/generator/python/expressions/PythonExpressionGenerator.xtend

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ class PythonExpressionGenerator {
184184
}
185185

186186
private def String generateSwitchOperation(SwitchOperation expr, int ifLevel, boolean isLambda) {
187+
// translate switch into a series of if / elif statements
187188
val attr = generateExpression(expr.argument, 0, isLambda)
188189

189190
var _thenFuncsBuilder = new StringConcatenation()

src/main/java/com/regnosys/rosetta/generator/python/func/PythonFunctionGenerator.xtend

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ import com.regnosys.rosetta.rosetta.simple.Data
1212
import com.regnosys.rosetta.rosetta.simple.Function
1313
import com.regnosys.rosetta.rosetta.simple.Operation
1414
import com.regnosys.rosetta.rosetta.simple.Segment
15-
import com.regnosys.rosetta.rosetta.simple.ShortcutDeclaration
16-
import com.regnosys.rosetta.rosetta.simple.Condition
17-
import com.regnosys.rosetta.rosetta.RosettaFeature
18-
import com.regnosys.rosetta.rosetta.RosettaTyped
1915
import java.util.ArrayList
2016
import java.util.Collections
2117
import java.util.HashMap
@@ -287,7 +283,7 @@ class PythonFunctionGenerator {
287283
private def generateAddOperation(AssignPathRoot root, Operation operation, Function function, String expression) {
288284
val lineSeparator = System.getProperty("line.separator")
289285
val attribute = root as Attribute
290-
val fullPath = generateFullPath(operation.getPath().getReversedFeatures(), root.name)
286+
val fullPath = generateFullPath(operation.getPath().getReversedAttributes, root.name)
291287

292288
var result = ""
293289
if (attribute.typeCall.type instanceof RosettaEnumeration) {
@@ -328,7 +324,7 @@ class PythonFunctionGenerator {
328324
var result = new StringBuilder()
329325
result.append("'")
330326
while (currentPath !== null) {
331-
result.append(currentPath.getFeature().name)
327+
result.append(currentPath.getAttribute().name)
332328
if (currentPath.next !== null) {
333329
result.append("->")
334330
}
@@ -340,8 +336,8 @@ class PythonFunctionGenerator {
340336

341337
private def getNextPathElementName(Segment path) {
342338
if (path !== null) {
343-
val feature = path.getFeature()
344-
return "'" + feature.name + "'"
339+
val attribute = path.getAttribute()
340+
return "'" + attribute.name + "'"
345341
}
346342
return null
347343
}
@@ -356,34 +352,35 @@ class PythonFunctionGenerator {
356352
return '''_get_rune_object('«feature.typeCall.type.name»', «getNextPathElementName(path.next)», «buildObject(expression, path.next)»)'''
357353
}
358354
throw new IllegalArgumentException("Cannot build object for feature " + feature.getName() + " of type " + feature.class.simpleName)
355+
359356
}
360357

361-
private def String generateFullPath(Iterable<RosettaFeature> features, String root) {
362-
if (features.isEmpty) {
358+
private def String generateFullPath(Iterable<Attribute> attrs, String root) {
359+
if (attrs.isEmpty) {
363360
return "self"
364361
}
365362

366-
val attr = features.head
367-
val remainingAttrs = features.tail.toList
363+
val attr = attrs.head
364+
val remainingAttrs = attrs.tail.toList
368365

369366
val nextPath = if (remainingAttrs.isEmpty) '''rune_resolve_attr(self, «root»)''' else generateFullPath(
370367
remainingAttrs, root)
371368

372369
return '''rune_resolve_attr(«nextPath», '«attr.name»')'''
373370
}
374371

375-
private def getReversedFeatures(Segment segment) {
376-
val features = new ArrayList<RosettaFeature>();
372+
private def getReversedAttributes(Segment segment) {
373+
val attributes = new ArrayList<Attribute>();
377374
var current = segment;
378375

379376
while (current !== null) {
380-
features.add(current.getFeature());
377+
attributes.add(current.getAttribute());
381378
current = current.getNext();
382379
}
383380

384-
Collections.reverse(features);
381+
Collections.reverse(attributes);
385382

386-
return features;
383+
return attributes;
387384
}
388385

389386
def addImportsFromConditions(String variable, String namespace) {

0 commit comments

Comments
 (0)