Skip to content

Commit 333bf78

Browse files
committed
refactor: Rename Pushable::push to vm_push
1 parent 29b9653 commit 333bf78

File tree

16 files changed

+121
-119
lines changed

16 files changed

+121
-119
lines changed

c-api/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ pub unsafe extern "C" fn glu_push_string(vm: &Thread, s: &u8, len: usize) -> Err
155155
Ok(s) => s,
156156
Err(_) => return Error::Unknown,
157157
};
158-
match s.push(&mut vm.current_context()) {
158+
match s.vm_push(&mut vm.current_context()) {
159159
Ok(()) => Error::Ok,
160160
Err(_) => Error::Unknown,
161161
}
@@ -166,7 +166,7 @@ pub unsafe extern "C" fn glu_push_string(vm: &Thread, s: &u8, len: usize) -> Err
166166
#[no_mangle]
167167
pub unsafe extern "C" fn glu_push_string_unchecked(vm: &Thread, s: &u8, len: usize) -> Error {
168168
let s = str::from_utf8_unchecked(slice::from_raw_parts(s, len));
169-
match s.push(&mut vm.current_context()) {
169+
match s.vm_push(&mut vm.current_context()) {
170170
Ok(()) => Error::Ok,
171171
Err(_) => Error::Unknown,
172172
}

codegen/src/pushable.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn derive_struct(
4747
Fields::Unnamed(_) if field_idents.len() == 1 => {
4848
let ty = &field_types[0];
4949
let push_impl = quote! {
50-
<#ty as _gluon_api::Pushable<'__vm>>::push(self.0, ctx)?;
50+
<#ty as _gluon_api::Pushable<'__vm>>::vm_push(self.0, ctx)?;
5151
};
5252
return gen_impl(&container, &ident, generics, push_impl);
5353
}
@@ -163,7 +163,7 @@ fn gen_impl(
163163
impl #impl_generics _gluon_api::Pushable<'__vm> for #ident #ty_generics
164164
#where_clause #(#pushable_bounds),*
165165
{
166-
fn push(self, ctx: &mut _gluon_thread::ActiveThread<'__vm>) -> _GluonResult<()> {
166+
fn vm_push(self, ctx: &mut _gluon_thread::ActiveThread<'__vm>) -> _GluonResult<()> {
167167
#push_impl
168168
Ok(())
169169
}
@@ -182,7 +182,7 @@ fn gen_push_impl(
182182
// push each field onto the stack
183183
let stack_pushes = field_idents.iter().zip(field_types).map(|(ident, ty)| {
184184
quote! {
185-
<#ty as _gluon_api::Pushable<'__vm>>::push(#ident, ctx)?;
185+
<#ty as _gluon_api::Pushable<'__vm>>::vm_push(#ident, ctx)?;
186186
}
187187
});
188188

examples/marshalling.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ impl api::VmType for Enum {
4343
}
4444

4545
impl<'vm, 'value> api::Pushable<'vm> for Enum {
46-
fn push(self, context: &mut ActiveThread<'vm>) -> vm::Result<()> {
47-
api::ser::Ser(self).push(context)
46+
fn vm_push(self, context: &mut ActiveThread<'vm>) -> vm::Result<()> {
47+
api::ser::Ser(self).vm_push(context)
4848
}
4949
}
5050

@@ -240,7 +240,7 @@ where
240240

241241
// apply all generic parameters to the type
242242
let mut vec = AppVec::new();
243-
AppVec::push(&mut vec, T::make_type(thread));
243+
vec.push(T::make_type(thread));
244244
Type::app(ty, vec)
245245
}
246246
}
@@ -249,13 +249,13 @@ impl<'vm, T> Pushable<'vm> for GluonUser<T>
249249
where
250250
T: Pushable<'vm>,
251251
{
252-
fn push(self, ctx: &mut ActiveThread<'vm>) -> vm::Result<()> {
252+
fn vm_push(self, ctx: &mut ActiveThread<'vm>) -> vm::Result<()> {
253253
(record! {
254254
name => self.inner.name,
255255
age => self.inner.age,
256256
data => self.inner.data,
257257
})
258-
.push(ctx)
258+
.vm_push(ctx)
259259
}
260260
}
261261

repl/src/repl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,8 @@ macro_rules! define_vmtype {
302302
define_vmtype! { ReadlineError }
303303

304304
impl<'vm> Pushable<'vm> for ReadlineError {
305-
fn push(self, context: &mut ActiveThread<'vm>) -> VMResult<()> {
306-
gluon::vm::api::ser::Ser(self).push(context)
305+
fn vm_push(self, context: &mut ActiveThread<'vm>) -> VMResult<()> {
306+
gluon::vm::api::ser::Ser(self).vm_push(context)
307307
}
308308
}
309309

src/std_lib/http.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ impl VmType for Headers {
7272
}
7373

7474
impl<'vm> Pushable<'vm> for Headers {
75-
fn push(self, context: &mut ActiveThread<'vm>) -> vm::Result<()> {
75+
fn vm_push(self, context: &mut ActiveThread<'vm>) -> vm::Result<()> {
7676
Collect::new(
7777
self.0
7878
.iter()
7979
.map(|(name, value)| (name.as_str(), value.as_bytes())),
8080
)
81-
.push(context)
81+
.vm_push(context)
8282
}
8383
}
8484

vm/src/api/function.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl<'vm, F> Pushable<'vm> for Primitive<F>
7777
where
7878
F: FunctionType + VmType,
7979
{
80-
fn push(self, context: &mut ActiveThread<'vm>) -> Result<()> {
80+
fn vm_push(self, context: &mut ActiveThread<'vm>) -> Result<()> {
8181
// Map rust modules into gluon modules
8282
let name = if let Some(i) = self.name.rfind("::<") {
8383
&self.name[..i]
@@ -111,7 +111,7 @@ impl CPrimitive {
111111
}
112112

113113
impl<'vm> Pushable<'vm> for CPrimitive {
114-
fn push(self, context: &mut ActiveThread<'vm>) -> Result<()> {
114+
fn vm_push(self, context: &mut ActiveThread<'vm>) -> Result<()> {
115115
context.context().push_new_alloc(Move(ExternFunction {
116116
id: self.id,
117117
args: self.args,
@@ -196,7 +196,7 @@ where
196196
T: VmRootInternal,
197197
F: VmType,
198198
{
199-
fn push(self, context: &mut ActiveThread<'vm>) -> Result<()> {
199+
fn vm_push(self, context: &mut ActiveThread<'vm>) -> Result<()> {
200200
context.push(self.value.get_variant());
201201
Ok(())
202202
}
@@ -292,7 +292,7 @@ where $($args: Getable<'vm, 'vm> + 'vm,)*
292292
Ok(x) => x,
293293
Err(err) => {
294294
drop(stack);
295-
err.to_string().push(&mut context).unwrap();
295+
err.to_string().vm_push(&mut context).unwrap();
296296
return Status::Error;
297297
}
298298
};
@@ -398,10 +398,10 @@ impl<T, $($args,)* R> Function<T, fn($($args),*) -> R>
398398
let mut context = vm.current_context();
399399
context.push(self.value.get_variant());
400400
$(
401-
$args.push(&mut context)?;
401+
$args.vm_push(&mut context)?;
402402
)*
403403
for _ in 0..R::EXTRA_ARGS {
404-
0.push(&mut context).unwrap();
404+
0.vm_push(&mut context).unwrap();
405405
}
406406
let args = count!($($args),*) + R::EXTRA_ARGS;
407407
let context = ready!(vm.call_function(cx, context.into_owned(), args))?;
@@ -510,10 +510,10 @@ where
510510
let mut arg_count = R::EXTRA_ARGS;
511511
for arg in args {
512512
arg_count += 1;
513-
arg.push(&mut context)?;
513+
arg.vm_push(&mut context)?;
514514
}
515515
for _ in 0..R::EXTRA_ARGS {
516-
0.push(&mut context).unwrap();
516+
0.vm_push(&mut context).unwrap();
517517
}
518518
let context = ready!(vm.call_function(cx, context.into_owned(), arg_count))?;
519519
let mut context = context.unwrap();
@@ -562,7 +562,7 @@ impl<T: VmType> VmType for TypedBytecode<T> {
562562
}
563563

564564
impl<'vm, T: VmType> Pushable<'vm> for TypedBytecode<T> {
565-
fn push(self, context: &mut ActiveThread<'vm>) -> Result<()> {
565+
fn vm_push(self, context: &mut ActiveThread<'vm>) -> Result<()> {
566566
let closure = {
567567
let thread = context.thread();
568568
let mut compiled_module = CompiledModule::from(CompiledFunction::new(
@@ -576,6 +576,6 @@ impl<'vm, T: VmType> Pushable<'vm> for TypedBytecode<T> {
576576
.global_env()
577577
.new_global_thunk(thread, compiled_module)?
578578
};
579-
closure.push(context)
579+
closure.vm_push(context)
580580
}
581581
}

vm/src/api/json.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,37 +68,37 @@ impl VmType for serde_json::Value {
6868
}
6969

7070
impl<'vm> crate::api::Pushable<'vm> for serde_json::Value {
71-
fn push(self, context: &mut ActiveThread<'vm>) -> Result<()> {
71+
fn vm_push(self, context: &mut ActiveThread<'vm>) -> Result<()> {
7272
use serde_json::Value::*;
7373
let tag = match self {
7474
Null => {
7575
context.context().push_new_data(0, 0)?;
7676
return Ok(());
7777
}
7878
Bool(b) => {
79-
b.push(context)?;
79+
b.vm_push(context)?;
8080
1
8181
}
8282
Number(n) => {
8383
if let Some(i) = n.as_i64() {
84-
i.push(context)?;
84+
i.vm_push(context)?;
8585
2
8686
} else if let Some(i) = n.as_u64() {
87-
i.push(context)?;
87+
i.vm_push(context)?;
8888
2
8989
} else if let Some(i) = n.as_f64() {
90-
i.push(context)?;
90+
i.vm_push(context)?;
9191
3
9292
} else {
9393
return Err(format!("Unable to marshal serde_json::Number({})", n).into());
9494
}
9595
}
9696
String(s) => {
97-
s.push(context)?;
97+
s.vm_push(context)?;
9898
4
9999
}
100100
Array(a) => {
101-
a.push(context)?;
101+
a.vm_push(context)?;
102102
5
103103
}
104104
Object(o) => {
@@ -223,8 +223,8 @@ impl VmType for Value {
223223
pub struct JsonValue(crate::vm::RootedValue<RootedThread>);
224224

225225
impl<'vm> crate::api::Pushable<'vm> for JsonValue {
226-
fn push(self, context: &mut ActiveThread<'vm>) -> Result<()> {
227-
crate::api::Pushable::push(self.0, context)
226+
fn vm_push(self, context: &mut ActiveThread<'vm>) -> Result<()> {
227+
crate::api::Pushable::vm_push(self.0, context)
228228
}
229229
}
230230

@@ -262,7 +262,9 @@ impl<'de> de::DeserializeState<'de, ActiveThread<'de>> for JsonValue {
262262
T: crate::api::Pushable<'vm>,
263263
{
264264
let context = &mut *self.0;
265-
value.push(context).unwrap_or_else(|err| panic!("{}", err));
265+
value
266+
.vm_push(context)
267+
.unwrap_or_else(|err| panic!("{}", err));
266268
let thread = context.thread();
267269
let value = context.pop();
268270
JsonValue(thread.root_value((*value).clone()))

0 commit comments

Comments
 (0)