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

all: add UnsafeExpr (#5793)

This commit is contained in:
Nick Treleaven
2020-07-12 11:58:33 +01:00
committed by GitHub
parent cad816a19d
commit 53023c1ca9
9 changed files with 78 additions and 2 deletions

View File

@ -13,7 +13,7 @@ pub type Expr = AnonFn | ArrayInit | AsCast | Assoc | BoolLiteral | CallExpr | C
CharLiteral | ComptimeCall | ConcatExpr | EnumVal | FloatLiteral | Ident | IfExpr | IfGuardExpr |
IndexExpr | InfixExpr | IntegerLiteral | Likely | LockExpr | MapInit | MatchExpr | None |
OrExpr | ParExpr | PostfixExpr | PrefixExpr | RangeExpr | SelectorExpr | SizeOf | SqlExpr |
StringInterLiteral | StringLiteral | StructInit | Type | TypeOf
StringInterLiteral | StringLiteral | StructInit | Type | TypeOf | UnsafeExpr
pub type Stmt = AssertStmt | AssignStmt | Attr | Block | BranchStmt | Comment | CompFor |
CompIf | ConstDecl | DeferStmt | EnumDecl | ExprStmt | FnDecl | ForCStmt | ForInStmt |
@ -446,6 +446,12 @@ pub mut:
left_as_name string // only used in x is SumType check
}
pub struct UnsafeExpr {
pub:
stmts []Stmt
pos token.Position
}
pub struct LockExpr {
pub:
stmts []Stmt

View File

@ -254,6 +254,9 @@ pub fn (x Expr) str() string {
Likely {
return '_likely_(${it.expr.str()})'
}
UnsafeExpr {
return 'unsafe { $it.stmts.len stmts }'
}
else {
return '[unhandled expr type ${typeof(x)}]'
}