equal
deleted
inserted
replaced
23 yourself |
23 yourself |
24 ! ! |
24 ! ! |
25 |
25 |
26 !PPCCodeGenerator methodsFor:'accessing'! |
26 !PPCCodeGenerator methodsFor:'accessing'! |
27 |
27 |
28 arguments: args |
28 options: args |
29 super arguments: args. |
29 super options: args. |
30 codeGen arguments: args. |
30 codeGen options: args. |
31 ! |
31 ! |
32 |
32 |
33 clazz: aPPCClass |
33 clazz: aPPCClass |
34 codeGen clazz: aPPCClass |
34 codeGen clazz: aPPCClass |
35 ! |
35 ! |
41 codeGen: anObject |
41 codeGen: anObject |
42 codeGen := anObject |
42 codeGen := anObject |
43 ! |
43 ! |
44 |
44 |
45 guards |
45 guards |
46 ^ arguments guards |
46 ^ options guards |
47 ! ! |
47 ! ! |
48 |
48 |
49 !PPCCodeGenerator methodsFor:'code generation'! |
49 !PPCCodeGenerator methodsFor:'code generation'! |
50 |
50 |
51 generateChoiceChildOf: choiceNode atIndex: choiceChildNodeIndex useGuards: useGuards storeResultInto: resultVar |
51 generateChoiceChildOf: choiceNode atIndex: choiceChildNodeIndex useGuards: useGuards storeResultInto: resultVar |
338 variableNode parent isMessage ifTrue:[ |
338 variableNode parent isMessage ifTrue:[ |
339 | parent | |
339 | parent | |
340 |
340 |
341 parent := variableNode parent. |
341 parent := variableNode parent. |
342 "Check for <barg> at: <number>" |
342 "Check for <barg> at: <number>" |
343 ((parent selector == #at:) and:[ parent arguments first isLiteralNumber ]) ifTrue:[ |
343 ((parent selector == #at:) and:[ parent options first isLiteralNumber ]) ifTrue:[ |
344 blockMatches at: parent put: (childValueVars at: parent arguments first value). |
344 blockMatches at: parent put: (childValueVars at: parent options first value). |
345 ] ifFalse:[ |
345 ] ifFalse:[ |
346 "Check for <barg> first / second / ..." |
346 "Check for <barg> first / second / ..." |
347 | i | |
347 | i | |
348 |
348 |
349 i := #(first second third fourth fifth sixth) indexOf: parent selector. |
349 i := #(first second third fourth fifth sixth) indexOf: parent selector. |
949 id := codeGen idFor: node. |
949 id := codeGen idFor: node. |
950 codeGen profileTokenRead: id. |
950 codeGen profileTokenRead: id. |
951 |
951 |
952 self compileTokenWhitespace: node. |
952 self compileTokenWhitespace: node. |
953 |
953 |
954 (arguments guards and: [(guard := PPCGuard on: node) makesSense]) ifTrue: [ |
954 (options guards and: [(guard := PPCGuard on: node) makesSense]) ifTrue: [ |
955 guard id: id, '_guard'. |
955 guard id: id, '_guard'. |
956 codeGen code: 'context atEnd ifTrue: [ self error ].'. |
956 codeGen code: 'context atEnd ifTrue: [ self error ].'. |
957 guard compileGuard: codeGen. |
957 guard compileGuard: codeGen. |
958 codeGen codeOnLine: 'ifFalse: [ self error ].'. |
958 codeGen codeOnLine: 'ifFalse: [ self error ].'. |
959 codeGen code: 'error ifFalse: ['. |
959 codeGen code: 'error ifFalse: ['. |
961 ]. |
961 ]. |
962 |
962 |
963 codeGen codeAssign: 'context position + 1.' to: startVar. |
963 codeGen codeAssign: 'context position + 1.' to: startVar. |
964 codeGen codeEvaluateAndAssign:[ self visit:node child ] to:#whatever. |
964 codeGen codeEvaluateAndAssign:[ self visit:node child ] to:#whatever. |
965 |
965 |
966 (arguments guards and: [(guard := PPCGuard on: node) makesSense]) ifTrue: [ |
966 (options guards and: [(guard := PPCGuard on: node) makesSense]) ifTrue: [ |
967 codeGen dedent. |
967 codeGen dedent. |
968 codeGen code: '].'. |
968 codeGen code: '].'. |
969 ]. |
969 ]. |
970 |
970 |
971 codeGen codeIf: 'error' then: nil else: [ |
971 codeGen codeIf: 'error' then: nil else: [ |