We can also put them on more basic types
This commit is contained in:
parent
3bcc5d5530
commit
369e0f84db
@ -10,3 +10,5 @@ class Test:
|
||||
# Instances have a __class__ property synthesized by the VM
|
||||
let test = Test()
|
||||
print test.__class__
|
||||
|
||||
print (37.45).asInteger
|
||||
|
12
vm.c
12
vm.c
@ -721,6 +721,18 @@ static KrkValue run() {
|
||||
}
|
||||
}
|
||||
break;
|
||||
case VAL_FLOATING: {
|
||||
if (!strcmp(name->chars, "asInteger")) {
|
||||
krk_push(INTEGER_VAL((int)AS_FLOATING(krk_pop())));
|
||||
} else goto _undefined;
|
||||
break;
|
||||
}
|
||||
case VAL_INTEGER: {
|
||||
if (!strcmp(name->chars, "asFloating")) {
|
||||
krk_push(FLOATING_VAL((int)AS_INTEGER(krk_pop())));
|
||||
} else goto _undefined;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
runtimeError("Don't know how to retreive properties for %s yet", typeName(krk_peek(0)));
|
||||
return NONE_VAL();
|
||||
|
Loading…
Reference in New Issue
Block a user