compiler/PPCPlusNode.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sun, 26 Oct 2014 01:28:07 +0000
changeset 392 9b297f0d949c
parent 391 553a5456963b
child 421 7e08b31e0dae
permissions -rw-r--r--
Fixed PPCNode>>doOptmizationLoop:status: Must report status to changeStatus as caller is checking its value. Also, added PPCOptimizationResult class>>new as Smaltalk/X (actually, most Smalltalks) does not call #initialize by default.

"{ Package: 'stx:goodies/petitparser/compiler' }"

PPCDelegateNode subclass:#PPCPlusNode
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'PetitCompiler-Nodes'
!

!PPCPlusNode methodsFor:'as yet unclassified'!

compileWith: compiler effect: effect id: id
		
	compiler startMethod: id.
	compiler addVariable: 'retval'.
	compiler addVariable: 'element'.
		
	compiler add: 'retval := OrderedCollection new.'.
	compiler add: 'element := '.
	compiler callOnLine: (child compileWith: compiler).
	compiler add: 'error ifTrue: [ ^ self error: ''at least one occurence expected'' ].'.
	compiler add: 'retval add: element.'.
	
	compiler add: 'element := '.
	compiler callOnLine: (child compileWith: compiler).
	compiler add: '[ error ] whileFalse: ['.
	compiler indent.
	compiler add: 'retval add: element.'.
	compiler add: 'element := '.
	compiler callOnLine: (child compileWith: compiler).
	compiler dedent.
	compiler add: '].'.
	compiler add: 'self clearError.'.
	compiler add: '^ retval asArray'.
 ^ compiler stopMethod.
!

prefix
	^ #plus
! !