Skip to content

Commit 827a35d

Browse files
committed
remove merge artifacts to shrink the difference to main
1 parent 68ce1b7 commit 827a35d

File tree

8 files changed

+15
-1940
lines changed

8 files changed

+15
-1940
lines changed

crates/c/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ impl C {
556556
fn push_type_name(&mut self, ty: &Type, dst: &mut String) {
557557
match ty {
558558
Type::Bool => dst.push_str("bool"),
559-
Type::Char => dst.push_str("uint32_t"),
559+
Type::Char => dst.push_str("uint32_t"), // TODO: better type?
560560
Type::U8 => dst.push_str("uint8_t"),
561561
Type::S8 => dst.push_str("int8_t"),
562562
Type::U16 => dst.push_str("uint16_t"),

crates/core/Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,3 @@ doctest = false
1818
wit-parser = { workspace = true }
1919
anyhow = { workspace = true }
2020
heck = { workspace = true }
21-
22-
[features]
23-
default = ["async"]
24-
async = []

crates/core/src/abi.rs

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,7 @@ fn needs_post_return(resolve: &Resolve, ty: &Type) -> bool {
839839
TypeDefKind::Future(_) | TypeDefKind::Stream(_) => false,
840840
TypeDefKind::Unknown => unreachable!(),
841841
},
842+
842843
Type::Bool
843844
| Type::U8
844845
| Type::S8
@@ -894,7 +895,6 @@ impl<'a, B: Bindgen> Generator<'a, B> {
894895

895896
fn call_with_signature(&mut self, func: &Function, sig: WasmSignature) {
896897
const MAX_FLAT_PARAMS: usize = 16;
897-
// const MAX_FLAT_RESULTS: usize = 1;
898898

899899
let language_to_abi = matches!(self.lift_lower, LiftLower::LowerArgsLiftResults)
900900
|| (matches!(self.lift_lower, LiftLower::Symmetric)
@@ -994,11 +994,15 @@ impl<'a, B: Bindgen> Generator<'a, B> {
994994
sig: &sig,
995995
module_prefix: Default::default(),
996996
});
997-
};
997+
}
998998

999999
if matches!(self.lift_lower, LiftLower::Symmetric) && sig.retptr {
10001000
if let Some(ptr) = retptr_oprnd {
1001-
self.read_results_from_memory(&func.result, ptr.clone(), Default::default());
1001+
self.read_results_from_memory(
1002+
&func.result,
1003+
ptr.clone(),
1004+
Default::default(),
1005+
);
10021006
}
10031007
} else if !(sig.retptr || self.async_) {
10041008
// With no return pointer in use we can simply lift the
@@ -1041,24 +1045,10 @@ impl<'a, B: Bindgen> Generator<'a, B> {
10411045
});
10421046
}
10431047

1044-
// if let Some(results) = async_results {
1045-
// let name = &format!("[task-return]{}", func.name);
1046-
1047-
// self.emit(&Instruction::AsyncCallReturn {
1048-
// name,
1049-
// params: &if results.len() > MAX_FLAT_PARAMS {
1050-
// vec![WasmType::Pointer]
1051-
// } else {
1052-
// results
1053-
// },
1054-
// });
1055-
// self.emit(&Instruction::Return { func, amt: 1 });
1056-
// } else {
10571048
self.emit(&Instruction::Return {
10581049
func,
10591050
amt: usize::from(func.result.is_some()),
10601051
});
1061-
// }
10621052
}
10631053
false => {
10641054
if let (AbiVariant::GuestImport, true) = (self.variant, self.async_) {
@@ -1074,6 +1064,7 @@ impl<'a, B: Bindgen> Generator<'a, B> {
10741064
offset += self_.bindgen.sizes().size(ty);
10751065
}
10761066
};
1067+
10771068
if !sig.indirect_params {
10781069
// If parameters are not passed indirectly then we lift each
10791070
// argument in succession from the component wasm types that
@@ -1484,6 +1475,8 @@ impl<'a, B: Bindgen> Generator<'a, B> {
14841475
use Instruction::*;
14851476

14861477
match *ty {
1478+
// Builtin types need different flavors of storage instructions
1479+
// depending on the size of the value written.
14871480
Type::Bool => self.emit(&BoolFromI32),
14881481
Type::S8 => self.emit(&S8FromI32),
14891482
Type::U8 => self.emit(&U8FromI32),
@@ -2062,7 +2055,8 @@ impl<'a, B: Bindgen> Generator<'a, B> {
20622055
| Type::U64
20632056
| Type::S64
20642057
| Type::F32
2065-
| Type::F64 => {}
2058+
| Type::F64
2059+
| Type::ErrorContext => {}
20662060
Type::Id(id) => match &self.resolve.types[id].kind {
20672061
TypeDefKind::Type(t) => self.deallocate(t, addr, offset),
20682062

@@ -2133,7 +2127,6 @@ impl<'a, B: Bindgen> Generator<'a, B> {
21332127
TypeDefKind::Stream(_) => todo!("read stream from memory"),
21342128
TypeDefKind::Unknown => unreachable!(),
21352129
},
2136-
Type::ErrorContext => todo!(),
21372130
}
21382131
}
21392132

crates/core/src/lib.rs

Lines changed: 0 additions & 231 deletions
Original file line numberDiff line numberDiff line change
@@ -21,239 +21,8 @@ pub enum Direction {
2121
Export,
2222
}
2323

24-
// #[derive(Default)]
25-
// pub struct Types {
26-
// type_info: HashMap<TypeId, TypeInfo>,
27-
// }
28-
29-
// #[derive(Default, Clone, Copy, Debug)]
30-
// pub struct TypeInfo {
31-
// /// Whether or not this type is ever used (transitively) within the
32-
// /// parameter of an imported function.
33-
// ///
34-
// /// This means that it's used in a context where ownership isn't
35-
// /// relinquished.
36-
// pub borrowed: bool,
37-
38-
// /// Whether or not this type is ever used (transitively) within the
39-
// /// parameter or result of an export, or the result of an import.
40-
// ///
41-
// /// This means that it's used in a context where ownership is required and
42-
// /// memory management is necessary.
43-
// pub owned: bool,
44-
45-
// /// Whether or not this type is ever used (transitively) within the
46-
// /// error case in the result of a function.
47-
// pub error: bool,
48-
49-
// /// Whether or not this type (transitively) has a list (or string).
50-
// pub has_list: bool,
51-
52-
// /// Whether or not this type (transitively) has a resource (or handle).
53-
// pub has_resource: bool,
54-
55-
// /// Whether or not this type (transitively) has a borrow handle.
56-
// pub has_borrow_handle: bool,
57-
58-
// /// Whether or not this type (transitively) has an own handle.
59-
// pub has_own_handle: bool,
60-
// }
61-
62-
// impl std::ops::BitOrAssign for TypeInfo {
63-
// fn bitor_assign(&mut self, rhs: Self) {
64-
// self.borrowed |= rhs.borrowed;
65-
// self.owned |= rhs.owned;
66-
// self.error |= rhs.error;
67-
// self.has_list |= rhs.has_list;
68-
// self.has_resource |= rhs.has_resource;
69-
// self.has_borrow_handle |= rhs.has_borrow_handle;
70-
// self.has_own_handle |= rhs.has_own_handle;
71-
// }
72-
// }
73-
74-
// impl TypeInfo {
75-
// pub fn is_clone(&self) -> bool {
76-
// !self.has_resource
77-
// }
78-
// pub fn is_copy(&self) -> bool {
79-
// !self.has_list && !self.has_resource
80-
// }
81-
// }
82-
83-
// impl Types {
84-
// pub fn analyze(&mut self, resolve: &Resolve) {
85-
// for (t, _) in resolve.types.iter() {
86-
// self.type_id_info(resolve, t);
87-
// }
88-
// for (_, world) in resolve.worlds.iter() {
89-
// for (import, (_, item)) in world
90-
// .imports
91-
// .iter()
92-
// .map(|i| (true, i))
93-
// .chain(world.exports.iter().map(|i| (false, i)))
94-
// {
95-
// match item {
96-
// WorldItem::Function(f) => {
97-
// self.type_info_func(resolve, f, import);
98-
// }
99-
// WorldItem::Interface(id) => {
100-
// for (_, f) in resolve.interfaces[*id].functions.iter() {
101-
// self.type_info_func(resolve, f, import);
102-
// }
103-
// }
104-
// WorldItem::Type(_) => {}
105-
// }
106-
// }
107-
// }
108-
// }
109-
110-
// fn type_info_func(&mut self, resolve: &Resolve, func: &Function, import: bool) {
111-
// let mut live = LiveTypes::default();
112-
// for (_, ty) in func.params.iter() {
113-
// self.type_info(resolve, ty);
114-
// live.add_type(resolve, ty);
115-
// }
116-
// for id in live.iter() {
117-
// if resolve.types[id].name.is_some() {
118-
// let info = self.type_info.get_mut(&id).unwrap();
119-
// if import {
120-
// info.borrowed = true;
121-
// } else {
122-
// info.owned = true;
123-
// }
124-
// }
125-
// }
126-
// let mut live = LiveTypes::default();
127-
// for ty in func.results.iter_types() {
128-
// self.type_info(resolve, ty);
129-
// live.add_type(resolve, ty);
130-
// }
131-
// for id in live.iter() {
132-
// if resolve.types[id].name.is_some() {
133-
// self.type_info.get_mut(&id).unwrap().owned = true;
134-
// }
135-
// }
136-
137-
// for ty in func.results.iter_types() {
138-
// let id = match ty {
139-
// Type::Id(id) => *id,
140-
// _ => continue,
141-
// };
142-
// let err = match &resolve.types[id].kind {
143-
// TypeDefKind::Result(Result_ { err, .. }) => err,
144-
// _ => continue,
145-
// };
146-
// if let Some(Type::Id(id)) = err {
147-
// // When an interface `use`s a type from another interface, it creates a new typeid
148-
// // referring to the definition typeid. Chase any chain of references down to the
149-
// // typeid of the definition.
150-
// fn resolve_type_definition_id(resolve: &Resolve, mut id: TypeId) -> TypeId {
151-
// loop {
152-
// match resolve.types[id].kind {
153-
// TypeDefKind::Type(Type::Id(def_id)) => id = def_id,
154-
// _ => return id,
155-
// }
156-
// }
157-
// }
158-
// let id = resolve_type_definition_id(resolve, *id);
159-
// self.type_info.get_mut(&id).unwrap().error = true;
160-
// }
161-
// }
162-
// }
163-
164-
// pub fn get(&self, id: TypeId) -> TypeInfo {
165-
// self.type_info[&id]
166-
// }
167-
168-
// pub fn type_id_info(&mut self, resolve: &Resolve, ty: TypeId) -> TypeInfo {
169-
// if let Some(info) = self.type_info.get(&ty) {
170-
// return *info;
171-
// }
172-
// let mut info = TypeInfo::default();
173-
// match &resolve.types[ty].kind {
174-
// TypeDefKind::Record(r) => {
175-
// for field in r.fields.iter() {
176-
// info |= self.type_info(resolve, &field.ty);
177-
// }
178-
// }
179-
// TypeDefKind::Resource => {
180-
// info.has_resource = true;
181-
// }
182-
// TypeDefKind::Handle(handle) => {
183-
// match handle {
184-
// Handle::Borrow(_) => info.has_borrow_handle = true,
185-
// Handle::Own(_) => info.has_own_handle = true,
186-
// }
187-
// info.has_resource = true;
188-
// }
189-
// TypeDefKind::Tuple(t) => {
190-
// for ty in t.types.iter() {
191-
// info |= self.type_info(resolve, ty);
192-
// }
193-
// }
194-
// TypeDefKind::Flags(_) => {}
195-
// TypeDefKind::Enum(_) => {}
196-
// TypeDefKind::Variant(v) => {
197-
// for case in v.cases.iter() {
198-
// info |= self.optional_type_info(resolve, case.ty.as_ref());
199-
// }
200-
// }
201-
// TypeDefKind::List(ty) => {
202-
// info = self.type_info(resolve, ty);
203-
// info.has_list = true;
204-
// }
205-
// TypeDefKind::Type(ty) => {
206-
// info = self.type_info(resolve, ty);
207-
// }
208-
// TypeDefKind::Option(ty) => {
209-
// info = self.type_info(resolve, ty);
210-
// }
211-
// TypeDefKind::Result(r) => {
212-
// info = self.optional_type_info(resolve, r.ok.as_ref());
213-
// info |= self.optional_type_info(resolve, r.err.as_ref());
214-
// }
215-
// TypeDefKind::Future(_) | TypeDefKind::Stream(_) | TypeDefKind::Error => {}
216-
// TypeDefKind::Unknown => unreachable!(),
217-
// }
218-
// let prev = self.type_info.insert(ty, info);
219-
// assert!(prev.is_none());
220-
// info
221-
// }
222-
223-
// pub fn type_info(&mut self, resolve: &Resolve, ty: &Type) -> TypeInfo {
224-
// let mut info = TypeInfo::default();
225-
// match ty {
226-
// Type::String => info.has_list = true,
227-
// Type::Id(id) => return self.type_id_info(resolve, *id),
228-
// _ => {}
229-
// }
230-
// info
231-
// }
232-
233-
// fn optional_type_info(&mut self, resolve: &Resolve, ty: Option<&Type>) -> TypeInfo {
234-
// match ty {
235-
// Some(ty) => self.type_info(resolve, ty),
236-
// None => TypeInfo::default(),
237-
// }
238-
// }
239-
// }
240-
24124
pub trait WorldGenerator {
24225
fn generate(&mut self, resolve: &Resolve, id: WorldId, files: &mut Files) -> Result<()> {
243-
// TODO: Should we refine this test to inspect only types reachable from
244-
// the specified world?
245-
if !cfg!(feature = "async")
246-
&& resolve
247-
.types
248-
.iter()
249-
.any(|(_, ty)| matches!(ty.kind, TypeDefKind::Future(_) | TypeDefKind::Stream(_)))
250-
{
251-
anyhow::bail!(
252-
"must enable `async` feature when using WIT files \
253-
containing future, stream, or error types"
254-
);
255-
}
256-
25726
let world = &resolve.worlds[id];
25827
self.preprocess(resolve, id);
25928

crates/guest-rust/rt/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![cfg_attr(not(feature = "async"), no_std)]
1+
#![no_std]
22

33
extern crate alloc;
44

0 commit comments

Comments
 (0)