2010-12-13 12:01:24 +00:00
|
|
|
// Copyright 2010 The postscript-go Authors. All rights reserved.
|
|
|
|
// created: 13/12/2010 by Laurent Le Goff
|
|
|
|
|
2010-12-13 08:59:26 +00:00
|
|
|
package postscript
|
|
|
|
|
|
|
|
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) {
|
2010-12-13 19:13:10 +00:00
|
|
|
interpreter.Push("VM Snapshot")
|
2010-12-13 08:59:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func restore(interpreter *Interpreter) {
|
2010-12-13 19:13:10 +00:00
|
|
|
interpreter.Pop()
|
2010-12-13 08:59:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func initSystemOperators(interpreter *Interpreter) {
|
|
|
|
interpreter.SystemDefine("save", NewOperator(save))
|
|
|
|
interpreter.SystemDefine("restore", NewOperator(restore))
|
|
|
|
initStackOperator(interpreter)
|
|
|
|
initMathOperators(interpreter)
|
2010-12-13 19:13:10 +00:00
|
|
|
initArrayOperators(interpreter)
|
2010-12-13 08:59:26 +00:00
|
|
|
initDictionaryOperators(interpreter)
|
|
|
|
initRelationalOperators(interpreter)
|
|
|
|
initControlOperators(interpreter)
|
2010-12-13 19:13:10 +00:00
|
|
|
initMiscellaneousOperators(interpreter)
|
2010-12-13 08:59:26 +00:00
|
|
|
initDrawingOperators(interpreter)
|
2010-12-13 19:13:10 +00:00
|
|
|
|
|
|
|
initConflictingOperators(interpreter)
|
2010-12-13 08:59:26 +00:00
|
|
|
}
|