compiler/tests/PPCMockCompiler.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Tue, 16 Jun 2015 06:45:26 +0100
changeset 489 0ca7a70db0f5
parent 452 9f4558b3be66
child 524 f6f68d32de73
permissions -rw-r--r--
Fix in codegen for inlined sequence nodes. For inlined sequence nodes, generate nested ifs rather than sequential code which does not work when inlined. The reason is that #codeReturn: in inline generates instvar assignment, not method return, so in sequential code the next child of a sequence will be probed even if previous failed. If that happends, the whole sequence fail and therefore we must generate nested ifs to correctly handle this w.r.t. inlining.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     1
"{ Package: 'stx:goodies/petitparser/compiler/tests' }"
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     2
422
116d2b2af905 To fold
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 393
diff changeset
     3
"{ NameSpace: Smalltalk }"
116d2b2af905 To fold
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 393
diff changeset
     4
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     5
Object subclass:#PPCMockCompiler
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     6
	instanceVariableNames:'lines'
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     7
	classVariableNames:''
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     8
	poolDictionaries:''
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     9
	category:'PetitCompiler-Tests-Core'
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    10
!
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    11
393
00381102a9b5 Override #new in classes that implement #initialize.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 392
diff changeset
    12
00381102a9b5 Override #new in classes that implement #initialize.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 392
diff changeset
    13
!PPCMockCompiler class methodsFor:'instance creation'!
00381102a9b5 Override #new in classes that implement #initialize.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 392
diff changeset
    14
00381102a9b5 Override #new in classes that implement #initialize.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 392
diff changeset
    15
new
00381102a9b5 Override #new in classes that implement #initialize.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 392
diff changeset
    16
    "return an initialized instance"
00381102a9b5 Override #new in classes that implement #initialize.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 392
diff changeset
    17
00381102a9b5 Override #new in classes that implement #initialize.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 392
diff changeset
    18
    ^ self basicNew initialize.
00381102a9b5 Override #new in classes that implement #initialize.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 392
diff changeset
    19
! !
00381102a9b5 Override #new in classes that implement #initialize.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 392
diff changeset
    20
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    21
!PPCMockCompiler methodsFor:'accessing'!
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    22
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    23
lines
452
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
    24
    
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
    25
    ^ lines
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    26
!
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    27
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    28
lines: anObject
452
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
    29
    
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
    30
    lines := anObject
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    31
! !
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    32
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    33
!PPCMockCompiler methodsFor:'as yet unclassified'!
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    34
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    35
add: string
452
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
    36
    lines add: string
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    37
!
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    38
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    39
addConstant: object as: id
452
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
    40
    "TODO"
438
20598d7ce9fa Updated to PetitCompiler-JanKurs.100, PetitCompiler-Tests-JanKurs.44 and PetitCompiler-Benchmarks-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 422
diff changeset
    41
! !
20598d7ce9fa Updated to PetitCompiler-JanKurs.100, PetitCompiler-Tests-JanKurs.44 and PetitCompiler-Benchmarks-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 422
diff changeset
    42
20598d7ce9fa Updated to PetitCompiler-JanKurs.100, PetitCompiler-Tests-JanKurs.44 and PetitCompiler-Benchmarks-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 422
diff changeset
    43
!PPCMockCompiler methodsFor:'initialization'!
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    44
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    45
initialize
452
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
    46
    super initialize.
9f4558b3be66 Updated to PetitCompiler-JanKurs.111, PetitCompiler-Tests-JanKurs.51, PetitCompiler-Benchmarks-JanKurs.7, added PetitCompiler-Extras-Tests-JanKurs.4
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 438
diff changeset
    47
    lines := OrderedCollection new.
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    48
! !
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    49
393
00381102a9b5 Override #new in classes that implement #initialize.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 392
diff changeset
    50
!PPCMockCompiler class methodsFor:'documentation'!
00381102a9b5 Override #new in classes that implement #initialize.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 392
diff changeset
    51
00381102a9b5 Override #new in classes that implement #initialize.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 392
diff changeset
    52
version_HG
00381102a9b5 Override #new in classes that implement #initialize.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 392
diff changeset
    53
00381102a9b5 Override #new in classes that implement #initialize.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 392
diff changeset
    54
    ^ '$Changeset: <not expanded> $'
00381102a9b5 Override #new in classes that implement #initialize.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 392
diff changeset
    55
! !
00381102a9b5 Override #new in classes that implement #initialize.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 392
diff changeset
    56