Skip to content

Commit

Permalink
Merge branch 'topic/adapt_to_rewriting' into 'master'
Browse files Browse the repository at this point in the history
Adapt LKQL JIT to the rewriting Java bindings

See merge request eng/libadalang/langkit-query-language!195
  • Loading branch information
HugoGGuerrier committed Apr 4, 2024
2 parents b023da4 + 2870cdf commit 72947ac
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -529,31 +529,23 @@ public LKQLNode visit(Liblkqllang.BinOp binOp) {
final SourceLocation location = loc(binOp);

// Create the binary operator by switching on the operator type
return switch (binOp.fOp().getKindName()) {
case Liblkqllang.OpPlus.kindName -> BinPlusNodeGen.create(
return switch (binOp.fOp().getKind()) {
case OP_PLUS -> BinPlusNodeGen.create(
location, leftLocation, rightLocation, left, right);
case Liblkqllang.OpMinus.kindName -> BinMinusNodeGen.create(
case OP_MINUS -> BinMinusNodeGen.create(
location, leftLocation, rightLocation, left, right);
case Liblkqllang.OpMul.kindName -> BinMulNodeGen.create(
location, leftLocation, rightLocation, left, right);
case Liblkqllang.OpDiv.kindName -> BinDivNodeGen.create(
location, leftLocation, rightLocation, left, right);
case Liblkqllang.OpAnd.kindName -> new BinAnd(location, left, right);
case Liblkqllang.OpOr.kindName -> new BinOr(location, left, right);
case Liblkqllang.OpEq.kindName -> BinEqNodeGen.create(
location, leftLocation, rightLocation, left, right);
case Liblkqllang.OpNeq.kindName -> BinNeqNodeGen.create(
location, leftLocation, rightLocation, left, right);
case Liblkqllang.OpConcat.kindName -> BinConcatNodeGen.create(
location, leftLocation, rightLocation, left, right);
case Liblkqllang.OpLt.kindName -> BinLtNodeGen.create(
location, leftLocation, rightLocation, left, right);
case Liblkqllang.OpLeq.kindName -> BinLeqNodeGen.create(
location, leftLocation, rightLocation, left, right);
case Liblkqllang.OpGt.kindName -> BinGtNodeGen.create(
location, leftLocation, rightLocation, left, right);
case Liblkqllang.OpGeq.kindName -> BinGeqNodeGen.create(
case OP_MUL -> BinMulNodeGen.create(location, leftLocation, rightLocation, left, right);
case OP_DIV -> BinDivNodeGen.create(location, leftLocation, rightLocation, left, right);
case OP_AND -> new BinAnd(location, left, right);
case OP_OR -> new BinOr(location, left, right);
case OP_EQ -> BinEqNodeGen.create(location, leftLocation, rightLocation, left, right);
case OP_NEQ -> BinNeqNodeGen.create(location, leftLocation, rightLocation, left, right);
case OP_CONCAT -> BinConcatNodeGen.create(
location, leftLocation, rightLocation, left, right);
case OP_LT -> BinLtNodeGen.create(location, leftLocation, rightLocation, left, right);
case OP_LEQ -> BinLeqNodeGen.create(location, leftLocation, rightLocation, left, right);
case OP_GT -> BinGtNodeGen.create(location, leftLocation, rightLocation, left, right);
case OP_GEQ -> BinGeqNodeGen.create(location, leftLocation, rightLocation, left, right);
default -> null;
};
}
Expand Down Expand Up @@ -600,10 +592,10 @@ public LKQLNode visit(Liblkqllang.UnOp unOp) {
new SourceLocation(this.source, unOp.getSourceLocationRange());

// Create the unary operator by switching on the operator type
return switch (unOp.fOp().getKindName()) {
case Liblkqllang.OpNot.kindName -> UnNotNodeGen.create(location, argLocation, arg);
case Liblkqllang.OpPlus.kindName -> UnPlusNodeGen.create(location, argLocation, arg);
case Liblkqllang.OpMinus.kindName -> UnMinusNodeGen.create(location, argLocation, arg);
return switch (unOp.fOp().getKind()) {
case OP_NOT -> UnNotNodeGen.create(location, argLocation, arg);
case OP_PLUS -> UnPlusNodeGen.create(location, argLocation, arg);
case OP_MINUS -> UnMinusNodeGen.create(location, argLocation, arg);
default -> null;
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ public final class NodeKindPattern extends NodePattern {
*/
public NodeKindPattern(SourceLocation location, String kindName) {
super(location);
this.nodeClazz = Libadalang.NODE_CLASS_MAP.get(kindName);
if (this.nodeClazz == null) {
final var description = Libadalang.NODE_DESCRIPTION_MAP.get(kindName);
if (description == null) {
throw LKQLRuntimeException.invalidKindName(this);
}
this.nodeClazz = description.clazz;
}

// ----- Execution methods -----
Expand Down
2 changes: 1 addition & 1 deletion lkql_jit/native/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"--macro:truffle",
"--no-fallback",
"--language:regex",
"--initialize-at-build-time=com.adacore.lkql_jit",
"--initialize-at-build-time=com.adacore.lkql_jit,com.adacore.liblkqllang",
]

# Handle the dev and debug build mode
Expand Down

0 comments on commit 72947ac

Please sign in to comment.