ast: minor code cleanup (#6608)
parent
da7d531f8f
commit
57d705e265
156
vlib/v/ast/ast.v
156
vlib/v/ast/ast.v
|
@ -987,45 +987,11 @@ pub fn (expr Expr) position() token.Position {
|
||||||
AnonFn {
|
AnonFn {
|
||||||
return expr.decl.pos
|
return expr.decl.pos
|
||||||
}
|
}
|
||||||
ArrayInit {
|
ArrayInit, AsCast, Assoc, BoolLiteral, CallExpr, CastExpr, CharLiteral,
|
||||||
return expr.pos
|
Comment, EnumVal, FloatLiteral, Ident, IfExpr, IndexExpr,
|
||||||
}
|
IntegerLiteral, MapInit, MatchExpr, None, PostfixExpr, PrefixExpr,
|
||||||
AsCast {
|
SelectExpr, SelectorExpr, SizeOf, StringLiteral, StringInterLiteral,
|
||||||
return expr.pos
|
StructInit, Likely {
|
||||||
}
|
|
||||||
Assoc {
|
|
||||||
return expr.pos
|
|
||||||
}
|
|
||||||
BoolLiteral {
|
|
||||||
return expr.pos
|
|
||||||
}
|
|
||||||
// ast.Ident { }
|
|
||||||
CallExpr {
|
|
||||||
return expr.pos
|
|
||||||
}
|
|
||||||
CastExpr {
|
|
||||||
return expr.pos
|
|
||||||
}
|
|
||||||
CharLiteral {
|
|
||||||
return expr.pos
|
|
||||||
}
|
|
||||||
Comment {
|
|
||||||
return expr.pos
|
|
||||||
}
|
|
||||||
EnumVal {
|
|
||||||
return expr.pos
|
|
||||||
}
|
|
||||||
FloatLiteral {
|
|
||||||
return expr.pos
|
|
||||||
}
|
|
||||||
Ident {
|
|
||||||
return expr.pos
|
|
||||||
}
|
|
||||||
IfExpr {
|
|
||||||
return expr.pos
|
|
||||||
}
|
|
||||||
// ast.IfGuardExpr { }
|
|
||||||
IndexExpr {
|
|
||||||
return expr.pos
|
return expr.pos
|
||||||
}
|
}
|
||||||
InfixExpr {
|
InfixExpr {
|
||||||
|
@ -1040,49 +1006,14 @@ pub fn (expr Expr) position() token.Position {
|
||||||
len: right_pos.pos - left_pos.pos + right_pos.len
|
len: right_pos.pos - left_pos.pos + right_pos.len
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IntegerLiteral {
|
/*
|
||||||
return expr.pos
|
ast.Ident {}
|
||||||
}
|
ast.IfGuardExpr {}
|
||||||
MapInit {
|
ast.None {}
|
||||||
return expr.pos
|
ast.ParExpr {}
|
||||||
}
|
ast.Type {}
|
||||||
MatchExpr {
|
ast.TypeOf {}
|
||||||
return expr.pos
|
*/
|
||||||
}
|
|
||||||
None {
|
|
||||||
return expr.pos
|
|
||||||
}
|
|
||||||
PostfixExpr {
|
|
||||||
return expr.pos
|
|
||||||
}
|
|
||||||
// ast.None { }
|
|
||||||
PrefixExpr {
|
|
||||||
return expr.pos
|
|
||||||
}
|
|
||||||
// ast.ParExpr { }
|
|
||||||
SelectExpr {
|
|
||||||
return expr.pos
|
|
||||||
}
|
|
||||||
SelectorExpr {
|
|
||||||
return expr.pos
|
|
||||||
}
|
|
||||||
SizeOf {
|
|
||||||
return expr.pos
|
|
||||||
}
|
|
||||||
StringLiteral {
|
|
||||||
return expr.pos
|
|
||||||
}
|
|
||||||
StringInterLiteral {
|
|
||||||
return expr.pos
|
|
||||||
}
|
|
||||||
// ast.Type { }
|
|
||||||
StructInit {
|
|
||||||
return expr.pos
|
|
||||||
}
|
|
||||||
Likely {
|
|
||||||
return expr.pos
|
|
||||||
}
|
|
||||||
// ast.TypeOf { }
|
|
||||||
else {
|
else {
|
||||||
return token.Position{}
|
return token.Position{}
|
||||||
}
|
}
|
||||||
|
@ -1123,54 +1054,23 @@ pub fn (stmt Stmt) check_c_expr()? {
|
||||||
|
|
||||||
pub fn (stmt Stmt) position() token.Position {
|
pub fn (stmt Stmt) position() token.Position {
|
||||||
match stmt {
|
match stmt {
|
||||||
AssertStmt { return stmt.pos }
|
AssertStmt, AssignStmt, Block, ConstDecl, EnumDecl, ExprStmt, FnDecl,
|
||||||
AssignStmt { return stmt.pos }
|
ForCStmt, ForInStmt, ForStmt, Import, Return, StructDecl {
|
||||||
|
return stmt.pos
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
// Attr {
|
Attr {}
|
||||||
// }
|
BranchStmt {}
|
||||||
|
DeferStmt {}
|
||||||
|
GlobalDecl {}
|
||||||
|
GoStmt {}
|
||||||
|
GotoLabel {}
|
||||||
|
GotoStmt {}
|
||||||
|
HashStmt {}
|
||||||
|
InterfaceDecl {}
|
||||||
|
Module {}
|
||||||
|
TypeDecl {}
|
||||||
*/
|
*/
|
||||||
Block { return stmt.pos }
|
|
||||||
/*
|
|
||||||
// BranchStmt {
|
|
||||||
// }
|
|
||||||
*/
|
|
||||||
ConstDecl { return stmt.pos }
|
|
||||||
/*
|
|
||||||
// DeferStmt {
|
|
||||||
// }
|
|
||||||
*/
|
|
||||||
EnumDecl { return stmt.pos }
|
|
||||||
ExprStmt { return stmt.pos }
|
|
||||||
FnDecl { return stmt.pos }
|
|
||||||
ForCStmt { return stmt.pos }
|
|
||||||
ForInStmt { return stmt.pos }
|
|
||||||
ForStmt { return stmt.pos }
|
|
||||||
/*
|
|
||||||
// GlobalDecl {
|
|
||||||
// }
|
|
||||||
// GoStmt {
|
|
||||||
// }
|
|
||||||
// GotoLabel {
|
|
||||||
// }
|
|
||||||
// GotoStmt {
|
|
||||||
// }
|
|
||||||
// HashStmt {
|
|
||||||
// }
|
|
||||||
*/
|
|
||||||
Import { return stmt.pos }
|
|
||||||
/*
|
|
||||||
// InterfaceDecl {
|
|
||||||
// }
|
|
||||||
// Module {
|
|
||||||
// }
|
|
||||||
*/
|
|
||||||
Return { return stmt.pos }
|
|
||||||
StructDecl { return stmt.pos }
|
|
||||||
/*
|
|
||||||
// TypeDecl {
|
|
||||||
// }
|
|
||||||
*/
|
|
||||||
//
|
|
||||||
else { return token.Position{} }
|
else { return token.Position{} }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue