ast: vfmt ast.v

pull/4945/head
Alexander Medvednikov 2020-05-18 18:06:09 +02:00
parent 07a78b2843
commit 5c0c418818
1 changed files with 41 additions and 61 deletions

View File

@ -87,11 +87,11 @@ pub:
// `foo.bar` // `foo.bar`
pub struct SelectorExpr { pub struct SelectorExpr {
pub: pub:
pos token.Position pos token.Position
expr Expr expr Expr
field_name string field_name string
pub mut: pub mut:
expr_type table.Type expr_type table.Type
} }
// module declaration // module declaration
@ -112,7 +112,7 @@ pub:
default_expr Expr default_expr Expr
has_default_expr bool has_default_expr bool
attrs []string attrs []string
is_public bool is_public bool
pub mut: pub mut:
typ table.Type typ table.Type
} }
@ -127,12 +127,12 @@ pub mut:
pub struct ConstField { pub struct ConstField {
pub: pub:
name string name string
expr Expr expr Expr
is_pub bool is_pub bool
pos token.Position pos token.Position
pub mut: pub mut:
typ table.Type typ table.Type
comment Comment comment Comment
} }
@ -156,7 +156,7 @@ pub:
is_c bool is_c bool
is_js bool is_js bool
is_union bool is_union bool
attr string attr string
} }
pub struct InterfaceDecl { pub struct InterfaceDecl {
@ -164,7 +164,7 @@ pub:
name string name string
field_names []string field_names []string
methods []FnDecl methods []FnDecl
pos token.Position pos token.Position
} }
pub struct StructInitField { pub struct StructInitField {
@ -310,7 +310,7 @@ pub:
global_scope &Scope global_scope &Scope
pub mut: pub mut:
imports []Import imports []Import
errors []errors.Error errors []errors.Error
warnings []errors.Warning warnings []errors.Warning
} }
@ -510,7 +510,6 @@ pub:
pos token.Position pos token.Position
} }
*/ */
// #include etc // #include etc
pub struct HashStmt { pub struct HashStmt {
pub: pub:
@ -562,7 +561,7 @@ pub mut:
} }
pub struct EnumField { pub struct EnumField {
pub: pub:
name string name string
pos token.Position pos token.Position
expr Expr expr Expr
@ -756,7 +755,7 @@ pub:
pub struct ConcatExpr { pub struct ConcatExpr {
pub: pub:
vals []Expr vals []Expr
pub mut: pub mut:
return_type table.Type return_type table.Type
} }
@ -878,47 +877,30 @@ pub fn (expr Expr) position() token.Position {
pub fn (stmt Stmt) position() token.Position { pub fn (stmt Stmt) position() token.Position {
match mut stmt { match mut stmt {
AssertStmt { AssertStmt { return it.pos }
return it.pos AssignStmt { return it.pos }
} /*
AssignStmt {
return it.pos
}
// Attr { // Attr {
// } // }
// Block { // Block {
// } // }
// BranchStmt { // BranchStmt {
// } // }
Comment { */
return it.pos Comment { return it.pos }
} CompIf { return it.pos }
CompIf { ConstDecl { return it.pos }
return it.pos /*
}
ConstDecl {
return it.pos
}
// DeferStmt { // DeferStmt {
// } // }
EnumDecl { */
return it.pos EnumDecl { return it.pos }
} ExprStmt { return it.pos }
ExprStmt { FnDecl { return it.pos }
return it.pos ForCStmt { return it.pos }
} ForInStmt { return it.pos }
FnDecl { ForStmt { return it.pos }
return it.pos /*
}
ForCStmt {
return it.pos
}
ForInStmt {
return it.pos
}
ForStmt {
return it.pos
}
// GlobalDecl { // GlobalDecl {
// } // }
// GoStmt { // GoStmt {
@ -929,26 +911,23 @@ pub fn (stmt Stmt) position() token.Position {
// } // }
// HashStmt { // HashStmt {
// } // }
Import { */
return it.pos Import { return it.pos }
} /*
// InterfaceDecl { // InterfaceDecl {
// } // }
// Module { // Module {
// } // }
Return { */
return it.pos Return { return it.pos }
} StructDecl { return it.pos }
StructDecl { /*
return it.pos
}
// TypeDecl { // TypeDecl {
// } // }
// UnsafeStmt { // UnsafeStmt {
// } // }
else { */
return token.Position{} else { return token.Position{} }
}
} }
} }
@ -962,6 +941,7 @@ pub fn fe2ex(x table.FExpr) Expr {
C.memcpy(&res, &x, sizeof(Expr)) C.memcpy(&res, &x, sizeof(Expr))
return res return res
} }
pub fn ex2fe(x Expr) table.FExpr { pub fn ex2fe(x Expr) table.FExpr {
res := table.FExpr{} res := table.FExpr{}
C.memcpy(&res, &x, sizeof(table.FExpr)) C.memcpy(&res, &x, sizeof(table.FExpr))