Skip to content

Commit b2518b8

Browse files
committed
fixed edge case on destructor emission
1 parent 7090bec commit b2518b8

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# RLC
22

3+
[rationale, tutorials and documentation](https://rl-language.github.io)
4+
35
**Rulebook** is a language for complex interactive subsystems (reinforcement learning environments, videogames, UIs with graph-like transitions, multistep procedures, ...).
46

57
Rulebook is compiled and statically checked, the key and innovative feature of the language are [Action functions with SPIN properties](https://rl-language.github.io/language_tour.html#action-functions), which help to:

lib/conversions/src/RLCToC.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,21 @@ static void printMethodsOfType(
292292
attrs,
293293
builder,
294294
isDecl);
295+
296+
auto can_type = mlir::FunctionType::get(value.getContext(),
297+
value.getType().cast<mlir::FunctionType>().getInputs(), {mlir::rlc::BoolType::get(value.getContext())});
298+
printMethodOfType(
299+
OS,
300+
type,
301+
can_type,
302+
"can_" + action.getName().str(),
303+
mlir::rlc::mangledName(
304+
"can_" + action.getName().str(),
305+
true,
306+
can_type),
307+
attrs,
308+
builder,
309+
isDecl);
295310
}
296311
}
297312
}
@@ -662,8 +677,6 @@ void rlc::rlcToCHeader(mlir::ModuleOp Module, llvm::raw_ostream& OS)
662677
continue;
663678
if (fun.getUnmangledName() == "main")
664679
continue;
665-
if (fun.isDeclaration())
666-
continue;
667680
std::string cShortName =
668681
((not fun.getFunctionType().getInputs().empty() and
669682
fun.getFunctionType().getInputs().front().isa<mlir::rlc::ClassType>())

lib/dialect/src/EmitImplicitDestructorInvocationsPass.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,10 @@ namespace mlir::rlc
336336
destructorsToCreate.push_back(t);
337337
};
338338

339+
for (auto classDecl : op.getOps <mlir::rlc::ClassDeclaration>()) {
340+
collectToCreate(classDecl.getDeclaredType());
341+
classDecl.getDeclaredType().walk(collectToCreate);
342+
}
339343
op.walk([&](mlir::rlc::TypeAliasOp op) {
340344
auto type = op.getAliased();
341345
collectToCreate(type);

tool/rlc/test/wrappers/c_function.rl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ fun to_invoke() -> Int {true}:
1919
#include <stdbool.h>
2020
#define RLC_GET_FUNCTION_DECLS
2121
#define RLC_GET_TYPE_DECLS
22+
#define RLC_GET_TYPE_DEFS
2223
#include "./header.h"
2324

2425
int main() {

0 commit comments

Comments
 (0)