Added function calls, printing out of pointers

This commit is contained in:
Nathan Braswell
2016-01-11 23:41:09 -05:00
parent 5db0365a63
commit 4c569f4f8c
10 changed files with 162 additions and 72 deletions

View File

@@ -88,8 +88,8 @@ obj translation_unit (Object) {
return children == other.children && name == other.name
}
}
fun ast_import_ptr(name: string): *ast_node {
var to_ret.construct(name): import
fun ast_import_ptr(name: string, translation_unit: *ast_node): *ast_node {
var to_ret.construct(name, translation_unit): import
var ptr = new<ast_node>()
ptr->copy_construct(&ast_node::import(to_ret))
return ptr
@@ -103,17 +103,20 @@ fun is_import(node: *ast_node): bool {
obj import (Object) {
var scope: map<string, vector<*ast_node>>
var imported: set<string>
var translation_unit: *ast_node
var name: string
fun construct(nameIn: string): *import {
fun construct(nameIn: string, translation_unit_in: *ast_node): *import {
scope.construct()
imported.construct()
name.copy_construct(&nameIn)
translation_unit = translation_unit_in
return this
}
fun copy_construct(old: *import) {
scope.copy_construct(&old->scope)
imported.copy_construct(&old->imported)
name.copy_construct(&old->name)
translation_unit = old->translation_unit
}
fun destruct() {
scope.destruct()
@@ -125,7 +128,7 @@ obj import (Object) {
copy_construct(&other)
}
fun operator==(other: ref import): bool {
return imported == other.imported && name == other.name
return imported == other.imported && name == other.name && translation_unit == other.translation_unit
}
}
fun ast_identifier_ptr(name: *char, type: *type): *ast_node {
@@ -784,8 +787,8 @@ obj simple_passthrough (Object) {
return scope == other.scope && passthrough_str == other.passthrough_str
}
}
fun ast_function_call_ptr(): *ast_node {
var to_ret.construct(): function_call
fun ast_function_call_ptr(func: *ast_node, parameters: vector<*ast_node>): *ast_node {
var to_ret.construct(func, parameters): function_call
var ptr = new<ast_node>()
ptr->copy_construct(&ast_node::function_call(to_ret))
return ptr
@@ -797,23 +800,26 @@ fun is_function_call(node: *ast_node): bool {
return false
}
obj function_call (Object) {
var scope: map<string, vector<*ast_node>>
fun construct(): *function_call {
scope.construct()
var func: *ast_node
var parameters: vector<*ast_node>
fun construct(func_in: *ast_node, parameters_in: vector<*ast_node>): *function_call {
func = func_in
parameters.copy_construct(&parameters_in)
return this
}
fun copy_construct(old: *function_call) {
scope.copy_construct(&old->scope)
func = old->func
parameters.copy_construct(&old->parameters)
}
fun destruct() {
scope.destruct()
parameters.destruct()
}
fun operator=(other: ref function_call) {
destruct()
copy_construct(&other)
}
fun operator==(other: ref function_call): bool {
return true
return func == func && parameters == other.parameters
}
}
fun ast_value_ptr(string_value: string, value_type: *type): *ast_node {
@@ -879,7 +885,7 @@ fun get_ast_children(node: *ast_node): vector<*ast_node> {
ast_node::declaration_statement(backing) return vector<*ast_node>()
ast_node::if_comp(backing) return vector<*ast_node>(backing.statement)
ast_node::simple_passthrough(backing) return vector<*ast_node>()
ast_node::function_call(backing) return vector<*ast_node>()
ast_node::function_call(backing) return vector(backing.func) + backing.parameters
ast_node::value(backing) return vector<*ast_node>()
}
}
@@ -906,7 +912,7 @@ fun get_ast_name(node: *ast_node): string {
ast_node::declaration_statement(backing) return string("declaration_statement")
ast_node::if_comp(backing) return string("if_comp: ") + backing.wanted_generator
ast_node::simple_passthrough(backing) return string("simple_passthrough: , string:") + backing.passthrough_str
ast_node::function_call(backing) return string("function_call")
ast_node::function_call(backing) return string("function_call:(") + backing.parameters.size + ")"
ast_node::value(backing) return string("value: ") + backing.string_value + ": " + backing.value_type->to_string()
}
}
@@ -933,7 +939,7 @@ fun get_ast_scope(node: *ast_node): *map<string,vector<*ast_node>> {
ast_node::declaration_statement() return &node->declaration_statement.scope
ast_node::if_comp() return null<map<string,vector<*ast_node>>>()
ast_node::simple_passthrough() return &node->simple_passthrough.scope
ast_node::function_call() return &node->function_call.scope
ast_node::function_call() return null<map<string,vector<*ast_node>>>()
ast_node::value() return &node->value.scope
}
}