diff --git a/ql/test/library-tests/ast/Ast.expected b/ql/test/library-tests/ast/Ast.expected index 7f5e877af1c..ff9b6cb5dae 100644 --- a/ql/test/library-tests/ast/Ast.expected +++ b/ql/test/library-tests/ast/Ast.expected @@ -567,6 +567,21 @@ calls/calls.rb: # 319| getReceiver: [Self] self # 319| getArgument: [IntegerLiteral] 0 # 319| getAnOperand/getRightOperand: [IntegerLiteral] 1 +# 320| getStmt: [AssignMulExpr] ... *= ... +# 320| getAnOperand/getLeftOperand: [ElementReference, SetterMethodCall] ...[...] +# 320| getReceiver: [MethodCall] call to bar +# 320| getReceiver: [MethodCall] call to foo +# 320| getReceiver: [Self] self +# 320| getArgument: [IntegerLiteral] 0 +# 320| getArgument: [MethodCall] call to baz +# 320| getReceiver: [MethodCall] call to foo +# 320| getReceiver: [Self] self +# 320| getArgument: [AddExpr] ... + ... +# 320| getAnOperand/getLeftOperand: [MethodCall] call to boo +# 320| getReceiver: [MethodCall] call to foo +# 320| getReceiver: [Self] self +# 320| getAnOperand/getRightOperand: [IntegerLiteral] 1 +# 320| getAnOperand/getRightOperand: [IntegerLiteral] 2 control/cases.rb: # 1| [Toplevel] cases.rb # 2| getStmt: [AssignExpr] ... = ... @@ -1718,6 +1733,25 @@ operations/operations.rb: # 84| getStmt: [AssignBitwiseXorExpr] ... ^= ... # 84| getAnOperand/getLeftOperand: [LocalVariableAccess] baz # 84| getAnOperand/getRightOperand: [LocalVariableAccess] qux +# 86| getStmt: [ClassDeclaration] X +# 87| getStmt: [AssignExpr] ... = ... +# 87| getAnOperand/getLeftOperand: [InstanceVariableAccess] @x +# 87| getAnOperand/getRightOperand: [IntegerLiteral] 1 +# 88| getStmt: [AssignAddExpr] ... += ... +# 88| getAnOperand/getLeftOperand: [InstanceVariableAccess] @x +# 88| getAnOperand/getRightOperand: [IntegerLiteral] 2 +# 90| getStmt: [AssignExpr] ... = ... +# 90| getAnOperand/getLeftOperand: [ClassVariableAccess] @@y +# 90| getAnOperand/getRightOperand: [IntegerLiteral] 3 +# 91| getStmt: [AssignDivExpr] ... /= ... +# 91| getAnOperand/getLeftOperand: [ClassVariableAccess] @@y +# 91| getAnOperand/getRightOperand: [IntegerLiteral] 4 +# 94| getStmt: [AssignExpr] ... = ... +# 94| getAnOperand/getLeftOperand: [GlobalVariableAccess] $global_var +# 94| getAnOperand/getRightOperand: [IntegerLiteral] 5 +# 95| getStmt: [AssignMulExpr] ... *= ... +# 95| getAnOperand/getLeftOperand: [GlobalVariableAccess] $global_var +# 95| getAnOperand/getRightOperand: [IntegerLiteral] 6 params/params.rb: # 1| [Toplevel] params.rb # 4| getStmt: [Method] identifier_method_params diff --git a/ql/test/library-tests/ast/calls/calls.expected b/ql/test/library-tests/ast/calls/calls.expected index 74bcfee07ed..e10de4ae3d5 100644 --- a/ql/test/library-tests/ast/calls/calls.expected +++ b/ql/test/library-tests/ast/calls/calls.expected @@ -36,6 +36,12 @@ callsWithArguments | calls.rb:317:5:317:10 | ...[...] | []= | 0 | calls.rb:317:9:317:9 | 5 | | calls.rb:319:1:319:6 | ...[...] | [] | 0 | calls.rb:319:5:319:5 | 0 | | calls.rb:319:1:319:6 | ...[...] | []= | 0 | calls.rb:319:5:319:5 | 0 | +| calls.rb:320:1:320:32 | ...[...] | [] | 0 | calls.rb:320:9:320:9 | 0 | +| calls.rb:320:1:320:32 | ...[...] | [] | 1 | calls.rb:320:12:320:18 | call to baz | +| calls.rb:320:1:320:32 | ...[...] | [] | 2 | calls.rb:320:21:320:31 | ... + ... | +| calls.rb:320:1:320:32 | ...[...] | []= | 0 | calls.rb:320:9:320:9 | 0 | +| calls.rb:320:1:320:32 | ...[...] | []= | 1 | calls.rb:320:12:320:18 | call to baz | +| calls.rb:320:1:320:32 | ...[...] | []= | 2 | calls.rb:320:21:320:31 | ... + ... | callsWithReceiver | calls.rb:2:1:2:5 | call to foo | calls.rb:2:1:2:5 | self | | calls.rb:5:1:5:10 | call to bar | calls.rb:5:1:5:3 | Foo | @@ -216,6 +222,13 @@ callsWithReceiver | calls.rb:318:1:318:10 | call to count/count= | calls.rb:318:1:318:4 | self | | calls.rb:319:1:319:3 | call to foo | calls.rb:319:1:319:3 | self | | calls.rb:319:1:319:6 | ...[...] | calls.rb:319:1:319:3 | call to foo | +| calls.rb:320:1:320:3 | call to foo | calls.rb:320:1:320:3 | self | +| calls.rb:320:1:320:7 | call to bar | calls.rb:320:1:320:3 | call to foo | +| calls.rb:320:1:320:32 | ...[...] | calls.rb:320:1:320:7 | call to bar | +| calls.rb:320:12:320:14 | call to foo | calls.rb:320:12:320:14 | self | +| calls.rb:320:12:320:18 | call to baz | calls.rb:320:12:320:14 | call to foo | +| calls.rb:320:21:320:23 | call to foo | calls.rb:320:21:320:23 | self | +| calls.rb:320:21:320:27 | call to boo | calls.rb:320:21:320:23 | call to foo | callsWithBlock | calls.rb:17:1:17:17 | call to foo | calls.rb:17:5:17:17 | { ... } | | calls.rb:20:1:22:3 | call to foo | calls.rb:20:5:22:3 | do ... end | @@ -262,3 +275,4 @@ setterCalls | calls.rb:317:5:317:10 | ...[...] | | calls.rb:318:1:318:10 | call to count/count= | | calls.rb:319:1:319:6 | ...[...] | +| calls.rb:320:1:320:32 | ...[...] | diff --git a/ql/test/library-tests/ast/calls/calls.rb b/ql/test/library-tests/ast/calls/calls.rb index 8b827d07f9b..1362b043e8a 100644 --- a/ql/test/library-tests/ast/calls/calls.rb +++ b/ql/test/library-tests/ast/calls/calls.rb @@ -317,3 +317,4 @@ self.foo, *self.bar, foo[4] = [1, 2, 3, 4] a, *foo[5] = [1, 2, 3] self.count += 1 foo[0] += 1 +foo.bar[0, foo.baz, foo.boo + 1] *= 2 diff --git a/ql/test/library-tests/ast/operations/assignment.expected b/ql/test/library-tests/ast/operations/assignment.expected index d1f34896b31..454f86743ba 100644 --- a/ql/test/library-tests/ast/operations/assignment.expected +++ b/ql/test/library-tests/ast/operations/assignment.expected @@ -30,6 +30,12 @@ assignments | operations.rb:82:2:82:12 | ... &= ... | &= | operations.rb:82:2:82:4 | foo | operations.rb:82:9:82:12 | mask | AssignBitwiseAndExpr | | operations.rb:83:2:83:12 | ... \|= ... | \|= | operations.rb:83:2:83:4 | bar | operations.rb:83:9:83:12 | 0x01 | AssignBitwiseOrExpr | | operations.rb:84:2:84:11 | ... ^= ... | ^= | operations.rb:84:2:84:4 | baz | operations.rb:84:9:84:11 | qux | AssignBitwiseXorExpr | +| operations.rb:87:3:87:8 | ... = ... | = | operations.rb:87:3:87:4 | @x | operations.rb:87:8:87:8 | 1 | AssignExpr | +| operations.rb:88:3:88:9 | ... += ... | += | operations.rb:88:3:88:4 | @x | operations.rb:88:9:88:9 | 2 | AssignAddExpr | +| operations.rb:90:3:90:9 | ... = ... | = | operations.rb:90:3:90:5 | @@y | operations.rb:90:9:90:9 | 3 | AssignExpr | +| operations.rb:91:3:91:10 | ... /= ... | /= | operations.rb:91:3:91:5 | @@y | operations.rb:91:10:91:10 | 4 | AssignDivExpr | +| operations.rb:94:1:94:15 | ... = ... | = | operations.rb:94:1:94:11 | $global_var | operations.rb:94:15:94:15 | 5 | AssignExpr | +| operations.rb:95:1:95:16 | ... *= ... | *= | operations.rb:95:1:95:11 | $global_var | operations.rb:95:16:95:16 | 6 | AssignMulExpr | assignOperations | operations.rb:68:1:68:8 | ... += ... | += | operations.rb:68:1:68:1 | x | operations.rb:68:6:68:8 | 128 | AssignAddExpr | | operations.rb:69:1:69:7 | ... -= ... | -= | operations.rb:69:1:69:1 | y | operations.rb:69:6:69:7 | 32 | AssignSubExpr | @@ -44,6 +50,9 @@ assignOperations | operations.rb:82:2:82:12 | ... &= ... | &= | operations.rb:82:2:82:4 | foo | operations.rb:82:9:82:12 | mask | AssignBitwiseAndExpr | | operations.rb:83:2:83:12 | ... \|= ... | \|= | operations.rb:83:2:83:4 | bar | operations.rb:83:9:83:12 | 0x01 | AssignBitwiseOrExpr | | operations.rb:84:2:84:11 | ... ^= ... | ^= | operations.rb:84:2:84:4 | baz | operations.rb:84:9:84:11 | qux | AssignBitwiseXorExpr | +| operations.rb:88:3:88:9 | ... += ... | += | operations.rb:88:3:88:4 | @x | operations.rb:88:9:88:9 | 2 | AssignAddExpr | +| operations.rb:91:3:91:10 | ... /= ... | /= | operations.rb:91:3:91:5 | @@y | operations.rb:91:10:91:10 | 4 | AssignDivExpr | +| operations.rb:95:1:95:16 | ... *= ... | *= | operations.rb:95:1:95:11 | $global_var | operations.rb:95:16:95:16 | 6 | AssignMulExpr | assignArithmeticOperations | operations.rb:68:1:68:8 | ... += ... | += | operations.rb:68:1:68:1 | x | operations.rb:68:6:68:8 | 128 | AssignAddExpr | | operations.rb:69:1:69:7 | ... -= ... | -= | operations.rb:69:1:69:1 | y | operations.rb:69:6:69:7 | 32 | AssignSubExpr | @@ -51,6 +60,9 @@ assignArithmeticOperations | operations.rb:71:1:71:6 | ... /= ... | /= | operations.rb:71:1:71:1 | b | operations.rb:71:6:71:6 | 4 | AssignDivExpr | | operations.rb:72:1:72:6 | ... %= ... | %= | operations.rb:72:1:72:1 | z | operations.rb:72:6:72:6 | 2 | AssignModuloExpr | | operations.rb:73:1:73:11 | ... **= ... | **= | operations.rb:73:1:73:3 | foo | operations.rb:73:9:73:11 | bar | AssignExponentExpr | +| operations.rb:88:3:88:9 | ... += ... | += | operations.rb:88:3:88:4 | @x | operations.rb:88:9:88:9 | 2 | AssignAddExpr | +| operations.rb:91:3:91:10 | ... /= ... | /= | operations.rb:91:3:91:5 | @@y | operations.rb:91:10:91:10 | 4 | AssignDivExpr | +| operations.rb:95:1:95:16 | ... *= ... | *= | operations.rb:95:1:95:11 | $global_var | operations.rb:95:16:95:16 | 6 | AssignMulExpr | assignLogicalOperations | operations.rb:76:2:76:8 | ... &&= ... | &&= | operations.rb:76:2:76:2 | x | operations.rb:76:8:76:8 | y | AssignLogicalAndExpr | | operations.rb:77:2:77:8 | ... \|\|= ... | \|\|= | operations.rb:77:2:77:2 | a | operations.rb:77:8:77:8 | b | AssignLogicalOrExpr | diff --git a/ql/test/library-tests/ast/operations/operation.expected b/ql/test/library-tests/ast/operations/operation.expected index 3d5346e6346..7f4d25068eb 100644 --- a/ql/test/library-tests/ast/operations/operation.expected +++ b/ql/test/library-tests/ast/operations/operation.expected @@ -116,3 +116,15 @@ | operations.rb:83:2:83:12 | ... \|= ... | \|= | operations.rb:83:9:83:12 | 0x01 | AssignBitwiseOrExpr | | operations.rb:84:2:84:11 | ... ^= ... | ^= | operations.rb:84:2:84:4 | baz | AssignBitwiseXorExpr | | operations.rb:84:2:84:11 | ... ^= ... | ^= | operations.rb:84:9:84:11 | qux | AssignBitwiseXorExpr | +| operations.rb:87:3:87:8 | ... = ... | = | operations.rb:87:3:87:4 | @x | AssignExpr | +| operations.rb:87:3:87:8 | ... = ... | = | operations.rb:87:8:87:8 | 1 | AssignExpr | +| operations.rb:88:3:88:9 | ... += ... | += | operations.rb:88:3:88:4 | @x | AssignAddExpr | +| operations.rb:88:3:88:9 | ... += ... | += | operations.rb:88:9:88:9 | 2 | AssignAddExpr | +| operations.rb:90:3:90:9 | ... = ... | = | operations.rb:90:3:90:5 | @@y | AssignExpr | +| operations.rb:90:3:90:9 | ... = ... | = | operations.rb:90:9:90:9 | 3 | AssignExpr | +| operations.rb:91:3:91:10 | ... /= ... | /= | operations.rb:91:3:91:5 | @@y | AssignDivExpr | +| operations.rb:91:3:91:10 | ... /= ... | /= | operations.rb:91:10:91:10 | 4 | AssignDivExpr | +| operations.rb:94:1:94:15 | ... = ... | = | operations.rb:94:1:94:11 | $global_var | AssignExpr | +| operations.rb:94:1:94:15 | ... = ... | = | operations.rb:94:15:94:15 | 5 | AssignExpr | +| operations.rb:95:1:95:16 | ... *= ... | *= | operations.rb:95:1:95:11 | $global_var | AssignMulExpr | +| operations.rb:95:1:95:16 | ... *= ... | *= | operations.rb:95:16:95:16 | 6 | AssignMulExpr | diff --git a/ql/test/library-tests/ast/operations/operations.rb b/ql/test/library-tests/ast/operations/operations.rb index 707a2d36425..effee5860ba 100644 --- a/ql/test/library-tests/ast/operations/operations.rb +++ b/ql/test/library-tests/ast/operations/operations.rb @@ -81,4 +81,15 @@ foo **= bar y >>= 3 foo &= mask bar |= 0x01 - baz ^= qux \ No newline at end of file + baz ^= qux + +class X + @x = 1 + @x += 2 + + @@y = 3 + @@y /= 4 +end + +$global_var = 5 +$global_var *= 6 diff --git a/ql/test/library-tests/controlflow/graph/Cfg.expected b/ql/test/library-tests/controlflow/graph/Cfg.expected index 3e39856c559..84e66808854 100644 --- a/ql/test/library-tests/controlflow/graph/Cfg.expected +++ b/ql/test/library-tests/controlflow/graph/Cfg.expected @@ -2083,6 +2083,177 @@ cfg.rb: # 194| x #-----| -> call to puts +desugar.rb: +# 1| enter m1 +#-----| -> x + +# 1| enter desugar.rb +#-----| -> m1 + +# 1| m1 +#-----| -> m2 + +# 1| exit m1 + +# 1| exit desugar.rb + +# 1| exit m1 (normal) +#-----| -> exit m1 + +# 1| exit desugar.rb (normal) +#-----| -> exit desugar.rb + +# 1| x +#-----| -> x + +# 2| ... += ... +#-----| -> exit m1 (normal) + +# 2| x +#-----| -> 1 + +# 2| 1 +#-----| -> ... += ... + +# 5| enter m2 +#-----| -> x + +# 5| m2 +#-----| -> m3 + +# 5| exit m2 + +# 5| exit m2 (normal) +#-----| -> exit m2 + +# 5| x +#-----| -> x + +# 6| ... += ... +#-----| -> exit m2 (normal) + +# 6| call to count/count= +#-----| -> 1 + +# 6| call to foo +#-----| -> call to count/count= + +# 6| x +#-----| -> call to foo + +# 6| 1 +#-----| -> ... += ... + +# 9| enter m3 +#-----| -> x + +# 9| m3 +#-----| -> X + +# 9| exit m3 + +# 9| exit m3 (normal) +#-----| -> exit m3 + +# 9| x +#-----| -> y + +# 9| y +#-----| -> x + +# 10| ... += ... +#-----| -> exit m3 (normal) + +# 10| ...[...] +#-----| -> 1 + +# 10| call to foo +#-----| -> 0 + +# 10| x +#-----| -> call to foo + +# 10| 0 +#-----| -> y + +# 10| call to bar +#-----| -> x + +# 10| y +#-----| -> call to bar + +# 10| ... + ... +#-----| -> ...[...] + +# 10| call to baz +#-----| -> 3 + +# 10| x +#-----| -> call to baz + +# 10| 3 +#-----| -> ... + ... + +# 10| 1 +#-----| -> ... += ... + +# 13| X +#-----| -> @x + +# 14| ... = ... +#-----| -> @x + +# 14| @x +#-----| -> 1 + +# 14| 1 +#-----| -> ... = ... + +# 15| ... += ... +#-----| -> @@y + +# 15| @x +#-----| -> 2 + +# 15| 2 +#-----| -> ... += ... + +# 17| ... = ... +#-----| -> @@y + +# 17| @@y +#-----| -> 3 + +# 17| 3 +#-----| -> ... = ... + +# 18| ... /= ... +#-----| -> $global_var + +# 18| @@y +#-----| -> 4 + +# 18| 4 +#-----| -> ... /= ... + +# 21| ... = ... +#-----| -> $global_var + +# 21| $global_var +#-----| -> 5 + +# 21| 5 +#-----| -> ... = ... + +# 22| ... *= ... +#-----| -> exit desugar.rb (normal) + +# 22| $global_var +#-----| -> 6 + +# 22| 6 +#-----| -> ... *= ... + exit.rb: # 1| enter m1 #-----| -> x diff --git a/ql/test/library-tests/controlflow/graph/desugar.rb b/ql/test/library-tests/controlflow/graph/desugar.rb new file mode 100644 index 00000000000..25dd0e48e0e --- /dev/null +++ b/ql/test/library-tests/controlflow/graph/desugar.rb @@ -0,0 +1,22 @@ +def m1 x + x += 1 +end + +def m2 x + x.foo.count += 1 +end + +def m3 x, y + x.foo[0, y.bar, x.baz + 3] += 1 +end + +class X + @x = 1 + @x += 2 + + @@y = 3 + @@y /= 4 +end + +$global_var = 5 +$global_var *= 6