v2: time - prefix C struct & ast.TypeName to ast.Type
							parent
							
								
									448ed41562
								
							
						
					
					
						commit
						147ecc5e17
					
				| 
						 | 
				
			
			@ -15,6 +15,6 @@ struct C.tm {
 | 
			
		|||
 | 
			
		||||
fn C.timegm(&tm) time_t
 | 
			
		||||
 | 
			
		||||
fn make_unix_time(t tm) int {
 | 
			
		||||
fn make_unix_time(t C.tm) int {
 | 
			
		||||
	return int(C.timegm(&t))
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,24 +12,23 @@ pub type Expr = InfixExpr | IfExpr | StringLiteral | IntegerLiteral | CharLitera
 | 
			
		|||
FloatLiteral | Ident | CallExpr | BoolLiteral | StructInit | ArrayInit | SelectorExpr | PostfixExpr | 	
 | 
			
		||||
AssignExpr | PrefixExpr | MethodCallExpr | IndexExpr | RangeExpr | MatchExpr | 	
 | 
			
		||||
CastExpr | EnumVal | Assoc | SizeOf | None | MapInit | IfGuardExpr | ParExpr | OrExpr | 	
 | 
			
		||||
ConcatExpr | TypeName | AsCast
 | 
			
		||||
ConcatExpr | Type | AsCast
 | 
			
		||||
 | 
			
		||||
pub type Stmt = VarDecl | GlobalDecl | FnDecl | Return | Module | Import | ExprStmt | 	
 | 
			
		||||
ForStmt | StructDecl | ForCStmt | ForInStmt | CompIf | ConstDecl | Attr | BranchStmt | 	
 | 
			
		||||
HashStmt | AssignStmt | EnumDecl | TypeDecl | DeferStmt | GotoLabel | GotoStmt | 	
 | 
			
		||||
LineComment | MultiLineComment | AssertStmt | UnsafeStmt
 | 
			
		||||
 | 
			
		||||
pub type Type = StructType | ArrayType
 | 
			
		||||
// pub type Type = StructType | ArrayType
 | 
			
		||||
 | 
			
		||||
pub struct StructType {
 | 
			
		||||
	fields []Field
 | 
			
		||||
}
 | 
			
		||||
// pub struct StructType {
 | 
			
		||||
// 	fields []Field
 | 
			
		||||
// }
 | 
			
		||||
 | 
			
		||||
pub struct ArrayType {}
 | 
			
		||||
// pub struct ArrayType {}
 | 
			
		||||
 | 
			
		||||
pub struct TypeName {
 | 
			
		||||
pub struct Type {
 | 
			
		||||
pub:
 | 
			
		||||
	name string
 | 
			
		||||
	typ  table.Type
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -564,7 +564,7 @@ pub fn (c mut Checker) expr(node ast.Expr) table.Type {
 | 
			
		|||
		ast.StructInit {
 | 
			
		||||
			return c.check_struct_init(it)
 | 
			
		||||
		}
 | 
			
		||||
		ast.TypeName {
 | 
			
		||||
		ast.Type {
 | 
			
		||||
			return it.typ
 | 
			
		||||
		}
 | 
			
		||||
		/*
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -583,9 +583,7 @@ pub fn (p mut Parser) name_expr() ast.Expr {
 | 
			
		|||
	// `map[string]int` initialization
 | 
			
		||||
	if p.tok.lit == 'map' && p.peek_tok.kind == .lsbr {
 | 
			
		||||
		map_type := p.parse_map_type()
 | 
			
		||||
		map_type_sym := p.table.get_type_symbol(map_type)
 | 
			
		||||
		return ast.TypeName{
 | 
			
		||||
			name: map_type_sym.name
 | 
			
		||||
		return ast.Type{
 | 
			
		||||
			typ: map_type
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -1746,9 +1744,7 @@ fn (p mut Parser) match_expr() ast.Expr {
 | 
			
		|||
			// if sym.kind == .sum_type {
 | 
			
		||||
			// p.warn('is sum')
 | 
			
		||||
			typ := p.parse_type()
 | 
			
		||||
			typ_sym := p.table.get_type_symbol(typ)
 | 
			
		||||
			match_exprs << ast.TypeName{
 | 
			
		||||
				name: typ_sym.name
 | 
			
		||||
			match_exprs << ast.Type{
 | 
			
		||||
				typ: typ
 | 
			
		||||
			}
 | 
			
		||||
			p.scope.register_var(ast.VarDecl{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue