File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -79,10 +79,10 @@ function buildFromCallExpression(
7979 expr : CallExpression ,
8080 builder : llvm . IRBuilder
8181) {
82- const callle = ctx . llvmModule . getFunction ( 'puts' ) ;
82+ const callle = buildFromExpression ( expr . callee , ctx , builder ) ;
8383 if ( ! callle ) {
8484 throw new Error (
85- `Unknown fn: "puts" `
85+ `We cannot prepare expression to call this function `
8686 ) ;
8787 }
8888
@@ -96,8 +96,14 @@ function buildFromCallExpression(
9696 ) ;
9797}
9898
99+ function buildFromIdentifier ( block : Identifier , ctx : Context , builder : llvm . IRBuilder ) : llvm . Value {
100+ return ctx . llvmModule . getFunction ( block . name ) ;
101+ }
102+
99103function buildFromExpression ( block : Expression , ctx : Context , builder : llvm . IRBuilder ) : llvm . Value {
100104 switch ( block . type ) {
105+ case 'Identifier' :
106+ return buildFromIdentifier ( block , ctx , builder ) ;
101107 case 'NumericLiteral' :
102108 return buildFromNumberValue ( ctx , block . value , builder ) ;
103109 case 'StringLiteral' :
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ const example = `
88
99 returnVoid();
1010
11- console.log ("Hello World!");
11+ puts ("Hello World!");
1212}
1313` ;
1414
You can’t perform that action at this time.
0 commit comments