'From Cuis 2.0 of 24 February 2010 [latest update: #440] on 3 March 2010 at 8:50:28 am'!

!AssignmentNode methodsFor: 'testing' stamp: 'cmm 3/1/2010 10:08'!
isComplex
	^ value isComplex! !

!AssignmentNode methodsFor: 'printing' stamp: 'jmv 3/3/2010 08:49'!
printOn: aStream indent: level 
	variable printOn: aStream indent: level.
	aStream nextPutAll: ' _ '.
	value printOn: aStream indent: level! !


!BlockNode methodsFor: 'testing' stamp: 'cmm 3/1/2010 15:06'!
isComplex
	^ statements size > 1 or:
		[ (statements size = 1 and: [ statements first isComplex ]) or:
			[ arguments size > 0 or: [ temporaries size > 0 ] ] ]! !

!BlockNode methodsFor: 'printing' stamp: 'cmm 3/1/2010 16:19'!
printArgumentsOn: aStream indent: level 
	arguments size = 0 ifTrue: [^ self].
	arguments do: 
		[ : arg | 
		aStream nextPut: $: ;
			 space;
			 nextPutAll: arg key;
			 space ].
	aStream 
		nextPut: $|;
		space! !

!BlockNode methodsFor: 'printing' stamp: 'cmm 3/1/2010 19:36'!
printOn: aStream indent: level 
	aStream
		 nextPut:  $[ ;
		 space.
	self
		printArgumentsOn:  aStream
		indent:  level.
	(self
		printTemporaries:  temporaries
		on:  aStream
		doPrior:  [ ] ) ifTrue: 
		[ "If >0 temps and >1 statement, put all statements on separate lines"
		statements size >  1
			ifTrue:  [ aStream crtab:  level ] 
			ifFalse:  [ aStream space] ] .
	self
		printStatementsOn:  aStream
		indent:  level.
	aStream
		 space ;
		 nextPut:  $]! !

!BlockNode methodsFor: 'printing' stamp: 'cmm 3/1/2010 19:34'!
printWithClosureAnalysisOn: aStream indent: level
	aStream nextPut: $[; space.
	blockExtent ifNotNil: [aStream print: blockExtent].
	self printWithClosureAnalysisArgumentsOn: aStream indent: level.
	self printWithClosureAnalysisTemporariesOn: aStream indent: level.
	self printWithClosureAnalysisStatementsOn: aStream indent: level.
	aStream space; nextPut: $]! !


!BraceNode methodsFor: 'printing' stamp: 'cmm 3/1/2010 14:31'!
printOn: aStream indent: level 
	aStream nextPut: ${.
	1
		to: elements size
		do: 
			[ : i | 
			(elements at: i)
				printOn: aStream
				indent: level.
			i < elements size ifTrue: 
				[ aStream
					 nextPutAll: '. ' ;
					 crtab: level ] ].
	aStream nextPut: $}! !


!CascadeNode methodsFor: 'printing' stamp: 'cmm 3/1/2010 14:32'!
printOn: aStream indent: level precedence: p 
	p > 0 ifTrue: [ aStream nextPut: $( ].
	messages first
		printReceiver: receiver
		on: aStream
		indent: level.
	1
		to: messages size
		do: 
			[ : i | 
			aStream crtab: level + 1.
			(messages at: i)
				printOn: aStream
				indent: level.
			i < messages size ifTrue: [ aStream nextPutAll: ' ;' ] ].
	p > 0 ifTrue: [ aStream nextPut: $) ]! !

!CascadeNode methodsFor: 'testing' stamp: 'cmm 3/1/2010 09:10'!
isComplex
	^ true! !


!MessageNode methodsFor: 'printing' stamp: 'cmm 3/1/2010 14:39'!
printIfOn: aStream indent: level 
	receiver ifNotNil: 
		[ receiver
			printOn: aStream
			indent: level
			precedence: precedence ].
	(arguments last isJust: NodeNil) ifTrue: [ ^ self
			printKeywords: #ifTrue:
			arguments: (Array with: arguments first)
			on: aStream
			indent: level ].
	(arguments last isJust: NodeFalse) ifTrue: [ ^ self
			printKeywords: #and:
			arguments: (Array with: arguments first)
			on: aStream
			indent: level ].
	(arguments first isJust: NodeNil) ifTrue: [ ^ self
			printKeywords: #ifFalse:
			arguments: (Array with: arguments last)
			on: aStream
			indent: level ].
	(arguments first isJust: NodeTrue) ifTrue: [ ^ self
			printKeywords: #or:
			arguments: (Array with: arguments last)
			on: aStream
			indent: level ].
	self
		printKeywords: #ifTrue:ifFalse:
		arguments: arguments
		on: aStream
		indent: level! !

!MessageNode methodsFor: 'printing' stamp: 'cmm 3/1/2010 21:02'!
printKeywords: key arguments: args on: aStream indent: level 
	| keywords indent arg kwd doCrTab |
	args size = 0 ifTrue:
		[ aStream
			 space ;
			 nextPutAll: key.
		^ self ].
	keywords := key keywords.
	doCrTab := args size > 1.
	1
		to: (args size min: keywords size)
		do:
			[ : i | arg := args at: i.
			kwd := keywords at: i.
			doCrTab
				ifTrue:
					[ aStream crtab: level + 1.
					indent := 1
					"newline after big args" ]
				ifFalse:
					[ aStream space.
					indent := 0 ].
			aStream nextPutAll: kwd.
			arg isComplex
				ifTrue: [ aStream crtab: level + indent + 1 ]
				ifFalse: [ aStream space ].
			arg
				printOn: aStream
				indent: level + 1 + indent
				precedence:
					(precedence = 2
						ifTrue: [ 1 ]
						ifFalse: [ precedence ]) ]! !

!MessageNode methodsFor: 'testing' stamp: 'cmm 3/1/2010 10:34'!
isComplex
	^ (special
			between: 1
			and: 10)
		or: 
		[ arguments size > 1
			or: 
			[ receiver isComplex or: [ arguments anySatisfy: [ : each | each isComplex ] ] ] ]! !

