1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

v2: time - prefix C struct & ast.TypeName to ast.Type

This commit is contained in:
Joe Conigliaro 2020-03-04 01:06:21 +11:00
parent 448ed41562
commit 147ecc5e17
4 changed files with 11 additions and 16 deletions

View File

@ -15,6 +15,6 @@ struct C.tm {
fn C.timegm(&tm) time_t 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)) return int(C.timegm(&t))
} }

View File

@ -12,24 +12,23 @@ pub type Expr = InfixExpr | IfExpr | StringLiteral | IntegerLiteral | CharLitera
FloatLiteral | Ident | CallExpr | BoolLiteral | StructInit | ArrayInit | SelectorExpr | PostfixExpr | FloatLiteral | Ident | CallExpr | BoolLiteral | StructInit | ArrayInit | SelectorExpr | PostfixExpr |
AssignExpr | PrefixExpr | MethodCallExpr | IndexExpr | RangeExpr | MatchExpr | AssignExpr | PrefixExpr | MethodCallExpr | IndexExpr | RangeExpr | MatchExpr |
CastExpr | EnumVal | Assoc | SizeOf | None | MapInit | IfGuardExpr | ParExpr | OrExpr | 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 | pub type Stmt = VarDecl | GlobalDecl | FnDecl | Return | Module | Import | ExprStmt |
ForStmt | StructDecl | ForCStmt | ForInStmt | CompIf | ConstDecl | Attr | BranchStmt | ForStmt | StructDecl | ForCStmt | ForInStmt | CompIf | ConstDecl | Attr | BranchStmt |
HashStmt | AssignStmt | EnumDecl | TypeDecl | DeferStmt | GotoLabel | GotoStmt | HashStmt | AssignStmt | EnumDecl | TypeDecl | DeferStmt | GotoLabel | GotoStmt |
LineComment | MultiLineComment | AssertStmt | UnsafeStmt LineComment | MultiLineComment | AssertStmt | UnsafeStmt
pub type Type = StructType | ArrayType // pub type Type = StructType | ArrayType
pub struct StructType { // pub struct StructType {
fields []Field // fields []Field
} // }
pub struct ArrayType {} // pub struct ArrayType {}
pub struct TypeName { pub struct Type {
pub: pub:
name string
typ table.Type typ table.Type
} }

View File

@ -564,7 +564,7 @@ pub fn (c mut Checker) expr(node ast.Expr) table.Type {
ast.StructInit { ast.StructInit {
return c.check_struct_init(it) return c.check_struct_init(it)
} }
ast.TypeName { ast.Type {
return it.typ return it.typ
} }
/* /*

View File

@ -583,9 +583,7 @@ pub fn (p mut Parser) name_expr() ast.Expr {
// `map[string]int` initialization // `map[string]int` initialization
if p.tok.lit == 'map' && p.peek_tok.kind == .lsbr { if p.tok.lit == 'map' && p.peek_tok.kind == .lsbr {
map_type := p.parse_map_type() map_type := p.parse_map_type()
map_type_sym := p.table.get_type_symbol(map_type) return ast.Type{
return ast.TypeName{
name: map_type_sym.name
typ: map_type typ: map_type
} }
} }
@ -1746,9 +1744,7 @@ fn (p mut Parser) match_expr() ast.Expr {
// if sym.kind == .sum_type { // if sym.kind == .sum_type {
// p.warn('is sum') // p.warn('is sum')
typ := p.parse_type() typ := p.parse_type()
typ_sym := p.table.get_type_symbol(typ) match_exprs << ast.Type{
match_exprs << ast.TypeName{
name: typ_sym.name
typ: typ typ: typ
} }
p.scope.register_var(ast.VarDecl{ p.scope.register_var(ast.VarDecl{