-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'topic/builtin_specializations' into 'master'
Rewrite LKQL built-ins as specialized nodes Closes #130 See merge request eng/libadalang/langkit-query-language!300
- Loading branch information
Showing
22 changed files
with
734 additions
and
614 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
50 changes: 50 additions & 0 deletions
50
lkql_jit/language/src/main/java/com/adacore/lkql_jit/built_ins/SpecializedBuiltInBody.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,50 @@ | ||
// | ||
// Copyright (C) 2005-2024, AdaCore | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
// | ||
|
||
package com.adacore.lkql_jit.built_ins; | ||
|
||
import com.adacore.lkql_jit.LKQLTypeSystem; | ||
import com.oracle.truffle.api.dsl.TypeSystemReference; | ||
import com.oracle.truffle.api.frame.VirtualFrame; | ||
import com.oracle.truffle.api.nodes.Node; | ||
|
||
public abstract class SpecializedBuiltInBody< | ||
T extends SpecializedBuiltInBody.SpecializedBuiltInNode> | ||
extends AbstractBuiltInFunctionBody { | ||
|
||
// ----- Attributes ----- | ||
|
||
/** This node represents the execution of the built-in function. */ | ||
@Child protected T specializedNode; | ||
|
||
// ----- Constructors ----- | ||
|
||
/** Create a new specialized body with its corresponding execution node. */ | ||
public SpecializedBuiltInBody(T specializedNode) { | ||
this.specializedNode = specializedNode; | ||
this.specializedNode.body = this; | ||
} | ||
|
||
// ----- Instance methods ----- | ||
|
||
/** Dispatch the function arguments to the specialized execution node. */ | ||
protected abstract Object dispatch(Object[] args); | ||
|
||
@Override | ||
public Object executeGeneric(VirtualFrame frame) { | ||
return this.dispatch(frame.getArguments()); | ||
} | ||
|
||
// ----- Inner classes ----- | ||
|
||
/** This class represents an execution node, payload of a built-in body. */ | ||
@TypeSystemReference(LKQLTypeSystem.class) | ||
public abstract static class SpecializedBuiltInNode extends Node { | ||
// ----- Attributes ----- | ||
|
||
/** The built-in body that owns this specialized node. */ | ||
protected SpecializedBuiltInBody body; | ||
} | ||
} |
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
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
Oops, something went wrong.