-
Notifications
You must be signed in to change notification settings - Fork 7
/
operators.go
41 lines (32 loc) · 1022 Bytes
/
operators.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
// Copyright 2010 The postscript-go Authors. All rights reserved.
// created: 13/12/2010 by Laurent Le Goff
package ps
type OperatorFunc func(interpreter *Interpreter)
type PrimitiveOperator struct {
f OperatorFunc
}
func NewOperator(f OperatorFunc) *PrimitiveOperator {
return &PrimitiveOperator{f}
}
func (o *PrimitiveOperator) Execute(interpreter *Interpreter) {
o.f(interpreter)
}
func save(interpreter *Interpreter) {
interpreter.Push("VM Snapshot")
}
func restore(interpreter *Interpreter) {
interpreter.Pop()
}
func initSystemOperators(interpreter *Interpreter) {
interpreter.SystemDefine("save", NewOperator(save))
interpreter.SystemDefine("restore", NewOperator(restore))
initStackOperator(interpreter)
initMathOperators(interpreter)
initArrayOperators(interpreter)
initDictionaryOperators(interpreter)
initRelationalOperators(interpreter)
initControlOperators(interpreter)
initMiscellaneousOperators(interpreter)
initDrawingOperators(interpreter)
initConflictingOperators(interpreter)
}