Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler-lib/src/do_compile/nodes/parsed_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl<'a> CompileNode<'a, (), Vec<CompilationError>> for ParsedModule {
params
.writer
.get_current_block()
.write_opcode(CompilerOpcode::Return);
.write_opcode(CompilerOpcode::ReturnUnit);

let co = match params
.writer
Expand Down
2 changes: 1 addition & 1 deletion vm-lib/src/runtime_value/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ impl Function {
}
Ok(CallResult::Ok(ret))
}
_ => Ok(CallResult::OkNoValue),
_ => panic!("functions must return a value"),
},
RunloopExit::Exception(e) => Ok(CallResult::Exception(e)),
}
Expand Down
9 changes: 1 addition & 8 deletions vm-lib/src/runtime_value/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ impl RuntimeValue {
cur_frame.stack.push(other_val.clone());
match rel_op_obj.eval(1, cur_frame, vm, true) {
Ok(cr) => match cr {
CallResult::OkNoValue => OperatorEvalAttemptOutcome::NeedTryROperator,
CallResult::Ok(rv) => {
if let Some(bl) = rv.as_boolean() {
OperatorEvalAttemptOutcome::Ok(bl.raw_value())
Expand Down Expand Up @@ -162,7 +161,6 @@ impl RuntimeValue {
cur_frame.stack.push(other_val.clone());
match op_equals.eval(1, cur_frame, vm, true) {
Ok(cr) => match cr {
CallResult::OkNoValue => OperatorEvalAttemptOutcome::NeedTryROperator,
CallResult::Ok(rv) => OperatorEvalAttemptOutcome::Ok(rv),
CallResult::Exception(e) => {
if e.is_builtin_unimplemented(vm) {
Expand All @@ -183,7 +181,6 @@ impl RuntimeValue {
) -> OperatorEvalAttemptOutcome<RuntimeValue> {
match op.eval(0, cur_frame, vm, true) {
Ok(cr) => match cr {
CallResult::OkNoValue => OperatorEvalAttemptOutcome::NeedTryROperator,
CallResult::Ok(rv) => OperatorEvalAttemptOutcome::Ok(rv),
CallResult::Exception(e) => {
if e.is_builtin_unimplemented(vm) {
Expand Down Expand Up @@ -457,11 +454,7 @@ macro_rules! val_or_bound_func {
};
}

pub enum CallResult<T = RuntimeValue> {
OkNoValue,
Ok(T),
Exception(crate::error::exception::VmException),
}
pub type CallResult = crate::vm::RunloopExit<RuntimeValue>;

impl RuntimeValue {
pub fn bind(&self, f: Function) -> RuntimeValue {
Expand Down
12 changes: 4 additions & 8 deletions vm-lib/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,7 @@ impl VirtualMachine {
};

match main_f.eval(main_argc, &mut main_frame, self, &Default::default(), true)? {
crate::runtime_value::CallResult::OkNoValue
| crate::runtime_value::CallResult::Ok(_) => Ok(RunloopExit::Ok(())),
crate::runtime_value::CallResult::Ok(_) => Ok(RunloopExit::Ok(())),
crate::runtime_value::CallResult::Exception(e) => Ok(RunloopExit::Exception(e)),
}
}
Expand Down Expand Up @@ -975,8 +974,7 @@ impl VirtualMachine {
}
let cnt = pop_or_err!(next, frame, op_idx);
match cnt.read_index(&indices, frame, self) {
Ok(crate::runtime_value::CallResult::OkNoValue)
| Ok(crate::runtime_value::CallResult::Ok(_)) => {}
Ok(crate::runtime_value::CallResult::Ok(_)) => {}
Ok(crate::runtime_value::CallResult::Exception(e)) => {
return Ok(OpcodeRunExit::Exception(e));
}
Expand All @@ -998,8 +996,7 @@ impl VirtualMachine {
}
let cnt = pop_or_err!(next, frame, op_idx);
match cnt.write_index(&indices, &val, frame, self) {
Ok(crate::runtime_value::CallResult::OkNoValue)
| Ok(crate::runtime_value::CallResult::Ok(_)) => {}
Ok(crate::runtime_value::CallResult::Ok(_)) => {}
Ok(crate::runtime_value::CallResult::Exception(e)) => {
return Ok(OpcodeRunExit::Exception(e));
}
Expand Down Expand Up @@ -1182,8 +1179,7 @@ impl VirtualMachine {
Opcode::Call(argc) => {
let x = pop_or_err!(next, frame, op_idx);
match x.eval(argc, frame, self, false) {
Ok(crate::runtime_value::CallResult::OkNoValue)
| Ok(crate::runtime_value::CallResult::Ok(_)) => {}
Ok(crate::runtime_value::CallResult::Ok(_)) => {}
Ok(crate::runtime_value::CallResult::Exception(e)) => {
return Ok(OpcodeRunExit::Exception(e));
}
Expand Down