some bugfixes, getting closer
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import tree:*
|
||||
import symbol:*
|
||||
import vector:*
|
||||
import vector_literals:*
|
||||
import set:*
|
||||
|
||||
@@ -333,7 +333,7 @@ obj ast_transformation (Object) {
|
||||
println("FOR FIND OR INSTATINTATE")
|
||||
template_type_replacements.for_each(fun(key: string, value: *type) println(string("MAP: ") + key + " : " + value->to_string());)
|
||||
println("MAP DONE")
|
||||
|
||||
|
||||
var inst_type = null<ast_node>()
|
||||
// check if already instantiated
|
||||
if (results[i]->template.instantiated_map.contains_key(real_types_deref)) {
|
||||
@@ -341,14 +341,23 @@ obj ast_transformation (Object) {
|
||||
inst_type = results[i]->template.instantiated_map[real_types_deref]
|
||||
} else {
|
||||
print("Not using cached template - was looking for:\n\t\t")
|
||||
real_types_deref.for_each(fun(t: type) print(t.to_string() + ", ");)
|
||||
println("instead, only had:")
|
||||
var typeStr = string()
|
||||
real_types_deref.for_each(fun(t: type) typeStr += t.to_string() + ", ";)
|
||||
print(typeStr)
|
||||
println("\ninstead, only had:")
|
||||
results[i]->template.instantiated_map.for_each(fun(key: vector<type>, value: *ast_node) {
|
||||
print("\t\t")
|
||||
key.for_each(fun(t: type) print(t.to_string() + ", ");)
|
||||
var hasTypStr = string()
|
||||
key.for_each(fun(t: type) hasTypStr += t.to_string() + ", ";)
|
||||
print(hasTypStr)
|
||||
if (typeStr == hasTypStr)
|
||||
error("they're equal but really shouldnt be")
|
||||
println()
|
||||
})
|
||||
println("donr")
|
||||
inst_type = first_pass_type_def(results[i]->template.syntax_node, results[i], true)
|
||||
// no change up it's name so we can see that it's instantiated when printed out and keep track of it
|
||||
inst_type->type_def.name += "<" + typeStr + ">"
|
||||
// add to instantiated_map so we only instantiate with a paticular set of types once
|
||||
// put in map first for recursive purposes
|
||||
results[i]->template.instantiated_map.set(real_types_deref, inst_type)
|
||||
@@ -399,8 +408,7 @@ obj ast_transformation (Object) {
|
||||
ast_node::adt_def(backing) return backing.self_type->clone_with_indirection(indirection, is_ref)
|
||||
}
|
||||
}
|
||||
println("No objects in lookup, returning none")
|
||||
return type_ptr(base_type::none(), indirection, is_ref)
|
||||
error("no types found for " + type_syntax_str)
|
||||
}
|
||||
}
|
||||
fun transform(node: *tree<symbol>, scope: *ast_node, template_replacements: map<string, *type>): *ast_node return transform(node, scope, search_type::none(), template_replacements)
|
||||
@@ -697,7 +705,7 @@ obj ast_transformation (Object) {
|
||||
var to_ret = ast_case_statement_ptr()
|
||||
var the_adts = scope_lookup(concat_symbol_tree(get_node("scoped_identifier", get_node("scoped_identifier", node))), scope)
|
||||
if (the_adts.size != 1)
|
||||
error(string("the adts too large for ") + concat_symbol_tree(get_node("scoped_identifier", node)))
|
||||
error(string("the number of adts found was not 1, it was ") + the_adts.size + " for " + concat_symbol_tree(get_node("scoped_identifier", node)))
|
||||
var the_adt = the_adts[0]
|
||||
var the_option_name = concat_symbol_tree(get_node("identifier", get_node("scoped_identifier", node)))
|
||||
var the_option = the_adt->adt_def.options.find_first_satisfying(fun(option: *ast_node): bool return option->identifier.name == the_option_name;)
|
||||
@@ -1175,7 +1183,10 @@ fun scope_lookup(name: string, scope: *ast_node): vector<*ast_node> {
|
||||
results.for_each(fun(s: *ast_node) {
|
||||
print("looking in scope: ")
|
||||
println(s)
|
||||
next_results += scope_lookup_helper(i, s, set<*ast_node>())
|
||||
scope_lookup_helper(i, s, set<*ast_node>()).for_each(fun (result: *ast_node) {
|
||||
if (!next_results.contains(result))
|
||||
next_results.add(result)
|
||||
})
|
||||
})
|
||||
results = next_results
|
||||
})
|
||||
|
||||
@@ -922,7 +922,7 @@ obj c_generator (Object) {
|
||||
base_type::integer() return indirection + string("int")
|
||||
base_type::floating() return indirection + string("float")
|
||||
base_type::double_precision() return indirection + string("double")
|
||||
base_type::object() return type->type_def->type_def.name
|
||||
base_type::object() return cify_name(type->type_def->type_def.name)
|
||||
base_type::adt() return type->type_def->adt_def.name
|
||||
base_type::function() {
|
||||
var temp = indirection + string("function_")
|
||||
@@ -974,7 +974,7 @@ obj c_generator (Object) {
|
||||
match (*node) {
|
||||
ast_node::type_def(backing) {
|
||||
var upper = backing.scope[string("~enclosing_scope")][0]
|
||||
result = backing.name
|
||||
result = cify_name(backing.name)
|
||||
if (is_template(upper))
|
||||
upper->template.instantiated_map.reverse_get(node).for_each(fun(t: ref type) result += string("_") + type_decoration(&t);)
|
||||
}
|
||||
|
||||
@@ -19,6 +19,10 @@ fun operator+(first: *char, second: ref string): string {
|
||||
return string(first) + second
|
||||
}
|
||||
|
||||
/*fun operator+<T>(first: *char, second: T): string {*/
|
||||
/*return string(first) + second*/
|
||||
/*}*/
|
||||
|
||||
fun string(in:*char):string {
|
||||
var out.construct(in):string
|
||||
return out
|
||||
|
||||
@@ -139,29 +139,30 @@ obj type (Object) {
|
||||
indirection == other.indirection && deref_equality(type_def, other.type_def) && traits == other.traits
|
||||
}
|
||||
fun to_string(): string {
|
||||
var all_string = string("traits:[")
|
||||
traits.for_each(fun(t: string) all_string += t;)
|
||||
all_string += "] "
|
||||
var trait_string = string(":[")
|
||||
traits.for_each(fun(t: string) trait_string += t;)
|
||||
trait_string += "] "
|
||||
var indr_string = string("")
|
||||
if (is_ref)
|
||||
all_string += " ref "
|
||||
for (var i = 0; i < indirection; i++;) all_string += "*"
|
||||
indr_string += " ref "
|
||||
for (var i = 0; i < indirection; i++;) indr_string += "*"
|
||||
match (base) {
|
||||
base_type::none() return all_string + string("none")
|
||||
base_type::object() return all_string + type_def->type_def.name
|
||||
base_type::adt() return all_string + type_def->adt_def.name
|
||||
base_type::no_type_adt_option() return all_string + "no_type_adt_option"
|
||||
base_type::template() return all_string + string("template")
|
||||
base_type::template_type() return all_string + string("template_type")
|
||||
base_type::void_return() return all_string + string("void_return")
|
||||
base_type::boolean() return all_string + string("boolean")
|
||||
base_type::character() return all_string + string("character")
|
||||
base_type::integer() return all_string + string("integer")
|
||||
base_type::floating() return all_string + string("floating")
|
||||
base_type::double_precision() return all_string + string("double_precision")
|
||||
base_type::none() return indr_string + string("none") + trait_string
|
||||
base_type::object() return indr_string + type_def->type_def.name + trait_string
|
||||
base_type::adt() return indr_string + type_def->adt_def.name + trait_string
|
||||
base_type::no_type_adt_option() return indr_string + "no_type_adt_option" + trait_string
|
||||
base_type::template() return indr_string + string("template") + trait_string
|
||||
base_type::template_type() return indr_string + string("template_type") + trait_string
|
||||
base_type::void_return() return indr_string + string("void_return") + trait_string
|
||||
base_type::boolean() return indr_string + string("boolean") + trait_string
|
||||
base_type::character() return indr_string + string("character") + trait_string
|
||||
base_type::integer() return indr_string + string("integer") + trait_string
|
||||
base_type::floating() return indr_string + string("floating") + trait_string
|
||||
base_type::double_precision() return indr_string + string("double_precision") + trait_string
|
||||
base_type::function() {
|
||||
var temp = all_string + string("fun(")
|
||||
var temp = indr_string + string("fun(")
|
||||
parameter_types.for_each(fun(parameter_type: *type) temp += parameter_type->to_string() + ", ";)
|
||||
return temp + ")" + return_type->to_string()
|
||||
return temp + ")" + return_type->to_string() + trait_string
|
||||
}
|
||||
}
|
||||
return string("impossible type, indirection:") + indirection
|
||||
|
||||
Reference in New Issue
Block a user