More skeleton, including a trivial second_pass_function, fix a bug with ADTs that have members with the same name (may still be a problem if the ADT itself has the same name)

This commit is contained in:
Nathan Braswell
2016-01-05 21:40:00 -05:00
parent 79065c032f
commit f29fdcd463
6 changed files with 121 additions and 18 deletions

49
stdlib/type.krak Normal file
View File

@@ -0,0 +1,49 @@
// hmm, like the ast_node, this is another candadate for being fully an ADT
// one issue is that there are properties shared between most of the options (indirection, say)
adt base_type {
none,
template,
template_type,
void_return,
boolean,
character,
integer,
floating,
double_precision,
function
}
fun type(): type {
var to_ret.construct(): type
return to_ret
}
fun type(base: base_type): type {
var to_ret.construct(base): type
return to_ret
}
obj type (Object) {
var base: base_type
fun construct(): *type {
base.copy_construct(&base_type::none())
return this
}
fun construct(base_in: base_type): *type {
base.copy_construct(&base_in)
return this
}
fun copy_construct(old: *type) {
base = old->base
}
fun operator=(other: ref type) {
destruct()
copy_construct(&other)
}
fun destruct() {
base.destruct()
}
}