compiler/PPCInlinedMethod.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 17 Jun 2015 16:49:28 +0100
changeset 492 fc3dbe5654c5
parent 488 19a9c25960ef
child 503 ff58cd9f1f3c
permissions -rw-r--r--
Use #deepCopy instead of #copy when copying RB parse tree ...because #copy make a copy if child nodes but does not set their parents properly. Therefore node replacing does not work because it replaces it in wrong tree (original, not the copy).
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: 392
diff changeset
     3
"{ NameSpace: Smalltalk }"
116d2b2af905 To fold
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 392
diff changeset
     4
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     5
PPCMethod subclass:#PPCInlinedMethod
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
     6
	instanceVariableNames:''
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:''
477
b18b6cc7aabc Codegen refactoring [1/x]: Introduced a PPCCodeBlock
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 452
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
481
34ee0d3c72e7 Introduced PPCMappedActionNode for PPMappedActionParser.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 477
diff changeset
    12
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    13
!PPCInlinedMethod methodsFor:'as yet unclassified'!
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    14
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    15
call
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
    16
    ^ self code
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    17
!
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    18
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    19
code
477
b18b6cc7aabc Codegen refactoring [1/x]: Introduced a PPCCodeBlock
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 452
diff changeset
    20
    ^ (String streamContents:[:s | buffer codeOn:s ]) trimRight
b18b6cc7aabc Codegen refactoring [1/x]: Introduced a PPCCodeBlock
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 452
diff changeset
    21
b18b6cc7aabc Codegen refactoring [1/x]: Introduced a PPCCodeBlock
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 452
diff changeset
    22
    "Modified (format): / 01-06-2015 / 21:44:56 / 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
    23
!
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
    24
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
    25
isInline
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
    26
    ^ true
391
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
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
    29
!PPCInlinedMethod methodsFor:'code generation - variables'!
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
    30
488
19a9c25960ef Avoid creation of intermediate collection for mapped action nodes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 481
diff changeset
    31
allocateReturnVariableNamed: name
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
    32
    self error: 'return variable must be assigned by the non-inlined method....'
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
    33
488
19a9c25960ef Avoid creation of intermediate collection for mapped action nodes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 481
diff changeset
    34
    "Created: / 15-06-2015 / 17:52:35 / 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
    35
!
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
    36
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
    37
allocateTemporaryVariableNamed: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
    38
    self error: 'sorry, I can''t allocate variables....'
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
    39
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
    40
   "Created: / 23-04-2015 / 21:06:12 / 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
    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
481
34ee0d3c72e7 Introduced PPCMappedActionNode for PPMappedActionParser.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 477
diff changeset
    43
!PPCInlinedMethod class methodsFor:'documentation'!
34ee0d3c72e7 Introduced PPCMappedActionNode for PPMappedActionParser.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 477
diff changeset
    44
34ee0d3c72e7 Introduced PPCMappedActionNode for PPMappedActionParser.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 477
diff changeset
    45
version_HG
34ee0d3c72e7 Introduced PPCMappedActionNode for PPMappedActionParser.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 477
diff changeset
    46
34ee0d3c72e7 Introduced PPCMappedActionNode for PPMappedActionParser.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 477
diff changeset
    47
    ^ '$Changeset: <not expanded> $'
34ee0d3c72e7 Introduced PPCMappedActionNode for PPMappedActionParser.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 477
diff changeset
    48
! !
34ee0d3c72e7 Introduced PPCMappedActionNode for PPMappedActionParser.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 477
diff changeset
    49