20 lines
369 B
Go
20 lines
369 B
Go
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
|
|
}
|