Add Method type for objects
* Methods are wrappers created with an owner and a function, which passes the owner as the first argument when the function is called. * Fix a small bug in the VM where the pc was being set at the wrong time Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -13,12 +13,13 @@ pub static PRINTLN_BUILTIN_FUN: Lazy<NativeFunRef> = Lazy::new(|| NativeFun::new
|
||||
.expect("no __str__ or __repr__ member")
|
||||
};
|
||||
let return_value = vm.call(to_string, vec![]);
|
||||
let str_ref: &StrRef = std::any::Any::downcast_ref(&return_value).expect("to_string to return str value");
|
||||
{
|
||||
read_obj!(let str_obj = str_ref);
|
||||
read_obj!(let str_obj = return_value);
|
||||
let str_obj: &Str = str_obj.as_any().downcast_ref().unwrap();
|
||||
println!("{}", str_obj.value());
|
||||
}
|
||||
|
||||
vm.push(NIL_NAME.sym_ref());
|
||||
Signal::Return
|
||||
}));
|
||||
|
||||
@@ -32,9 +33,9 @@ pub static PRINT_BUILTIN_FUN: Lazy<NativeFunRef> = Lazy::new(|| NativeFun::new_o
|
||||
.expect("no __str__ or __repr__ member")
|
||||
};
|
||||
let return_value = vm.call(to_string, vec![]);
|
||||
let str_ref: &StrRef = std::any::Any::downcast_ref(&return_value).expect("to_string to return str value");
|
||||
{
|
||||
read_obj!(let str_obj = str_ref);
|
||||
read_obj!(let str_obj = return_value);
|
||||
let str_obj: &Str = str_obj.as_any().downcast_ref().unwrap();
|
||||
print!("{}", str_obj.value());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user