From 500caaeda74dd9c660279036293f4b2997cf0b03 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sat, 9 Sep 2017 09:42:37 +0200 Subject: Add vendor --- vendor/github.com/llgcode/ps/operators_misc.go | 38 ++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 vendor/github.com/llgcode/ps/operators_misc.go (limited to 'vendor/github.com/llgcode/ps/operators_misc.go') diff --git a/vendor/github.com/llgcode/ps/operators_misc.go b/vendor/github.com/llgcode/ps/operators_misc.go new file mode 100644 index 0000000..2971d06 --- /dev/null +++ b/vendor/github.com/llgcode/ps/operators_misc.go @@ -0,0 +1,38 @@ +// Copyright 2010 The postscript-go Authors. All rights reserved. +// created: 13/12/2010 by Laurent Le Goff + +// Miscellaneous Operators +package ps + +//proc bind proc Replace operator names in proc with operators; perform idiom recognition +func bind(interpreter *Interpreter) { + pdef := interpreter.PopProcedureDefinition() + values := make([]Value, len(pdef.Values)) + for i, value := range pdef.Values { + if s, ok := value.(string); ok { + firstChar := s[0] + if firstChar != '(' && firstChar != '/' { + v, _ := interpreter.FindValueInDictionaries(s) + operator, isOperator := v.(Operator) + if v == nil { + // log.Printf("Can't find def: %s\n", s) + } + if isOperator { + values[i] = operator + } else { + values[i] = value + } + } else { + values[i] = value + } + } else { + values[i] = value + } + } + pdef.Values = values + interpreter.Push(pdef) +} + +func initMiscellaneousOperators(interpreter *Interpreter) { + interpreter.SystemDefine("bind", NewOperator(bind)) +} -- cgit v1.2.3