Type as value initially working
This commit is contained in:
@@ -183,6 +183,9 @@ gen_value(Value a){
|
|||||||
break;
|
break;
|
||||||
CASE_BOOL: a.bool_val ? gen("true"):gen("false"); break;
|
CASE_BOOL: a.bool_val ? gen("true"):gen("false"); break;
|
||||||
CASE_FLOAT: gen("%f", a.f64_val); break;
|
CASE_FLOAT: gen("%f", a.f64_val); break;
|
||||||
|
case TYPE_TYPE: {
|
||||||
|
gen("%d", a.type_val->type_id);
|
||||||
|
}break;
|
||||||
default: result = false;
|
default: result = false;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -668,6 +671,7 @@ insert_builtin_types_into_scope(Ast_Scope *p){
|
|||||||
insert_builtin_into_scope(p, "F32"_s, type_f32);
|
insert_builtin_into_scope(p, "F32"_s, type_f32);
|
||||||
insert_builtin_into_scope(p, "F64"_s, type_f64);
|
insert_builtin_into_scope(p, "F64"_s, type_f64);
|
||||||
insert_builtin_into_scope(p, "Any"_s, type_any);
|
insert_builtin_into_scope(p, "Any"_s, type_any);
|
||||||
|
insert_builtin_into_scope(p, "Type"_s, type_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
global F64 parsing_time_begin;
|
global F64 parsing_time_begin;
|
||||||
|
|||||||
@@ -66,7 +66,8 @@ Type_Info :: struct
|
|||||||
type_infos_len: S32 #foreign
|
type_infos_len: S32 #foreign
|
||||||
type_infos : *Type_Info #foreign
|
type_infos : *Type_Info #foreign
|
||||||
|
|
||||||
get_type_info :: (id: Type_ID): *Type_Info
|
get_type_info :: (type: Type): *Type_Info
|
||||||
|
id := type->S32
|
||||||
if id >= type_infos_len
|
if id >= type_infos_len
|
||||||
return 0
|
return 0
|
||||||
return type_infos + id
|
return type_infos + id
|
||||||
@@ -60,7 +60,7 @@ WinMain :: (hInstance: HINSTANCE, hPrevInstance: HINSTANCE, lpCmdLine: LPSTR, nS
|
|||||||
if good_scheduling := false, timeBeginPeriod(1) == TIMERR_NOERROR
|
if good_scheduling := false, timeBeginPeriod(1) == TIMERR_NOERROR
|
||||||
good_scheduling = true
|
good_scheduling = true
|
||||||
|
|
||||||
char_info := get_type_info(5)
|
char_info := get_type_info(char)
|
||||||
assert(char_info.kind == Type_Info_Kind.CHAR)
|
assert(char_info.kind == Type_Info_Kind.CHAR)
|
||||||
|
|
||||||
arena: Arena
|
arena: Arena
|
||||||
|
|||||||
@@ -641,6 +641,11 @@ resolve_cast(Ast_Binary *node){
|
|||||||
node->before_type = expr.type;
|
node->before_type = expr.type;
|
||||||
|
|
||||||
switch(expr.type->kind){
|
switch(expr.type->kind){
|
||||||
|
case TYPE_TYPE:{
|
||||||
|
if(is_int(type)){
|
||||||
|
expr.type = type;
|
||||||
|
} else goto failure;
|
||||||
|
} break;
|
||||||
case TYPE_ENUM:{
|
case TYPE_ENUM:{
|
||||||
if(is_int(type))
|
if(is_int(type))
|
||||||
expr.type = type;
|
expr.type = type;
|
||||||
|
|||||||
1
types.h
1
types.h
@@ -124,6 +124,7 @@ name(Ast_Type *type){
|
|||||||
case TYPE_U64: return "U64";
|
case TYPE_U64: return "U64";
|
||||||
case TYPE_ANY: return "Any";
|
case TYPE_ANY: return "Any";
|
||||||
case TYPE_TUPLE: return "Tuple";
|
case TYPE_TUPLE: return "Tuple";
|
||||||
|
case TYPE_TYPE: return "S64";
|
||||||
invalid_default_case;
|
invalid_default_case;
|
||||||
}
|
}
|
||||||
return "<unknown_type>";
|
return "<unknown_type>";
|
||||||
|
|||||||
Reference in New Issue
Block a user