diff --git a/src/arobject.h b/src/arobject.h index 9209bbb..b7cf226 100644 --- a/src/arobject.h +++ b/src/arobject.h @@ -16,11 +16,11 @@ typedef enum { __base__, __class__, __name__, - __binding__, - __function__, BUILT_IN_ARRAY_COUNT, + __binding__, + __function__, __add__, __string__, __subtract__, diff --git a/src/runtime/call/call.c b/src/runtime/call/call.c index 112d656..dd387e6 100644 --- a/src/runtime/call/call.c +++ b/src/runtime/call/call.c @@ -121,6 +121,7 @@ void run_call(ArgonObject *original_object, size_t argc, ArgonObject **argv, (int)object_name->value.as_str->length, object_name->value.as_str->data, object->value.argon_fn->number_of_parameters, argc); + return; } Stack *scope = create_scope(object->value.argon_fn->stack, true); for (size_t i = 0; i < argc; i++) { diff --git a/src/runtime/objects/object.c b/src/runtime/objects/object.c index 688388a..0858567 100644 --- a/src/runtime/objects/object.c +++ b/src/runtime/objects/object.c @@ -35,6 +35,8 @@ const char *built_in_field_names[BUILT_IN_FIELDS_COUNT] = { "__class__", "__name__", "", // above is anything that gets stored in built in slots + "__binding__", + "__function__", "__add__", "__string__", "__subtract__", @@ -44,8 +46,6 @@ const char *built_in_field_names[BUILT_IN_FIELDS_COUNT] = { "__init__", "__boolean__", "__get_attr__", - "__binding__", - "__function__", "address", "__call__", "__number__", diff --git a/src/runtime/objects/object.h b/src/runtime/objects/object.h index ccc8670..419e7ba 100644 --- a/src/runtime/objects/object.h +++ b/src/runtime/objects/object.h @@ -13,6 +13,8 @@ extern ArgonObject *BASE_CLASS; +extern const char *built_in_field_names[BUILT_IN_FIELDS_COUNT]; + typedef struct ArgonObject ArgonObject; ArgonObject *new_class(); diff --git a/src/runtime/runtime.c b/src/runtime/runtime.c index 5e02131..d1be7d2 100644 --- a/src/runtime/runtime.c +++ b/src/runtime/runtime.c @@ -615,7 +615,6 @@ void bootstrap_types() { add_builtin_field(ARGON_METHOD_TYPE, __base__, BASE_CLASS); add_builtin_field(ARGON_METHOD_TYPE, __name__, new_string_object_null_terminated("method")); - create_ARGON_NUMBER_TYPE(); add_builtin_field( BASE_CLASS, __new__, @@ -695,6 +694,7 @@ void bootstrap_types() { BASE_CLASS, __set_attr__, create_argon_native_function("__set_attr__", BASE_CLASS___set_attr__)); create_ARGON_DICTIONARY_TYPE(); + create_ARGON_NUMBER_TYPE(); } void add_to_hashmap(struct hashmap_GC *hashmap, char *name, ArgonObject *value) { diff --git a/tests/class_method.ar b/tests/class_method.ar new file mode 100644 index 0000000..fda8e78 --- /dev/null +++ b/tests/class_method.ar @@ -0,0 +1,5 @@ +string.cool(self) = do + term.log(self, self.length) + return 10 +'hello world'.cool() +string.cool('goodbye world') \ No newline at end of file