Continuation based Rust
CbR...!?
LLVM base なので割と簡単に実装可能。goto 文たすだけ。
Thread Pool などはこれを使って記述できる
Reification part ( goto 文のmeta計算の指定で、patternを使う(メタ計算を反映する部分))
Reflection part ( stub で、codeGear別のメタ計算を実装する (メタ計算をとってくる部分))
GearsOSの構文はくそなので、Rust で、まともなものにできれば割と良い。
Rust 所有権がむしろ邪魔。https://scrapbox.io/files/65081ea224f5f1001d721b49.svg
なので、あきらめた方が良いと思う
code:pm
package meta;
use strict;
use warnings;
sub replaceMeta {
return (
);
}
#my ($currentCodeGearName, $context, $next) = @_; sub generateRandomMeta {
my ($context, $next) = @_;
return "goto random($context, $next);";
}
sub generateMcMeta {
my ($context, $next) = @_;
return "goto mcMeta($context, $next);";
}
1;
code: stub
__code spawnTasksMCTaskManagerImpl3(struct MCTaskManagerImpl* taskManagerImpl, __code next1(...), struct TaskManager* taskManager) {
if (taskManagerImpl->taskList == NULL) {
struct Queue* tasks = taskManagerImpl->workers0->tasks; // printf("put NULL\n");
goto tasks->put(NULL, shutdownMCTaskManagerImpl1);
}
struct Context* task = (struct Context*)taskManagerImpl->taskList->data;
taskManagerImpl->taskList = taskManagerImpl->taskList->next;
goto taskManager->spawn(task, spawnTasksMCTaskManagerImpl3);
}
__code spawnTasksMCTaskManagerImpl3_stub(struct Context* context) {
MCTaskManagerImpl* taskManagerImpl = (MCTaskManagerImpl*)GearImpl(context, TaskManager, taskManager);
enum Code next1 = Gearef(context, TaskManager)->next1;
TaskManager* taskManager = &Gearef(context, TaskManager)->taskManager->TaskManager;
goto spawnTasksMCTaskManagerImpl3(context, taskManagerImpl, next1, taskManager);
}
code:aho
/// Is the current token the start of an FnHeader / not a valid parse?
///
/// check_pub adds additional pub to the checks in case users place it
/// wrongly, can be used to ensure pub never comes after default.
pub(super) fn check_fn_front_matter(&mut self, check_pub: bool, case: Case) -> bool {
// We use an over-approximation here.
// const const, fn const won't parse, but we're not stepping over other syntax either.
// pub is added in case users got confused with the ordering like async pub fn,
// only if it wasn't preceded by default as default pub is invalid.
let quals: &Symbol = if check_pub { } else {
};
self.check_keyword_case(kw::Fn, case) // Definitely an fn.
// $qual fn or $qual $qual:
|| quals.iter().any(|&kw| self.check_keyword_case(kw, case))
&& self.look_ahead(1, |t| {
ここの kw::Fn を kw::Cg とかにすると codeGear を構文的に定義できる
Ty に戻り値として、__code_type のを入れるのかな