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