compiler/PPCLiteralNode.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Tue, 14 Apr 2015 07:40:53 +0100
changeset 428 b879012e366e
parent 422 116d2b2af905
child 438 20598d7ce9fa
permissions -rw-r--r--
Compilation fixed, removed obsolete methods ...to make it in sync with: Name: PetitCompiler-JanKurs.71 Author: JanKurs Time: 18-11-2014, 09:48:35.425 AM UUID: 06352c33-3c76-4382-8536-0cc48e225117

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

"{ NameSpace: Smalltalk }"

PPCAbstractLiteralNode subclass:#PPCLiteralNode
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'PetitCompiler-Nodes'
!

!PPCLiteralNode methodsFor:'compiling'!

compileWith: compiler effect: effect id: id
	| encodedLiteral |
	
	encodedLiteral := self encodeQuotes: literal.
	compiler startMethod: id.
	compiler addVariable: 'retval'.
	compiler addVariable: 'position'.
	compiler add: 'position := context position.'.

	compiler add: 'retval := context next: ', literal size asString, '.'.
	compiler add: 'retval = #''', encodedLiteral, ''' ifTrue: [ ^ #''', encodedLiteral, '''].'.
	compiler add: 'context position: position.'.
	compiler add: '^ self error: ''', encodedLiteral,  ' expected'' at: position'.
 ^	compiler stopMethod.	
! !

!PPCLiteralNode methodsFor:'optimizing'!

asInlined
	^ PPCInlineLiteralNode new
		literal: literal;
		name: name;
		yourself
! !