Added indirection to types in prep for function calls, full passthrough, and the first real hello world

This commit is contained in:
Nathan Braswell
2016-01-10 18:26:31 -05:00
parent 7f20a42178
commit 5db0365a63
7 changed files with 82 additions and 45 deletions

View File

@@ -143,25 +143,31 @@ obj ast_transformation (Object) {
// always get to pre-reffed level
var real_node = get_node("pre_reffed", node)
// check for indirection and step down
var indirection = 0
while (get_node("pre_reffed", real_node)) {
real_node = get_node("pre_reffed", real_node)
indirection++
}
var type_syntax_str = concat_symbol_tree(real_node)
println(type_syntax_str + " *************************")
// should take into account indirection and references...
if (type_syntax_str == "void")
return type_ptr(base_type::void_return())
return type_ptr(base_type::void_return(), indirection)
else if (type_syntax_str == "bool")
return type_ptr(base_type::boolean())
return type_ptr(base_type::boolean(), indirection)
else if (type_syntax_str == "int")
return type_ptr(base_type::integer())
return type_ptr(base_type::integer(), indirection)
else if (type_syntax_str == "float")
return type_ptr(base_type::floating())
return type_ptr(base_type::floating(), indirection)
else if (type_syntax_str == "double")
return type_ptr(base_type::double_precision())
return type_ptr(base_type::double_precision(), indirection)
else if (type_syntax_str == "char")
return type_ptr(base_type::character())
else if (/* check for function type*/ true)
return type_ptr(base_type::function())
return type_ptr(base_type::character(), indirection)
else if (/* check for function type*/ false)
return type_ptr(base_type::function(), indirection)
else {
// do lookup for objects, ADTs, templates, etc
return type_ptr(base_type::none())
return type_ptr(base_type::none(), indirection)
}
}
/*NodeTree<ASTData>* ASTTransformation::transform(NodeTree<Symbol>* from, NodeTree<ASTData>* scope, std::vector<Type> types, bool limitToFunction, std::map<std::string, Type*> templateTypeReplacements) {*/
@@ -208,7 +214,7 @@ obj ast_transformation (Object) {
var value_str = concat_symbol_tree(node)
var value_type = null<type>()
if (value_str[0] == '"')
value_type = type_ptr(base_type::character()) // and indirection, sigh
value_type = type_ptr(base_type::character(), 1)
else if (value_str[0] == '\'')
value_type = type_ptr(base_type::character())
else {