Skip to content

Commit

Permalink
Add test compiling multiple functions calling one another
Browse files Browse the repository at this point in the history
This tests compilation of relocatable calls.
  • Loading branch information
janvrany committed Jun 24, 2024
1 parent d008da5 commit 8533901
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/Tinyrossa-Tests/TRCompilationTestCase.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,53 @@ TRCompilationTestCase >> test03_lconst [
"
]

{ #category : #tests }
TRCompilationTestCase >> test04_call_resolved [
| comp1 bldr1 comp2 bldr2 |

self target name = 'powerpc64le-linux' ifTrue: [
self skip: 'Skipped since calls are not implemented for POWER (see issue #45)'.
].

" ### CALLEE ### "
comp1 := TRCompilation forConfig: compilation config.
bldr1 := comp1 builder.
bldr1 defineName: 'callee' type: Int32.
bldr1 defineParameter: 'x' type: Int32.
bldr1 ireturn:
{ bldr1 iadd:
{ bldr1 iload: 'x'.
bldr1 iconst: 1 } }.
comp1 optimize.
comp1 compile.

" ### CALLER ### "
comp2 := TRCompilation forConfig: compilation config.
bldr2 := comp2 builder.
bldr2 defineName: 'caller' type: Int32.
bldr2 defineParameter: 'x' type: Int32.
bldr2 defineFunction: 'callee' type: Int32.
bldr2 ireturn:
{ bldr2 iadd:
{ bldr2 iload: 'x'.
bldr2 icall: { bldr2 iload: 'x' . 'callee' } } }.
comp2 optimize.
comp2 compile.

" ### ######### ### "

shell inject: comp1.
shell inject: comp2.

self assert: (shell invoke: comp2 functionSymbol with: { 10 } types: { Int32 })
equals: 21

"
TRRV64GCompilationTests debug: #test03_lconst_n
TRPPC64CompilationTests debug: #test03_lconst_n
"
]

{ #category : #'tests - examples' }
TRCompilationTestCase >> test_example01_meaningOfLife [
TRCompilationExamples new
Expand Down

0 comments on commit 8533901

Please sign in to comment.