-
Notifications
You must be signed in to change notification settings - Fork 0
/
os.go
75 lines (59 loc) · 1.38 KB
/
os.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package os
import (
"os"
"strconv"
qlang "qlang.io/spec"
)
// -----------------------------------------------------------------------------
// Exports is the export table of this module.
//
var Exports = map[string]interface{}{
"_name": "os",
"_initSafe": _initSafe,
"args": os.Args[1:],
"stdin": os.Stdin,
"stderr": os.Stderr,
"stdout": os.Stdout,
"getenv": os.Getenv,
"open": os.Open,
"create": os.Create,
"exit": os.Exit,
"Args": os.Args[1:],
"Stdin": os.Stdin,
"Stderr": os.Stderr,
"Stdout": os.Stdout,
"Getenv": os.Getenv,
"Open": os.Open,
"Create": os.Create,
"Exit": os.Exit,
}
func _initSafe(mod qlang.Module) {
mod.Disable("open")
mod.Disable("getenv")
mod.Exports["exit"] = SafeExit
mod.Disable("Open")
mod.Disable("Getenv")
mod.Exports["Exit"] = SafeExit
}
// SafeExit is a safe way to quit qlang application.
//
func SafeExit(code int) {
panic("exit " + strconv.Itoa(code))
}
// -----------------------------------------------------------------------------
func exit() {
os.Exit(0)
}
func safeExit() {
panic("exit")
}
func _initSafe2(mod qlang.Module) {
mod.Exports["exit"] = safeExit
}
// InlineExports is the export table of this module.
//
var InlineExports = map[string]interface{}{
"exit": exit,
"_initSafe": _initSafe2,
}
// -----------------------------------------------------------------------------