Commit Graph

5 Commits

Author SHA1 Message Date
43183d6553 Most object types get their own file now
This is hopefully going to make navigating the source tree easier.
Hopefully.

The only types that don't get their own files are:

* function types (UserFunction, BuiltinFunction, Method), which all live
  in obj/function.rs
* Nil, which lives in obj.rs
* Obj, which lives in obj.rs

Type definitions and init_types now live in obj/ty.rs.

New obj::prelude module for common imports.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-09-30 15:15:41 -07:00
9d5d094c5b Big Object naming refactor
* trait Obj -> Object
* Remove *Inst suffix from all object types. ObjInst -> Obj, IntInst ->
  Int, etc
* Type -> Ty, type_inst() -> ty(), type_name() -> ty_name()

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-09-26 11:07:12 -07:00
38a2064b08 Re-shuffle Obj::type_inst and BaseObjInst::type_inst
There was a moment during the refactor that I was thinking about getting
rid of the `__type__` attribute as the source of truth for the type
instance, but I think that was a bit more than I could chew. However I
forgot to re-add the default implementation for Obj::type_inst, so that
has been added back in.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-09-25 10:27:53 -07:00
2203957ebb Typesystem global instance churn, again
I don't know if I'm ever going to get this right.

It's a massive pain having to pass around the base "Method" type
everywhere. It really makes a lot more sense to have it already defined
someplace statically available. It makes doing like getting an attribute
or vtable entry a lot more ergonomic. Previously we'd have to pass in
the Method type every time, which was silly. Now we can just let the
MethodInst::instantiate() function query it directly. Like, this is
100000% better.

Also, I got rid of get_attr_lazy in favor of get_vtable_attr. I think
that I want to unify get_attr and get_vtable_attr, but that would
require a GC pointer to the "self" object on every object that you
create. That's a bit iffy.

But for now, things are feeling a little better and all the tests are
passing, so that's good at least.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-09-25 10:22:03 -07:00
078aef70ea Split up src/obj.rs
* common macros are in their own private module
* functions are in their own obj::function module

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-09-24 09:03:34 -07:00