Added in extern global variables and printing of *char and string to stderr with printlnerr, printerr. Note that this will still compile in a previous version, but instead of extern, stderr will be newly declared. This is ok, because this version of the compiler never uses it, so we'll only use it after this one is bootstrapped in.

This commit is contained in:
Nathan Braswell
2016-05-22 13:08:10 -07:00
parent a64e79c789
commit 12dfa837e3
5 changed files with 49 additions and 30 deletions

View File

@@ -815,8 +815,8 @@ obj assignment_statement (Object) {
return to == other.to && from == other.from
}
}
fun ast_declaration_statement_ptr(ident: *ast_node, expression: *ast_node): *ast_node {
var to_ret.construct(ident, expression): declaration_statement
fun ast_declaration_statement_ptr(ident: *ast_node, expression: *ast_node, is_extern: bool): *ast_node {
var to_ret.construct(ident, expression, is_extern): declaration_statement
var ptr = new<ast_node>()
ptr->copy_construct(&ast_node::declaration_statement(to_ret))
return ptr
@@ -831,16 +831,19 @@ obj declaration_statement (Object) {
var identifier: *ast_node
var expression: *ast_node
var init_method_call: *ast_node
fun construct(identifier_in: *ast_node, expression_in: *ast_node): *declaration_statement {
var is_extern: bool
fun construct(identifier_in: *ast_node, expression_in: *ast_node, is_extern_in: bool): *declaration_statement {
identifier = identifier_in
expression = expression_in
init_method_call = null<ast_node>()
is_extern = is_extern_in
return this
}
fun copy_construct(old: *declaration_statement) {
identifier = old->identifier
expression = old->expression
init_method_call = old->init_method_call
is_extern = old->is_extern
}
fun destruct() {
}
@@ -849,7 +852,7 @@ obj declaration_statement (Object) {
copy_construct(&other)
}
fun operator==(other: ref declaration_statement): bool {
return identifier == other.identifier && expression == other.expression && init_method_call == other.init_method_call
return identifier == other.identifier && expression == other.expression && init_method_call == other.init_method_call && is_extern == other.is_extern
}
}
fun ast_if_comp_ptr(): *ast_node {