-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
9 changed files
with
81 additions
and
22 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
16 changes: 16 additions & 0 deletions
16
interpreter/jvm/src/main/scala/chester/truffle/ChesterContext.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,16 @@ | ||
package chester.truffle; | ||
|
||
import com.oracle.truffle.api.TruffleLanguage; | ||
import com.oracle.truffle.api.nodes.Node; | ||
import com.oracle.truffle.api.object.DynamicObject; | ||
|
||
public final class ChesterContext { | ||
private static final TruffleLanguage.ContextReference<ChesterContext> REF = | ||
TruffleLanguage.ContextReference.create(ChesterLang.class); | ||
|
||
/** Retrieve the current language context for the given {@link Node}. */ | ||
public static ChesterContext get(Node node) { | ||
return REF.get(node); | ||
} | ||
|
||
} |
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 was deleted.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
interpreter/jvm/src/main/scala/chester/truffle/node/BooleanNode.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,25 @@ | ||
package chester.truffle.node; | ||
|
||
import chester.syntax.core.BooleanTerm; | ||
import chester.syntax.core.BooleanTermC; | ||
import chester.syntax.core.TermMeta; | ||
import scala.None; | ||
import scala.None$; | ||
import scala.Option; | ||
|
||
public final class BooleanNode extends LiteralNode implements BooleanTermC<TermNode> { | ||
private final boolean value; | ||
|
||
public BooleanNode(boolean value) { | ||
this.value = value; | ||
} | ||
@Override | ||
public boolean value() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public Option<TermMeta> meta() { | ||
return (Option) None$.MODULE$; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
interpreter/jvm/src/main/scala/chester/truffle/node/ChesterNode.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,16 @@ | ||
package chester.truffle.node; | ||
|
||
import chester.truffle.ChesterContext; | ||
import chester.truffle.ChesterLang; | ||
import com.oracle.truffle.api.nodes.Node; | ||
|
||
public abstract class ChesterNode extends Node { | ||
protected final ChesterLang currentTruffleLanguage() { | ||
return ChesterLang.get(this); | ||
} | ||
|
||
/** Allows retrieving the current Truffle language Context from within a Node. */ | ||
protected final ChesterContext currentLanguageContext() { | ||
return ChesterContext.get(this); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
interpreter/jvm/src/main/scala/chester/truffle/node/LiteralNode.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,6 @@ | ||
package chester.truffle.node; | ||
|
||
import chester.syntax.core.LiteralTermT; | ||
|
||
public abstract class LiteralNode extends TermNode implements LiteralTermT<TermNode> { | ||
} |
6 changes: 6 additions & 0 deletions
6
interpreter/jvm/src/main/scala/chester/truffle/node/TermNode.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,6 @@ | ||
package chester.truffle.node; | ||
|
||
import chester.syntax.core.TermT; | ||
|
||
public abstract class TermNode extends ChesterNode implements TermT<TermNode> { | ||
} |
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