Invert event loop
This commit is contained in:
@@ -97,6 +97,36 @@ impl<'a> Emitter<'a> {
|
||||
let value = operand(self, FIRST_ARG as usize, self.rep(&self.cache.protos[kind as usize]));
|
||||
(format!("({} = {value}, (undefined_t){{0}})", proto_global(kind)), Type::Undefined)
|
||||
}
|
||||
|
||||
// Keeps the fn where `jsrt_complete` finds it
|
||||
Code::HostLink => {
|
||||
let value = operand(self, FIRST_ARG as usize, self.rep(&self.cache.host_complete));
|
||||
(format!("({HOST_COMPLETE_GLOBAL} = {value}, (undefined_t){{0}})"), Type::Undefined)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The body of `jsrt_complete(h)`: a call of the fn that the stdlib links
|
||||
/// for the host, with op `h` (see `infer::host_calls()`)
|
||||
pub(super) fn host_complete(&mut self) -> String {
|
||||
let ty = self.cache.host_complete.clone();
|
||||
let mut out = String::new();
|
||||
|
||||
if ty == Type::Unknown {
|
||||
return out;
|
||||
}
|
||||
|
||||
let rep = self.rep(&ty);
|
||||
let operands = [(HOST_COMPLETE_GLOBAL.to_string(), rep), ("(undefined_t){0}".into(), Rep::Undefined), ("h".into(), Rep::Int)];
|
||||
|
||||
self.dispatch(HOST_COMPLETE_GLOBAL, &ty, "jsrt_type_error();", &mut out, |e, member, callee, rep| {
|
||||
let Type::Obj(cell) = member else { return None };
|
||||
let mut operands = operands.clone();
|
||||
operands[0] = (callee.into(), rep);
|
||||
let arg_types = [member.clone(), Type::Undefined, Type::Int];
|
||||
Some(format!("{};", e.call_code(cell.code()?, HOST_COMPLETE, &arg_types, &operands).0))
|
||||
});
|
||||
|
||||
out
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user