compiler/PPCMethod.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 24 Aug 2015 15:56:20 +0100
changeset 525 751532c8f3db
parent 516 3b81c9e53352
parent 524 f6f68d32de73
permissions -rw-r--r--
Merge
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' }"
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: 414
diff changeset
     3
"{ NameSpace: Smalltalk }"
116d2b2af905 To fold
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 414
diff changeset
     4
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     5
Object subclass:#PPCMethod
515
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
     6
	instanceVariableNames:'selector source category variableForReturn'
391
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:''
502
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
     9
	category:'PetitCompiler-Compiler-Codegen'
391
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
399
b5b7a6db033b Fix in PPCMethod>>addVariable: make sure variable is added only once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 393
diff changeset
    12
422
116d2b2af905 To fold
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 414
diff changeset
    13
!PPCMethod class methodsFor:'as yet unclassified'!
393
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
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
    21
!PPCMethod methodsFor:'accessing'!
391
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
body
524
f6f68d32de73 Merged in PetitCompiler-JanVrany.170, PetitCompiler-Tests-JanKurs.116, PetitCompiler-Extras-Tests-JanKurs.29, PetitCompiler-Benchmarks-JanKurs.19
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 515
diff changeset
    24
    self halt: '???'.
f6f68d32de73 Merged in PetitCompiler-JanVrany.170, PetitCompiler-Tests-JanKurs.116, PetitCompiler-Extras-Tests-JanKurs.29, PetitCompiler-Benchmarks-JanKurs.19
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 515
diff changeset
    25
"	^ buffer contents"
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
bridge
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
    ^ PPCBridge on: self methodName.
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    30
!
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    31
459
4751c407bb40 Merged with PetitCompiler-JanKurs.20150510144201, PetitCompiler-Tests-JanKurs.20150510144201, PetitCompiler-Extras-Tests-JanKurs.20150510144201, PetitCompiler-Benchmarks-JanKurs.20150510144201
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 452
diff changeset
    32
category
4751c407bb40 Merged with PetitCompiler-JanKurs.20150510144201, PetitCompiler-Tests-JanKurs.20150510144201, PetitCompiler-Extras-Tests-JanKurs.20150510144201, PetitCompiler-Benchmarks-JanKurs.20150510144201
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 452
diff changeset
    33
    ^ category isNil 
4751c407bb40 Merged with PetitCompiler-JanKurs.20150510144201, PetitCompiler-Tests-JanKurs.20150510144201, PetitCompiler-Extras-Tests-JanKurs.20150510144201, PetitCompiler-Benchmarks-JanKurs.20150510144201
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 452
diff changeset
    34
        ifTrue: [ category := 'generated' ]
4751c407bb40 Merged with PetitCompiler-JanKurs.20150510144201, PetitCompiler-Tests-JanKurs.20150510144201, PetitCompiler-Extras-Tests-JanKurs.20150510144201, PetitCompiler-Benchmarks-JanKurs.20150510144201
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 452
diff changeset
    35
        ifFalse: [ category ]
464
f6d77fee9811 Updated to PetitCompiler-JanKurs.118, PetitCompiler-Tests-JanKurs.46, PetitCompiler-Extras-Tests-JanKurs.11, and PetitCompiler-Benchmarks-JanKurs.11
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 459
diff changeset
    36
                          
459
4751c407bb40 Merged with PetitCompiler-JanKurs.20150510144201, PetitCompiler-Tests-JanKurs.20150510144201, PetitCompiler-Extras-Tests-JanKurs.20150510144201, PetitCompiler-Benchmarks-JanKurs.20150510144201
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 452
diff changeset
    37
!
4751c407bb40 Merged with PetitCompiler-JanKurs.20150510144201, PetitCompiler-Tests-JanKurs.20150510144201, PetitCompiler-Extras-Tests-JanKurs.20150510144201, PetitCompiler-Benchmarks-JanKurs.20150510144201
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 452
diff changeset
    38
4751c407bb40 Merged with PetitCompiler-JanKurs.20150510144201, PetitCompiler-Tests-JanKurs.20150510144201, PetitCompiler-Extras-Tests-JanKurs.20150510144201, PetitCompiler-Benchmarks-JanKurs.20150510144201
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 452
diff changeset
    39
category: value
4751c407bb40 Merged with PetitCompiler-JanKurs.20150510144201, PetitCompiler-Tests-JanKurs.20150510144201, PetitCompiler-Extras-Tests-JanKurs.20150510144201, PetitCompiler-Benchmarks-JanKurs.20150510144201
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 452
diff changeset
    40
    category := value
4751c407bb40 Merged with PetitCompiler-JanKurs.20150510144201, PetitCompiler-Tests-JanKurs.20150510144201, PetitCompiler-Extras-Tests-JanKurs.20150510144201, PetitCompiler-Benchmarks-JanKurs.20150510144201
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 452
diff changeset
    41
!
4751c407bb40 Merged with PetitCompiler-JanKurs.20150510144201, PetitCompiler-Tests-JanKurs.20150510144201, PetitCompiler-Extras-Tests-JanKurs.20150510144201, PetitCompiler-Benchmarks-JanKurs.20150510144201
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 452
diff changeset
    42
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    43
code
502
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
    44
    ^ String streamContents: [ :s |
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
    45
        s nextPutAll: self methodName; cr.
515
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
    46
        source codeOn: s.    
502
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
    47
    ]
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
    48
502
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
    49
    "Modified: / 01-06-2015 / 21:24:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    50
!
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    51
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    52
id: value
515
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
    53
    selector := value
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    54
!
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    55
502
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
    56
indentationLevel
515
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
    57
    ^ source indentationLevel
502
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
    58
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
    59
    "Created: / 01-06-2015 / 21:38:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
    60
!
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
    61
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
    62
indentationLevel: anInteger
515
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
    63
    source indentationLevel: anInteger
502
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
    64
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
    65
    "Created: / 01-06-2015 / 21:38:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
    66
!
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
    67
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    68
methodName
515
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
    69
    ^ selector
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    70
!
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    71
515
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
    72
source
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
    73
    ^ source isString ifTrue:[ 
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
    74
        source
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
    75
    ] ifFalse:[ 
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
    76
        String streamContents: [ :s |
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
    77
            s nextPutAll: self methodName; cr.
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
    78
            source sourceOn:s.    
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
    79
        ]
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
    80
    ].
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
    81
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
    82
    "Created: / 24-07-2015 / 19:46:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
    83
!
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
    84
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
    85
source: aString
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
    86
    source := aString
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
    87
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
    88
    "Created: / 24-07-2015 / 19:48:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
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
    89
! !
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
    90
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
    91
!PPCMethod methodsFor:'as yet unclassified'!
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
    92
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
    93
add: string
515
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
    94
    source add: string
502
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
    95
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
    96
    "Modified: / 01-06-2015 / 21:09:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
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
    97
!
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
    98
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
    99
addOnLine: string
515
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
   100
    source addOnLine: string
502
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   101
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   102
    "Modified: / 01-06-2015 / 21:09:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
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
   103
!
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
   104
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
   105
call
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
   106
    ^ 'self ', self methodName, '.'.
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
   107
!
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
   108
515
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
   109
callOn: receiver
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
   110
    ^ receiver, ' ', self methodName.
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
   111
!
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
   112
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   113
profilingBegin
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
   114
    self profile ifTrue: [ 
515
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
   115
 																^ '  context methodInvoked: #', selector, '.'	
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
   116
    ].
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
   117
    ^ ''
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   118
!
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   119
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   120
profilingEnd
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
   121
    self profile ifTrue: [ 
515
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
   122
 																^ '  context methodFinished: #', selector, '.'	
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
   123
    ].
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
   124
    ^ ''
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   125
! !
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   126
502
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   127
!PPCMethod methodsFor:'code generation'!
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   128
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   129
code: aStringOrBlockOrRBParseNode
515
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
   130
    source code: aStringOrBlockOrRBParseNode.
502
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   131
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   132
    "Created: / 01-06-2015 / 22:31:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   133
    "Modified (format): / 01-06-2015 / 23:50:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   134
!
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   135
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   136
codeBlock: contents
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   137
    | outerBlock innerBlock |
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   138
515
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
   139
    outerBlock := source.
502
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   140
    innerBlock := PPCCodeBlock new.
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   141
    innerBlock indentationLevel: outerBlock indentationLevel + 1.  
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   142
    [ 
524
f6f68d32de73 Merged in PetitCompiler-JanVrany.170, PetitCompiler-Tests-JanKurs.116, PetitCompiler-Extras-Tests-JanKurs.29, PetitCompiler-Benchmarks-JanKurs.19
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 515
diff changeset
   143
        outerBlock addOnLine: '['.
515
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
   144
        source := innerBlock.
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
   145
        self codeOnLine: contents.
502
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   146
    ] ensure:[
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   147
        outerBlock 
524
f6f68d32de73 Merged in PetitCompiler-JanVrany.170, PetitCompiler-Tests-JanKurs.116, PetitCompiler-Extras-Tests-JanKurs.29, PetitCompiler-Benchmarks-JanKurs.19
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 515
diff changeset
   148
            codeOnLine: (String streamContents:[:s | innerBlock sourceOn:s]);
f6f68d32de73 Merged in PetitCompiler-JanVrany.170, PetitCompiler-Tests-JanKurs.116, PetitCompiler-Extras-Tests-JanKurs.29, PetitCompiler-Benchmarks-JanKurs.19
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 515
diff changeset
   149
            add: ']'.
515
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
   150
        source := outerBlock.
502
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   151
    ]
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
   152
502
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   153
    "Created: / 01-06-2015 / 22:33:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   154
    "Modified: / 03-06-2015 / 06:11:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
515
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
   155
!
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
   156
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
   157
codeOnLine: aStringOrBlockOrRBParseNode
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
   158
    source codeOnLine: aStringOrBlockOrRBParseNode.
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
   159
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
   160
    "Created: / 01-06-2015 / 22:31:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
   161
    "Modified (format): / 01-06-2015 / 23:50:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
502
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   162
! !
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   163
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   164
!PPCMethod methodsFor:'code generation - indenting'!
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   165
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   166
dedent
515
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
   167
    source dedent
502
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   168
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   169
    "Created: / 01-06-2015 / 21:32:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   170
!
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
   171
502
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   172
indent
515
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
   173
    source indent
502
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   174
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   175
    "Created: / 01-06-2015 / 21:32:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
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
   176
!
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
   177
502
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   178
nl
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   179
515
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
   180
    source nl
502
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   181
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   182
    "Created: / 01-06-2015 / 21:52:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   183
! !
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   184
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   185
!PPCMethod methodsFor:'code generation - variables'!
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   186
515
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
   187
addVariable: name
524
f6f68d32de73 Merged in PetitCompiler-JanVrany.170, PetitCompiler-Tests-JanKurs.116, PetitCompiler-Extras-Tests-JanKurs.29, PetitCompiler-Benchmarks-JanKurs.19
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 515
diff changeset
   188
    self halt: 'deprecated'.
f6f68d32de73 Merged in PetitCompiler-JanVrany.170, PetitCompiler-Tests-JanKurs.116, PetitCompiler-Extras-Tests-JanKurs.29, PetitCompiler-Benchmarks-JanKurs.19
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 515
diff changeset
   189
"	(variables includes: name) ifTrue:[ 
515
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
   190
        self error:'Duplicate variable name, must rename'.
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
   191
    ].
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
   192
    variables add: name.
524
f6f68d32de73 Merged in PetitCompiler-JanVrany.170, PetitCompiler-Tests-JanKurs.116, PetitCompiler-Extras-Tests-JanKurs.29, PetitCompiler-Benchmarks-JanKurs.19
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 515
diff changeset
   193
"
f6f68d32de73 Merged in PetitCompiler-JanVrany.170, PetitCompiler-Tests-JanKurs.116, PetitCompiler-Extras-Tests-JanKurs.29, PetitCompiler-Benchmarks-JanKurs.19
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 515
diff changeset
   194
    "Modified: / 23-04-2015 / 12:29:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
515
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
   195
!
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
   196
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
   197
allocateReturnVariable
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
   198
    
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
   199
	^ variableForReturn isNil ifTrue:[ 
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
   200
		variableForReturn := self allocateTemporaryVariableNamed: 'retval'  
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
   201
	] ifFalse:[ 
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
   202
		variableForReturn
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
   203
	].
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
   204
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
   205
    "Created: / 23-04-2015 / 18:03:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
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
   206
!
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
   207
502
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   208
allocateReturnVariableNamed: name    
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   209
    "Allocate temporary variable used for storing a parser's return value (the parsed object)"
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   210
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   211
    variableForReturn notNil ifTrue:[ 
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   212
        self error: 'Return variable already allocated!!'.
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   213
        ^ self.
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   214
    ]. 
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   215
    variableForReturn := self allocateTemporaryVariableNamed: name.
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   216
    ^ variableForReturn
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   217
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   218
    "Created: / 15-06-2015 / 17:52:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   219
!
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   220
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
   221
allocateTemporaryVariableNamed:preferredName 
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
   222
    "Allocate a new variable with (preferably) given name.
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
   223
     Returns a real variable name that should be used."
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
   224
515
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
   225
    ^ source allocateTemporaryVariableNamed: preferredName
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
   226
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
   227
    "Created: / 23-04-2015 / 17:37:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
502
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   228
    "Modified: / 01-06-2015 / 21:04:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
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
   229
!
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
   230
502
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   231
returnVariable    
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   232
    ^ variableForReturn
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
   233
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
   234
    "Created: / 23-04-2015 / 20:50:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
502
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   235
    "Modified (format): / 15-06-2015 / 18:12:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
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
   236
!
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
   237
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
   238
returnVariable: aString
502
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   239
    (variableForReturn notNil and:[variableForReturn ~= aString]) ifTrue:[ 
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   240
         self error: 'Return variable already allocated with different name (''', variableForReturn , ''' vs ''', aString,''')'.
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   241
    ].
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   242
    variableForReturn := aString
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
   243
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
   244
    "Created: / 23-04-2015 / 18:23:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
502
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   245
    "Modified: / 15-06-2015 / 18:14:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
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
   246
! !
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
   247
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   248
!PPCMethod methodsFor:'initialization'!
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   249
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   250
initialize
515
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
   251
    source := PPCCodeBlock new.
502
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   252
1e45d3c96ec5 Updated to PetitCompiler-JanVrany.135, PetitCompiler-Tests-JanKurs.93, PetitCompiler-Extras-Tests-JanVrany.16, PetitCompiler-Benchmarks-JanKurs.12
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 464
diff changeset
   253
    "Modified: / 01-06-2015 / 21:33:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
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
   254
! !
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
   255
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
   256
!PPCMethod methodsFor:'printing'!
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
   257
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
   258
printOn:aStream
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
   259
    "append a printed representation if the receiver to the argument, aStream"
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
   260
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
   261
    super printOn:aStream.
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
   262
    aStream nextPutAll:' id: '.
515
b5316ef15274 Updated to PetitCompiler-JanKurs.160, PetitCompiler-Tests-JanKurs.112, PetitCompiler-Extras-Tests-JanKurs.25, PetitCompiler-Benchmarks-JanKurs.17
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 502
diff changeset
   263
    selector printOn:aStream.
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
   264
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
   265
    "Modified: / 23-04-2015 / 12:32:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   266
! !
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   267
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
   268
!PPCMethod methodsFor:'testing'!
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
   269
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
   270
isInline
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
   271
    ^ false
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
   272
!
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
   273
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
   274
isMethod
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
   275
    ^ true
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
   276
! !
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
   277
399
b5b7a6db033b Fix in PPCMethod>>addVariable: make sure variable is added only once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 393
diff changeset
   278
!PPCMethod class methodsFor:'documentation'!
b5b7a6db033b Fix in PPCMethod>>addVariable: make sure variable is added only once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 393
diff changeset
   279
b5b7a6db033b Fix in PPCMethod>>addVariable: make sure variable is added only once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 393
diff changeset
   280
version_HG
b5b7a6db033b Fix in PPCMethod>>addVariable: make sure variable is added only once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 393
diff changeset
   281
b5b7a6db033b Fix in PPCMethod>>addVariable: make sure variable is added only once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 393
diff changeset
   282
    ^ '$Changeset: <not expanded> $'
b5b7a6db033b Fix in PPCMethod>>addVariable: make sure variable is added only once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 393
diff changeset
   283
! !
b5b7a6db033b Fix in PPCMethod>>addVariable: make sure variable is added only once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 393
diff changeset
   284