Add struct access! Uses new translation_unit_generative pass depended on by scope lookups to generate compiler_intrinsics that access members of structs'

This commit is contained in:
Nathan Braswell
2018-10-27 18:00:26 -04:00
parent db3004329d
commit 8177bc7fd0
3 changed files with 99 additions and 31 deletions

View File

@@ -152,7 +152,7 @@ fun adt_lower(name_ast_map: *map<str, pair<*tree<symbol>,*ast_node>>, ast_to_syn
backing.cases.for_each(fun(case_stmt: *ast_node) {
var option = case_stmt->case_statement.option
if (!get_ast_scope(get_ast_type(value)->type_def)->contains_key(str("flag")))
error("trying to get flag from struct without it - are you matching on not an adt? - ")
error("trying to get flag from struct without it - are you matching on not an adt? - " + get_ast_type(value)->to_string())
var flag = get_from_scope(get_ast_type(value)->type_def, "flag")
var data = get_from_scope(get_ast_type(value)->type_def, "data")
var option_num = -7

View File

@@ -119,6 +119,9 @@ fun shallow_equality(a: *type, b: *type):bool {
type::_fun(x) {
return is_fun(b) && a->_fun.third == b->_fun.third
}
type::_obj(x) {
return is_obj(b) && get_ast_binding(x) == get_ast_binding(b->_obj)
}
}
return *a == *b
}