compiler/PPCInlineNotLiteralNode.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 20 Apr 2015 11:23:20 +0100
changeset 432 fde2d5969fbb
parent 422 116d2b2af905
permissions -rw-r--r--
PPCBenchmarkResource updated to work on Smalltalk/X ...as API of FileReference and Filename differ.

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

"{ NameSpace: Smalltalk }"

PPCNotLiteralNode subclass:#PPCInlineNotLiteralNode
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'PetitCompiler-Nodes'
!

!PPCInlineNotLiteralNode methodsFor:'as yet unclassified'!

compileWith: compiler effect: effect id: id
	| encodedLiteral size |
	encodedLiteral := self encodeQuotes: literal.
	size := literal size asString.
	
	compiler startInline: id.
	compiler add: '((context peek: ', size, ') =#''', encodedLiteral, ''')'.
	compiler indent.
	compiler add: ' ifTrue: [ self error: ''', encodedLiteral, ' not expected'' ]'.
	compiler add: ' ifFalse: [ nil ].'.
	compiler dedent.
 ^ compiler stopInline.
! !

!PPCInlineNotLiteralNode methodsFor:'printing'!

asInlined
	^ self
!

printOn: aStream
	aStream nextPutAll: #inlined.
	super printOn: aStream.
! !