add associated Payload type to ArenaAllocated
This commit is contained in:
@@ -1757,7 +1757,7 @@ impl Machine {
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn push_load_state_payload(&mut self) {
|
||||
let payload = arena_alloc!(
|
||||
let payload: TypedArenaPtr<LiveLoadState> = arena_alloc!(
|
||||
LoadStatePayload::new(self.code.len(), LiveTermStream::new(ListingSource::User),),
|
||||
&mut self.machine_st.arena
|
||||
);
|
||||
|
||||
@@ -451,7 +451,9 @@ impl<T> DerefMut for StreamLayout<T> {
|
||||
|
||||
macro_rules! arena_allocated_impl_for_stream {
|
||||
($stream_type:ty, $stream_tag:ident) => {
|
||||
impl ArenaAllocated for StreamLayout<$stream_type> {
|
||||
impl ArenaAllocated for $stream_tag {
|
||||
type Payload = StreamLayout<$stream_type>;
|
||||
|
||||
#[inline]
|
||||
fn tag() -> ArenaHeaderTag {
|
||||
ArenaHeaderTag::$stream_tag
|
||||
@@ -477,26 +479,26 @@ arena_allocated_impl_for_stream!(StandardErrorStream, StandardErrorStream);
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub enum Stream {
|
||||
Byte(TypedArenaPtr<StreamLayout<CharReader<ByteStream>>>),
|
||||
InputFile(TypedArenaPtr<StreamLayout<CharReader<InputFileStream>>>),
|
||||
OutputFile(TypedArenaPtr<StreamLayout<OutputFileStream>>),
|
||||
StaticString(TypedArenaPtr<StreamLayout<StaticStringStream>>),
|
||||
NamedTcp(TypedArenaPtr<StreamLayout<CharReader<NamedTcpStream>>>),
|
||||
Byte(TypedArenaPtr<ByteStream>),
|
||||
InputFile(TypedArenaPtr<InputFileStream>),
|
||||
OutputFile(TypedArenaPtr<OutputFileStream>),
|
||||
StaticString(TypedArenaPtr<StaticStringStream>),
|
||||
NamedTcp(TypedArenaPtr<NamedTcpStream>),
|
||||
#[cfg(feature = "tls")]
|
||||
NamedTls(TypedArenaPtr<StreamLayout<CharReader<NamedTlsStream>>>),
|
||||
NamedTls(TypedArenaPtr<NamedTlsStream>),
|
||||
#[cfg(feature = "http")]
|
||||
HttpRead(TypedArenaPtr<StreamLayout<CharReader<HttpReadStream>>>),
|
||||
HttpRead(TypedArenaPtr<HttpReadStream>),
|
||||
#[cfg(feature = "http")]
|
||||
HttpWrite(TypedArenaPtr<StreamLayout<CharReader<HttpWriteStream>>>),
|
||||
HttpWrite(TypedArenaPtr<HttpWriteStream>),
|
||||
Null(StreamOptions),
|
||||
Readline(TypedArenaPtr<StreamLayout<ReadlineStream>>),
|
||||
StandardOutput(TypedArenaPtr<StreamLayout<StandardOutputStream>>),
|
||||
StandardError(TypedArenaPtr<StreamLayout<StandardErrorStream>>),
|
||||
Readline(TypedArenaPtr<ReadlineStream>),
|
||||
StandardOutput(TypedArenaPtr<StandardOutputStream>),
|
||||
StandardError(TypedArenaPtr<StandardErrorStream>),
|
||||
}
|
||||
|
||||
impl From<TypedArenaPtr<StreamLayout<ReadlineStream>>> for Stream {
|
||||
impl From<TypedArenaPtr<ReadlineStream>> for Stream {
|
||||
#[inline]
|
||||
fn from(stream: TypedArenaPtr<StreamLayout<ReadlineStream>>) -> Stream {
|
||||
fn from(stream: TypedArenaPtr<ReadlineStream>) -> Stream {
|
||||
Stream::Readline(stream)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4519,7 +4519,8 @@ impl Machine {
|
||||
});
|
||||
|
||||
let http_listener = HttpListener { incoming: rx };
|
||||
let http_listener = arena_alloc!(http_listener, &mut self.machine_st.arena);
|
||||
let http_listener: TypedArenaPtr<HttpListener> =
|
||||
arena_alloc!(http_listener, &mut self.machine_st.arena);
|
||||
|
||||
let addr = self.deref_register(2);
|
||||
self.machine_st.bind(
|
||||
@@ -4584,7 +4585,7 @@ impl Machine {
|
||||
self.indices.streams.insert(stream);
|
||||
let stream = stream_as_cell!(stream);
|
||||
|
||||
let handle = arena_alloc!(request.response, &mut self.machine_st.arena);
|
||||
let handle: TypedArenaPtr<HttpResponse> = arena_alloc!(request.response, &mut self.machine_st.arena);
|
||||
|
||||
self.machine_st.bind(method.as_var().unwrap(), atom_as_cell!(method_atom));
|
||||
self.machine_st.bind(path.as_var().unwrap(), path_cell);
|
||||
@@ -6516,32 +6517,33 @@ impl Machine {
|
||||
format!("{}:{}", socket_atom.as_str(), port)
|
||||
};
|
||||
|
||||
let (tcp_listener, port) = match TcpListener::bind(server_addr).map_err(|e| e.kind()) {
|
||||
Ok(tcp_listener) => {
|
||||
let port = tcp_listener.local_addr().map(|addr| addr.port()).ok();
|
||||
let (tcp_listener, port): (TypedArenaPtr<TcpListener>, _) =
|
||||
match TcpListener::bind(server_addr).map_err(|e| e.kind()) {
|
||||
Ok(tcp_listener) => {
|
||||
let port = tcp_listener.local_addr().map(|addr| addr.port()).ok();
|
||||
|
||||
if let Some(port) = port {
|
||||
(
|
||||
arena_alloc!(tcp_listener, &mut self.machine_st.arena),
|
||||
port as usize,
|
||||
)
|
||||
} else {
|
||||
if let Some(port) = port {
|
||||
(
|
||||
arena_alloc!(tcp_listener, &mut self.machine_st.arena),
|
||||
port as usize,
|
||||
)
|
||||
} else {
|
||||
self.machine_st.fail = true;
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
Err(ErrorKind::PermissionDenied) => {
|
||||
return Err(self.machine_st.open_permission_error(
|
||||
addr,
|
||||
atom!("socket_server_open"),
|
||||
2,
|
||||
));
|
||||
}
|
||||
_ => {
|
||||
self.machine_st.fail = true;
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
Err(ErrorKind::PermissionDenied) => {
|
||||
return Err(self.machine_st.open_permission_error(
|
||||
addr,
|
||||
atom!("socket_server_open"),
|
||||
2,
|
||||
));
|
||||
}
|
||||
_ => {
|
||||
self.machine_st.fail = true;
|
||||
return Ok(());
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
let addr = self.deref_register(3);
|
||||
self.machine_st.bind(
|
||||
|
||||
Reference in New Issue
Block a user