compiler: support panic in source

In situations where VM's FAULT state needs to be reached,
panic function can be used. It compiles to THROW instruction.
This commit is contained in:
Evgenii Stratonikov 2020-01-28 17:18:38 +03:00
parent a839efb35e
commit d2326a8b96
3 changed files with 89 additions and 0 deletions

View file

@ -16,6 +16,7 @@ var (
"SHA1", "Hash256", "Hash160",
"VerifySignature", "AppCall",
"FromAddress", "Equals",
"panic",
}
)
@ -69,6 +70,12 @@ func isIdentBool(ident *ast.Ident) bool {
return ident.Name == "true" || ident.Name == "false"
}
// isExprNil looks if the given expression is a `nil`.
func isExprNil(e ast.Expr) bool {
v, ok := e.(*ast.Ident)
return ok && v.Name == "nil"
}
// makeBoolFromIdent creates a bool type from an *ast.Ident.
func makeBoolFromIdent(ident *ast.Ident, tinfo *types.Info) (types.TypeAndValue, error) {
var b bool