Fixed code generation for deterministic choice w.r.t inlining
authorJan Vrany <jan.vrany@fit.cvut.cz>
Thu, 21 May 2015 15:35:26 +0100
changeset 467 dd13296df294
parent 466 ac2d987a03d3
child 468 3cbcf5839693
Fixed code generation for deterministic choice w.r.t inlining For PPCDeterministicChoiceNode generate code in form if () else if () else if () else error instead of sequence of ifs. The former is safe w.r.t inlining.
compiler/PPCTokenizingCodeGenerator.st
--- a/compiler/PPCTokenizingCodeGenerator.st	Thu May 21 14:43:38 2015 +0100
+++ b/compiler/PPCTokenizingCodeGenerator.st	Thu May 21 15:35:26 2015 +0100
@@ -9,6 +9,7 @@
 	category:'PetitCompiler-Visitors'
 !
 
+
 !PPCTokenizingCodeGenerator methodsFor:'accessing'!
 
 guards
@@ -148,10 +149,13 @@
             compiler codeStoreValueOf: [ self visit: child ] intoVariable: self retvalVar.
             compiler codeReturn: self retvalVar.
         compiler dedent.
-        compiler add: '].'
+        compiler add: '] ifFalse:['
     ].
+    compiler codeError: 'no choice found'.
+    node children size timesRepeat: [ compiler add: ']' ].
+    compiler add: '.'.
 
-    compiler codeError: 'no choice found'.
+    "Modified: / 21-05-2015 / 15:31:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 visitTokenChoiceNode: node
@@ -206,3 +210,10 @@
     self error: 'shoudl not happend!!'
 ! !
 
+!PPCTokenizingCodeGenerator class methodsFor:'documentation'!
+
+version_HG
+
+    ^ '$Changeset: <not expanded> $'
+! !
+