new enum step 1

pull/2663/head
Alexander Medvednikov 2019-11-06 06:16:12 +03:00
parent 855a736a2c
commit 4d876d1980
4 changed files with 9 additions and 9 deletions

View File

@ -59,7 +59,7 @@ fn (p mut Parser) enum_decl(no_name bool) {
name: enum_name name: enum_name
mod: p.mod mod: p.mod
parent: 'int' parent: 'int'
cat: .enum_ //.enum_ //if is_c { TypeCategory.c_struct } else {TypeCategory.enum_ } cat: TypeCategory.enum_
enum_vals: fields.clone() enum_vals: fields.clone()
is_public: is_pub is_public: is_pub
}) })

View File

@ -1219,7 +1219,7 @@ fn (p mut Parser) replace_type_params(f &Fn, ti TypeInst) []string {
fn (p mut Parser) register_vargs_stuct(typ string, len int) string { fn (p mut Parser) register_vargs_stuct(typ string, len int) string {
vargs_struct := 'varg_$typ' vargs_struct := 'varg_$typ'
varg_type := Type{ varg_type := Type{
cat: .struct_, cat: TypeCategory.struct_,
name: vargs_struct, name: vargs_struct,
mod: p.mod mod: p.mod
} }
@ -1299,7 +1299,7 @@ fn (p mut Parser) register_multi_return_stuct(types []string) string {
typ := '_V_MulRet_' + types.join('_V_').replace('*', '_PTR_') typ := '_V_MulRet_' + types.join('_V_').replace('*', '_PTR_')
if p.table.known_type(typ) { return typ } if p.table.known_type(typ) { return typ }
p.table.register_type2(Type{ p.table.register_type2(Type{
cat: .struct_, cat: TypeCategory.struct_,
name: typ, name: typ,
mod: p.mod mod: p.mod
}) })

View File

@ -227,7 +227,7 @@ fn (p & Parser) peek() TokenKind {
} }
[inline] fn (p &Parser) peek_token() Token { [inline] fn (p &Parser) peek_token() Token {
if p.token_idx >= p.tokens.len - 2 { if p.token_idx >= p.tokens.len - 2 {
return Token{ tok:.eof } return Token{ tok:TokenKind.eof }
} }
return p.tokens[p.token_idx] return p.tokens[p.token_idx]
} }
@ -639,7 +639,7 @@ fn (p mut Parser) type_decl() {
name: name name: name
parent: parent.name parent: parent.name
mod: p.mod mod: p.mod
cat: .alias cat: TypeCategory.alias
}) })
} }
@ -1683,7 +1683,7 @@ fn (p mut Parser) name_expr() string {
if p.expected_type == enum_type.name { if p.expected_type == enum_type.name {
// `if color == .red` is enough // `if color == .red` is enough
// no need in `if color == Color.red` // no need in `if color == Color.red`
p.error('`${enum_type.name}.$val` is unnecessary, use `.$val`') p.warn('`${enum_type.name}.$val` is unnecessary, use `.$val`')
} }
// println('enum val $val') // println('enum val $val')
p.gen(mod_gen_name(enum_type.mod) + '__' + enum_type.name + '_' + val)// `color = main__Color_green` p.gen(mod_gen_name(enum_type.mod) + '__' + enum_type.name + '_' + val)// `color = main__Color_green`

View File

@ -31,7 +31,7 @@ fn (p mut Parser) get_type2() Type {
name: f.typ_str()// 'fn (int, int) string' name: f.typ_str()// 'fn (int, int) string'
mod: p.mod mod: p.mod
func: f func: f
cat: .func cat: TypeCategory.func
} }
p.table.register_type2(fn_typ) p.table.register_type2(fn_typ)
return fn_typ return fn_typ