v2: temp const fix
							parent
							
								
									6f577321f1
								
							
						
					
					
						commit
						30c8a5a010
					
				| 
						 | 
					@ -213,6 +213,7 @@ pub:
 | 
				
			||||||
	imports []Import
 | 
						imports []Import
 | 
				
			||||||
	stmts   []Stmt
 | 
						stmts   []Stmt
 | 
				
			||||||
	scope   &Scope
 | 
						scope   &Scope
 | 
				
			||||||
 | 
						const_decls []ConstDecl
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub struct IdentFunc {
 | 
					pub struct IdentFunc {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -48,6 +48,18 @@ pub fn (c mut Checker) check2(ast_file ast.File) []string {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub fn (c mut Checker) check_files(ast_files []ast.File) {
 | 
					pub fn (c mut Checker) check_files(ast_files []ast.File) {
 | 
				
			||||||
 | 
						// TODO: temp fix, impl proper solition
 | 
				
			||||||
 | 
						for file in ast_files {
 | 
				
			||||||
 | 
							c.file = file
 | 
				
			||||||
 | 
							for stmt in file.stmts {
 | 
				
			||||||
 | 
								match mut stmt {
 | 
				
			||||||
 | 
									ast.ConstDecl {
 | 
				
			||||||
 | 
										c.stmt(*it)
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									else {}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	for file in ast_files {
 | 
						for file in ast_files {
 | 
				
			||||||
		c.check(file)
 | 
							c.check(file)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -304,6 +316,7 @@ fn (c mut Checker) stmt(node ast.Stmt) {
 | 
				
			||||||
				mut field := it.fields[i]
 | 
									mut field := it.fields[i]
 | 
				
			||||||
				typ := c.expr(expr)
 | 
									typ := c.expr(expr)
 | 
				
			||||||
				mut xconst := c.table.consts[field.name]
 | 
									mut xconst := c.table.consts[field.name]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				// if xconst.typ == 0 {
 | 
									// if xconst.typ == 0 {
 | 
				
			||||||
				xconst.typ = typ
 | 
									xconst.typ = typ
 | 
				
			||||||
				c.table.consts[field.name] = xconst
 | 
									c.table.consts[field.name] = xconst
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -466,7 +466,7 @@ pub fn (p mut Parser) parse_ident(is_c bool) ast.Ident {
 | 
				
			||||||
	else {
 | 
						else {
 | 
				
			||||||
		// handle consts/fns in checker
 | 
							// handle consts/fns in checker
 | 
				
			||||||
		ident.kind = .unresolved
 | 
							ident.kind = .unresolved
 | 
				
			||||||
		return ident
 | 
							return {ident | name: p.prepend_mod(name)}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1277,7 +1277,7 @@ fn (p mut Parser) const_decl() ast.ConstDecl {
 | 
				
			||||||
	mut fields := []ast.Field
 | 
						mut fields := []ast.Field
 | 
				
			||||||
	mut exprs := []ast.Expr
 | 
						mut exprs := []ast.Expr
 | 
				
			||||||
	for p.tok.kind != .rpar {
 | 
						for p.tok.kind != .rpar {
 | 
				
			||||||
		name := p.check_name()
 | 
							name := p.prepend_mod(p.check_name())
 | 
				
			||||||
		// println('const: $name')
 | 
							// println('const: $name')
 | 
				
			||||||
		p.check(.assign)
 | 
							p.check(.assign)
 | 
				
			||||||
		expr,typ := p.expr(0)
 | 
							expr,typ := p.expr(0)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue