From 147ecc5e17d95f20e8044d035bebeb05fdb05968 Mon Sep 17 00:00:00 2001 From: Joe Conigliaro Date: Wed, 4 Mar 2020 01:06:21 +1100 Subject: [PATCH] v2: time - prefix C struct & ast.TypeName to ast.Type --- vlib/time/time_nix.v | 2 +- vlib/v/ast/ast.v | 15 +++++++-------- vlib/v/checker/checker.v | 2 +- vlib/v/parser/parser.v | 8 ++------ 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/vlib/time/time_nix.v b/vlib/time/time_nix.v index 9779a61055..8e409d39ea 100644 --- a/vlib/time/time_nix.v +++ b/vlib/time/time_nix.v @@ -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)) } diff --git a/vlib/v/ast/ast.v b/vlib/v/ast/ast.v index c9ef539eb8..6a30e11bc0 100644 --- a/vlib/v/ast/ast.v +++ b/vlib/v/ast/ast.v @@ -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 } diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index e08ea8491f..5fd0941341 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -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 } /* diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 9bec87b1f8..a10d82022e 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -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{