Allow disassembling continuations and stack frames as well
This commit is contained in:
parent
a01a4d0574
commit
f4660b6bc1
1 changed files with 16 additions and 2 deletions
|
@ -543,8 +543,22 @@ Result<StackFrame> stdlib_disassemble(const StackFrame& stack) {
|
|||
|
||||
auto val = TRY(params.get(0));
|
||||
|
||||
if (!val.is<Function>()) return ERROR(TypeMismatch);
|
||||
auto disassembled = Value(TRY(val.to<Function>()->disassemble()));
|
||||
Value disassembled;
|
||||
|
||||
if (val.is<Function>()) {
|
||||
disassembled = Value(TRY(val.to<Function>()->disassemble()));
|
||||
} else if (val.is<Continuation>()) {
|
||||
auto frame = TRY(val.to<Continuation>()->frame());
|
||||
auto fun = TRY(frame.fun());
|
||||
if (!fun.is<Function>()) return ERROR(TypeMismatch);
|
||||
disassembled = Value(TRY(fun.to<Function>()->disassemble()));
|
||||
} else if (val.is<StackFrame>()) {
|
||||
auto fun = TRY(val.to<StackFrame>()->fun());
|
||||
if (!fun.is<Function>()) return ERROR(TypeMismatch);
|
||||
disassembled = Value(TRY(fun.to<Function>()->disassemble()));
|
||||
} else {
|
||||
return ERROR(TypeMismatch);
|
||||
}
|
||||
|
||||
auto res = TRY(stack.set(0, disassembled));
|
||||
|
||||
|
|
Loading…
Reference in a new issue