Allow to create tasks with symbol name in addition to numeric ID
This commit is contained in:
parent
4945a86c2e
commit
69e2403c93
1 changed files with 10 additions and 3 deletions
|
@ -378,12 +378,19 @@ Result<StackFrame> stdlib_task(const StackFrame& stack) {
|
|||
if (size == 0) return ERROR(ArgumentCountMismatch);
|
||||
|
||||
Value task_id = TRY(params_array.get(0));
|
||||
if (!task_id.is<Int64>()) return ERROR(TypeMismatch);
|
||||
uint64_t num_task_id = 0;
|
||||
|
||||
if (task_id.is<Int64>()) {
|
||||
num_task_id = (uint64_t)task_id.to<Int64>()->value();
|
||||
} else if (task_id.is<Symbol>()) {
|
||||
num_task_id = (uint64_t)TRY(get_stdlib_task(*task_id.to<Symbol>()));
|
||||
} else {
|
||||
return ERROR(TypeMismatch);
|
||||
}
|
||||
|
||||
Value task_params = TRY(params_array.slice(1, size));
|
||||
|
||||
auto val = Value(TRY(Task::create((uint64_t)task_id.to<Int64>()->value(),
|
||||
*task_params.to<Array>())));
|
||||
auto val = Value(TRY(Task::create(num_task_id, *task_params.to<Array>())));
|
||||
|
||||
auto res = TRY(stack.set(0, val));
|
||||
|
||||
|
|
Loading…
Reference in a new issue