-
Notifications
You must be signed in to change notification settings - Fork 0
/
opcodes.go
90 lines (86 loc) · 2.63 KB
/
opcodes.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package vesper
const (
opNone = iota
opLiteral
opLocal
opJumpFalse
opJump
opTailCall
opCall
opReturn
opClosure
opPop
opGlobal
opDefGlobal
opSetLocal
opUse
opDefMacro
opArray
opStruct
opUndefGlobal
opCount
)
var (
// NoneSymbol represents a nil operation
NoneSymbol = defaultVM.Intern("none")
// LiteralSymbol represents a bytecode for a literal
LiteralSymbol = defaultVM.Intern("literal")
// LocalSymbol represents bytecode for a local variable
LocalSymbol = defaultVM.Intern("local")
// JumpfalseSymbol represents a jump on false
JumpfalseSymbol = defaultVM.Intern("jumpfalse")
// JumpSymbol represents an unconditional jump
JumpSymbol = defaultVM.Intern("jump")
// TailcallSymbol represents a tailcall operation
TailcallSymbol = defaultVM.Intern("tailcall")
// CallSymbol represents a function call
CallSymbol = defaultVM.Intern("call")
// ReturnSymbol represents a return from the current function
ReturnSymbol = defaultVM.Intern("return")
// ClosureSymbol represents the creation of a closure
ClosureSymbol = defaultVM.Intern("closure")
// PopSymbol represents the pop operation
PopSymbol = defaultVM.Intern("pop")
// GlobalSymbol represents a reference to a global
GlobalSymbol = defaultVM.Intern("global")
// DefglobalSymbol represents the definition of a global symbol
DefglobalSymbol = defaultVM.Intern("defglobal")
// SetlocalSymbol represents setting a local varioble
SetlocalSymbol = defaultVM.Intern("setlocal")
// UseSymbol represents the "use" of a module
UseSymbol = defaultVM.Intern("use")
// DefmacroSymbol represents a macro definition
DefmacroSymbol = defaultVM.Intern("defmacro")
// ArraySymbol represents the creation of a literal array
ArraySymbol = defaultVM.Intern("array")
// StructSymbol represents creation of a literal struct
StructSymbol = defaultVM.Intern("struct")
// UndefineSymbol represents an undefine operation
UndefineSymbol = defaultVM.Intern("undefine")
// FuncSymbol represents a function definition
FuncSymbol = defaultVM.Intern("func")
)
var opsyms = initOpsyms()
func initOpsyms() []*Object {
syms := []*Object{
opNone: NoneSymbol,
opLiteral: LiteralSymbol,
opLocal: LocalSymbol,
opJumpFalse: JumpfalseSymbol,
opJump: JumpSymbol,
opTailCall: TailcallSymbol,
opCall: CallSymbol,
opReturn: ReturnSymbol,
opClosure: ClosureSymbol,
opPop: PopSymbol,
opGlobal: GlobalSymbol,
opDefGlobal: DefglobalSymbol,
opSetLocal: SetlocalSymbol,
opUse: UseSymbol,
opDefMacro: DefmacroSymbol,
opArray: ArraySymbol,
opStruct: StructSymbol,
opUndefGlobal: UndefineSymbol,
}
return syms
}