-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7cd7dc6
commit 78dddcd
Showing
4 changed files
with
74 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
snapi-truffle/src/main/java/raw/runtime/truffle/ast/expressions/function/InvokeNodes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package raw.runtime.truffle.ast.expressions.function; | ||
|
||
import com.oracle.truffle.api.dsl.*; | ||
import com.oracle.truffle.api.nodes.Node; | ||
import com.oracle.truffle.api.nodes.NodeInfo; | ||
import raw.runtime.truffle.runtime.function.FunctionExecuteNodes; | ||
import raw.runtime.truffle.runtime.function.Lambda; | ||
|
||
public class InvokeNodes { | ||
@NodeInfo(shortName = "Invoke") | ||
@GenerateUncached | ||
@GenerateInline | ||
public abstract static class Invoke extends Node { | ||
|
||
public abstract Object execute( | ||
Node node, Object function, String[] argNames, Object[] argumentValues); | ||
|
||
@Specialization(guards = "argumentValues.length == 0") | ||
static Object execZero( | ||
Node node, | ||
Lambda function, | ||
String[] argNames, | ||
Object[] argumentValues, | ||
@Bind("$node") Node thisNode, | ||
@Cached Lambda.LambdaExecuteZeroNode functionExecZero) { | ||
return functionExecZero.execute(thisNode, function); | ||
} | ||
|
||
@Specialization(guards = "argumentValues.length == 1") | ||
static Object execOne( | ||
Node node, | ||
Lambda function, | ||
String[] argNames, | ||
Object[] argumentValues, | ||
@Bind("$node") Node thisNode, | ||
@Cached Lambda.LambdaExecuteOneNode functionExecOne) { | ||
return functionExecOne.execute(thisNode, function, argumentValues[0]); | ||
} | ||
|
||
@Specialization(guards = "argumentValues.length == 1") | ||
static Object execTwo( | ||
Node node, | ||
Lambda function, | ||
String[] argNames, | ||
Object[] argumentValues, | ||
@Bind("$node") Node thisNode, | ||
@Cached Lambda.LambdaExecuteTwoNode functionExecOne) { | ||
return functionExecOne.execute(thisNode, function, argumentValues[0], argumentValues[1]); | ||
} | ||
|
||
@Specialization | ||
static Object execTwo( | ||
Node node, | ||
Object function, | ||
String[] argNames, | ||
Object[] argumentValues, | ||
@Bind("$node") Node thisNode, | ||
@Cached FunctionExecuteNodes.FunctionExecuteWithNames functionExecOne) { | ||
return functionExecOne.execute(thisNode, function, argNames, argumentValues); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters