germax26
66cd54e532
I plan to make a few changes to my language, and I will then update these files later. I am moving them because I don't want them polluting the main directory. I probably should have done this to begin with, but better late than never.
29 lines
776 B
Plaintext
29 lines
776 B
Plaintext
import "ppp_types.ppp";
|
|
import "ppp_ast.ppp";
|
|
|
|
enum Object {
|
|
Int(int),
|
|
Str(str),
|
|
Bool(bool),
|
|
Void,
|
|
Type(Type),
|
|
Tuple(Type, Object[]),
|
|
List(Type, Object[]),
|
|
Array(Type, int, Object[]),
|
|
Function(Type, (str, (str, Type)[], Type, Statement, (str, (str, Type)[], Type, Statement, Object[]) -> Object)),
|
|
Return(Type, Object),
|
|
EnumValue(Type, str, (dict[str, Object] | Object[])),
|
|
EnumStruct(Type, dict[str, Object]),
|
|
Struct(Type, dict[str, Object])
|
|
}
|
|
|
|
func object_get_type(object: Object) -> Type {
|
|
match object in {
|
|
case Int(_) return Type.Int;
|
|
case Str(_) return Type.Str;
|
|
case Type(_) return Type.Type;
|
|
case Function(type_, _) return type_;
|
|
case EnumValue(type_, _, _) return type_;
|
|
case _ assert false, "Unimplemented object_get_type %s" % object;
|
|
}
|
|
} |