rearrange builtins
This commit is contained in:
19
builtins/exit.go
Normal file
19
builtins/exit.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package builtins
|
||||
|
||||
import "monkey/object"
|
||||
|
||||
// Exit ...
|
||||
func Exit(args ...object.Object) object.Object {
|
||||
var status int
|
||||
if len(args) == 1 {
|
||||
if args[0].Type() != object.INTEGER_OBJ {
|
||||
return newError("argument to `exit` must be INTEGER, got %s",
|
||||
args[0].Type())
|
||||
}
|
||||
status = int(args[0].(*object.Integer).Value)
|
||||
}
|
||||
|
||||
object.ExitFunction(status)
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user