aboutsummaryrefslogtreecommitdiffstats
path: root/Godeps/_workspace/src/github.com/robertkrimen/otto
diff options
context:
space:
mode:
Diffstat (limited to 'Godeps/_workspace/src/github.com/robertkrimen/otto')
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/.gitignore5
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/DESIGN.markdown1
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/LICENSE7
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/Makefile63
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/README.markdown825
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/array_test.go716
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/bug_test.go617
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/builtin.go353
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_array.go672
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_boolean.go28
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_date.go615
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_error.go126
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_function.go129
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_json.go299
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_math.go145
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_number.go93
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_object.go289
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_regexp.go65
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_string.go500
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_test.go136
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/clone.go155
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/cmpl.go24
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/cmpl_evaluate.go96
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/cmpl_evaluate_expression.go456
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/cmpl_evaluate_statement.go421
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/cmpl_parse.go650
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/cmpl_test.go54
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/console.go51
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/date_test.go481
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/dbg.go9
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/documentation_test.go95
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/error.go245
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/error_test.go192
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/evaluate.go318
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/function_test.go280
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/global.go221
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/global_test.go355
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/inline1086
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/inline.go6649
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/json_test.go183
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/math_test.go303
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/number_test.go165
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/object.go156
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/object_class.go493
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/object_test.go639
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/otto.go578
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/otto/Makefile5
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/otto/main.go48
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/otto_.go178
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/otto_error_test.go48
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/otto_test.go1379
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/panic_test.go40
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/parser_test.go42
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/property.go220
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/reflect_test.go483
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/regexp_test.go290
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/result.go30
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/runtime.go331
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/runtime_test.go778
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/scope.go34
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/script.go122
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/script_test.go78
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/stash.go275
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/string_test.go365
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/terst/terst.go669
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/test/Makefile26
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/test/tester.go196
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/testing_test.go135
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/type_arguments.go106
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/type_array.go109
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/type_boolean.go13
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/type_date.go299
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/type_error.go13
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/type_function.go262
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/type_go_array.go134
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/type_go_map.go87
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/type_go_slice.go118
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/type_go_struct.go146
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/type_number.go5
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/type_reference.go103
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/type_regexp.go146
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/type_string.go112
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/underscore/Makefile11
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/underscore/README.markdown53
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/underscore/source.go3462
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/underscore/testify84
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/underscore/underscore.go49
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/underscore_arrays_test.go344
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/underscore_chaining_test.go95
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/underscore_collections_test.go698
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/underscore_functions_test.go208
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/underscore_objects_test.go826
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/underscore_test.go165
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/underscore_utility_test.go419
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/value.go989
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/value_boolean.go40
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/value_number.go324
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/value_primitive.go23
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/value_string.go103
-rw-r--r--Godeps/_workspace/src/github.com/robertkrimen/otto/value_test.go281
100 files changed, 35638 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/.gitignore b/Godeps/_workspace/src/github.com/robertkrimen/otto/.gitignore
new file mode 100644
index 000000000..8c2a16949
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/.gitignore
@@ -0,0 +1,5 @@
+/.test
+/otto/otto
+/otto/otto-*
+/test/test-*.js
+/test/tester
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/DESIGN.markdown b/Godeps/_workspace/src/github.com/robertkrimen/otto/DESIGN.markdown
new file mode 100644
index 000000000..288752987
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/DESIGN.markdown
@@ -0,0 +1 @@
+* Designate the filename of "anonymous" source code by the hash (md5/sha1, etc.)
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/LICENSE b/Godeps/_workspace/src/github.com/robertkrimen/otto/LICENSE
new file mode 100644
index 000000000..b6179fe38
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/LICENSE
@@ -0,0 +1,7 @@
+Copyright (c) 2012 Robert Krimen
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/Makefile b/Godeps/_workspace/src/github.com/robertkrimen/otto/Makefile
new file mode 100644
index 000000000..8d74038eb
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/Makefile
@@ -0,0 +1,63 @@
+.PHONY: test test-race test-release release release-check test-262
+.PHONY: parser
+.PHONY: otto assets underscore
+
+TESTS := \
+ ~
+
+TEST := -v --run
+TEST := -v
+TEST := -v --run Test\($(subst $(eval) ,\|,$(TESTS))\)
+TEST := .
+
+test: parser inline.go
+ go test -i
+ go test $(TEST)
+ @echo PASS
+
+parser:
+ $(MAKE) -C parser
+
+inline.go: inline
+ ./$< > $@
+
+#################
+# release, test #
+#################
+
+release: test-race test-release
+ for package in . parser token ast file underscore registry; do (cd $$package && godocdown --signature > README.markdown); done
+ @echo \*\*\* make release-check
+ @echo PASS
+
+release-check: .test
+ $(MAKE) -C test build test
+ $(MAKE) -C .test/test262 build test
+ @echo PASS
+
+test-262: .test
+ $(MAKE) -C .test/test262 build test
+ @echo PASS
+
+test-release:
+ go test -i
+ go test
+
+test-race:
+ go test -race -i
+ go test -race
+
+#################################
+# otto, assets, underscore, ... #
+#################################
+
+otto:
+ $(MAKE) -C otto
+
+assets:
+ mkdir -p .assets
+ for file in underscore/test/*.js; do tr "\`" "_" < $$file > .assets/`basename $$file`; done
+
+underscore:
+ $(MAKE) -C $@
+
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/README.markdown b/Godeps/_workspace/src/github.com/robertkrimen/otto/README.markdown
new file mode 100644
index 000000000..571743bf1
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/README.markdown
@@ -0,0 +1,825 @@
+# otto
+--
+ import "github.com/robertkrimen/otto"
+
+Package otto is a JavaScript parser and interpreter written natively in Go.
+
+http://godoc.org/github.com/robertkrimen/otto
+
+ import (
+ "github.com/robertkrimen/otto"
+ )
+
+Run something in the VM
+
+ vm := otto.New()
+ vm.Run(`
+ abc = 2 + 2;
+ console.log("The value of abc is " + abc); // 4
+ `)
+
+Get a value out of the VM
+
+ value, err := vm.Get("abc")
+ value, _ := value.ToInteger()
+ }
+
+Set a number
+
+ vm.Set("def", 11)
+ vm.Run(`
+ console.log("The value of def is " + def);
+ // The value of def is 11
+ `)
+
+Set a string
+
+ vm.Set("xyzzy", "Nothing happens.")
+ vm.Run(`
+ console.log(xyzzy.length); // 16
+ `)
+
+Get the value of an expression
+
+ value, _ = vm.Run("xyzzy.length")
+ {
+ // value is an int64 with a value of 16
+ value, _ := value.ToInteger()
+ }
+
+An error happens
+
+ value, err = vm.Run("abcdefghijlmnopqrstuvwxyz.length")
+ if err != nil {
+ // err = ReferenceError: abcdefghijlmnopqrstuvwxyz is not defined
+ // If there is an error, then value.IsUndefined() is true
+ ...
+ }
+
+Set a Go function
+
+ vm.Set("sayHello", func(call otto.FunctionCall) otto.Value {
+ fmt.Printf("Hello, %s.\n", call.Argument(0).String())
+ return otto.Value{}
+ })
+
+Set a Go function that returns something useful
+
+ vm.Set("twoPlus", func(call otto.FunctionCall) otto.Value {
+ right, _ := call.Argument(0).ToInteger()
+ result, _ := vm.ToValue(2 + right)
+ return result
+ })
+
+Use the functions in JavaScript
+
+ result, _ = vm.Run(`
+ sayHello("Xyzzy"); // Hello, Xyzzy.
+ sayHello(); // Hello, undefined
+
+ result = twoPlus(2.0); // 4
+ `)
+
+
+### Parser
+
+A separate parser is available in the parser package if you're just interested
+in building an AST.
+
+http://godoc.org/github.com/robertkrimen/otto/parser
+
+Parse and return an AST
+
+ filename := "" // A filename is optional
+ src := `
+ // Sample xyzzy example
+ (function(){
+ if (3.14159 > 0) {
+ console.log("Hello, World.");
+ return;
+ }
+
+ var xyzzy = NaN;
+ console.log("Nothing happens.");
+ return xyzzy;
+ })();
+ `
+
+ // Parse some JavaScript, yielding a *ast.Program and/or an ErrorList
+ program, err := parser.ParseFile(nil, filename, src, 0)
+
+### otto
+
+You can run (Go) JavaScript from the commandline with:
+http://github.com/robertkrimen/otto/tree/master/otto
+
+ $ go get -v github.com/robertkrimen/otto/otto
+
+Run JavaScript by entering some source on stdin or by giving otto a filename:
+
+ $ otto example.js
+
+### underscore
+
+Optionally include the JavaScript utility-belt library, underscore, with this
+import:
+
+ import (
+ "github.com/robertkrimen/otto"
+ _ "github.com/robertkrimen/otto/underscore"
+ )
+
+ // Now every otto runtime will come loaded with underscore
+
+For more information: http://github.com/robertkrimen/otto/tree/master/underscore
+
+
+### Caveat Emptor
+
+The following are some limitations with otto:
+
+ * "use strict" will parse, but does nothing.
+ * The regular expression engine (re2/regexp) is not fully compatible with the ECMA5 specification.
+
+
+### Regular Expression Incompatibility
+
+Go translates JavaScript-style regular expressions into something that is
+"regexp" compatible via `parser.TransformRegExp`. Unfortunately, RegExp requires
+backtracking for some patterns, and backtracking is not supported by the
+standard Go engine: https://code.google.com/p/re2/wiki/Syntax
+
+Therefore, the following syntax is incompatible:
+
+ (?=) // Lookahead (positive), currently a parsing error
+ (?!) // Lookahead (backhead), currently a parsing error
+ \1 // Backreference (\1, \2, \3, ...), currently a parsing error
+
+A brief discussion of these limitations: "Regexp (?!re)"
+https://groups.google.com/forum/?fromgroups=#%21topic/golang-nuts/7qgSDWPIh_E
+
+More information about re2: https://code.google.com/p/re2/
+
+In addition to the above, re2 (Go) has a different definition for \s: [\t\n\f\r
+]. The JavaScript definition, on the other hand, also includes \v, Unicode
+"Separator, Space", etc.
+
+
+### Halting Problem
+
+If you want to stop long running executions (like third-party code), you can use
+the interrupt channel to do this:
+
+ package main
+
+ import (
+ "errors"
+ "fmt"
+ "os"
+ "time"
+
+ "github.com/robertkrimen/otto"
+ )
+
+ var halt = errors.New("Stahp")
+
+ func main() {
+ runUnsafe(`var abc = [];`)
+ runUnsafe(`
+ while (true) {
+ // Loop forever
+ }`)
+ }
+
+ func runUnsafe(unsafe string) {
+ start := time.Now()
+ defer func() {
+ duration := time.Since(start)
+ if caught := recover(); caught != nil {
+ if caught == halt {
+ fmt.Fprintf(os.Stderr, "Some code took to long! Stopping after: %v\n", duration)
+ return
+ }
+ panic(caught) // Something else happened, repanic!
+ }
+ fmt.Fprintf(os.Stderr, "Ran code successfully: %v\n", duration)
+ }()
+
+ vm := otto.New()
+ vm.Interrupt = make(chan func(), 1) // The buffer prevents blocking
+
+ go func() {
+ time.Sleep(2 * time.Second) // Stop after two seconds
+ vm.Interrupt <- func() {
+ panic(halt)
+ }
+ }()
+
+ vm.Run(unsafe) // Here be dragons (risky code)
+ }
+
+Where is setTimeout/setInterval?
+
+These timing functions are not actually part of the ECMA-262 specification.
+Typically, they belong to the `windows` object (in the browser). It would not be
+difficult to provide something like these via Go, but you probably want to wrap
+otto in an event loop in that case.
+
+For an example of how this could be done in Go with otto, see natto:
+
+http://github.com/robertkrimen/natto
+
+Here is some more discussion of the issue:
+
+* http://book.mixu.net/node/ch2.html
+
+* http://en.wikipedia.org/wiki/Reentrancy_%28computing%29
+
+* http://aaroncrane.co.uk/2009/02/perl_safe_signals/
+
+## Usage
+
+```go
+var ErrVersion = errors.New("version mismatch")
+```
+
+#### type Error
+
+```go
+type Error struct {
+}
+```
+
+An Error represents a runtime error, e.g. a TypeError, a ReferenceError, etc.
+
+#### func (Error) Error
+
+```go
+func (err Error) Error() string
+```
+Error returns a description of the error
+
+ TypeError: 'def' is not a function
+
+#### func (Error) String
+
+```go
+func (err Error) String() string
+```
+String returns a description of the error and a trace of where the error
+occurred.
+
+ TypeError: 'def' is not a function
+ at xyz (<anonymous>:3:9)
+ at <anonymous>:7:1/
+
+#### type FunctionCall
+
+```go
+type FunctionCall struct {
+ This Value
+ ArgumentList []Value
+ Otto *Otto
+}
+```
+
+FunctionCall is an encapsulation of a JavaScript function call.
+
+#### func (FunctionCall) Argument
+
+```go
+func (self FunctionCall) Argument(index int) Value
+```
+Argument will return the value of the argument at the given index.
+
+If no such argument exists, undefined is returned.
+
+#### type Object
+
+```go
+type Object struct {
+}
+```
+
+Object is the representation of a JavaScript object.
+
+#### func (Object) Call
+
+```go
+func (self Object) Call(name string, argumentList ...interface{}) (Value, error)
+```
+Call a method on the object.
+
+It is essentially equivalent to:
+
+ var method, _ := object.Get(name)
+ method.Call(object, argumentList...)
+
+An undefined value and an error will result if:
+
+ 1. There is an error during conversion of the argument list
+ 2. The property is not actually a function
+ 3. An (uncaught) exception is thrown
+
+#### func (Object) Class
+
+```go
+func (self Object) Class() string
+```
+Class will return the class string of the object.
+
+The return value will (generally) be one of:
+
+ Object
+ Function
+ Array
+ String
+ Number
+ Boolean
+ Date
+ RegExp
+
+#### func (Object) Get
+
+```go
+func (self Object) Get(name string) (Value, error)
+```
+Get the value of the property with the given name.
+
+#### func (Object) Keys
+
+```go
+func (self Object) Keys() []string
+```
+Get the keys for the object
+
+Equivalent to calling Object.keys on the object
+
+#### func (Object) Set
+
+```go
+func (self Object) Set(name string, value interface{}) error
+```
+Set the property of the given name to the given value.
+
+An error will result if the setting the property triggers an exception (i.e.
+read-only), or there is an error during conversion of the given value.
+
+#### func (Object) Value
+
+```go
+func (self Object) Value() Value
+```
+Value will return self as a value.
+
+#### type Otto
+
+```go
+type Otto struct {
+ // Interrupt is a channel for interrupting the runtime. You can use this to halt a long running execution, for example.
+ // See "Halting Problem" for more information.
+ Interrupt chan func()
+}
+```
+
+Otto is the representation of the JavaScript runtime. Each instance of Otto has
+a self-contained namespace.
+
+#### func New
+
+```go
+func New() *Otto
+```
+New will allocate a new JavaScript runtime
+
+#### func Run
+
+```go
+func Run(src interface{}) (*Otto, Value, error)
+```
+Run will allocate a new JavaScript runtime, run the given source on the
+allocated runtime, and return the runtime, resulting value, and error (if any).
+
+src may be a string, a byte slice, a bytes.Buffer, or an io.Reader, but it MUST
+always be in UTF-8.
+
+src may also be a Script.
+
+src may also be a Program, but if the AST has been modified, then runtime
+behavior is undefined.
+
+#### func (Otto) Call
+
+```go
+func (self Otto) Call(source string, this interface{}, argumentList ...interface{}) (Value, error)
+```
+Call the given JavaScript with a given this and arguments.
+
+If this is nil, then some special handling takes place to determine the proper
+this value, falling back to a "standard" invocation if necessary (where this is
+undefined).
+
+If source begins with "new " (A lowercase new followed by a space), then Call
+will invoke the function constructor rather than performing a function call. In
+this case, the this argument has no effect.
+
+ // value is a String object
+ value, _ := vm.Call("Object", nil, "Hello, World.")
+
+ // Likewise...
+ value, _ := vm.Call("new Object", nil, "Hello, World.")
+
+ // This will perform a concat on the given array and return the result
+ // value is [ 1, 2, 3, undefined, 4, 5, 6, 7, "abc" ]
+ value, _ := vm.Call(`[ 1, 2, 3, undefined, 4 ].concat`, nil, 5, 6, 7, "abc")
+
+#### func (*Otto) Compile
+
+```go
+func (self *Otto) Compile(filename string, src interface{}) (*Script, error)
+```
+Compile will parse the given source and return a Script value or nil and an
+error if there was a problem during compilation.
+
+ script, err := vm.Compile("", `var abc; if (!abc) abc = 0; abc += 2; abc;`)
+ vm.Run(script)
+
+#### func (*Otto) Copy
+
+```go
+func (in *Otto) Copy() *Otto
+```
+Copy will create a copy/clone of the runtime.
+
+Copy is useful for saving some time when creating many similar runtimes.
+
+This method works by walking the original runtime and cloning each object,
+scope, stash, etc. into a new runtime.
+
+Be on the lookout for memory leaks or inadvertent sharing of resources.
+
+#### func (Otto) Get
+
+```go
+func (self Otto) Get(name string) (Value, error)
+```
+Get the value of the top-level binding of the given name.
+
+If there is an error (like the binding does not exist), then the value will be
+undefined.
+
+#### func (Otto) Object
+
+```go
+func (self Otto) Object(source string) (*Object, error)
+```
+Object will run the given source and return the result as an object.
+
+For example, accessing an existing object:
+
+ object, _ := vm.Object(`Number`)
+
+Or, creating a new object:
+
+ object, _ := vm.Object(`({ xyzzy: "Nothing happens." })`)
+
+Or, creating and assigning an object:
+
+ object, _ := vm.Object(`xyzzy = {}`)
+ object.Set("volume", 11)
+
+If there is an error (like the source does not result in an object), then nil
+and an error is returned.
+
+#### func (Otto) Run
+
+```go
+func (self Otto) Run(src interface{}) (Value, error)
+```
+Run will run the given source (parsing it first if necessary), returning the
+resulting value and error (if any)
+
+src may be a string, a byte slice, a bytes.Buffer, or an io.Reader, but it MUST
+always be in UTF-8.
+
+If the runtime is unable to parse source, then this function will return
+undefined and the parse error (nothing will be evaluated in this case).
+
+src may also be a Script.
+
+src may also be a Program, but if the AST has been modified, then runtime
+behavior is undefined.
+
+#### func (Otto) Set
+
+```go
+func (self Otto) Set(name string, value interface{}) error
+```
+Set the top-level binding of the given name to the given value.
+
+Set will automatically apply ToValue to the given value in order to convert it
+to a JavaScript value (type Value).
+
+If there is an error (like the binding is read-only, or the ToValue conversion
+fails), then an error is returned.
+
+If the top-level binding does not exist, it will be created.
+
+#### func (Otto) ToValue
+
+```go
+func (self Otto) ToValue(value interface{}) (Value, error)
+```
+ToValue will convert an interface{} value to a value digestible by
+otto/JavaScript.
+
+#### type Script
+
+```go
+type Script struct {
+}
+```
+
+Script is a handle for some (reusable) JavaScript. Passing a Script value to a
+run method will evaluate the JavaScript.
+
+#### func (*Script) String
+
+```go
+func (self *Script) String() string
+```
+
+#### type Value
+
+```go
+type Value struct {
+}
+```
+
+Value is the representation of a JavaScript value.
+
+#### func FalseValue
+
+```go
+func FalseValue() Value
+```
+FalseValue will return a value representing false.
+
+It is equivalent to:
+
+ ToValue(false)
+
+#### func NaNValue
+
+```go
+func NaNValue() Value
+```
+NaNValue will return a value representing NaN.
+
+It is equivalent to:
+
+ ToValue(math.NaN())
+
+#### func NullValue
+
+```go
+func NullValue() Value
+```
+NullValue will return a Value representing null.
+
+#### func ToValue
+
+```go
+func ToValue(value interface{}) (Value, error)
+```
+ToValue will convert an interface{} value to a value digestible by
+otto/JavaScript
+
+This function will not work for advanced types (struct, map, slice/array, etc.)
+and you should use Otto.ToValue instead.
+
+#### func TrueValue
+
+```go
+func TrueValue() Value
+```
+TrueValue will return a value representing true.
+
+It is equivalent to:
+
+ ToValue(true)
+
+#### func UndefinedValue
+
+```go
+func UndefinedValue() Value
+```
+UndefinedValue will return a Value representing undefined.
+
+#### func (Value) Call
+
+```go
+func (value Value) Call(this Value, argumentList ...interface{}) (Value, error)
+```
+Call the value as a function with the given this value and argument list and
+return the result of invocation. It is essentially equivalent to:
+
+ value.apply(thisValue, argumentList)
+
+An undefined value and an error will result if:
+
+ 1. There is an error during conversion of the argument list
+ 2. The value is not actually a function
+ 3. An (uncaught) exception is thrown
+
+#### func (Value) Class
+
+```go
+func (value Value) Class() string
+```
+Class will return the class string of the value or the empty string if value is
+not an object.
+
+The return value will (generally) be one of:
+
+ Object
+ Function
+ Array
+ String
+ Number
+ Boolean
+ Date
+ RegExp
+
+#### func (Value) Export
+
+```go
+func (self Value) Export() (interface{}, error)
+```
+Export will attempt to convert the value to a Go representation and return it
+via an interface{} kind.
+
+Export returns an error, but it will always be nil. It is present for backwards
+compatibility.
+
+If a reasonable conversion is not possible, then the original value is returned.
+
+ undefined -> nil (FIXME?: Should be Value{})
+ null -> nil
+ boolean -> bool
+ number -> A number type (int, float32, uint64, ...)
+ string -> string
+ Array -> []interface{}
+ Object -> map[string]interface{}
+
+#### func (Value) IsBoolean
+
+```go
+func (value Value) IsBoolean() bool
+```
+IsBoolean will return true if value is a boolean (primitive).
+
+#### func (Value) IsDefined
+
+```go
+func (value Value) IsDefined() bool
+```
+IsDefined will return false if the value is undefined, and true otherwise.
+
+#### func (Value) IsFunction
+
+```go
+func (value Value) IsFunction() bool
+```
+IsFunction will return true if value is a function.
+
+#### func (Value) IsNaN
+
+```go
+func (value Value) IsNaN() bool
+```
+IsNaN will return true if value is NaN (or would convert to NaN).
+
+#### func (Value) IsNull
+
+```go
+func (value Value) IsNull() bool
+```
+IsNull will return true if the value is null, and false otherwise.
+
+#### func (Value) IsNumber
+
+```go
+func (value Value) IsNumber() bool
+```
+IsNumber will return true if value is a number (primitive).
+
+#### func (Value) IsObject
+
+```go
+func (value Value) IsObject() bool
+```
+IsObject will return true if value is an object.
+
+#### func (Value) IsPrimitive
+
+```go
+func (value Value) IsPrimitive() bool
+```
+IsPrimitive will return true if value is a primitive (any kind of primitive).
+
+#### func (Value) IsString
+
+```go
+func (value Value) IsString() bool
+```
+IsString will return true if value is a string (primitive).
+
+#### func (Value) IsUndefined
+
+```go
+func (value Value) IsUndefined() bool
+```
+IsUndefined will return true if the value is undefined, and false otherwise.
+
+#### func (Value) Object
+
+```go
+func (value Value) Object() *Object
+```
+Object will return the object of the value, or nil if value is not an object.
+
+This method will not do any implicit conversion. For example, calling this
+method on a string primitive value will not return a String object.
+
+#### func (Value) String
+
+```go
+func (value Value) String() string
+```
+String will return the value as a string.
+
+This method will make return the empty string if there is an error.
+
+#### func (Value) ToBoolean
+
+```go
+func (value Value) ToBoolean() (bool, error)
+```
+ToBoolean will convert the value to a boolean (bool).
+
+ ToValue(0).ToBoolean() => false
+ ToValue("").ToBoolean() => false
+ ToValue(true).ToBoolean() => true
+ ToValue(1).ToBoolean() => true
+ ToValue("Nothing happens").ToBoolean() => true
+
+If there is an error during the conversion process (like an uncaught exception),
+then the result will be false and an error.
+
+#### func (Value) ToFloat
+
+```go
+func (value Value) ToFloat() (float64, error)
+```
+ToFloat will convert the value to a number (float64).
+
+ ToValue(0).ToFloat() => 0.
+ ToValue(1.1).ToFloat() => 1.1
+ ToValue("11").ToFloat() => 11.
+
+If there is an error during the conversion process (like an uncaught exception),
+then the result will be 0 and an error.
+
+#### func (Value) ToInteger
+
+```go
+func (value Value) ToInteger() (int64, error)
+```
+ToInteger will convert the value to a number (int64).
+
+ ToValue(0).ToInteger() => 0
+ ToValue(1.1).ToInteger() => 1
+ ToValue("11").ToInteger() => 11
+
+If there is an error during the conversion process (like an uncaught exception),
+then the result will be 0 and an error.
+
+#### func (Value) ToString
+
+```go
+func (value Value) ToString() (string, error)
+```
+ToString will convert the value to a string (string).
+
+ ToValue(0).ToString() => "0"
+ ToValue(false).ToString() => "false"
+ ToValue(1.1).ToString() => "1.1"
+ ToValue("11").ToString() => "11"
+ ToValue('Nothing happens.').ToString() => "Nothing happens."
+
+If there is an error during the conversion process (like an uncaught exception),
+then the result will be the empty string ("") and an error.
+
+--
+**godocdown** http://github.com/robertkrimen/godocdown
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/array_test.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/array_test.go
new file mode 100644
index 000000000..06f481bd4
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/array_test.go
@@ -0,0 +1,716 @@
+package otto
+
+import (
+ "testing"
+)
+
+func TestArray(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ var abc = [ undefined, "Nothing happens." ];
+ abc.length;
+ `, 2)
+
+ test(`
+ abc = ""+[0, 1, 2, 3];
+ def = [].toString();
+ ghi = [null, 4, "null"].toString();
+ [ abc, def, ghi ];
+ `, "0,1,2,3,,,4,null")
+
+ test(`new Array(0).length`, 0)
+
+ test(`new Array(11).length`, 11)
+
+ test(`new Array(11, 1).length`, 2)
+
+ test(`
+ abc = [0, 1, 2, 3];
+ abc.xyzzy = "Nothing happens.";
+ delete abc[1];
+ var xyzzy = delete abc.xyzzy;
+ [ abc, xyzzy, abc.xyzzy ];
+ `, "0,,2,3,true,")
+
+ test(`
+ var abc = [0, 1, 2, 3, 4];
+ abc.length = 2;
+ abc;
+ `, "0,1")
+
+ test(`raise:
+ [].length = 3.14159;
+ `, "RangeError")
+
+ test(`raise:
+ new Array(3.14159);
+ `, "RangeError")
+
+ test(`
+ Object.defineProperty(Array.prototype, "0", {
+ value: 100,
+ writable: false,
+ configurable: true
+ });
+ abc = [101];
+ abc.hasOwnProperty("0") && abc[0] === 101;
+ `, true)
+
+ test(`
+ abc = [,,undefined];
+ [ abc.hasOwnProperty(0), abc.hasOwnProperty(1), abc.hasOwnProperty(2) ];
+ `, "false,false,true")
+
+ test(`
+ abc = Object.getOwnPropertyDescriptor(Array, "prototype");
+ [ [ typeof Array.prototype ],
+ [ abc.writable, abc.enumerable, abc.configurable ] ];
+ `, "object,false,false,false")
+ })
+}
+
+func TestArray_toString(t *testing.T) {
+ tt(t, func() {
+ {
+ test(`
+ Array.prototype.toString = function() {
+ return "Nothing happens.";
+ }
+ abc = Array.prototype.toString();
+ def = [].toString();
+ ghi = [null, 4, "null"].toString();
+
+ [ abc, def, ghi ].join(",");
+ `, "Nothing happens.,Nothing happens.,Nothing happens.")
+ }
+
+ {
+ test(`
+ Array.prototype.join = undefined
+ abc = Array.prototype.toString()
+ def = [].toString()
+ ghi = [null, 4, "null"].toString()
+
+ abc + "," + def + "," + ghi;
+ `, "[object Array],[object Array],[object Array]")
+ }
+ })
+}
+
+func TestArray_toLocaleString(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ defer mockUTC()()
+
+ test(`
+ [ 3.14159, "abc", undefined, new Date(0) ].toLocaleString();
+ `, "3.14159,abc,,1970-01-01 00:00:00")
+
+ test(`raise:
+ [ { toLocaleString: undefined } ].toLocaleString();
+ `, "TypeError")
+ })
+}
+
+func TestArray_concat(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ abc = [0, 1, 2];
+ def = [-1, -2, -3];
+ ghi = abc.concat(def);
+ jkl = abc.concat(def, 3, 4, 5);
+ mno = def.concat(-4, -5, abc);
+
+ [ ghi, jkl, mno ].join(";");
+ `, "0,1,2,-1,-2,-3;0,1,2,-1,-2,-3,3,4,5;-1,-2,-3,-4,-5,0,1,2")
+
+ test(`
+ var abc = [,1];
+ var def = abc.concat([], [,]);
+
+ def.getClass = Object.prototype.toString;
+
+ [ def.getClass(), typeof def[0], def[1], typeof def[2], def.length ];
+ `, "[object Array],undefined,1,undefined,3")
+
+ test(`
+ Object.defineProperty(Array.prototype, "0", {
+ value: 100,
+ writable: false,
+ configurable: true
+ });
+
+ var abc = Array.prototype.concat.call(101);
+
+ var hasProperty = abc.hasOwnProperty("0");
+ var instanceOfVerify = typeof abc[0] === "object";
+ var verifyValue = false;
+ verifyValue = abc[0] == 101;
+
+ var verifyEnumerable = false;
+ for (var property in abc) {
+ if (property === "0" && abc.hasOwnProperty("0")) {
+ verifyEnumerable = true;
+ }
+ }
+
+ var verifyWritable = false;
+ abc[0] = 12;
+ verifyWritable = abc[0] === 12;
+
+ var verifyConfigurable = false;
+ delete abc[0];
+ verifyConfigurable = abc.hasOwnProperty("0");
+
+ [ hasProperty, instanceOfVerify, verifyValue, !verifyConfigurable, verifyEnumerable, verifyWritable ];
+ `, "true,true,true,true,true,true")
+ })
+}
+
+func TestArray_splice(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ abc = [0, 1, 2];
+ def = abc.splice(1, 2, 3, 4, 5);
+ ghi = [].concat(abc);
+ jkl = ghi.splice(17, 21, 7, 8, 9);
+ [ abc, def, ghi, jkl ].join(";");
+ `, "0,3,4,5;1,2;0,3,4,5,7,8,9;")
+ })
+}
+
+func TestArray_shift(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ abc = [0, 1, 2];
+ def = abc.shift();
+ ghi = [].concat(abc);
+ jkl = abc.shift();
+ mno = [].concat(abc);
+ pqr = abc.shift();
+ stu = [].concat(abc);
+ vwx = abc.shift();
+
+ [ abc, def, ghi, jkl, mno, pqr, stu, vwx ].join(";");
+ `, ";0;1,2;1;2;2;;")
+ })
+}
+
+func TestArray_push(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ abc = [0];
+ def = abc.push(1);
+ ghi = [].concat(abc);
+ jkl = abc.push(2,3,4);
+
+ [ abc, def, ghi, jkl ].join(";");
+ `, "0,1,2,3,4;2;0,1;5")
+ })
+}
+
+func TestArray_pop(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ abc = [0,1];
+ def = abc.pop();
+ ghi = [].concat(abc);
+ jkl = abc.pop();
+ mno = [].concat(abc);
+ pqr = abc.pop();
+
+ [ abc, def, ghi, jkl, mno, pqr ].join(";");
+ `, ";1;0;0;;")
+ })
+}
+
+func TestArray_slice(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ abc = [0,1,2,3];
+ def = abc.slice();
+ ghi = abc.slice(1);
+ jkl = abc.slice(3,-1);
+ mno = abc.slice(2,-1);
+ pqr = abc.slice(-1, -10);
+
+ [ abc, def, ghi, jkl, mno, pqr ].join(";");
+ `, "0,1,2,3;0,1,2,3;1,2,3;;2;")
+
+ // Array.protoype.slice is generic
+ test(`
+ abc = { 0: 0, 1: 1, 2: 2, 3: 3 };
+ abc.length = 4;
+ def = Array.prototype.slice.call(abc);
+ ghi = Array.prototype.slice.call(abc,1);
+ jkl = Array.prototype.slice.call(abc,3,-1);
+ mno = Array.prototype.slice.call(abc,2,-1);
+ pqr = Array.prototype.slice.call(abc,-1,-10);
+
+ [ abc, def, ghi, jkl, pqr ].join(";");
+ `, "[object Object];0,1,2,3;1,2,3;;")
+ })
+}
+
+func TestArray_sliceArguments(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ (function(){
+ return Array.prototype.slice.call(arguments, 1)
+ })({}, 1, 2, 3);
+ `, "1,2,3")
+ })
+}
+
+func TestArray_unshift(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ abc = [];
+ def = abc.unshift(0);
+ ghi = [].concat(abc);
+ jkl = abc.unshift(1,2,3,4);
+
+ [ abc, def, ghi, jkl ].join(";");
+ `, "1,2,3,4,0;1;0;5")
+ })
+}
+
+func TestArray_reverse(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ abc = [0,1,2,3].reverse();
+ def = [0,1,2].reverse();
+
+ [ abc, def ];
+ `, "3,2,1,0,2,1,0")
+ })
+}
+
+func TestArray_sort(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ abc = [0,1,2,3].sort();
+ def = [3,2,1,0].sort();
+ ghi = [].sort();
+ jkl = [0].sort();
+ mno = [1,0].sort();
+ pqr = [1,5,-10, 100, 8, 72, 401, 0.05].sort();
+ stu = [1,5,-10, 100, 8, 72, 401, 0.05].sort(function(x, y){
+ return x == y ? 0 : x < y ? -1 : 1
+ });
+
+ [ abc, def, ghi, jkl, mno, pqr, stu ].join(";");
+ `, "0,1,2,3;0,1,2,3;;0;0,1;-10,0.05,1,100,401,5,72,8;-10,0.05,1,5,8,72,100,401")
+
+ test(`Array.prototype.sort.length`, 1)
+ })
+}
+
+func TestArray_isArray(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ [ Array.isArray.length, Array.isArray(), Array.isArray([]), Array.isArray({}) ];
+ `, "1,false,true,false")
+
+ test(`Array.isArray(Math)`, false)
+ })
+}
+
+func TestArray_indexOf(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`['a', 'b', 'c', 'b'].indexOf('b')`, 1)
+
+ test(`['a', 'b', 'c', 'b'].indexOf('b', 2)`, 3)
+
+ test(`['a', 'b', 'c', 'b'].indexOf('b', -2)`, 3)
+
+ test(`
+ Object.prototype.indexOf = Array.prototype.indexOf;
+ var abc = {0: 'a', 1: 'b', 2: 'c', length: 3};
+ abc.indexOf('c');
+ `, 2)
+
+ test(`[true].indexOf(true, "-Infinity")`, 0)
+
+ test(`
+ var target = {};
+ Math[3] = target;
+ Math.length = 5;
+ Array.prototype.indexOf.call(Math, target) === 3;
+ `, true)
+
+ test(`
+ var _NaN = NaN;
+ var abc = new Array("NaN", undefined, 0, false, null, {toString:function(){return NaN}}, "false", _NaN, NaN);
+ abc.indexOf(NaN);
+ `, -1)
+
+ test(`
+ var abc = {toString:function (){return 0}};
+ var def = 1;
+ var ghi = -(4/3);
+ var jkl = new Array(false, undefined, null, "0", abc, -1.3333333333333, "string", -0, true, +0, def, 1, 0, false, ghi, -(4/3));
+ [ jkl.indexOf(-(4/3)), jkl.indexOf(0), jkl.indexOf(-0), jkl.indexOf(1) ];
+ `, "14,7,7,10")
+ })
+}
+
+func TestArray_lastIndexOf(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`['a', 'b', 'c', 'b'].lastIndexOf('b')`, 3)
+
+ test(`['a', 'b', 'c', 'b'].lastIndexOf('b', 2)`, 1)
+
+ test(`['a', 'b', 'c', 'b'].lastIndexOf('b', -2)`, 1)
+
+ test(`
+ Object.prototype.lastIndexOf = Array.prototype.lastIndexOf;
+ var abc = {0: 'a', 1: 'b', 2: 'c', 3: 'b', length: 4};
+ abc.lastIndexOf('b');
+ `, 3)
+
+ test(`
+ var target = {};
+ Math[3] = target;
+ Math.length = 5;
+ [ Array.prototype.lastIndexOf.call(Math, target) === 3 ];
+ `, "true")
+
+ test(`
+ var _NaN = NaN;
+ var abc = new Array("NaN", undefined, 0, false, null, {toString:function(){return NaN}}, "false", _NaN, NaN);
+ abc.lastIndexOf(NaN);
+ `, -1)
+
+ test(`
+ var abc = {toString:function (){return 0}};
+ var def = 1;
+ var ghi = -(4/3);
+ var jkl = new Array(false, undefined, null, "0", abc, -1.3333333333333, "string", -0, true, +0, def, 1, 0, false, ghi, -(4/3));
+ [ jkl.lastIndexOf(-(4/3)), jkl.indexOf(0), jkl.indexOf(-0), jkl.indexOf(1) ];
+ `, "15,7,7,10")
+ })
+}
+
+func TestArray_every(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`raise: [].every()`, "TypeError")
+
+ test(`raise: [].every("abc")`, "TypeError")
+
+ test(`[].every(function() { return false })`, true)
+
+ test(`[1,2,3].every(function() { return false })`, false)
+
+ test(`[1,2,3].every(function() { return true })`, true)
+
+ test(`[1,2,3].every(function(_, index) { if (index === 1) return true })`, false)
+
+ test(`
+ var abc = function(value, index, object) {
+ return ('[object Math]' !== Object.prototype.toString.call(object));
+ };
+
+ Math.length = 1;
+ Math[0] = 1;
+ !Array.prototype.every.call(Math, abc);
+ `, true)
+
+ test(`
+ var def = false;
+
+ var abc = function(value, index, object) {
+ def = true;
+ return this === Math;
+ };
+
+ [11].every(abc, Math) && def;
+ `, true)
+
+ test(`
+ var def = false;
+
+ var abc = function(value, index, object) {
+ def = true;
+ return Math;
+ };
+
+ [11].every(abc) && def;
+ `, true)
+ })
+}
+
+func TestArray_some(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`raise: [].some("abc")`, "TypeError")
+
+ test(`[].some(function() { return true })`, false)
+
+ test(`[1,2,3].some(function() { return false })`, false)
+
+ test(`[1,2,3].some(function() { return true })`, true)
+
+ test(`[1,2,3].some(function(_, index) { if (index === 1) return true })`, true)
+
+ test(`
+ var abc = function(value, index, object) {
+ return ('[object Math]' !== Object.prototype.toString.call(object));
+ };
+
+ Math.length = 1;
+ Math[0] = 1;
+ !Array.prototype.some.call(Math, abc);
+ `, true)
+
+ test(`
+ var abc = function(value, index, object) {
+ return this === Math;
+ };
+
+ [11].some(abc, Math);
+ `, true)
+
+ test(`
+ var abc = function(value, index, object) {
+ return Math;
+ };
+
+ [11].some(abc);
+ `, true)
+ })
+}
+
+func TestArray_forEach(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`raise: [].forEach("abc")`, "TypeError")
+
+ test(`
+ var abc = 0;
+ [].forEach(function(value) {
+ abc += value;
+ });
+ abc;
+ `, 0)
+
+ test(`
+ abc = 0;
+ var def = [];
+ [1,2,3].forEach(function(value, index) {
+ abc += value;
+ def.push(index);
+ });
+ [ abc, def ];
+ `, "6,0,1,2")
+
+ test(`
+ var def = false;
+ var abc = function(value, index, object) {
+ def = ('[object Math]' === Object.prototype.toString.call(object));
+ };
+
+ Math.length = 1;
+ Math[0] = 1;
+ Array.prototype.forEach.call(Math, abc);
+ def;
+ `, true)
+
+ test(`
+ var def = false;
+ var abc = function(value, index, object) {
+ def = this === Math;
+ };
+
+ [11].forEach(abc, Math);
+ def;
+ `, true)
+ })
+}
+
+func TestArray_indexing(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ var abc = new Array(0, 1);
+ var def = abc.length;
+ abc[4294967296] = 10; // 2^32 => 0
+ abc[4294967297] = 11; // 2^32+1 => 1
+ [ def, abc.length, abc[0], abc[1], abc[4294967296] ];
+ `, "2,2,0,1,10")
+
+ test(`
+ abc = new Array(0, 1);
+ def = abc.length;
+ abc[4294967295] = 10;
+ var ghi = abc.length;
+ abc[4294967299] = 12;
+ var jkl = abc.length;
+ abc[4294967294] = 11;
+ [ def, ghi, jkl, abc.length, abc[4294967295], abc[4294967299] ];
+ `, "2,2,2,4294967295,10,12")
+ })
+}
+
+func TestArray_map(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`raise: [].map("abc")`, "TypeError")
+
+ test(`[].map(function() { return 1 }).length`, 0)
+
+ test(`[1,2,3].map(function(value) { return value * value })`, "1,4,9")
+
+ test(`[1,2,3].map(function(value) { return 1 })`, "1,1,1")
+
+ test(`
+ var abc = function(value, index, object) {
+ return ('[object Math]' === Object.prototype.toString.call(object));
+ };
+
+ Math.length = 1;
+ Math[0] = 1;
+ Array.prototype.map.call(Math, abc)[0];
+ `, true)
+
+ test(`
+ var abc = function(value, index, object) {
+ return this === Math;
+ };
+
+ [11].map(abc, Math)[0];
+ `, true)
+ })
+}
+
+func TestArray_filter(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`raise: [].filter("abc")`, "TypeError")
+
+ test(`[].filter(function() { return 1 }).length`, 0)
+
+ test(`[1,2,3].filter(function() { return false }).length`, 0)
+
+ test(`[1,2,3].filter(function() { return true })`, "1,2,3")
+ })
+}
+
+func TestArray_reduce(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`raise: [].reduce("abc")`, "TypeError")
+
+ test(`raise: [].reduce(function() {})`, "TypeError")
+
+ test(`[].reduce(function() {}, 0)`, 0)
+
+ test(`[].reduce(function() {}, undefined)`, "undefined")
+
+ test(`['a','b','c'].reduce(function(result, value) { return result+', '+value })`, "a, b, c")
+
+ test(`[1,2,3].reduce(function(result, value) { return result + value }, 4)`, 10)
+
+ test(`[1,2,3].reduce(function(result, value) { return result + value })`, 6)
+ })
+}
+
+func TestArray_reduceRight(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`raise: [].reduceRight("abc")`, "TypeError")
+
+ test(`raise: [].reduceRight(function() {})`, "TypeError")
+
+ test(`[].reduceRight(function() {}, 0)`, 0)
+
+ test(`[].reduceRight(function() {}, undefined)`, "undefined")
+
+ test(`['a','b','c'].reduceRight(function(result, value) { return result+', '+value })`, "c, b, a")
+
+ test(`[1,2,3].reduceRight(function(result, value) { return result + value }, 4)`, 10)
+
+ test(`[1,2,3].reduceRight(function(result, value) { return result + value })`, 6)
+ })
+}
+
+func TestArray_defineOwnProperty(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ var abc = [];
+ Object.defineProperty(abc, "length", {
+ writable: false
+ });
+ abc.length;
+ `, 0)
+
+ test(`raise:
+ var abc = [];
+ var exception;
+ Object.defineProperty(abc, "length", {
+ writable: false
+ });
+ Object.defineProperty(abc, "length", {
+ writable: true
+ });
+ `, "TypeError")
+ })
+}
+
+func TestArray_new(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ var abc = new Array(null);
+ var def = new Array(undefined);
+ [ abc.length, abc[0] === null, def.length, def[0] === undefined ]
+ `, "1,true,1,true")
+
+ test(`
+ var abc = new Array(new Number(0));
+ var def = new Array(new Number(4294967295));
+ [ abc.length, typeof abc[0], abc[0] == 0, def.length, typeof def[0], def[0] == 4294967295 ]
+ `, "1,object,true,1,object,true")
+ })
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/bug_test.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/bug_test.go
new file mode 100644
index 000000000..5e4d90bae
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/bug_test.go
@@ -0,0 +1,617 @@
+package otto
+
+import (
+ "testing"
+ "time"
+)
+
+func Test_262(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ // 11.13.1-1-1
+ test(`raise:
+ eval("42 = 42;");
+ `, "ReferenceError: Invalid left-hand side in assignment")
+ })
+}
+
+func Test_issue5(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`'abc' === 'def'`, false)
+ test(`'\t' === '\r'`, false)
+ })
+}
+
+func Test_issue13(t *testing.T) {
+ tt(t, func() {
+ test, tester := test()
+ vm := tester.vm
+
+ value, err := vm.ToValue(map[string]interface{}{
+ "string": "Xyzzy",
+ "number": 42,
+ "array": []string{"def", "ghi"},
+ })
+ if err != nil {
+ t.Error(err)
+ t.FailNow()
+ }
+
+ fn, err := vm.Object(`
+ (function(value){
+ return ""+[value.string, value.number, value.array]
+ })
+ `)
+ if err != nil {
+ t.Error(err)
+ t.FailNow()
+ }
+
+ result, err := fn.Value().Call(fn.Value(), value)
+ if err != nil {
+ t.Error(err)
+ t.FailNow()
+ }
+ is(result.string(), "Xyzzy,42,def,ghi")
+
+ anything := struct {
+ Abc interface{}
+ }{
+ Abc: map[string]interface{}{
+ "def": []interface{}{
+ []interface{}{
+ "a", "b", "c", "", "d", "e",
+ },
+ map[string]interface{}{
+ "jkl": "Nothing happens.",
+ },
+ },
+ "ghi": -1,
+ },
+ }
+
+ vm.Set("anything", anything)
+ test(`
+ [
+ anything,
+ "~",
+ anything.Abc,
+ "~",
+ anything.Abc.def,
+ "~",
+ anything.Abc.def[1].jkl,
+ "~",
+ anything.Abc.ghi,
+ ];
+ `, "[object Object],~,[object Object],~,a,b,c,,d,e,[object Object],~,Nothing happens.,~,-1")
+ })
+}
+
+func Test_issue16(t *testing.T) {
+ tt(t, func() {
+ test, vm := test()
+
+ test(`
+ var def = {
+ "abc": ["abc"],
+ "xyz": ["xyz"]
+ };
+ def.abc.concat(def.xyz);
+ `, "abc,xyz")
+
+ vm.Set("ghi", []string{"jkl", "mno"})
+
+ test(`
+ def.abc.concat(def.xyz).concat(ghi);
+ `, "abc,xyz,jkl,mno")
+
+ test(`
+ ghi.concat(def.abc.concat(def.xyz));
+ `, "jkl,mno,abc,xyz")
+
+ vm.Set("pqr", []interface{}{"jkl", 42, 3.14159, true})
+
+ test(`
+ pqr.concat(ghi, def.abc, def, def.xyz);
+ `, "jkl,42,3.14159,true,jkl,mno,abc,[object Object],xyz")
+
+ test(`
+ pqr.concat(ghi, def.abc, def, def.xyz).length;
+ `, 9)
+ })
+}
+
+func Test_issue21(t *testing.T) {
+ tt(t, func() {
+ vm1 := New()
+ vm1.Run(`
+ abc = {}
+ abc.ghi = "Nothing happens.";
+ var jkl = 0;
+ abc.def = function() {
+ jkl += 1;
+ return 1;
+ }
+ `)
+ abc, err := vm1.Get("abc")
+ is(err, nil)
+
+ vm2 := New()
+ vm2.Set("cba", abc)
+ _, err = vm2.Run(`
+ var pqr = 0;
+ cba.mno = function() {
+ pqr -= 1;
+ return 1;
+ }
+ cba.def();
+ cba.def();
+ cba.def();
+ `)
+ is(err, nil)
+
+ jkl, err := vm1.Get("jkl")
+ is(err, nil)
+ is(jkl, 3)
+
+ _, err = vm1.Run(`
+ abc.mno();
+ abc.mno();
+ abc.mno();
+ `)
+ is(err, nil)
+
+ pqr, err := vm2.Get("pqr")
+ is(err, nil)
+ is(pqr, -3)
+ })
+}
+
+func Test_issue24(t *testing.T) {
+ tt(t, func() {
+ _, vm := test()
+
+ {
+ vm.Set("abc", []string{"abc", "def", "ghi"})
+ value, err := vm.Get("abc")
+ is(err, nil)
+ export, _ := value.Export()
+ {
+ value, valid := export.([]string)
+ is(valid, true)
+
+ is(value[0], "abc")
+ is(value[2], "ghi")
+ }
+ }
+
+ {
+ vm.Set("abc", [...]string{"abc", "def", "ghi"})
+ value, err := vm.Get("abc")
+ is(err, nil)
+ export, _ := value.Export()
+ {
+ value, valid := export.([3]string)
+ is(valid, true)
+
+ is(value[0], "abc")
+ is(value[2], "ghi")
+ }
+ }
+
+ {
+ vm.Set("abc", &[...]string{"abc", "def", "ghi"})
+ value, err := vm.Get("abc")
+ is(err, nil)
+ export, _ := value.Export()
+ {
+ value, valid := export.(*[3]string)
+ is(valid, true)
+
+ is(value[0], "abc")
+ is(value[2], "ghi")
+ }
+ }
+
+ {
+ vm.Set("abc", map[int]string{0: "abc", 1: "def", 2: "ghi"})
+ value, err := vm.Get("abc")
+ is(err, nil)
+ export, _ := value.Export()
+ {
+ value, valid := export.(map[int]string)
+ is(valid, true)
+
+ is(value[0], "abc")
+ is(value[2], "ghi")
+ }
+ }
+
+ {
+ vm.Set("abc", _abcStruct{Abc: true, Ghi: "Nothing happens."})
+ value, err := vm.Get("abc")
+ is(err, nil)
+ export, _ := value.Export()
+ {
+ value, valid := export.(_abcStruct)
+ is(valid, true)
+
+ is(value.Abc, true)
+ is(value.Ghi, "Nothing happens.")
+ }
+ }
+
+ {
+ vm.Set("abc", &_abcStruct{Abc: true, Ghi: "Nothing happens."})
+ value, err := vm.Get("abc")
+ is(err, nil)
+ export, _ := value.Export()
+ {
+ value, valid := export.(*_abcStruct)
+ is(valid, true)
+
+ is(value.Abc, true)
+ is(value.Ghi, "Nothing happens.")
+ }
+ }
+ })
+}
+
+func Test_issue39(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ var abc = 0, def = [], ghi = function() {
+ if (abc < 10) return ++abc;
+ return undefined;
+ }
+ for (var jkl; (jkl = ghi());) def.push(jkl);
+ def;
+ `, "1,2,3,4,5,6,7,8,9,10")
+
+ test(`
+ var abc = ["1", "2", "3", "4"];
+ var def = [];
+ for (var ghi; (ghi = abc.shift());) {
+ def.push(ghi);
+ }
+ def;
+ `, "1,2,3,4")
+ })
+}
+
+func Test_issue64(t *testing.T) {
+ tt(t, func() {
+ test, vm := test()
+
+ defer mockTimeLocal(time.UTC)()
+
+ abc := map[string]interface{}{
+ "time": time.Unix(0, 0),
+ }
+ vm.Set("abc", abc)
+
+ def := struct {
+ Public string
+ private string
+ }{
+ "Public", "private",
+ }
+ vm.Set("def", def)
+
+ test(`"sec" in abc.time`, false)
+
+ test(`
+ [ "Public" in def, "private" in def, def.Public, def.private ];
+ `, "true,false,Public,")
+
+ test(`JSON.stringify(abc)`, `{"time":"1970-01-01T00:00:00Z"}`)
+ })
+}
+
+func Test_issue73(t *testing.T) {
+ tt(t, func() {
+ test, vm := test()
+
+ vm.Set("abc", [4]int{3, 2, 1, 0})
+
+ test(`
+ var def = [ 0, 1, 2, 3 ];
+ JSON.stringify(def) + JSON.stringify(abc);
+ `, "[0,1,2,3][3,2,1,0]")
+ })
+}
+
+func Test_7_3_1(t *testing.T) {
+ tt(t, func() {
+ test(`
+ eval("var test7_3_1\u2028abc = 66;");
+ [ abc, typeof test7_3_1 ];
+ `, "66,undefined")
+ })
+}
+
+func Test_7_3_3(t *testing.T) {
+ tt(t, func() {
+ test(`raise:
+ eval("//\u2028 =;");
+ `, "SyntaxError: Unexpected token =")
+ })
+}
+
+func Test_S7_3_A2_1_T1(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`raise:
+ eval("'\u000Astr\u000Aing\u000A'")
+ `, "SyntaxError: Unexpected token ILLEGAL")
+ })
+}
+
+func Test_S7_8_3_A2_1_T1(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ [ .0 === 0.0, .0, .1 === 0.1, .1 ]
+ `, "true,0,true,0.1")
+ })
+}
+
+func Test_S7_8_4_A4_2_T3(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ "\a"
+ `, "a")
+ })
+}
+
+func Test_S7_9_A1(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ var def;
+ abc: for (var i = 0; i <= 0; i++) {
+ for (var j = 0; j <= 1; j++) {
+ if (j === 0) {
+ continue abc;
+ } else {
+ def = true;
+ }
+ }
+ }
+ [ def, i, j ];
+ `, ",1,0")
+ })
+}
+
+func Test_S7_9_A3(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ (function(){
+ return
+ 1;
+ })()
+ `, "undefined")
+ })
+}
+
+func Test_7_3_10(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ eval("var \u0061\u0062\u0063 = 3.14159;");
+ abc;
+ `, 3.14159)
+
+ test(`
+ abc = undefined;
+ eval("var \\u0061\\u0062\\u0063 = 3.14159;");
+ abc;
+ `, 3.14159)
+ })
+}
+
+func Test_bug(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ // 10.4.2-1-5
+ test(`
+ "abc\
+def"
+ `, "abcdef")
+
+ test(`
+ eval("'abc';\
+ 'def'")
+ `, "def")
+
+ // S12.6.1_A10
+ test(`
+ var abc = 0;
+ do {
+ if(typeof(def) === "function"){
+ abc = -1;
+ break;
+ } else {
+ abc = 1;
+ break;
+ }
+ } while(function def(){});
+ abc;
+ `, 1)
+
+ // S12.7_A7
+ test(`raise:
+ abc:
+ while (true) {
+ eval("continue abc");
+ }
+ `, "SyntaxError: Undefined label 'abc'")
+
+ // S15.1.2.1_A3.3_T3
+ test(`raise:
+ eval("return");
+ `, "SyntaxError: Illegal return statement")
+
+ // 15.2.3.3-2-33
+ test(`
+ var abc = { "AB\n\\cd": 1 };
+ Object.getOwnPropertyDescriptor(abc, "AB\n\\cd").value;
+ `, 1)
+
+ // S15.3_A2_T1
+ test(`raise:
+ Function.call(this, "var x / = 1;");
+ `, "SyntaxError: Unexpected token /")
+
+ // ?
+ test(`
+ (function(){
+ var abc = [];
+ (function(){
+ abc.push(0);
+ abc.push(1);
+ })(undefined);
+ if ((function(){ return true; })()) {
+ (function(){
+ abc.push(2);
+ })();
+ }
+ return abc;
+ })();
+ `, "0,1,2")
+
+ if false {
+ // 15.9.5.43-0-10
+ // Should be an invalid date
+ test(`
+ date = new Date(1970, 0, -99999999, 0, 0, 0, 1);
+ `, "")
+ }
+
+ // S7.8.3_A1.2_T1
+ test(`
+ [ 0e1, 1e1, 2e1, 3e1, 4e1, 5e1, 6e1, 7e1, 8e1, 9e1 ];
+ `, "0,10,20,30,40,50,60,70,80,90")
+
+ // S15.10.2.7_A3_T2
+ test(`
+ var abc = /\s+abc\s+/.exec("\t abc def");
+ [ abc.length, abc.index, abc.input, abc ];
+ `, "1,0,\t abc def,\t abc ")
+ })
+}
+
+func Test_issue79(t *testing.T) {
+ tt(t, func() {
+ test, vm := test()
+
+ vm.Set("abc", []_abcStruct{
+ {
+ Ghi: "一",
+ Def: 1,
+ },
+ {
+ Def: 3,
+ Ghi: "三",
+ },
+ {
+ Def: 2,
+ Ghi: "二",
+ },
+ {
+ Def: 4,
+ Ghi: "å››",
+ },
+ })
+
+ test(`
+ abc.sort(function(a,b){ return b.Def-a.Def });
+ def = [];
+ for (i = 0; i < abc.length; i++) {
+ def.push(abc[i].String())
+ }
+ def;
+ `, "四,三,二,一")
+ })
+}
+
+func Test_issue80(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ JSON.stringify([
+ 1401868959,
+ 14018689591,
+ 140186895901,
+ 1401868959001,
+ 14018689590001,
+ 140186895900001,
+ 1401868959000001,
+ 1401868959000001.5,
+ 14018689590000001,
+ 140186895900000001,
+ 1401868959000000001,
+ 14018689590000000001,
+ 140186895900000000001,
+ 140186895900000000001.5
+ ]);
+ `, "[1401868959,14018689591,140186895901,1401868959001,14018689590001,140186895900001,1401868959000001,1.4018689590000015e+15,14018689590000001,140186895900000001,1401868959000000001,1.401868959e+19,1.401868959e+20,1.401868959e+20]")
+ })
+}
+
+func Test_issue87(t *testing.T) {
+ tt(t, func() {
+ test, vm := test()
+
+ test(`
+ var def = 0;
+ abc: {
+ for (;;) {
+ def = !1;
+ break abc;
+ }
+ def = !0;
+ }
+ def;
+ `, false)
+
+ _, err := vm.Run(`
+/*
+CryptoJS v3.1.2
+code.google.com/p/crypto-js
+(c) 2009-2013 by Jeff Mott. All rights reserved.
+code.google.com/p/crypto-js/wiki/License
+*/
+var CryptoJS=CryptoJS||function(h,s){var f={},g=f.lib={},q=function(){},m=g.Base={extend:function(a){q.prototype=this;var c=new q;a&&c.mixIn(a);c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)});c.init.prototype=c;c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},
+r=g.WordArray=m.extend({init:function(a,c){a=this.words=a||[];this.sigBytes=c!=s?c:4*a.length},toString:function(a){return(a||k).stringify(this)},concat:function(a){var c=this.words,d=a.words,b=this.sigBytes;a=a.sigBytes;this.clamp();if(b%4)for(var e=0;e<a;e++)c[b+e>>>2]|=(d[e>>>2]>>>24-8*(e%4)&255)<<24-8*((b+e)%4);else if(65535<d.length)for(e=0;e<a;e+=4)c[b+e>>>2]=d[e>>>2];else c.push.apply(c,d);this.sigBytes+=a;return this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<<
+32-8*(c%4);a.length=h.ceil(c/4)},clone:function(){var a=m.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var c=[],d=0;d<a;d+=4)c.push(4294967296*h.random()|0);return new r.init(c,a)}}),l=f.enc={},k=l.Hex={stringify:function(a){var c=a.words;a=a.sigBytes;for(var d=[],b=0;b<a;b++){var e=c[b>>>2]>>>24-8*(b%4)&255;d.push((e>>>4).toString(16));d.push((e&15).toString(16))}return d.join("")},parse:function(a){for(var c=a.length,d=[],b=0;b<c;b+=2)d[b>>>3]|=parseInt(a.substr(b,
+2),16)<<24-4*(b%8);return new r.init(d,c/2)}},n=l.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var d=[],b=0;b<a;b++)d.push(String.fromCharCode(c[b>>>2]>>>24-8*(b%4)&255));return d.join("")},parse:function(a){for(var c=a.length,d=[],b=0;b<c;b++)d[b>>>2]|=(a.charCodeAt(b)&255)<<24-8*(b%4);return new r.init(d,c)}},j=l.Utf8={stringify:function(a){try{return decodeURIComponent(escape(n.stringify(a)))}catch(c){throw Error("Malformed UTF-8 data");}},parse:function(a){return n.parse(unescape(encodeURIComponent(a)))}},
+u=g.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new r.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=j.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var c=this._data,d=c.words,b=c.sigBytes,e=this.blockSize,f=b/(4*e),f=a?h.ceil(f):h.max((f|0)-this._minBufferSize,0);a=f*e;b=h.min(4*a,b);if(a){for(var g=0;g<a;g+=e)this._doProcessBlock(d,g);g=d.splice(0,a);c.sigBytes-=b}return new r.init(g,b)},clone:function(){var a=m.clone.call(this);
+a._data=this._data.clone();return a},_minBufferSize:0});g.Hasher=u.extend({cfg:m.extend(),init:function(a){this.cfg=this.cfg.extend(a);this.reset()},reset:function(){u.reset.call(this);this._doReset()},update:function(a){this._append(a);this._process();return this},finalize:function(a){a&&this._append(a);return this._doFinalize()},blockSize:16,_createHelper:function(a){return function(c,d){return(new a.init(d)).finalize(c)}},_createHmacHelper:function(a){return function(c,d){return(new t.HMAC.init(a,
+d)).finalize(c)}}});var t=f.algo={};return f}(Math);
+(function(h){for(var s=CryptoJS,f=s.lib,g=f.WordArray,q=f.Hasher,f=s.algo,m=[],r=[],l=function(a){return 4294967296*(a-(a|0))|0},k=2,n=0;64>n;){var j;a:{j=k;for(var u=h.sqrt(j),t=2;t<=u;t++)if(!(j%t)){j=!1;break a}j=!0}j&&(8>n&&(m[n]=l(h.pow(k,0.5))),r[n]=l(h.pow(k,1/3)),n++);k++}var a=[],f=f.SHA256=q.extend({_doReset:function(){this._hash=new g.init(m.slice(0))},_doProcessBlock:function(c,d){for(var b=this._hash.words,e=b[0],f=b[1],g=b[2],j=b[3],h=b[4],m=b[5],n=b[6],q=b[7],p=0;64>p;p++){if(16>p)a[p]=
+c[d+p]|0;else{var k=a[p-15],l=a[p-2];a[p]=((k<<25|k>>>7)^(k<<14|k>>>18)^k>>>3)+a[p-7]+((l<<15|l>>>17)^(l<<13|l>>>19)^l>>>10)+a[p-16]}k=q+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(h&m^~h&n)+r[p]+a[p];l=((e<<30|e>>>2)^(e<<19|e>>>13)^(e<<10|e>>>22))+(e&f^e&g^f&g);q=n;n=m;m=h;h=j+k|0;j=g;g=f;f=e;e=k+l|0}b[0]=b[0]+e|0;b[1]=b[1]+f|0;b[2]=b[2]+g|0;b[3]=b[3]+j|0;b[4]=b[4]+h|0;b[5]=b[5]+m|0;b[6]=b[6]+n|0;b[7]=b[7]+q|0},_doFinalize:function(){var a=this._data,d=a.words,b=8*this._nDataBytes,e=8*a.sigBytes;
+d[e>>>5]|=128<<24-e%32;d[(e+64>>>9<<4)+14]=h.floor(b/4294967296);d[(e+64>>>9<<4)+15]=b;a.sigBytes=4*d.length;this._process();return this._hash},clone:function(){var a=q.clone.call(this);a._hash=this._hash.clone();return a}});s.SHA256=q._createHelper(f);s.HmacSHA256=q._createHmacHelper(f)})(Math);
+(function(){var h=CryptoJS,s=h.enc.Utf8;h.algo.HMAC=h.lib.Base.extend({init:function(f,g){f=this._hasher=new f.init;"string"==typeof g&&(g=s.parse(g));var h=f.blockSize,m=4*h;g.sigBytes>m&&(g=f.finalize(g));g.clamp();for(var r=this._oKey=g.clone(),l=this._iKey=g.clone(),k=r.words,n=l.words,j=0;j<h;j++)k[j]^=1549556828,n[j]^=909522486;r.sigBytes=l.sigBytes=m;this.reset()},reset:function(){var f=this._hasher;f.reset();f.update(this._iKey)},update:function(f){this._hasher.update(f);return this},finalize:function(f){var g=
+this._hasher;f=g.finalize(f);g.reset();return g.finalize(this._oKey.clone().concat(f))}})})();
+ `)
+ is(err, nil)
+
+ test(`CryptoJS.HmacSHA256("Message", "secret");`, "aa747c502a898200f9e4fa21bac68136f886a0e27aec70ba06daf2e2a5cb5597")
+ })
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin.go
new file mode 100644
index 000000000..c3375a108
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin.go
@@ -0,0 +1,353 @@
+package otto
+
+import (
+ "encoding/hex"
+ "math"
+ "net/url"
+ "regexp"
+ "strconv"
+ "strings"
+ "unicode/utf16"
+ "unicode/utf8"
+)
+
+// Global
+func builtinGlobal_eval(call FunctionCall) Value {
+ src := call.Argument(0)
+ if !src.IsString() {
+ return src
+ }
+ runtime := call.runtime
+ program := runtime.cmpl_parseOrThrow(src.string())
+ if !call.eval {
+ // Not a direct call to eval, so we enter the global ExecutionContext
+ runtime.enterGlobalScope()
+ defer runtime.leaveScope()
+ }
+ returnValue := runtime.cmpl_evaluate_nodeProgram(program, true)
+ if returnValue.isEmpty() {
+ return Value{}
+ }
+ return returnValue
+}
+
+func builtinGlobal_isNaN(call FunctionCall) Value {
+ value := call.Argument(0).float64()
+ return toValue_bool(math.IsNaN(value))
+}
+
+func builtinGlobal_isFinite(call FunctionCall) Value {
+ value := call.Argument(0).float64()
+ return toValue_bool(!math.IsNaN(value) && !math.IsInf(value, 0))
+}
+
+// radix 3 => 2 (ASCII 50) +47
+// radix 11 => A/a (ASCII 65/97) +54/+86
+var parseInt_alphabetTable = func() []string {
+ table := []string{"", "", "01"}
+ for radix := 3; radix <= 36; radix += 1 {
+ alphabet := table[radix-1]
+ if radix <= 10 {
+ alphabet += string(radix + 47)
+ } else {
+ alphabet += string(radix+54) + string(radix+86)
+ }
+ table = append(table, alphabet)
+ }
+ return table
+}()
+
+func digitValue(chr rune) int {
+ switch {
+ case '0' <= chr && chr <= '9':
+ return int(chr - '0')
+ case 'a' <= chr && chr <= 'z':
+ return int(chr - 'a' + 10)
+ case 'A' <= chr && chr <= 'Z':
+ return int(chr - 'A' + 10)
+ }
+ return 36 // Larger than any legal digit value
+}
+
+func builtinGlobal_parseInt(call FunctionCall) Value {
+ input := strings.TrimSpace(call.Argument(0).string())
+ if len(input) == 0 {
+ return NaNValue()
+ }
+
+ radix := int(toInt32(call.Argument(1)))
+
+ negative := false
+ switch input[0] {
+ case '+':
+ input = input[1:]
+ case '-':
+ negative = true
+ input = input[1:]
+ }
+
+ strip := true
+ if radix == 0 {
+ radix = 10
+ } else {
+ if radix < 2 || radix > 36 {
+ return NaNValue()
+ } else if radix != 16 {
+ strip = false
+ }
+ }
+
+ switch len(input) {
+ case 0:
+ return NaNValue()
+ case 1:
+ default:
+ if strip {
+ if input[0] == '0' && (input[1] == 'x' || input[1] == 'X') {
+ input = input[2:]
+ radix = 16
+ }
+ }
+ }
+
+ base := radix
+ index := 0
+ for ; index < len(input); index++ {
+ digit := digitValue(rune(input[index])) // If not ASCII, then an error anyway
+ if digit >= base {
+ break
+ }
+ }
+ input = input[0:index]
+
+ value, err := strconv.ParseInt(input, radix, 64)
+ if err != nil {
+ if err.(*strconv.NumError).Err == strconv.ErrRange {
+ base := float64(base)
+ // Could just be a very large number (e.g. 0x8000000000000000)
+ var value float64
+ for _, chr := range input {
+ digit := float64(digitValue(chr))
+ if digit >= base {
+ goto error
+ }
+ value = value*base + digit
+ }
+ if negative {
+ value *= -1
+ }
+ return toValue_float64(value)
+ }
+ error:
+ return NaNValue()
+ }
+ if negative {
+ value *= -1
+ }
+
+ return toValue_int64(value)
+}
+
+var parseFloat_matchBadSpecial = regexp.MustCompile(`[\+\-]?(?:[Ii]nf$|infinity)`)
+var parseFloat_matchValid = regexp.MustCompile(`[0-9eE\+\-\.]|Infinity`)
+
+func builtinGlobal_parseFloat(call FunctionCall) Value {
+ // Caveat emptor: This implementation does NOT match the specification
+ input := strings.TrimSpace(call.Argument(0).string())
+ if parseFloat_matchBadSpecial.MatchString(input) {
+ return NaNValue()
+ }
+ value, err := strconv.ParseFloat(input, 64)
+ if err != nil {
+ for end := len(input); end > 0; end -= 1 {
+ input := input[0:end]
+ if !parseFloat_matchValid.MatchString(input) {
+ return NaNValue()
+ }
+ value, err = strconv.ParseFloat(input, 64)
+ if err == nil {
+ break
+ }
+ }
+ if err != nil {
+ return NaNValue()
+ }
+ }
+ return toValue_float64(value)
+}
+
+// encodeURI/decodeURI
+
+func _builtinGlobal_encodeURI(call FunctionCall, escape *regexp.Regexp) Value {
+ value := call.Argument(0)
+ var input []uint16
+ switch vl := value.value.(type) {
+ case []uint16:
+ input = vl
+ default:
+ input = utf16.Encode([]rune(value.string()))
+ }
+ if len(input) == 0 {
+ return toValue_string("")
+ }
+ output := []byte{}
+ length := len(input)
+ encode := make([]byte, 4)
+ for index := 0; index < length; {
+ value := input[index]
+ decode := utf16.Decode(input[index : index+1])
+ if value >= 0xDC00 && value <= 0xDFFF {
+ panic(call.runtime.panicURIError("URI malformed"))
+ }
+ if value >= 0xD800 && value <= 0xDBFF {
+ index += 1
+ if index >= length {
+ panic(call.runtime.panicURIError("URI malformed"))
+ }
+ // input = ..., value, value1, ...
+ value1 := input[index]
+ if value1 < 0xDC00 || value1 > 0xDFFF {
+ panic(call.runtime.panicURIError("URI malformed"))
+ }
+ decode = []rune{((rune(value) - 0xD800) * 0x400) + (rune(value1) - 0xDC00) + 0x10000}
+ }
+ index += 1
+ size := utf8.EncodeRune(encode, decode[0])
+ encode := encode[0:size]
+ output = append(output, encode...)
+ }
+ {
+ value := escape.ReplaceAllFunc(output, func(target []byte) []byte {
+ // Probably a better way of doing this
+ if target[0] == ' ' {
+ return []byte("%20")
+ }
+ return []byte(url.QueryEscape(string(target)))
+ })
+ return toValue_string(string(value))
+ }
+}
+
+var encodeURI_Regexp = regexp.MustCompile(`([^~!@#$&*()=:/,;?+'])`)
+
+func builtinGlobal_encodeURI(call FunctionCall) Value {
+ return _builtinGlobal_encodeURI(call, encodeURI_Regexp)
+}
+
+var encodeURIComponent_Regexp = regexp.MustCompile(`([^~!*()'])`)
+
+func builtinGlobal_encodeURIComponent(call FunctionCall) Value {
+ return _builtinGlobal_encodeURI(call, encodeURIComponent_Regexp)
+}
+
+// 3B/2F/3F/3A/40/26/3D/2B/24/2C/23
+var decodeURI_guard = regexp.MustCompile(`(?i)(?:%)(3B|2F|3F|3A|40|26|3D|2B|24|2C|23)`)
+
+func _decodeURI(input string, reserve bool) (string, bool) {
+ if reserve {
+ input = decodeURI_guard.ReplaceAllString(input, "%25$1")
+ }
+ input = strings.Replace(input, "+", "%2B", -1) // Ugly hack to make QueryUnescape work with our use case
+ output, err := url.QueryUnescape(input)
+ if err != nil || !utf8.ValidString(output) {
+ return "", true
+ }
+ return output, false
+}
+
+func builtinGlobal_decodeURI(call FunctionCall) Value {
+ output, err := _decodeURI(call.Argument(0).string(), true)
+ if err {
+ panic(call.runtime.panicURIError("URI malformed"))
+ }
+ return toValue_string(output)
+}
+
+func builtinGlobal_decodeURIComponent(call FunctionCall) Value {
+ output, err := _decodeURI(call.Argument(0).string(), false)
+ if err {
+ panic(call.runtime.panicURIError("URI malformed"))
+ }
+ return toValue_string(output)
+}
+
+// escape/unescape
+
+func builtin_shouldEscape(chr byte) bool {
+ if 'A' <= chr && chr <= 'Z' || 'a' <= chr && chr <= 'z' || '0' <= chr && chr <= '9' {
+ return false
+ }
+ return !strings.ContainsRune("*_+-./", rune(chr))
+}
+
+const escapeBase16 = "0123456789ABCDEF"
+
+func builtin_escape(input string) string {
+ output := make([]byte, 0, len(input))
+ length := len(input)
+ for index := 0; index < length; {
+ if builtin_shouldEscape(input[index]) {
+ chr, width := utf8.DecodeRuneInString(input[index:])
+ chr16 := utf16.Encode([]rune{chr})[0]
+ if 256 > chr16 {
+ output = append(output, '%',
+ escapeBase16[chr16>>4],
+ escapeBase16[chr16&15],
+ )
+ } else {
+ output = append(output, '%', 'u',
+ escapeBase16[chr16>>12],
+ escapeBase16[(chr16>>8)&15],
+ escapeBase16[(chr16>>4)&15],
+ escapeBase16[chr16&15],
+ )
+ }
+ index += width
+
+ } else {
+ output = append(output, input[index])
+ index += 1
+ }
+ }
+ return string(output)
+}
+
+func builtin_unescape(input string) string {
+ output := make([]rune, 0, len(input))
+ length := len(input)
+ for index := 0; index < length; {
+ if input[index] == '%' {
+ if index <= length-6 && input[index+1] == 'u' {
+ byte16, err := hex.DecodeString(input[index+2 : index+6])
+ if err == nil {
+ value := uint16(byte16[0])<<8 + uint16(byte16[1])
+ chr := utf16.Decode([]uint16{value})[0]
+ output = append(output, chr)
+ index += 6
+ continue
+ }
+ }
+ if index <= length-3 {
+ byte8, err := hex.DecodeString(input[index+1 : index+3])
+ if err == nil {
+ value := uint16(byte8[0])
+ chr := utf16.Decode([]uint16{value})[0]
+ output = append(output, chr)
+ index += 3
+ continue
+ }
+ }
+ }
+ output = append(output, rune(input[index]))
+ index += 1
+ }
+ return string(output)
+}
+
+func builtinGlobal_escape(call FunctionCall) Value {
+ return toValue_string(builtin_escape(call.Argument(0).string()))
+}
+
+func builtinGlobal_unescape(call FunctionCall) Value {
+ return toValue_string(builtin_unescape(call.Argument(0).string()))
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_array.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_array.go
new file mode 100644
index 000000000..44bf88569
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_array.go
@@ -0,0 +1,672 @@
+package otto
+
+import (
+ "strconv"
+ "strings"
+)
+
+// Array
+
+func builtinArray(call FunctionCall) Value {
+ return toValue_object(builtinNewArrayNative(call.runtime, call.ArgumentList))
+}
+
+func builtinNewArray(self *_object, argumentList []Value) Value {
+ return toValue_object(builtinNewArrayNative(self.runtime, argumentList))
+}
+
+func builtinNewArrayNative(runtime *_runtime, argumentList []Value) *_object {
+ if len(argumentList) == 1 {
+ firstArgument := argumentList[0]
+ if firstArgument.IsNumber() {
+ return runtime.newArray(arrayUint32(runtime, firstArgument))
+ }
+ }
+ return runtime.newArrayOf(argumentList)
+}
+
+func builtinArray_toString(call FunctionCall) Value {
+ thisObject := call.thisObject()
+ join := thisObject.get("join")
+ if join.isCallable() {
+ join := join._object()
+ return join.call(call.This, call.ArgumentList, false, nativeFrame)
+ }
+ return builtinObject_toString(call)
+}
+
+func builtinArray_toLocaleString(call FunctionCall) Value {
+ separator := ","
+ thisObject := call.thisObject()
+ length := int64(toUint32(thisObject.get("length")))
+ if length == 0 {
+ return toValue_string("")
+ }
+ stringList := make([]string, 0, length)
+ for index := int64(0); index < length; index += 1 {
+ value := thisObject.get(arrayIndexToString(index))
+ stringValue := ""
+ switch value.kind {
+ case valueEmpty, valueUndefined, valueNull:
+ default:
+ object := call.runtime.toObject(value)
+ toLocaleString := object.get("toLocaleString")
+ if !toLocaleString.isCallable() {
+ panic(call.runtime.panicTypeError())
+ }
+ stringValue = toLocaleString.call(call.runtime, toValue_object(object)).string()
+ }
+ stringList = append(stringList, stringValue)
+ }
+ return toValue_string(strings.Join(stringList, separator))
+}
+
+func builtinArray_concat(call FunctionCall) Value {
+ thisObject := call.thisObject()
+ valueArray := []Value{}
+ source := append([]Value{toValue_object(thisObject)}, call.ArgumentList...)
+ for _, item := range source {
+ switch item.kind {
+ case valueObject:
+ object := item._object()
+ if isArray(object) {
+ length := object.get("length").number().int64
+ for index := int64(0); index < length; index += 1 {
+ name := strconv.FormatInt(index, 10)
+ if object.hasProperty(name) {
+ valueArray = append(valueArray, object.get(name))
+ } else {
+ valueArray = append(valueArray, Value{})
+ }
+ }
+ continue
+ }
+ fallthrough
+ default:
+ valueArray = append(valueArray, item)
+ }
+ }
+ return toValue_object(call.runtime.newArrayOf(valueArray))
+}
+
+func builtinArray_shift(call FunctionCall) Value {
+ thisObject := call.thisObject()
+ length := int64(toUint32(thisObject.get("length")))
+ if 0 == length {
+ thisObject.put("length", toValue_int64(0), true)
+ return Value{}
+ }
+ first := thisObject.get("0")
+ for index := int64(1); index < length; index++ {
+ from := arrayIndexToString(index)
+ to := arrayIndexToString(index - 1)
+ if thisObject.hasProperty(from) {
+ thisObject.put(to, thisObject.get(from), true)
+ } else {
+ thisObject.delete(to, true)
+ }
+ }
+ thisObject.delete(arrayIndexToString(length-1), true)
+ thisObject.put("length", toValue_int64(length-1), true)
+ return first
+}
+
+func builtinArray_push(call FunctionCall) Value {
+ thisObject := call.thisObject()
+ itemList := call.ArgumentList
+ index := int64(toUint32(thisObject.get("length")))
+ for len(itemList) > 0 {
+ thisObject.put(arrayIndexToString(index), itemList[0], true)
+ itemList = itemList[1:]
+ index += 1
+ }
+ length := toValue_int64(index)
+ thisObject.put("length", length, true)
+ return length
+}
+
+func builtinArray_pop(call FunctionCall) Value {
+ thisObject := call.thisObject()
+ length := int64(toUint32(thisObject.get("length")))
+ if 0 == length {
+ thisObject.put("length", toValue_uint32(0), true)
+ return Value{}
+ }
+ last := thisObject.get(arrayIndexToString(length - 1))
+ thisObject.delete(arrayIndexToString(length-1), true)
+ thisObject.put("length", toValue_int64(length-1), true)
+ return last
+}
+
+func builtinArray_join(call FunctionCall) Value {
+ separator := ","
+ {
+ argument := call.Argument(0)
+ if argument.IsDefined() {
+ separator = argument.string()
+ }
+ }
+ thisObject := call.thisObject()
+ length := int64(toUint32(thisObject.get("length")))
+ if length == 0 {
+ return toValue_string("")
+ }
+ stringList := make([]string, 0, length)
+ for index := int64(0); index < length; index += 1 {
+ value := thisObject.get(arrayIndexToString(index))
+ stringValue := ""
+ switch value.kind {
+ case valueEmpty, valueUndefined, valueNull:
+ default:
+ stringValue = value.string()
+ }
+ stringList = append(stringList, stringValue)
+ }
+ return toValue_string(strings.Join(stringList, separator))
+}
+
+func builtinArray_splice(call FunctionCall) Value {
+ thisObject := call.thisObject()
+ length := int64(toUint32(thisObject.get("length")))
+
+ start := valueToRangeIndex(call.Argument(0), length, false)
+ deleteCount := valueToRangeIndex(call.Argument(1), int64(length)-start, true)
+ valueArray := make([]Value, deleteCount)
+
+ for index := int64(0); index < deleteCount; index++ {
+ indexString := arrayIndexToString(int64(start + index))
+ if thisObject.hasProperty(indexString) {
+ valueArray[index] = thisObject.get(indexString)
+ }
+ }
+
+ // 0, <1, 2, 3, 4>, 5, 6, 7
+ // a, b
+ // length 8 - delete 4 @ start 1
+
+ itemList := []Value{}
+ itemCount := int64(len(call.ArgumentList))
+ if itemCount > 2 {
+ itemCount -= 2 // Less the first two arguments
+ itemList = call.ArgumentList[2:]
+ } else {
+ itemCount = 0
+ }
+ if itemCount < deleteCount {
+ // The Object/Array is shrinking
+ stop := int64(length) - deleteCount
+ // The new length of the Object/Array before
+ // appending the itemList remainder
+ // Stopping at the lower bound of the insertion:
+ // Move an item from the after the deleted portion
+ // to a position after the inserted portion
+ for index := start; index < stop; index++ {
+ from := arrayIndexToString(index + deleteCount) // Position just after deletion
+ to := arrayIndexToString(index + itemCount) // Position just after splice (insertion)
+ if thisObject.hasProperty(from) {
+ thisObject.put(to, thisObject.get(from), true)
+ } else {
+ thisObject.delete(to, true)
+ }
+ }
+ // Delete off the end
+ // We don't bother to delete below <stop + itemCount> (if any) since those
+ // will be overwritten anyway
+ for index := int64(length); index > (stop + itemCount); index-- {
+ thisObject.delete(arrayIndexToString(index-1), true)
+ }
+ } else if itemCount > deleteCount {
+ // The Object/Array is growing
+ // The itemCount is greater than the deleteCount, so we do
+ // not have to worry about overwriting what we should be moving
+ // ---
+ // Starting from the upper bound of the deletion:
+ // Move an item from the after the deleted portion
+ // to a position after the inserted portion
+ for index := int64(length) - deleteCount; index > start; index-- {
+ from := arrayIndexToString(index + deleteCount - 1)
+ to := arrayIndexToString(index + itemCount - 1)
+ if thisObject.hasProperty(from) {
+ thisObject.put(to, thisObject.get(from), true)
+ } else {
+ thisObject.delete(to, true)
+ }
+ }
+ }
+
+ for index := int64(0); index < itemCount; index++ {
+ thisObject.put(arrayIndexToString(index+start), itemList[index], true)
+ }
+ thisObject.put("length", toValue_int64(int64(length)+itemCount-deleteCount), true)
+
+ return toValue_object(call.runtime.newArrayOf(valueArray))
+}
+
+func builtinArray_slice(call FunctionCall) Value {
+ thisObject := call.thisObject()
+
+ length := int64(toUint32(thisObject.get("length")))
+ start, end := rangeStartEnd(call.ArgumentList, length, false)
+
+ if start >= end {
+ // Always an empty array
+ return toValue_object(call.runtime.newArray(0))
+ }
+ sliceLength := end - start
+ sliceValueArray := make([]Value, sliceLength)
+
+ for index := int64(0); index < sliceLength; index++ {
+ from := arrayIndexToString(index + start)
+ if thisObject.hasProperty(from) {
+ sliceValueArray[index] = thisObject.get(from)
+ }
+ }
+
+ return toValue_object(call.runtime.newArrayOf(sliceValueArray))
+}
+
+func builtinArray_unshift(call FunctionCall) Value {
+ thisObject := call.thisObject()
+ length := int64(toUint32(thisObject.get("length")))
+ itemList := call.ArgumentList
+ itemCount := int64(len(itemList))
+
+ for index := length; index > 0; index-- {
+ from := arrayIndexToString(index - 1)
+ to := arrayIndexToString(index + itemCount - 1)
+ if thisObject.hasProperty(from) {
+ thisObject.put(to, thisObject.get(from), true)
+ } else {
+ thisObject.delete(to, true)
+ }
+ }
+
+ for index := int64(0); index < itemCount; index++ {
+ thisObject.put(arrayIndexToString(index), itemList[index], true)
+ }
+
+ newLength := toValue_int64(length + itemCount)
+ thisObject.put("length", newLength, true)
+ return newLength
+}
+
+func builtinArray_reverse(call FunctionCall) Value {
+ thisObject := call.thisObject()
+ length := int64(toUint32(thisObject.get("length")))
+
+ lower := struct {
+ name string
+ index int64
+ exists bool
+ }{}
+ upper := lower
+
+ lower.index = 0
+ middle := length / 2 // Division will floor
+
+ for lower.index != middle {
+ lower.name = arrayIndexToString(lower.index)
+ upper.index = length - lower.index - 1
+ upper.name = arrayIndexToString(upper.index)
+
+ lower.exists = thisObject.hasProperty(lower.name)
+ upper.exists = thisObject.hasProperty(upper.name)
+
+ if lower.exists && upper.exists {
+ lowerValue := thisObject.get(lower.name)
+ upperValue := thisObject.get(upper.name)
+ thisObject.put(lower.name, upperValue, true)
+ thisObject.put(upper.name, lowerValue, true)
+ } else if !lower.exists && upper.exists {
+ value := thisObject.get(upper.name)
+ thisObject.delete(upper.name, true)
+ thisObject.put(lower.name, value, true)
+ } else if lower.exists && !upper.exists {
+ value := thisObject.get(lower.name)
+ thisObject.delete(lower.name, true)
+ thisObject.put(upper.name, value, true)
+ } else {
+ // Nothing happens.
+ }
+
+ lower.index += 1
+ }
+
+ return call.This
+}
+
+func sortCompare(thisObject *_object, index0, index1 uint, compare *_object) int {
+ j := struct {
+ name string
+ exists bool
+ defined bool
+ value string
+ }{}
+ k := j
+ j.name = arrayIndexToString(int64(index0))
+ j.exists = thisObject.hasProperty(j.name)
+ k.name = arrayIndexToString(int64(index1))
+ k.exists = thisObject.hasProperty(k.name)
+
+ if !j.exists && !k.exists {
+ return 0
+ } else if !j.exists {
+ return 1
+ } else if !k.exists {
+ return -1
+ }
+
+ x := thisObject.get(j.name)
+ y := thisObject.get(k.name)
+ j.defined = x.IsDefined()
+ k.defined = y.IsDefined()
+
+ if !j.defined && !k.defined {
+ return 0
+ } else if !j.defined {
+ return 1
+ } else if !k.defined {
+ return -1
+ }
+
+ if compare == nil {
+ j.value = x.string()
+ k.value = y.string()
+
+ if j.value == k.value {
+ return 0
+ } else if j.value < k.value {
+ return -1
+ }
+
+ return 1
+ }
+
+ return int(toInt32(compare.call(Value{}, []Value{x, y}, false, nativeFrame)))
+}
+
+func arraySortSwap(thisObject *_object, index0, index1 uint) {
+
+ j := struct {
+ name string
+ exists bool
+ }{}
+ k := j
+
+ j.name = arrayIndexToString(int64(index0))
+ j.exists = thisObject.hasProperty(j.name)
+ k.name = arrayIndexToString(int64(index1))
+ k.exists = thisObject.hasProperty(k.name)
+
+ if j.exists && k.exists {
+ jValue := thisObject.get(j.name)
+ kValue := thisObject.get(k.name)
+ thisObject.put(j.name, kValue, true)
+ thisObject.put(k.name, jValue, true)
+ } else if !j.exists && k.exists {
+ value := thisObject.get(k.name)
+ thisObject.delete(k.name, true)
+ thisObject.put(j.name, value, true)
+ } else if j.exists && !k.exists {
+ value := thisObject.get(j.name)
+ thisObject.delete(j.name, true)
+ thisObject.put(k.name, value, true)
+ } else {
+ // Nothing happens.
+ }
+}
+
+func arraySortQuickPartition(thisObject *_object, left, right, pivot uint, compare *_object) uint {
+ arraySortSwap(thisObject, pivot, right) // Right is now the pivot value
+ cursor := left
+ for index := left; index < right; index++ {
+ if sortCompare(thisObject, index, right, compare) == -1 { // Compare to the pivot value
+ arraySortSwap(thisObject, index, cursor)
+ cursor += 1
+ }
+ }
+ arraySortSwap(thisObject, cursor, right)
+ return cursor
+}
+
+func arraySortQuickSort(thisObject *_object, left, right uint, compare *_object) {
+ if left < right {
+ pivot := left + (right-left)/2
+ pivot = arraySortQuickPartition(thisObject, left, right, pivot, compare)
+ if pivot > 0 {
+ arraySortQuickSort(thisObject, left, pivot-1, compare)
+ }
+ arraySortQuickSort(thisObject, pivot+1, right, compare)
+ }
+}
+
+func builtinArray_sort(call FunctionCall) Value {
+ thisObject := call.thisObject()
+ length := uint(toUint32(thisObject.get("length")))
+ compareValue := call.Argument(0)
+ compare := compareValue._object()
+ if compareValue.IsUndefined() {
+ } else if !compareValue.isCallable() {
+ panic(call.runtime.panicTypeError())
+ }
+ if length > 1 {
+ arraySortQuickSort(thisObject, 0, length-1, compare)
+ }
+ return call.This
+}
+
+func builtinArray_isArray(call FunctionCall) Value {
+ return toValue_bool(isArray(call.Argument(0)._object()))
+}
+
+func builtinArray_indexOf(call FunctionCall) Value {
+ thisObject, matchValue := call.thisObject(), call.Argument(0)
+ if length := int64(toUint32(thisObject.get("length"))); length > 0 {
+ index := int64(0)
+ if len(call.ArgumentList) > 1 {
+ index = call.Argument(1).number().int64
+ }
+ if index < 0 {
+ if index += length; index < 0 {
+ index = 0
+ }
+ } else if index >= length {
+ index = -1
+ }
+ for ; index >= 0 && index < length; index++ {
+ name := arrayIndexToString(int64(index))
+ if !thisObject.hasProperty(name) {
+ continue
+ }
+ value := thisObject.get(name)
+ if strictEqualityComparison(matchValue, value) {
+ return toValue_uint32(uint32(index))
+ }
+ }
+ }
+ return toValue_int(-1)
+}
+
+func builtinArray_lastIndexOf(call FunctionCall) Value {
+ thisObject, matchValue := call.thisObject(), call.Argument(0)
+ length := int64(toUint32(thisObject.get("length")))
+ index := length - 1
+ if len(call.ArgumentList) > 1 {
+ index = call.Argument(1).number().int64
+ }
+ if 0 > index {
+ index += length
+ }
+ if index > length {
+ index = length - 1
+ } else if 0 > index {
+ return toValue_int(-1)
+ }
+ for ; index >= 0; index-- {
+ name := arrayIndexToString(int64(index))
+ if !thisObject.hasProperty(name) {
+ continue
+ }
+ value := thisObject.get(name)
+ if strictEqualityComparison(matchValue, value) {
+ return toValue_uint32(uint32(index))
+ }
+ }
+ return toValue_int(-1)
+}
+
+func builtinArray_every(call FunctionCall) Value {
+ thisObject := call.thisObject()
+ this := toValue_object(thisObject)
+ if iterator := call.Argument(0); iterator.isCallable() {
+ length := int64(toUint32(thisObject.get("length")))
+ callThis := call.Argument(1)
+ for index := int64(0); index < length; index++ {
+ if key := arrayIndexToString(index); thisObject.hasProperty(key) {
+ if value := thisObject.get(key); iterator.call(call.runtime, callThis, value, toValue_int64(index), this).bool() {
+ continue
+ }
+ return falseValue
+ }
+ }
+ return trueValue
+ }
+ panic(call.runtime.panicTypeError())
+}
+
+func builtinArray_some(call FunctionCall) Value {
+ thisObject := call.thisObject()
+ this := toValue_object(thisObject)
+ if iterator := call.Argument(0); iterator.isCallable() {
+ length := int64(toUint32(thisObject.get("length")))
+ callThis := call.Argument(1)
+ for index := int64(0); index < length; index++ {
+ if key := arrayIndexToString(index); thisObject.hasProperty(key) {
+ if value := thisObject.get(key); iterator.call(call.runtime, callThis, value, toValue_int64(index), this).bool() {
+ return trueValue
+ }
+ }
+ }
+ return falseValue
+ }
+ panic(call.runtime.panicTypeError())
+}
+
+func builtinArray_forEach(call FunctionCall) Value {
+ thisObject := call.thisObject()
+ this := toValue_object(thisObject)
+ if iterator := call.Argument(0); iterator.isCallable() {
+ length := int64(toUint32(thisObject.get("length")))
+ callThis := call.Argument(1)
+ for index := int64(0); index < length; index++ {
+ if key := arrayIndexToString(index); thisObject.hasProperty(key) {
+ iterator.call(call.runtime, callThis, thisObject.get(key), toValue_int64(index), this)
+ }
+ }
+ return Value{}
+ }
+ panic(call.runtime.panicTypeError())
+}
+
+func builtinArray_map(call FunctionCall) Value {
+ thisObject := call.thisObject()
+ this := toValue_object(thisObject)
+ if iterator := call.Argument(0); iterator.isCallable() {
+ length := int64(toUint32(thisObject.get("length")))
+ callThis := call.Argument(1)
+ values := make([]Value, length)
+ for index := int64(0); index < length; index++ {
+ if key := arrayIndexToString(index); thisObject.hasProperty(key) {
+ values[index] = iterator.call(call.runtime, callThis, thisObject.get(key), index, this)
+ } else {
+ values[index] = Value{}
+ }
+ }
+ return toValue_object(call.runtime.newArrayOf(values))
+ }
+ panic(call.runtime.panicTypeError())
+}
+
+func builtinArray_filter(call FunctionCall) Value {
+ thisObject := call.thisObject()
+ this := toValue_object(thisObject)
+ if iterator := call.Argument(0); iterator.isCallable() {
+ length := int64(toUint32(thisObject.get("length")))
+ callThis := call.Argument(1)
+ values := make([]Value, 0)
+ for index := int64(0); index < length; index++ {
+ if key := arrayIndexToString(index); thisObject.hasProperty(key) {
+ value := thisObject.get(key)
+ if iterator.call(call.runtime, callThis, value, index, this).bool() {
+ values = append(values, value)
+ }
+ }
+ }
+ return toValue_object(call.runtime.newArrayOf(values))
+ }
+ panic(call.runtime.panicTypeError())
+}
+
+func builtinArray_reduce(call FunctionCall) Value {
+ thisObject := call.thisObject()
+ this := toValue_object(thisObject)
+ if iterator := call.Argument(0); iterator.isCallable() {
+ initial := len(call.ArgumentList) > 1
+ start := call.Argument(1)
+ length := int64(toUint32(thisObject.get("length")))
+ index := int64(0)
+ if length > 0 || initial {
+ var accumulator Value
+ if !initial {
+ for ; index < length; index++ {
+ if key := arrayIndexToString(index); thisObject.hasProperty(key) {
+ accumulator = thisObject.get(key)
+ index++
+ break
+ }
+ }
+ } else {
+ accumulator = start
+ }
+ for ; index < length; index++ {
+ if key := arrayIndexToString(index); thisObject.hasProperty(key) {
+ accumulator = iterator.call(call.runtime, Value{}, accumulator, thisObject.get(key), key, this)
+ }
+ }
+ return accumulator
+ }
+ }
+ panic(call.runtime.panicTypeError())
+}
+
+func builtinArray_reduceRight(call FunctionCall) Value {
+ thisObject := call.thisObject()
+ this := toValue_object(thisObject)
+ if iterator := call.Argument(0); iterator.isCallable() {
+ initial := len(call.ArgumentList) > 1
+ start := call.Argument(1)
+ length := int64(toUint32(thisObject.get("length")))
+ if length > 0 || initial {
+ index := length - 1
+ var accumulator Value
+ if !initial {
+ for ; index >= 0; index-- {
+ if key := arrayIndexToString(index); thisObject.hasProperty(key) {
+ accumulator = thisObject.get(key)
+ index -= 1
+ break
+ }
+ }
+ } else {
+ accumulator = start
+ }
+ for ; index >= 0; index-- {
+ if key := arrayIndexToString(index); thisObject.hasProperty(key) {
+ accumulator = iterator.call(call.runtime, Value{}, accumulator, thisObject.get(key), key, this)
+ }
+ }
+ return accumulator
+ }
+ }
+ panic(call.runtime.panicTypeError())
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_boolean.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_boolean.go
new file mode 100644
index 000000000..59b8e789b
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_boolean.go
@@ -0,0 +1,28 @@
+package otto
+
+// Boolean
+
+func builtinBoolean(call FunctionCall) Value {
+ return toValue_bool(call.Argument(0).bool())
+}
+
+func builtinNewBoolean(self *_object, argumentList []Value) Value {
+ return toValue_object(self.runtime.newBoolean(valueOfArrayIndex(argumentList, 0)))
+}
+
+func builtinBoolean_toString(call FunctionCall) Value {
+ value := call.This
+ if !value.IsBoolean() {
+ // Will throw a TypeError if ThisObject is not a Boolean
+ value = call.thisClassObject("Boolean").primitiveValue()
+ }
+ return toValue_string(value.string())
+}
+
+func builtinBoolean_valueOf(call FunctionCall) Value {
+ value := call.This
+ if !value.IsBoolean() {
+ value = call.thisClassObject("Boolean").primitiveValue()
+ }
+ return value
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_date.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_date.go
new file mode 100644
index 000000000..f20bf8e3f
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_date.go
@@ -0,0 +1,615 @@
+package otto
+
+import (
+ "math"
+ Time "time"
+)
+
+// Date
+
+const (
+ // TODO Be like V8?
+ // builtinDate_goDateTimeLayout = "Mon Jan 2 2006 15:04:05 GMT-0700 (MST)"
+ builtinDate_goDateTimeLayout = Time.RFC1123 // "Mon, 02 Jan 2006 15:04:05 MST"
+ builtinDate_goDateLayout = "Mon, 02 Jan 2006"
+ builtinDate_goTimeLayout = "15:04:05 MST"
+)
+
+func builtinDate(call FunctionCall) Value {
+ date := &_dateObject{}
+ date.Set(newDateTime([]Value{}, Time.Local))
+ return toValue_string(date.Time().Format(builtinDate_goDateTimeLayout))
+}
+
+func builtinNewDate(self *_object, argumentList []Value) Value {
+ return toValue_object(self.runtime.newDate(newDateTime(argumentList, Time.Local)))
+}
+
+func builtinDate_toString(call FunctionCall) Value {
+ date := dateObjectOf(call.runtime, call.thisObject())
+ if date.isNaN {
+ return toValue_string("Invalid Date")
+ }
+ return toValue_string(date.Time().Local().Format(builtinDate_goDateTimeLayout))
+}
+
+func builtinDate_toDateString(call FunctionCall) Value {
+ date := dateObjectOf(call.runtime, call.thisObject())
+ if date.isNaN {
+ return toValue_string("Invalid Date")
+ }
+ return toValue_string(date.Time().Local().Format(builtinDate_goDateLayout))
+}
+
+func builtinDate_toTimeString(call FunctionCall) Value {
+ date := dateObjectOf(call.runtime, call.thisObject())
+ if date.isNaN {
+ return toValue_string("Invalid Date")
+ }
+ return toValue_string(date.Time().Local().Format(builtinDate_goTimeLayout))
+}
+
+func builtinDate_toUTCString(call FunctionCall) Value {
+ date := dateObjectOf(call.runtime, call.thisObject())
+ if date.isNaN {
+ return toValue_string("Invalid Date")
+ }
+ return toValue_string(date.Time().Format(builtinDate_goDateTimeLayout))
+}
+
+func builtinDate_toISOString(call FunctionCall) Value {
+ date := dateObjectOf(call.runtime, call.thisObject())
+ if date.isNaN {
+ return toValue_string("Invalid Date")
+ }
+ return toValue_string(date.Time().Format("2006-01-02T15:04:05.000Z"))
+}
+
+func builtinDate_toJSON(call FunctionCall) Value {
+ object := call.thisObject()
+ value := object.DefaultValue(defaultValueHintNumber) // FIXME object.primitiveNumberValue
+ { // FIXME value.isFinite
+ value := value.float64()
+ if math.IsNaN(value) || math.IsInf(value, 0) {
+ return nullValue
+ }
+ }
+ toISOString := object.get("toISOString")
+ if !toISOString.isCallable() {
+ // FIXME
+ panic(call.runtime.panicTypeError())
+ }
+ return toISOString.call(call.runtime, toValue_object(object), []Value{})
+}
+
+func builtinDate_toGMTString(call FunctionCall) Value {
+ date := dateObjectOf(call.runtime, call.thisObject())
+ if date.isNaN {
+ return toValue_string("Invalid Date")
+ }
+ return toValue_string(date.Time().Format("Mon, 02 Jan 2006 15:04:05 GMT"))
+}
+
+func builtinDate_getTime(call FunctionCall) Value {
+ date := dateObjectOf(call.runtime, call.thisObject())
+ if date.isNaN {
+ return NaNValue()
+ }
+ // We do this (convert away from a float) so the user
+ // does not get something back in exponential notation
+ return toValue_int64(int64(date.Epoch()))
+}
+
+func builtinDate_setTime(call FunctionCall) Value {
+ object := call.thisObject()
+ date := dateObjectOf(call.runtime, call.thisObject())
+ date.Set(call.Argument(0).float64())
+ object.value = date
+ return date.Value()
+}
+
+func _builtinDate_beforeSet(call FunctionCall, argumentLimit int, timeLocal bool) (*_object, *_dateObject, *_ecmaTime, []int) {
+ object := call.thisObject()
+ date := dateObjectOf(call.runtime, call.thisObject())
+ if date.isNaN {
+ return nil, nil, nil, nil
+ }
+
+ if argumentLimit > len(call.ArgumentList) {
+ argumentLimit = len(call.ArgumentList)
+ }
+
+ if argumentLimit == 0 {
+ object.value = invalidDateObject
+ return nil, nil, nil, nil
+ }
+
+ valueList := make([]int, argumentLimit)
+ for index := 0; index < argumentLimit; index++ {
+ value := call.ArgumentList[index]
+ nm := value.number()
+ switch nm.kind {
+ case numberInteger, numberFloat:
+ default:
+ object.value = invalidDateObject
+ return nil, nil, nil, nil
+ }
+ valueList[index] = int(nm.int64)
+ }
+ baseTime := date.Time()
+ if timeLocal {
+ baseTime = baseTime.Local()
+ }
+ ecmaTime := ecmaTime(baseTime)
+ return object, &date, &ecmaTime, valueList
+}
+
+func builtinDate_parse(call FunctionCall) Value {
+ date := call.Argument(0).string()
+ return toValue_float64(dateParse(date))
+}
+
+func builtinDate_UTC(call FunctionCall) Value {
+ return toValue_float64(newDateTime(call.ArgumentList, Time.UTC))
+}
+
+func builtinDate_now(call FunctionCall) Value {
+ call.ArgumentList = []Value(nil)
+ return builtinDate_UTC(call)
+}
+
+// This is a placeholder
+func builtinDate_toLocaleString(call FunctionCall) Value {
+ date := dateObjectOf(call.runtime, call.thisObject())
+ if date.isNaN {
+ return toValue_string("Invalid Date")
+ }
+ return toValue_string(date.Time().Local().Format("2006-01-02 15:04:05"))
+}
+
+// This is a placeholder
+func builtinDate_toLocaleDateString(call FunctionCall) Value {
+ date := dateObjectOf(call.runtime, call.thisObject())
+ if date.isNaN {
+ return toValue_string("Invalid Date")
+ }
+ return toValue_string(date.Time().Local().Format("2006-01-02"))
+}
+
+// This is a placeholder
+func builtinDate_toLocaleTimeString(call FunctionCall) Value {
+ date := dateObjectOf(call.runtime, call.thisObject())
+ if date.isNaN {
+ return toValue_string("Invalid Date")
+ }
+ return toValue_string(date.Time().Local().Format("15:04:05"))
+}
+
+func builtinDate_valueOf(call FunctionCall) Value {
+ date := dateObjectOf(call.runtime, call.thisObject())
+ if date.isNaN {
+ return NaNValue()
+ }
+ return date.Value()
+}
+
+func builtinDate_getYear(call FunctionCall) Value {
+ // Will throw a TypeError is ThisObject is nil or
+ // does not have Class of "Date"
+ date := dateObjectOf(call.runtime, call.thisObject())
+ if date.isNaN {
+ return NaNValue()
+ }
+ return toValue_int(date.Time().Local().Year() - 1900)
+}
+
+func builtinDate_getFullYear(call FunctionCall) Value {
+ // Will throw a TypeError is ThisObject is nil or
+ // does not have Class of "Date"
+ date := dateObjectOf(call.runtime, call.thisObject())
+ if date.isNaN {
+ return NaNValue()
+ }
+ return toValue_int(date.Time().Local().Year())
+}
+
+func builtinDate_getUTCFullYear(call FunctionCall) Value {
+ date := dateObjectOf(call.runtime, call.thisObject())
+ if date.isNaN {
+ return NaNValue()
+ }
+ return toValue_int(date.Time().Year())
+}
+
+func builtinDate_getMonth(call FunctionCall) Value {
+ date := dateObjectOf(call.runtime, call.thisObject())
+ if date.isNaN {
+ return NaNValue()
+ }
+ return toValue_int(dateFromGoMonth(date.Time().Local().Month()))
+}
+
+func builtinDate_getUTCMonth(call FunctionCall) Value {
+ date := dateObjectOf(call.runtime, call.thisObject())
+ if date.isNaN {
+ return NaNValue()
+ }
+ return toValue_int(dateFromGoMonth(date.Time().Month()))
+}
+
+func builtinDate_getDate(call FunctionCall) Value {
+ date := dateObjectOf(call.runtime, call.thisObject())
+ if date.isNaN {
+ return NaNValue()
+ }
+ return toValue_int(date.Time().Local().Day())
+}
+
+func builtinDate_getUTCDate(call FunctionCall) Value {
+ date := dateObjectOf(call.runtime, call.thisObject())
+ if date.isNaN {
+ return NaNValue()
+ }
+ return toValue_int(date.Time().Day())
+}
+
+func builtinDate_getDay(call FunctionCall) Value {
+ // Actually day of the week
+ date := dateObjectOf(call.runtime, call.thisObject())
+ if date.isNaN {
+ return NaNValue()
+ }
+ return toValue_int(dateFromGoDay(date.Time().Local().Weekday()))
+}
+
+func builtinDate_getUTCDay(call FunctionCall) Value {
+ date := dateObjectOf(call.runtime, call.thisObject())
+ if date.isNaN {
+ return NaNValue()
+ }
+ return toValue_int(dateFromGoDay(date.Time().Weekday()))
+}
+
+func builtinDate_getHours(call FunctionCall) Value {
+ date := dateObjectOf(call.runtime, call.thisObject())
+ if date.isNaN {
+ return NaNValue()
+ }
+ return toValue_int(date.Time().Local().Hour())
+}
+
+func builtinDate_getUTCHours(call FunctionCall) Value {
+ date := dateObjectOf(call.runtime, call.thisObject())
+ if date.isNaN {
+ return NaNValue()
+ }
+ return toValue_int(date.Time().Hour())
+}
+
+func builtinDate_getMinutes(call FunctionCall) Value {
+ date := dateObjectOf(call.runtime, call.thisObject())
+ if date.isNaN {
+ return NaNValue()
+ }
+ return toValue_int(date.Time().Local().Minute())
+}
+
+func builtinDate_getUTCMinutes(call FunctionCall) Value {
+ date := dateObjectOf(call.runtime, call.thisObject())
+ if date.isNaN {
+ return NaNValue()
+ }
+ return toValue_int(date.Time().Minute())
+}
+
+func builtinDate_getSeconds(call FunctionCall) Value {
+ date := dateObjectOf(call.runtime, call.thisObject())
+ if date.isNaN {
+ return NaNValue()
+ }
+ return toValue_int(date.Time().Local().Second())
+}
+
+func builtinDate_getUTCSeconds(call FunctionCall) Value {
+ date := dateObjectOf(call.runtime, call.thisObject())
+ if date.isNaN {
+ return NaNValue()
+ }
+ return toValue_int(date.Time().Second())
+}
+
+func builtinDate_getMilliseconds(call FunctionCall) Value {
+ date := dateObjectOf(call.runtime, call.thisObject())
+ if date.isNaN {
+ return NaNValue()
+ }
+ return toValue_int(date.Time().Local().Nanosecond() / (100 * 100 * 100))
+}
+
+func builtinDate_getUTCMilliseconds(call FunctionCall) Value {
+ date := dateObjectOf(call.runtime, call.thisObject())
+ if date.isNaN {
+ return NaNValue()
+ }
+ return toValue_int(date.Time().Nanosecond() / (100 * 100 * 100))
+}
+
+func builtinDate_getTimezoneOffset(call FunctionCall) Value {
+ date := dateObjectOf(call.runtime, call.thisObject())
+ if date.isNaN {
+ return NaNValue()
+ }
+ timeLocal := date.Time().Local()
+ // Is this kosher?
+ timeLocalAsUTC := Time.Date(
+ timeLocal.Year(),
+ timeLocal.Month(),
+ timeLocal.Day(),
+ timeLocal.Hour(),
+ timeLocal.Minute(),
+ timeLocal.Second(),
+ timeLocal.Nanosecond(),
+ Time.UTC,
+ )
+ return toValue_float64(date.Time().Sub(timeLocalAsUTC).Seconds() / 60)
+}
+
+func builtinDate_setMilliseconds(call FunctionCall) Value {
+ object, date, ecmaTime, value := _builtinDate_beforeSet(call, 1, true)
+ if ecmaTime == nil {
+ return NaNValue()
+ }
+
+ ecmaTime.millisecond = value[0]
+
+ date.SetTime(ecmaTime.goTime())
+ object.value = *date
+ return date.Value()
+}
+
+func builtinDate_setUTCMilliseconds(call FunctionCall) Value {
+ object, date, ecmaTime, value := _builtinDate_beforeSet(call, 1, false)
+ if ecmaTime == nil {
+ return NaNValue()
+ }
+
+ ecmaTime.millisecond = value[0]
+
+ date.SetTime(ecmaTime.goTime())
+ object.value = *date
+ return date.Value()
+}
+
+func builtinDate_setSeconds(call FunctionCall) Value {
+ object, date, ecmaTime, value := _builtinDate_beforeSet(call, 2, true)
+ if ecmaTime == nil {
+ return NaNValue()
+ }
+
+ if len(value) > 1 {
+ ecmaTime.millisecond = value[1]
+ }
+ ecmaTime.second = value[0]
+
+ date.SetTime(ecmaTime.goTime())
+ object.value = *date
+ return date.Value()
+}
+
+func builtinDate_setUTCSeconds(call FunctionCall) Value {
+ object, date, ecmaTime, value := _builtinDate_beforeSet(call, 2, false)
+ if ecmaTime == nil {
+ return NaNValue()
+ }
+
+ if len(value) > 1 {
+ ecmaTime.millisecond = value[1]
+ }
+ ecmaTime.second = value[0]
+
+ date.SetTime(ecmaTime.goTime())
+ object.value = *date
+ return date.Value()
+}
+
+func builtinDate_setMinutes(call FunctionCall) Value {
+ object, date, ecmaTime, value := _builtinDate_beforeSet(call, 3, true)
+ if ecmaTime == nil {
+ return NaNValue()
+ }
+
+ if len(value) > 2 {
+ ecmaTime.millisecond = value[2]
+ ecmaTime.second = value[1]
+ } else if len(value) > 1 {
+ ecmaTime.second = value[1]
+ }
+ ecmaTime.minute = value[0]
+
+ date.SetTime(ecmaTime.goTime())
+ object.value = *date
+ return date.Value()
+}
+
+func builtinDate_setUTCMinutes(call FunctionCall) Value {
+ object, date, ecmaTime, value := _builtinDate_beforeSet(call, 3, false)
+ if ecmaTime == nil {
+ return NaNValue()
+ }
+
+ if len(value) > 2 {
+ ecmaTime.millisecond = value[2]
+ ecmaTime.second = value[1]
+ } else if len(value) > 1 {
+ ecmaTime.second = value[1]
+ }
+ ecmaTime.minute = value[0]
+
+ date.SetTime(ecmaTime.goTime())
+ object.value = *date
+ return date.Value()
+}
+
+func builtinDate_setHours(call FunctionCall) Value {
+ object, date, ecmaTime, value := _builtinDate_beforeSet(call, 4, true)
+ if ecmaTime == nil {
+ return NaNValue()
+ }
+
+ if len(value) > 3 {
+ ecmaTime.millisecond = value[3]
+ ecmaTime.second = value[2]
+ ecmaTime.minute = value[1]
+ } else if len(value) > 2 {
+ ecmaTime.second = value[2]
+ ecmaTime.minute = value[1]
+ } else if len(value) > 1 {
+ ecmaTime.minute = value[1]
+ }
+ ecmaTime.hour = value[0]
+
+ date.SetTime(ecmaTime.goTime())
+ object.value = *date
+ return date.Value()
+}
+
+func builtinDate_setUTCHours(call FunctionCall) Value {
+ object, date, ecmaTime, value := _builtinDate_beforeSet(call, 4, false)
+ if ecmaTime == nil {
+ return NaNValue()
+ }
+
+ if len(value) > 3 {
+ ecmaTime.millisecond = value[3]
+ ecmaTime.second = value[2]
+ ecmaTime.minute = value[1]
+ } else if len(value) > 2 {
+ ecmaTime.second = value[2]
+ ecmaTime.minute = value[1]
+ } else if len(value) > 1 {
+ ecmaTime.minute = value[1]
+ }
+ ecmaTime.hour = value[0]
+
+ date.SetTime(ecmaTime.goTime())
+ object.value = *date
+ return date.Value()
+}
+
+func builtinDate_setDate(call FunctionCall) Value {
+ object, date, ecmaTime, value := _builtinDate_beforeSet(call, 1, true)
+ if ecmaTime == nil {
+ return NaNValue()
+ }
+
+ ecmaTime.day = value[0]
+
+ date.SetTime(ecmaTime.goTime())
+ object.value = *date
+ return date.Value()
+}
+
+func builtinDate_setUTCDate(call FunctionCall) Value {
+ object, date, ecmaTime, value := _builtinDate_beforeSet(call, 1, false)
+ if ecmaTime == nil {
+ return NaNValue()
+ }
+
+ ecmaTime.day = value[0]
+
+ date.SetTime(ecmaTime.goTime())
+ object.value = *date
+ return date.Value()
+}
+
+func builtinDate_setMonth(call FunctionCall) Value {
+ object, date, ecmaTime, value := _builtinDate_beforeSet(call, 2, true)
+ if ecmaTime == nil {
+ return NaNValue()
+ }
+
+ if len(value) > 1 {
+ ecmaTime.day = value[1]
+ }
+ ecmaTime.month = value[0]
+
+ date.SetTime(ecmaTime.goTime())
+ object.value = *date
+ return date.Value()
+}
+
+func builtinDate_setUTCMonth(call FunctionCall) Value {
+ object, date, ecmaTime, value := _builtinDate_beforeSet(call, 2, false)
+ if ecmaTime == nil {
+ return NaNValue()
+ }
+
+ if len(value) > 1 {
+ ecmaTime.day = value[1]
+ }
+ ecmaTime.month = value[0]
+
+ date.SetTime(ecmaTime.goTime())
+ object.value = *date
+ return date.Value()
+}
+
+func builtinDate_setYear(call FunctionCall) Value {
+ object, date, ecmaTime, value := _builtinDate_beforeSet(call, 1, true)
+ if ecmaTime == nil {
+ return NaNValue()
+ }
+
+ year := value[0]
+ if 0 <= year && year <= 99 {
+ year += 1900
+ }
+ ecmaTime.year = year
+
+ date.SetTime(ecmaTime.goTime())
+ object.value = *date
+ return date.Value()
+}
+
+func builtinDate_setFullYear(call FunctionCall) Value {
+ object, date, ecmaTime, value := _builtinDate_beforeSet(call, 3, true)
+ if ecmaTime == nil {
+ return NaNValue()
+ }
+
+ if len(value) > 2 {
+ ecmaTime.day = value[2]
+ ecmaTime.month = value[1]
+ } else if len(value) > 1 {
+ ecmaTime.month = value[1]
+ }
+ ecmaTime.year = value[0]
+
+ date.SetTime(ecmaTime.goTime())
+ object.value = *date
+ return date.Value()
+}
+
+func builtinDate_setUTCFullYear(call FunctionCall) Value {
+ object, date, ecmaTime, value := _builtinDate_beforeSet(call, 3, false)
+ if ecmaTime == nil {
+ return NaNValue()
+ }
+
+ if len(value) > 2 {
+ ecmaTime.day = value[2]
+ ecmaTime.month = value[1]
+ } else if len(value) > 1 {
+ ecmaTime.month = value[1]
+ }
+ ecmaTime.year = value[0]
+
+ date.SetTime(ecmaTime.goTime())
+ object.value = *date
+ return date.Value()
+}
+
+// toUTCString
+// toISOString
+// toJSONString
+// toJSON
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_error.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_error.go
new file mode 100644
index 000000000..4c054fbea
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_error.go
@@ -0,0 +1,126 @@
+package otto
+
+import (
+ "fmt"
+)
+
+func builtinError(call FunctionCall) Value {
+ return toValue_object(call.runtime.newError("", call.Argument(0)))
+}
+
+func builtinNewError(self *_object, argumentList []Value) Value {
+ return toValue_object(self.runtime.newError("", valueOfArrayIndex(argumentList, 0)))
+}
+
+func builtinError_toString(call FunctionCall) Value {
+ thisObject := call.thisObject()
+ if thisObject == nil {
+ panic(call.runtime.panicTypeError())
+ }
+
+ name := "Error"
+ nameValue := thisObject.get("name")
+ if nameValue.IsDefined() {
+ name = nameValue.string()
+ }
+
+ message := ""
+ messageValue := thisObject.get("message")
+ if messageValue.IsDefined() {
+ message = messageValue.string()
+ }
+
+ if len(name) == 0 {
+ return toValue_string(message)
+ }
+
+ if len(message) == 0 {
+ return toValue_string(name)
+ }
+
+ return toValue_string(fmt.Sprintf("%s: %s", name, message))
+}
+
+func (runtime *_runtime) newEvalError(message Value) *_object {
+ self := runtime.newErrorObject("EvalError", message)
+ self.prototype = runtime.global.EvalErrorPrototype
+ return self
+}
+
+func builtinEvalError(call FunctionCall) Value {
+ return toValue_object(call.runtime.newEvalError(call.Argument(0)))
+}
+
+func builtinNewEvalError(self *_object, argumentList []Value) Value {
+ return toValue_object(self.runtime.newEvalError(valueOfArrayIndex(argumentList, 0)))
+}
+
+func (runtime *_runtime) newTypeError(message Value) *_object {
+ self := runtime.newErrorObject("TypeError", message)
+ self.prototype = runtime.global.TypeErrorPrototype
+ return self
+}
+
+func builtinTypeError(call FunctionCall) Value {
+ return toValue_object(call.runtime.newTypeError(call.Argument(0)))
+}
+
+func builtinNewTypeError(self *_object, argumentList []Value) Value {
+ return toValue_object(self.runtime.newTypeError(valueOfArrayIndex(argumentList, 0)))
+}
+
+func (runtime *_runtime) newRangeError(message Value) *_object {
+ self := runtime.newErrorObject("RangeError", message)
+ self.prototype = runtime.global.RangeErrorPrototype
+ return self
+}
+
+func builtinRangeError(call FunctionCall) Value {
+ return toValue_object(call.runtime.newRangeError(call.Argument(0)))
+}
+
+func builtinNewRangeError(self *_object, argumentList []Value) Value {
+ return toValue_object(self.runtime.newRangeError(valueOfArrayIndex(argumentList, 0)))
+}
+
+func (runtime *_runtime) newURIError(message Value) *_object {
+ self := runtime.newErrorObject("URIError", message)
+ self.prototype = runtime.global.URIErrorPrototype
+ return self
+}
+
+func (runtime *_runtime) newReferenceError(message Value) *_object {
+ self := runtime.newErrorObject("ReferenceError", message)
+ self.prototype = runtime.global.ReferenceErrorPrototype
+ return self
+}
+
+func builtinReferenceError(call FunctionCall) Value {
+ return toValue_object(call.runtime.newReferenceError(call.Argument(0)))
+}
+
+func builtinNewReferenceError(self *_object, argumentList []Value) Value {
+ return toValue_object(self.runtime.newReferenceError(valueOfArrayIndex(argumentList, 0)))
+}
+
+func (runtime *_runtime) newSyntaxError(message Value) *_object {
+ self := runtime.newErrorObject("SyntaxError", message)
+ self.prototype = runtime.global.SyntaxErrorPrototype
+ return self
+}
+
+func builtinSyntaxError(call FunctionCall) Value {
+ return toValue_object(call.runtime.newSyntaxError(call.Argument(0)))
+}
+
+func builtinNewSyntaxError(self *_object, argumentList []Value) Value {
+ return toValue_object(self.runtime.newSyntaxError(valueOfArrayIndex(argumentList, 0)))
+}
+
+func builtinURIError(call FunctionCall) Value {
+ return toValue_object(call.runtime.newURIError(call.Argument(0)))
+}
+
+func builtinNewURIError(self *_object, argumentList []Value) Value {
+ return toValue_object(self.runtime.newURIError(valueOfArrayIndex(argumentList, 0)))
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_function.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_function.go
new file mode 100644
index 000000000..3d07566c6
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_function.go
@@ -0,0 +1,129 @@
+package otto
+
+import (
+ "fmt"
+ "regexp"
+ "strings"
+ "unicode"
+
+ "github.com/robertkrimen/otto/parser"
+)
+
+// Function
+
+func builtinFunction(call FunctionCall) Value {
+ return toValue_object(builtinNewFunctionNative(call.runtime, call.ArgumentList))
+}
+
+func builtinNewFunction(self *_object, argumentList []Value) Value {
+ return toValue_object(builtinNewFunctionNative(self.runtime, argumentList))
+}
+
+func argumentList2parameterList(argumentList []Value) []string {
+ parameterList := make([]string, 0, len(argumentList))
+ for _, value := range argumentList {
+ tmp := strings.FieldsFunc(value.string(), func(chr rune) bool {
+ return chr == ',' || unicode.IsSpace(chr)
+ })
+ parameterList = append(parameterList, tmp...)
+ }
+ return parameterList
+}
+
+var matchIdentifier = regexp.MustCompile(`^[$_\p{L}][$_\p{L}\d}]*$`)
+
+func builtinNewFunctionNative(runtime *_runtime, argumentList []Value) *_object {
+ var parameterList, body string
+ count := len(argumentList)
+ if count > 0 {
+ tmp := make([]string, 0, count-1)
+ for _, value := range argumentList[0 : count-1] {
+ tmp = append(tmp, value.string())
+ }
+ parameterList = strings.Join(tmp, ",")
+ body = argumentList[count-1].string()
+ }
+
+ // FIXME
+ function, err := parser.ParseFunction(parameterList, body)
+ runtime.parseThrow(err) // Will panic/throw appropriately
+ cmpl := _compiler{}
+ cmpl_function := cmpl.parseExpression(function)
+
+ return runtime.newNodeFunction(cmpl_function.(*_nodeFunctionLiteral), runtime.globalStash)
+}
+
+func builtinFunction_toString(call FunctionCall) Value {
+ object := call.thisClassObject("Function") // Should throw a TypeError unless Function
+ switch fn := object.value.(type) {
+ case _nativeFunctionObject:
+ return toValue_string(fmt.Sprintf("function %s() { [native code] }", fn.name))
+ case _nodeFunctionObject:
+ return toValue_string(fn.node.source)
+ case _bindFunctionObject:
+ return toValue_string("function () { [native code] }")
+ }
+
+ panic(call.runtime.panicTypeError("Function.toString()"))
+}
+
+func builtinFunction_apply(call FunctionCall) Value {
+ if !call.This.isCallable() {
+ panic(call.runtime.panicTypeError())
+ }
+ this := call.Argument(0)
+ if this.IsUndefined() {
+ // FIXME Not ECMA5
+ this = toValue_object(call.runtime.globalObject)
+ }
+ argumentList := call.Argument(1)
+ switch argumentList.kind {
+ case valueUndefined, valueNull:
+ return call.thisObject().call(this, nil, false, nativeFrame)
+ case valueObject:
+ default:
+ panic(call.runtime.panicTypeError())
+ }
+
+ arrayObject := argumentList._object()
+ thisObject := call.thisObject()
+ length := int64(toUint32(arrayObject.get("length")))
+ valueArray := make([]Value, length)
+ for index := int64(0); index < length; index++ {
+ valueArray[index] = arrayObject.get(arrayIndexToString(index))
+ }
+ return thisObject.call(this, valueArray, false, nativeFrame)
+}
+
+func builtinFunction_call(call FunctionCall) Value {
+ if !call.This.isCallable() {
+ panic(call.runtime.panicTypeError())
+ }
+ thisObject := call.thisObject()
+ this := call.Argument(0)
+ if this.IsUndefined() {
+ // FIXME Not ECMA5
+ this = toValue_object(call.runtime.globalObject)
+ }
+ if len(call.ArgumentList) >= 1 {
+ return thisObject.call(this, call.ArgumentList[1:], false, nativeFrame)
+ }
+ return thisObject.call(this, nil, false, nativeFrame)
+}
+
+func builtinFunction_bind(call FunctionCall) Value {
+ target := call.This
+ if !target.isCallable() {
+ panic(call.runtime.panicTypeError())
+ }
+ targetObject := target._object()
+
+ this := call.Argument(0)
+ argumentList := call.slice(1)
+ if this.IsUndefined() {
+ // FIXME Do this elsewhere?
+ this = toValue_object(call.runtime.globalObject)
+ }
+
+ return toValue_object(call.runtime.newBoundFunction(targetObject, this, argumentList))
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_json.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_json.go
new file mode 100644
index 000000000..aed54bf12
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_json.go
@@ -0,0 +1,299 @@
+package otto
+
+import (
+ "bytes"
+ "encoding/json"
+ "fmt"
+ "strings"
+)
+
+type _builtinJSON_parseContext struct {
+ call FunctionCall
+ reviver Value
+}
+
+func builtinJSON_parse(call FunctionCall) Value {
+ ctx := _builtinJSON_parseContext{
+ call: call,
+ }
+ revive := false
+ if reviver := call.Argument(1); reviver.isCallable() {
+ revive = true
+ ctx.reviver = reviver
+ }
+
+ var root interface{}
+ err := json.Unmarshal([]byte(call.Argument(0).string()), &root)
+ if err != nil {
+ panic(call.runtime.panicSyntaxError(err.Error()))
+ }
+ value, exists := builtinJSON_parseWalk(ctx, root)
+ if !exists {
+ value = Value{}
+ }
+ if revive {
+ root := ctx.call.runtime.newObject()
+ root.put("", value, false)
+ return builtinJSON_reviveWalk(ctx, root, "")
+ }
+ return value
+}
+
+func builtinJSON_reviveWalk(ctx _builtinJSON_parseContext, holder *_object, name string) Value {
+ value := holder.get(name)
+ if object := value._object(); object != nil {
+ if isArray(object) {
+ length := int64(objectLength(object))
+ for index := int64(0); index < length; index += 1 {
+ name := arrayIndexToString(index)
+ value := builtinJSON_reviveWalk(ctx, object, name)
+ if value.IsUndefined() {
+ object.delete(name, false)
+ } else {
+ object.defineProperty(name, value, 0111, false)
+ }
+ }
+ } else {
+ object.enumerate(false, func(name string) bool {
+ value := builtinJSON_reviveWalk(ctx, object, name)
+ if value.IsUndefined() {
+ object.delete(name, false)
+ } else {
+ object.defineProperty(name, value, 0111, false)
+ }
+ return true
+ })
+ }
+ }
+ return ctx.reviver.call(ctx.call.runtime, toValue_object(holder), name, value)
+}
+
+func builtinJSON_parseWalk(ctx _builtinJSON_parseContext, rawValue interface{}) (Value, bool) {
+ switch value := rawValue.(type) {
+ case nil:
+ return nullValue, true
+ case bool:
+ return toValue_bool(value), true
+ case string:
+ return toValue_string(value), true
+ case float64:
+ return toValue_float64(value), true
+ case []interface{}:
+ arrayValue := make([]Value, len(value))
+ for index, rawValue := range value {
+ if value, exists := builtinJSON_parseWalk(ctx, rawValue); exists {
+ arrayValue[index] = value
+ }
+ }
+ return toValue_object(ctx.call.runtime.newArrayOf(arrayValue)), true
+ case map[string]interface{}:
+ object := ctx.call.runtime.newObject()
+ for name, rawValue := range value {
+ if value, exists := builtinJSON_parseWalk(ctx, rawValue); exists {
+ object.put(name, value, false)
+ }
+ }
+ return toValue_object(object), true
+ }
+ return Value{}, false
+}
+
+type _builtinJSON_stringifyContext struct {
+ call FunctionCall
+ stack []*_object
+ propertyList []string
+ replacerFunction *Value
+ gap string
+}
+
+func builtinJSON_stringify(call FunctionCall) Value {
+ ctx := _builtinJSON_stringifyContext{
+ call: call,
+ stack: []*_object{nil},
+ }
+ replacer := call.Argument(1)._object()
+ if replacer != nil {
+ if isArray(replacer) {
+ length := objectLength(replacer)
+ seen := map[string]bool{}
+ propertyList := make([]string, length)
+ length = 0
+ for index, _ := range propertyList {
+ value := replacer.get(arrayIndexToString(int64(index)))
+ switch value.kind {
+ case valueObject:
+ switch value.value.(*_object).class {
+ case "String":
+ case "Number":
+ default:
+ continue
+ }
+ case valueString:
+ case valueNumber:
+ default:
+ continue
+ }
+ name := value.string()
+ if seen[name] {
+ continue
+ }
+ seen[name] = true
+ length += 1
+ propertyList[index] = name
+ }
+ ctx.propertyList = propertyList[0:length]
+ } else if replacer.class == "Function" {
+ value := toValue_object(replacer)
+ ctx.replacerFunction = &value
+ }
+ }
+ if spaceValue, exists := call.getArgument(2); exists {
+ if spaceValue.kind == valueObject {
+ switch spaceValue.value.(*_object).class {
+ case "String":
+ spaceValue = toValue_string(spaceValue.string())
+ case "Number":
+ spaceValue = spaceValue.numberValue()
+ }
+ }
+ switch spaceValue.kind {
+ case valueString:
+ value := spaceValue.string()
+ if len(value) > 10 {
+ ctx.gap = value[0:10]
+ } else {
+ ctx.gap = value
+ }
+ case valueNumber:
+ value := spaceValue.number().int64
+ if value > 10 {
+ value = 10
+ } else if value < 0 {
+ value = 0
+ }
+ ctx.gap = strings.Repeat(" ", int(value))
+ }
+ }
+ holder := call.runtime.newObject()
+ holder.put("", call.Argument(0), false)
+ value, exists := builtinJSON_stringifyWalk(ctx, "", holder)
+ if !exists {
+ return Value{}
+ }
+ valueJSON, err := json.Marshal(value)
+ if err != nil {
+ panic(call.runtime.panicTypeError(err.Error()))
+ }
+ if ctx.gap != "" {
+ valueJSON1 := bytes.Buffer{}
+ json.Indent(&valueJSON1, valueJSON, "", ctx.gap)
+ valueJSON = valueJSON1.Bytes()
+ }
+ return toValue_string(string(valueJSON))
+}
+
+func builtinJSON_stringifyWalk(ctx _builtinJSON_stringifyContext, key string, holder *_object) (interface{}, bool) {
+ value := holder.get(key)
+
+ if value.IsObject() {
+ object := value._object()
+ if toJSON := object.get("toJSON"); toJSON.IsFunction() {
+ value = toJSON.call(ctx.call.runtime, value, key)
+ } else {
+ // If the object is a GoStruct or something that implements json.Marshaler
+ if object.objectClass.marshalJSON != nil {
+ marshaler := object.objectClass.marshalJSON(object)
+ if marshaler != nil {
+ return marshaler, true
+ }
+ }
+ }
+ }
+
+ if ctx.replacerFunction != nil {
+ value = (*ctx.replacerFunction).call(ctx.call.runtime, toValue_object(holder), key, value)
+ }
+
+ if value.kind == valueObject {
+ switch value.value.(*_object).class {
+ case "Boolean":
+ value = value._object().value.(Value)
+ case "String":
+ value = toValue_string(value.string())
+ case "Number":
+ value = value.numberValue()
+ }
+ }
+
+ switch value.kind {
+ case valueBoolean:
+ return value.bool(), true
+ case valueString:
+ return value.string(), true
+ case valueNumber:
+ integer := value.number()
+ switch integer.kind {
+ case numberInteger:
+ return integer.int64, true
+ case numberFloat:
+ return integer.float64, true
+ default:
+ return nil, true
+ }
+ case valueNull:
+ return nil, true
+ case valueObject:
+ holder := value._object()
+ if value := value._object(); nil != value {
+ for _, object := range ctx.stack {
+ if holder == object {
+ panic(ctx.call.runtime.panicTypeError("Converting circular structure to JSON"))
+ }
+ }
+ ctx.stack = append(ctx.stack, value)
+ defer func() { ctx.stack = ctx.stack[:len(ctx.stack)-1] }()
+ }
+ if isArray(holder) {
+ var length uint32
+ switch value := holder.get("length").value.(type) {
+ case uint32:
+ length = value
+ case int:
+ if value >= 0 {
+ length = uint32(value)
+ }
+ default:
+ panic(ctx.call.runtime.panicTypeError(fmt.Sprintf("JSON.stringify: invalid length: %v (%[1]T)", value)))
+ }
+ array := make([]interface{}, length)
+ for index, _ := range array {
+ name := arrayIndexToString(int64(index))
+ value, _ := builtinJSON_stringifyWalk(ctx, name, holder)
+ array[index] = value
+ }
+ return array, true
+ } else if holder.class != "Function" {
+ object := map[string]interface{}{}
+ if ctx.propertyList != nil {
+ for _, name := range ctx.propertyList {
+ value, exists := builtinJSON_stringifyWalk(ctx, name, holder)
+ if exists {
+ object[name] = value
+ }
+ }
+ } else {
+ // Go maps are without order, so this doesn't conform to the ECMA ordering
+ // standard, but oh well...
+ holder.enumerate(false, func(name string) bool {
+ value, exists := builtinJSON_stringifyWalk(ctx, name, holder)
+ if exists {
+ object[name] = value
+ }
+ return true
+ })
+ }
+ return object, true
+ }
+ }
+ return nil, false
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_math.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_math.go
new file mode 100644
index 000000000..a9f4a55c1
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_math.go
@@ -0,0 +1,145 @@
+package otto
+
+import (
+ "math"
+ "math/rand"
+)
+
+// Math
+
+func builtinMath_abs(call FunctionCall) Value {
+ number := call.Argument(0).float64()
+ return toValue_float64(math.Abs(number))
+}
+
+func builtinMath_acos(call FunctionCall) Value {
+ number := call.Argument(0).float64()
+ return toValue_float64(math.Acos(number))
+}
+
+func builtinMath_asin(call FunctionCall) Value {
+ number := call.Argument(0).float64()
+ return toValue_float64(math.Asin(number))
+}
+
+func builtinMath_atan(call FunctionCall) Value {
+ number := call.Argument(0).float64()
+ return toValue_float64(math.Atan(number))
+}
+
+func builtinMath_atan2(call FunctionCall) Value {
+ y := call.Argument(0).float64()
+ if math.IsNaN(y) {
+ return NaNValue()
+ }
+ x := call.Argument(1).float64()
+ if math.IsNaN(x) {
+ return NaNValue()
+ }
+ return toValue_float64(math.Atan2(y, x))
+}
+
+func builtinMath_cos(call FunctionCall) Value {
+ number := call.Argument(0).float64()
+ return toValue_float64(math.Cos(number))
+}
+
+func builtinMath_ceil(call FunctionCall) Value {
+ number := call.Argument(0).float64()
+ return toValue_float64(math.Ceil(number))
+}
+
+func builtinMath_exp(call FunctionCall) Value {
+ number := call.Argument(0).float64()
+ return toValue_float64(math.Exp(number))
+}
+
+func builtinMath_floor(call FunctionCall) Value {
+ number := call.Argument(0).float64()
+ return toValue_float64(math.Floor(number))
+}
+
+func builtinMath_log(call FunctionCall) Value {
+ number := call.Argument(0).float64()
+ return toValue_float64(math.Log(number))
+}
+
+func builtinMath_max(call FunctionCall) Value {
+ switch len(call.ArgumentList) {
+ case 0:
+ return negativeInfinityValue()
+ case 1:
+ return toValue_float64(call.ArgumentList[0].float64())
+ }
+ result := call.ArgumentList[0].float64()
+ if math.IsNaN(result) {
+ return NaNValue()
+ }
+ for _, value := range call.ArgumentList[1:] {
+ value := value.float64()
+ if math.IsNaN(value) {
+ return NaNValue()
+ }
+ result = math.Max(result, value)
+ }
+ return toValue_float64(result)
+}
+
+func builtinMath_min(call FunctionCall) Value {
+ switch len(call.ArgumentList) {
+ case 0:
+ return positiveInfinityValue()
+ case 1:
+ return toValue_float64(call.ArgumentList[0].float64())
+ }
+ result := call.ArgumentList[0].float64()
+ if math.IsNaN(result) {
+ return NaNValue()
+ }
+ for _, value := range call.ArgumentList[1:] {
+ value := value.float64()
+ if math.IsNaN(value) {
+ return NaNValue()
+ }
+ result = math.Min(result, value)
+ }
+ return toValue_float64(result)
+}
+
+func builtinMath_pow(call FunctionCall) Value {
+ // TODO Make sure this works according to the specification (15.8.2.13)
+ x := call.Argument(0).float64()
+ y := call.Argument(1).float64()
+ if math.Abs(x) == 1 && math.IsInf(y, 0) {
+ return NaNValue()
+ }
+ return toValue_float64(math.Pow(x, y))
+}
+
+func builtinMath_random(call FunctionCall) Value {
+ return toValue_float64(rand.Float64())
+}
+
+func builtinMath_round(call FunctionCall) Value {
+ number := call.Argument(0).float64()
+ value := math.Floor(number + 0.5)
+ if value == 0 {
+ value = math.Copysign(0, number)
+ }
+ return toValue_float64(value)
+}
+
+func builtinMath_sin(call FunctionCall) Value {
+ number := call.Argument(0).float64()
+ return toValue_float64(math.Sin(number))
+}
+
+func builtinMath_sqrt(call FunctionCall) Value {
+ number := call.Argument(0).float64()
+ return toValue_float64(math.Sqrt(number))
+}
+
+func builtinMath_tan(call FunctionCall) Value {
+ number := call.Argument(0).float64()
+ return toValue_float64(math.Tan(number))
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_number.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_number.go
new file mode 100644
index 000000000..26a03e7b6
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_number.go
@@ -0,0 +1,93 @@
+package otto
+
+import (
+ "math"
+ "strconv"
+)
+
+// Number
+
+func numberValueFromNumberArgumentList(argumentList []Value) Value {
+ if len(argumentList) > 0 {
+ return argumentList[0].numberValue()
+ }
+ return toValue_int(0)
+}
+
+func builtinNumber(call FunctionCall) Value {
+ return numberValueFromNumberArgumentList(call.ArgumentList)
+}
+
+func builtinNewNumber(self *_object, argumentList []Value) Value {
+ return toValue_object(self.runtime.newNumber(numberValueFromNumberArgumentList(argumentList)))
+}
+
+func builtinNumber_toString(call FunctionCall) Value {
+ // Will throw a TypeError if ThisObject is not a Number
+ value := call.thisClassObject("Number").primitiveValue()
+ radix := 10
+ radixArgument := call.Argument(0)
+ if radixArgument.IsDefined() {
+ integer := toIntegerFloat(radixArgument)
+ if integer < 2 || integer > 36 {
+ panic(call.runtime.panicRangeError("RangeError: toString() radix must be between 2 and 36"))
+ }
+ radix = int(integer)
+ }
+ if radix == 10 {
+ return toValue_string(value.string())
+ }
+ return toValue_string(numberToStringRadix(value, radix))
+}
+
+func builtinNumber_valueOf(call FunctionCall) Value {
+ return call.thisClassObject("Number").primitiveValue()
+}
+
+func builtinNumber_toFixed(call FunctionCall) Value {
+ precision := toIntegerFloat(call.Argument(0))
+ if 20 < precision || 0 > precision {
+ panic(call.runtime.panicRangeError("toFixed() precision must be between 0 and 20"))
+ }
+ if call.This.IsNaN() {
+ return toValue_string("NaN")
+ }
+ value := call.This.float64()
+ if math.Abs(value) >= 1e21 {
+ return toValue_string(floatToString(value, 64))
+ }
+ return toValue_string(strconv.FormatFloat(call.This.float64(), 'f', int(precision), 64))
+}
+
+func builtinNumber_toExponential(call FunctionCall) Value {
+ if call.This.IsNaN() {
+ return toValue_string("NaN")
+ }
+ precision := float64(-1)
+ if value := call.Argument(0); value.IsDefined() {
+ precision = toIntegerFloat(value)
+ if 0 > precision {
+ panic(call.runtime.panicRangeError("RangeError: toString() radix must be between 2 and 36"))
+ }
+ }
+ return toValue_string(strconv.FormatFloat(call.This.float64(), 'e', int(precision), 64))
+}
+
+func builtinNumber_toPrecision(call FunctionCall) Value {
+ if call.This.IsNaN() {
+ return toValue_string("NaN")
+ }
+ value := call.Argument(0)
+ if value.IsUndefined() {
+ return toValue_string(call.This.string())
+ }
+ precision := toIntegerFloat(value)
+ if 1 > precision {
+ panic(call.runtime.panicRangeError("RangeError: toPrecision() precision must be greater than 1"))
+ }
+ return toValue_string(strconv.FormatFloat(call.This.float64(), 'g', int(precision), 64))
+}
+
+func builtinNumber_toLocaleString(call FunctionCall) Value {
+ return builtinNumber_toString(call)
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_object.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_object.go
new file mode 100644
index 000000000..c2433f7be
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_object.go
@@ -0,0 +1,289 @@
+package otto
+
+import (
+ "fmt"
+)
+
+// Object
+
+func builtinObject(call FunctionCall) Value {
+ value := call.Argument(0)
+ switch value.kind {
+ case valueUndefined, valueNull:
+ return toValue_object(call.runtime.newObject())
+ }
+
+ return toValue_object(call.runtime.toObject(value))
+}
+
+func builtinNewObject(self *_object, argumentList []Value) Value {
+ value := valueOfArrayIndex(argumentList, 0)
+ switch value.kind {
+ case valueNull, valueUndefined:
+ case valueNumber, valueString, valueBoolean:
+ return toValue_object(self.runtime.toObject(value))
+ case valueObject:
+ return value
+ default:
+ }
+ return toValue_object(self.runtime.newObject())
+}
+
+func builtinObject_valueOf(call FunctionCall) Value {
+ return toValue_object(call.thisObject())
+}
+
+func builtinObject_hasOwnProperty(call FunctionCall) Value {
+ propertyName := call.Argument(0).string()
+ thisObject := call.thisObject()
+ return toValue_bool(thisObject.hasOwnProperty(propertyName))
+}
+
+func builtinObject_isPrototypeOf(call FunctionCall) Value {
+ value := call.Argument(0)
+ if !value.IsObject() {
+ return falseValue
+ }
+ prototype := call.toObject(value).prototype
+ thisObject := call.thisObject()
+ for prototype != nil {
+ if thisObject == prototype {
+ return trueValue
+ }
+ prototype = prototype.prototype
+ }
+ return falseValue
+}
+
+func builtinObject_propertyIsEnumerable(call FunctionCall) Value {
+ propertyName := call.Argument(0).string()
+ thisObject := call.thisObject()
+ property := thisObject.getOwnProperty(propertyName)
+ if property != nil && property.enumerable() {
+ return trueValue
+ }
+ return falseValue
+}
+
+func builtinObject_toString(call FunctionCall) Value {
+ result := ""
+ if call.This.IsUndefined() {
+ result = "[object Undefined]"
+ } else if call.This.IsNull() {
+ result = "[object Null]"
+ } else {
+ result = fmt.Sprintf("[object %s]", call.thisObject().class)
+ }
+ return toValue_string(result)
+}
+
+func builtinObject_toLocaleString(call FunctionCall) Value {
+ toString := call.thisObject().get("toString")
+ if !toString.isCallable() {
+ panic(call.runtime.panicTypeError())
+ }
+ return toString.call(call.runtime, call.This)
+}
+
+func builtinObject_getPrototypeOf(call FunctionCall) Value {
+ objectValue := call.Argument(0)
+ object := objectValue._object()
+ if object == nil {
+ panic(call.runtime.panicTypeError())
+ }
+
+ if object.prototype == nil {
+ return nullValue
+ }
+
+ return toValue_object(object.prototype)
+}
+
+func builtinObject_getOwnPropertyDescriptor(call FunctionCall) Value {
+ objectValue := call.Argument(0)
+ object := objectValue._object()
+ if object == nil {
+ panic(call.runtime.panicTypeError())
+ }
+
+ name := call.Argument(1).string()
+ descriptor := object.getOwnProperty(name)
+ if descriptor == nil {
+ return Value{}
+ }
+ return toValue_object(call.runtime.fromPropertyDescriptor(*descriptor))
+}
+
+func builtinObject_defineProperty(call FunctionCall) Value {
+ objectValue := call.Argument(0)
+ object := objectValue._object()
+ if object == nil {
+ panic(call.runtime.panicTypeError())
+ }
+ name := call.Argument(1).string()
+ descriptor := toPropertyDescriptor(call.runtime, call.Argument(2))
+ object.defineOwnProperty(name, descriptor, true)
+ return objectValue
+}
+
+func builtinObject_defineProperties(call FunctionCall) Value {
+ objectValue := call.Argument(0)
+ object := objectValue._object()
+ if object == nil {
+ panic(call.runtime.panicTypeError())
+ }
+
+ properties := call.runtime.toObject(call.Argument(1))
+ properties.enumerate(false, func(name string) bool {
+ descriptor := toPropertyDescriptor(call.runtime, properties.get(name))
+ object.defineOwnProperty(name, descriptor, true)
+ return true
+ })
+
+ return objectValue
+}
+
+func builtinObject_create(call FunctionCall) Value {
+ prototypeValue := call.Argument(0)
+ if !prototypeValue.IsNull() && !prototypeValue.IsObject() {
+ panic(call.runtime.panicTypeError())
+ }
+
+ object := call.runtime.newObject()
+ object.prototype = prototypeValue._object()
+
+ propertiesValue := call.Argument(1)
+ if propertiesValue.IsDefined() {
+ properties := call.runtime.toObject(propertiesValue)
+ properties.enumerate(false, func(name string) bool {
+ descriptor := toPropertyDescriptor(call.runtime, properties.get(name))
+ object.defineOwnProperty(name, descriptor, true)
+ return true
+ })
+ }
+
+ return toValue_object(object)
+}
+
+func builtinObject_isExtensible(call FunctionCall) Value {
+ object := call.Argument(0)
+ if object := object._object(); object != nil {
+ return toValue_bool(object.extensible)
+ }
+ panic(call.runtime.panicTypeError())
+}
+
+func builtinObject_preventExtensions(call FunctionCall) Value {
+ object := call.Argument(0)
+ if object := object._object(); object != nil {
+ object.extensible = false
+ } else {
+ panic(call.runtime.panicTypeError())
+ }
+ return object
+}
+
+func builtinObject_isSealed(call FunctionCall) Value {
+ object := call.Argument(0)
+ if object := object._object(); object != nil {
+ if object.extensible {
+ return toValue_bool(false)
+ }
+ result := true
+ object.enumerate(true, func(name string) bool {
+ property := object.getProperty(name)
+ if property.configurable() {
+ result = false
+ }
+ return true
+ })
+ return toValue_bool(result)
+ }
+ panic(call.runtime.panicTypeError())
+}
+
+func builtinObject_seal(call FunctionCall) Value {
+ object := call.Argument(0)
+ if object := object._object(); object != nil {
+ object.enumerate(true, func(name string) bool {
+ if property := object.getOwnProperty(name); nil != property && property.configurable() {
+ property.configureOff()
+ object.defineOwnProperty(name, *property, true)
+ }
+ return true
+ })
+ object.extensible = false
+ } else {
+ panic(call.runtime.panicTypeError())
+ }
+ return object
+}
+
+func builtinObject_isFrozen(call FunctionCall) Value {
+ object := call.Argument(0)
+ if object := object._object(); object != nil {
+ if object.extensible {
+ return toValue_bool(false)
+ }
+ result := true
+ object.enumerate(true, func(name string) bool {
+ property := object.getProperty(name)
+ if property.configurable() || property.writable() {
+ result = false
+ }
+ return true
+ })
+ return toValue_bool(result)
+ }
+ panic(call.runtime.panicTypeError())
+}
+
+func builtinObject_freeze(call FunctionCall) Value {
+ object := call.Argument(0)
+ if object := object._object(); object != nil {
+ object.enumerate(true, func(name string) bool {
+ if property, update := object.getOwnProperty(name), false; nil != property {
+ if property.isDataDescriptor() && property.writable() {
+ property.writeOff()
+ update = true
+ }
+ if property.configurable() {
+ property.configureOff()
+ update = true
+ }
+ if update {
+ object.defineOwnProperty(name, *property, true)
+ }
+ }
+ return true
+ })
+ object.extensible = false
+ } else {
+ panic(call.runtime.panicTypeError())
+ }
+ return object
+}
+
+func builtinObject_keys(call FunctionCall) Value {
+ if object, keys := call.Argument(0)._object(), []Value(nil); nil != object {
+ object.enumerate(false, func(name string) bool {
+ keys = append(keys, toValue_string(name))
+ return true
+ })
+ return toValue_object(call.runtime.newArrayOf(keys))
+ }
+ panic(call.runtime.panicTypeError())
+}
+
+func builtinObject_getOwnPropertyNames(call FunctionCall) Value {
+ if object, propertyNames := call.Argument(0)._object(), []Value(nil); nil != object {
+ object.enumerate(true, func(name string) bool {
+ if object.hasOwnProperty(name) {
+ propertyNames = append(propertyNames, toValue_string(name))
+ }
+ return true
+ })
+ return toValue_object(call.runtime.newArrayOf(propertyNames))
+ }
+ panic(call.runtime.panicTypeError())
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_regexp.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_regexp.go
new file mode 100644
index 000000000..99422510d
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_regexp.go
@@ -0,0 +1,65 @@
+package otto
+
+import (
+ "fmt"
+)
+
+// RegExp
+
+func builtinRegExp(call FunctionCall) Value {
+ pattern := call.Argument(0)
+ flags := call.Argument(1)
+ if object := pattern._object(); object != nil {
+ if object.class == "RegExp" && flags.IsUndefined() {
+ return pattern
+ }
+ }
+ return toValue_object(call.runtime.newRegExp(pattern, flags))
+}
+
+func builtinNewRegExp(self *_object, argumentList []Value) Value {
+ return toValue_object(self.runtime.newRegExp(
+ valueOfArrayIndex(argumentList, 0),
+ valueOfArrayIndex(argumentList, 1),
+ ))
+}
+
+func builtinRegExp_toString(call FunctionCall) Value {
+ thisObject := call.thisObject()
+ source := thisObject.get("source").string()
+ flags := []byte{}
+ if thisObject.get("global").bool() {
+ flags = append(flags, 'g')
+ }
+ if thisObject.get("ignoreCase").bool() {
+ flags = append(flags, 'i')
+ }
+ if thisObject.get("multiline").bool() {
+ flags = append(flags, 'm')
+ }
+ return toValue_string(fmt.Sprintf("/%s/%s", source, flags))
+}
+
+func builtinRegExp_exec(call FunctionCall) Value {
+ thisObject := call.thisObject()
+ target := call.Argument(0).string()
+ match, result := execRegExp(thisObject, target)
+ if !match {
+ return nullValue
+ }
+ return toValue_object(execResultToArray(call.runtime, target, result))
+}
+
+func builtinRegExp_test(call FunctionCall) Value {
+ thisObject := call.thisObject()
+ target := call.Argument(0).string()
+ match, _ := execRegExp(thisObject, target)
+ return toValue_bool(match)
+}
+
+func builtinRegExp_compile(call FunctionCall) Value {
+ // This (useless) function is deprecated, but is here to provide some
+ // semblance of compatibility.
+ // Caveat emptor: it may not be around for long.
+ return Value{}
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_string.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_string.go
new file mode 100644
index 000000000..6a1718458
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_string.go
@@ -0,0 +1,500 @@
+package otto
+
+import (
+ "bytes"
+ "regexp"
+ "strconv"
+ "strings"
+ "unicode/utf8"
+)
+
+// String
+
+func stringValueFromStringArgumentList(argumentList []Value) Value {
+ if len(argumentList) > 0 {
+ return toValue_string(argumentList[0].string())
+ }
+ return toValue_string("")
+}
+
+func builtinString(call FunctionCall) Value {
+ return stringValueFromStringArgumentList(call.ArgumentList)
+}
+
+func builtinNewString(self *_object, argumentList []Value) Value {
+ return toValue_object(self.runtime.newString(stringValueFromStringArgumentList(argumentList)))
+}
+
+func builtinString_toString(call FunctionCall) Value {
+ return call.thisClassObject("String").primitiveValue()
+}
+func builtinString_valueOf(call FunctionCall) Value {
+ return call.thisClassObject("String").primitiveValue()
+}
+
+func builtinString_fromCharCode(call FunctionCall) Value {
+ chrList := make([]uint16, len(call.ArgumentList))
+ for index, value := range call.ArgumentList {
+ chrList[index] = toUint16(value)
+ }
+ return toValue_string16(chrList)
+}
+
+func builtinString_charAt(call FunctionCall) Value {
+ checkObjectCoercible(call.runtime, call.This)
+ idx := int(call.Argument(0).number().int64)
+ chr := stringAt(call.This._object().stringValue(), idx)
+ if chr == utf8.RuneError {
+ return toValue_string("")
+ }
+ return toValue_string(string(chr))
+}
+
+func builtinString_charCodeAt(call FunctionCall) Value {
+ checkObjectCoercible(call.runtime, call.This)
+ idx := int(call.Argument(0).number().int64)
+ chr := stringAt(call.This._object().stringValue(), idx)
+ if chr == utf8.RuneError {
+ return NaNValue()
+ }
+ return toValue_uint16(uint16(chr))
+}
+
+func builtinString_concat(call FunctionCall) Value {
+ checkObjectCoercible(call.runtime, call.This)
+ var value bytes.Buffer
+ value.WriteString(call.This.string())
+ for _, item := range call.ArgumentList {
+ value.WriteString(item.string())
+ }
+ return toValue_string(value.String())
+}
+
+func builtinString_indexOf(call FunctionCall) Value {
+ checkObjectCoercible(call.runtime, call.This)
+ value := call.This.string()
+ target := call.Argument(0).string()
+ if 2 > len(call.ArgumentList) {
+ return toValue_int(strings.Index(value, target))
+ }
+ start := toIntegerFloat(call.Argument(1))
+ if 0 > start {
+ start = 0
+ } else if start >= float64(len(value)) {
+ if target == "" {
+ return toValue_int(len(value))
+ }
+ return toValue_int(-1)
+ }
+ index := strings.Index(value[int(start):], target)
+ if index >= 0 {
+ index += int(start)
+ }
+ return toValue_int(index)
+}
+
+func builtinString_lastIndexOf(call FunctionCall) Value {
+ checkObjectCoercible(call.runtime, call.This)
+ value := call.This.string()
+ target := call.Argument(0).string()
+ if 2 > len(call.ArgumentList) || call.ArgumentList[1].IsUndefined() {
+ return toValue_int(strings.LastIndex(value, target))
+ }
+ length := len(value)
+ if length == 0 {
+ return toValue_int(strings.LastIndex(value, target))
+ }
+ start := call.ArgumentList[1].number()
+ if start.kind == numberInfinity { // FIXME
+ // startNumber is infinity, so start is the end of string (start = length)
+ return toValue_int(strings.LastIndex(value, target))
+ }
+ if 0 > start.int64 {
+ start.int64 = 0
+ }
+ end := int(start.int64) + len(target)
+ if end > length {
+ end = length
+ }
+ return toValue_int(strings.LastIndex(value[:end], target))
+}
+
+func builtinString_match(call FunctionCall) Value {
+ checkObjectCoercible(call.runtime, call.This)
+ target := call.This.string()
+ matcherValue := call.Argument(0)
+ matcher := matcherValue._object()
+ if !matcherValue.IsObject() || matcher.class != "RegExp" {
+ matcher = call.runtime.newRegExp(matcherValue, Value{})
+ }
+ global := matcher.get("global").bool()
+ if !global {
+ match, result := execRegExp(matcher, target)
+ if !match {
+ return nullValue
+ }
+ return toValue_object(execResultToArray(call.runtime, target, result))
+ }
+
+ {
+ result := matcher.regExpValue().regularExpression.FindAllStringIndex(target, -1)
+ matchCount := len(result)
+ if result == nil {
+ matcher.put("lastIndex", toValue_int(0), true)
+ return Value{} // !match
+ }
+ matchCount = len(result)
+ valueArray := make([]Value, matchCount)
+ for index := 0; index < matchCount; index++ {
+ valueArray[index] = toValue_string(target[result[index][0]:result[index][1]])
+ }
+ matcher.put("lastIndex", toValue_int(result[matchCount-1][1]), true)
+ return toValue_object(call.runtime.newArrayOf(valueArray))
+ }
+}
+
+var builtinString_replace_Regexp = regexp.MustCompile("\\$(?:[\\$\\&\\'\\`1-9]|0[1-9]|[1-9][0-9])")
+
+func builtinString_findAndReplaceString(input []byte, lastIndex int, match []int, target []byte, replaceValue []byte) (output []byte) {
+ matchCount := len(match) / 2
+ output = input
+ if match[0] != lastIndex {
+ output = append(output, target[lastIndex:match[0]]...)
+ }
+ replacement := builtinString_replace_Regexp.ReplaceAllFunc(replaceValue, func(part []byte) []byte {
+ // TODO Check if match[0] or match[1] can be -1 in this scenario
+ switch part[1] {
+ case '$':
+ return []byte{'$'}
+ case '&':
+ return target[match[0]:match[1]]
+ case '`':
+ return target[:match[0]]
+ case '\'':
+ return target[match[1]:len(target)]
+ }
+ matchNumberParse, error := strconv.ParseInt(string(part[1:]), 10, 64)
+ matchNumber := int(matchNumberParse)
+ if error != nil || matchNumber >= matchCount {
+ return []byte{}
+ }
+ offset := 2 * matchNumber
+ if match[offset] != -1 {
+ return target[match[offset]:match[offset+1]]
+ }
+ return []byte{} // The empty string
+ })
+ output = append(output, replacement...)
+ return output
+}
+
+func builtinString_replace(call FunctionCall) Value {
+ checkObjectCoercible(call.runtime, call.This)
+ target := []byte(call.This.string())
+ searchValue := call.Argument(0)
+ searchObject := searchValue._object()
+
+ // TODO If a capture is -1?
+ var search *regexp.Regexp
+ global := false
+ find := 1
+ if searchValue.IsObject() && searchObject.class == "RegExp" {
+ regExp := searchObject.regExpValue()
+ search = regExp.regularExpression
+ if regExp.global {
+ find = -1
+ }
+ } else {
+ search = regexp.MustCompile(regexp.QuoteMeta(searchValue.string()))
+ }
+
+ found := search.FindAllSubmatchIndex(target, find)
+ if found == nil {
+ return toValue_string(string(target)) // !match
+ }
+
+ {
+ lastIndex := 0
+ result := []byte{}
+
+ replaceValue := call.Argument(1)
+ if replaceValue.isCallable() {
+ target := string(target)
+ replace := replaceValue._object()
+ for _, match := range found {
+ if match[0] != lastIndex {
+ result = append(result, target[lastIndex:match[0]]...)
+ }
+ matchCount := len(match) / 2
+ argumentList := make([]Value, matchCount+2)
+ for index := 0; index < matchCount; index++ {
+ offset := 2 * index
+ if match[offset] != -1 {
+ argumentList[index] = toValue_string(target[match[offset]:match[offset+1]])
+ } else {
+ argumentList[index] = Value{}
+ }
+ }
+ argumentList[matchCount+0] = toValue_int(match[0])
+ argumentList[matchCount+1] = toValue_string(target)
+ replacement := replace.call(Value{}, argumentList, false, nativeFrame).string()
+ result = append(result, []byte(replacement)...)
+ lastIndex = match[1]
+ }
+
+ } else {
+ replace := []byte(replaceValue.string())
+ for _, match := range found {
+ result = builtinString_findAndReplaceString(result, lastIndex, match, target, replace)
+ lastIndex = match[1]
+ }
+ }
+
+ if lastIndex != len(target) {
+ result = append(result, target[lastIndex:]...)
+ }
+
+ if global && searchObject != nil {
+ searchObject.put("lastIndex", toValue_int(lastIndex), true)
+ }
+
+ return toValue_string(string(result))
+ }
+}
+
+func builtinString_search(call FunctionCall) Value {
+ checkObjectCoercible(call.runtime, call.This)
+ target := call.This.string()
+ searchValue := call.Argument(0)
+ search := searchValue._object()
+ if !searchValue.IsObject() || search.class != "RegExp" {
+ search = call.runtime.newRegExp(searchValue, Value{})
+ }
+ result := search.regExpValue().regularExpression.FindStringIndex(target)
+ if result == nil {
+ return toValue_int(-1)
+ }
+ return toValue_int(result[0])
+}
+
+func stringSplitMatch(target string, targetLength int64, index uint, search string, searchLength int64) (bool, uint) {
+ if int64(index)+searchLength > searchLength {
+ return false, 0
+ }
+ found := strings.Index(target[index:], search)
+ if 0 > found {
+ return false, 0
+ }
+ return true, uint(found)
+}
+
+func builtinString_split(call FunctionCall) Value {
+ checkObjectCoercible(call.runtime, call.This)
+ target := call.This.string()
+
+ separatorValue := call.Argument(0)
+ limitValue := call.Argument(1)
+ limit := -1
+ if limitValue.IsDefined() {
+ limit = int(toUint32(limitValue))
+ }
+
+ if limit == 0 {
+ return toValue_object(call.runtime.newArray(0))
+ }
+
+ if separatorValue.IsUndefined() {
+ return toValue_object(call.runtime.newArrayOf([]Value{toValue_string(target)}))
+ }
+
+ if separatorValue.isRegExp() {
+ targetLength := len(target)
+ search := separatorValue._object().regExpValue().regularExpression
+ valueArray := []Value{}
+ result := search.FindAllStringSubmatchIndex(target, -1)
+ lastIndex := 0
+ found := 0
+
+ for _, match := range result {
+ if match[0] == match[1] {
+ // FIXME Ugh, this is a hack
+ if match[0] == 0 || match[0] == targetLength {
+ continue
+ }
+ }
+
+ if lastIndex != match[0] {
+ valueArray = append(valueArray, toValue_string(target[lastIndex:match[0]]))
+ found++
+ } else if lastIndex == match[0] {
+ if lastIndex != -1 {
+ valueArray = append(valueArray, toValue_string(""))
+ found++
+ }
+ }
+
+ lastIndex = match[1]
+ if found == limit {
+ goto RETURN
+ }
+
+ captureCount := len(match) / 2
+ for index := 1; index < captureCount; index++ {
+ offset := index * 2
+ value := Value{}
+ if match[offset] != -1 {
+ value = toValue_string(target[match[offset]:match[offset+1]])
+ }
+ valueArray = append(valueArray, value)
+ found++
+ if found == limit {
+ goto RETURN
+ }
+ }
+ }
+
+ if found != limit {
+ if lastIndex != targetLength {
+ valueArray = append(valueArray, toValue_string(target[lastIndex:targetLength]))
+ } else {
+ valueArray = append(valueArray, toValue_string(""))
+ }
+ }
+
+ RETURN:
+ return toValue_object(call.runtime.newArrayOf(valueArray))
+
+ } else {
+ separator := separatorValue.string()
+
+ splitLimit := limit
+ excess := false
+ if limit > 0 {
+ splitLimit = limit + 1
+ excess = true
+ }
+
+ split := strings.SplitN(target, separator, splitLimit)
+
+ if excess && len(split) > limit {
+ split = split[:limit]
+ }
+
+ valueArray := make([]Value, len(split))
+ for index, value := range split {
+ valueArray[index] = toValue_string(value)
+ }
+
+ return toValue_object(call.runtime.newArrayOf(valueArray))
+ }
+}
+
+func builtinString_slice(call FunctionCall) Value {
+ checkObjectCoercible(call.runtime, call.This)
+ target := call.This.string()
+
+ length := int64(len(target))
+ start, end := rangeStartEnd(call.ArgumentList, length, false)
+ if end-start <= 0 {
+ return toValue_string("")
+ }
+ return toValue_string(target[start:end])
+}
+
+func builtinString_substring(call FunctionCall) Value {
+ checkObjectCoercible(call.runtime, call.This)
+ target := call.This.string()
+
+ length := int64(len(target))
+ start, end := rangeStartEnd(call.ArgumentList, length, true)
+ if start > end {
+ start, end = end, start
+ }
+ return toValue_string(target[start:end])
+}
+
+func builtinString_substr(call FunctionCall) Value {
+ target := call.This.string()
+
+ size := int64(len(target))
+ start, length := rangeStartLength(call.ArgumentList, size)
+
+ if start >= size {
+ return toValue_string("")
+ }
+
+ if length <= 0 {
+ return toValue_string("")
+ }
+
+ if start+length >= size {
+ // Cap length to be to the end of the string
+ // start = 3, length = 5, size = 4 [0, 1, 2, 3]
+ // 4 - 3 = 1
+ // target[3:4]
+ length = size - start
+ }
+
+ return toValue_string(target[start : start+length])
+}
+
+func builtinString_toLowerCase(call FunctionCall) Value {
+ checkObjectCoercible(call.runtime, call.This)
+ return toValue_string(strings.ToLower(call.This.string()))
+}
+
+func builtinString_toUpperCase(call FunctionCall) Value {
+ checkObjectCoercible(call.runtime, call.This)
+ return toValue_string(strings.ToUpper(call.This.string()))
+}
+
+// 7.2 Table 2 — Whitespace Characters & 7.3 Table 3 - Line Terminator Characters
+const builtinString_trim_whitespace = "\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF"
+
+func builtinString_trim(call FunctionCall) Value {
+ checkObjectCoercible(call.runtime, call.This)
+ return toValue(strings.Trim(call.This.string(),
+ builtinString_trim_whitespace))
+}
+
+// Mozilla extension, not ECMAScript 5
+func builtinString_trimLeft(call FunctionCall) Value {
+ checkObjectCoercible(call.runtime, call.This)
+ return toValue(strings.TrimLeft(call.This.string(),
+ builtinString_trim_whitespace))
+}
+
+// Mozilla extension, not ECMAScript 5
+func builtinString_trimRight(call FunctionCall) Value {
+ checkObjectCoercible(call.runtime, call.This)
+ return toValue(strings.TrimRight(call.This.string(),
+ builtinString_trim_whitespace))
+}
+
+func builtinString_localeCompare(call FunctionCall) Value {
+ checkObjectCoercible(call.runtime, call.This)
+ this := call.This.string()
+ that := call.Argument(0).string()
+ if this < that {
+ return toValue_int(-1)
+ } else if this == that {
+ return toValue_int(0)
+ }
+ return toValue_int(1)
+}
+
+/*
+An alternate version of String.trim
+func builtinString_trim(call FunctionCall) Value {
+ checkObjectCoercible(call.This)
+ return toValue_string(strings.TrimFunc(call.string(.This), isWhiteSpaceOrLineTerminator))
+}
+*/
+
+func builtinString_toLocaleLowerCase(call FunctionCall) Value {
+ return builtinString_toLowerCase(call)
+}
+
+func builtinString_toLocaleUpperCase(call FunctionCall) Value {
+ return builtinString_toUpperCase(call)
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_test.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_test.go
new file mode 100644
index 000000000..f5be00ab6
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/builtin_test.go
@@ -0,0 +1,136 @@
+package otto
+
+import (
+ "testing"
+)
+
+func TestString_substr(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ [
+ "abc".substr(0,1), // "a"
+ "abc".substr(0,2), // "ab"
+ "abc".substr(0,3), // "abc"
+ "abc".substr(0,4), // "abc"
+ "abc".substr(0,9), // "abc"
+ ];
+ `, "a,ab,abc,abc,abc")
+
+ test(`
+ [
+ "abc".substr(1,1), // "b"
+ "abc".substr(1,2), // "bc"
+ "abc".substr(1,3), // "bc"
+ "abc".substr(1,4), // "bc"
+ "abc".substr(1,9), // "bc"
+ ];
+ `, "b,bc,bc,bc,bc")
+
+ test(`
+ [
+ "abc".substr(2,1), // "c"
+ "abc".substr(2,2), // "c"
+ "abc".substr(2,3), // "c"
+ "abc".substr(2,4), // "c"
+ "abc".substr(2,9), // "c"
+ ];
+ `, "c,c,c,c,c")
+
+ test(`
+ [
+ "abc".substr(3,1), // ""
+ "abc".substr(3,2), // ""
+ "abc".substr(3,3), // ""
+ "abc".substr(3,4), // ""
+ "abc".substr(3,9), // ""
+ ];
+ `, ",,,,")
+
+ test(`
+ [
+ "abc".substr(0), // "abc"
+ "abc".substr(1), // "bc"
+ "abc".substr(2), // "c"
+ "abc".substr(3), // ""
+ "abc".substr(9), // ""
+ ];
+ `, "abc,bc,c,,")
+
+ test(`
+ [
+ "abc".substr(-9), // "abc"
+ "abc".substr(-3), // "abc"
+ "abc".substr(-2), // "bc"
+ "abc".substr(-1), // "c"
+ ];
+ `, "abc,abc,bc,c")
+
+ test(`
+ [
+ "abc".substr(-9, 1), // "a"
+ "abc".substr(-3, 1), // "a"
+ "abc".substr(-2, 1), // "b"
+ "abc".substr(-1, 1), // "c"
+ "abc".substr(-1, 2), // "c"
+ ];
+ `, "a,a,b,c,c")
+
+ test(`"abcd".substr(3, 5)`, "d")
+ })
+}
+
+func Test_builtin_escape(t *testing.T) {
+ tt(t, func() {
+ is(builtin_escape("abc"), "abc")
+
+ is(builtin_escape("="), "%3D")
+
+ is(builtin_escape("abc=%+32"), "abc%3D%25+32")
+
+ is(builtin_escape("世界"), "%u4E16%u754C")
+ })
+}
+
+func Test_builtin_unescape(t *testing.T) {
+ tt(t, func() {
+ is(builtin_unescape("abc"), "abc")
+
+ is(builtin_unescape("=%3D"), "==")
+
+ is(builtin_unescape("abc%3D%25+32"), "abc=%+32")
+
+ is(builtin_unescape("%u4E16%u754C"), "世界")
+ })
+}
+
+func TestGlobal_escape(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ [
+ escape("abc"), // "abc"
+ escape("="), // "%3D"
+ escape("abc=%+32"), // "abc%3D%25+32"
+ escape("\u4e16\u754c"), // "%u4E16%u754C"
+ ];
+ `, "abc,%3D,abc%3D%25+32,%u4E16%u754C")
+ })
+}
+
+func TestGlobal_unescape(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ [
+ unescape("abc"), // "abc"
+ unescape("=%3D"), // "=="
+ unescape("abc%3D%25+32"), // "abc=%+32"
+ unescape("%u4E16%u754C"), // "世界"
+ ];
+ `, "abc,==,abc=%+32,世界")
+ })
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/clone.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/clone.go
new file mode 100644
index 000000000..f79901b35
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/clone.go
@@ -0,0 +1,155 @@
+package otto
+
+import (
+ "fmt"
+)
+
+type _clone struct {
+ runtime *_runtime
+ _object map[*_object]*_object
+ _objectStash map[*_objectStash]*_objectStash
+ _dclStash map[*_dclStash]*_dclStash
+ _fnStash map[*_fnStash]*_fnStash
+}
+
+func (in *_runtime) clone() *_runtime {
+
+ in.lck.Lock()
+ defer in.lck.Unlock()
+
+ out := &_runtime{}
+ clone := _clone{
+ runtime: out,
+ _object: make(map[*_object]*_object),
+ _objectStash: make(map[*_objectStash]*_objectStash),
+ _dclStash: make(map[*_dclStash]*_dclStash),
+ _fnStash: make(map[*_fnStash]*_fnStash),
+ }
+
+ globalObject := clone.object(in.globalObject)
+ out.globalStash = out.newObjectStash(globalObject, nil)
+ out.globalObject = globalObject
+ out.global = _global{
+ clone.object(in.global.Object),
+ clone.object(in.global.Function),
+ clone.object(in.global.Array),
+ clone.object(in.global.String),
+ clone.object(in.global.Boolean),
+ clone.object(in.global.Number),
+ clone.object(in.global.Math),
+ clone.object(in.global.Date),
+ clone.object(in.global.RegExp),
+ clone.object(in.global.Error),
+ clone.object(in.global.EvalError),
+ clone.object(in.global.TypeError),
+ clone.object(in.global.RangeError),
+ clone.object(in.global.ReferenceError),
+ clone.object(in.global.SyntaxError),
+ clone.object(in.global.URIError),
+ clone.object(in.global.JSON),
+
+ clone.object(in.global.ObjectPrototype),
+ clone.object(in.global.FunctionPrototype),
+ clone.object(in.global.ArrayPrototype),
+ clone.object(in.global.StringPrototype),
+ clone.object(in.global.BooleanPrototype),
+ clone.object(in.global.NumberPrototype),
+ clone.object(in.global.DatePrototype),
+ clone.object(in.global.RegExpPrototype),
+ clone.object(in.global.ErrorPrototype),
+ clone.object(in.global.EvalErrorPrototype),
+ clone.object(in.global.TypeErrorPrototype),
+ clone.object(in.global.RangeErrorPrototype),
+ clone.object(in.global.ReferenceErrorPrototype),
+ clone.object(in.global.SyntaxErrorPrototype),
+ clone.object(in.global.URIErrorPrototype),
+ }
+
+ out.eval = out.globalObject.property["eval"].value.(Value).value.(*_object)
+ out.globalObject.prototype = out.global.ObjectPrototype
+
+ // Not sure if this is necessary, but give some help to the GC
+ clone.runtime = nil
+ clone._object = nil
+ clone._objectStash = nil
+ clone._dclStash = nil
+ clone._fnStash = nil
+
+ return out
+}
+
+func (clone *_clone) object(in *_object) *_object {
+ if out, exists := clone._object[in]; exists {
+ return out
+ }
+ out := &_object{}
+ clone._object[in] = out
+ return in.objectClass.clone(in, out, clone)
+}
+
+func (clone *_clone) dclStash(in *_dclStash) (*_dclStash, bool) {
+ if out, exists := clone._dclStash[in]; exists {
+ return out, true
+ }
+ out := &_dclStash{}
+ clone._dclStash[in] = out
+ return out, false
+}
+
+func (clone *_clone) objectStash(in *_objectStash) (*_objectStash, bool) {
+ if out, exists := clone._objectStash[in]; exists {
+ return out, true
+ }
+ out := &_objectStash{}
+ clone._objectStash[in] = out
+ return out, false
+}
+
+func (clone *_clone) fnStash(in *_fnStash) (*_fnStash, bool) {
+ if out, exists := clone._fnStash[in]; exists {
+ return out, true
+ }
+ out := &_fnStash{}
+ clone._fnStash[in] = out
+ return out, false
+}
+
+func (clone *_clone) value(in Value) Value {
+ out := in
+ switch value := in.value.(type) {
+ case *_object:
+ out.value = clone.object(value)
+ }
+ return out
+}
+
+func (clone *_clone) valueArray(in []Value) []Value {
+ out := make([]Value, len(in))
+ for index, value := range in {
+ out[index] = clone.value(value)
+ }
+ return out
+}
+
+func (clone *_clone) stash(in _stash) _stash {
+ if in == nil {
+ return nil
+ }
+ return in.clone(clone)
+}
+
+func (clone *_clone) property(in _property) _property {
+ out := in
+ if value, valid := in.value.(Value); valid {
+ out.value = clone.value(value)
+ } else {
+ panic(fmt.Errorf("in.value.(Value) != true"))
+ }
+ return out
+}
+
+func (clone *_clone) dclProperty(in _dclProperty) _dclProperty {
+ out := in
+ out.value = clone.value(in.value)
+ return out
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/cmpl.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/cmpl.go
new file mode 100644
index 000000000..c191b4527
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/cmpl.go
@@ -0,0 +1,24 @@
+package otto
+
+import (
+ "github.com/robertkrimen/otto/ast"
+ "github.com/robertkrimen/otto/file"
+)
+
+type _file struct {
+ name string
+ src string
+ base int // This will always be 1 or greater
+}
+
+type _compiler struct {
+ file *file.File
+ program *ast.Program
+}
+
+func (cmpl *_compiler) parse() *_nodeProgram {
+ if cmpl.program != nil {
+ cmpl.file = cmpl.program.File
+ }
+ return cmpl._parse(cmpl.program)
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/cmpl_evaluate.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/cmpl_evaluate.go
new file mode 100644
index 000000000..6741bf394
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/cmpl_evaluate.go
@@ -0,0 +1,96 @@
+package otto
+
+import (
+ "strconv"
+)
+
+func (self *_runtime) cmpl_evaluate_nodeProgram(node *_nodeProgram, eval bool) Value {
+ if !eval {
+ self.enterGlobalScope()
+ defer func() {
+ self.leaveScope()
+ }()
+ }
+ self.cmpl_functionDeclaration(node.functionList)
+ self.cmpl_variableDeclaration(node.varList)
+ self.scope.frame.file = node.file
+ return self.cmpl_evaluate_nodeStatementList(node.body)
+}
+
+func (self *_runtime) cmpl_call_nodeFunction(function *_object, stash *_fnStash, node *_nodeFunctionLiteral, this Value, argumentList []Value) Value {
+
+ indexOfParameterName := make([]string, len(argumentList))
+ // function(abc, def, ghi)
+ // indexOfParameterName[0] = "abc"
+ // indexOfParameterName[1] = "def"
+ // indexOfParameterName[2] = "ghi"
+ // ...
+
+ argumentsFound := false
+ for index, name := range node.parameterList {
+ if name == "arguments" {
+ argumentsFound = true
+ }
+ value := Value{}
+ if index < len(argumentList) {
+ value = argumentList[index]
+ indexOfParameterName[index] = name
+ }
+ // strict = false
+ self.scope.lexical.setValue(name, value, false)
+ }
+
+ if !argumentsFound {
+ arguments := self.newArgumentsObject(indexOfParameterName, stash, len(argumentList))
+ arguments.defineProperty("callee", toValue_object(function), 0101, false)
+ stash.arguments = arguments
+ // strict = false
+ self.scope.lexical.setValue("arguments", toValue_object(arguments), false)
+ for index, _ := range argumentList {
+ if index < len(node.parameterList) {
+ continue
+ }
+ indexAsString := strconv.FormatInt(int64(index), 10)
+ arguments.defineProperty(indexAsString, argumentList[index], 0111, false)
+ }
+ }
+
+ self.cmpl_functionDeclaration(node.functionList)
+ self.cmpl_variableDeclaration(node.varList)
+
+ result := self.cmpl_evaluate_nodeStatement(node.body)
+ if result.kind == valueResult {
+ return result
+ }
+
+ return Value{}
+}
+
+func (self *_runtime) cmpl_functionDeclaration(list []*_nodeFunctionLiteral) {
+ executionContext := self.scope
+ eval := executionContext.eval
+ stash := executionContext.variable
+
+ for _, function := range list {
+ name := function.name
+ value := self.cmpl_evaluate_nodeExpression(function)
+ if !stash.hasBinding(name) {
+ stash.createBinding(name, eval == true, value)
+ } else {
+ // TODO 10.5.5.e
+ stash.setBinding(name, value, false) // TODO strict
+ }
+ }
+}
+
+func (self *_runtime) cmpl_variableDeclaration(list []string) {
+ executionContext := self.scope
+ eval := executionContext.eval
+ stash := executionContext.variable
+
+ for _, name := range list {
+ if !stash.hasBinding(name) {
+ stash.createBinding(name, eval == true, Value{}) // TODO strict?
+ }
+ }
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/cmpl_evaluate_expression.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/cmpl_evaluate_expression.go
new file mode 100644
index 000000000..34449970e
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/cmpl_evaluate_expression.go
@@ -0,0 +1,456 @@
+package otto
+
+import (
+ "fmt"
+ "math"
+ "runtime"
+
+ "github.com/robertkrimen/otto/token"
+)
+
+func (self *_runtime) cmpl_evaluate_nodeExpression(node _nodeExpression) Value {
+ // Allow interpreter interruption
+ // If the Interrupt channel is nil, then
+ // we avoid runtime.Gosched() overhead (if any)
+ // FIXME: Test this
+ if self.otto.Interrupt != nil {
+ runtime.Gosched()
+ select {
+ case value := <-self.otto.Interrupt:
+ value()
+ default:
+ }
+ }
+
+ switch node := node.(type) {
+
+ case *_nodeArrayLiteral:
+ return self.cmpl_evaluate_nodeArrayLiteral(node)
+
+ case *_nodeAssignExpression:
+ return self.cmpl_evaluate_nodeAssignExpression(node)
+
+ case *_nodeBinaryExpression:
+ if node.comparison {
+ return self.cmpl_evaluate_nodeBinaryExpression_comparison(node)
+ } else {
+ return self.cmpl_evaluate_nodeBinaryExpression(node)
+ }
+
+ case *_nodeBracketExpression:
+ return self.cmpl_evaluate_nodeBracketExpression(node)
+
+ case *_nodeCallExpression:
+ return self.cmpl_evaluate_nodeCallExpression(node, nil)
+
+ case *_nodeConditionalExpression:
+ return self.cmpl_evaluate_nodeConditionalExpression(node)
+
+ case *_nodeDotExpression:
+ return self.cmpl_evaluate_nodeDotExpression(node)
+
+ case *_nodeFunctionLiteral:
+ var local = self.scope.lexical
+ if node.name != "" {
+ local = self.newDeclarationStash(local)
+ }
+
+ value := toValue_object(self.newNodeFunction(node, local))
+ if node.name != "" {
+ local.createBinding(node.name, false, value)
+ }
+ return value
+
+ case *_nodeIdentifier:
+ name := node.name
+ // TODO Should be true or false (strictness) depending on context
+ // getIdentifierReference should not return nil, but we check anyway and panic
+ // so as not to propagate the nil into something else
+ reference := getIdentifierReference(self, self.scope.lexical, name, false, _at(node.idx))
+ if reference == nil {
+ // Should never get here!
+ panic(hereBeDragons("referenceError == nil: " + name))
+ }
+ return toValue(reference)
+
+ case *_nodeLiteral:
+ return node.value
+
+ case *_nodeNewExpression:
+ return self.cmpl_evaluate_nodeNewExpression(node)
+
+ case *_nodeObjectLiteral:
+ return self.cmpl_evaluate_nodeObjectLiteral(node)
+
+ case *_nodeRegExpLiteral:
+ return toValue_object(self._newRegExp(node.pattern, node.flags))
+
+ case *_nodeSequenceExpression:
+ return self.cmpl_evaluate_nodeSequenceExpression(node)
+
+ case *_nodeThisExpression:
+ return toValue_object(self.scope.this)
+
+ case *_nodeUnaryExpression:
+ return self.cmpl_evaluate_nodeUnaryExpression(node)
+
+ case *_nodeVariableExpression:
+ return self.cmpl_evaluate_nodeVariableExpression(node)
+ }
+
+ panic(fmt.Errorf("Here be dragons: evaluate_nodeExpression(%T)", node))
+}
+
+func (self *_runtime) cmpl_evaluate_nodeArrayLiteral(node *_nodeArrayLiteral) Value {
+
+ valueArray := []Value{}
+
+ for _, node := range node.value {
+ if node == nil {
+ valueArray = append(valueArray, emptyValue)
+ } else {
+ valueArray = append(valueArray, self.cmpl_evaluate_nodeExpression(node).resolve())
+ }
+ }
+
+ result := self.newArrayOf(valueArray)
+
+ return toValue_object(result)
+}
+
+func (self *_runtime) cmpl_evaluate_nodeAssignExpression(node *_nodeAssignExpression) Value {
+
+ left := self.cmpl_evaluate_nodeExpression(node.left)
+ right := self.cmpl_evaluate_nodeExpression(node.right)
+ rightValue := right.resolve()
+
+ result := rightValue
+ if node.operator != token.ASSIGN {
+ result = self.calculateBinaryExpression(node.operator, left, rightValue)
+ }
+
+ self.putValue(left.reference(), result)
+
+ return result
+}
+
+func (self *_runtime) cmpl_evaluate_nodeBinaryExpression(node *_nodeBinaryExpression) Value {
+
+ left := self.cmpl_evaluate_nodeExpression(node.left)
+ leftValue := left.resolve()
+
+ switch node.operator {
+ // Logical
+ case token.LOGICAL_AND:
+ if !leftValue.bool() {
+ return leftValue
+ }
+ right := self.cmpl_evaluate_nodeExpression(node.right)
+ return right.resolve()
+ case token.LOGICAL_OR:
+ if leftValue.bool() {
+ return leftValue
+ }
+ right := self.cmpl_evaluate_nodeExpression(node.right)
+ return right.resolve()
+ }
+
+ return self.calculateBinaryExpression(node.operator, leftValue, self.cmpl_evaluate_nodeExpression(node.right))
+}
+
+func (self *_runtime) cmpl_evaluate_nodeBinaryExpression_comparison(node *_nodeBinaryExpression) Value {
+
+ left := self.cmpl_evaluate_nodeExpression(node.left).resolve()
+ right := self.cmpl_evaluate_nodeExpression(node.right).resolve()
+
+ return toValue_bool(self.calculateComparison(node.operator, left, right))
+}
+
+func (self *_runtime) cmpl_evaluate_nodeBracketExpression(node *_nodeBracketExpression) Value {
+ target := self.cmpl_evaluate_nodeExpression(node.left)
+ targetValue := target.resolve()
+ member := self.cmpl_evaluate_nodeExpression(node.member)
+ memberValue := member.resolve()
+
+ // TODO Pass in base value as-is, and defer toObject till later?
+ return toValue(newPropertyReference(self, self.toObject(targetValue), memberValue.string(), false, _at(node.idx)))
+}
+
+func (self *_runtime) cmpl_evaluate_nodeCallExpression(node *_nodeCallExpression, withArgumentList []interface{}) Value {
+ rt := self
+ this := Value{}
+ callee := self.cmpl_evaluate_nodeExpression(node.callee)
+
+ argumentList := []Value{}
+ if withArgumentList != nil {
+ argumentList = self.toValueArray(withArgumentList...)
+ } else {
+ for _, argumentNode := range node.argumentList {
+ argumentList = append(argumentList, self.cmpl_evaluate_nodeExpression(argumentNode).resolve())
+ }
+ }
+
+ rf := callee.reference()
+ vl := callee.resolve()
+
+ eval := false // Whether this call is a (candidate for) direct call to eval
+ name := ""
+ if rf != nil {
+ switch rf := rf.(type) {
+ case *_propertyReference:
+ name = rf.name
+ object := rf.base
+ this = toValue_object(object)
+ eval = rf.name == "eval" // Possible direct eval
+ case *_stashReference:
+ // TODO ImplicitThisValue
+ name = rf.name
+ eval = rf.name == "eval" // Possible direct eval
+ default:
+ // FIXME?
+ panic(rt.panicTypeError("Here be dragons"))
+ }
+ }
+
+ at := _at(-1)
+ switch callee := node.callee.(type) {
+ case *_nodeIdentifier:
+ at = _at(callee.idx)
+ case *_nodeDotExpression:
+ at = _at(callee.idx)
+ case *_nodeBracketExpression:
+ at = _at(callee.idx)
+ }
+
+ frame := _frame{
+ callee: name,
+ file: self.scope.frame.file,
+ }
+
+ if !vl.IsFunction() {
+ if name == "" {
+ // FIXME Maybe typeof?
+ panic(rt.panicTypeError("%v is not a function", vl, at))
+ }
+ panic(rt.panicTypeError("'%s' is not a function", name, at))
+ }
+
+ self.scope.frame.offset = int(at)
+
+ return vl._object().call(this, argumentList, eval, frame)
+}
+
+func (self *_runtime) cmpl_evaluate_nodeConditionalExpression(node *_nodeConditionalExpression) Value {
+ test := self.cmpl_evaluate_nodeExpression(node.test)
+ testValue := test.resolve()
+ if testValue.bool() {
+ return self.cmpl_evaluate_nodeExpression(node.consequent)
+ }
+ return self.cmpl_evaluate_nodeExpression(node.alternate)
+}
+
+func (self *_runtime) cmpl_evaluate_nodeDotExpression(node *_nodeDotExpression) Value {
+ target := self.cmpl_evaluate_nodeExpression(node.left)
+ targetValue := target.resolve()
+ // TODO Pass in base value as-is, and defer toObject till later?
+ object, err := self.objectCoerce(targetValue)
+ if err != nil {
+ panic(self.panicTypeError("Cannot access member '%s' of %s", node.identifier, err.Error()))
+ }
+ return toValue(newPropertyReference(self, object, node.identifier, false, _at(node.idx)))
+}
+
+func (self *_runtime) cmpl_evaluate_nodeNewExpression(node *_nodeNewExpression) Value {
+ rt := self
+ callee := self.cmpl_evaluate_nodeExpression(node.callee)
+
+ argumentList := []Value{}
+ for _, argumentNode := range node.argumentList {
+ argumentList = append(argumentList, self.cmpl_evaluate_nodeExpression(argumentNode).resolve())
+ }
+
+ rf := callee.reference()
+ vl := callee.resolve()
+
+ name := ""
+ if rf != nil {
+ switch rf := rf.(type) {
+ case *_propertyReference:
+ name = rf.name
+ case *_stashReference:
+ name = rf.name
+ default:
+ panic(rt.panicTypeError("Here be dragons"))
+ }
+ }
+
+ at := _at(-1)
+ switch callee := node.callee.(type) {
+ case *_nodeIdentifier:
+ at = _at(callee.idx)
+ case *_nodeDotExpression:
+ at = _at(callee.idx)
+ case *_nodeBracketExpression:
+ at = _at(callee.idx)
+ }
+
+ if !vl.IsFunction() {
+ if name == "" {
+ // FIXME Maybe typeof?
+ panic(rt.panicTypeError("%v is not a function", vl, at))
+ }
+ panic(rt.panicTypeError("'%s' is not a function", name, at))
+ }
+
+ self.scope.frame.offset = int(at)
+
+ return vl._object().construct(argumentList)
+}
+
+func (self *_runtime) cmpl_evaluate_nodeObjectLiteral(node *_nodeObjectLiteral) Value {
+
+ result := self.newObject()
+
+ for _, property := range node.value {
+ switch property.kind {
+ case "value":
+ result.defineProperty(property.key, self.cmpl_evaluate_nodeExpression(property.value).resolve(), 0111, false)
+ case "get":
+ getter := self.newNodeFunction(property.value.(*_nodeFunctionLiteral), self.scope.lexical)
+ descriptor := _property{}
+ descriptor.mode = 0211
+ descriptor.value = _propertyGetSet{getter, nil}
+ result.defineOwnProperty(property.key, descriptor, false)
+ case "set":
+ setter := self.newNodeFunction(property.value.(*_nodeFunctionLiteral), self.scope.lexical)
+ descriptor := _property{}
+ descriptor.mode = 0211
+ descriptor.value = _propertyGetSet{nil, setter}
+ result.defineOwnProperty(property.key, descriptor, false)
+ default:
+ panic(fmt.Errorf("Here be dragons: evaluate_nodeObjectLiteral: invalid property.Kind: %v", property.kind))
+ }
+ }
+
+ return toValue_object(result)
+}
+
+func (self *_runtime) cmpl_evaluate_nodeSequenceExpression(node *_nodeSequenceExpression) Value {
+ var result Value
+ for _, node := range node.sequence {
+ result = self.cmpl_evaluate_nodeExpression(node)
+ result = result.resolve()
+ }
+ return result
+}
+
+func (self *_runtime) cmpl_evaluate_nodeUnaryExpression(node *_nodeUnaryExpression) Value {
+
+ target := self.cmpl_evaluate_nodeExpression(node.operand)
+ switch node.operator {
+ case token.TYPEOF, token.DELETE:
+ if target.kind == valueReference && target.reference().invalid() {
+ if node.operator == token.TYPEOF {
+ return toValue_string("undefined")
+ }
+ return trueValue
+ }
+ }
+
+ switch node.operator {
+ case token.NOT:
+ targetValue := target.resolve()
+ if targetValue.bool() {
+ return falseValue
+ }
+ return trueValue
+ case token.BITWISE_NOT:
+ targetValue := target.resolve()
+ integerValue := toInt32(targetValue)
+ return toValue_int32(^integerValue)
+ case token.PLUS:
+ targetValue := target.resolve()
+ return toValue_float64(targetValue.float64())
+ case token.MINUS:
+ targetValue := target.resolve()
+ value := targetValue.float64()
+ // TODO Test this
+ sign := float64(-1)
+ if math.Signbit(value) {
+ sign = 1
+ }
+ return toValue_float64(math.Copysign(value, sign))
+ case token.INCREMENT:
+ targetValue := target.resolve()
+ if node.postfix {
+ // Postfix++
+ oldValue := targetValue.float64()
+ newValue := toValue_float64(+1 + oldValue)
+ self.putValue(target.reference(), newValue)
+ return toValue_float64(oldValue)
+ } else {
+ // ++Prefix
+ newValue := toValue_float64(+1 + targetValue.float64())
+ self.putValue(target.reference(), newValue)
+ return newValue
+ }
+ case token.DECREMENT:
+ targetValue := target.resolve()
+ if node.postfix {
+ // Postfix--
+ oldValue := targetValue.float64()
+ newValue := toValue_float64(-1 + oldValue)
+ self.putValue(target.reference(), newValue)
+ return toValue_float64(oldValue)
+ } else {
+ // --Prefix
+ newValue := toValue_float64(-1 + targetValue.float64())
+ self.putValue(target.reference(), newValue)
+ return newValue
+ }
+ case token.VOID:
+ target.resolve() // FIXME Side effect?
+ return Value{}
+ case token.DELETE:
+ reference := target.reference()
+ if reference == nil {
+ return trueValue
+ }
+ return toValue_bool(target.reference().delete())
+ case token.TYPEOF:
+ targetValue := target.resolve()
+ switch targetValue.kind {
+ case valueUndefined:
+ return toValue_string("undefined")
+ case valueNull:
+ return toValue_string("object")
+ case valueBoolean:
+ return toValue_string("boolean")
+ case valueNumber:
+ return toValue_string("number")
+ case valueString:
+ return toValue_string("string")
+ case valueObject:
+ if targetValue._object().isCall() {
+ return toValue_string("function")
+ }
+ return toValue_string("object")
+ default:
+ // FIXME ?
+ }
+ }
+
+ panic(hereBeDragons())
+}
+
+func (self *_runtime) cmpl_evaluate_nodeVariableExpression(node *_nodeVariableExpression) Value {
+ if node.initializer != nil {
+ // FIXME If reference is nil
+ left := getIdentifierReference(self, self.scope.lexical, node.name, false, _at(node.idx))
+ right := self.cmpl_evaluate_nodeExpression(node.initializer)
+ rightValue := right.resolve()
+
+ self.putValue(left, rightValue)
+ }
+ return toValue_string(node.name)
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/cmpl_evaluate_statement.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/cmpl_evaluate_statement.go
new file mode 100644
index 000000000..7be158487
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/cmpl_evaluate_statement.go
@@ -0,0 +1,421 @@
+package otto
+
+import (
+ "fmt"
+ "runtime"
+
+ "github.com/robertkrimen/otto/token"
+)
+
+func (self *_runtime) cmpl_evaluate_nodeStatement(node _nodeStatement) Value {
+ // Allow interpreter interruption
+ // If the Interrupt channel is nil, then
+ // we avoid runtime.Gosched() overhead (if any)
+ // FIXME: Test this
+ if self.otto.Interrupt != nil {
+ runtime.Gosched()
+ select {
+ case value := <-self.otto.Interrupt:
+ value()
+ default:
+ }
+ }
+
+ switch node := node.(type) {
+
+ case *_nodeBlockStatement:
+ labels := self.labels
+ self.labels = nil
+
+ value := self.cmpl_evaluate_nodeStatementList(node.list)
+ switch value.kind {
+ case valueResult:
+ switch value.evaluateBreak(labels) {
+ case resultBreak:
+ return emptyValue
+ }
+ }
+ return value
+
+ case *_nodeBranchStatement:
+ target := node.label
+ switch node.branch { // FIXME Maybe node.kind? node.operator?
+ case token.BREAK:
+ return toValue(newBreakResult(target))
+ case token.CONTINUE:
+ return toValue(newContinueResult(target))
+ }
+
+ case *_nodeDebuggerStatement:
+ return emptyValue // Nothing happens.
+
+ case *_nodeDoWhileStatement:
+ return self.cmpl_evaluate_nodeDoWhileStatement(node)
+
+ case *_nodeEmptyStatement:
+ return emptyValue
+
+ case *_nodeExpressionStatement:
+ return self.cmpl_evaluate_nodeExpression(node.expression)
+
+ case *_nodeForInStatement:
+ return self.cmpl_evaluate_nodeForInStatement(node)
+
+ case *_nodeForStatement:
+ return self.cmpl_evaluate_nodeForStatement(node)
+
+ case *_nodeIfStatement:
+ return self.cmpl_evaluate_nodeIfStatement(node)
+
+ case *_nodeLabelledStatement:
+ self.labels = append(self.labels, node.label)
+ defer func() {
+ if len(self.labels) > 0 {
+ self.labels = self.labels[:len(self.labels)-1] // Pop the label
+ } else {
+ self.labels = nil
+ }
+ }()
+ return self.cmpl_evaluate_nodeStatement(node.statement)
+
+ case *_nodeReturnStatement:
+ if node.argument != nil {
+ return toValue(newReturnResult(self.cmpl_evaluate_nodeExpression(node.argument).resolve()))
+ }
+ return toValue(newReturnResult(Value{}))
+
+ case *_nodeSwitchStatement:
+ return self.cmpl_evaluate_nodeSwitchStatement(node)
+
+ case *_nodeThrowStatement:
+ value := self.cmpl_evaluate_nodeExpression(node.argument).resolve()
+ panic(newException(value))
+
+ case *_nodeTryStatement:
+ return self.cmpl_evaluate_nodeTryStatement(node)
+
+ case *_nodeVariableStatement:
+ // Variables are already defined, this is initialization only
+ for _, variable := range node.list {
+ self.cmpl_evaluate_nodeVariableExpression(variable.(*_nodeVariableExpression))
+ }
+ return emptyValue
+
+ case *_nodeWhileStatement:
+ return self.cmpl_evaluate_nodeWhileStatement(node)
+
+ case *_nodeWithStatement:
+ return self.cmpl_evaluate_nodeWithStatement(node)
+
+ }
+
+ panic(fmt.Errorf("Here be dragons: evaluate_nodeStatement(%T)", node))
+}
+
+func (self *_runtime) cmpl_evaluate_nodeStatementList(list []_nodeStatement) Value {
+ var result Value
+ for _, node := range list {
+ value := self.cmpl_evaluate_nodeStatement(node)
+ switch value.kind {
+ case valueResult:
+ return value
+ case valueEmpty:
+ default:
+ // We have getValue here to (for example) trigger a
+ // ReferenceError (of the not defined variety)
+ // Not sure if this is the best way to error out early
+ // for such errors or if there is a better way
+ // TODO Do we still need this?
+ result = value.resolve()
+ }
+ }
+ return result
+}
+
+func (self *_runtime) cmpl_evaluate_nodeDoWhileStatement(node *_nodeDoWhileStatement) Value {
+
+ labels := append(self.labels, "")
+ self.labels = nil
+
+ test := node.test
+
+ result := emptyValue
+resultBreak:
+ for {
+ for _, node := range node.body {
+ value := self.cmpl_evaluate_nodeStatement(node)
+ switch value.kind {
+ case valueResult:
+ switch value.evaluateBreakContinue(labels) {
+ case resultReturn:
+ return value
+ case resultBreak:
+ break resultBreak
+ case resultContinue:
+ goto resultContinue
+ }
+ case valueEmpty:
+ default:
+ result = value
+ }
+ }
+ resultContinue:
+ if !self.cmpl_evaluate_nodeExpression(test).resolve().bool() {
+ // Stahp: do ... while (false)
+ break
+ }
+ }
+ return result
+}
+
+func (self *_runtime) cmpl_evaluate_nodeForInStatement(node *_nodeForInStatement) Value {
+
+ labels := append(self.labels, "")
+ self.labels = nil
+
+ source := self.cmpl_evaluate_nodeExpression(node.source)
+ sourceValue := source.resolve()
+
+ switch sourceValue.kind {
+ case valueUndefined, valueNull:
+ return emptyValue
+ }
+
+ sourceObject := self.toObject(sourceValue)
+
+ into := node.into
+ body := node.body
+
+ result := emptyValue
+ object := sourceObject
+ for object != nil {
+ enumerateValue := emptyValue
+ object.enumerate(false, func(name string) bool {
+ into := self.cmpl_evaluate_nodeExpression(into)
+ // In the case of: for (var abc in def) ...
+ if into.reference() == nil {
+ identifier := into.string()
+ // TODO Should be true or false (strictness) depending on context
+ into = toValue(getIdentifierReference(self, self.scope.lexical, identifier, false, -1))
+ }
+ self.putValue(into.reference(), toValue_string(name))
+ for _, node := range body {
+ value := self.cmpl_evaluate_nodeStatement(node)
+ switch value.kind {
+ case valueResult:
+ switch value.evaluateBreakContinue(labels) {
+ case resultReturn:
+ enumerateValue = value
+ return false
+ case resultBreak:
+ object = nil
+ return false
+ case resultContinue:
+ return true
+ }
+ case valueEmpty:
+ default:
+ enumerateValue = value
+ }
+ }
+ return true
+ })
+ if object == nil {
+ break
+ }
+ object = object.prototype
+ if !enumerateValue.isEmpty() {
+ result = enumerateValue
+ }
+ }
+ return result
+}
+
+func (self *_runtime) cmpl_evaluate_nodeForStatement(node *_nodeForStatement) Value {
+
+ labels := append(self.labels, "")
+ self.labels = nil
+
+ initializer := node.initializer
+ test := node.test
+ update := node.update
+ body := node.body
+
+ if initializer != nil {
+ initialResult := self.cmpl_evaluate_nodeExpression(initializer)
+ initialResult.resolve() // Side-effect trigger
+ }
+
+ result := emptyValue
+resultBreak:
+ for {
+ if test != nil {
+ testResult := self.cmpl_evaluate_nodeExpression(test)
+ testResultValue := testResult.resolve()
+ if testResultValue.bool() == false {
+ break
+ }
+ }
+ for _, node := range body {
+ value := self.cmpl_evaluate_nodeStatement(node)
+ switch value.kind {
+ case valueResult:
+ switch value.evaluateBreakContinue(labels) {
+ case resultReturn:
+ return value
+ case resultBreak:
+ break resultBreak
+ case resultContinue:
+ goto resultContinue
+ }
+ case valueEmpty:
+ default:
+ result = value
+ }
+ }
+ resultContinue:
+ if update != nil {
+ updateResult := self.cmpl_evaluate_nodeExpression(update)
+ updateResult.resolve() // Side-effect trigger
+ }
+ }
+ return result
+}
+
+func (self *_runtime) cmpl_evaluate_nodeIfStatement(node *_nodeIfStatement) Value {
+ test := self.cmpl_evaluate_nodeExpression(node.test)
+ testValue := test.resolve()
+ if testValue.bool() {
+ return self.cmpl_evaluate_nodeStatement(node.consequent)
+ } else if node.alternate != nil {
+ return self.cmpl_evaluate_nodeStatement(node.alternate)
+ }
+
+ return emptyValue
+}
+
+func (self *_runtime) cmpl_evaluate_nodeSwitchStatement(node *_nodeSwitchStatement) Value {
+
+ labels := append(self.labels, "")
+ self.labels = nil
+
+ discriminantResult := self.cmpl_evaluate_nodeExpression(node.discriminant)
+ target := node.default_
+
+ for index, clause := range node.body {
+ test := clause.test
+ if test != nil {
+ if self.calculateComparison(token.STRICT_EQUAL, discriminantResult, self.cmpl_evaluate_nodeExpression(test)) {
+ target = index
+ break
+ }
+ }
+ }
+
+ result := emptyValue
+ if target != -1 {
+ for _, clause := range node.body[target:] {
+ for _, statement := range clause.consequent {
+ value := self.cmpl_evaluate_nodeStatement(statement)
+ switch value.kind {
+ case valueResult:
+ switch value.evaluateBreak(labels) {
+ case resultReturn:
+ return value
+ case resultBreak:
+ return emptyValue
+ }
+ case valueEmpty:
+ default:
+ result = value
+ }
+ }
+ }
+ }
+
+ return result
+}
+
+func (self *_runtime) cmpl_evaluate_nodeTryStatement(node *_nodeTryStatement) Value {
+ tryCatchValue, exception := self.tryCatchEvaluate(func() Value {
+ return self.cmpl_evaluate_nodeStatement(node.body)
+ })
+
+ if exception && node.catch != nil {
+ outer := self.scope.lexical
+ self.scope.lexical = self.newDeclarationStash(outer)
+ defer func() {
+ self.scope.lexical = outer
+ }()
+ // TODO If necessary, convert TypeError<runtime> => TypeError
+ // That, is, such errors can be thrown despite not being JavaScript "native"
+ // strict = false
+ self.scope.lexical.setValue(node.catch.parameter, tryCatchValue, false)
+
+ // FIXME node.CatchParameter
+ // FIXME node.Catch
+ tryCatchValue, exception = self.tryCatchEvaluate(func() Value {
+ return self.cmpl_evaluate_nodeStatement(node.catch.body)
+ })
+ }
+
+ if node.finally != nil {
+ finallyValue := self.cmpl_evaluate_nodeStatement(node.finally)
+ if finallyValue.kind == valueResult {
+ return finallyValue
+ }
+ }
+
+ if exception {
+ panic(newException(tryCatchValue))
+ }
+
+ return tryCatchValue
+}
+
+func (self *_runtime) cmpl_evaluate_nodeWhileStatement(node *_nodeWhileStatement) Value {
+
+ test := node.test
+ body := node.body
+ labels := append(self.labels, "")
+ self.labels = nil
+
+ result := emptyValue
+resultBreakContinue:
+ for {
+ if !self.cmpl_evaluate_nodeExpression(test).resolve().bool() {
+ // Stahp: while (false) ...
+ break
+ }
+ for _, node := range body {
+ value := self.cmpl_evaluate_nodeStatement(node)
+ switch value.kind {
+ case valueResult:
+ switch value.evaluateBreakContinue(labels) {
+ case resultReturn:
+ return value
+ case resultBreak:
+ break resultBreakContinue
+ case resultContinue:
+ continue resultBreakContinue
+ }
+ case valueEmpty:
+ default:
+ result = value
+ }
+ }
+ }
+ return result
+}
+
+func (self *_runtime) cmpl_evaluate_nodeWithStatement(node *_nodeWithStatement) Value {
+ object := self.cmpl_evaluate_nodeExpression(node.object)
+ outer := self.scope.lexical
+ lexical := self.newObjectStash(self.toObject(object.resolve()), outer)
+ self.scope.lexical = lexical
+ defer func() {
+ self.scope.lexical = outer
+ }()
+
+ return self.cmpl_evaluate_nodeStatement(node.body)
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/cmpl_parse.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/cmpl_parse.go
new file mode 100644
index 000000000..e758a5230
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/cmpl_parse.go
@@ -0,0 +1,650 @@
+package otto
+
+import (
+ "fmt"
+ "regexp"
+
+ "github.com/robertkrimen/otto/ast"
+ "github.com/robertkrimen/otto/file"
+ "github.com/robertkrimen/otto/token"
+)
+
+var trueLiteral = &_nodeLiteral{value: toValue_bool(true)}
+var falseLiteral = &_nodeLiteral{value: toValue_bool(false)}
+var nullLiteral = &_nodeLiteral{value: nullValue}
+var emptyStatement = &_nodeEmptyStatement{}
+
+func (cmpl *_compiler) parseExpression(in ast.Expression) _nodeExpression {
+ if in == nil {
+ return nil
+ }
+
+ switch in := in.(type) {
+
+ case *ast.ArrayLiteral:
+ out := &_nodeArrayLiteral{
+ value: make([]_nodeExpression, len(in.Value)),
+ }
+ for i, value := range in.Value {
+ out.value[i] = cmpl.parseExpression(value)
+ }
+ return out
+
+ case *ast.AssignExpression:
+ return &_nodeAssignExpression{
+ operator: in.Operator,
+ left: cmpl.parseExpression(in.Left),
+ right: cmpl.parseExpression(in.Right),
+ }
+
+ case *ast.BinaryExpression:
+ return &_nodeBinaryExpression{
+ operator: in.Operator,
+ left: cmpl.parseExpression(in.Left),
+ right: cmpl.parseExpression(in.Right),
+ comparison: in.Comparison,
+ }
+
+ case *ast.BooleanLiteral:
+ if in.Value {
+ return trueLiteral
+ }
+ return falseLiteral
+
+ case *ast.BracketExpression:
+ return &_nodeBracketExpression{
+ idx: in.Left.Idx0(),
+ left: cmpl.parseExpression(in.Left),
+ member: cmpl.parseExpression(in.Member),
+ }
+
+ case *ast.CallExpression:
+ out := &_nodeCallExpression{
+ callee: cmpl.parseExpression(in.Callee),
+ argumentList: make([]_nodeExpression, len(in.ArgumentList)),
+ }
+ for i, value := range in.ArgumentList {
+ out.argumentList[i] = cmpl.parseExpression(value)
+ }
+ return out
+
+ case *ast.ConditionalExpression:
+ return &_nodeConditionalExpression{
+ test: cmpl.parseExpression(in.Test),
+ consequent: cmpl.parseExpression(in.Consequent),
+ alternate: cmpl.parseExpression(in.Alternate),
+ }
+
+ case *ast.DotExpression:
+ return &_nodeDotExpression{
+ idx: in.Left.Idx0(),
+ left: cmpl.parseExpression(in.Left),
+ identifier: in.Identifier.Name,
+ }
+
+ case *ast.FunctionLiteral:
+ name := ""
+ if in.Name != nil {
+ name = in.Name.Name
+ }
+ out := &_nodeFunctionLiteral{
+ name: name,
+ body: cmpl.parseStatement(in.Body),
+ source: in.Source,
+ file: cmpl.file,
+ }
+ if in.ParameterList != nil {
+ list := in.ParameterList.List
+ out.parameterList = make([]string, len(list))
+ for i, value := range list {
+ out.parameterList[i] = value.Name
+ }
+ }
+ for _, value := range in.DeclarationList {
+ switch value := value.(type) {
+ case *ast.FunctionDeclaration:
+ out.functionList = append(out.functionList, cmpl.parseExpression(value.Function).(*_nodeFunctionLiteral))
+ case *ast.VariableDeclaration:
+ for _, value := range value.List {
+ out.varList = append(out.varList, value.Name)
+ }
+ default:
+ panic(fmt.Errorf("Here be dragons: parseProgram.declaration(%T)", value))
+ }
+ }
+ return out
+
+ case *ast.Identifier:
+ return &_nodeIdentifier{
+ idx: in.Idx,
+ name: in.Name,
+ }
+
+ case *ast.NewExpression:
+ out := &_nodeNewExpression{
+ callee: cmpl.parseExpression(in.Callee),
+ argumentList: make([]_nodeExpression, len(in.ArgumentList)),
+ }
+ for i, value := range in.ArgumentList {
+ out.argumentList[i] = cmpl.parseExpression(value)
+ }
+ return out
+
+ case *ast.NullLiteral:
+ return nullLiteral
+
+ case *ast.NumberLiteral:
+ return &_nodeLiteral{
+ value: toValue(in.Value),
+ }
+
+ case *ast.ObjectLiteral:
+ out := &_nodeObjectLiteral{
+ value: make([]_nodeProperty, len(in.Value)),
+ }
+ for i, value := range in.Value {
+ out.value[i] = _nodeProperty{
+ key: value.Key,
+ kind: value.Kind,
+ value: cmpl.parseExpression(value.Value),
+ }
+ }
+ return out
+
+ case *ast.RegExpLiteral:
+ return &_nodeRegExpLiteral{
+ flags: in.Flags,
+ pattern: in.Pattern,
+ }
+
+ case *ast.SequenceExpression:
+ out := &_nodeSequenceExpression{
+ sequence: make([]_nodeExpression, len(in.Sequence)),
+ }
+ for i, value := range in.Sequence {
+ out.sequence[i] = cmpl.parseExpression(value)
+ }
+ return out
+
+ case *ast.StringLiteral:
+ return &_nodeLiteral{
+ value: toValue_string(in.Value),
+ }
+
+ case *ast.ThisExpression:
+ return &_nodeThisExpression{}
+
+ case *ast.UnaryExpression:
+ return &_nodeUnaryExpression{
+ operator: in.Operator,
+ operand: cmpl.parseExpression(in.Operand),
+ postfix: in.Postfix,
+ }
+
+ case *ast.VariableExpression:
+ return &_nodeVariableExpression{
+ idx: in.Idx0(),
+ name: in.Name,
+ initializer: cmpl.parseExpression(in.Initializer),
+ }
+
+ }
+
+ panic(fmt.Errorf("Here be dragons: cmpl.parseExpression(%T)", in))
+}
+
+func (cmpl *_compiler) parseStatement(in ast.Statement) _nodeStatement {
+ if in == nil {
+ return nil
+ }
+
+ switch in := in.(type) {
+
+ case *ast.BlockStatement:
+ out := &_nodeBlockStatement{
+ list: make([]_nodeStatement, len(in.List)),
+ }
+ for i, value := range in.List {
+ out.list[i] = cmpl.parseStatement(value)
+ }
+ return out
+
+ case *ast.BranchStatement:
+ out := &_nodeBranchStatement{
+ branch: in.Token,
+ }
+ if in.Label != nil {
+ out.label = in.Label.Name
+ }
+ return out
+
+ case *ast.DebuggerStatement:
+ return &_nodeDebuggerStatement{}
+
+ case *ast.DoWhileStatement:
+ out := &_nodeDoWhileStatement{
+ test: cmpl.parseExpression(in.Test),
+ }
+ body := cmpl.parseStatement(in.Body)
+ if block, ok := body.(*_nodeBlockStatement); ok {
+ out.body = block.list
+ } else {
+ out.body = append(out.body, body)
+ }
+ return out
+
+ case *ast.EmptyStatement:
+ return emptyStatement
+
+ case *ast.ExpressionStatement:
+ return &_nodeExpressionStatement{
+ expression: cmpl.parseExpression(in.Expression),
+ }
+
+ case *ast.ForInStatement:
+ out := &_nodeForInStatement{
+ into: cmpl.parseExpression(in.Into),
+ source: cmpl.parseExpression(in.Source),
+ }
+ body := cmpl.parseStatement(in.Body)
+ if block, ok := body.(*_nodeBlockStatement); ok {
+ out.body = block.list
+ } else {
+ out.body = append(out.body, body)
+ }
+ return out
+
+ case *ast.ForStatement:
+ out := &_nodeForStatement{
+ initializer: cmpl.parseExpression(in.Initializer),
+ update: cmpl.parseExpression(in.Update),
+ test: cmpl.parseExpression(in.Test),
+ }
+ body := cmpl.parseStatement(in.Body)
+ if block, ok := body.(*_nodeBlockStatement); ok {
+ out.body = block.list
+ } else {
+ out.body = append(out.body, body)
+ }
+ return out
+
+ case *ast.IfStatement:
+ return &_nodeIfStatement{
+ test: cmpl.parseExpression(in.Test),
+ consequent: cmpl.parseStatement(in.Consequent),
+ alternate: cmpl.parseStatement(in.Alternate),
+ }
+
+ case *ast.LabelledStatement:
+ return &_nodeLabelledStatement{
+ label: in.Label.Name,
+ statement: cmpl.parseStatement(in.Statement),
+ }
+
+ case *ast.ReturnStatement:
+ return &_nodeReturnStatement{
+ argument: cmpl.parseExpression(in.Argument),
+ }
+
+ case *ast.SwitchStatement:
+ out := &_nodeSwitchStatement{
+ discriminant: cmpl.parseExpression(in.Discriminant),
+ default_: in.Default,
+ body: make([]*_nodeCaseStatement, len(in.Body)),
+ }
+ for i, clause := range in.Body {
+ out.body[i] = &_nodeCaseStatement{
+ test: cmpl.parseExpression(clause.Test),
+ consequent: make([]_nodeStatement, len(clause.Consequent)),
+ }
+ for j, value := range clause.Consequent {
+ out.body[i].consequent[j] = cmpl.parseStatement(value)
+ }
+ }
+ return out
+
+ case *ast.ThrowStatement:
+ return &_nodeThrowStatement{
+ argument: cmpl.parseExpression(in.Argument),
+ }
+
+ case *ast.TryStatement:
+ out := &_nodeTryStatement{
+ body: cmpl.parseStatement(in.Body),
+ finally: cmpl.parseStatement(in.Finally),
+ }
+ if in.Catch != nil {
+ out.catch = &_nodeCatchStatement{
+ parameter: in.Catch.Parameter.Name,
+ body: cmpl.parseStatement(in.Catch.Body),
+ }
+ }
+ return out
+
+ case *ast.VariableStatement:
+ out := &_nodeVariableStatement{
+ list: make([]_nodeExpression, len(in.List)),
+ }
+ for i, value := range in.List {
+ out.list[i] = cmpl.parseExpression(value)
+ }
+ return out
+
+ case *ast.WhileStatement:
+ out := &_nodeWhileStatement{
+ test: cmpl.parseExpression(in.Test),
+ }
+ body := cmpl.parseStatement(in.Body)
+ if block, ok := body.(*_nodeBlockStatement); ok {
+ out.body = block.list
+ } else {
+ out.body = append(out.body, body)
+ }
+ return out
+
+ case *ast.WithStatement:
+ return &_nodeWithStatement{
+ object: cmpl.parseExpression(in.Object),
+ body: cmpl.parseStatement(in.Body),
+ }
+
+ }
+
+ panic(fmt.Errorf("Here be dragons: cmpl.parseStatement(%T)", in))
+}
+
+func cmpl_parse(in *ast.Program) *_nodeProgram {
+ cmpl := _compiler{
+ program: in,
+ }
+ return cmpl.parse()
+}
+
+func (cmpl *_compiler) _parse(in *ast.Program) *_nodeProgram {
+ out := &_nodeProgram{
+ body: make([]_nodeStatement, len(in.Body)),
+ file: in.File,
+ }
+ for i, value := range in.Body {
+ out.body[i] = cmpl.parseStatement(value)
+ }
+ for _, value := range in.DeclarationList {
+ switch value := value.(type) {
+ case *ast.FunctionDeclaration:
+ out.functionList = append(out.functionList, cmpl.parseExpression(value.Function).(*_nodeFunctionLiteral))
+ case *ast.VariableDeclaration:
+ for _, value := range value.List {
+ out.varList = append(out.varList, value.Name)
+ }
+ default:
+ panic(fmt.Errorf("Here be dragons: cmpl.parseProgram.DeclarationList(%T)", value))
+ }
+ }
+ return out
+}
+
+type _nodeProgram struct {
+ body []_nodeStatement
+
+ varList []string
+ functionList []*_nodeFunctionLiteral
+
+ variableList []_nodeDeclaration
+
+ file *file.File
+}
+
+type _nodeDeclaration struct {
+ name string
+ definition _node
+}
+
+type _node interface {
+}
+
+type (
+ _nodeExpression interface {
+ _node
+ _expressionNode()
+ }
+
+ _nodeArrayLiteral struct {
+ value []_nodeExpression
+ }
+
+ _nodeAssignExpression struct {
+ operator token.Token
+ left _nodeExpression
+ right _nodeExpression
+ }
+
+ _nodeBinaryExpression struct {
+ operator token.Token
+ left _nodeExpression
+ right _nodeExpression
+ comparison bool
+ }
+
+ _nodeBracketExpression struct {
+ idx file.Idx
+ left _nodeExpression
+ member _nodeExpression
+ }
+
+ _nodeCallExpression struct {
+ callee _nodeExpression
+ argumentList []_nodeExpression
+ }
+
+ _nodeConditionalExpression struct {
+ test _nodeExpression
+ consequent _nodeExpression
+ alternate _nodeExpression
+ }
+
+ _nodeDotExpression struct {
+ idx file.Idx
+ left _nodeExpression
+ identifier string
+ }
+
+ _nodeFunctionLiteral struct {
+ name string
+ body _nodeStatement
+ source string
+ parameterList []string
+ varList []string
+ functionList []*_nodeFunctionLiteral
+ file *file.File
+ }
+
+ _nodeIdentifier struct {
+ idx file.Idx
+ name string
+ }
+
+ _nodeLiteral struct {
+ value Value
+ }
+
+ _nodeNewExpression struct {
+ callee _nodeExpression
+ argumentList []_nodeExpression
+ }
+
+ _nodeObjectLiteral struct {
+ value []_nodeProperty
+ }
+
+ _nodeProperty struct {
+ key string
+ kind string
+ value _nodeExpression
+ }
+
+ _nodeRegExpLiteral struct {
+ flags string
+ pattern string // Value?
+ regexp *regexp.Regexp
+ }
+
+ _nodeSequenceExpression struct {
+ sequence []_nodeExpression
+ }
+
+ _nodeThisExpression struct {
+ }
+
+ _nodeUnaryExpression struct {
+ operator token.Token
+ operand _nodeExpression
+ postfix bool
+ }
+
+ _nodeVariableExpression struct {
+ idx file.Idx
+ name string
+ initializer _nodeExpression
+ }
+)
+
+type (
+ _nodeStatement interface {
+ _node
+ _statementNode()
+ }
+
+ _nodeBlockStatement struct {
+ list []_nodeStatement
+ }
+
+ _nodeBranchStatement struct {
+ branch token.Token
+ label string
+ }
+
+ _nodeCaseStatement struct {
+ test _nodeExpression
+ consequent []_nodeStatement
+ }
+
+ _nodeCatchStatement struct {
+ parameter string
+ body _nodeStatement
+ }
+
+ _nodeDebuggerStatement struct {
+ }
+
+ _nodeDoWhileStatement struct {
+ test _nodeExpression
+ body []_nodeStatement
+ }
+
+ _nodeEmptyStatement struct {
+ }
+
+ _nodeExpressionStatement struct {
+ expression _nodeExpression
+ }
+
+ _nodeForInStatement struct {
+ into _nodeExpression
+ source _nodeExpression
+ body []_nodeStatement
+ }
+
+ _nodeForStatement struct {
+ initializer _nodeExpression
+ update _nodeExpression
+ test _nodeExpression
+ body []_nodeStatement
+ }
+
+ _nodeIfStatement struct {
+ test _nodeExpression
+ consequent _nodeStatement
+ alternate _nodeStatement
+ }
+
+ _nodeLabelledStatement struct {
+ label string
+ statement _nodeStatement
+ }
+
+ _nodeReturnStatement struct {
+ argument _nodeExpression
+ }
+
+ _nodeSwitchStatement struct {
+ discriminant _nodeExpression
+ default_ int
+ body []*_nodeCaseStatement
+ }
+
+ _nodeThrowStatement struct {
+ argument _nodeExpression
+ }
+
+ _nodeTryStatement struct {
+ body _nodeStatement
+ catch *_nodeCatchStatement
+ finally _nodeStatement
+ }
+
+ _nodeVariableStatement struct {
+ list []_nodeExpression
+ }
+
+ _nodeWhileStatement struct {
+ test _nodeExpression
+ body []_nodeStatement
+ }
+
+ _nodeWithStatement struct {
+ object _nodeExpression
+ body _nodeStatement
+ }
+)
+
+// _expressionNode
+
+func (*_nodeArrayLiteral) _expressionNode() {}
+func (*_nodeAssignExpression) _expressionNode() {}
+func (*_nodeBinaryExpression) _expressionNode() {}
+func (*_nodeBracketExpression) _expressionNode() {}
+func (*_nodeCallExpression) _expressionNode() {}
+func (*_nodeConditionalExpression) _expressionNode() {}
+func (*_nodeDotExpression) _expressionNode() {}
+func (*_nodeFunctionLiteral) _expressionNode() {}
+func (*_nodeIdentifier) _expressionNode() {}
+func (*_nodeLiteral) _expressionNode() {}
+func (*_nodeNewExpression) _expressionNode() {}
+func (*_nodeObjectLiteral) _expressionNode() {}
+func (*_nodeRegExpLiteral) _expressionNode() {}
+func (*_nodeSequenceExpression) _expressionNode() {}
+func (*_nodeThisExpression) _expressionNode() {}
+func (*_nodeUnaryExpression) _expressionNode() {}
+func (*_nodeVariableExpression) _expressionNode() {}
+
+// _statementNode
+
+func (*_nodeBlockStatement) _statementNode() {}
+func (*_nodeBranchStatement) _statementNode() {}
+func (*_nodeCaseStatement) _statementNode() {}
+func (*_nodeCatchStatement) _statementNode() {}
+func (*_nodeDebuggerStatement) _statementNode() {}
+func (*_nodeDoWhileStatement) _statementNode() {}
+func (*_nodeEmptyStatement) _statementNode() {}
+func (*_nodeExpressionStatement) _statementNode() {}
+func (*_nodeForInStatement) _statementNode() {}
+func (*_nodeForStatement) _statementNode() {}
+func (*_nodeIfStatement) _statementNode() {}
+func (*_nodeLabelledStatement) _statementNode() {}
+func (*_nodeReturnStatement) _statementNode() {}
+func (*_nodeSwitchStatement) _statementNode() {}
+func (*_nodeThrowStatement) _statementNode() {}
+func (*_nodeTryStatement) _statementNode() {}
+func (*_nodeVariableStatement) _statementNode() {}
+func (*_nodeWhileStatement) _statementNode() {}
+func (*_nodeWithStatement) _statementNode() {}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/cmpl_test.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/cmpl_test.go
new file mode 100644
index 000000000..34b050f00
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/cmpl_test.go
@@ -0,0 +1,54 @@
+package otto
+
+import (
+ "testing"
+
+ "github.com/robertkrimen/otto/parser"
+)
+
+func Test_cmpl(t *testing.T) {
+ tt(t, func() {
+ vm := New()
+
+ test := func(src string, expect ...interface{}) {
+ program, err := parser.ParseFile(nil, "", src, 0)
+ is(err, nil)
+ {
+ program := cmpl_parse(program)
+ value := vm.runtime.cmpl_evaluate_nodeProgram(program, false)
+ if len(expect) > 0 {
+ is(value, expect[0])
+ }
+ }
+ }
+
+ test(``, Value{})
+
+ test(`var abc = 1; abc;`, 1)
+
+ test(`var abc = 1 + 1; abc;`, 2)
+
+ test(`1 + 2;`, 3)
+ })
+}
+
+func TestParse_cmpl(t *testing.T) {
+ tt(t, func() {
+
+ test := func(src string) {
+ program, err := parser.ParseFile(nil, "", src, 0)
+ is(err, nil)
+ is(cmpl_parse(program), "!=", nil)
+ }
+
+ test(``)
+
+ test(`var abc = 1; abc;`)
+
+ test(`
+ function abc() {
+ return;
+ }
+ `)
+ })
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/console.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/console.go
new file mode 100644
index 000000000..948face77
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/console.go
@@ -0,0 +1,51 @@
+package otto
+
+import (
+ "fmt"
+ "os"
+ "strings"
+)
+
+func formatForConsole(argumentList []Value) string {
+ output := []string{}
+ for _, argument := range argumentList {
+ output = append(output, fmt.Sprintf("%v", argument))
+ }
+ return strings.Join(output, " ")
+}
+
+func builtinConsole_log(call FunctionCall) Value {
+ fmt.Fprintln(os.Stdout, formatForConsole(call.ArgumentList))
+ return Value{}
+}
+
+func builtinConsole_error(call FunctionCall) Value {
+ fmt.Fprintln(os.Stdout, formatForConsole(call.ArgumentList))
+ return Value{}
+}
+
+// Nothing happens.
+func builtinConsole_dir(call FunctionCall) Value {
+ return Value{}
+}
+
+func builtinConsole_time(call FunctionCall) Value {
+ return Value{}
+}
+
+func builtinConsole_timeEnd(call FunctionCall) Value {
+ return Value{}
+}
+
+func builtinConsole_trace(call FunctionCall) Value {
+ return Value{}
+}
+
+func builtinConsole_assert(call FunctionCall) Value {
+ return Value{}
+}
+
+func (runtime *_runtime) newConsole() *_object {
+
+ return newConsoleObject(runtime)
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/date_test.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/date_test.go
new file mode 100644
index 000000000..a9c71edde
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/date_test.go
@@ -0,0 +1,481 @@
+package otto
+
+import (
+ "math"
+ "testing"
+ "time"
+)
+
+func mockTimeLocal(location *time.Location) func() {
+ local := time.Local
+ time.Local = location
+ return func() {
+ time.Local = local
+ }
+}
+
+// Passing or failing should not be dependent on what time zone we're in
+func mockUTC() func() {
+ return mockTimeLocal(time.UTC)
+}
+
+func TestDate(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ defer mockUTC()()
+
+ time0 := time.Unix(1348616313, 47*1000*1000).Local()
+
+ test(`Date`, "function Date() { [native code] }")
+ test(`new Date(0).toUTCString()`, "Thu, 01 Jan 1970 00:00:00 UTC")
+ test(`new Date(0).toGMTString()`, "Thu, 01 Jan 1970 00:00:00 GMT")
+ if false {
+ // TODO toLocale{Date,Time}String
+ test(`new Date(0).toLocaleString()`, "")
+ test(`new Date(0).toLocaleDateString()`, "")
+ test(`new Date(0).toLocaleTimeString()`, "")
+ }
+ test(`new Date(1348616313).getTime()`, 1348616313)
+ test(`new Date(1348616313).toUTCString()`, "Fri, 16 Jan 1970 14:36:56 UTC")
+ test(`abc = new Date(1348616313047); abc.toUTCString()`, "Tue, 25 Sep 2012 23:38:33 UTC")
+ test(`abc.getYear()`, time0.Year()-1900)
+ test(`abc.getFullYear()`, time0.Year())
+ test(`abc.getUTCFullYear()`, 2012)
+ test(`abc.getMonth()`, int(time0.Month())-1) // Remember, the JavaScript month is 0-based
+ test(`abc.getUTCMonth()`, 8)
+ test(`abc.getDate()`, time0.Day())
+ test(`abc.getUTCDate()`, 25)
+ test(`abc.getDay()`, int(time0.Weekday()))
+ test(`abc.getUTCDay()`, 2)
+ test(`abc.getHours()`, time0.Hour())
+ test(`abc.getUTCHours()`, 23)
+ test(`abc.getMinutes()`, time0.Minute())
+ test(`abc.getUTCMinutes()`, 38)
+ test(`abc.getSeconds()`, time0.Second())
+ test(`abc.getUTCSeconds()`, 33)
+ test(`abc.getMilliseconds()`, time0.Nanosecond()/(1000*1000)) // In honor of the 47%
+ test(`abc.getUTCMilliseconds()`, 47)
+ _, offset := time0.Zone()
+ test(`abc.getTimezoneOffset()`, offset/-60)
+
+ test(`new Date("Xyzzy").getTime()`, math.NaN())
+
+ test(`abc.setFullYear(2011); abc.toUTCString()`, "Sun, 25 Sep 2011 23:38:33 UTC")
+ test(`new Date(12564504e5).toUTCString()`, "Sun, 25 Oct 2009 06:00:00 UTC")
+ test(`new Date(2009, 9, 25).toUTCString()`, "Sun, 25 Oct 2009 00:00:00 UTC")
+ test(`+(new Date(2009, 9, 25))`, 1256428800000)
+
+ format := "Mon, 2 Jan 2006 15:04:05 MST"
+
+ time1 := time.Unix(1256450400, 0)
+ time0 = time.Date(time1.Year(), time1.Month(), time1.Day(), time1.Hour(), time1.Minute(), time1.Second(), time1.Nanosecond(), time1.Location()).UTC()
+
+ time0 = time.Date(time1.Year(), time1.Month(), time1.Day(), time1.Hour(), time1.Minute(), time1.Second(), 2001*1000*1000, time1.Location()).UTC()
+ test(`abc = new Date(12564504e5); abc.setMilliseconds(2001); abc.toUTCString()`, time0.Format(format))
+
+ time0 = time.Date(time1.Year(), time1.Month(), time1.Day(), time1.Hour(), time1.Minute(), 61, time1.Nanosecond(), time1.Location()).UTC()
+ test(`abc = new Date(12564504e5); abc.setSeconds("61"); abc.toUTCString()`, time0.Format(format))
+
+ time0 = time.Date(time1.Year(), time1.Month(), time1.Day(), time1.Hour(), 61, time1.Second(), time1.Nanosecond(), time1.Location()).UTC()
+ test(`abc = new Date(12564504e5); abc.setMinutes("61"); abc.toUTCString()`, time0.Format(format))
+
+ time0 = time.Date(time1.Year(), time1.Month(), time1.Day(), 5, time1.Minute(), time1.Second(), time1.Nanosecond(), time1.Location()).UTC()
+ test(`abc = new Date(12564504e5); abc.setHours("5"); abc.toUTCString()`, time0.Format(format))
+
+ time0 = time.Date(time1.Year(), time1.Month(), 26, time1.Hour(), time1.Minute(), time1.Second(), time1.Nanosecond(), time1.Location()).UTC()
+ test(`abc = new Date(12564504e5); abc.setDate("26"); abc.toUTCString()`, time0.Format(format))
+
+ time0 = time.Date(time1.Year(), 10, time1.Day(), time1.Hour(), time1.Minute(), time1.Second(), time1.Nanosecond(), time1.Location()).UTC()
+ test(`abc = new Date(12564504e5); abc.setMonth(9); abc.toUTCString()`, time0.Format(format))
+ test(`abc = new Date(12564504e5); abc.setMonth("09"); abc.toUTCString()`, time0.Format(format))
+
+ time0 = time.Date(time1.Year(), 11, time1.Day(), time1.Hour(), time1.Minute(), time1.Second(), time1.Nanosecond(), time1.Location()).UTC()
+ test(`abc = new Date(12564504e5); abc.setMonth("10"); abc.toUTCString()`, time0.Format(format))
+
+ time0 = time.Date(2010, time1.Month(), time1.Day(), time1.Hour(), time1.Minute(), time1.Second(), time1.Nanosecond(), time1.Location()).UTC()
+ test(`abc = new Date(12564504e5); abc.setFullYear(2010); abc.toUTCString()`, time0.Format(format))
+
+ test(`new Date("2001-01-01T10:01:02.000").getTime()`, 978343262000)
+
+ // Date()
+ test(`typeof Date()`, "string")
+ test(`typeof Date(2006, 1, 2)`, "string")
+
+ test(`
+ abc = Object.getOwnPropertyDescriptor(Date, "parse");
+ [ abc.value === Date.parse, abc.writable, abc.enumerable, abc.configurable ];
+ `, "true,true,false,true")
+
+ test(`
+ abc = Object.getOwnPropertyDescriptor(Date.prototype, "toTimeString");
+ [ abc.value === Date.prototype.toTimeString, abc.writable, abc.enumerable, abc.configurable ];
+ `, "true,true,false,true")
+
+ test(`
+ var abc = Object.getOwnPropertyDescriptor(Date, "prototype");
+ [ [ typeof Date.prototype ],
+ [ abc.writable, abc.enumerable, abc.configurable ] ];
+ `, "object,false,false,false")
+ })
+}
+
+func TestDate_parse(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ defer mockUTC()()
+
+ test(`Date.parse("2001-01-01T10:01:02.000")`, 978343262000)
+
+ test(`Date.parse("2006-01-02T15:04:05.000")`, 1136214245000)
+
+ test(`Date.parse("2006")`, 1136073600000)
+
+ test(`Date.parse("1970-01-16T14:36:56+00:00")`, 1348616000)
+
+ test(`Date.parse("1970-01-16T14:36:56.313+00:00")`, 1348616313)
+
+ test(`Date.parse("1970-01-16T14:36:56.000")`, 1348616000)
+
+ test(`Date.parse.length`, 1)
+ })
+}
+
+func TestDate_UTC(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ defer mockUTC()()
+
+ test(`Date.UTC(2009, 9, 25)`, 1256428800000)
+
+ test(`Date.UTC.length`, 7)
+ })
+}
+
+func TestDate_now(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ defer mockUTC()()
+
+ // FIXME I think this too risky
+ test(`+(""+Date.now()).substr(0, 10)`, float64(epochToInteger(timeToEpoch(time.Now()))/1000))
+
+ test(`Date.now() - Date.now(1,2,3) < 24 * 60 * 60`, true)
+ })
+}
+
+func TestDate_toISOString(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ defer mockUTC()()
+
+ test(`new Date(0).toISOString()`, "1970-01-01T00:00:00.000Z")
+ })
+}
+
+func TestDate_toJSON(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ defer mockUTC()()
+
+ test(`new Date(0).toJSON()`, "1970-01-01T00:00:00.000Z")
+ })
+}
+
+func TestDate_setYear(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ defer mockUTC()()
+
+ test(`new Date(12564504e5).setYear(96)`, 846223200000)
+
+ test(`new Date(12564504e5).setYear(1996)`, 846223200000)
+
+ test(`new Date(12564504e5).setYear(2000)`, 972453600000)
+ })
+}
+
+func TestDateDefaultValue(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ defer mockUTC()()
+
+ test(`
+ var date = new Date();
+ date + 0 === date.toString() + "0";
+ `, true)
+ })
+}
+
+func TestDate_April1978(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ defer mockUTC()()
+
+ test(`
+ var abc = new Date(1978,3);
+ [ abc.getYear(), abc.getMonth(), abc.valueOf() ];
+ `, "78,3,260236800000")
+ })
+}
+
+func TestDate_setMilliseconds(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ defer mockUTC()()
+
+ test(`
+ abc = new Date();
+ def = abc.setMilliseconds();
+ [ abc, def ];
+ `, "Invalid Date,NaN")
+ })
+}
+
+func TestDate_new(t *testing.T) {
+ // FIXME?
+ // This is probably incorrect, due to differences in Go date/time handling
+ // versus ECMA date/time handling, but we'll leave this here for
+ // future reference
+
+ if true {
+ return
+ }
+
+ tt(t, func() {
+ test, _ := test()
+
+ defer mockUTC()()
+
+ test(`
+ [
+ new Date(1899, 11).valueOf(),
+ new Date(1899, 12).valueOf(),
+ new Date(1900, 0).valueOf()
+ ]
+ `, "-2211638400000,-2208960000000,-2208960000000")
+ })
+}
+
+func TestDateComparison(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ defer mockUTC()()
+
+ test(`
+ var now0 = Date.now();
+ var now1 = (new Date()).toString();
+ [ now0 === now1, Math.abs(now0 - Date.parse(now1)) <= 1000 ];
+ `, "false,true")
+ })
+}
+
+func TestDate_setSeconds(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ defer mockUTC()()
+
+ test(`
+ abc = new Date(1980, 10);
+ def = new Date(abc);
+
+ abc.setSeconds(10, 12);
+
+ def.setSeconds(10);
+ def.setMilliseconds(12);
+
+ abc.valueOf() === def.valueOf();
+ `, true)
+
+ test(`
+ abc = new Date(1980, 10);
+ def = new Date(abc);
+
+ abc.setUTCSeconds(10, 12);
+
+ def.setUTCSeconds(10);
+ def.setUTCMilliseconds(12);
+
+ abc.valueOf() === def.valueOf();
+ `, true)
+
+ test(`Date.prototype.setSeconds.length`, 2)
+ test(`Date.prototype.setUTCSeconds.length`, 2)
+ })
+}
+
+func TestDate_setMinutes(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ defer mockUTC()()
+
+ test(`
+ abc = new Date(1980, 10);
+ def = new Date(abc);
+
+ abc.setMinutes(8, 10, 12);
+
+ def.setMinutes(8);
+ def.setSeconds(10);
+ def.setMilliseconds(12);
+
+ abc.valueOf() === def.valueOf();
+ `, true)
+
+ test(`
+ abc = new Date(1980, 10);
+ def = new Date(abc);
+
+ abc.setUTCMinutes(8, 10, 12);
+
+ def.setUTCMinutes(8);
+ def.setUTCSeconds(10);
+ def.setUTCMilliseconds(12);
+
+ abc.valueOf() === def.valueOf();
+ `, true)
+
+ test(`Date.prototype.setMinutes.length`, 3)
+ test(`Date.prototype.setUTCMinutes.length`, 3)
+ })
+}
+
+func TestDate_setHours(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ defer mockUTC()()
+
+ test(`
+ abc = new Date(1980, 10);
+ def = new Date(abc);
+
+ abc.setHours(6, 8, 10, 12);
+
+ def.setHours(6);
+ def.setMinutes(8);
+ def.setSeconds(10);
+ def.setMilliseconds(12);
+
+ abc.valueOf() === def.valueOf();
+ `, true)
+
+ test(`
+ abc = new Date(1980, 10);
+ def = new Date(abc);
+
+ abc.setUTCHours(6, 8, 10, 12);
+
+ def.setUTCHours(6);
+ def.setUTCMinutes(8);
+ def.setUTCSeconds(10);
+ def.setUTCMilliseconds(12);
+
+ abc.valueOf() === def.valueOf();
+ `, true)
+
+ test(`Date.prototype.setHours.length`, 4)
+ test(`Date.prototype.setUTCHours.length`, 4)
+ })
+}
+
+func TestDate_setMonth(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ defer mockUTC()()
+
+ test(`
+ abc = new Date(1980, 10);
+ def = new Date(abc);
+
+ abc.setMonth(6, 8);
+
+ def.setMonth(6);
+ def.setDate(8);
+
+ abc.valueOf() === def.valueOf();
+ `, true)
+
+ test(`
+ abc = new Date(1980, 10);
+ def = new Date(abc);
+
+ abc.setUTCMonth(6, 8);
+
+ def.setUTCMonth(6);
+ def.setUTCDate(8);
+
+ abc.valueOf() === def.valueOf();
+ `, true)
+
+ test(`Date.prototype.setMonth.length`, 2)
+ test(`Date.prototype.setUTCMonth.length`, 2)
+ })
+}
+
+func TestDate_setFullYear(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ defer mockUTC()()
+
+ test(`
+ abc = new Date(1980, 10);
+ def = new Date(abc);
+
+ abc.setFullYear(1981, 6, 8);
+
+ def.setFullYear(1981);
+ def.setMonth(6);
+ def.setDate(8);
+
+ abc.valueOf() === def.valueOf();
+ `, true)
+
+ test(`
+ abc = new Date(1980, 10);
+ def = new Date(abc);
+
+ abc.setUTCFullYear(1981, 6, 8);
+
+ def.setUTCFullYear(1981);
+ def.setUTCMonth(6);
+ def.setUTCDate(8);
+
+ abc.valueOf() === def.valueOf();
+ `, true)
+
+ test(`Date.prototype.setFullYear.length`, 3)
+ test(`Date.prototype.setUTCFullYear.length`, 3)
+ })
+}
+
+func TestDate_setTime(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ defer mockUTC()()
+
+ test(`
+ var abc = new Date(1999, 6, 1);
+ var def = new Date();
+ def.setTime(abc.getTime());
+ [ def, abc.valueOf() == def.valueOf() ];
+ `, "Thu, 01 Jul 1999 00:00:00 UTC,true")
+
+ test(`Date.prototype.setTime.length`, 1)
+ })
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/dbg.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/dbg.go
new file mode 100644
index 000000000..51fbdc206
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/dbg.go
@@ -0,0 +1,9 @@
+// This file was AUTOMATICALLY GENERATED by dbg-import (smuggol) for github.com/robertkrimen/dbg
+
+package otto
+
+import (
+ Dbg "github.com/robertkrimen/otto/dbg"
+)
+
+var dbg, dbgf = Dbg.New()
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/documentation_test.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/documentation_test.go
new file mode 100644
index 000000000..04646117f
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/documentation_test.go
@@ -0,0 +1,95 @@
+package otto
+
+import (
+ "fmt"
+)
+
+func ExampleSynopsis() {
+
+ vm := New()
+ vm.Run(`
+ abc = 2 + 2;
+ console.log("The value of abc is " + abc); // 4
+ `)
+
+ value, _ := vm.Get("abc")
+ {
+ value, _ := value.ToInteger()
+ fmt.Println(value)
+ }
+
+ vm.Set("def", 11)
+ vm.Run(`
+ console.log("The value of def is " + def);
+ `)
+
+ vm.Set("xyzzy", "Nothing happens.")
+ vm.Run(`
+ console.log(xyzzy.length);
+ `)
+
+ value, _ = vm.Run("xyzzy.length")
+ {
+ value, _ := value.ToInteger()
+ fmt.Println(value)
+ }
+
+ value, err := vm.Run("abcdefghijlmnopqrstuvwxyz.length")
+ fmt.Println(value)
+ fmt.Println(err)
+
+ vm.Set("sayHello", func(call FunctionCall) Value {
+ fmt.Printf("Hello, %s.\n", call.Argument(0).String())
+ return UndefinedValue()
+ })
+
+ vm.Set("twoPlus", func(call FunctionCall) Value {
+ right, _ := call.Argument(0).ToInteger()
+ result, _ := vm.ToValue(2 + right)
+ return result
+ })
+
+ value, _ = vm.Run(`
+ sayHello("Xyzzy");
+ sayHello();
+
+ result = twoPlus(2.0);
+ `)
+ fmt.Println(value)
+
+ // Output:
+ // The value of abc is 4
+ // 4
+ // The value of def is 11
+ // 16
+ // 16
+ // undefined
+ // ReferenceError: 'abcdefghijlmnopqrstuvwxyz' is not defined
+ // Hello, Xyzzy.
+ // Hello, undefined.
+ // 4
+}
+
+func ExampleConsole() {
+
+ vm := New()
+ console := map[string]interface{}{
+ "log": func(call FunctionCall) Value {
+ fmt.Println("console.log:", formatForConsole(call.ArgumentList))
+ return UndefinedValue()
+ },
+ }
+
+ err := vm.Set("console", console)
+
+ value, err := vm.Run(`
+ console.log("Hello, World.");
+ `)
+ fmt.Println(value)
+ fmt.Println(err)
+
+ // Output:
+ // console.log: Hello, World.
+ // undefined
+ // <nil>
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/error.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/error.go
new file mode 100644
index 000000000..111471044
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/error.go
@@ -0,0 +1,245 @@
+package otto
+
+import (
+ "errors"
+ "fmt"
+ "strings"
+
+ "github.com/robertkrimen/otto/file"
+)
+
+type _exception struct {
+ value interface{}
+}
+
+func newException(value interface{}) *_exception {
+ return &_exception{
+ value: value,
+ }
+}
+
+func (self *_exception) eject() interface{} {
+ value := self.value
+ self.value = nil // Prevent Go from holding on to the value, whatever it is
+ return value
+}
+
+type _error struct {
+ name string
+ message string
+ trace []_frame
+
+ offset int
+}
+
+type _frame struct {
+ file *file.File
+ offset int
+ callee string
+}
+
+var (
+ nativeFrame = _frame{}
+)
+
+type _at int
+
+func (fr _frame) location() string {
+ if fr.file == nil {
+ return "<unknown>"
+ }
+ path := fr.file.Name()
+ line, column := _position(fr.file, fr.offset)
+
+ if path == "" {
+ path = "<anonymous>"
+ }
+
+ str := fmt.Sprintf("%s:%d:%d", path, line, column)
+
+ if fr.callee != "" {
+ str = fmt.Sprintf("%s (%s)", fr.callee, str)
+ }
+
+ return str
+}
+
+func _position(file *file.File, offset int) (line, column int) {
+ {
+ offset := offset - file.Base()
+ if offset < 0 {
+ return -offset, -1
+ }
+
+ src := file.Source()
+ if offset >= len(src) {
+ return -offset, -len(src)
+ }
+ src = src[:offset]
+
+ line := 1 + strings.Count(src, "\n")
+ column := 0
+ if index := strings.LastIndex(src, "\n"); index >= 0 {
+ column = offset - index
+ } else {
+ column = 1 + len(src)
+ }
+ return line, column
+ }
+}
+
+// An Error represents a runtime error, e.g. a TypeError, a ReferenceError, etc.
+type Error struct {
+ _error
+}
+
+// Error returns a description of the error
+//
+// TypeError: 'def' is not a function
+//
+func (err Error) Error() string {
+ if len(err.name) == 0 {
+ return err.message
+ }
+ if len(err.message) == 0 {
+ return err.name
+ }
+ return fmt.Sprintf("%s: %s", err.name, err.message)
+}
+
+// String returns a description of the error and a trace of where the
+// error occurred.
+//
+// TypeError: 'def' is not a function
+// at xyz (<anonymous>:3:9)
+// at <anonymous>:7:1/
+//
+func (err Error) String() string {
+ str := err.Error() + "\n"
+ for _, frame := range err.trace {
+ str += " at " + frame.location() + "\n"
+ }
+ return str
+}
+
+func (err _error) describe(format string, in ...interface{}) string {
+ return fmt.Sprintf(format, in...)
+}
+
+func (self _error) messageValue() Value {
+ if self.message == "" {
+ return Value{}
+ }
+ return toValue_string(self.message)
+}
+
+func (rt *_runtime) typeErrorResult(throw bool) bool {
+ if throw {
+ panic(rt.panicTypeError())
+ }
+ return false
+}
+
+func newError(rt *_runtime, name string, in ...interface{}) _error {
+ err := _error{
+ name: name,
+ offset: -1,
+ }
+ description := ""
+ length := len(in)
+
+ if rt != nil {
+ scope := rt.scope
+ frame := scope.frame
+ if length > 0 {
+ if at, ok := in[length-1].(_at); ok {
+ in = in[0 : length-1]
+ if scope != nil {
+ frame.offset = int(at)
+ }
+ length -= 1
+ }
+ if length > 0 {
+ description, in = in[0].(string), in[1:]
+ }
+ }
+ limit := 10
+ err.trace = append(err.trace, frame)
+ if scope != nil {
+ for limit > 0 {
+ scope = scope.outer
+ if scope == nil {
+ break
+ }
+ if scope.frame.offset >= 0 {
+ err.trace = append(err.trace, scope.frame)
+ }
+ limit--
+ }
+ }
+ } else {
+ if length > 0 {
+ description, in = in[0].(string), in[1:]
+ }
+ }
+ err.message = err.describe(description, in...)
+ return err
+}
+
+func (rt *_runtime) panicTypeError(argumentList ...interface{}) *_exception {
+ return &_exception{
+ value: newError(rt, "TypeError", argumentList...),
+ }
+}
+
+func (rt *_runtime) panicReferenceError(argumentList ...interface{}) *_exception {
+ return &_exception{
+ value: newError(rt, "ReferenceError", argumentList...),
+ }
+}
+
+func (rt *_runtime) panicURIError(argumentList ...interface{}) *_exception {
+ return &_exception{
+ value: newError(rt, "URIError", argumentList...),
+ }
+}
+
+func (rt *_runtime) panicSyntaxError(argumentList ...interface{}) *_exception {
+ return &_exception{
+ value: newError(rt, "SyntaxError", argumentList...),
+ }
+}
+
+func (rt *_runtime) panicRangeError(argumentList ...interface{}) *_exception {
+ return &_exception{
+ value: newError(rt, "RangeError", argumentList...),
+ }
+}
+
+func catchPanic(function func()) (err error) {
+ defer func() {
+ if caught := recover(); caught != nil {
+ if exception, ok := caught.(*_exception); ok {
+ caught = exception.eject()
+ }
+ switch caught := caught.(type) {
+ case _error:
+ err = &Error{caught}
+ return
+ case Value:
+ if vl := caught._object(); vl != nil {
+ switch vl := vl.value.(type) {
+ case _error:
+ err = &Error{vl}
+ return
+ }
+ }
+ err = errors.New(caught.string())
+ return
+ }
+ panic(caught)
+ }
+ }()
+ function()
+ return nil
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/error_test.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/error_test.go
new file mode 100644
index 000000000..7f1b16af7
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/error_test.go
@@ -0,0 +1,192 @@
+package otto
+
+import (
+ "testing"
+)
+
+func TestError(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ [ Error.prototype.name, Error.prototype.message, Error.prototype.hasOwnProperty("message") ];
+ `, "Error,,true")
+ })
+}
+
+func TestError_instanceof(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`(new TypeError()) instanceof Error`, true)
+ })
+}
+
+func TestPanicValue(t *testing.T) {
+ tt(t, func() {
+ test, vm := test()
+
+ vm.Set("abc", func(call FunctionCall) Value {
+ value, err := call.Otto.Run(`({ def: 3.14159 })`)
+ is(err, nil)
+ panic(value)
+ })
+
+ test(`
+ try {
+ abc();
+ }
+ catch (err) {
+ error = err;
+ }
+ [ error instanceof Error, error.message, error.def ];
+ `, "false,,3.14159")
+ })
+}
+
+func Test_catchPanic(t *testing.T) {
+ tt(t, func() {
+ vm := New()
+
+ _, err := vm.Run(`
+ A syntax error that
+ does not define
+ var;
+ abc;
+ `)
+ is(err, "!=", nil)
+
+ _, err = vm.Call(`abc.def`, nil)
+ is(err, "!=", nil)
+ })
+}
+
+func TestErrorContext(t *testing.T) {
+ tt(t, func() {
+ vm := New()
+
+ _, err := vm.Run(`
+ undefined();
+ `)
+ {
+ err := err.(*Error)
+ is(err.message, "'undefined' is not a function")
+ is(len(err.trace), 1)
+ is(err.trace[0].location(), "<anonymous>:2:13")
+ }
+
+ _, err = vm.Run(`
+ ({}).abc();
+ `)
+ {
+ err := err.(*Error)
+ is(err.message, "'abc' is not a function")
+ is(len(err.trace), 1)
+ is(err.trace[0].location(), "<anonymous>:2:14")
+ }
+
+ _, err = vm.Run(`
+ ("abc").abc();
+ `)
+ {
+ err := err.(*Error)
+ is(err.message, "'abc' is not a function")
+ is(len(err.trace), 1)
+ is(err.trace[0].location(), "<anonymous>:2:14")
+ }
+
+ _, err = vm.Run(`
+ var ghi = "ghi";
+ ghi();
+ `)
+ {
+ err := err.(*Error)
+ is(err.message, "'ghi' is not a function")
+ is(len(err.trace), 1)
+ is(err.trace[0].location(), "<anonymous>:3:13")
+ }
+
+ _, err = vm.Run(`
+ function def() {
+ undefined();
+ }
+ function abc() {
+ def();
+ }
+ abc();
+ `)
+ {
+ err := err.(*Error)
+ is(err.message, "'undefined' is not a function")
+ is(len(err.trace), 3)
+ is(err.trace[0].location(), "def (<anonymous>:3:17)")
+ is(err.trace[1].location(), "abc (<anonymous>:6:17)")
+ is(err.trace[2].location(), "<anonymous>:8:13")
+ }
+
+ _, err = vm.Run(`
+ function abc() {
+ xyz();
+ }
+ abc();
+ `)
+ {
+ err := err.(*Error)
+ is(err.message, "'xyz' is not defined")
+ is(len(err.trace), 2)
+ is(err.trace[0].location(), "abc (<anonymous>:3:17)")
+ is(err.trace[1].location(), "<anonymous>:5:13")
+ }
+
+ _, err = vm.Run(`
+ mno + 1;
+ `)
+ {
+ err := err.(*Error)
+ is(err.message, "'mno' is not defined")
+ is(len(err.trace), 1)
+ is(err.trace[0].location(), "<anonymous>:2:13")
+ }
+
+ _, err = vm.Run(`
+ eval("xyz();");
+ `)
+ {
+ err := err.(*Error)
+ is(err.message, "'xyz' is not defined")
+ is(len(err.trace), 1)
+ is(err.trace[0].location(), "<anonymous>:1:1")
+ }
+
+ _, err = vm.Run(`
+ xyzzy = "Nothing happens."
+ eval("xyzzy();");
+ `)
+ {
+ err := err.(*Error)
+ is(err.message, "'xyzzy' is not a function")
+ is(len(err.trace), 1)
+ is(err.trace[0].location(), "<anonymous>:1:1")
+ }
+
+ _, err = vm.Run(`
+ throw Error("xyzzy");
+ `)
+ {
+ err := err.(*Error)
+ is(err.message, "xyzzy")
+ is(len(err.trace), 1)
+ is(err.trace[0].location(), "<anonymous>:2:19")
+ }
+
+ _, err = vm.Run(`
+ throw new Error("xyzzy");
+ `)
+ {
+ err := err.(*Error)
+ is(err.message, "xyzzy")
+ is(len(err.trace), 1)
+ is(err.trace[0].location(), "<anonymous>:2:23")
+ }
+ })
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/evaluate.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/evaluate.go
new file mode 100644
index 000000000..093054cc3
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/evaluate.go
@@ -0,0 +1,318 @@
+package otto
+
+import (
+ "fmt"
+ "math"
+ "strings"
+
+ "github.com/robertkrimen/otto/token"
+)
+
+func (self *_runtime) evaluateMultiply(left float64, right float64) Value {
+ // TODO 11.5.1
+ return Value{}
+}
+
+func (self *_runtime) evaluateDivide(left float64, right float64) Value {
+ if math.IsNaN(left) || math.IsNaN(right) {
+ return NaNValue()
+ }
+ if math.IsInf(left, 0) && math.IsInf(right, 0) {
+ return NaNValue()
+ }
+ if left == 0 && right == 0 {
+ return NaNValue()
+ }
+ if math.IsInf(left, 0) {
+ if math.Signbit(left) == math.Signbit(right) {
+ return positiveInfinityValue()
+ } else {
+ return negativeInfinityValue()
+ }
+ }
+ if math.IsInf(right, 0) {
+ if math.Signbit(left) == math.Signbit(right) {
+ return positiveZeroValue()
+ } else {
+ return negativeZeroValue()
+ }
+ }
+ if right == 0 {
+ if math.Signbit(left) == math.Signbit(right) {
+ return positiveInfinityValue()
+ } else {
+ return negativeInfinityValue()
+ }
+ }
+ return toValue_float64(left / right)
+}
+
+func (self *_runtime) evaluateModulo(left float64, right float64) Value {
+ // TODO 11.5.3
+ return Value{}
+}
+
+func (self *_runtime) calculateBinaryExpression(operator token.Token, left Value, right Value) Value {
+
+ leftValue := left.resolve()
+
+ switch operator {
+
+ // Additive
+ case token.PLUS:
+ leftValue = toPrimitive(leftValue)
+ rightValue := right.resolve()
+ rightValue = toPrimitive(rightValue)
+
+ if leftValue.IsString() || rightValue.IsString() {
+ return toValue_string(strings.Join([]string{leftValue.string(), rightValue.string()}, ""))
+ } else {
+ return toValue_float64(leftValue.float64() + rightValue.float64())
+ }
+ case token.MINUS:
+ rightValue := right.resolve()
+ return toValue_float64(leftValue.float64() - rightValue.float64())
+
+ // Multiplicative
+ case token.MULTIPLY:
+ rightValue := right.resolve()
+ return toValue_float64(leftValue.float64() * rightValue.float64())
+ case token.SLASH:
+ rightValue := right.resolve()
+ return self.evaluateDivide(leftValue.float64(), rightValue.float64())
+ case token.REMAINDER:
+ rightValue := right.resolve()
+ return toValue_float64(math.Mod(leftValue.float64(), rightValue.float64()))
+
+ // Logical
+ case token.LOGICAL_AND:
+ left := leftValue.bool()
+ if !left {
+ return falseValue
+ }
+ return toValue_bool(right.resolve().bool())
+ case token.LOGICAL_OR:
+ left := leftValue.bool()
+ if left {
+ return trueValue
+ }
+ return toValue_bool(right.resolve().bool())
+
+ // Bitwise
+ case token.AND:
+ rightValue := right.resolve()
+ return toValue_int32(toInt32(leftValue) & toInt32(rightValue))
+ case token.OR:
+ rightValue := right.resolve()
+ return toValue_int32(toInt32(leftValue) | toInt32(rightValue))
+ case token.EXCLUSIVE_OR:
+ rightValue := right.resolve()
+ return toValue_int32(toInt32(leftValue) ^ toInt32(rightValue))
+
+ // Shift
+ // (Masking of 0x1f is to restrict the shift to a maximum of 31 places)
+ case token.SHIFT_LEFT:
+ rightValue := right.resolve()
+ return toValue_int32(toInt32(leftValue) << (toUint32(rightValue) & 0x1f))
+ case token.SHIFT_RIGHT:
+ rightValue := right.resolve()
+ return toValue_int32(toInt32(leftValue) >> (toUint32(rightValue) & 0x1f))
+ case token.UNSIGNED_SHIFT_RIGHT:
+ rightValue := right.resolve()
+ // Shifting an unsigned integer is a logical shift
+ return toValue_uint32(toUint32(leftValue) >> (toUint32(rightValue) & 0x1f))
+
+ case token.INSTANCEOF:
+ rightValue := right.resolve()
+ if !rightValue.IsObject() {
+ panic(self.panicTypeError("Expecting a function in instanceof check, but got: %v", rightValue))
+ }
+ return toValue_bool(rightValue._object().hasInstance(leftValue))
+
+ case token.IN:
+ rightValue := right.resolve()
+ if !rightValue.IsObject() {
+ panic(self.panicTypeError())
+ }
+ return toValue_bool(rightValue._object().hasProperty(leftValue.string()))
+ }
+
+ panic(hereBeDragons(operator))
+}
+
+func valueKindDispatchKey(left _valueKind, right _valueKind) int {
+ return (int(left) << 2) + int(right)
+}
+
+var equalDispatch map[int](func(Value, Value) bool) = makeEqualDispatch()
+
+func makeEqualDispatch() map[int](func(Value, Value) bool) {
+ key := valueKindDispatchKey
+ return map[int](func(Value, Value) bool){
+
+ key(valueNumber, valueObject): func(x Value, y Value) bool { return x.float64() == y.float64() },
+ key(valueString, valueObject): func(x Value, y Value) bool { return x.float64() == y.float64() },
+ key(valueObject, valueNumber): func(x Value, y Value) bool { return x.float64() == y.float64() },
+ key(valueObject, valueString): func(x Value, y Value) bool { return x.float64() == y.float64() },
+ }
+}
+
+type _lessThanResult int
+
+const (
+ lessThanFalse _lessThanResult = iota
+ lessThanTrue
+ lessThanUndefined
+)
+
+func calculateLessThan(left Value, right Value, leftFirst bool) _lessThanResult {
+
+ x := Value{}
+ y := x
+
+ if leftFirst {
+ x = toNumberPrimitive(left)
+ y = toNumberPrimitive(right)
+ } else {
+ y = toNumberPrimitive(right)
+ x = toNumberPrimitive(left)
+ }
+
+ result := false
+ if x.kind != valueString || y.kind != valueString {
+ x, y := x.float64(), y.float64()
+ if math.IsNaN(x) || math.IsNaN(y) {
+ return lessThanUndefined
+ }
+ result = x < y
+ } else {
+ x, y := x.string(), y.string()
+ result = x < y
+ }
+
+ if result {
+ return lessThanTrue
+ }
+
+ return lessThanFalse
+}
+
+// FIXME Probably a map is not the most efficient way to do this
+var lessThanTable [4](map[_lessThanResult]bool) = [4](map[_lessThanResult]bool){
+ // <
+ map[_lessThanResult]bool{
+ lessThanFalse: false,
+ lessThanTrue: true,
+ lessThanUndefined: false,
+ },
+
+ // >
+ map[_lessThanResult]bool{
+ lessThanFalse: false,
+ lessThanTrue: true,
+ lessThanUndefined: false,
+ },
+
+ // <=
+ map[_lessThanResult]bool{
+ lessThanFalse: true,
+ lessThanTrue: false,
+ lessThanUndefined: false,
+ },
+
+ // >=
+ map[_lessThanResult]bool{
+ lessThanFalse: true,
+ lessThanTrue: false,
+ lessThanUndefined: false,
+ },
+}
+
+func (self *_runtime) calculateComparison(comparator token.Token, left Value, right Value) bool {
+
+ // FIXME Use strictEqualityComparison?
+ // TODO This might be redundant now (with regards to evaluateComparison)
+ x := left.resolve()
+ y := right.resolve()
+
+ kindEqualKind := false
+ result := true
+ negate := false
+
+ switch comparator {
+ case token.LESS:
+ result = lessThanTable[0][calculateLessThan(x, y, true)]
+ case token.GREATER:
+ result = lessThanTable[1][calculateLessThan(y, x, false)]
+ case token.LESS_OR_EQUAL:
+ result = lessThanTable[2][calculateLessThan(y, x, false)]
+ case token.GREATER_OR_EQUAL:
+ result = lessThanTable[3][calculateLessThan(x, y, true)]
+ case token.STRICT_NOT_EQUAL:
+ negate = true
+ fallthrough
+ case token.STRICT_EQUAL:
+ if x.kind != y.kind {
+ result = false
+ } else {
+ kindEqualKind = true
+ }
+ case token.NOT_EQUAL:
+ negate = true
+ fallthrough
+ case token.EQUAL:
+ if x.kind == y.kind {
+ kindEqualKind = true
+ } else if x.kind <= valueNull && y.kind <= valueNull {
+ result = true
+ } else if x.kind <= valueNull || y.kind <= valueNull {
+ result = false
+ } else if x.kind <= valueString && y.kind <= valueString {
+ result = x.float64() == y.float64()
+ } else if x.kind == valueBoolean {
+ result = self.calculateComparison(token.EQUAL, toValue_float64(x.float64()), y)
+ } else if y.kind == valueBoolean {
+ result = self.calculateComparison(token.EQUAL, x, toValue_float64(y.float64()))
+ } else if x.kind == valueObject {
+ result = self.calculateComparison(token.EQUAL, toPrimitive(x), y)
+ } else if y.kind == valueObject {
+ result = self.calculateComparison(token.EQUAL, x, toPrimitive(y))
+ } else {
+ panic(hereBeDragons("Unable to test for equality: %v ==? %v", x, y))
+ }
+ default:
+ panic(fmt.Errorf("Unknown comparator %s", comparator.String()))
+ }
+
+ if kindEqualKind {
+ switch x.kind {
+ case valueUndefined, valueNull:
+ result = true
+ case valueNumber:
+ x := x.float64()
+ y := y.float64()
+ if math.IsNaN(x) || math.IsNaN(y) {
+ result = false
+ } else {
+ result = x == y
+ }
+ case valueString:
+ result = x.string() == y.string()
+ case valueBoolean:
+ result = x.bool() == y.bool()
+ case valueObject:
+ result = x._object() == y._object()
+ default:
+ goto ERROR
+ }
+ }
+
+ if negate {
+ result = !result
+ }
+
+ return result
+
+ERROR:
+ panic(hereBeDragons("%v (%v) %s %v (%v)", x, x.kind, comparator, y, y.kind))
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/function_test.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/function_test.go
new file mode 100644
index 000000000..c10bf8592
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/function_test.go
@@ -0,0 +1,280 @@
+package otto
+
+import (
+ "testing"
+)
+
+func TestFunction(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ var abc = Object.getOwnPropertyDescriptor(Function, "prototype");
+ [ [ typeof Function.prototype, typeof Function.prototype.length, Function.prototype.length ],
+ [ abc.writable, abc.enumerable, abc.configurable ] ];
+ `, "function,number,0,false,false,false")
+ })
+}
+
+func Test_argumentList2parameterList(t *testing.T) {
+ tt(t, func() {
+ is(argumentList2parameterList([]Value{toValue("abc, def"), toValue("ghi")}), []string{"abc", "def", "ghi"})
+ })
+}
+
+func TestFunction_new(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`raise:
+ new Function({});
+ `, "SyntaxError: Unexpected identifier")
+
+ test(`
+ var abc = Function("def, ghi", "jkl", "return def+ghi+jkl");
+ [ typeof abc, abc instanceof Function, abc("ab", "ba", 1) ];
+ `, "function,true,abba1")
+
+ test(`raise:
+ var abc = {
+ toString: function() { throw 1; }
+ };
+ var def = {
+ toString: function() { throw 2; }
+ };
+ var ghi = new Function(abc, def);
+ ghi;
+ `, "1")
+
+ // S15.3.2.1_A3_T10
+ test(`raise:
+ var abc = {
+ toString: function() { return "z;x"; }
+ };
+ var def = "return this";
+ var ghi = new Function(abc, def);
+ ghi;
+ `, "SyntaxError: Unexpected token ;")
+
+ test(`raise:
+ var abc;
+ var def = "return true";
+ var ghi = new Function(null, def);
+ ghi;
+ `, "SyntaxError: Unexpected token null")
+ })
+}
+
+func TestFunction_apply(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`Function.prototype.apply.length`, 2)
+ test(`String.prototype.substring.apply("abc", [1, 11])`, "bc")
+ })
+}
+
+func TestFunction_call(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`Function.prototype.call.length`, 1)
+ test(`String.prototype.substring.call("abc", 1, 11)`, "bc")
+ })
+}
+
+func TestFunctionArguments(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ // Should not be able to delete arguments
+ test(`
+ function abc(def, arguments){
+ delete def;
+ return def;
+ }
+ abc(1);
+ `, 1)
+
+ // Again, should not be able to delete arguments
+ test(`
+ function abc(def){
+ delete def;
+ return def;
+ }
+ abc(1);
+ `, 1)
+
+ // Test typeof of a function argument
+ test(`
+ function abc(def, ghi, jkl){
+ return typeof jkl
+ }
+ abc("1st", "2nd", "3rd", "4th", "5th");
+ `, "string")
+
+ test(`
+ function abc(def, ghi, jkl){
+ arguments[0] = 3.14;
+ arguments[1] = 'Nothing happens';
+ arguments[2] = 42;
+ if (3.14 === def && 'Nothing happens' === ghi && 42 === jkl)
+ return true;
+ }
+ abc(-1, 4.2, 314);
+ `, true)
+ })
+}
+
+func TestFunctionDeclarationInFunction(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ // Function declarations happen AFTER parameter/argument declarations
+ // That is, a function declared within a function will shadow/overwrite
+ // declared parameters
+
+ test(`
+ function abc(def){
+ return def;
+ function def(){
+ return 1;
+ }
+ }
+ typeof abc();
+ `, "function")
+ })
+}
+
+func TestArguments_defineOwnProperty(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ var abc;
+ var def = true;
+ var ghi = {};
+ (function (a, b, c) {
+ Object.defineProperty(arguments, "0", {
+ value: 42,
+ writable: false,
+ enumerable: false,
+ configurable: false
+ });
+ Object.defineProperty(arguments, "1", {
+ value: 3.14,
+ configurable: true,
+ enumerable: true
+ });
+ abc = Object.getOwnPropertyDescriptor(arguments, "0");
+ for (var name in arguments) {
+ ghi[name] = (ghi[name] || 0) + 1;
+ if (name === "0") {
+ def = false;
+ }
+ }
+ }(0, 1, 2));
+ [ abc.value, abc.writable, abc.enumerable, abc.configurable, def, ghi["1"] ];
+ `, "42,false,false,false,true,1")
+ })
+}
+
+func TestFunction_bind(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ defer mockUTC()()
+
+ test(`
+ abc = function(){
+ return "abc";
+ };
+ def = abc.bind();
+ [ typeof def.prototype, typeof def.hasOwnProperty, def.hasOwnProperty("caller"), def.hasOwnProperty("arguments"), def() ];
+ `, "object,function,true,true,abc")
+
+ test(`
+ abc = function(){
+ return arguments[1];
+ };
+ def = abc.bind(undefined, "abc");
+ ghi = abc.bind(undefined, "abc", "ghi");
+ [ def(), def("def"), ghi("def") ];
+ `, ",def,ghi")
+
+ test(`
+ var abc = function () {};
+ var ghi;
+ try {
+ Object.defineProperty(Function.prototype, "xyzzy", {
+ value: 1001,
+ writable: true,
+ enumerable: true,
+ configurable: true
+ });
+ var def = abc.bind({});
+ ghi = !def.hasOwnProperty("xyzzy") && ghi.xyzzy === 1001;
+ } finally {
+ delete Function.prototype.xyzzy;
+ }
+ [ ghi ];
+ `, "true")
+
+ test(`
+ var abc = function (def, ghi) {};
+ var jkl = abc.bind({});
+ var mno = abc.bind({}, 1, 2);
+ [ jkl.length, mno.length ];
+ `, "2,0")
+
+ test(`raise:
+ Math.bind();
+ `, "TypeError: 'bind' is not a function")
+
+ test(`
+ function construct(fn, arguments) {
+ var bound = Function.prototype.bind.apply(fn, [null].concat(arguments));
+ return new bound();
+ }
+ var abc = construct(Date, [1957, 4, 27]);
+ Object.prototype.toString.call(abc);
+ `, "[object Date]")
+
+ test(`
+ var fn = function (x, y, z) {
+ var result = {};
+ result.abc = x + y + z;
+ result.def = arguments[0] === "a" && arguments.length === 3;
+ return result;
+ };
+ var newFn = Function.prototype.bind.call(fn, {}, "a", "b", "c");
+ var result = new newFn();
+ [ result.hasOwnProperty("abc"), result.hasOwnProperty("def"), result.abc, result.def ];
+ `, "true,true,abc,true")
+
+ test(`
+ abc = function(){
+ return "abc";
+ };
+ def = abc.bind();
+ def.toString();
+ `, "function () { [native code] }")
+ })
+}
+
+func TestFunction_toString(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`raise:
+ Function.prototype.toString.call(undefined);
+ `, "TypeError")
+
+ test(`
+ abc = function() { return -1 ;
+}
+ 1;
+ abc.toString();
+ `, "function() { return -1 ;\n}")
+ })
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/global.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/global.go
new file mode 100644
index 000000000..4f035314a
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/global.go
@@ -0,0 +1,221 @@
+package otto
+
+import (
+ "strconv"
+ "time"
+)
+
+var (
+ prototypeValueObject = interface{}(nil)
+ prototypeValueFunction = _nativeFunctionObject{
+ call: func(_ FunctionCall) Value {
+ return Value{}
+ },
+ }
+ prototypeValueString = _stringASCII("")
+ // TODO Make this just false?
+ prototypeValueBoolean = Value{
+ kind: valueBoolean,
+ value: false,
+ }
+ prototypeValueNumber = Value{
+ kind: valueNumber,
+ value: 0,
+ }
+ prototypeValueDate = _dateObject{
+ epoch: 0,
+ isNaN: false,
+ time: time.Unix(0, 0).UTC(),
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ }
+ prototypeValueRegExp = _regExpObject{
+ regularExpression: nil,
+ global: false,
+ ignoreCase: false,
+ multiline: false,
+ source: "",
+ flags: "",
+ }
+)
+
+func newContext() *_runtime {
+
+ self := &_runtime{}
+
+ self.globalStash = self.newObjectStash(nil, nil)
+ self.globalObject = self.globalStash.object
+
+ _newContext(self)
+
+ self.eval = self.globalObject.property["eval"].value.(Value).value.(*_object)
+ self.globalObject.prototype = self.global.ObjectPrototype
+
+ return self
+}
+
+func (runtime *_runtime) newBaseObject() *_object {
+ self := newObject(runtime, "")
+ return self
+}
+
+func (runtime *_runtime) newClassObject(class string) *_object {
+ return newObject(runtime, class)
+}
+
+func (runtime *_runtime) newPrimitiveObject(class string, value Value) *_object {
+ self := runtime.newClassObject(class)
+ self.value = value
+ return self
+}
+
+func (self *_object) primitiveValue() Value {
+ switch value := self.value.(type) {
+ case Value:
+ return value
+ case _stringObject:
+ return toValue_string(value.String())
+ }
+ return Value{}
+}
+
+func (self *_object) hasPrimitive() bool {
+ switch self.value.(type) {
+ case Value, _stringObject:
+ return true
+ }
+ return false
+}
+
+func (runtime *_runtime) newObject() *_object {
+ self := runtime.newClassObject("Object")
+ self.prototype = runtime.global.ObjectPrototype
+ return self
+}
+
+func (runtime *_runtime) newArray(length uint32) *_object {
+ self := runtime.newArrayObject(length)
+ self.prototype = runtime.global.ArrayPrototype
+ return self
+}
+
+func (runtime *_runtime) newArrayOf(valueArray []Value) *_object {
+ self := runtime.newArray(uint32(len(valueArray)))
+ for index, value := range valueArray {
+ if value.isEmpty() {
+ continue
+ }
+ self.defineProperty(strconv.FormatInt(int64(index), 10), value, 0111, false)
+ }
+ return self
+}
+
+func (runtime *_runtime) newString(value Value) *_object {
+ self := runtime.newStringObject(value)
+ self.prototype = runtime.global.StringPrototype
+ return self
+}
+
+func (runtime *_runtime) newBoolean(value Value) *_object {
+ self := runtime.newBooleanObject(value)
+ self.prototype = runtime.global.BooleanPrototype
+ return self
+}
+
+func (runtime *_runtime) newNumber(value Value) *_object {
+ self := runtime.newNumberObject(value)
+ self.prototype = runtime.global.NumberPrototype
+ return self
+}
+
+func (runtime *_runtime) newRegExp(patternValue Value, flagsValue Value) *_object {
+
+ pattern := ""
+ flags := ""
+ if object := patternValue._object(); object != nil && object.class == "RegExp" {
+ if flagsValue.IsDefined() {
+ panic(runtime.panicTypeError("Cannot supply flags when constructing one RegExp from another"))
+ }
+ regExp := object.regExpValue()
+ pattern = regExp.source
+ flags = regExp.flags
+ } else {
+ if patternValue.IsDefined() {
+ pattern = patternValue.string()
+ }
+ if flagsValue.IsDefined() {
+ flags = flagsValue.string()
+ }
+ }
+
+ return runtime._newRegExp(pattern, flags)
+}
+
+func (runtime *_runtime) _newRegExp(pattern string, flags string) *_object {
+ self := runtime.newRegExpObject(pattern, flags)
+ self.prototype = runtime.global.RegExpPrototype
+ return self
+}
+
+// TODO Should (probably) be one argument, right? This is redundant
+func (runtime *_runtime) newDate(epoch float64) *_object {
+ self := runtime.newDateObject(epoch)
+ self.prototype = runtime.global.DatePrototype
+ return self
+}
+
+func (runtime *_runtime) newError(name string, message Value) *_object {
+ var self *_object
+ switch name {
+ case "EvalError":
+ return runtime.newEvalError(message)
+ case "TypeError":
+ return runtime.newTypeError(message)
+ case "RangeError":
+ return runtime.newRangeError(message)
+ case "ReferenceError":
+ return runtime.newReferenceError(message)
+ case "SyntaxError":
+ return runtime.newSyntaxError(message)
+ case "URIError":
+ return runtime.newURIError(message)
+ }
+
+ self = runtime.newErrorObject(name, message)
+ self.prototype = runtime.global.ErrorPrototype
+ if name != "" {
+ self.defineProperty("name", toValue_string(name), 0111, false)
+ }
+ return self
+}
+
+func (runtime *_runtime) newNativeFunction(name string, _nativeFunction _nativeFunction) *_object {
+ self := runtime.newNativeFunctionObject(name, _nativeFunction, 0)
+ self.prototype = runtime.global.FunctionPrototype
+ prototype := runtime.newObject()
+ self.defineProperty("prototype", toValue_object(prototype), 0100, false)
+ prototype.defineProperty("constructor", toValue_object(self), 0100, false)
+ return self
+}
+
+func (runtime *_runtime) newNodeFunction(node *_nodeFunctionLiteral, scopeEnvironment _stash) *_object {
+ // TODO Implement 13.2 fully
+ self := runtime.newNodeFunctionObject(node, scopeEnvironment)
+ self.prototype = runtime.global.FunctionPrototype
+ prototype := runtime.newObject()
+ self.defineProperty("prototype", toValue_object(prototype), 0100, false)
+ prototype.defineProperty("constructor", toValue_object(self), 0101, false)
+ return self
+}
+
+// FIXME Only in one place...
+func (runtime *_runtime) newBoundFunction(target *_object, this Value, argumentList []Value) *_object {
+ self := runtime.newBoundFunctionObject(target, this, argumentList)
+ self.prototype = runtime.global.FunctionPrototype
+ prototype := runtime.newObject()
+ self.defineProperty("prototype", toValue_object(prototype), 0100, false)
+ prototype.defineProperty("constructor", toValue_object(self), 0100, false)
+ return self
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/global_test.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/global_test.go
new file mode 100644
index 000000000..9257b58c3
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/global_test.go
@@ -0,0 +1,355 @@
+package otto
+
+import (
+ "fmt"
+ "math"
+ "strings"
+ "testing"
+)
+
+func TestGlobal(t *testing.T) {
+ tt(t, func() {
+ test, vm := test()
+
+ runtime := vm.vm.runtime
+
+ {
+ call := func(object interface{}, src string, argumentList ...interface{}) Value {
+ var tgt *Object
+ switch object := object.(type) {
+ case Value:
+ tgt = object.Object()
+ case *Object:
+ tgt = object
+ case *_object:
+ tgt = toValue_object(object).Object()
+ default:
+ panic("Here be dragons.")
+ }
+ value, err := tgt.Call(src, argumentList...)
+ is(err, nil)
+ return value
+ }
+
+ // FIXME enterGlobalScope
+ if false {
+ value := runtime.scope.lexical.getBinding("Object", false)._object().call(UndefinedValue(), []Value{toValue(runtime.newObject())}, false, nativeFrame)
+ is(value.IsObject(), true)
+ is(value, "[object Object]")
+ is(value._object().prototype == runtime.global.ObjectPrototype, true)
+ is(value._object().prototype == runtime.global.Object.get("prototype")._object(), true)
+ is(value._object().get("toString"), "function toString() { [native code] }")
+ is(call(value.Object(), "hasOwnProperty", "hasOwnProperty"), false)
+
+ is(call(value._object().get("toString")._object().prototype, "toString"), "function () { [native code] }") // TODO Is this right?
+ is(value._object().get("toString")._object().get("toString"), "function toString() { [native code] }")
+ is(value._object().get("toString")._object().get("toString")._object(), "function toString() { [native code] }")
+
+ is(call(value._object(), "propertyIsEnumerable", "isPrototypeOf"), false)
+ value._object().put("xyzzy", toValue_string("Nothing happens."), false)
+ is(call(value, "propertyIsEnumerable", "isPrototypeOf"), false)
+ is(call(value, "propertyIsEnumerable", "xyzzy"), true)
+ is(value._object().get("xyzzy"), "Nothing happens.")
+
+ is(call(runtime.scope.lexical.getBinding("Object", false), "isPrototypeOf", value), false)
+ is(call(runtime.scope.lexical.getBinding("Object", false)._object().get("prototype"), "isPrototypeOf", value), true)
+ is(call(runtime.scope.lexical.getBinding("Function", false), "isPrototypeOf", value), false)
+
+ is(runtime.newObject().prototype == runtime.global.Object.get("prototype")._object(), true)
+
+ abc := runtime.newBoolean(toValue_bool(true))
+ is(toValue_object(abc), "true") // TODO Call primitive?
+
+ //def := runtime.localGet("Boolean")._object().Construct(UndefinedValue(), []Value{})
+ //is(def, "false") // TODO Call primitive?
+ }
+ }
+
+ test(`new Number().constructor == Number`, true)
+
+ test(`this.hasOwnProperty`, "function hasOwnProperty() { [native code] }")
+
+ test(`eval.length === 1`, true)
+ test(`eval.prototype === undefined`, true)
+ test(`raise: new eval()`, "TypeError: function eval() { [native code] } is not a constructor")
+
+ test(`
+ [
+ [ delete undefined, undefined ],
+ [ delete NaN, NaN ],
+ [ delete Infinity, Infinity ],
+ ];
+ `, "false,,false,NaN,false,Infinity")
+
+ test(`
+ Object.getOwnPropertyNames(Function('return this')()).sort();
+ `, "Array,Boolean,Date,Error,EvalError,Function,Infinity,JSON,Math,NaN,Number,Object,RangeError,ReferenceError,RegExp,String,SyntaxError,TypeError,URIError,console,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,escape,eval,isFinite,isNaN,parseFloat,parseInt,undefined,unescape")
+
+ // __defineGetter__,__defineSetter__,__lookupGetter__,__lookupSetter__,constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf
+ test(`
+ Object.getOwnPropertyNames(Object.prototype).sort();
+ `, "constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf")
+
+ // arguments,caller,length,name,prototype
+ test(`
+ Object.getOwnPropertyNames(EvalError).sort();
+ `, "length,prototype")
+
+ test(`
+ var abc = [];
+ var def = [EvalError, RangeError, ReferenceError, SyntaxError, TypeError, URIError];
+ for (constructor in def) {
+ abc.push(def[constructor] === def[constructor].prototype.constructor);
+ }
+ def = [Array, Boolean, Date, Function, Number, Object, RegExp, String, SyntaxError];
+ for (constructor in def) {
+ abc.push(def[constructor] === def[constructor].prototype.constructor);
+ }
+ abc;
+ `, "true,true,true,true,true,true,true,true,true,true,true,true,true,true,true")
+
+ test(`
+ [ Array.prototype.constructor === Array, Array.constructor === Function ];
+ `, "true,true")
+
+ test(`
+ [ Number.prototype.constructor === Number, Number.constructor === Function ];
+ `, "true,true")
+
+ test(`
+ [ Function.prototype.constructor === Function, Function.constructor === Function ];
+ `, "true,true")
+ })
+}
+
+func TestGlobalLength(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ [ Object.length, Function.length, RegExp.length, Math.length ];
+ `, "1,1,2,")
+ })
+}
+
+func TestGlobalError(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ [ TypeError.length, TypeError(), TypeError("Nothing happens.") ];
+ `, "1,TypeError,TypeError: Nothing happens.")
+
+ test(`
+ [ URIError.length, URIError(), URIError("Nothing happens.") ];
+ `, "1,URIError,URIError: Nothing happens.")
+ })
+}
+
+func TestGlobalReadOnly(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`Number.POSITIVE_INFINITY`, math.Inf(1))
+
+ test(`
+ Number.POSITIVE_INFINITY = 1;
+ `, 1)
+
+ test(`Number.POSITIVE_INFINITY`, math.Inf(1))
+
+ test(`
+ Number.POSITIVE_INFINITY = 1;
+ Number.POSITIVE_INFINITY;
+ `, math.Inf(1))
+ })
+}
+
+func Test_isNaN(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`isNaN(0)`, false)
+ test(`isNaN("Xyzzy")`, true)
+ test(`isNaN()`, true)
+ test(`isNaN(NaN)`, true)
+ test(`isNaN(Infinity)`, false)
+
+ test(`isNaN.length === 1`, true)
+ test(`isNaN.prototype === undefined`, true)
+ })
+}
+
+func Test_isFinite(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`isFinite(0)`, true)
+ test(`isFinite("Xyzzy")`, false)
+ test(`isFinite()`, false)
+ test(`isFinite(NaN)`, false)
+ test(`isFinite(Infinity)`, false)
+ test(`isFinite(new Number(451));`, true)
+
+ test(`isFinite.length === 1`, true)
+ test(`isFinite.prototype === undefined`, true)
+ })
+}
+
+func Test_parseInt(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`parseInt("0")`, 0)
+ test(`parseInt("11")`, 11)
+ test(`parseInt(" 11")`, 11)
+ test(`parseInt("11 ")`, 11)
+ test(`parseInt(" 11 ")`, 11)
+ test(`parseInt(" 11\n")`, 11)
+ test(`parseInt(" 11\n", 16)`, 17)
+
+ test(`parseInt("Xyzzy")`, _NaN)
+
+ test(`parseInt(" 0x11\n", 16)`, 17)
+ test(`parseInt("0x0aXyzzy", 16)`, 10)
+ test(`parseInt("0x1", 0)`, 1)
+ test(`parseInt("0x10000000000000000000", 16)`, float64(75557863725914323419136))
+
+ test(`parseInt.length === 2`, true)
+ test(`parseInt.prototype === undefined`, true)
+ })
+}
+
+func Test_parseFloat(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`parseFloat("0")`, 0)
+ test(`parseFloat("11")`, 11)
+ test(`parseFloat(" 11")`, 11)
+ test(`parseFloat("11 ")`, 11)
+ test(`parseFloat(" 11 ")`, 11)
+ test(`parseFloat(" 11\n")`, 11)
+ test(`parseFloat(" 11\n", 16)`, 11)
+ test(`parseFloat("11.1")`, 11.1)
+
+ test(`parseFloat("Xyzzy")`, _NaN)
+
+ test(`parseFloat(" 0x11\n", 16)`, 0)
+ test(`parseFloat("0x0a")`, 0)
+ test(`parseFloat("0x0aXyzzy")`, 0)
+ test(`parseFloat("Infinity")`, _Infinity)
+ test(`parseFloat("infinity")`, _NaN)
+ test(`parseFloat("0x")`, 0)
+ test(`parseFloat("11x")`, 11)
+ test(`parseFloat("Infinity1")`, _Infinity)
+
+ test(`parseFloat.length === 1`, true)
+ test(`parseFloat.prototype === undefined`, true)
+ })
+}
+
+func Test_encodeURI(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`encodeURI("http://example.com/ Nothing happens.")`, "http://example.com/%20Nothing%20happens.")
+ test(`encodeURI("http://example.com/ _^#")`, "http://example.com/%20_%5E#")
+ test(`encodeURI(String.fromCharCode("0xE000"))`, "%EE%80%80")
+ test(`encodeURI(String.fromCharCode("0xFFFD"))`, "%EF%BF%BD")
+ test(`raise: encodeURI(String.fromCharCode("0xDC00"))`, "URIError: URI malformed")
+
+ test(`encodeURI.length === 1`, true)
+ test(`encodeURI.prototype === undefined`, true)
+ })
+}
+
+func Test_encodeURIComponent(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`encodeURIComponent("http://example.com/ Nothing happens.")`, "http%3A%2F%2Fexample.com%2F%20Nothing%20happens.")
+ test(`encodeURIComponent("http://example.com/ _^#")`, "http%3A%2F%2Fexample.com%2F%20_%5E%23")
+ })
+}
+
+func Test_decodeURI(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`decodeURI(encodeURI("http://example.com/ Nothing happens."))`, "http://example.com/ Nothing happens.")
+ test(`decodeURI(encodeURI("http://example.com/ _^#"))`, "http://example.com/ _^#")
+ test(`raise: decodeURI("http://example.com/ _^#%")`, "URIError: URI malformed")
+ test(`raise: decodeURI("%DF%7F")`, "URIError: URI malformed")
+ for _, check := range strings.Fields("+ %3B %2F %3F %3A %40 %26 %3D %2B %24 %2C %23") {
+ test(fmt.Sprintf(`decodeURI("%s")`, check), check)
+ }
+
+ test(`decodeURI.length === 1`, true)
+ test(`decodeURI.prototype === undefined`, true)
+ })
+}
+
+func Test_decodeURIComponent(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`decodeURIComponent(encodeURI("http://example.com/ Nothing happens."))`, "http://example.com/ Nothing happens.")
+ test(`decodeURIComponent(encodeURI("http://example.com/ _^#"))`, "http://example.com/ _^#")
+
+ test(`decodeURIComponent.length === 1`, true)
+ test(`decodeURIComponent.prototype === undefined`, true)
+
+ test(`
+ var global = Function('return this')();
+ var abc = Object.getOwnPropertyDescriptor(global, "decodeURIComponent");
+ [ abc.value === global.decodeURIComponent, abc.writable, abc.enumerable, abc.configurable ];
+ `, "true,true,false,true")
+ })
+}
+
+func TestGlobal_skipEnumeration(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ var found = [];
+ for (var test in this) {
+ if (false ||
+ test === 'NaN' ||
+ test === 'undefined' ||
+ test === 'Infinity' ||
+ false) {
+ found.push(test)
+ }
+ }
+ found.length;
+ `, 0)
+
+ test(`
+ var found = [];
+ for (var test in this) {
+ if (false ||
+ test === 'Object' ||
+ test === 'Function' ||
+ test === 'String' ||
+ test === 'Number' ||
+ test === 'Array' ||
+ test === 'Boolean' ||
+ test === 'Date' ||
+ test === 'RegExp' ||
+ test === 'Error' ||
+ test === 'EvalError' ||
+ test === 'RangeError' ||
+ test === 'ReferenceError' ||
+ test === 'SyntaxError' ||
+ test === 'TypeError' ||
+ test === 'URIError' ||
+ false) {
+ found.push(test)
+ }
+ }
+ found.length;
+ `, 0)
+ })
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/inline b/Godeps/_workspace/src/github.com/robertkrimen/otto/inline
new file mode 100644
index 000000000..c3620b4a2
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/inline
@@ -0,0 +1,1086 @@
+#!/usr/bin/env perl
+
+my $_fmt;
+$_fmt = "gofmt";
+$_fmt = "cat -n" if "cat" eq ($ARGV[0] || "");
+
+use strict;
+use warnings;
+use IO::File;
+
+my $self = __PACKAGE__;
+
+sub functionLabel ($) {
+ return "$_[0]_function";
+}
+
+sub trim ($) {
+ local $_ = shift;
+ s/^\s*//, s/\s*$// for $_;
+ return $_;
+}
+
+open my $fmt, "|-", "$_fmt" or die $!;
+
+$fmt->print(<<_END_);
+package otto
+
+import (
+ "math"
+)
+
+func _newContext(runtime *_runtime) {
+@{[ join "\n", $self->newContext() ]}
+}
+
+func newConsoleObject(runtime *_runtime) *_object {
+@{[ join "\n", $self->newConsoleObject() ]}
+}
+_END_
+
+for (qw/int int8 int16 int32 int64 uint uint8 uint16 uint32 uint64 float32 float64/) {
+ $fmt->print(<<_END_);
+
+func toValue_$_(value $_) Value {
+ return Value{
+ kind: valueNumber,
+ value: value,
+ }
+}
+_END_
+}
+
+$fmt->print(<<_END_);
+
+func toValue_string(value string) Value {
+ return Value{
+ kind: valueString,
+ value: value,
+ }
+}
+
+func toValue_string16(value []uint16) Value {
+ return Value{
+ kind: valueString,
+ value: value,
+ }
+}
+
+func toValue_bool(value bool) Value {
+ return Value{
+ kind: valueBoolean,
+ value: value,
+ }
+}
+
+func toValue_object(value *_object) Value {
+ return Value{
+ kind: valueObject,
+ value: value,
+ }
+}
+_END_
+
+close $fmt;
+
+sub newConsoleObject {
+ my $self = shift;
+
+ return
+ $self->block(sub {
+ my $class = "Console";
+ my @got = $self->functionDeclare(
+ $class,
+ "log", 0,
+ "debug:log", 0,
+ "info:log", 0,
+ "error", 0,
+ "warn:error", 0,
+ "dir", 0,
+ "time", 0,
+ "timeEnd", 0,
+ "trace", 0,
+ "assert", 0,
+ );
+ return
+ "return @{[ $self->newObject(@got) ]}"
+ }),
+ ;
+}
+
+sub newContext {
+ my $self = shift;
+ return
+ # ObjectPrototype
+ $self->block(sub {
+ my $class = "Object";
+ return
+ ".${class}Prototype =",
+ $self->globalPrototype(
+ $class,
+ "_classObject",
+ undef,
+ "prototypeValueObject",
+ ),
+ }),
+
+ # FunctionPrototype
+ $self->block(sub {
+ my $class = "Function";
+ return
+ ".${class}Prototype =",
+ $self->globalPrototype(
+ $class,
+ "_classObject",
+ ".ObjectPrototype",
+ "prototypeValueFunction",
+ ),
+ }),
+
+ # ObjectPrototype
+ $self->block(sub {
+ my $class = "Object";
+ my @got = $self->functionDeclare(
+ $class,
+ "valueOf", 0,
+ "toString", 0,
+ "toLocaleString", 0,
+ "hasOwnProperty", 1,
+ "isPrototypeOf", 1,
+ "propertyIsEnumerable", 1,
+ );
+ my @propertyMap = $self->propertyMap(
+ @got,
+ $self->property("constructor", undef),
+ );
+ my $propertyOrder = $self->propertyOrder(@propertyMap);
+ $propertyOrder =~ s/^propertyOrder: //;
+ return
+ ".${class}Prototype.property =", @propertyMap,
+ ".${class}Prototype.propertyOrder =", $propertyOrder,
+ }),
+
+ # FunctionPrototype
+ $self->block(sub {
+ my $class = "Function";
+ my @got = $self->functionDeclare(
+ $class,
+ "toString", 0,
+ "apply", 2,
+ "call", 1,
+ "bind", 1,
+ );
+ my @propertyMap = $self->propertyMap(
+ @got,
+ $self->property("constructor", undef),
+ $self->property("length", $self->numberValue(0), "0"),
+ );
+ my $propertyOrder = $self->propertyOrder(@propertyMap);
+ $propertyOrder =~ s/^propertyOrder: //;
+ return
+ ".${class}Prototype.property =", @propertyMap,
+ ".${class}Prototype.propertyOrder =", $propertyOrder,
+ }),
+
+ # Object
+ $self->block(sub {
+ my $class = "Object";
+ return
+ ".$class =",
+ $self->globalFunction(
+ $class,
+ 1,
+ $self->functionDeclare(
+ $class,
+ "getPrototypeOf", 1,
+ "getOwnPropertyDescriptor", 2,
+ "defineProperty", 3,
+ "defineProperties", 2,
+ "create", 2,
+ "isExtensible", 1,
+ "preventExtensions", 1,
+ "isSealed", 1,
+ "seal", 1,
+ "isFrozen", 1,
+ "freeze", 1,
+ "keys", 1,
+ "getOwnPropertyNames", 1,
+ ),
+ ),
+ }),
+
+ # Function
+ $self->block(sub {
+ my $class = "Function";
+ return
+ "Function :=",
+ $self->globalFunction(
+ $class,
+ 1,
+ ),
+ ".$class = Function",
+ }),
+
+ # Array
+ $self->block(sub {
+ my $class = "Array";
+ my @got = $self->functionDeclare(
+ $class,
+ "toString", 0,
+ "toLocaleString", 0,
+ "concat", 1,
+ "join", 1,
+ "splice", 2,
+ "shift", 0,
+ "pop", 0,
+ "push", 1,
+ "slice", 2,
+ "unshift", 1,
+ "reverse", 0,
+ "sort", 1,
+ "indexOf", 1,
+ "lastIndexOf", 1,
+ "every", 1,
+ "some", 1,
+ "forEach", 1,
+ "map", 1,
+ "filter", 1,
+ "reduce", 1,
+ "reduceRight", 1,
+ );
+ return
+ ".${class}Prototype =",
+ $self->globalPrototype(
+ $class,
+ "_classArray",
+ ".ObjectPrototype",
+ undef,
+ $self->property("length", $self->numberValue("uint32(0)"), "0100"),
+ @got,
+ ),
+ ".$class =",
+ $self->globalFunction(
+ $class,
+ 1,
+ $self->functionDeclare(
+ $class,
+ "isArray", 1,
+ ),
+ ),
+ }),
+
+ # String
+ $self->block(sub {
+ my $class = "String";
+ my @got = $self->functionDeclare(
+ $class,
+ "toString", 0,
+ "valueOf", 0,
+ "charAt", 1,
+ "charCodeAt", 1,
+ "concat", 1,
+ "indexOf", 1,
+ "lastIndexOf", 1,
+ "match", 1,
+ "replace", 2,
+ "search", 1,
+ "split", 2,
+ "slice", 2,
+ "substring", 2,
+ "toLowerCase", 0,
+ "toUpperCase", 0,
+ "substr", 2,
+ "trim", 0,
+ "trimLeft", 0,
+ "trimRight", 0,
+ "localeCompare", 1,
+ "toLocaleLowerCase", 0,
+ "toLocaleUpperCase", 0,
+ );
+ return
+ ".${class}Prototype =",
+ $self->globalPrototype(
+ $class,
+ "_classString",
+ ".ObjectPrototype",
+ "prototypeValueString",
+ $self->property("length", $self->numberValue("int(0)"), "0"),
+ @got,
+ ),
+ ".$class =",
+ $self->globalFunction(
+ $class,
+ 1,
+ $self->functionDeclare(
+ $class,
+ "fromCharCode", 1,
+ ),
+ ),
+ }),
+
+ # Boolean
+ $self->block(sub {
+ my $class = "Boolean";
+ my @got = $self->functionDeclare(
+ $class,
+ "toString", 0,
+ "valueOf", 0,
+ );
+ return
+ ".${class}Prototype =",
+ $self->globalPrototype(
+ $class,
+ "_classObject",
+ ".ObjectPrototype",
+ "prototypeValueBoolean",
+ @got,
+ ),
+ ".$class =",
+ $self->globalFunction(
+ $class,
+ 1,
+ $self->functionDeclare(
+ $class,
+ ),
+ ),
+ }),
+
+ # Number
+ $self->block(sub {
+ my $class = "Number";
+ my @got = $self->functionDeclare(
+ $class,
+ "toString", 0,
+ "valueOf", 0,
+ "toFixed", 1,
+ "toExponential", 1,
+ "toPrecision", 1,
+ "toLocaleString", 1,
+ );
+ return
+ ".${class}Prototype =",
+ $self->globalPrototype(
+ $class,
+ "_classObject",
+ ".ObjectPrototype",
+ "prototypeValueNumber",
+ @got,
+ ),
+ ".$class =",
+ $self->globalFunction(
+ $class,
+ 1,
+ $self->functionDeclare(
+ $class,
+ ),
+ $self->numberConstantDeclare(
+ "MAX_VALUE", "math.MaxFloat64",
+ "MIN_VALUE", "math.SmallestNonzeroFloat64",
+ "NaN", "math.NaN()",
+ "NEGATIVE_INFINITY", "math.Inf(-1)",
+ "POSITIVE_INFINITY", "math.Inf(+1)",
+ ),
+ ),
+ }),
+
+ # Math
+ $self->block(sub {
+ my $class = "Math";
+ return
+ ".$class =",
+ $self->globalObject(
+ $class,
+ $self->functionDeclare(
+ $class,
+ "abs", 1,
+ "acos", 1,
+ "asin", 1,
+ "atan", 1,
+ "atan2", 1,
+ "ceil", 1,
+ "cos", 1,
+ "exp", 1,
+ "floor", 1,
+ "log", 1,
+ "max", 2,
+ "min", 2,
+ "pow", 2,
+ "random", 0,
+ "round", 1,
+ "sin", 1,
+ "sqrt", 1,
+ "tan", 1,
+ ),
+ $self->numberConstantDeclare(
+ "E", "math.E",
+ "LN10", "math.Ln10",
+ "LN2", "math.Ln2",
+ "LOG2E", "math.Log2E",
+ "LOG10E", "math.Log10E",
+ "PI", "math.Pi",
+ "SQRT1_2", "sqrt1_2",
+ "SQRT2", "math.Sqrt2",
+ )
+ ),
+ }),
+
+ # Date
+ $self->block(sub {
+ my $class = "Date";
+ my @got = $self->functionDeclare(
+ $class,
+ "toString", 0,
+ "toDateString", 0,
+ "toTimeString", 0,
+ "toUTCString", 0,
+ "toISOString", 0,
+ "toJSON", 1,
+ "toGMTString", 0,
+ "toLocaleString", 0,
+ "toLocaleDateString", 0,
+ "toLocaleTimeString", 0,
+ "valueOf", 0,
+ "getTime", 0,
+ "getYear", 0,
+ "getFullYear", 0,
+ "getUTCFullYear", 0,
+ "getMonth", 0,
+ "getUTCMonth", 0,
+ "getDate", 0,
+ "getUTCDate", 0,
+ "getDay", 0,
+ "getUTCDay", 0,
+ "getHours", 0,
+ "getUTCHours", 0,
+ "getMinutes", 0,
+ "getUTCMinutes", 0,
+ "getSeconds", 0,
+ "getUTCSeconds", 0,
+ "getMilliseconds", 0,
+ "getUTCMilliseconds", 0,
+ "getTimezoneOffset", 0,
+ "setTime", 1,
+ "setMilliseconds", 1,
+ "setUTCMilliseconds", 1,
+ "setSeconds", 2,
+ "setUTCSeconds", 2,
+ "setMinutes", 3,
+ "setUTCMinutes", 3,
+ "setHours", 4,
+ "setUTCHours", 4,
+ "setDate", 1,
+ "setUTCDate", 1,
+ "setMonth", 2,
+ "setUTCMonth", 2,
+ "setYear", 1,
+ "setFullYear", 3,
+ "setUTCFullYear", 3,
+ );
+ return
+ ".${class}Prototype =",
+ $self->globalPrototype(
+ $class,
+ "_classObject",
+ ".ObjectPrototype",
+ "prototypeValueDate",
+ @got,
+ ),
+ ".$class =",
+ $self->globalFunction(
+ $class,
+ 7,
+ $self->functionDeclare(
+ $class,
+ "parse", 1,
+ "UTC", 7,
+ "now", 0,
+ ),
+ ),
+ }),
+
+ # RegExp
+ $self->block(sub {
+ my $class = "RegExp";
+ my @got = $self->functionDeclare(
+ $class,
+ "toString", 0,
+ "exec", 1,
+ "test", 1,
+ "compile", 1,
+ );
+ return
+ ".${class}Prototype =",
+ $self->globalPrototype(
+ $class,
+ "_classObject",
+ ".ObjectPrototype",
+ "prototypeValueRegExp",
+ @got,
+ ),
+ ".$class =",
+ $self->globalFunction(
+ $class,
+ 2,
+ $self->functionDeclare(
+ $class,
+ ),
+ ),
+ }),
+
+ # Error
+ $self->block(sub {
+ my $class = "Error";
+ my @got = $self->functionDeclare(
+ $class,
+ "toString", 0,
+ );
+ return
+ ".${class}Prototype =",
+ $self->globalPrototype(
+ $class,
+ "_classObject",
+ ".ObjectPrototype",
+ undef,
+ @got,
+ $self->property("name", $self->stringValue("Error")),
+ $self->property("message", $self->stringValue("")),
+ ),
+ ".$class =",
+ $self->globalFunction(
+ $class,
+ 1,
+ $self->functionDeclare(
+ $class,
+ ),
+ ),
+ }),
+
+ (map {
+ my $class = "${_}Error";
+ $self->block(sub {
+ my @got = $self->functionDeclare(
+ $class,
+ );
+ return
+ ".${class}Prototype =",
+ $self->globalPrototype(
+ $class,
+ "_classObject",
+ ".ErrorPrototype",
+ undef,
+ @got,
+ $self->property("name", $self->stringValue($class)),
+ ),
+ ".$class =",
+ $self->globalFunction(
+ $class,
+ 1,
+ $self->functionDeclare(
+ $class,
+ ),
+ ),
+ });
+ } qw/Eval Type Range Reference Syntax URI/),
+
+ # JSON
+ $self->block(sub {
+ my $class = "JSON";
+ return
+ ".$class =",
+ $self->globalObject(
+ $class,
+ $self->functionDeclare(
+ $class,
+ "parse", 2,
+ "stringify", 3,
+ ),
+ ),
+ }),
+
+ # Global
+ $self->block(sub {
+ my $class = "Global";
+ my @got = $self->functionDeclare(
+ $class,
+ "eval", 1,
+ "parseInt", 2,
+ "parseFloat", 1,
+ "isNaN", 1,
+ "isFinite", 1,
+ "decodeURI", 1,
+ "decodeURIComponent", 1,
+ "encodeURI", 1,
+ "encodeURIComponent", 1,
+ "escape", 1,
+ "unescape", 1,
+ );
+ my @propertyMap = $self->propertyMap(
+ @got,
+ $self->globalDeclare(
+ "Object",
+ "Function",
+ "Array",
+ "String",
+ "Boolean",
+ "Number",
+ "Math",
+ "Date",
+ "RegExp",
+ "Error",
+ "EvalError",
+ "TypeError",
+ "RangeError",
+ "ReferenceError",
+ "SyntaxError",
+ "URIError",
+ "JSON",
+ ),
+ $self->property("undefined", $self->undefinedValue(), "0"),
+ $self->property("NaN", $self->numberValue("math.NaN()"), "0"),
+ $self->property("Infinity", $self->numberValue("math.Inf(+1)"), "0"),
+ );
+ my $propertyOrder = $self->propertyOrder(@propertyMap);
+ $propertyOrder =~ s/^propertyOrder: //;
+ return
+ "runtime.globalObject.property =",
+ @propertyMap,
+ "runtime.globalObject.propertyOrder =",
+ $propertyOrder,
+ ;
+ }),
+ ;
+}
+
+sub propertyMap {
+ my $self = shift;
+ return "map[string]_property{", (join ",\n", @_, ""), "}",
+}
+
+our (@preblock, @postblock);
+sub block {
+ my $self = shift;
+ local @preblock = ();
+ local @postblock = ();
+ my @input = $_[0]->();
+ my @output;
+ while (@input) {
+ local $_ = shift @input;
+ if (m/^\./) {
+ $_ = "runtime.global$_";
+ }
+ if (m/ :?=$/) {
+ $_ .= shift @input;
+ }
+ push @output, $_;
+ }
+ return
+ "{",
+ @preblock,
+ @output,
+ @postblock,
+ "}",
+ ;
+}
+
+sub numberConstantDeclare {
+ my $self = shift;
+ my @got;
+ while (@_) {
+ my $name = shift;
+ my $value = shift;
+ push @got, $self->property($name, $self->numberValue($value), "0"),
+ }
+ return @got;
+}
+
+sub functionDeclare {
+ my $self = shift;
+ my $class = shift;
+ my $builtin = "builtin${class}";
+ my @got;
+ while (@_) {
+ my $name = shift;
+ my $length = shift;
+ $name = $self->newFunction($name, "${builtin}_", $length);
+ push @got, $self->functionProperty($name),
+ }
+ return @got;
+}
+
+sub globalDeclare {
+ my $self = shift;
+ my @got;
+ while (@_) {
+ my $name = shift;
+ push @got, $self->property($name, $self->objectValue("runtime.global.$name"), "0101"),
+ }
+ return @got;
+}
+
+sub propertyOrder {
+ my $self = shift;
+ my $propertyMap = join "", @_;
+
+ my (@keys) = $propertyMap =~ m/("\w+"):/g;
+ my $propertyOrder =
+ join "\n", "propertyOrder: []string{", (join ",\n", @keys, ""), "}";
+ return $propertyOrder;
+}
+
+sub globalObject {
+ my $self = shift;
+ my $name = shift;
+
+ my $propertyMap = "";
+ if (@_) {
+ $propertyMap = join "\n", $self->propertyMap(@_);
+ my $propertyOrder = $self->propertyOrder($propertyMap);
+ $propertyMap = "property: $propertyMap,\n$propertyOrder,";
+ }
+
+ return trim <<_END_;
+&_object{
+ runtime: runtime,
+ class: "$name",
+ objectClass: _classObject,
+ prototype: runtime.global.ObjectPrototype,
+ extensible: true,
+ $propertyMap
+}
+_END_
+}
+
+sub globalFunction {
+ my $self = shift;
+ my $name = shift;
+ my $length = shift;
+
+ my $builtin = "builtin${name}";
+ my $builtinNew = "builtinNew${name}";
+ my $prototype = "runtime.global.${name}Prototype";
+ my $propertyMap = "";
+ unshift @_,
+ $self->property("length", $self->numberValue($length), "0"),
+ $self->property("prototype", $self->objectValue($prototype), "0"),
+ ;
+
+ if (@_) {
+ $propertyMap = join "\n", $self->propertyMap(@_);
+ my $propertyOrder = $self->propertyOrder($propertyMap);
+ $propertyMap = "property: $propertyMap,\n$propertyOrder,";
+ }
+
+ push @postblock, $self->statement(
+ "$prototype.property[\"constructor\"] =",
+ $self->property(undef, $self->objectValue("runtime.global.${name}"), "0101"),
+ );
+
+ return trim <<_END_;
+&_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ value: @{[ $self->nativeFunctionOf($name, $builtin, $builtinNew) ]},
+ $propertyMap
+}
+_END_
+}
+
+sub nativeCallFunction {
+ my $self = shift;
+ my $name = shift;
+ my $func = shift;
+ return trim <<_END_;
+_nativeCallFunction{ "$name", $func }
+_END_
+}
+
+sub globalPrototype {
+ my $self = shift;
+ my $class = shift;
+ my $classObject = shift;
+ my $prototype = shift;
+ my $value = shift;
+
+ if (!defined $prototype) {
+ $prototype = "nil";
+ }
+
+ if (!defined $value) {
+ $value = "nil";
+ }
+
+ if ($prototype =~ m/^\./) {
+ $prototype = "runtime.global$prototype";
+ }
+
+ my $propertyMap = "";
+ if (@_) {
+ $propertyMap = join "\n", $self->propertyMap(@_);
+ my $propertyOrder = $self->propertyOrder($propertyMap);
+ $propertyMap = "property: $propertyMap,\n$propertyOrder,";
+ }
+
+ return trim <<_END_;
+&_object{
+ runtime: runtime,
+ class: "$class",
+ objectClass: $classObject,
+ prototype: $prototype,
+ extensible: true,
+ value: $value,
+ $propertyMap
+}
+_END_
+}
+
+sub newFunction {
+ my $self = shift;
+ my $name = shift;
+ my $func = shift;
+ my $length = shift;
+
+ my @name = ($name, $name);
+ if ($name =~ m/^(\w+):(\w+)$/) {
+ @name = ($1, $2);
+ $name = $name[0];
+ }
+
+ if ($func =~ m/^builtin\w+_$/) {
+ $func = "$func$name[1]";
+ }
+
+ my $propertyOrder = "";
+ my @propertyMap = (
+ $self->property("length", $self->numberValue($length), "0"),
+ );
+
+ if (@propertyMap) {
+ $propertyOrder = $self->propertyOrder(@propertyMap);
+ $propertyOrder = "$propertyOrder,";
+ }
+
+ my $label = functionLabel($name);
+ push @preblock, $self->statement(
+ "$label := @{[ trim <<_END_ ]}",
+&_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: @{[ join "\n", $self->propertyMap(@propertyMap) ]},
+ $propertyOrder
+ value: @{[ $self->nativeFunctionOf($name, $func) ]},
+}
+_END_
+ );
+
+ return $name;
+}
+
+sub newObject {
+ my $self = shift;
+
+ my $propertyMap = join "\n", $self->propertyMap(@_);
+ my $propertyOrder = $self->propertyOrder($propertyMap);
+
+ return trim <<_END_;
+&_object{
+ runtime: runtime,
+ class: "Object",
+ objectClass: _classObject,
+ prototype: runtime.global.ObjectPrototype,
+ extensible: true,
+ property: $propertyMap,
+ $propertyOrder,
+}
+_END_
+}
+
+sub newPrototypeObject {
+ my $self = shift;
+ my $class = shift;
+ my $objectClass = shift;
+ my $value = shift;
+ if (defined $value) {
+ $value = "value: $value,";
+ }
+
+ my $propertyMap = join "\n", $self->propertyMap(@_);
+ my $propertyOrder = $self->propertyOrder($propertyMap);
+
+ return trim <<_END_;
+&_object{
+ runtime: runtime,
+ class: "$class",
+ objectClass: $objectClass,
+ prototype: runtime.global.ObjectPrototype,
+ extensible: true,
+ property: $propertyMap,
+ $propertyOrder,
+ $value
+}
+_END_
+}
+
+sub functionProperty {
+ my $self = shift;
+ my $name = shift;
+
+ return $self->property(
+ $name,
+ $self->objectValue(functionLabel($name))
+ );
+}
+
+sub statement {
+ my $self = shift;
+ return join "\n", @_;
+}
+
+sub functionOf {
+ my $self = shift;
+ my $call = shift;
+ my $construct = shift;
+ if ($construct) {
+ $construct = "construct: $construct,";
+ } else {
+ $construct = "";
+ }
+
+ return trim <<_END_
+_functionObject{
+ call: $call,
+ $construct
+}
+_END_
+}
+
+sub nativeFunctionOf {
+ my $self = shift;
+ my $name = shift;
+ my $call = shift;
+ my $construct = shift;
+ if ($construct) {
+ $construct = "construct: $construct,";
+ } else {
+ $construct = "";
+ }
+
+ return trim <<_END_
+_nativeFunctionObject{
+ name: "$name",
+ call: $call,
+ $construct
+}
+_END_
+}
+
+sub nameProperty {
+ my $self = shift;
+ my $name = shift;
+ my $value = shift;
+
+ return trim <<_END_;
+"$name": _property{
+ mode: 0101,
+ value: $value,
+}
+_END_
+}
+
+sub numberValue {
+ my $self = shift;
+ my $value = shift;
+ return trim <<_END_;
+Value{
+ kind: valueNumber,
+ value: $value,
+}
+_END_
+}
+
+sub property {
+ my $self = shift;
+ my $name = shift;
+ my $value = shift;
+ my $mode = shift;
+ $mode = "0101" unless defined $mode;
+ if (! defined $value) {
+ $value = "Value{}";
+ }
+ if (defined $name) {
+ return trim <<_END_;
+"$name": _property{
+ mode: $mode,
+ value: $value,
+}
+_END_
+ } else {
+ return trim <<_END_;
+_property{
+ mode: $mode,
+ value: $value,
+}
+_END_
+ }
+
+}
+
+sub objectProperty {
+ my $self = shift;
+ my $name = shift;
+ my $value = shift;
+
+ return trim <<_END_;
+"$name": _property{
+ mode: 0101,
+ value: @{[ $self->objectValue($value)]},
+}
+_END_
+}
+
+sub objectValue {
+ my $self = shift;
+ my $value = shift;
+ return trim <<_END_
+Value{
+ kind: valueObject,
+ value: $value,
+}
+_END_
+}
+
+sub stringValue {
+ my $self = shift;
+ my $value = shift;
+ return trim <<_END_
+Value{
+ kind: valueString,
+ value: "$value",
+}
+_END_
+}
+
+sub booleanValue {
+ my $self = shift;
+ my $value = shift;
+ return trim <<_END_
+Value{
+ kind: valueBoolean,
+ value: $value,
+}
+_END_
+}
+
+sub undefinedValue {
+ my $self = shift;
+ return trim <<_END_
+Value{
+ kind: valueUndefined,
+}
+_END_
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/inline.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/inline.go
new file mode 100644
index 000000000..6e5df8393
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/inline.go
@@ -0,0 +1,6649 @@
+package otto
+
+import (
+ "math"
+)
+
+func _newContext(runtime *_runtime) {
+ {
+ runtime.global.ObjectPrototype = &_object{
+ runtime: runtime,
+ class: "Object",
+ objectClass: _classObject,
+ prototype: nil,
+ extensible: true,
+ value: prototypeValueObject,
+ }
+ }
+ {
+ runtime.global.FunctionPrototype = &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.ObjectPrototype,
+ extensible: true,
+ value: prototypeValueFunction,
+ }
+ }
+ {
+ valueOf_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "valueOf",
+ call: builtinObject_valueOf,
+ },
+ }
+ toString_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "toString",
+ call: builtinObject_toString,
+ },
+ }
+ toLocaleString_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "toLocaleString",
+ call: builtinObject_toLocaleString,
+ },
+ }
+ hasOwnProperty_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "hasOwnProperty",
+ call: builtinObject_hasOwnProperty,
+ },
+ }
+ isPrototypeOf_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "isPrototypeOf",
+ call: builtinObject_isPrototypeOf,
+ },
+ }
+ propertyIsEnumerable_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "propertyIsEnumerable",
+ call: builtinObject_propertyIsEnumerable,
+ },
+ }
+ runtime.global.ObjectPrototype.property = map[string]_property{
+ "valueOf": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: valueOf_function,
+ },
+ },
+ "toString": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: toString_function,
+ },
+ },
+ "toLocaleString": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: toLocaleString_function,
+ },
+ },
+ "hasOwnProperty": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: hasOwnProperty_function,
+ },
+ },
+ "isPrototypeOf": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: isPrototypeOf_function,
+ },
+ },
+ "propertyIsEnumerable": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: propertyIsEnumerable_function,
+ },
+ },
+ "constructor": _property{
+ mode: 0101,
+ value: Value{},
+ },
+ }
+ runtime.global.ObjectPrototype.propertyOrder = []string{
+ "valueOf",
+ "toString",
+ "toLocaleString",
+ "hasOwnProperty",
+ "isPrototypeOf",
+ "propertyIsEnumerable",
+ "constructor",
+ }
+ }
+ {
+ toString_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "toString",
+ call: builtinFunction_toString,
+ },
+ }
+ apply_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "apply",
+ call: builtinFunction_apply,
+ },
+ }
+ call_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "call",
+ call: builtinFunction_call,
+ },
+ }
+ bind_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "bind",
+ call: builtinFunction_bind,
+ },
+ }
+ runtime.global.FunctionPrototype.property = map[string]_property{
+ "toString": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: toString_function,
+ },
+ },
+ "apply": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: apply_function,
+ },
+ },
+ "call": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: call_function,
+ },
+ },
+ "bind": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: bind_function,
+ },
+ },
+ "constructor": _property{
+ mode: 0101,
+ value: Value{},
+ },
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ }
+ runtime.global.FunctionPrototype.propertyOrder = []string{
+ "toString",
+ "apply",
+ "call",
+ "bind",
+ "constructor",
+ "length",
+ }
+ }
+ {
+ getPrototypeOf_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "getPrototypeOf",
+ call: builtinObject_getPrototypeOf,
+ },
+ }
+ getOwnPropertyDescriptor_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "getOwnPropertyDescriptor",
+ call: builtinObject_getOwnPropertyDescriptor,
+ },
+ }
+ defineProperty_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 3,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "defineProperty",
+ call: builtinObject_defineProperty,
+ },
+ }
+ defineProperties_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "defineProperties",
+ call: builtinObject_defineProperties,
+ },
+ }
+ create_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "create",
+ call: builtinObject_create,
+ },
+ }
+ isExtensible_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "isExtensible",
+ call: builtinObject_isExtensible,
+ },
+ }
+ preventExtensions_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "preventExtensions",
+ call: builtinObject_preventExtensions,
+ },
+ }
+ isSealed_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "isSealed",
+ call: builtinObject_isSealed,
+ },
+ }
+ seal_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "seal",
+ call: builtinObject_seal,
+ },
+ }
+ isFrozen_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "isFrozen",
+ call: builtinObject_isFrozen,
+ },
+ }
+ freeze_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "freeze",
+ call: builtinObject_freeze,
+ },
+ }
+ keys_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "keys",
+ call: builtinObject_keys,
+ },
+ }
+ getOwnPropertyNames_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "getOwnPropertyNames",
+ call: builtinObject_getOwnPropertyNames,
+ },
+ }
+ runtime.global.Object = &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ value: _nativeFunctionObject{
+ name: "Object",
+ call: builtinObject,
+ construct: builtinNewObject,
+ },
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ "prototype": _property{
+ mode: 0,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.ObjectPrototype,
+ },
+ },
+ "getPrototypeOf": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: getPrototypeOf_function,
+ },
+ },
+ "getOwnPropertyDescriptor": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: getOwnPropertyDescriptor_function,
+ },
+ },
+ "defineProperty": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: defineProperty_function,
+ },
+ },
+ "defineProperties": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: defineProperties_function,
+ },
+ },
+ "create": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: create_function,
+ },
+ },
+ "isExtensible": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: isExtensible_function,
+ },
+ },
+ "preventExtensions": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: preventExtensions_function,
+ },
+ },
+ "isSealed": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: isSealed_function,
+ },
+ },
+ "seal": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: seal_function,
+ },
+ },
+ "isFrozen": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: isFrozen_function,
+ },
+ },
+ "freeze": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: freeze_function,
+ },
+ },
+ "keys": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: keys_function,
+ },
+ },
+ "getOwnPropertyNames": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: getOwnPropertyNames_function,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ "prototype",
+ "getPrototypeOf",
+ "getOwnPropertyDescriptor",
+ "defineProperty",
+ "defineProperties",
+ "create",
+ "isExtensible",
+ "preventExtensions",
+ "isSealed",
+ "seal",
+ "isFrozen",
+ "freeze",
+ "keys",
+ "getOwnPropertyNames",
+ },
+ }
+ runtime.global.ObjectPrototype.property["constructor"] =
+ _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.Object,
+ },
+ }
+ }
+ {
+ Function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ value: _nativeFunctionObject{
+ name: "Function",
+ call: builtinFunction,
+ construct: builtinNewFunction,
+ },
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ "prototype": _property{
+ mode: 0,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.FunctionPrototype,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ "prototype",
+ },
+ }
+ runtime.global.Function = Function
+ runtime.global.FunctionPrototype.property["constructor"] =
+ _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.Function,
+ },
+ }
+ }
+ {
+ toString_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "toString",
+ call: builtinArray_toString,
+ },
+ }
+ toLocaleString_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "toLocaleString",
+ call: builtinArray_toLocaleString,
+ },
+ }
+ concat_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "concat",
+ call: builtinArray_concat,
+ },
+ }
+ join_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "join",
+ call: builtinArray_join,
+ },
+ }
+ splice_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "splice",
+ call: builtinArray_splice,
+ },
+ }
+ shift_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "shift",
+ call: builtinArray_shift,
+ },
+ }
+ pop_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "pop",
+ call: builtinArray_pop,
+ },
+ }
+ push_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "push",
+ call: builtinArray_push,
+ },
+ }
+ slice_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "slice",
+ call: builtinArray_slice,
+ },
+ }
+ unshift_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "unshift",
+ call: builtinArray_unshift,
+ },
+ }
+ reverse_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "reverse",
+ call: builtinArray_reverse,
+ },
+ }
+ sort_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "sort",
+ call: builtinArray_sort,
+ },
+ }
+ indexOf_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "indexOf",
+ call: builtinArray_indexOf,
+ },
+ }
+ lastIndexOf_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "lastIndexOf",
+ call: builtinArray_lastIndexOf,
+ },
+ }
+ every_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "every",
+ call: builtinArray_every,
+ },
+ }
+ some_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "some",
+ call: builtinArray_some,
+ },
+ }
+ forEach_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "forEach",
+ call: builtinArray_forEach,
+ },
+ }
+ map_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "map",
+ call: builtinArray_map,
+ },
+ }
+ filter_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "filter",
+ call: builtinArray_filter,
+ },
+ }
+ reduce_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "reduce",
+ call: builtinArray_reduce,
+ },
+ }
+ reduceRight_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "reduceRight",
+ call: builtinArray_reduceRight,
+ },
+ }
+ isArray_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "isArray",
+ call: builtinArray_isArray,
+ },
+ }
+ runtime.global.ArrayPrototype = &_object{
+ runtime: runtime,
+ class: "Array",
+ objectClass: _classArray,
+ prototype: runtime.global.ObjectPrototype,
+ extensible: true,
+ value: nil,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0100,
+ value: Value{
+ kind: valueNumber,
+ value: uint32(0),
+ },
+ },
+ "toString": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: toString_function,
+ },
+ },
+ "toLocaleString": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: toLocaleString_function,
+ },
+ },
+ "concat": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: concat_function,
+ },
+ },
+ "join": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: join_function,
+ },
+ },
+ "splice": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: splice_function,
+ },
+ },
+ "shift": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: shift_function,
+ },
+ },
+ "pop": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: pop_function,
+ },
+ },
+ "push": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: push_function,
+ },
+ },
+ "slice": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: slice_function,
+ },
+ },
+ "unshift": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: unshift_function,
+ },
+ },
+ "reverse": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: reverse_function,
+ },
+ },
+ "sort": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: sort_function,
+ },
+ },
+ "indexOf": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: indexOf_function,
+ },
+ },
+ "lastIndexOf": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: lastIndexOf_function,
+ },
+ },
+ "every": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: every_function,
+ },
+ },
+ "some": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: some_function,
+ },
+ },
+ "forEach": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: forEach_function,
+ },
+ },
+ "map": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: map_function,
+ },
+ },
+ "filter": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: filter_function,
+ },
+ },
+ "reduce": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: reduce_function,
+ },
+ },
+ "reduceRight": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: reduceRight_function,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ "toString",
+ "toLocaleString",
+ "concat",
+ "join",
+ "splice",
+ "shift",
+ "pop",
+ "push",
+ "slice",
+ "unshift",
+ "reverse",
+ "sort",
+ "indexOf",
+ "lastIndexOf",
+ "every",
+ "some",
+ "forEach",
+ "map",
+ "filter",
+ "reduce",
+ "reduceRight",
+ },
+ }
+ runtime.global.Array = &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ value: _nativeFunctionObject{
+ name: "Array",
+ call: builtinArray,
+ construct: builtinNewArray,
+ },
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ "prototype": _property{
+ mode: 0,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.ArrayPrototype,
+ },
+ },
+ "isArray": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: isArray_function,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ "prototype",
+ "isArray",
+ },
+ }
+ runtime.global.ArrayPrototype.property["constructor"] =
+ _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.Array,
+ },
+ }
+ }
+ {
+ toString_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "toString",
+ call: builtinString_toString,
+ },
+ }
+ valueOf_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "valueOf",
+ call: builtinString_valueOf,
+ },
+ }
+ charAt_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "charAt",
+ call: builtinString_charAt,
+ },
+ }
+ charCodeAt_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "charCodeAt",
+ call: builtinString_charCodeAt,
+ },
+ }
+ concat_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "concat",
+ call: builtinString_concat,
+ },
+ }
+ indexOf_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "indexOf",
+ call: builtinString_indexOf,
+ },
+ }
+ lastIndexOf_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "lastIndexOf",
+ call: builtinString_lastIndexOf,
+ },
+ }
+ match_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "match",
+ call: builtinString_match,
+ },
+ }
+ replace_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "replace",
+ call: builtinString_replace,
+ },
+ }
+ search_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "search",
+ call: builtinString_search,
+ },
+ }
+ split_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "split",
+ call: builtinString_split,
+ },
+ }
+ slice_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "slice",
+ call: builtinString_slice,
+ },
+ }
+ substring_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "substring",
+ call: builtinString_substring,
+ },
+ }
+ toLowerCase_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "toLowerCase",
+ call: builtinString_toLowerCase,
+ },
+ }
+ toUpperCase_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "toUpperCase",
+ call: builtinString_toUpperCase,
+ },
+ }
+ substr_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "substr",
+ call: builtinString_substr,
+ },
+ }
+ trim_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "trim",
+ call: builtinString_trim,
+ },
+ }
+ trimLeft_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "trimLeft",
+ call: builtinString_trimLeft,
+ },
+ }
+ trimRight_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "trimRight",
+ call: builtinString_trimRight,
+ },
+ }
+ localeCompare_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "localeCompare",
+ call: builtinString_localeCompare,
+ },
+ }
+ toLocaleLowerCase_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "toLocaleLowerCase",
+ call: builtinString_toLocaleLowerCase,
+ },
+ }
+ toLocaleUpperCase_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "toLocaleUpperCase",
+ call: builtinString_toLocaleUpperCase,
+ },
+ }
+ fromCharCode_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "fromCharCode",
+ call: builtinString_fromCharCode,
+ },
+ }
+ runtime.global.StringPrototype = &_object{
+ runtime: runtime,
+ class: "String",
+ objectClass: _classString,
+ prototype: runtime.global.ObjectPrototype,
+ extensible: true,
+ value: prototypeValueString,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: int(0),
+ },
+ },
+ "toString": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: toString_function,
+ },
+ },
+ "valueOf": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: valueOf_function,
+ },
+ },
+ "charAt": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: charAt_function,
+ },
+ },
+ "charCodeAt": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: charCodeAt_function,
+ },
+ },
+ "concat": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: concat_function,
+ },
+ },
+ "indexOf": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: indexOf_function,
+ },
+ },
+ "lastIndexOf": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: lastIndexOf_function,
+ },
+ },
+ "match": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: match_function,
+ },
+ },
+ "replace": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: replace_function,
+ },
+ },
+ "search": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: search_function,
+ },
+ },
+ "split": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: split_function,
+ },
+ },
+ "slice": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: slice_function,
+ },
+ },
+ "substring": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: substring_function,
+ },
+ },
+ "toLowerCase": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: toLowerCase_function,
+ },
+ },
+ "toUpperCase": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: toUpperCase_function,
+ },
+ },
+ "substr": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: substr_function,
+ },
+ },
+ "trim": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: trim_function,
+ },
+ },
+ "trimLeft": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: trimLeft_function,
+ },
+ },
+ "trimRight": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: trimRight_function,
+ },
+ },
+ "localeCompare": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: localeCompare_function,
+ },
+ },
+ "toLocaleLowerCase": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: toLocaleLowerCase_function,
+ },
+ },
+ "toLocaleUpperCase": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: toLocaleUpperCase_function,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ "toString",
+ "valueOf",
+ "charAt",
+ "charCodeAt",
+ "concat",
+ "indexOf",
+ "lastIndexOf",
+ "match",
+ "replace",
+ "search",
+ "split",
+ "slice",
+ "substring",
+ "toLowerCase",
+ "toUpperCase",
+ "substr",
+ "trim",
+ "trimLeft",
+ "trimRight",
+ "localeCompare",
+ "toLocaleLowerCase",
+ "toLocaleUpperCase",
+ },
+ }
+ runtime.global.String = &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ value: _nativeFunctionObject{
+ name: "String",
+ call: builtinString,
+ construct: builtinNewString,
+ },
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ "prototype": _property{
+ mode: 0,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.StringPrototype,
+ },
+ },
+ "fromCharCode": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: fromCharCode_function,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ "prototype",
+ "fromCharCode",
+ },
+ }
+ runtime.global.StringPrototype.property["constructor"] =
+ _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.String,
+ },
+ }
+ }
+ {
+ toString_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "toString",
+ call: builtinBoolean_toString,
+ },
+ }
+ valueOf_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "valueOf",
+ call: builtinBoolean_valueOf,
+ },
+ }
+ runtime.global.BooleanPrototype = &_object{
+ runtime: runtime,
+ class: "Boolean",
+ objectClass: _classObject,
+ prototype: runtime.global.ObjectPrototype,
+ extensible: true,
+ value: prototypeValueBoolean,
+ property: map[string]_property{
+ "toString": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: toString_function,
+ },
+ },
+ "valueOf": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: valueOf_function,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "toString",
+ "valueOf",
+ },
+ }
+ runtime.global.Boolean = &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ value: _nativeFunctionObject{
+ name: "Boolean",
+ call: builtinBoolean,
+ construct: builtinNewBoolean,
+ },
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ "prototype": _property{
+ mode: 0,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.BooleanPrototype,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ "prototype",
+ },
+ }
+ runtime.global.BooleanPrototype.property["constructor"] =
+ _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.Boolean,
+ },
+ }
+ }
+ {
+ toString_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "toString",
+ call: builtinNumber_toString,
+ },
+ }
+ valueOf_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "valueOf",
+ call: builtinNumber_valueOf,
+ },
+ }
+ toFixed_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "toFixed",
+ call: builtinNumber_toFixed,
+ },
+ }
+ toExponential_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "toExponential",
+ call: builtinNumber_toExponential,
+ },
+ }
+ toPrecision_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "toPrecision",
+ call: builtinNumber_toPrecision,
+ },
+ }
+ toLocaleString_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "toLocaleString",
+ call: builtinNumber_toLocaleString,
+ },
+ }
+ runtime.global.NumberPrototype = &_object{
+ runtime: runtime,
+ class: "Number",
+ objectClass: _classObject,
+ prototype: runtime.global.ObjectPrototype,
+ extensible: true,
+ value: prototypeValueNumber,
+ property: map[string]_property{
+ "toString": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: toString_function,
+ },
+ },
+ "valueOf": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: valueOf_function,
+ },
+ },
+ "toFixed": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: toFixed_function,
+ },
+ },
+ "toExponential": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: toExponential_function,
+ },
+ },
+ "toPrecision": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: toPrecision_function,
+ },
+ },
+ "toLocaleString": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: toLocaleString_function,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "toString",
+ "valueOf",
+ "toFixed",
+ "toExponential",
+ "toPrecision",
+ "toLocaleString",
+ },
+ }
+ runtime.global.Number = &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ value: _nativeFunctionObject{
+ name: "Number",
+ call: builtinNumber,
+ construct: builtinNewNumber,
+ },
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ "prototype": _property{
+ mode: 0,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.NumberPrototype,
+ },
+ },
+ "MAX_VALUE": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: math.MaxFloat64,
+ },
+ },
+ "MIN_VALUE": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: math.SmallestNonzeroFloat64,
+ },
+ },
+ "NaN": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: math.NaN(),
+ },
+ },
+ "NEGATIVE_INFINITY": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: math.Inf(-1),
+ },
+ },
+ "POSITIVE_INFINITY": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: math.Inf(+1),
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ "prototype",
+ "MAX_VALUE",
+ "MIN_VALUE",
+ "NaN",
+ "NEGATIVE_INFINITY",
+ "POSITIVE_INFINITY",
+ },
+ }
+ runtime.global.NumberPrototype.property["constructor"] =
+ _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.Number,
+ },
+ }
+ }
+ {
+ abs_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "abs",
+ call: builtinMath_abs,
+ },
+ }
+ acos_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "acos",
+ call: builtinMath_acos,
+ },
+ }
+ asin_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "asin",
+ call: builtinMath_asin,
+ },
+ }
+ atan_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "atan",
+ call: builtinMath_atan,
+ },
+ }
+ atan2_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "atan2",
+ call: builtinMath_atan2,
+ },
+ }
+ ceil_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "ceil",
+ call: builtinMath_ceil,
+ },
+ }
+ cos_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "cos",
+ call: builtinMath_cos,
+ },
+ }
+ exp_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "exp",
+ call: builtinMath_exp,
+ },
+ }
+ floor_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "floor",
+ call: builtinMath_floor,
+ },
+ }
+ log_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "log",
+ call: builtinMath_log,
+ },
+ }
+ max_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "max",
+ call: builtinMath_max,
+ },
+ }
+ min_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "min",
+ call: builtinMath_min,
+ },
+ }
+ pow_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "pow",
+ call: builtinMath_pow,
+ },
+ }
+ random_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "random",
+ call: builtinMath_random,
+ },
+ }
+ round_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "round",
+ call: builtinMath_round,
+ },
+ }
+ sin_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "sin",
+ call: builtinMath_sin,
+ },
+ }
+ sqrt_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "sqrt",
+ call: builtinMath_sqrt,
+ },
+ }
+ tan_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "tan",
+ call: builtinMath_tan,
+ },
+ }
+ runtime.global.Math = &_object{
+ runtime: runtime,
+ class: "Math",
+ objectClass: _classObject,
+ prototype: runtime.global.ObjectPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "abs": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: abs_function,
+ },
+ },
+ "acos": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: acos_function,
+ },
+ },
+ "asin": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: asin_function,
+ },
+ },
+ "atan": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: atan_function,
+ },
+ },
+ "atan2": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: atan2_function,
+ },
+ },
+ "ceil": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: ceil_function,
+ },
+ },
+ "cos": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: cos_function,
+ },
+ },
+ "exp": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: exp_function,
+ },
+ },
+ "floor": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: floor_function,
+ },
+ },
+ "log": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: log_function,
+ },
+ },
+ "max": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: max_function,
+ },
+ },
+ "min": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: min_function,
+ },
+ },
+ "pow": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: pow_function,
+ },
+ },
+ "random": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: random_function,
+ },
+ },
+ "round": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: round_function,
+ },
+ },
+ "sin": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: sin_function,
+ },
+ },
+ "sqrt": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: sqrt_function,
+ },
+ },
+ "tan": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: tan_function,
+ },
+ },
+ "E": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: math.E,
+ },
+ },
+ "LN10": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: math.Ln10,
+ },
+ },
+ "LN2": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: math.Ln2,
+ },
+ },
+ "LOG2E": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: math.Log2E,
+ },
+ },
+ "LOG10E": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: math.Log10E,
+ },
+ },
+ "PI": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: math.Pi,
+ },
+ },
+ "SQRT1_2": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: sqrt1_2,
+ },
+ },
+ "SQRT2": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: math.Sqrt2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "abs",
+ "acos",
+ "asin",
+ "atan",
+ "atan2",
+ "ceil",
+ "cos",
+ "exp",
+ "floor",
+ "log",
+ "max",
+ "min",
+ "pow",
+ "random",
+ "round",
+ "sin",
+ "sqrt",
+ "tan",
+ "E",
+ "LN10",
+ "LN2",
+ "LOG2E",
+ "LOG10E",
+ "PI",
+ "SQRT1_2",
+ "SQRT2",
+ },
+ }
+ }
+ {
+ toString_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "toString",
+ call: builtinDate_toString,
+ },
+ }
+ toDateString_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "toDateString",
+ call: builtinDate_toDateString,
+ },
+ }
+ toTimeString_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "toTimeString",
+ call: builtinDate_toTimeString,
+ },
+ }
+ toUTCString_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "toUTCString",
+ call: builtinDate_toUTCString,
+ },
+ }
+ toISOString_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "toISOString",
+ call: builtinDate_toISOString,
+ },
+ }
+ toJSON_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "toJSON",
+ call: builtinDate_toJSON,
+ },
+ }
+ toGMTString_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "toGMTString",
+ call: builtinDate_toGMTString,
+ },
+ }
+ toLocaleString_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "toLocaleString",
+ call: builtinDate_toLocaleString,
+ },
+ }
+ toLocaleDateString_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "toLocaleDateString",
+ call: builtinDate_toLocaleDateString,
+ },
+ }
+ toLocaleTimeString_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "toLocaleTimeString",
+ call: builtinDate_toLocaleTimeString,
+ },
+ }
+ valueOf_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "valueOf",
+ call: builtinDate_valueOf,
+ },
+ }
+ getTime_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "getTime",
+ call: builtinDate_getTime,
+ },
+ }
+ getYear_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "getYear",
+ call: builtinDate_getYear,
+ },
+ }
+ getFullYear_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "getFullYear",
+ call: builtinDate_getFullYear,
+ },
+ }
+ getUTCFullYear_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "getUTCFullYear",
+ call: builtinDate_getUTCFullYear,
+ },
+ }
+ getMonth_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "getMonth",
+ call: builtinDate_getMonth,
+ },
+ }
+ getUTCMonth_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "getUTCMonth",
+ call: builtinDate_getUTCMonth,
+ },
+ }
+ getDate_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "getDate",
+ call: builtinDate_getDate,
+ },
+ }
+ getUTCDate_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "getUTCDate",
+ call: builtinDate_getUTCDate,
+ },
+ }
+ getDay_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "getDay",
+ call: builtinDate_getDay,
+ },
+ }
+ getUTCDay_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "getUTCDay",
+ call: builtinDate_getUTCDay,
+ },
+ }
+ getHours_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "getHours",
+ call: builtinDate_getHours,
+ },
+ }
+ getUTCHours_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "getUTCHours",
+ call: builtinDate_getUTCHours,
+ },
+ }
+ getMinutes_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "getMinutes",
+ call: builtinDate_getMinutes,
+ },
+ }
+ getUTCMinutes_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "getUTCMinutes",
+ call: builtinDate_getUTCMinutes,
+ },
+ }
+ getSeconds_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "getSeconds",
+ call: builtinDate_getSeconds,
+ },
+ }
+ getUTCSeconds_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "getUTCSeconds",
+ call: builtinDate_getUTCSeconds,
+ },
+ }
+ getMilliseconds_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "getMilliseconds",
+ call: builtinDate_getMilliseconds,
+ },
+ }
+ getUTCMilliseconds_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "getUTCMilliseconds",
+ call: builtinDate_getUTCMilliseconds,
+ },
+ }
+ getTimezoneOffset_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "getTimezoneOffset",
+ call: builtinDate_getTimezoneOffset,
+ },
+ }
+ setTime_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "setTime",
+ call: builtinDate_setTime,
+ },
+ }
+ setMilliseconds_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "setMilliseconds",
+ call: builtinDate_setMilliseconds,
+ },
+ }
+ setUTCMilliseconds_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "setUTCMilliseconds",
+ call: builtinDate_setUTCMilliseconds,
+ },
+ }
+ setSeconds_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "setSeconds",
+ call: builtinDate_setSeconds,
+ },
+ }
+ setUTCSeconds_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "setUTCSeconds",
+ call: builtinDate_setUTCSeconds,
+ },
+ }
+ setMinutes_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 3,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "setMinutes",
+ call: builtinDate_setMinutes,
+ },
+ }
+ setUTCMinutes_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 3,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "setUTCMinutes",
+ call: builtinDate_setUTCMinutes,
+ },
+ }
+ setHours_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 4,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "setHours",
+ call: builtinDate_setHours,
+ },
+ }
+ setUTCHours_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 4,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "setUTCHours",
+ call: builtinDate_setUTCHours,
+ },
+ }
+ setDate_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "setDate",
+ call: builtinDate_setDate,
+ },
+ }
+ setUTCDate_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "setUTCDate",
+ call: builtinDate_setUTCDate,
+ },
+ }
+ setMonth_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "setMonth",
+ call: builtinDate_setMonth,
+ },
+ }
+ setUTCMonth_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "setUTCMonth",
+ call: builtinDate_setUTCMonth,
+ },
+ }
+ setYear_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "setYear",
+ call: builtinDate_setYear,
+ },
+ }
+ setFullYear_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 3,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "setFullYear",
+ call: builtinDate_setFullYear,
+ },
+ }
+ setUTCFullYear_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 3,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "setUTCFullYear",
+ call: builtinDate_setUTCFullYear,
+ },
+ }
+ parse_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "parse",
+ call: builtinDate_parse,
+ },
+ }
+ UTC_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 7,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "UTC",
+ call: builtinDate_UTC,
+ },
+ }
+ now_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "now",
+ call: builtinDate_now,
+ },
+ }
+ runtime.global.DatePrototype = &_object{
+ runtime: runtime,
+ class: "Date",
+ objectClass: _classObject,
+ prototype: runtime.global.ObjectPrototype,
+ extensible: true,
+ value: prototypeValueDate,
+ property: map[string]_property{
+ "toString": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: toString_function,
+ },
+ },
+ "toDateString": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: toDateString_function,
+ },
+ },
+ "toTimeString": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: toTimeString_function,
+ },
+ },
+ "toUTCString": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: toUTCString_function,
+ },
+ },
+ "toISOString": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: toISOString_function,
+ },
+ },
+ "toJSON": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: toJSON_function,
+ },
+ },
+ "toGMTString": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: toGMTString_function,
+ },
+ },
+ "toLocaleString": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: toLocaleString_function,
+ },
+ },
+ "toLocaleDateString": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: toLocaleDateString_function,
+ },
+ },
+ "toLocaleTimeString": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: toLocaleTimeString_function,
+ },
+ },
+ "valueOf": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: valueOf_function,
+ },
+ },
+ "getTime": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: getTime_function,
+ },
+ },
+ "getYear": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: getYear_function,
+ },
+ },
+ "getFullYear": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: getFullYear_function,
+ },
+ },
+ "getUTCFullYear": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: getUTCFullYear_function,
+ },
+ },
+ "getMonth": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: getMonth_function,
+ },
+ },
+ "getUTCMonth": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: getUTCMonth_function,
+ },
+ },
+ "getDate": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: getDate_function,
+ },
+ },
+ "getUTCDate": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: getUTCDate_function,
+ },
+ },
+ "getDay": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: getDay_function,
+ },
+ },
+ "getUTCDay": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: getUTCDay_function,
+ },
+ },
+ "getHours": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: getHours_function,
+ },
+ },
+ "getUTCHours": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: getUTCHours_function,
+ },
+ },
+ "getMinutes": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: getMinutes_function,
+ },
+ },
+ "getUTCMinutes": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: getUTCMinutes_function,
+ },
+ },
+ "getSeconds": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: getSeconds_function,
+ },
+ },
+ "getUTCSeconds": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: getUTCSeconds_function,
+ },
+ },
+ "getMilliseconds": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: getMilliseconds_function,
+ },
+ },
+ "getUTCMilliseconds": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: getUTCMilliseconds_function,
+ },
+ },
+ "getTimezoneOffset": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: getTimezoneOffset_function,
+ },
+ },
+ "setTime": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: setTime_function,
+ },
+ },
+ "setMilliseconds": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: setMilliseconds_function,
+ },
+ },
+ "setUTCMilliseconds": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: setUTCMilliseconds_function,
+ },
+ },
+ "setSeconds": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: setSeconds_function,
+ },
+ },
+ "setUTCSeconds": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: setUTCSeconds_function,
+ },
+ },
+ "setMinutes": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: setMinutes_function,
+ },
+ },
+ "setUTCMinutes": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: setUTCMinutes_function,
+ },
+ },
+ "setHours": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: setHours_function,
+ },
+ },
+ "setUTCHours": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: setUTCHours_function,
+ },
+ },
+ "setDate": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: setDate_function,
+ },
+ },
+ "setUTCDate": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: setUTCDate_function,
+ },
+ },
+ "setMonth": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: setMonth_function,
+ },
+ },
+ "setUTCMonth": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: setUTCMonth_function,
+ },
+ },
+ "setYear": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: setYear_function,
+ },
+ },
+ "setFullYear": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: setFullYear_function,
+ },
+ },
+ "setUTCFullYear": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: setUTCFullYear_function,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "toString",
+ "toDateString",
+ "toTimeString",
+ "toUTCString",
+ "toISOString",
+ "toJSON",
+ "toGMTString",
+ "toLocaleString",
+ "toLocaleDateString",
+ "toLocaleTimeString",
+ "valueOf",
+ "getTime",
+ "getYear",
+ "getFullYear",
+ "getUTCFullYear",
+ "getMonth",
+ "getUTCMonth",
+ "getDate",
+ "getUTCDate",
+ "getDay",
+ "getUTCDay",
+ "getHours",
+ "getUTCHours",
+ "getMinutes",
+ "getUTCMinutes",
+ "getSeconds",
+ "getUTCSeconds",
+ "getMilliseconds",
+ "getUTCMilliseconds",
+ "getTimezoneOffset",
+ "setTime",
+ "setMilliseconds",
+ "setUTCMilliseconds",
+ "setSeconds",
+ "setUTCSeconds",
+ "setMinutes",
+ "setUTCMinutes",
+ "setHours",
+ "setUTCHours",
+ "setDate",
+ "setUTCDate",
+ "setMonth",
+ "setUTCMonth",
+ "setYear",
+ "setFullYear",
+ "setUTCFullYear",
+ },
+ }
+ runtime.global.Date = &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ value: _nativeFunctionObject{
+ name: "Date",
+ call: builtinDate,
+ construct: builtinNewDate,
+ },
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 7,
+ },
+ },
+ "prototype": _property{
+ mode: 0,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.DatePrototype,
+ },
+ },
+ "parse": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: parse_function,
+ },
+ },
+ "UTC": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: UTC_function,
+ },
+ },
+ "now": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: now_function,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ "prototype",
+ "parse",
+ "UTC",
+ "now",
+ },
+ }
+ runtime.global.DatePrototype.property["constructor"] =
+ _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.Date,
+ },
+ }
+ }
+ {
+ toString_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "toString",
+ call: builtinRegExp_toString,
+ },
+ }
+ exec_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "exec",
+ call: builtinRegExp_exec,
+ },
+ }
+ test_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "test",
+ call: builtinRegExp_test,
+ },
+ }
+ compile_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "compile",
+ call: builtinRegExp_compile,
+ },
+ }
+ runtime.global.RegExpPrototype = &_object{
+ runtime: runtime,
+ class: "RegExp",
+ objectClass: _classObject,
+ prototype: runtime.global.ObjectPrototype,
+ extensible: true,
+ value: prototypeValueRegExp,
+ property: map[string]_property{
+ "toString": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: toString_function,
+ },
+ },
+ "exec": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: exec_function,
+ },
+ },
+ "test": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: test_function,
+ },
+ },
+ "compile": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: compile_function,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "toString",
+ "exec",
+ "test",
+ "compile",
+ },
+ }
+ runtime.global.RegExp = &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ value: _nativeFunctionObject{
+ name: "RegExp",
+ call: builtinRegExp,
+ construct: builtinNewRegExp,
+ },
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ "prototype": _property{
+ mode: 0,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.RegExpPrototype,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ "prototype",
+ },
+ }
+ runtime.global.RegExpPrototype.property["constructor"] =
+ _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.RegExp,
+ },
+ }
+ }
+ {
+ toString_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "toString",
+ call: builtinError_toString,
+ },
+ }
+ runtime.global.ErrorPrototype = &_object{
+ runtime: runtime,
+ class: "Error",
+ objectClass: _classObject,
+ prototype: runtime.global.ObjectPrototype,
+ extensible: true,
+ value: nil,
+ property: map[string]_property{
+ "toString": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: toString_function,
+ },
+ },
+ "name": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueString,
+ value: "Error",
+ },
+ },
+ "message": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueString,
+ value: "",
+ },
+ },
+ },
+ propertyOrder: []string{
+ "toString",
+ "name",
+ "message",
+ },
+ }
+ runtime.global.Error = &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ value: _nativeFunctionObject{
+ name: "Error",
+ call: builtinError,
+ construct: builtinNewError,
+ },
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ "prototype": _property{
+ mode: 0,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.ErrorPrototype,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ "prototype",
+ },
+ }
+ runtime.global.ErrorPrototype.property["constructor"] =
+ _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.Error,
+ },
+ }
+ }
+ {
+ runtime.global.EvalErrorPrototype = &_object{
+ runtime: runtime,
+ class: "EvalError",
+ objectClass: _classObject,
+ prototype: runtime.global.ErrorPrototype,
+ extensible: true,
+ value: nil,
+ property: map[string]_property{
+ "name": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueString,
+ value: "EvalError",
+ },
+ },
+ },
+ propertyOrder: []string{
+ "name",
+ },
+ }
+ runtime.global.EvalError = &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ value: _nativeFunctionObject{
+ name: "EvalError",
+ call: builtinEvalError,
+ construct: builtinNewEvalError,
+ },
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ "prototype": _property{
+ mode: 0,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.EvalErrorPrototype,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ "prototype",
+ },
+ }
+ runtime.global.EvalErrorPrototype.property["constructor"] =
+ _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.EvalError,
+ },
+ }
+ }
+ {
+ runtime.global.TypeErrorPrototype = &_object{
+ runtime: runtime,
+ class: "TypeError",
+ objectClass: _classObject,
+ prototype: runtime.global.ErrorPrototype,
+ extensible: true,
+ value: nil,
+ property: map[string]_property{
+ "name": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueString,
+ value: "TypeError",
+ },
+ },
+ },
+ propertyOrder: []string{
+ "name",
+ },
+ }
+ runtime.global.TypeError = &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ value: _nativeFunctionObject{
+ name: "TypeError",
+ call: builtinTypeError,
+ construct: builtinNewTypeError,
+ },
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ "prototype": _property{
+ mode: 0,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.TypeErrorPrototype,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ "prototype",
+ },
+ }
+ runtime.global.TypeErrorPrototype.property["constructor"] =
+ _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.TypeError,
+ },
+ }
+ }
+ {
+ runtime.global.RangeErrorPrototype = &_object{
+ runtime: runtime,
+ class: "RangeError",
+ objectClass: _classObject,
+ prototype: runtime.global.ErrorPrototype,
+ extensible: true,
+ value: nil,
+ property: map[string]_property{
+ "name": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueString,
+ value: "RangeError",
+ },
+ },
+ },
+ propertyOrder: []string{
+ "name",
+ },
+ }
+ runtime.global.RangeError = &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ value: _nativeFunctionObject{
+ name: "RangeError",
+ call: builtinRangeError,
+ construct: builtinNewRangeError,
+ },
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ "prototype": _property{
+ mode: 0,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.RangeErrorPrototype,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ "prototype",
+ },
+ }
+ runtime.global.RangeErrorPrototype.property["constructor"] =
+ _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.RangeError,
+ },
+ }
+ }
+ {
+ runtime.global.ReferenceErrorPrototype = &_object{
+ runtime: runtime,
+ class: "ReferenceError",
+ objectClass: _classObject,
+ prototype: runtime.global.ErrorPrototype,
+ extensible: true,
+ value: nil,
+ property: map[string]_property{
+ "name": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueString,
+ value: "ReferenceError",
+ },
+ },
+ },
+ propertyOrder: []string{
+ "name",
+ },
+ }
+ runtime.global.ReferenceError = &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ value: _nativeFunctionObject{
+ name: "ReferenceError",
+ call: builtinReferenceError,
+ construct: builtinNewReferenceError,
+ },
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ "prototype": _property{
+ mode: 0,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.ReferenceErrorPrototype,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ "prototype",
+ },
+ }
+ runtime.global.ReferenceErrorPrototype.property["constructor"] =
+ _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.ReferenceError,
+ },
+ }
+ }
+ {
+ runtime.global.SyntaxErrorPrototype = &_object{
+ runtime: runtime,
+ class: "SyntaxError",
+ objectClass: _classObject,
+ prototype: runtime.global.ErrorPrototype,
+ extensible: true,
+ value: nil,
+ property: map[string]_property{
+ "name": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueString,
+ value: "SyntaxError",
+ },
+ },
+ },
+ propertyOrder: []string{
+ "name",
+ },
+ }
+ runtime.global.SyntaxError = &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ value: _nativeFunctionObject{
+ name: "SyntaxError",
+ call: builtinSyntaxError,
+ construct: builtinNewSyntaxError,
+ },
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ "prototype": _property{
+ mode: 0,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.SyntaxErrorPrototype,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ "prototype",
+ },
+ }
+ runtime.global.SyntaxErrorPrototype.property["constructor"] =
+ _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.SyntaxError,
+ },
+ }
+ }
+ {
+ runtime.global.URIErrorPrototype = &_object{
+ runtime: runtime,
+ class: "URIError",
+ objectClass: _classObject,
+ prototype: runtime.global.ErrorPrototype,
+ extensible: true,
+ value: nil,
+ property: map[string]_property{
+ "name": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueString,
+ value: "URIError",
+ },
+ },
+ },
+ propertyOrder: []string{
+ "name",
+ },
+ }
+ runtime.global.URIError = &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ value: _nativeFunctionObject{
+ name: "URIError",
+ call: builtinURIError,
+ construct: builtinNewURIError,
+ },
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ "prototype": _property{
+ mode: 0,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.URIErrorPrototype,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ "prototype",
+ },
+ }
+ runtime.global.URIErrorPrototype.property["constructor"] =
+ _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.URIError,
+ },
+ }
+ }
+ {
+ parse_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "parse",
+ call: builtinJSON_parse,
+ },
+ }
+ stringify_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 3,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "stringify",
+ call: builtinJSON_stringify,
+ },
+ }
+ runtime.global.JSON = &_object{
+ runtime: runtime,
+ class: "JSON",
+ objectClass: _classObject,
+ prototype: runtime.global.ObjectPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "parse": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: parse_function,
+ },
+ },
+ "stringify": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: stringify_function,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "parse",
+ "stringify",
+ },
+ }
+ }
+ {
+ eval_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "eval",
+ call: builtinGlobal_eval,
+ },
+ }
+ parseInt_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "parseInt",
+ call: builtinGlobal_parseInt,
+ },
+ }
+ parseFloat_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "parseFloat",
+ call: builtinGlobal_parseFloat,
+ },
+ }
+ isNaN_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "isNaN",
+ call: builtinGlobal_isNaN,
+ },
+ }
+ isFinite_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "isFinite",
+ call: builtinGlobal_isFinite,
+ },
+ }
+ decodeURI_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "decodeURI",
+ call: builtinGlobal_decodeURI,
+ },
+ }
+ decodeURIComponent_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "decodeURIComponent",
+ call: builtinGlobal_decodeURIComponent,
+ },
+ }
+ encodeURI_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "encodeURI",
+ call: builtinGlobal_encodeURI,
+ },
+ }
+ encodeURIComponent_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "encodeURIComponent",
+ call: builtinGlobal_encodeURIComponent,
+ },
+ }
+ escape_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "escape",
+ call: builtinGlobal_escape,
+ },
+ }
+ unescape_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "unescape",
+ call: builtinGlobal_unescape,
+ },
+ }
+ runtime.globalObject.property = map[string]_property{
+ "eval": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: eval_function,
+ },
+ },
+ "parseInt": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: parseInt_function,
+ },
+ },
+ "parseFloat": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: parseFloat_function,
+ },
+ },
+ "isNaN": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: isNaN_function,
+ },
+ },
+ "isFinite": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: isFinite_function,
+ },
+ },
+ "decodeURI": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: decodeURI_function,
+ },
+ },
+ "decodeURIComponent": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: decodeURIComponent_function,
+ },
+ },
+ "encodeURI": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: encodeURI_function,
+ },
+ },
+ "encodeURIComponent": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: encodeURIComponent_function,
+ },
+ },
+ "escape": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: escape_function,
+ },
+ },
+ "unescape": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: unescape_function,
+ },
+ },
+ "Object": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.Object,
+ },
+ },
+ "Function": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.Function,
+ },
+ },
+ "Array": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.Array,
+ },
+ },
+ "String": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.String,
+ },
+ },
+ "Boolean": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.Boolean,
+ },
+ },
+ "Number": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.Number,
+ },
+ },
+ "Math": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.Math,
+ },
+ },
+ "Date": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.Date,
+ },
+ },
+ "RegExp": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.RegExp,
+ },
+ },
+ "Error": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.Error,
+ },
+ },
+ "EvalError": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.EvalError,
+ },
+ },
+ "TypeError": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.TypeError,
+ },
+ },
+ "RangeError": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.RangeError,
+ },
+ },
+ "ReferenceError": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.ReferenceError,
+ },
+ },
+ "SyntaxError": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.SyntaxError,
+ },
+ },
+ "URIError": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.URIError,
+ },
+ },
+ "JSON": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.JSON,
+ },
+ },
+ "undefined": _property{
+ mode: 0,
+ value: Value{
+ kind: valueUndefined,
+ },
+ },
+ "NaN": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: math.NaN(),
+ },
+ },
+ "Infinity": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: math.Inf(+1),
+ },
+ },
+ }
+ runtime.globalObject.propertyOrder = []string{
+ "eval",
+ "parseInt",
+ "parseFloat",
+ "isNaN",
+ "isFinite",
+ "decodeURI",
+ "decodeURIComponent",
+ "encodeURI",
+ "encodeURIComponent",
+ "escape",
+ "unescape",
+ "Object",
+ "Function",
+ "Array",
+ "String",
+ "Boolean",
+ "Number",
+ "Math",
+ "Date",
+ "RegExp",
+ "Error",
+ "EvalError",
+ "TypeError",
+ "RangeError",
+ "ReferenceError",
+ "SyntaxError",
+ "URIError",
+ "JSON",
+ "undefined",
+ "NaN",
+ "Infinity",
+ }
+ }
+}
+
+func newConsoleObject(runtime *_runtime) *_object {
+ {
+ log_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "log",
+ call: builtinConsole_log,
+ },
+ }
+ debug_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "debug",
+ call: builtinConsole_log,
+ },
+ }
+ info_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "info",
+ call: builtinConsole_log,
+ },
+ }
+ error_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "error",
+ call: builtinConsole_error,
+ },
+ }
+ warn_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "warn",
+ call: builtinConsole_error,
+ },
+ }
+ dir_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "dir",
+ call: builtinConsole_dir,
+ },
+ }
+ time_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "time",
+ call: builtinConsole_time,
+ },
+ }
+ timeEnd_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "timeEnd",
+ call: builtinConsole_timeEnd,
+ },
+ }
+ trace_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "trace",
+ call: builtinConsole_trace,
+ },
+ }
+ assert_function := &_object{
+ runtime: runtime,
+ class: "Function",
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "length": _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "length",
+ },
+ value: _nativeFunctionObject{
+ name: "assert",
+ call: builtinConsole_assert,
+ },
+ }
+ return &_object{
+ runtime: runtime,
+ class: "Object",
+ objectClass: _classObject,
+ prototype: runtime.global.ObjectPrototype,
+ extensible: true,
+ property: map[string]_property{
+ "log": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: log_function,
+ },
+ },
+ "debug": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: debug_function,
+ },
+ },
+ "info": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: info_function,
+ },
+ },
+ "error": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: error_function,
+ },
+ },
+ "warn": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: warn_function,
+ },
+ },
+ "dir": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: dir_function,
+ },
+ },
+ "time": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: time_function,
+ },
+ },
+ "timeEnd": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: timeEnd_function,
+ },
+ },
+ "trace": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: trace_function,
+ },
+ },
+ "assert": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: assert_function,
+ },
+ },
+ },
+ propertyOrder: []string{
+ "log",
+ "debug",
+ "info",
+ "error",
+ "warn",
+ "dir",
+ "time",
+ "timeEnd",
+ "trace",
+ "assert",
+ },
+ }
+ }
+}
+
+func toValue_int(value int) Value {
+ return Value{
+ kind: valueNumber,
+ value: value,
+ }
+}
+
+func toValue_int8(value int8) Value {
+ return Value{
+ kind: valueNumber,
+ value: value,
+ }
+}
+
+func toValue_int16(value int16) Value {
+ return Value{
+ kind: valueNumber,
+ value: value,
+ }
+}
+
+func toValue_int32(value int32) Value {
+ return Value{
+ kind: valueNumber,
+ value: value,
+ }
+}
+
+func toValue_int64(value int64) Value {
+ return Value{
+ kind: valueNumber,
+ value: value,
+ }
+}
+
+func toValue_uint(value uint) Value {
+ return Value{
+ kind: valueNumber,
+ value: value,
+ }
+}
+
+func toValue_uint8(value uint8) Value {
+ return Value{
+ kind: valueNumber,
+ value: value,
+ }
+}
+
+func toValue_uint16(value uint16) Value {
+ return Value{
+ kind: valueNumber,
+ value: value,
+ }
+}
+
+func toValue_uint32(value uint32) Value {
+ return Value{
+ kind: valueNumber,
+ value: value,
+ }
+}
+
+func toValue_uint64(value uint64) Value {
+ return Value{
+ kind: valueNumber,
+ value: value,
+ }
+}
+
+func toValue_float32(value float32) Value {
+ return Value{
+ kind: valueNumber,
+ value: value,
+ }
+}
+
+func toValue_float64(value float64) Value {
+ return Value{
+ kind: valueNumber,
+ value: value,
+ }
+}
+
+func toValue_string(value string) Value {
+ return Value{
+ kind: valueString,
+ value: value,
+ }
+}
+
+func toValue_string16(value []uint16) Value {
+ return Value{
+ kind: valueString,
+ value: value,
+ }
+}
+
+func toValue_bool(value bool) Value {
+ return Value{
+ kind: valueBoolean,
+ value: value,
+ }
+}
+
+func toValue_object(value *_object) Value {
+ return Value{
+ kind: valueObject,
+ value: value,
+ }
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/json_test.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/json_test.go
new file mode 100644
index 000000000..4dd2ed7bf
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/json_test.go
@@ -0,0 +1,183 @@
+package otto
+
+import (
+ "testing"
+)
+
+func BenchmarkJSON_parse(b *testing.B) {
+ vm := New()
+ for i := 0; i < b.N; i++ {
+ vm.Run(`JSON.parse("1")`)
+ vm.Run(`JSON.parse("[1,2,3]")`)
+ vm.Run(`JSON.parse('{"a":{"x":100,"y":110},"b":[10,20,30],"c":"zazazaza"}')`)
+ vm.Run(`JSON.parse("[1,2,3]", function(k, v) { return undefined })`)
+ }
+}
+
+func TestJSON_parse(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ JSON.parse("1");
+ `, 1)
+
+ test(`
+ JSON.parse("null");
+ `, "null") // TODO Can we make this nil?
+
+ test(`
+ var abc = JSON.parse('"a\uFFFFbc"');
+ [ abc[0], abc[2], abc[3], abc.length ];
+ `, "a,b,c,4")
+
+ test(`
+ JSON.parse("[1, 2, 3]");
+ `, "1,2,3")
+
+ test(`
+ JSON.parse('{ "abc": 1, "def":2 }').abc;
+ `, 1)
+
+ test(`
+ JSON.parse('{ "abc": { "x": 100, "y": 110 }, "def": [ 10, 20 ,30 ], "ghi": "zazazaza" }').def;
+ `, "10,20,30")
+
+ test(`raise:
+ JSON.parse("12\t\r\n 34");
+ `, "SyntaxError: invalid character '3' after top-level value")
+
+ test(`
+ JSON.parse("[1, 2, 3]", function() { return undefined });
+ `, "undefined")
+
+ test(`raise:
+ JSON.parse("");
+ `, "SyntaxError: unexpected end of JSON input")
+
+ test(`raise:
+ JSON.parse("[1, 2, 3");
+ `, "SyntaxError: unexpected end of JSON input")
+
+ test(`raise:
+ JSON.parse("[1, 2, ; abc=10");
+ `, "SyntaxError: invalid character ';' looking for beginning of value")
+
+ test(`raise:
+ JSON.parse("[1, 2, function(){}]");
+ `, "SyntaxError: invalid character 'u' in literal false (expecting 'a')")
+ })
+}
+
+func TestJSON_stringify(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ defer mockUTC()()
+
+ test(`
+ JSON.stringify(function(){});
+ `, "undefined")
+
+ test(`
+ JSON.stringify(new Boolean(false));
+ `, "false")
+
+ test(`
+ JSON.stringify({a1: {b1: [1,2,3,4], b2: {c1: 1, c2: 2}}, a2: 'a2'}, null, -5);
+ `, `{"a1":{"b1":[1,2,3,4],"b2":{"c1":1,"c2":2}},"a2":"a2"}`)
+
+ test(`
+ JSON.stringify(undefined);
+ `, "undefined")
+
+ test(`
+ JSON.stringify(1);
+ `, "1")
+
+ test(`
+ JSON.stringify("abc def");
+ `, "\"abc def\"")
+
+ test(`
+ JSON.stringify(3.14159);
+ `, "3.14159")
+
+ test(`
+ JSON.stringify([]);
+ `, "[]")
+
+ test(`
+ JSON.stringify([1, 2, 3]);
+ `, "[1,2,3]")
+
+ test(`
+ JSON.stringify([true, false, null]);
+ `, "[true,false,null]")
+
+ test(`
+ JSON.stringify({
+ abc: { x: 100, y: 110 },
+ def: [ 10, 20, 30 ],
+ ghi: "zazazaza"
+ });
+ `, `{"abc":{"x":100,"y":110},"def":[10,20,30],"ghi":"zazazaza"}`)
+
+ test(`
+ JSON.stringify([
+ 'e',
+ {pluribus: 'unum'}
+ ], null, '\t');
+ `, "[\n\t\"e\",\n\t{\n\t\t\"pluribus\": \"unum\"\n\t}\n]")
+
+ test(`
+ JSON.stringify(new Date(0));
+ `, `"1970-01-01T00:00:00.000Z"`)
+
+ test(`
+ JSON.stringify([ new Date(0) ], function(key, value){
+ return this[key] instanceof Date ? 'Date(' + this[key] + ')' : value
+ });
+ `, `["Date(Thu, 01 Jan 1970 00:00:00 UTC)"]`)
+
+ test(`
+ JSON.stringify({
+ abc: 1,
+ def: 2,
+ ghi: 3
+ }, ['abc','def']);
+ `, `{"abc":1,"def":2}`)
+
+ test(`raise:
+ var abc = {
+ def: null
+ };
+ abc.def = abc;
+ JSON.stringify(abc)
+ `, "TypeError: Converting circular structure to JSON")
+
+ test(`raise:
+ var abc= [ null ];
+ abc[0] = abc;
+ JSON.stringify(abc);
+ `, "TypeError: Converting circular structure to JSON")
+
+ test(`raise:
+ var abc = {
+ def: {}
+ };
+ abc.def.ghi = abc;
+ JSON.stringify(abc)
+ `, "TypeError: Converting circular structure to JSON")
+
+ test(`
+ var ghi = { "pi": 3.14159 };
+ var abc = {
+ def: {}
+ };
+ abc.ghi = ghi;
+ abc.def.ghi = ghi;
+ JSON.stringify(abc);
+ `, `{"def":{"ghi":{"pi":3.14159}},"ghi":{"pi":3.14159}}`)
+ })
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/math_test.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/math_test.go
new file mode 100644
index 000000000..499998b14
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/math_test.go
@@ -0,0 +1,303 @@
+package otto
+
+import (
+ "math"
+ "testing"
+)
+
+var _NaN = math.NaN()
+var _Infinity = math.Inf(1)
+
+func TestMath_toString(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`Math.toString()`, "[object Math]")
+ })
+}
+
+func TestMath_abs(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`Math.abs(NaN)`, _NaN)
+ test(`Math.abs(2)`, 2)
+ test(`Math.abs(-2)`, 2)
+ test(`Math.abs(-Infinity)`, _Infinity)
+
+ test(`Math.acos(0.5)`, 1.0471975511965976)
+
+ test(`Math.abs('-1')`, 1)
+ test(`Math.abs(-2)`, 2)
+ test(`Math.abs(null)`, 0)
+ test(`Math.abs("string")`, _NaN)
+ test(`Math.abs()`, _NaN)
+ })
+}
+
+func TestMath_acos(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`Math.acos(NaN)`, _NaN)
+ test(`Math.acos(2)`, _NaN)
+ test(`Math.acos(-2)`, _NaN)
+ test(`1/Math.acos(1)`, _Infinity)
+
+ test(`Math.acos(0.5)`, 1.0471975511965976)
+ })
+}
+
+func TestMath_asin(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`Math.asin(NaN)`, _NaN)
+ test(`Math.asin(2)`, _NaN)
+ test(`Math.asin(-2)`, _NaN)
+ test(`1/Math.asin(0)`, _Infinity)
+ test(`1/Math.asin(-0)`, -_Infinity)
+
+ test(`Math.asin(0.5)`, 0.5235987755982989)
+ })
+}
+
+func TestMath_atan(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`Math.atan(NaN)`, _NaN)
+ test(`1/Math.atan(0)`, _Infinity)
+ test(`1/Math.atan(-0)`, -_Infinity)
+ test(`Math.atan(Infinity)`, 1.5707963267948966)
+ test(`Math.atan(-Infinity)`, -1.5707963267948966)
+
+ // freebsd/386 1.03 => 0.4636476090008061
+ // darwin 1.03 => 0.46364760900080604
+ test(`Math.atan(0.5).toPrecision(10)`, "0.463647609")
+ })
+}
+
+func TestMath_atan2(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`Math.atan2()`, _NaN)
+ test(`Math.atan2(NaN)`, _NaN)
+ test(`Math.atan2(0, NaN)`, _NaN)
+
+ test(`Math.atan2(1, 0)`, 1.5707963267948966)
+ test(`Math.atan2(1, -0)`, 1.5707963267948966)
+
+ test(`1/Math.atan2(0, 1)`, _Infinity)
+ test(`1/Math.atan2(0, 0)`, _Infinity)
+ test(`Math.atan2(0, -0)`, 3.141592653589793)
+ test(`Math.atan2(0, -1)`, 3.141592653589793)
+
+ test(`1/Math.atan2(-0, 1)`, -_Infinity)
+ test(`1/Math.atan2(-0, 0)`, -_Infinity)
+ test(`Math.atan2(-0, -0)`, -3.141592653589793)
+ test(`Math.atan2(-0, -1)`, -3.141592653589793)
+
+ test(`Math.atan2(-1, 0)`, -1.5707963267948966)
+ test(`Math.atan2(-1, -0)`, -1.5707963267948966)
+
+ test(`1/Math.atan2(1, Infinity)`, _Infinity)
+ test(`Math.atan2(1, -Infinity)`, 3.141592653589793)
+ test(`1/Math.atan2(-1, Infinity)`, -_Infinity)
+ test(`Math.atan2(-1, -Infinity)`, -3.141592653589793)
+
+ test(`Math.atan2(Infinity, 1)`, 1.5707963267948966)
+ test(`Math.atan2(-Infinity, 1)`, -1.5707963267948966)
+
+ test(`Math.atan2(Infinity, Infinity)`, 0.7853981633974483)
+ test(`Math.atan2(Infinity, -Infinity)`, 2.356194490192345)
+ test(`Math.atan2(-Infinity, Infinity)`, -0.7853981633974483)
+ test(`Math.atan2(-Infinity, -Infinity)`, -2.356194490192345)
+ })
+}
+
+func TestMath_ceil(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`Math.ceil(NaN)`, _NaN)
+ test(`Math.ceil(+0)`, 0)
+ test(`1/Math.ceil(-0)`, -_Infinity)
+ test(`Math.ceil(Infinity)`, _Infinity)
+ test(`Math.ceil(-Infinity)`, -_Infinity)
+ test(`1/Math.ceil(-0.5)`, -_Infinity)
+
+ test(`Math.ceil(-11)`, -11)
+ test(`Math.ceil(-0.5)`, 0)
+ test(`Math.ceil(1.5)`, 2)
+ })
+}
+
+func TestMath_cos(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`Math.cos(NaN)`, _NaN)
+ test(`Math.cos(+0)`, 1)
+ test(`Math.cos(-0)`, 1)
+ test(`Math.cos(Infinity)`, _NaN)
+ test(`Math.cos(-Infinity)`, _NaN)
+
+ test(`Math.cos(0.5)`, 0.8775825618903728)
+ })
+}
+
+func TestMath_exp(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`Math.exp(NaN)`, _NaN)
+ test(`Math.exp(+0)`, 1)
+ test(`Math.exp(-0)`, 1)
+ test(`Math.exp(Infinity)`, _Infinity)
+ test(`Math.exp(-Infinity)`, 0)
+ })
+}
+
+func TestMath_floor(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`Math.floor(NaN)`, _NaN)
+ test(`Math.floor(+0)`, 0)
+ test(`1/Math.floor(-0)`, -_Infinity)
+ test(`Math.floor(Infinity)`, _Infinity)
+ test(`Math.floor(-Infinity)`, -_Infinity)
+
+ test(`Math.floor(-11)`, -11)
+ test(`Math.floor(-0.5)`, -1)
+ test(`Math.floor(1.5)`, 1)
+ })
+}
+
+func TestMath_log(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`Math.log(NaN)`, _NaN)
+ test(`Math.log(-1)`, _NaN)
+ test(`Math.log(+0)`, -_Infinity)
+ test(`Math.log(-0)`, -_Infinity)
+ test(`1/Math.log(1)`, _Infinity)
+ test(`Math.log(Infinity)`, _Infinity)
+
+ test(`Math.log(0.5)`, -0.6931471805599453)
+ })
+}
+
+func TestMath_max(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`Math.max(-11, -1, 0, 1, 2, 3, 11)`, 11)
+ })
+}
+
+func TestMath_min(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`Math.min(-11, -1, 0, 1, 2, 3, 11)`, -11)
+ })
+}
+
+func TestMath_pow(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`Math.pow(0, NaN)`, _NaN)
+ test(`Math.pow(0, 0)`, 1)
+ test(`Math.pow(NaN, 0)`, 1)
+ test(`Math.pow(0, -0)`, 1)
+ test(`Math.pow(NaN, -0)`, 1)
+ test(`Math.pow(NaN, 1)`, _NaN)
+ test(`Math.pow(2, Infinity)`, _Infinity)
+ test(`1/Math.pow(2, -Infinity)`, _Infinity)
+ test(`Math.pow(1, Infinity)`, _NaN)
+ test(`Math.pow(1, -Infinity)`, _NaN)
+ test(`1/Math.pow(0.1, Infinity)`, _Infinity)
+ test(`Math.pow(0.1, -Infinity)`, _Infinity)
+ test(`Math.pow(Infinity, 1)`, _Infinity)
+ test(`1/Math.pow(Infinity, -1)`, _Infinity)
+ test(`Math.pow(-Infinity, 1)`, -_Infinity)
+ test(`Math.pow(-Infinity, 2)`, _Infinity)
+ test(`1/Math.pow(-Infinity, -1)`, -_Infinity)
+ test(`1/Math.pow(-Infinity, -2)`, _Infinity)
+ test(`1/Math.pow(0, 1)`, _Infinity)
+ test(`Math.pow(0, -1)`, _Infinity)
+ test(`1/Math.pow(-0, 1)`, -_Infinity)
+ test(`1/Math.pow(-0, 2)`, _Infinity)
+ test(`Math.pow(-0, -1)`, -_Infinity)
+ test(`Math.pow(-0, -2)`, _Infinity)
+ test(`Math.pow(-1, 0.1)`, _NaN)
+
+ test(`
+ [ Math.pow(-1, +Infinity), Math.pow(1, Infinity) ];
+ `, "NaN,NaN")
+ })
+}
+
+func TestMath_round(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`Math.round(NaN)`, _NaN)
+ test(`1/Math.round(0)`, _Infinity)
+ test(`1/Math.round(-0)`, -_Infinity)
+ test(`Math.round(Infinity)`, _Infinity)
+ test(`Math.round(-Infinity)`, -_Infinity)
+ test(`1/Math.round(0.1)`, _Infinity)
+ test(`1/Math.round(-0.1)`, -_Infinity)
+
+ test(`Math.round(3.5)`, 4)
+ test(`Math.round(-3.5)`, -3)
+ })
+}
+
+func TestMath_sin(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`Math.sin(NaN)`, _NaN)
+ test(`1/Math.sin(+0)`, _Infinity)
+ test(`1/Math.sin(-0)`, -_Infinity)
+ test(`Math.sin(Infinity)`, _NaN)
+ test(`Math.sin(-Infinity)`, _NaN)
+
+ test(`Math.sin(0.5)`, 0.479425538604203)
+ })
+}
+
+func TestMath_sqrt(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`Math.sqrt(NaN)`, _NaN)
+ test(`Math.sqrt(-1)`, _NaN)
+ test(`1/Math.sqrt(+0)`, _Infinity)
+ test(`1/Math.sqrt(-0)`, -_Infinity)
+ test(`Math.sqrt(Infinity)`, _Infinity)
+
+ test(`Math.sqrt(2)`, 1.4142135623730951)
+ })
+}
+
+func TestMath_tan(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`Math.tan(NaN)`, _NaN)
+ test(`1/Math.tan(+0)`, _Infinity)
+ test(`1/Math.tan(-0)`, -_Infinity)
+ test(`Math.tan(Infinity)`, _NaN)
+ test(`Math.tan(-Infinity)`, _NaN)
+
+ test(`Math.tan(0.5)`, 0.5463024898437905)
+ })
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/number_test.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/number_test.go
new file mode 100644
index 000000000..8db01cfc7
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/number_test.go
@@ -0,0 +1,165 @@
+package otto
+
+import (
+ "testing"
+)
+
+func TestNumber(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ var abc = Object.getOwnPropertyDescriptor(Number, "prototype");
+ [ [ typeof Number.prototype ],
+ [ abc.writable, abc.enumerable, abc.configurable ] ];
+ `, "object,false,false,false")
+ })
+}
+
+func TestNumber_toString(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ new Number(451).toString();
+ `, "451")
+
+ test(`
+ new Number(451).toString(10);
+ `, "451")
+
+ test(`
+ new Number(451).toString(8);
+ `, "703")
+
+ test(`raise:
+ new Number(451).toString(1);
+ `, "RangeError: RangeError: toString() radix must be between 2 and 36")
+
+ test(`raise:
+ new Number(451).toString(Infinity);
+ `, "RangeError: RangeError: toString() radix must be between 2 and 36")
+
+ test(`
+ new Number(NaN).toString()
+ `, "NaN")
+
+ test(`
+ new Number(Infinity).toString()
+ `, "Infinity")
+
+ test(`
+ new Number(Infinity).toString(16)
+ `, "Infinity")
+
+ test(`
+ [
+ Number.prototype.toString(undefined),
+ new Number().toString(undefined),
+ new Number(0).toString(undefined),
+ new Number(-1).toString(undefined),
+ new Number(1).toString(undefined),
+ new Number(Number.NaN).toString(undefined),
+ new Number(Number.POSITIVE_INFINITY).toString(undefined),
+ new Number(Number.NEGATIVE_INFINITY).toString(undefined)
+ ]
+ `, "0,0,0,-1,1,NaN,Infinity,-Infinity")
+ })
+}
+
+func TestNumber_toFixed(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`new Number(451).toFixed(2)`, "451.00")
+ test(`12345.6789.toFixed()`, "12346")
+ test(`12345.6789.toFixed(1)`, "12345.7")
+ test(`12345.6789.toFixed(6)`, "12345.678900")
+ test(`(1.23e-20).toFixed(2)`, "0.00")
+ test(`2.34.toFixed(1)`, "2.3") // FIXME Wtf? "2.3"
+ test(`-2.34.toFixed(1)`, -2.3) // FIXME Wtf? -2.3
+ test(`(-2.34).toFixed(1)`, "-2.3")
+
+ test(`raise:
+ new Number("a").toFixed(Number.POSITIVE_INFINITY);
+ `, "RangeError: toFixed() precision must be between 0 and 20")
+
+ test(`
+ [
+ new Number(1e21).toFixed(),
+ new Number(1e21).toFixed(0),
+ new Number(1e21).toFixed(1),
+ new Number(1e21).toFixed(1.1),
+ new Number(1e21).toFixed(0.9),
+ new Number(1e21).toFixed("1"),
+ new Number(1e21).toFixed("1.1"),
+ new Number(1e21).toFixed("0.9"),
+ new Number(1e21).toFixed(Number.NaN),
+ new Number(1e21).toFixed("some string")
+ ];
+ `, "1e+21,1e+21,1e+21,1e+21,1e+21,1e+21,1e+21,1e+21,1e+21,1e+21")
+
+ test(`raise:
+ new Number(1e21).toFixed(Number.POSITIVE_INFINITY);
+ `, "RangeError: toFixed() precision must be between 0 and 20")
+ })
+}
+
+func TestNumber_toExponential(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`new Number(451).toExponential(2)`, "4.51e+02")
+ test(`77.1234.toExponential()`, "7.71234e+01")
+ test(`77.1234.toExponential(4)`, "7.7123e+01")
+ test(`77.1234.toExponential(2)`, "7.71e+01")
+ test(`77 .toExponential()`, "7.7e+01")
+ })
+}
+
+func TestNumber_toPrecision(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`new Number(451).toPrecision()`, "451")
+ test(`new Number(451).toPrecision(1)`, "5e+02")
+ test(`5.123456.toPrecision()`, "5.123456")
+ test(`5.123456.toPrecision(5)`, "5.1235")
+ test(`5.123456.toPrecision(2)`, "5.1")
+ test(`5.123456.toPrecision(1)`, "5")
+ })
+}
+
+func TestNumber_toLocaleString(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ [
+ new Number(451).toLocaleString(),
+ new Number(451).toLocaleString(10),
+ new Number(451).toLocaleString(8)
+ ];
+ `, "451,451,703")
+ })
+}
+
+func TestValue_number(t *testing.T) {
+ tt(t, func() {
+ nm := toValue(0.0).number()
+ is(nm.kind, numberInteger)
+
+ nm = toValue(3.14159).number()
+ is(nm.kind, numberFloat)
+ })
+}
+
+func Test_NaN(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ [ NaN === NaN, NaN == NaN ];
+ `, "false,false")
+ })
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/object.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/object.go
new file mode 100644
index 000000000..849812c91
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/object.go
@@ -0,0 +1,156 @@
+package otto
+
+type _object struct {
+ runtime *_runtime
+
+ class string
+ objectClass *_objectClass
+ value interface{}
+
+ prototype *_object
+ extensible bool
+
+ property map[string]_property
+ propertyOrder []string
+}
+
+func newObject(runtime *_runtime, class string) *_object {
+ self := &_object{
+ runtime: runtime,
+ class: class,
+ objectClass: _classObject,
+ property: make(map[string]_property),
+ extensible: true,
+ }
+ return self
+}
+
+// 8.12
+
+// 8.12.1
+func (self *_object) getOwnProperty(name string) *_property {
+ return self.objectClass.getOwnProperty(self, name)
+}
+
+// 8.12.2
+func (self *_object) getProperty(name string) *_property {
+ return self.objectClass.getProperty(self, name)
+}
+
+// 8.12.3
+func (self *_object) get(name string) Value {
+ return self.objectClass.get(self, name)
+}
+
+// 8.12.4
+func (self *_object) canPut(name string) bool {
+ return self.objectClass.canPut(self, name)
+}
+
+// 8.12.5
+func (self *_object) put(name string, value Value, throw bool) {
+ self.objectClass.put(self, name, value, throw)
+}
+
+// 8.12.6
+func (self *_object) hasProperty(name string) bool {
+ return self.objectClass.hasProperty(self, name)
+}
+
+func (self *_object) hasOwnProperty(name string) bool {
+ return self.objectClass.hasOwnProperty(self, name)
+}
+
+type _defaultValueHint int
+
+const (
+ defaultValueNoHint _defaultValueHint = iota
+ defaultValueHintString
+ defaultValueHintNumber
+)
+
+// 8.12.8
+func (self *_object) DefaultValue(hint _defaultValueHint) Value {
+ if hint == defaultValueNoHint {
+ if self.class == "Date" {
+ // Date exception
+ hint = defaultValueHintString
+ } else {
+ hint = defaultValueHintNumber
+ }
+ }
+ methodSequence := []string{"valueOf", "toString"}
+ if hint == defaultValueHintString {
+ methodSequence = []string{"toString", "valueOf"}
+ }
+ for _, methodName := range methodSequence {
+ method := self.get(methodName)
+ // FIXME This is redundant...
+ if method.isCallable() {
+ result := method._object().call(toValue_object(self), nil, false, nativeFrame)
+ if result.IsPrimitive() {
+ return result
+ }
+ }
+ }
+
+ panic(self.runtime.panicTypeError())
+}
+
+func (self *_object) String() string {
+ return self.DefaultValue(defaultValueHintString).string()
+}
+
+func (self *_object) defineProperty(name string, value Value, mode _propertyMode, throw bool) bool {
+ return self.defineOwnProperty(name, _property{value, mode}, throw)
+}
+
+// 8.12.9
+func (self *_object) defineOwnProperty(name string, descriptor _property, throw bool) bool {
+ return self.objectClass.defineOwnProperty(self, name, descriptor, throw)
+}
+
+func (self *_object) delete(name string, throw bool) bool {
+ return self.objectClass.delete(self, name, throw)
+}
+
+func (self *_object) enumerate(all bool, each func(string) bool) {
+ self.objectClass.enumerate(self, all, each)
+}
+
+func (self *_object) _exists(name string) bool {
+ _, exists := self.property[name]
+ return exists
+}
+
+func (self *_object) _read(name string) (_property, bool) {
+ property, exists := self.property[name]
+ return property, exists
+}
+
+func (self *_object) _write(name string, value interface{}, mode _propertyMode) {
+ if value == nil {
+ value = Value{}
+ }
+ _, exists := self.property[name]
+ self.property[name] = _property{value, mode}
+ if !exists {
+ self.propertyOrder = append(self.propertyOrder, name)
+ }
+}
+
+func (self *_object) _delete(name string) {
+ _, exists := self.property[name]
+ delete(self.property, name)
+ if exists {
+ for index, property := range self.propertyOrder {
+ if name == property {
+ if index == len(self.propertyOrder)-1 {
+ self.propertyOrder = self.propertyOrder[:index]
+ } else {
+ self.propertyOrder = append(self.propertyOrder[:index], self.propertyOrder[index+1:]...)
+ }
+ }
+ }
+ }
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/object_class.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/object_class.go
new file mode 100644
index 000000000..d18b9cede
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/object_class.go
@@ -0,0 +1,493 @@
+package otto
+
+import (
+ "encoding/json"
+)
+
+type _objectClass struct {
+ getOwnProperty func(*_object, string) *_property
+ getProperty func(*_object, string) *_property
+ get func(*_object, string) Value
+ canPut func(*_object, string) bool
+ put func(*_object, string, Value, bool)
+ hasProperty func(*_object, string) bool
+ hasOwnProperty func(*_object, string) bool
+ defineOwnProperty func(*_object, string, _property, bool) bool
+ delete func(*_object, string, bool) bool
+ enumerate func(*_object, bool, func(string) bool)
+ clone func(*_object, *_object, *_clone) *_object
+ marshalJSON func(*_object) json.Marshaler
+}
+
+func objectEnumerate(self *_object, all bool, each func(string) bool) {
+ for _, name := range self.propertyOrder {
+ if all || self.property[name].enumerable() {
+ if !each(name) {
+ return
+ }
+ }
+ }
+}
+
+var (
+ _classObject,
+ _classArray,
+ _classString,
+ _classArguments,
+ _classGoStruct,
+ _classGoMap,
+ _classGoArray,
+ _classGoSlice,
+ _ *_objectClass
+)
+
+func init() {
+ _classObject = &_objectClass{
+ objectGetOwnProperty,
+ objectGetProperty,
+ objectGet,
+ objectCanPut,
+ objectPut,
+ objectHasProperty,
+ objectHasOwnProperty,
+ objectDefineOwnProperty,
+ objectDelete,
+ objectEnumerate,
+ objectClone,
+ nil,
+ }
+
+ _classArray = &_objectClass{
+ objectGetOwnProperty,
+ objectGetProperty,
+ objectGet,
+ objectCanPut,
+ objectPut,
+ objectHasProperty,
+ objectHasOwnProperty,
+ arrayDefineOwnProperty,
+ objectDelete,
+ objectEnumerate,
+ objectClone,
+ nil,
+ }
+
+ _classString = &_objectClass{
+ stringGetOwnProperty,
+ objectGetProperty,
+ objectGet,
+ objectCanPut,
+ objectPut,
+ objectHasProperty,
+ objectHasOwnProperty,
+ objectDefineOwnProperty,
+ objectDelete,
+ stringEnumerate,
+ objectClone,
+ nil,
+ }
+
+ _classArguments = &_objectClass{
+ argumentsGetOwnProperty,
+ objectGetProperty,
+ argumentsGet,
+ objectCanPut,
+ objectPut,
+ objectHasProperty,
+ objectHasOwnProperty,
+ argumentsDefineOwnProperty,
+ argumentsDelete,
+ objectEnumerate,
+ objectClone,
+ nil,
+ }
+
+ _classGoStruct = &_objectClass{
+ goStructGetOwnProperty,
+ objectGetProperty,
+ objectGet,
+ goStructCanPut,
+ goStructPut,
+ objectHasProperty,
+ objectHasOwnProperty,
+ objectDefineOwnProperty,
+ objectDelete,
+ goStructEnumerate,
+ objectClone,
+ goStructMarshalJSON,
+ }
+
+ _classGoMap = &_objectClass{
+ goMapGetOwnProperty,
+ objectGetProperty,
+ objectGet,
+ objectCanPut,
+ objectPut,
+ objectHasProperty,
+ objectHasOwnProperty,
+ goMapDefineOwnProperty,
+ goMapDelete,
+ goMapEnumerate,
+ objectClone,
+ nil,
+ }
+
+ _classGoArray = &_objectClass{
+ goArrayGetOwnProperty,
+ objectGetProperty,
+ objectGet,
+ objectCanPut,
+ objectPut,
+ objectHasProperty,
+ objectHasOwnProperty,
+ goArrayDefineOwnProperty,
+ goArrayDelete,
+ goArrayEnumerate,
+ objectClone,
+ nil,
+ }
+
+ _classGoSlice = &_objectClass{
+ goSliceGetOwnProperty,
+ objectGetProperty,
+ objectGet,
+ objectCanPut,
+ objectPut,
+ objectHasProperty,
+ objectHasOwnProperty,
+ goSliceDefineOwnProperty,
+ goSliceDelete,
+ goSliceEnumerate,
+ objectClone,
+ nil,
+ }
+}
+
+// Allons-y
+
+// 8.12.1
+func objectGetOwnProperty(self *_object, name string) *_property {
+ // Return a _copy_ of the property
+ property, exists := self._read(name)
+ if !exists {
+ return nil
+ }
+ return &property
+}
+
+// 8.12.2
+func objectGetProperty(self *_object, name string) *_property {
+ property := self.getOwnProperty(name)
+ if property != nil {
+ return property
+ }
+ if self.prototype != nil {
+ return self.prototype.getProperty(name)
+ }
+ return nil
+}
+
+// 8.12.3
+func objectGet(self *_object, name string) Value {
+ property := self.getProperty(name)
+ if property != nil {
+ return property.get(self)
+ }
+ return Value{}
+}
+
+// 8.12.4
+func objectCanPut(self *_object, name string) bool {
+ canPut, _, _ := _objectCanPut(self, name)
+ return canPut
+}
+
+func _objectCanPut(self *_object, name string) (canPut bool, property *_property, setter *_object) {
+ property = self.getOwnProperty(name)
+ if property != nil {
+ switch propertyValue := property.value.(type) {
+ case Value:
+ canPut = property.writable()
+ return
+ case _propertyGetSet:
+ setter = propertyValue[1]
+ canPut = setter != nil
+ return
+ default:
+ panic(self.runtime.panicTypeError())
+ }
+ }
+
+ if self.prototype == nil {
+ return self.extensible, nil, nil
+ }
+
+ property = self.prototype.getProperty(name)
+ if property == nil {
+ return self.extensible, nil, nil
+ }
+
+ switch propertyValue := property.value.(type) {
+ case Value:
+ if !self.extensible {
+ return false, nil, nil
+ }
+ return property.writable(), nil, nil
+ case _propertyGetSet:
+ setter = propertyValue[1]
+ canPut = setter != nil
+ return
+ default:
+ panic(self.runtime.panicTypeError())
+ }
+}
+
+// 8.12.5
+func objectPut(self *_object, name string, value Value, throw bool) {
+
+ if true {
+ // Shortcut...
+ //
+ // So, right now, every class is using objectCanPut and every class
+ // is using objectPut.
+ //
+ // If that were to no longer be the case, we would have to have
+ // something to detect that here, so that we do not use an
+ // incompatible canPut routine
+ canPut, property, setter := _objectCanPut(self, name)
+ if !canPut {
+ self.runtime.typeErrorResult(throw)
+ } else if setter != nil {
+ setter.call(toValue(self), []Value{value}, false, nativeFrame)
+ } else if property != nil {
+ property.value = value
+ self.defineOwnProperty(name, *property, throw)
+ } else {
+ self.defineProperty(name, value, 0111, throw)
+ }
+ return
+ }
+
+ // The long way...
+ //
+ // Right now, code should never get here, see above
+ if !self.canPut(name) {
+ self.runtime.typeErrorResult(throw)
+ return
+ }
+
+ property := self.getOwnProperty(name)
+ if property == nil {
+ property = self.getProperty(name)
+ if property != nil {
+ if getSet, isAccessor := property.value.(_propertyGetSet); isAccessor {
+ getSet[1].call(toValue(self), []Value{value}, false, nativeFrame)
+ return
+ }
+ }
+ self.defineProperty(name, value, 0111, throw)
+ } else {
+ switch propertyValue := property.value.(type) {
+ case Value:
+ property.value = value
+ self.defineOwnProperty(name, *property, throw)
+ case _propertyGetSet:
+ if propertyValue[1] != nil {
+ propertyValue[1].call(toValue(self), []Value{value}, false, nativeFrame)
+ return
+ }
+ if throw {
+ panic(self.runtime.panicTypeError())
+ }
+ default:
+ panic(self.runtime.panicTypeError())
+ }
+ }
+}
+
+// 8.12.6
+func objectHasProperty(self *_object, name string) bool {
+ return self.getProperty(name) != nil
+}
+
+func objectHasOwnProperty(self *_object, name string) bool {
+ return self.getOwnProperty(name) != nil
+}
+
+// 8.12.9
+func objectDefineOwnProperty(self *_object, name string, descriptor _property, throw bool) bool {
+ property, exists := self._read(name)
+ {
+ if !exists {
+ if !self.extensible {
+ goto Reject
+ }
+ if newGetSet, isAccessor := descriptor.value.(_propertyGetSet); isAccessor {
+ if newGetSet[0] == &_nilGetSetObject {
+ newGetSet[0] = nil
+ }
+ if newGetSet[1] == &_nilGetSetObject {
+ newGetSet[1] = nil
+ }
+ descriptor.value = newGetSet
+ }
+ self._write(name, descriptor.value, descriptor.mode)
+ return true
+ }
+ if descriptor.isEmpty() {
+ return true
+ }
+
+ // TODO Per 8.12.9.6 - We should shortcut here (returning true) if
+ // the current and new (define) properties are the same
+
+ configurable := property.configurable()
+ if !configurable {
+ if descriptor.configurable() {
+ goto Reject
+ }
+ // Test that, if enumerable is set on the property descriptor, then it should
+ // be the same as the existing property
+ if descriptor.enumerateSet() && descriptor.enumerable() != property.enumerable() {
+ goto Reject
+ }
+ }
+ value, isDataDescriptor := property.value.(Value)
+ getSet, _ := property.value.(_propertyGetSet)
+ if descriptor.isGenericDescriptor() {
+ // GenericDescriptor
+ } else if isDataDescriptor != descriptor.isDataDescriptor() {
+ // DataDescriptor <=> AccessorDescriptor
+ if !configurable {
+ goto Reject
+ }
+ } else if isDataDescriptor && descriptor.isDataDescriptor() {
+ // DataDescriptor <=> DataDescriptor
+ if !configurable {
+ if !property.writable() && descriptor.writable() {
+ goto Reject
+ }
+ if !property.writable() {
+ if descriptor.value != nil && !sameValue(value, descriptor.value.(Value)) {
+ goto Reject
+ }
+ }
+ }
+ } else {
+ // AccessorDescriptor <=> AccessorDescriptor
+ newGetSet, _ := descriptor.value.(_propertyGetSet)
+ presentGet, presentSet := true, true
+ if newGetSet[0] == &_nilGetSetObject {
+ // Present, but nil
+ newGetSet[0] = nil
+ } else if newGetSet[0] == nil {
+ // Missing, not even nil
+ newGetSet[0] = getSet[0]
+ presentGet = false
+ }
+ if newGetSet[1] == &_nilGetSetObject {
+ // Present, but nil
+ newGetSet[1] = nil
+ } else if newGetSet[1] == nil {
+ // Missing, not even nil
+ newGetSet[1] = getSet[1]
+ presentSet = false
+ }
+ if !configurable {
+ if (presentGet && (getSet[0] != newGetSet[0])) || (presentSet && (getSet[1] != newGetSet[1])) {
+ goto Reject
+ }
+ }
+ descriptor.value = newGetSet
+ }
+ {
+ // This section will preserve attributes of
+ // the original property, if necessary
+ value1 := descriptor.value
+ if value1 == nil {
+ value1 = property.value
+ } else if newGetSet, isAccessor := descriptor.value.(_propertyGetSet); isAccessor {
+ if newGetSet[0] == &_nilGetSetObject {
+ newGetSet[0] = nil
+ }
+ if newGetSet[1] == &_nilGetSetObject {
+ newGetSet[1] = nil
+ }
+ value1 = newGetSet
+ }
+ mode1 := descriptor.mode
+ if mode1&0222 != 0 {
+ // TODO Factor this out into somewhere testable
+ // (Maybe put into switch ...)
+ mode0 := property.mode
+ if mode1&0200 != 0 {
+ if descriptor.isDataDescriptor() {
+ mode1 &= ^0200 // Turn off "writable" missing
+ mode1 |= (mode0 & 0100)
+ }
+ }
+ if mode1&020 != 0 {
+ mode1 |= (mode0 & 010)
+ }
+ if mode1&02 != 0 {
+ mode1 |= (mode0 & 01)
+ }
+ mode1 &= 0311 // 0311 to preserve the non-setting on "writable"
+ }
+ self._write(name, value1, mode1)
+ }
+ return true
+ }
+Reject:
+ if throw {
+ panic(self.runtime.panicTypeError())
+ }
+ return false
+}
+
+func objectDelete(self *_object, name string, throw bool) bool {
+ property_ := self.getOwnProperty(name)
+ if property_ == nil {
+ return true
+ }
+ if property_.configurable() {
+ self._delete(name)
+ return true
+ }
+ return self.runtime.typeErrorResult(throw)
+}
+
+func objectClone(in *_object, out *_object, clone *_clone) *_object {
+ *out = *in
+
+ out.runtime = clone.runtime
+ if out.prototype != nil {
+ out.prototype = clone.object(in.prototype)
+ }
+ out.property = make(map[string]_property, len(in.property))
+ out.propertyOrder = make([]string, len(in.propertyOrder))
+ copy(out.propertyOrder, in.propertyOrder)
+ for index, property := range in.property {
+ out.property[index] = clone.property(property)
+ }
+
+ switch value := in.value.(type) {
+ case _nativeFunctionObject:
+ out.value = value
+ case _bindFunctionObject:
+ out.value = _bindFunctionObject{
+ target: clone.object(value.target),
+ this: clone.value(value.this),
+ argumentList: clone.valueArray(value.argumentList),
+ }
+ case _nodeFunctionObject:
+ out.value = _nodeFunctionObject{
+ node: value.node,
+ stash: clone.stash(value.stash),
+ }
+ case _argumentsObject:
+ out.value = value.clone(clone)
+ }
+
+ return out
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/object_test.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/object_test.go
new file mode 100644
index 000000000..d1e90680b
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/object_test.go
@@ -0,0 +1,639 @@
+package otto
+
+import (
+ "testing"
+)
+
+func TestObject_(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ object := newObject(nil, "")
+ is(object != nil, true)
+
+ object.put("xyzzy", toValue("Nothing happens."), true)
+ is(object.get("xyzzy"), "Nothing happens.")
+
+ test(`
+ var abc = Object.getOwnPropertyDescriptor(Object, "prototype");
+ [ [ typeof Object.prototype, abc.writable, abc.enumerable, abc.configurable ],
+ ];
+ `, "object,false,false,false")
+ })
+}
+
+func TestStringObject(t *testing.T) {
+ tt(t, func() {
+ object := New().runtime.newStringObject(toValue("xyzzy"))
+ is(object.get("1"), "y")
+ is(object.get("10"), "undefined")
+ is(object.get("2"), "z")
+ })
+}
+
+func TestObject_getPrototypeOf(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ abc = {};
+ def = Object.getPrototypeOf(abc);
+ ghi = Object.getPrototypeOf(def);
+ [abc,def,ghi,ghi+""];
+ `, "[object Object],[object Object],,null")
+
+ test(`
+ abc = Object.getOwnPropertyDescriptor(Object, "getPrototypeOf");
+ [ abc.value === Object.getPrototypeOf, abc.writable, abc.enumerable, abc.configurable ];
+ `, "true,true,false,true")
+ })
+}
+
+func TestObject_new(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ [ new Object("abc"), new Object(2+2) ];
+ `, "abc,4")
+ })
+}
+
+func TestObject_create(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`raise: Object.create()`, "TypeError")
+
+ test(`
+ var abc = Object.create(null)
+ var def = Object.create({x: 10, y: 20})
+ var ghi = Object.create(Object.prototype)
+
+ var jkl = Object.create({x: 10, y: 20}, {
+ z: {
+ value: 30,
+ writable: true
+ },
+ // sum: {
+ // get: function() {
+ // return this.x + this.y + this.z
+ // }
+ // }
+ });
+ [ abc.prototype, def.x, def.y, ghi, jkl.x, jkl.y, jkl.z ]
+ `, ",10,20,[object Object],10,20,30")
+
+ test(`
+ var properties = {};
+ Object.defineProperty(properties, "abc", {
+ value: {},
+ enumerable: false
+ });
+ var mno = Object.create({}, properties);
+ mno.hasOwnProperty("abc");
+ `, false)
+ })
+}
+
+func TestObject_toLocaleString(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ ({}).toLocaleString();
+ `, "[object Object]")
+
+ test(`
+ object = {
+ toString: function() {
+ return "Nothing happens.";
+ }
+ };
+ object.toLocaleString();
+ `, "Nothing happens.")
+ })
+}
+
+func TestObject_isExtensible(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`raise:
+ Object.isExtensible();
+ `, "TypeError")
+
+ // FIXME terst, Why raise?
+ test(`raise:
+ Object.isExtensible({});
+ `, true)
+
+ test(`Object.isExtensible.length`, 1)
+ test(`Object.isExtensible.prototype`, "undefined")
+ })
+}
+
+func TestObject_preventExtensions(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`raise:
+ Object.preventExtensions()
+ `, "TypeError")
+
+ test(`raise:
+ var abc = { def: true };
+ var ghi = Object.preventExtensions(abc);
+ [ ghi.def === true, Object.isExtensible(abc), Object.isExtensible(ghi) ];
+ `, "true,false,false")
+
+ test(`
+ var abc = new String();
+ var def = Object.isExtensible(abc);
+ Object.preventExtensions(abc);
+ var ghi = false;
+ try {
+ Object.defineProperty(abc, "0", { value: "~" });
+ } catch (err) {
+ ghi = err instanceof TypeError;
+ }
+ [ def, ghi, abc.hasOwnProperty("0"), typeof abc[0] ];
+ `, "true,true,false,undefined")
+
+ test(`Object.preventExtensions.length`, 1)
+ test(`Object.preventExtensions.prototype`, "undefined")
+ })
+}
+
+func TestObject_isSealed(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`Object.isSealed.length`, 1)
+ test(`Object.isSealed.prototype`, "undefined")
+ })
+}
+
+func TestObject_seal(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`raise: Object.seal()`, "TypeError")
+
+ test(`
+ var abc = {a:1,b:1,c:3};
+ var sealed = Object.isSealed(abc);
+ Object.seal(abc);
+ [sealed, Object.isSealed(abc)];
+ `, "false,true")
+
+ test(`
+ var abc = {a:1,b:1,c:3};
+ var sealed = Object.isSealed(abc);
+ var caught = false;
+ Object.seal(abc);
+ abc.b = 5;
+ Object.defineProperty(abc, "a", {value:4});
+ try {
+ Object.defineProperty(abc, "a", {value:42,enumerable:false});
+ } catch (e) {
+ caught = e instanceof TypeError;
+ }
+ [sealed, Object.isSealed(abc), caught, abc.a, abc.b];
+ `, "false,true,true,4,5")
+
+ test(`Object.seal.length`, 1)
+ test(`Object.seal.prototype`, "undefined")
+ })
+}
+
+func TestObject_isFrozen(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`raise: Object.isFrozen()`, "TypeError")
+ test(`Object.isFrozen(Object.preventExtensions({a:1}))`, false)
+ test(`Object.isFrozen({})`, false)
+
+ test(`
+ var abc = {};
+ Object.defineProperty(abc, "def", {
+ value: "def",
+ writable: true,
+ configurable: false
+ });
+ Object.preventExtensions(abc);
+ !Object.isFrozen(abc);
+ `, true)
+
+ test(`Object.isFrozen.length`, 1)
+ test(`Object.isFrozen.prototype`, "undefined")
+ })
+}
+
+func TestObject_freeze(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`raise: Object.freeze()`, "TypeError")
+
+ test(`
+ var abc = {a:1,b:2,c:3};
+ var frozen = Object.isFrozen(abc);
+ Object.freeze(abc);
+ abc.b = 5;
+ [frozen, Object.isFrozen(abc), abc.b];
+ `, "false,true,2")
+
+ test(`
+ var abc = {a:1,b:2,c:3};
+ var frozen = Object.isFrozen(abc);
+ var caught = false;
+ Object.freeze(abc);
+ abc.b = 5;
+ try {
+ Object.defineProperty(abc, "a", {value:4});
+ } catch (e) {
+ caught = e instanceof TypeError;
+ }
+ [frozen, Object.isFrozen(abc), caught, abc.a, abc.b];
+ `, "false,true,true,1,2")
+
+ test(`Object.freeze.length`, 1)
+ test(`Object.freeze.prototype`, "undefined")
+ })
+}
+
+func TestObject_defineProperty(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ (function(abc, def, ghi){
+ Object.defineProperty(arguments, "0", {
+ enumerable: false
+ });
+ return true;
+ })(0, 1, 2);
+ `, true)
+
+ test(`
+ var abc = {};
+ abc.def = 3.14; // Default: writable: true, enumerable: true, configurable: true
+
+ Object.defineProperty(abc, "def", {
+ value: 42
+ });
+
+ var ghi = Object.getOwnPropertyDescriptor(abc, "def");
+ [ ghi.value, ghi.writable, ghi.enumerable, ghi.configurable ];
+ `, "42,true,true,true")
+
+ // Test that we handle the case of DefineOwnProperty
+ // where [[Writable]] is something but [[Value]] is not
+ test(`
+ var abc = [];
+ Object.defineProperty(abc, "0", { writable: false });
+ 0 in abc;
+ `, true)
+
+ // Test that we handle the case of DefineOwnProperty
+ // where [[Writable]] is something but [[Value]] is not
+ // (and the property originally had something for [[Value]]
+ test(`
+ abc = {
+ def: 42
+ };
+ Object.defineProperty(abc, "def", { writable: false });
+ abc.def;
+ `, 42)
+ })
+}
+
+func TestObject_keys(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`Object.keys({ abc:undefined, def:undefined })`, "abc,def")
+
+ test(`
+ function abc() {
+ this.abc = undefined;
+ this.def = undefined;
+ }
+ Object.keys(new abc())
+ `, "abc,def")
+
+ test(`
+ function def() {
+ this.ghi = undefined;
+ }
+ def.prototype = new abc();
+ Object.keys(new def());
+ `, "ghi")
+
+ test(`
+ var ghi = Object.create(
+ {
+ abc: undefined,
+ def: undefined
+ },
+ {
+ ghi: { value: undefined, enumerable: true },
+ jkl: { value: undefined, enumerable: false }
+ }
+ );
+ Object.keys(ghi);
+ `, "ghi")
+
+ test(`
+ (function(abc, def, ghi){
+ return Object.keys(arguments)
+ })(undefined, undefined);
+ `, "0,1")
+
+ test(`
+ (function(abc, def, ghi){
+ return Object.keys(arguments)
+ })(undefined, undefined, undefined, undefined);
+ `, "0,1,2,3")
+ })
+}
+
+func TestObject_getOwnPropertyNames(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`Object.getOwnPropertyNames({ abc:undefined, def:undefined })`, "abc,def")
+
+ test(`
+ var ghi = Object.create(
+ {
+ abc: undefined,
+ def: undefined
+ },
+ {
+ ghi: { value: undefined, enumerable: true },
+ jkl: { value: undefined, enumerable: false }
+ }
+ );
+ Object.getOwnPropertyNames(ghi)
+ `, "ghi,jkl")
+ })
+}
+
+func TestObjectGetterSetter(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`raise:
+ Object.create({}, {
+ abc: {
+ get: function(){
+ return "true";
+ },
+ writable: true
+ }
+ }).abc;
+ `, "TypeError")
+
+ test(`raise:
+ Object.create({}, {
+ abc: {
+ get: function(){
+ return "true";
+ },
+ writable: false
+ }
+ }).abc;
+ `, "TypeError")
+
+ test(`
+ Object.create({}, {
+ abc: {
+ get: function(){
+ return "true";
+ }
+ }
+ }).abc;
+ `, "true")
+
+ test(`
+ Object.create({xyz:true},{abc:{get:function(){return this.xyx}}}).abc;
+ Object.create({
+ xyz: true
+ }, {
+ abc: {
+ get: function(){
+ return this.xyz;
+ }
+ }
+ }).abc;
+ `, true)
+
+ test(`
+ var abc = false;
+ var def = Object.create({}, {
+ xyz: {
+ set: function(value) {
+ abc = value;
+ }
+ }
+ });
+ def.xyz = true;
+ [ abc ];
+ `, "true")
+
+ test(`
+ var abc = {};
+ Object.defineProperty(abc, "def", {
+ value: "xyzzy",
+ configurable: true
+ });
+ Object.preventExtensions(abc);
+ Object.defineProperty(abc, "def", {
+ get: function() {
+ return 5;
+ }
+ });
+ var def = Object.getOwnPropertyDescriptor(abc, "def");
+ [ abc.def, typeof def.get, typeof def.set, typeof def.value, def.configurable, def.enumerable, typeof def.writable ];
+ `, "5,function,undefined,undefined,true,false,undefined")
+
+ test(`
+ var abc = {};
+ Object.defineProperty(abc, "def", {
+ get: function() {
+ return 5;
+ }
+ configurable: true
+ });
+ Object.preventExtensions(abc);
+ Object.defineProperty(abc, "def", {
+ value: "xyzzy",
+ });
+ var def = Object.getOwnPropertyDescriptor(abc, "def");
+ [ abc.def, typeof def.get, typeof def.set, def.value, def.configurable, def.enumerable, def.writable ];
+ `, "xyzzy,undefined,undefined,xyzzy,true,false,false")
+
+ test(`
+ var abc = {};
+
+ function _get0() {
+ return 10;
+ }
+
+ function _set(value) {
+ abc.def = value;
+ }
+
+ Object.defineProperty(abc, "ghi", {
+ get: _get0,
+ set: _set,
+ configurable: true
+ });
+
+ function _get1() {
+ return 20;
+ }
+
+ Object.defineProperty(abc, "ghi", {
+ get: _get0
+ });
+
+ var descriptor = Object.getOwnPropertyDescriptor(abc, "ghi");
+ [ typeof descriptor.set ];
+ `, "function")
+
+ test(`raise:
+ var abc = [];
+ Object.defineProperty(abc, "length", {
+ get: function () {
+ return 2;
+ }
+ });
+ `, "TypeError")
+
+ test(`
+ var abc = {};
+
+ var getter = function() {
+ return 1;
+ }
+
+ Object.defineProperty(abc, "def", {
+ get: getter,
+ configurable: false
+ });
+
+ var jkl = undefined;
+ try {
+ Object.defineProperty(abc, "def", {
+ get: undefined
+ });
+ }
+ catch (err) {
+ jkl = err;
+ }
+ var ghi = Object.getOwnPropertyDescriptor(abc, "def");
+ [ jkl instanceof TypeError, ghi.get === getter, ghi.configurable, ghi.enumerable ];
+ `, "true,true,false,false")
+
+ test(`
+ var abc = {};
+
+ var getter = function() {
+ return 1;
+ };
+
+ Object.defineProperty(abc, "def", {
+ get: getter
+ });
+
+ Object.defineProperty(abc, "def", {
+ set: undefined
+ });
+
+ var ghi = Object.getOwnPropertyDescriptor(abc, "def");
+ [ ghi.get === getter, ghi.set === undefined, ghi.configurable, ghi.enumerable ];
+ `, "true,true,false,false")
+
+ test(`
+ var abc = {};
+
+ var getter = function() {
+ return 1;
+ };
+
+ Object.defineProperty(abc, "def", {
+ get: getter
+ });
+
+ var jkl = undefined;
+ try {
+ Object.defineProperty(abc, "def", {
+ set: function() {}
+ });
+ }
+ catch (err) {
+ jkl = err;
+ }
+
+ var ghi = Object.getOwnPropertyDescriptor(abc, "def");
+ [ jkl instanceof TypeError, ghi.get === getter, ghi.set, ghi.configurable, ghi.enumerable ];
+ `, "true,true,,false,false")
+
+ test(`
+ var abc = {};
+ var def = "xyzzy";
+
+ Object.defineProperty(abc, "ghi", {
+ get: undefined,
+ set: function(value) {
+ def = value;
+ },
+ enumerable: true,
+ configurable: true
+ });
+
+ var hasOwn = abc.hasOwnProperty("ghi");
+ var descriptor = Object.getOwnPropertyDescriptor(abc, "ghi");
+
+ [ hasOwn, typeof descriptor.get ];
+ `, "true,undefined")
+
+ test(`
+ var abc = "xyzzy";
+ Object.defineProperty(Array.prototype, "abc", {
+ get: function () {
+ return abc;
+ },
+ set: function (value) {
+ abc = value;
+ },
+ enumerable: true,
+ configurable: true
+ });
+ var def = [];
+ def.abc = 3.14159;
+ [ def.hasOwnProperty("abc"), def.abc, abc ];
+ `, "false,3.14159,3.14159")
+ })
+}
+
+func TestProperty(t *testing.T) {
+ tt(t, func() {
+ property := _property{}
+ property.writeOn()
+ is(property.writeSet(), true)
+
+ property.writeClear()
+ is(property.writeSet(), false)
+
+ property.writeOff()
+ is(property.writeSet(), true)
+
+ property.writeClear()
+ is(property.writeSet(), false)
+ })
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/otto.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/otto.go
new file mode 100644
index 000000000..9de3e08c5
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/otto.go
@@ -0,0 +1,578 @@
+/*
+Package otto is a JavaScript parser and interpreter written natively in Go.
+
+http://godoc.org/github.com/robertkrimen/otto
+
+ import (
+ "github.com/robertkrimen/otto"
+ )
+
+Run something in the VM
+
+ vm := otto.New()
+ vm.Run(`
+ abc = 2 + 2;
+ console.log("The value of abc is " + abc); // 4
+ `)
+
+Get a value out of the VM
+
+ value, err := vm.Get("abc")
+ value, _ := value.ToInteger()
+ }
+
+Set a number
+
+ vm.Set("def", 11)
+ vm.Run(`
+ console.log("The value of def is " + def);
+ // The value of def is 11
+ `)
+
+Set a string
+
+ vm.Set("xyzzy", "Nothing happens.")
+ vm.Run(`
+ console.log(xyzzy.length); // 16
+ `)
+
+Get the value of an expression
+
+ value, _ = vm.Run("xyzzy.length")
+ {
+ // value is an int64 with a value of 16
+ value, _ := value.ToInteger()
+ }
+
+An error happens
+
+ value, err = vm.Run("abcdefghijlmnopqrstuvwxyz.length")
+ if err != nil {
+ // err = ReferenceError: abcdefghijlmnopqrstuvwxyz is not defined
+ // If there is an error, then value.IsUndefined() is true
+ ...
+ }
+
+Set a Go function
+
+ vm.Set("sayHello", func(call otto.FunctionCall) otto.Value {
+ fmt.Printf("Hello, %s.\n", call.Argument(0).String())
+ return otto.Value{}
+ })
+
+Set a Go function that returns something useful
+
+ vm.Set("twoPlus", func(call otto.FunctionCall) otto.Value {
+ right, _ := call.Argument(0).ToInteger()
+ result, _ := vm.ToValue(2 + right)
+ return result
+ })
+
+Use the functions in JavaScript
+
+ result, _ = vm.Run(`
+ sayHello("Xyzzy"); // Hello, Xyzzy.
+ sayHello(); // Hello, undefined
+
+ result = twoPlus(2.0); // 4
+ `)
+
+Parser
+
+A separate parser is available in the parser package if you're just interested in building an AST.
+
+http://godoc.org/github.com/robertkrimen/otto/parser
+
+Parse and return an AST
+
+ filename := "" // A filename is optional
+ src := `
+ // Sample xyzzy example
+ (function(){
+ if (3.14159 > 0) {
+ console.log("Hello, World.");
+ return;
+ }
+
+ var xyzzy = NaN;
+ console.log("Nothing happens.");
+ return xyzzy;
+ })();
+ `
+
+ // Parse some JavaScript, yielding a *ast.Program and/or an ErrorList
+ program, err := parser.ParseFile(nil, filename, src, 0)
+
+otto
+
+You can run (Go) JavaScript from the commandline with: http://github.com/robertkrimen/otto/tree/master/otto
+
+ $ go get -v github.com/robertkrimen/otto/otto
+
+Run JavaScript by entering some source on stdin or by giving otto a filename:
+
+ $ otto example.js
+
+underscore
+
+Optionally include the JavaScript utility-belt library, underscore, with this import:
+
+ import (
+ "github.com/robertkrimen/otto"
+ _ "github.com/robertkrimen/otto/underscore"
+ )
+
+ // Now every otto runtime will come loaded with underscore
+
+For more information: http://github.com/robertkrimen/otto/tree/master/underscore
+
+Caveat Emptor
+
+The following are some limitations with otto:
+
+ * "use strict" will parse, but does nothing.
+ * The regular expression engine (re2/regexp) is not fully compatible with the ECMA5 specification.
+
+Regular Expression Incompatibility
+
+Go translates JavaScript-style regular expressions into something that is "regexp" compatible via `parser.TransformRegExp`.
+Unfortunately, RegExp requires backtracking for some patterns, and backtracking is not supported by the standard Go engine: https://code.google.com/p/re2/wiki/Syntax
+
+Therefore, the following syntax is incompatible:
+
+ (?=) // Lookahead (positive), currently a parsing error
+ (?!) // Lookahead (backhead), currently a parsing error
+ \1 // Backreference (\1, \2, \3, ...), currently a parsing error
+
+A brief discussion of these limitations: "Regexp (?!re)" https://groups.google.com/forum/?fromgroups=#%21topic/golang-nuts/7qgSDWPIh_E
+
+More information about re2: https://code.google.com/p/re2/
+
+In addition to the above, re2 (Go) has a different definition for \s: [\t\n\f\r ].
+The JavaScript definition, on the other hand, also includes \v, Unicode "Separator, Space", etc.
+
+Halting Problem
+
+If you want to stop long running executions (like third-party code), you can use the interrupt channel to do this:
+
+ package main
+
+ import (
+ "errors"
+ "fmt"
+ "os"
+ "time"
+
+ "github.com/robertkrimen/otto"
+ )
+
+ var halt = errors.New("Stahp")
+
+ func main() {
+ runUnsafe(`var abc = [];`)
+ runUnsafe(`
+ while (true) {
+ // Loop forever
+ }`)
+ }
+
+ func runUnsafe(unsafe string) {
+ start := time.Now()
+ defer func() {
+ duration := time.Since(start)
+ if caught := recover(); caught != nil {
+ if caught == halt {
+ fmt.Fprintf(os.Stderr, "Some code took to long! Stopping after: %v\n", duration)
+ return
+ }
+ panic(caught) // Something else happened, repanic!
+ }
+ fmt.Fprintf(os.Stderr, "Ran code successfully: %v\n", duration)
+ }()
+
+ vm := otto.New()
+ vm.Interrupt = make(chan func(), 1) // The buffer prevents blocking
+
+ go func() {
+ time.Sleep(2 * time.Second) // Stop after two seconds
+ vm.Interrupt <- func() {
+ panic(halt)
+ }
+ }()
+
+ vm.Run(unsafe) // Here be dragons (risky code)
+ }
+
+Where is setTimeout/setInterval?
+
+These timing functions are not actually part of the ECMA-262 specification. Typically, they belong to the `windows` object (in the browser).
+It would not be difficult to provide something like these via Go, but you probably want to wrap otto in an event loop in that case.
+
+For an example of how this could be done in Go with otto, see natto:
+
+http://github.com/robertkrimen/natto
+
+Here is some more discussion of the issue:
+
+* http://book.mixu.net/node/ch2.html
+
+* http://en.wikipedia.org/wiki/Reentrancy_%28computing%29
+
+* http://aaroncrane.co.uk/2009/02/perl_safe_signals/
+
+*/
+package otto
+
+import (
+ "fmt"
+ "strings"
+
+ "github.com/robertkrimen/otto/registry"
+)
+
+// Otto is the representation of the JavaScript runtime. Each instance of Otto has a self-contained namespace.
+type Otto struct {
+ // Interrupt is a channel for interrupting the runtime. You can use this to halt a long running execution, for example.
+ // See "Halting Problem" for more information.
+ Interrupt chan func()
+ runtime *_runtime
+}
+
+// New will allocate a new JavaScript runtime
+func New() *Otto {
+ self := &Otto{
+ runtime: newContext(),
+ }
+ self.runtime.otto = self
+ self.Set("console", self.runtime.newConsole())
+
+ registry.Apply(func(entry registry.Entry) {
+ self.Run(entry.Source())
+ })
+
+ return self
+}
+
+func (otto *Otto) clone() *Otto {
+ self := &Otto{
+ runtime: otto.runtime.clone(),
+ }
+ self.runtime.otto = self
+ return self
+}
+
+// Run will allocate a new JavaScript runtime, run the given source
+// on the allocated runtime, and return the runtime, resulting value, and
+// error (if any).
+//
+// src may be a string, a byte slice, a bytes.Buffer, or an io.Reader, but it MUST always be in UTF-8.
+//
+// src may also be a Script.
+//
+// src may also be a Program, but if the AST has been modified, then runtime behavior is undefined.
+//
+func Run(src interface{}) (*Otto, Value, error) {
+ otto := New()
+ value, err := otto.Run(src) // This already does safety checking
+ return otto, value, err
+}
+
+// Run will run the given source (parsing it first if necessary), returning the resulting value and error (if any)
+//
+// src may be a string, a byte slice, a bytes.Buffer, or an io.Reader, but it MUST always be in UTF-8.
+//
+// If the runtime is unable to parse source, then this function will return undefined and the parse error (nothing
+// will be evaluated in this case).
+//
+// src may also be a Script.
+//
+// src may also be a Program, but if the AST has been modified, then runtime behavior is undefined.
+//
+func (self Otto) Run(src interface{}) (Value, error) {
+ value, err := self.runtime.cmpl_run(src)
+ if !value.safe() {
+ value = Value{}
+ }
+ return value, err
+}
+
+// Get the value of the top-level binding of the given name.
+//
+// If there is an error (like the binding does not exist), then the value
+// will be undefined.
+func (self Otto) Get(name string) (Value, error) {
+ value := Value{}
+ err := catchPanic(func() {
+ value = self.getValue(name)
+ })
+ if !value.safe() {
+ value = Value{}
+ }
+ return value, err
+}
+
+func (self Otto) getValue(name string) Value {
+ return self.runtime.globalStash.getBinding(name, false)
+}
+
+// Set the top-level binding of the given name to the given value.
+//
+// Set will automatically apply ToValue to the given value in order
+// to convert it to a JavaScript value (type Value).
+//
+// If there is an error (like the binding is read-only, or the ToValue conversion
+// fails), then an error is returned.
+//
+// If the top-level binding does not exist, it will be created.
+func (self Otto) Set(name string, value interface{}) error {
+ {
+ value, err := self.ToValue(value)
+ if err != nil {
+ return err
+ }
+ err = catchPanic(func() {
+ self.setValue(name, value)
+ })
+ return err
+ }
+}
+
+func (self Otto) setValue(name string, value Value) {
+ self.runtime.globalStash.setValue(name, value, false)
+}
+
+// Call the given JavaScript with a given this and arguments.
+//
+// If this is nil, then some special handling takes place to determine the proper
+// this value, falling back to a "standard" invocation if necessary (where this is
+// undefined).
+//
+// If source begins with "new " (A lowercase new followed by a space), then
+// Call will invoke the function constructor rather than performing a function call.
+// In this case, the this argument has no effect.
+//
+// // value is a String object
+// value, _ := vm.Call("Object", nil, "Hello, World.")
+//
+// // Likewise...
+// value, _ := vm.Call("new Object", nil, "Hello, World.")
+//
+// // This will perform a concat on the given array and return the result
+// // value is [ 1, 2, 3, undefined, 4, 5, 6, 7, "abc" ]
+// value, _ := vm.Call(`[ 1, 2, 3, undefined, 4 ].concat`, nil, 5, 6, 7, "abc")
+//
+func (self Otto) Call(source string, this interface{}, argumentList ...interface{}) (Value, error) {
+
+ thisValue := Value{}
+
+ construct := false
+ if strings.HasPrefix(source, "new ") {
+ source = source[4:]
+ construct = true
+ }
+
+ // FIXME enterGlobalScope
+ self.runtime.enterGlobalScope()
+ defer func() {
+ self.runtime.leaveScope()
+ }()
+
+ if !construct && this == nil {
+ program, err := self.runtime.cmpl_parse("", source+"()")
+ if err == nil {
+ if node, ok := program.body[0].(*_nodeExpressionStatement); ok {
+ if node, ok := node.expression.(*_nodeCallExpression); ok {
+ var value Value
+ err := catchPanic(func() {
+ value = self.runtime.cmpl_evaluate_nodeCallExpression(node, argumentList)
+ })
+ if err != nil {
+ return Value{}, err
+ }
+ return value, nil
+ }
+ }
+ }
+ } else {
+ value, err := self.ToValue(this)
+ if err != nil {
+ return Value{}, err
+ }
+ thisValue = value
+ }
+
+ {
+ this := thisValue
+
+ fn, err := self.Run(source)
+ if err != nil {
+ return Value{}, err
+ }
+
+ if construct {
+ result, err := fn.constructSafe(self.runtime, this, argumentList...)
+ if err != nil {
+ return Value{}, err
+ }
+ return result, nil
+ }
+
+ result, err := fn.Call(this, argumentList...)
+ if err != nil {
+ return Value{}, err
+ }
+ return result, nil
+ }
+}
+
+// Object will run the given source and return the result as an object.
+//
+// For example, accessing an existing object:
+//
+// object, _ := vm.Object(`Number`)
+//
+// Or, creating a new object:
+//
+// object, _ := vm.Object(`({ xyzzy: "Nothing happens." })`)
+//
+// Or, creating and assigning an object:
+//
+// object, _ := vm.Object(`xyzzy = {}`)
+// object.Set("volume", 11)
+//
+// If there is an error (like the source does not result in an object), then
+// nil and an error is returned.
+func (self Otto) Object(source string) (*Object, error) {
+ value, err := self.runtime.cmpl_run(source)
+ if err != nil {
+ return nil, err
+ }
+ if value.IsObject() {
+ return value.Object(), nil
+ }
+ return nil, fmt.Errorf("value is not an object")
+}
+
+// ToValue will convert an interface{} value to a value digestible by otto/JavaScript.
+func (self Otto) ToValue(value interface{}) (Value, error) {
+ return self.runtime.safeToValue(value)
+}
+
+// Copy will create a copy/clone of the runtime.
+//
+// Copy is useful for saving some time when creating many similar runtimes.
+//
+// This method works by walking the original runtime and cloning each object, scope, stash,
+// etc. into a new runtime.
+//
+// Be on the lookout for memory leaks or inadvertent sharing of resources.
+func (in *Otto) Copy() *Otto {
+ out := &Otto{
+ runtime: in.runtime.clone(),
+ }
+ out.runtime.otto = out
+ return out
+}
+
+// Object{}
+
+// Object is the representation of a JavaScript object.
+type Object struct {
+ object *_object
+ value Value
+}
+
+func _newObject(object *_object, value Value) *Object {
+ // value MUST contain object!
+ return &Object{
+ object: object,
+ value: value,
+ }
+}
+
+// Call a method on the object.
+//
+// It is essentially equivalent to:
+//
+// var method, _ := object.Get(name)
+// method.Call(object, argumentList...)
+//
+// An undefined value and an error will result if:
+//
+// 1. There is an error during conversion of the argument list
+// 2. The property is not actually a function
+// 3. An (uncaught) exception is thrown
+//
+func (self Object) Call(name string, argumentList ...interface{}) (Value, error) {
+ // TODO: Insert an example using JavaScript below...
+ // e.g., Object("JSON").Call("stringify", ...)
+
+ function, err := self.Get(name)
+ if err != nil {
+ return Value{}, err
+ }
+ return function.Call(self.Value(), argumentList...)
+}
+
+// Value will return self as a value.
+func (self Object) Value() Value {
+ return self.value
+}
+
+// Get the value of the property with the given name.
+func (self Object) Get(name string) (Value, error) {
+ value := Value{}
+ err := catchPanic(func() {
+ value = self.object.get(name)
+ })
+ if !value.safe() {
+ value = Value{}
+ }
+ return value, err
+}
+
+// Set the property of the given name to the given value.
+//
+// An error will result if the setting the property triggers an exception (i.e. read-only),
+// or there is an error during conversion of the given value.
+func (self Object) Set(name string, value interface{}) error {
+ {
+ value, err := self.object.runtime.safeToValue(value)
+ if err != nil {
+ return err
+ }
+ err = catchPanic(func() {
+ self.object.put(name, value, true)
+ })
+ return err
+ }
+}
+
+// Get the keys for the object
+//
+// Equivalent to calling Object.keys on the object
+func (self Object) Keys() []string {
+ var keys []string
+ self.object.enumerate(false, func(name string) bool {
+ keys = append(keys, name)
+ return true
+ })
+ return keys
+}
+
+// Class will return the class string of the object.
+//
+// The return value will (generally) be one of:
+//
+// Object
+// Function
+// Array
+// String
+// Number
+// Boolean
+// Date
+// RegExp
+//
+func (self Object) Class() string {
+ return self.object.class
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/otto/Makefile b/Godeps/_workspace/src/github.com/robertkrimen/otto/otto/Makefile
new file mode 100644
index 000000000..bac5cd4a5
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/otto/Makefile
@@ -0,0 +1,5 @@
+.PHONY: build
+
+build:
+ go build -a
+ -gxc build-darwin-386 -a
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/otto/main.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/otto/main.go
new file mode 100644
index 000000000..f379e42a9
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/otto/main.go
@@ -0,0 +1,48 @@
+package main
+
+import (
+ "flag"
+ "fmt"
+ "io/ioutil"
+ "os"
+
+ "github.com/robertkrimen/otto"
+ "github.com/robertkrimen/otto/underscore"
+)
+
+var flag_underscore *bool = flag.Bool("underscore", true, "Load underscore into the runtime environment")
+
+func readSource(filename string) ([]byte, error) {
+ if filename == "" || filename == "-" {
+ return ioutil.ReadAll(os.Stdin)
+ }
+ return ioutil.ReadFile(filename)
+}
+
+func main() {
+ flag.Parse()
+
+ if !*flag_underscore {
+ underscore.Disable()
+ }
+
+ err := func() error {
+ src, err := readSource(flag.Arg(0))
+ if err != nil {
+ return err
+ }
+
+ vm := otto.New()
+ _, err = vm.Run(src)
+ return err
+ }()
+ if err != nil {
+ switch err := err.(type) {
+ case *otto.Error:
+ fmt.Print(err.String())
+ default:
+ fmt.Println(err)
+ }
+ os.Exit(64)
+ }
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/otto_.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/otto_.go
new file mode 100644
index 000000000..e053b54e2
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/otto_.go
@@ -0,0 +1,178 @@
+package otto
+
+import (
+ "fmt"
+ "regexp"
+ runtime_ "runtime"
+ "strconv"
+ "strings"
+)
+
+var isIdentifier_Regexp *regexp.Regexp = regexp.MustCompile(`^[a-zA-Z\$][a-zA-Z0-9\$]*$`)
+
+func isIdentifier(string_ string) bool {
+ return isIdentifier_Regexp.MatchString(string_)
+}
+
+func (self *_runtime) toValueArray(arguments ...interface{}) []Value {
+ length := len(arguments)
+ if length == 1 {
+ if valueArray, ok := arguments[0].([]Value); ok {
+ return valueArray
+ }
+ return []Value{toValue(arguments[0])}
+ }
+
+ valueArray := make([]Value, length)
+ for index, value := range arguments {
+ valueArray[index] = toValue(value)
+ }
+
+ return valueArray
+}
+
+func stringToArrayIndex(name string) int64 {
+ index, err := strconv.ParseInt(name, 10, 64)
+ if err != nil {
+ return -1
+ }
+ if index < 0 {
+ return -1
+ }
+ if index >= maxUint32 {
+ // The value 2^32 (or above) is not a valid index because
+ // you cannot store a uint32 length for an index of uint32
+ return -1
+ }
+ return index
+}
+
+func isUint32(value int64) bool {
+ return value >= 0 && value <= maxUint32
+}
+
+func arrayIndexToString(index int64) string {
+ return strconv.FormatInt(index, 10)
+}
+
+func valueOfArrayIndex(array []Value, index int) Value {
+ value, _ := getValueOfArrayIndex(array, index)
+ return value
+}
+
+func getValueOfArrayIndex(array []Value, index int) (Value, bool) {
+ if index >= 0 && index < len(array) {
+ value := array[index]
+ if !value.isEmpty() {
+ return value, true
+ }
+ }
+ return Value{}, false
+}
+
+// A range index can be anything from 0 up to length. It is NOT safe to use as an index
+// to an array, but is useful for slicing and in some ECMA algorithms.
+func valueToRangeIndex(indexValue Value, length int64, negativeIsZero bool) int64 {
+ index := indexValue.number().int64
+ if negativeIsZero {
+ if index < 0 {
+ index = 0
+ }
+ // minimum(index, length)
+ if index >= length {
+ index = length
+ }
+ return index
+ }
+
+ if index < 0 {
+ index += length
+ if index < 0 {
+ index = 0
+ }
+ } else {
+ if index > length {
+ index = length
+ }
+ }
+ return index
+}
+
+func rangeStartEnd(array []Value, size int64, negativeIsZero bool) (start, end int64) {
+ start = valueToRangeIndex(valueOfArrayIndex(array, 0), size, negativeIsZero)
+ if len(array) == 1 {
+ // If there is only the start argument, then end = size
+ end = size
+ return
+ }
+
+ // Assuming the argument is undefined...
+ end = size
+ endValue := valueOfArrayIndex(array, 1)
+ if !endValue.IsUndefined() {
+ // Which it is not, so get the value as an array index
+ end = valueToRangeIndex(endValue, size, negativeIsZero)
+ }
+ return
+}
+
+func rangeStartLength(source []Value, size int64) (start, length int64) {
+ start = valueToRangeIndex(valueOfArrayIndex(source, 0), size, false)
+
+ // Assume the second argument is missing or undefined
+ length = int64(size)
+ if len(source) == 1 {
+ // If there is only the start argument, then length = size
+ return
+ }
+
+ lengthValue := valueOfArrayIndex(source, 1)
+ if !lengthValue.IsUndefined() {
+ // Which it is not, so get the value as an array index
+ length = lengthValue.number().int64
+ }
+ return
+}
+
+func boolFields(input string) (result map[string]bool) {
+ result = map[string]bool{}
+ for _, word := range strings.Fields(input) {
+ result[word] = true
+ }
+ return result
+}
+
+func hereBeDragons(arguments ...interface{}) string {
+ pc, _, _, _ := runtime_.Caller(1)
+ name := runtime_.FuncForPC(pc).Name()
+ message := fmt.Sprintf("Here be dragons -- %s", name)
+ if len(arguments) > 0 {
+ message += ": "
+ argument0 := fmt.Sprintf("%s", arguments[0])
+ if len(arguments) == 1 {
+ message += argument0
+ } else {
+ message += fmt.Sprintf(argument0, arguments[1:]...)
+ }
+ } else {
+ message += "."
+ }
+ return message
+}
+
+func throwHereBeDragons(arguments ...interface{}) {
+ panic(hereBeDragons(arguments...))
+}
+
+func eachPair(list []interface{}, fn func(_0, _1 interface{})) {
+ for len(list) > 0 {
+ var _0, _1 interface{}
+ _0 = list[0]
+ list = list[1:] // Pop off first
+ if len(list) > 0 {
+ _1 = list[0]
+ list = list[1:] // Pop off second
+ }
+ fn(_0, _1)
+ }
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/otto_error_test.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/otto_error_test.go
new file mode 100644
index 000000000..5ce358819
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/otto_error_test.go
@@ -0,0 +1,48 @@
+package otto
+
+import (
+ "testing"
+)
+
+func TestOttoError(t *testing.T) {
+ tt(t, func() {
+ vm := New()
+
+ _, err := vm.Run(`throw "Xyzzy"`)
+ is(err, "Xyzzy")
+
+ _, err = vm.Run(`throw new TypeError()`)
+ is(err, "TypeError")
+
+ _, err = vm.Run(`throw new TypeError("Nothing happens.")`)
+ is(err, "TypeError: Nothing happens.")
+
+ _, err = ToValue([]byte{})
+ is(err, "TypeError: invalid value (slice): missing runtime: [] ([]uint8)")
+
+ _, err = vm.Run(`
+ (function(){
+ return abcdef.length
+ })()
+ `)
+ is(err, "ReferenceError: 'abcdef' is not defined")
+
+ _, err = vm.Run(`
+ function start() {
+ }
+
+ start()
+
+ xyzzy()
+ `)
+ is(err, "ReferenceError: 'xyzzy' is not defined")
+
+ _, err = vm.Run(`
+ // Just a comment
+
+ xyzzy
+ `)
+ is(err, "ReferenceError: 'xyzzy' is not defined")
+
+ })
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/otto_test.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/otto_test.go
new file mode 100644
index 000000000..2f1e1c35f
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/otto_test.go
@@ -0,0 +1,1379 @@
+package otto
+
+import (
+ "bytes"
+ "io"
+ "testing"
+
+ "github.com/robertkrimen/otto/parser"
+)
+
+func TestOtto(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test("xyzzy = 2", 2)
+
+ test("xyzzy + 2", 4)
+
+ test("xyzzy += 16", 18)
+
+ test("xyzzy", 18)
+
+ test(`
+ (function(){
+ return 1
+ })()
+ `, 1)
+
+ test(`
+ (function(){
+ return 1
+ }).call(this)
+ `, 1)
+
+ test(`
+ (function(){
+ var result
+ (function(){
+ result = -1
+ })()
+ return result
+ })()
+ `, -1)
+
+ test(`
+ var abc = 1
+ abc || (abc = -1)
+ abc
+ `, 1)
+
+ test(`
+ var abc = (function(){ 1 === 1 })();
+ abc;
+ `, "undefined")
+ })
+}
+
+func TestFunction__(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ function abc() {
+ return 1;
+ };
+ abc();
+ `, 1)
+ })
+}
+
+func TestIf(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ abc = undefined;
+ def = undefined;
+ if (true) abc = 1
+ else abc = 2;
+ if (false) {
+ def = 3;
+ }
+ else def = 4;
+
+ [ abc, def ];
+ `, "1,4")
+
+ test(`
+ if (1) {
+ abc = 1;
+ }
+ else {
+ abc = 0;
+ }
+ abc;
+ `, 1)
+
+ test(`
+ if (0) {
+ abc = 1;
+ }
+ else {
+ abc = 0;
+ }
+ abc;
+ `, 0)
+
+ test(`
+ abc = 0;
+ if (0) {
+ abc = 1;
+ }
+ abc;
+ `, 0)
+
+ test(`
+ abc = 0;
+ if (abc) {
+ abc = 1;
+ }
+ abc;
+ `, 0)
+ })
+}
+
+func TestSequence(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ 1, 2, 3;
+ `, 3)
+ })
+}
+
+func TestCall(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ Math.pow(3, 2);
+ `, 9)
+ })
+}
+
+func TestMember(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ abc = [ 0, 1, 2 ];
+ def = {
+ "abc": 0,
+ "def": 1,
+ "ghi": 2,
+ };
+ [ abc[2], def.abc, abc[1], def.def ];
+ `, "2,0,1,1")
+ })
+}
+
+func Test_this(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ typeof this;
+ `, "object")
+ })
+}
+
+func TestWhile(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ limit = 4
+ abc = 0
+ while (limit) {
+ abc = abc + 1
+ limit = limit - 1
+ }
+ abc;
+ `, 4)
+ })
+}
+
+func TestSwitch_break(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ var abc = true;
+ var ghi = "Xyzzy";
+ while (abc) {
+ switch ('def') {
+ case 'def':
+ break;
+ }
+ ghi = "Nothing happens.";
+ abc = false;
+ }
+ ghi;
+ `, "Nothing happens.")
+
+ test(`
+ var abc = true;
+ var ghi = "Xyzzy";
+ WHILE:
+ while (abc) {
+ switch ('def') {
+ case 'def':
+ break WHILE;
+ }
+ ghi = "Nothing happens."
+ abc = false
+ }
+ ghi;
+ `, "Xyzzy")
+
+ test(`
+ var ghi = "Xyzzy";
+ FOR:
+ for (;;) {
+ switch ('def') {
+ case 'def':
+ break FOR;
+ ghi = "";
+ }
+ ghi = "Nothing happens.";
+ }
+ ghi;
+ `, "Xyzzy")
+
+ test(`
+ var ghi = "Xyzzy";
+ FOR:
+ for (var jkl in {}) {
+ switch ('def') {
+ case 'def':
+ break FOR;
+ ghi = "Something happens.";
+ }
+ ghi = "Nothing happens.";
+ }
+ ghi;
+ `, "Xyzzy")
+
+ test(`
+ var ghi = "Xyzzy";
+ function jkl() {
+ switch ('def') {
+ case 'def':
+ break;
+ ghi = "";
+ }
+ ghi = "Nothing happens.";
+ }
+ while (abc) {
+ jkl();
+ abc = false;
+ ghi = "Something happens.";
+ }
+ ghi;
+ `, "Something happens.")
+ })
+}
+
+func TestTryFinally(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ var abc;
+ try {
+ abc = 1;
+ }
+ finally {
+ abc = 2;
+ }
+ abc;
+ `, 2)
+
+ test(`
+ var abc = false, def = 0;
+ do {
+ def += 1;
+ if (def > 100) {
+ break;
+ }
+ try {
+ continue;
+ }
+ finally {
+ abc = true;
+ }
+ }
+ while(!abc && def < 10)
+ def;
+ `, 1)
+
+ test(`
+ var abc = false, def = 0, ghi = 0;
+ do {
+ def += 1;
+ if (def > 100) {
+ break;
+ }
+ try {
+ throw 0;
+ }
+ catch (jkl) {
+ continue;
+ }
+ finally {
+ abc = true;
+ ghi = 11;
+ }
+ ghi -= 1;
+ }
+ while(!abc && def < 10)
+ ghi;
+ `, 11)
+
+ test(`
+ var abc = 0, def = 0;
+ do {
+ try {
+ abc += 1;
+ throw "ghi";
+ }
+ finally {
+ def = 1;
+ continue;
+ }
+ def -= 1;
+ }
+ while (abc < 2)
+ [ abc, def ];
+ `, "2,1")
+ })
+}
+
+func TestTryCatch(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ var abc = 1;
+ try {
+ throw 4;
+ abc = -1;
+ }
+ catch (xyzzy) {
+ abc += xyzzy + 1;
+ }
+ abc;
+ `, 6)
+
+ test(`
+ abc = 1;
+ var def;
+ try {
+ try {
+ throw 4;
+ abc = -1;
+ }
+ catch (xyzzy) {
+ abc += xyzzy + 1;
+ throw 64;
+ }
+ }
+ catch (xyzzy) {
+ def = xyzzy;
+ abc = -2;
+ }
+ [ def, abc ];
+ `, "64,-2")
+ })
+}
+
+func TestWith(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ var def;
+ with({ abc: 9 }) {
+ def = abc;
+ }
+ def;
+ `, 9)
+
+ test(`
+ var def;
+ with({ abc: function(){
+ return 11;
+ } }) {
+ def = abc();
+ }
+ def;
+ `, 11)
+ })
+}
+
+func TestSwitch(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ var abc = 0;
+ switch (0) {
+ default:
+ abc += 1;
+ case 1:
+ abc += 2;
+ case 2:
+ abc += 4;
+ case 3:
+ abc += 8;
+ }
+ abc;
+ `, 15)
+
+ test(`
+ abc = 0;
+ switch (3) {
+ default:
+ abc += 1;
+ case 1:
+ abc += 2;
+ case 2:
+ abc += 4;
+ case 3:
+ abc += 8;
+ }
+ abc;
+ `, 8)
+
+ test(`
+ abc = 0;
+ switch (60) {
+ case 1:
+ abc += 2;
+ case 2:
+ abc += 4;
+ case 3:
+ abc += 8;
+ }
+ abc;
+ `, 0)
+ })
+}
+
+func TestForIn(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ var abc;
+ for (property in { a: 1 }) {
+ abc = property;
+ }
+ abc;
+ `, "a")
+
+ test(`
+ var ghi;
+ for (property in new String("xyzzy")) {
+ ghi = property;
+ }
+ ghi;
+ `, "4")
+ })
+}
+
+func TestFor(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ var abc = 7;
+ for (i = 0; i < 3; i += 1) {
+ abc += 1;
+ }
+ abc;
+ `, 10)
+
+ test(`
+ abc = 7;
+ for (i = 0; i < 3; i += 1) {
+ abc += 1;
+ if (i == 1) {
+ break;
+ }
+ }
+ abc;
+ `, 9)
+
+ test(`
+ abc = 7;
+ for (i = 0; i < 3; i += 1) {
+ if (i == 2) {
+ continue;
+ }
+ abc += 1;
+ }
+ abc;
+ `, 9)
+
+ test(`
+ abc = 0;
+ for (;;) {
+ abc += 1;
+ if (abc == 3)
+ break;
+ }
+ abc;
+ `, 3)
+
+ test(`
+ for (abc = 0; ;) {
+ abc += 1;
+ if (abc == 3)
+ break;
+ }
+ abc;
+ `, 3)
+
+ test(`
+ for (abc = 0; ; abc += 1) {
+ abc += 1;
+ if (abc == 3)
+ break;
+ }
+ abc;
+ `, 3)
+ })
+}
+
+func TestLabelled(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ // TODO Add emergency break
+
+ test(`
+ xyzzy: for (var abc = 0; abc <= 0; abc++) {
+ for (var def = 0; def <= 1; def++) {
+ if (def === 0) {
+ continue xyzzy;
+ } else {
+ }
+ }
+ }
+ `)
+
+ test(`
+ abc = 0
+ def:
+ while (true) {
+ while (true) {
+ abc = abc + 1
+ if (abc > 11) {
+ break def;
+ }
+ }
+ }
+ abc;
+ `, 12)
+
+ test(`
+ abc = 0
+ def:
+ do {
+ do {
+ abc = abc + 1
+ if (abc > 11) {
+ break def;
+ }
+ } while (true)
+ } while (true)
+ abc;
+ `, 12)
+ })
+}
+
+func TestConditional(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ [ true ? false : true, true ? 1 : 0, false ? 3.14159 : "abc" ];
+ `, "false,1,abc")
+ })
+}
+
+func TestArrayLiteral(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ [ 1, , 3.14159 ];
+ `, "1,,3.14159")
+ })
+}
+
+func TestAssignment(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ var abc = 1;
+ abc;
+ `, 1)
+
+ test(`
+ abc += 2;
+ abc;
+ `, 3)
+ })
+}
+
+func TestBinaryOperation(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`0 == 1`, false)
+ test(`1 == "1"`, true)
+ test(`0 === 1`, false)
+ test(`1 === "1"`, false)
+ test(`"1" === "1"`, true)
+ })
+}
+
+func Test_typeof(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`typeof abc`, "undefined")
+ test(`typeof abc === 'undefined'`, true)
+ test(`typeof {}`, "object")
+ test(`typeof null`, "object")
+ })
+}
+
+func Test_PrimitiveValueObjectValue(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ Number11 := test(`new Number(11)`)
+ is(Number11.float64(), 11)
+ })
+}
+
+func Test_eval(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ // FIXME terst, Is this correct?
+ test(`
+ var abc = 1;
+ `, "undefined")
+
+ test(`
+ eval("abc += 1");
+ `, 2)
+
+ test(`
+ (function(){
+ var abc = 11;
+ eval("abc += 1");
+ return abc;
+ })();
+ `, 12)
+ test(`abc`, 2)
+
+ test(`
+ (function(){
+ try {
+ eval("var prop = \\u2029;");
+ return false;
+ } catch (abc) {
+ return [ abc instanceof SyntaxError, abc.toString() ];
+ }
+ })();
+ `, "true,SyntaxError: Unexpected token ILLEGAL")
+
+ test(`
+ function abc(){
+ this.THIS = eval("this");
+ }
+ var def = new abc();
+ def === def.THIS;
+ `, true)
+ })
+}
+
+func Test_evalDirectIndirect(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ // (function () {return this;}()).abc = "global";
+ test(`
+ var abc = "global";
+ (function(){
+ try {
+ var _eval = eval;
+ var abc = "function";
+ return [
+ _eval("\'global\' === abc"), // eval (Indirect)
+ eval("\'function\' === abc"), // eval (Direct)
+ ];
+ } finally {
+ delete this.abc;
+ }
+ })();
+ `, "true,true")
+ })
+}
+
+func TestError_URIError(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`new URIError() instanceof URIError`, true)
+
+ test(`
+ var abc
+ try {
+ decodeURI("http://example.com/ _^#%")
+ }
+ catch (def) {
+ abc = def instanceof URIError
+ }
+ abc
+ `, true)
+ })
+}
+
+func TestTo(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ {
+ value, _ := test(`"11"`).ToFloat()
+ is(value, float64(11))
+ }
+
+ {
+ value, _ := test(`"11"`).ToInteger()
+ is(value, int64(11))
+
+ value, _ = test(`1.1`).ToInteger()
+ is(value, int64(1))
+ }
+ })
+}
+
+func TestShouldError(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`raise:
+ xyzzy
+ throw new TypeError("Nothing happens.")
+ `, "ReferenceError: 'xyzzy' is not defined")
+ })
+}
+
+func TestAPI(t *testing.T) {
+ tt(t, func() {
+ test, vm := test()
+
+ test(`
+ String.prototype.xyzzy = function(){
+ return this.length + 11 + (arguments[0] || 0)
+ }
+ abc = new String("xyzzy")
+ def = "Nothing happens."
+ abc.xyzzy()
+ `, 16)
+ abc, _ := vm.Get("abc")
+ def, _ := vm.Get("def")
+ object := abc.Object()
+ result, _ := object.Call("xyzzy")
+ is(result, 16)
+ result, _ = object.Call("xyzzy", 1)
+ is(result, 17)
+ value, _ := object.Get("xyzzy")
+ result, _ = value.Call(def)
+ is(result, 27)
+ result, _ = value.Call(def, 3)
+ is(result, 30)
+ object = value.Object() // Object xyzzy
+ result, _ = object.Value().Call(def, 3)
+ is(result, 30)
+
+ test(`
+ abc = {
+ 'abc': 1,
+ 'def': false,
+ 3.14159: NaN,
+ };
+ abc['abc'];
+ `, 1)
+ abc, err := vm.Get("abc")
+ is(err, nil)
+ object = abc.Object() // Object abc
+ value, err = object.Get("abc")
+ is(err, nil)
+ is(value, 1)
+ is(object.Keys(), []string{"abc", "def", "3.14159"})
+
+ test(`
+ abc = [ 0, 1, 2, 3.14159, "abc", , ];
+ abc.def = true;
+ `)
+ abc, err = vm.Get("abc")
+ is(err, nil)
+ object = abc.Object() // Object abc
+ is(object.Keys(), []string{"0", "1", "2", "3", "4", "def"})
+ })
+}
+
+func TestUnicode(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`var abc = eval("\"a\uFFFFa\"");`, "undefined")
+
+ test(`abc.length`, 3)
+
+ test(`abc != "aa"`, true)
+
+ test("abc[1] === \"\uFFFF\"", true)
+ })
+}
+
+func TestDotMember(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ abc = {
+ ghi: 11,
+ }
+ abc.def = "Xyzzy"
+ abc.null = "Nothing happens."
+ `)
+ test(`abc.def`, "Xyzzy")
+ test(`abc.null`, "Nothing happens.")
+ test(`abc.ghi`, 11)
+
+ test(`
+ abc = {
+ null: 11,
+ }
+ `)
+ test(`abc.def`, "undefined")
+ test(`abc.null`, 11)
+ test(`abc.ghi`, "undefined")
+ })
+}
+
+func Test_stringToFloat(t *testing.T) {
+ tt(t, func() {
+
+ is(parseNumber("10e10000"), _Infinity)
+ is(parseNumber("10e10_."), _NaN)
+ })
+}
+
+func Test_delete(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ delete 42;
+ `, true)
+
+ test(`
+ var abc = delete $_undefined_$;
+ abc = abc && delete ($_undefined_$);
+ abc;
+ `, true)
+
+ // delete should not trigger get()
+ test(`
+ var abc = {
+ get def() {
+ throw "Test_delete: delete should not trigger get()"
+ }
+ };
+ delete abc.def
+ `, true)
+ })
+}
+
+func TestObject_defineOwnProperty(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ var object = {};
+
+ var descriptor = new Boolean(false);
+ descriptor.configurable = true;
+
+ Object.defineProperties(object, {
+ property: descriptor
+ });
+
+ var abc = object.hasOwnProperty("property");
+ delete object.property;
+ var def = object.hasOwnProperty("property");
+
+ [ abc, def ];
+ `, "true,false")
+
+ test(`
+ var object = [0, 1, 2];
+ Object.defineProperty(object, "0", {
+ value: 42,
+ writable: false,
+ enumerable: false,
+ configurable: false
+ });
+ var abc = Object.getOwnPropertyDescriptor(object, "0");
+ [ abc.value, abc.writable, abc.enumerable, abc.configurable ];
+ `, "42,false,false,false")
+
+ test(`
+ var abc = { "xyzzy": 42 };
+ var def = Object.defineProperties(abc, "");
+ abc === def;
+ `, true)
+ })
+}
+
+func Test_assignmentEvaluationOrder(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ var abc = 0;
+ ((abc = 1) & abc);
+ `, 1)
+
+ test(`
+ var abc = 0;
+ (abc & (abc = 1));
+ `, 0)
+ })
+}
+
+func TestOttoCall(t *testing.T) {
+ tt(t, func() {
+ vm := New()
+
+ _, err := vm.Run(`
+ var abc = {
+ ghi: 1,
+ def: function(def){
+ var ghi = 0;
+ if (this.ghi) {
+ ghi = this.ghi;
+ }
+ return "def: " + (def + 3.14159 + ghi);
+ }
+ };
+ `)
+ is(err, nil)
+
+ value, err := vm.Call(`abc.def`, nil, 2)
+ is(err, nil)
+ is(value, "def: 6.14159")
+
+ value, err = vm.Call(`abc.def`, "", 2)
+ is(err, nil)
+ is(value, "def: 5.14159")
+
+ // Do not attempt to do a ToValue on a this of nil
+ value, err = vm.Call(`jkl.def`, nil, 1, 2, 3)
+ is(err, "!=", nil)
+ is(value, "undefined")
+
+ value, err = vm.Call(`[ 1, 2, 3, undefined, 4 ].concat`, nil, 5, 6, 7, "abc")
+ is(err, nil)
+ is(value, "1,2,3,,4,5,6,7,abc")
+ })
+}
+
+func TestOttoCall_new(t *testing.T) {
+ tt(t, func() {
+ test, vm := test()
+
+ vm.Set("abc", func(call FunctionCall) Value {
+ value, err := call.Otto.Call(`new Object`, nil, "Nothing happens.")
+ is(err, nil)
+ return value
+ })
+ test(`
+ def = abc();
+ [ def, def instanceof String ];
+ `, "Nothing happens.,true")
+ })
+}
+
+func TestOttoCall_throw(t *testing.T) {
+ // FIXME? (Been broken for a while)
+ // Looks like this has been broken for a while... what
+ // behavior do we want here?
+
+ if true {
+ return
+ }
+
+ tt(t, func() {
+ test, vm := test()
+
+ vm.Set("abc", func(call FunctionCall) Value {
+ if false {
+ call.Otto.Call(`throw eval`, nil, "({ def: 3.14159 })")
+ }
+ call.Otto.Call(`throw Error`, nil, "abcdef")
+ return Value{}
+ })
+ // TODO try { abc(); } catch (err) { error = err }
+ // Possible unrelated error case:
+ // If error is not declared beforehand, is later referencing it a ReferenceError?
+ // Should the catch { } declare error in the outer scope?
+ test(`
+ var error;
+ try {
+ abc();
+ }
+ catch (err) {
+ error = err;
+ }
+ [ error instanceof Error, error.message, error.def ];
+ `, "true,abcdef,")
+
+ vm.Set("def", func(call FunctionCall) Value {
+ call.Otto.Call(`throw new Object`, nil, 3.14159)
+ return UndefinedValue()
+ })
+ test(`
+ try {
+ def();
+ }
+ catch (err) {
+ error = err;
+ }
+ [ error instanceof Error, error.message, error.def, typeof error, error, error instanceof Number ];
+ `, "false,,,object,3.14159,true")
+ })
+}
+
+func TestOttoCopy(t *testing.T) {
+ tt(t, func() {
+ vm0 := New()
+ vm0.Run(`
+ var abc = function() {
+ return "Xyzzy";
+ };
+
+ function def() {
+ return abc() + (0 + {});
+ }
+ `)
+
+ value, err := vm0.Run(`
+ def();
+ `)
+ is(err, nil)
+ is(value, "Xyzzy0[object Object]")
+
+ vm1 := vm0.Copy()
+ value, err = vm1.Run(`
+ def();
+ `)
+ is(err, nil)
+ is(value, "Xyzzy0[object Object]")
+
+ vm1.Run(`
+ abc = function() {
+ return 3.14159;
+ };
+ `)
+ value, err = vm1.Run(`
+ def();
+ `)
+ is(err, nil)
+ is(value, "3.141590[object Object]")
+
+ value, err = vm0.Run(`
+ def();
+ `)
+ is(err, nil)
+ is(value, "Xyzzy0[object Object]")
+
+ {
+ vm0 := New()
+ vm0.Run(`
+ var global = (function () {return this;}())
+ var abc = 0;
+ var vm = "vm0";
+
+ var def = (function(){
+ var jkl = 0;
+ var abc = function() {
+ global.abc += 1;
+ jkl += 1;
+ return 1;
+ };
+
+ return function() {
+ return [ vm, global.abc, jkl, abc() ];
+ };
+ })();
+ `)
+
+ value, err := vm0.Run(`
+ def();
+ `)
+ is(err, nil)
+ is(value, "vm0,0,0,1")
+
+ vm1 := vm0.Copy()
+ vm1.Set("vm", "vm1")
+ value, err = vm1.Run(`
+ def();
+ `)
+ is(err, nil)
+ is(value, "vm1,1,1,1")
+
+ value, err = vm0.Run(`
+ def();
+ `)
+ is(err, nil)
+ is(value, "vm0,1,1,1")
+
+ value, err = vm1.Run(`
+ def();
+ `)
+ is(err, nil)
+ is(value, "vm1,2,2,1")
+ }
+ })
+}
+
+func TestOttoCall_clone(t *testing.T) {
+ tt(t, func() {
+ vm := New().clone()
+ rt := vm.runtime
+
+ {
+ // FIXME terst, Check how this comparison is done
+ is(rt.global.Array.prototype, rt.global.FunctionPrototype)
+ is(rt.global.ArrayPrototype, "!=", nil)
+ is(rt.global.Array.runtime, rt)
+ is(rt.global.Array.prototype.runtime, rt)
+ is(rt.global.Array.get("prototype")._object().runtime, rt)
+ }
+
+ {
+ value, err := vm.Run(`[ 1, 2, 3 ].toString()`)
+ is(err, nil)
+ is(value, "1,2,3")
+ }
+
+ {
+ value, err := vm.Run(`[ 1, 2, 3 ]`)
+ is(err, nil)
+ is(value, "1,2,3")
+ object := value._object()
+ is(object, "!=", nil)
+ is(object.prototype, rt.global.ArrayPrototype)
+
+ value, err = vm.Run(`Array.prototype`)
+ is(err, nil)
+ object = value._object()
+ is(object.runtime, rt)
+ is(object, "!=", nil)
+ is(object, rt.global.ArrayPrototype)
+ }
+
+ {
+ otto1 := New()
+ _, err := otto1.Run(`
+ var abc = 1;
+ var def = 2;
+ `)
+ is(err, nil)
+
+ otto2 := otto1.clone()
+ value, err := otto2.Run(`abc += 1; abc;`)
+ is(err, nil)
+ is(value, 2)
+
+ value, err = otto1.Run(`abc += 4; abc;`)
+ is(err, nil)
+ is(value, 5)
+ }
+
+ {
+ vm1 := New()
+ _, err := vm1.Run(`
+ var abc = 1;
+ var def = function(value) {
+ abc += value;
+ return abc;
+ }
+ `)
+ is(err, nil)
+
+ vm2 := vm1.clone()
+ value, err := vm2.Run(`def(1)`)
+ is(err, nil)
+ is(value, 2)
+
+ value, err = vm1.Run(`def(4)`)
+ is(err, nil)
+ is(value, 5)
+ }
+
+ {
+ vm1 := New()
+ _, err := vm1.Run(`
+ var abc = {
+ ghi: 1,
+ jkl: function(value) {
+ this.ghi += value;
+ return this.ghi;
+ }
+ };
+ var def = {
+ abc: abc
+ };
+ `)
+ is(err, nil)
+
+ otto2 := vm1.clone()
+ value, err := otto2.Run(`def.abc.jkl(1)`)
+ is(err, nil)
+ is(value, 2)
+
+ value, err = vm1.Run(`def.abc.jkl(4)`)
+ is(err, nil)
+ is(value, 5)
+ }
+
+ {
+ vm1 := New()
+ _, err := vm1.Run(`
+ var abc = function() { return "abc"; };
+ var def = function() { return "def"; };
+ `)
+ is(err, nil)
+
+ vm2 := vm1.clone()
+ value, err := vm2.Run(`
+ [ abc.toString(), def.toString() ];
+ `)
+ is(value, `function() { return "abc"; },function() { return "def"; }`)
+
+ _, err = vm2.Run(`
+ var def = function() { return "ghi"; };
+ `)
+ is(err, nil)
+
+ value, err = vm1.Run(`
+ [ abc.toString(), def.toString() ];
+ `)
+ is(value, `function() { return "abc"; },function() { return "def"; }`)
+
+ value, err = vm2.Run(`
+ [ abc.toString(), def.toString() ];
+ `)
+ is(value, `function() { return "abc"; },function() { return "ghi"; }`)
+ }
+
+ })
+}
+
+func TestOttoRun(t *testing.T) {
+ tt(t, func() {
+ vm := New()
+
+ program, err := parser.ParseFile(nil, "", "", 0)
+ is(err, nil)
+ value, err := vm.Run(program)
+ is(err, nil)
+ is(value, UndefinedValue())
+
+ program, err = parser.ParseFile(nil, "", "2 + 2", 0)
+ is(err, nil)
+ value, err = vm.Run(program)
+ is(err, nil)
+ is(value, 4)
+ value, err = vm.Run(program)
+ is(err, nil)
+ is(value, 4)
+
+ program, err = parser.ParseFile(nil, "", "var abc; if (!abc) abc = 0; abc += 2; abc;", 0)
+ value, err = vm.Run(program)
+ is(err, nil)
+ is(value, 2)
+ value, err = vm.Run(program)
+ is(err, nil)
+ is(value, 4)
+ value, err = vm.Run(program)
+ is(err, nil)
+ is(value, 6)
+
+ {
+ src := []byte("var abc; if (!abc) abc = 0; abc += 2; abc;")
+ value, err = vm.Run(src)
+ is(err, nil)
+ is(value, 8)
+
+ value, err = vm.Run(bytes.NewBuffer(src))
+ is(err, nil)
+ is(value, 10)
+
+ value, err = vm.Run(io.Reader(bytes.NewBuffer(src)))
+ is(err, nil)
+ is(value, 12)
+ }
+
+ {
+ script, err := vm.Compile("", `var abc; if (!abc) abc = 0; abc += 2; abc;`)
+ is(err, nil)
+
+ value, err = vm.Run(script)
+ is(err, nil)
+ is(value, 14)
+
+ value, err = vm.Run(script)
+ is(err, nil)
+ is(value, 16)
+
+ is(script.String(), "// \nvar abc; if (!abc) abc = 0; abc += 2; abc;")
+ }
+ })
+}
+
+func Test_objectLength(t *testing.T) {
+ tt(t, func() {
+ _, vm := test()
+
+ value := vm.Set("abc", []string{"jkl", "mno"})
+ is(objectLength(value._object()), 2)
+
+ value, _ = vm.Run(`[1, 2, 3]`)
+ is(objectLength(value._object()), 3)
+
+ value, _ = vm.Run(`new String("abcdefghi")`)
+ is(objectLength(value._object()), 9)
+
+ value, _ = vm.Run(`"abcdefghi"`)
+ is(objectLength(value._object()), 0)
+ })
+}
+
+func BenchmarkNew(b *testing.B) {
+ for i := 0; i < b.N; i++ {
+ New()
+ }
+}
+
+func BenchmarkClone(b *testing.B) {
+ vm := New()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ vm.clone()
+ }
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/panic_test.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/panic_test.go
new file mode 100644
index 000000000..06f0a64fc
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/panic_test.go
@@ -0,0 +1,40 @@
+package otto
+
+import (
+ "testing"
+)
+
+func Test_panic(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ // Test that property.value is set to something if writable is set
+ // to something
+ test(`
+ var abc = [];
+ Object.defineProperty(abc, "0", { writable: false });
+ Object.defineProperty(abc, "0", { writable: false });
+ "0" in abc;
+ `, true)
+
+ test(`raise:
+ var abc = [];
+ Object.defineProperty(abc, "0", { writable: false });
+ Object.defineProperty(abc, "0", { value: false, writable: false });
+ `, "TypeError")
+
+ // Test that a regular expression can contain \c0410 (CYRILLIC CAPITAL LETTER A)
+ // without panicking
+ test(`
+ var abc = 0x0410;
+ var def = String.fromCharCode(abc);
+ new RegExp("\\c" + def).exec(def);
+ `, "null")
+
+ // Test transforming a transformable regular expression without a panic
+ test(`
+ new RegExp("\\u0000");
+ new RegExp("\\undefined").test("undefined");
+ `, true)
+ })
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/parser_test.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/parser_test.go
new file mode 100644
index 000000000..7db43d239
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/parser_test.go
@@ -0,0 +1,42 @@
+package otto
+
+import (
+ "testing"
+)
+
+func TestPersistence(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ function abc() { return 1; }
+ abc.toString();
+ `, "function abc() { return 1; }")
+
+ test(`
+ function def() { return 3.14159; }
+ [ abc.toString(), def.toString() ];
+ `, "function abc() { return 1; },function def() { return 3.14159; }")
+
+ test(`
+ eval("function ghi() { return 'ghi' }");
+ [ abc.toString(), def.toString(), ghi.toString() ];
+ `, "function abc() { return 1; },function def() { return 3.14159; },function ghi() { return 'ghi' }")
+
+ test(`
+ [ abc.toString(), def.toString(), ghi.toString() ];
+ `, "function abc() { return 1; },function def() { return 3.14159; },function ghi() { return 'ghi' }")
+
+ test(`/*
+
+
+
+
+
+
+
+
+
+ */`, UndefinedValue())
+ })
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/property.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/property.go
new file mode 100644
index 000000000..5445eccde
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/property.go
@@ -0,0 +1,220 @@
+package otto
+
+// property
+
+type _propertyMode int
+
+const (
+ modeWriteMask _propertyMode = 0700
+ modeEnumerateMask = 0070
+ modeConfigureMask = 0007
+ modeOnMask = 0111
+ modeOffMask = 0000
+ modeSetMask = 0222 // If value is 2, then mode is neither "On" nor "Off"
+)
+
+type _propertyGetSet [2]*_object
+
+var _nilGetSetObject _object = _object{}
+
+type _property struct {
+ value interface{}
+ mode _propertyMode
+}
+
+func (self _property) writable() bool {
+ return self.mode&modeWriteMask == modeWriteMask&modeOnMask
+}
+
+func (self *_property) writeOn() {
+ self.mode = (self.mode & ^modeWriteMask) | (modeWriteMask & modeOnMask)
+}
+
+func (self *_property) writeOff() {
+ self.mode &= ^modeWriteMask
+}
+
+func (self *_property) writeClear() {
+ self.mode = (self.mode & ^modeWriteMask) | (modeWriteMask & modeSetMask)
+}
+
+func (self _property) writeSet() bool {
+ return 0 == self.mode&modeWriteMask&modeSetMask
+}
+
+func (self _property) enumerable() bool {
+ return self.mode&modeEnumerateMask == modeEnumerateMask&modeOnMask
+}
+
+func (self *_property) enumerateOn() {
+ self.mode = (self.mode & ^modeEnumerateMask) | (modeEnumerateMask & modeOnMask)
+}
+
+func (self *_property) enumerateOff() {
+ self.mode &= ^modeEnumerateMask
+}
+
+func (self _property) enumerateSet() bool {
+ return 0 == self.mode&modeEnumerateMask&modeSetMask
+}
+
+func (self _property) configurable() bool {
+ return self.mode&modeConfigureMask == modeConfigureMask&modeOnMask
+}
+
+func (self *_property) configureOn() {
+ self.mode = (self.mode & ^modeConfigureMask) | (modeConfigureMask & modeOnMask)
+}
+
+func (self *_property) configureOff() {
+ self.mode &= ^modeConfigureMask
+}
+
+func (self _property) configureSet() bool {
+ return 0 == self.mode&modeConfigureMask&modeSetMask
+}
+
+func (self _property) copy() *_property {
+ property := self
+ return &property
+}
+
+func (self _property) get(this *_object) Value {
+ switch value := self.value.(type) {
+ case Value:
+ return value
+ case _propertyGetSet:
+ if value[0] != nil {
+ return value[0].call(toValue(this), nil, false, nativeFrame)
+ }
+ }
+ return Value{}
+}
+
+func (self _property) isAccessorDescriptor() bool {
+ setGet, test := self.value.(_propertyGetSet)
+ return test && (setGet[0] != nil || setGet[1] != nil)
+}
+
+func (self _property) isDataDescriptor() bool {
+ if self.writeSet() { // Either "On" or "Off"
+ return true
+ }
+ value, valid := self.value.(Value)
+ return valid && !value.isEmpty()
+}
+
+func (self _property) isGenericDescriptor() bool {
+ return !(self.isDataDescriptor() || self.isAccessorDescriptor())
+}
+
+func (self _property) isEmpty() bool {
+ return self.mode == 0222 && self.isGenericDescriptor()
+}
+
+// _enumerableValue, _enumerableTrue, _enumerableFalse?
+// .enumerableValue() .enumerableExists()
+
+func toPropertyDescriptor(rt *_runtime, value Value) (descriptor _property) {
+ objectDescriptor := value._object()
+ if objectDescriptor == nil {
+ panic(rt.panicTypeError())
+ }
+
+ {
+ descriptor.mode = modeSetMask // Initially nothing is set
+ if objectDescriptor.hasProperty("enumerable") {
+ if objectDescriptor.get("enumerable").bool() {
+ descriptor.enumerateOn()
+ } else {
+ descriptor.enumerateOff()
+ }
+ }
+
+ if objectDescriptor.hasProperty("configurable") {
+ if objectDescriptor.get("configurable").bool() {
+ descriptor.configureOn()
+ } else {
+ descriptor.configureOff()
+ }
+ }
+
+ if objectDescriptor.hasProperty("writable") {
+ if objectDescriptor.get("writable").bool() {
+ descriptor.writeOn()
+ } else {
+ descriptor.writeOff()
+ }
+ }
+ }
+
+ var getter, setter *_object
+ getterSetter := false
+
+ if objectDescriptor.hasProperty("get") {
+ value := objectDescriptor.get("get")
+ if value.IsDefined() {
+ if !value.isCallable() {
+ panic(rt.panicTypeError())
+ }
+ getter = value._object()
+ getterSetter = true
+ } else {
+ getter = &_nilGetSetObject
+ getterSetter = true
+ }
+ }
+
+ if objectDescriptor.hasProperty("set") {
+ value := objectDescriptor.get("set")
+ if value.IsDefined() {
+ if !value.isCallable() {
+ panic(rt.panicTypeError())
+ }
+ setter = value._object()
+ getterSetter = true
+ } else {
+ setter = &_nilGetSetObject
+ getterSetter = true
+ }
+ }
+
+ if getterSetter {
+ if descriptor.writeSet() {
+ panic(rt.panicTypeError())
+ }
+ descriptor.value = _propertyGetSet{getter, setter}
+ }
+
+ if objectDescriptor.hasProperty("value") {
+ if getterSetter {
+ panic(rt.panicTypeError())
+ }
+ descriptor.value = objectDescriptor.get("value")
+ }
+
+ return
+}
+
+func (self *_runtime) fromPropertyDescriptor(descriptor _property) *_object {
+ object := self.newObject()
+ if descriptor.isDataDescriptor() {
+ object.defineProperty("value", descriptor.value.(Value), 0111, false)
+ object.defineProperty("writable", toValue_bool(descriptor.writable()), 0111, false)
+ } else if descriptor.isAccessorDescriptor() {
+ getSet := descriptor.value.(_propertyGetSet)
+ get := Value{}
+ if getSet[0] != nil {
+ get = toValue_object(getSet[0])
+ }
+ set := Value{}
+ if getSet[1] != nil {
+ set = toValue_object(getSet[1])
+ }
+ object.defineProperty("get", get, 0111, false)
+ object.defineProperty("set", set, 0111, false)
+ }
+ object.defineProperty("enumerable", toValue_bool(descriptor.enumerable()), 0111, false)
+ object.defineProperty("configurable", toValue_bool(descriptor.configurable()), 0111, false)
+ return object
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/reflect_test.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/reflect_test.go
new file mode 100644
index 000000000..e4e83adeb
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/reflect_test.go
@@ -0,0 +1,483 @@
+package otto
+
+import (
+ "math"
+ "reflect"
+ "testing"
+)
+
+type _abcStruct struct {
+ Abc bool
+ Def int
+ Ghi string
+ Jkl interface{}
+ Mno _mnoStruct
+ Pqr map[string]int8
+}
+
+func (abc _abcStruct) String() string {
+ return abc.Ghi
+}
+
+func (abc *_abcStruct) FuncPointer() string {
+ return "abc"
+}
+
+func (abc _abcStruct) Func() {
+ return
+}
+
+func (abc _abcStruct) FuncReturn1() string {
+ return "abc"
+}
+
+func (abc _abcStruct) FuncReturn2() (string, error) {
+ return "def", nil
+}
+
+func (abc _abcStruct) Func1Return1(a string) string {
+ return a
+}
+
+func (abc _abcStruct) Func2Return1(x, y string) string {
+ return x + y
+}
+
+func (abc _abcStruct) FuncEllipsis(xyz ...string) int {
+ return len(xyz)
+}
+
+func (abc _abcStruct) FuncReturnStruct() _mnoStruct {
+ return _mnoStruct{}
+}
+
+type _mnoStruct struct {
+ Ghi string
+}
+
+func (mno _mnoStruct) Func() string {
+ return "mno"
+}
+
+func TestReflect(t *testing.T) {
+ if true {
+ return
+ }
+ tt(t, func() {
+ // Testing dbgf
+ // These should panic
+ toValue("Xyzzy").toReflectValue(reflect.Ptr)
+ stringToReflectValue("Xyzzy", reflect.Ptr)
+ })
+}
+
+func Test_reflectStruct(t *testing.T) {
+ tt(t, func() {
+ test, vm := test()
+
+ // _abcStruct
+ {
+ abc := &_abcStruct{}
+ vm.Set("abc", abc)
+
+ test(`
+ [ abc.Abc, abc.Ghi ];
+ `, "false,")
+
+ abc.Abc = true
+ abc.Ghi = "Nothing happens."
+
+ test(`
+ [ abc.Abc, abc.Ghi ];
+ `, "true,Nothing happens.")
+
+ *abc = _abcStruct{}
+
+ test(`
+ [ abc.Abc, abc.Ghi ];
+ `, "false,")
+
+ abc.Abc = true
+ abc.Ghi = "Xyzzy"
+ vm.Set("abc", abc)
+
+ test(`
+ [ abc.Abc, abc.Ghi ];
+ `, "true,Xyzzy")
+
+ is(abc.Abc, true)
+ test(`
+ abc.Abc = false;
+ abc.Def = 451;
+ abc.Ghi = "Nothing happens.";
+ abc.abc = "Something happens.";
+ [ abc.Def, abc.abc ];
+ `, "451,Something happens.")
+ is(abc.Abc, false)
+ is(abc.Def, 451)
+ is(abc.Ghi, "Nothing happens.")
+
+ test(`
+ delete abc.Def;
+ delete abc.abc;
+ [ abc.Def, abc.abc ];
+ `, "451,")
+ is(abc.Def, 451)
+
+ test(`
+ abc.FuncPointer();
+ `, "abc")
+
+ test(`
+ abc.Func();
+ `, "undefined")
+
+ test(`
+ abc.FuncReturn1();
+ `, "abc")
+
+ test(`
+ abc.Func1Return1("abc");
+ `, "abc")
+
+ test(`
+ abc.Func2Return1("abc", "def");
+ `, "abcdef")
+
+ test(`
+ abc.FuncEllipsis("abc", "def", "ghi");
+ `, 3)
+
+ test(`raise:
+ abc.FuncReturn2();
+ `, "TypeError")
+
+ test(`
+ abc.FuncReturnStruct();
+ `, "[object Object]")
+
+ test(`
+ abc.FuncReturnStruct().Func();
+ `, "mno")
+ }
+ })
+}
+
+func Test_reflectMap(t *testing.T) {
+ tt(t, func() {
+ test, vm := test()
+
+ // map[string]string
+ {
+ abc := map[string]string{
+ "Xyzzy": "Nothing happens.",
+ "def": "1",
+ }
+ vm.Set("abc", abc)
+
+ test(`
+ abc.xyz = "pqr";
+ [ abc.Xyzzy, abc.def, abc.ghi ];
+ `, "Nothing happens.,1,")
+
+ is(abc["xyz"], "pqr")
+ }
+
+ // map[string]float64
+ {
+ abc := map[string]float64{
+ "Xyzzy": math.Pi,
+ "def": 1,
+ }
+ vm.Set("abc", abc)
+
+ test(`
+ abc.xyz = "pqr";
+ abc.jkl = 10;
+ [ abc.Xyzzy, abc.def, abc.ghi ];
+ `, "3.141592653589793,1,")
+
+ is(abc["xyz"], math.NaN())
+ is(abc["jkl"], float64(10))
+ }
+
+ // map[string]int32
+ {
+ abc := map[string]int32{
+ "Xyzzy": 3,
+ "def": 1,
+ }
+ vm.Set("abc", abc)
+
+ test(`
+ abc.xyz = "pqr";
+ abc.jkl = 10;
+ [ abc.Xyzzy, abc.def, abc.ghi ];
+ `, "3,1,")
+
+ is(abc["xyz"], 0)
+ is(abc["jkl"], int32(10))
+
+ test(`
+ delete abc["Xyzzy"];
+ `)
+
+ _, exists := abc["Xyzzy"]
+ is(exists, false)
+ is(abc["Xyzzy"], 0)
+ }
+
+ // map[int32]string
+ {
+ abc := map[int32]string{
+ 0: "abc",
+ 1: "def",
+ }
+ vm.Set("abc", abc)
+
+ test(`
+ abc[2] = "pqr";
+ //abc.jkl = 10;
+ abc[3] = 10;
+ [ abc[0], abc[1], abc[2], abc[3] ]
+ `, "abc,def,pqr,10")
+
+ is(abc[2], "pqr")
+ is(abc[3], "10")
+
+ test(`
+ delete abc[2];
+ `)
+
+ _, exists := abc[2]
+ is(exists, false)
+ }
+
+ })
+}
+
+func Test_reflectSlice(t *testing.T) {
+ tt(t, func() {
+ test, vm := test()
+
+ // []bool
+ {
+ abc := []bool{
+ false,
+ true,
+ true,
+ false,
+ }
+ vm.Set("abc", abc)
+
+ test(`
+ abc;
+ `, "false,true,true,false")
+
+ test(`
+ abc[0] = true;
+ abc[abc.length-1] = true;
+ delete abc[2];
+ abc;
+ `, "true,true,false,true")
+
+ is(abc, []bool{true, true, false, true})
+ is(abc[len(abc)-1], true)
+ }
+
+ // []int32
+ {
+ abc := make([]int32, 4)
+ vm.Set("abc", abc)
+
+ test(`
+ abc;
+ `, "0,0,0,0")
+
+ test(`
+ abc[0] = 4.2;
+ abc[1] = "42";
+ abc[2] = 3.14;
+ abc;
+ `, "4,42,3,0")
+
+ is(abc, []int32{4, 42, 3, 0})
+
+ test(`
+ delete abc[1];
+ delete abc[2];
+ `)
+ is(abc[1], 0)
+ is(abc[2], 0)
+ }
+ })
+}
+
+func Test_reflectArray(t *testing.T) {
+ tt(t, func() {
+ test, vm := test()
+
+ // []bool
+ {
+ abc := [4]bool{
+ false,
+ true,
+ true,
+ false,
+ }
+ vm.Set("abc", abc)
+
+ test(`
+ abc;
+ `, "false,true,true,false")
+ // Unaddressable array
+
+ test(`
+ abc[0] = true;
+ abc[abc.length-1] = true;
+ abc;
+ `, "false,true,true,false")
+ // Again, unaddressable array
+
+ is(abc, [4]bool{false, true, true, false})
+ is(abc[len(abc)-1], false)
+ // ...
+ }
+
+ // []int32
+ {
+ abc := make([]int32, 4)
+ vm.Set("abc", abc)
+
+ test(`
+ abc;
+ `, "0,0,0,0")
+
+ test(`
+ abc[0] = 4.2;
+ abc[1] = "42";
+ abc[2] = 3.14;
+ abc;
+ `, "4,42,3,0")
+
+ is(abc, []int32{4, 42, 3, 0})
+ }
+
+ // []bool
+ {
+ abc := [4]bool{
+ false,
+ true,
+ true,
+ false,
+ }
+ vm.Set("abc", &abc)
+
+ test(`
+ abc;
+ `, "false,true,true,false")
+
+ test(`
+ abc[0] = true;
+ abc[abc.length-1] = true;
+ delete abc[2];
+ abc;
+ `, "true,true,false,true")
+
+ is(abc, [4]bool{true, true, false, true})
+ is(abc[len(abc)-1], true)
+ }
+
+ })
+}
+
+func Test_reflectArray_concat(t *testing.T) {
+ tt(t, func() {
+ test, vm := test()
+
+ vm.Set("ghi", []string{"jkl", "mno"})
+ vm.Set("pqr", []interface{}{"jkl", 42, 3.14159, true})
+ test(`
+ var def = {
+ "abc": ["abc"],
+ "xyz": ["xyz"]
+ };
+ xyz = pqr.concat(ghi, def.abc, def, def.xyz);
+ [ xyz, xyz.length ];
+ `, "jkl,42,3.14159,true,jkl,mno,abc,[object Object],xyz,9")
+ })
+}
+
+func Test_reflectMapInterface(t *testing.T) {
+ tt(t, func() {
+ test, vm := test()
+
+ {
+ abc := map[string]interface{}{
+ "Xyzzy": "Nothing happens.",
+ "def": "1",
+ "jkl": "jkl",
+ }
+ vm.Set("abc", abc)
+ vm.Set("mno", &_abcStruct{})
+
+ test(`
+ abc.xyz = "pqr";
+ abc.ghi = {};
+ abc.jkl = 3.14159;
+ abc.mno = mno;
+ mno.Abc = true;
+ mno.Ghi = "Something happens.";
+ [ abc.Xyzzy, abc.def, abc.ghi, abc.mno ];
+ `, "Nothing happens.,1,[object Object],[object Object]")
+
+ is(abc["xyz"], "pqr")
+ is(abc["ghi"], "[object Object]")
+ is(abc["jkl"], float64(3.14159))
+ mno, valid := abc["mno"].(*_abcStruct)
+ is(valid, true)
+ is(mno.Abc, true)
+ is(mno.Ghi, "Something happens.")
+ }
+ })
+}
+
+func TestPassthrough(t *testing.T) {
+ tt(t, func() {
+ test, vm := test()
+
+ {
+ abc := &_abcStruct{
+ Mno: _mnoStruct{
+ Ghi: "<Mno.Ghi>",
+ },
+ }
+ vm.Set("abc", abc)
+
+ test(`
+ abc.Mno.Ghi;
+ `, "<Mno.Ghi>")
+
+ vm.Set("pqr", map[string]int8{
+ "xyzzy": 0,
+ "Nothing happens.": 1,
+ })
+
+ test(`
+ abc.Ghi = "abc";
+ abc.Pqr = pqr;
+ abc.Pqr["Nothing happens."];
+ `, 1)
+
+ mno := _mnoStruct{
+ Ghi: "<mno.Ghi>",
+ }
+ vm.Set("mno", mno)
+
+ test(`
+ abc.Mno = mno;
+ abc.Mno.Ghi;
+ `, "<mno.Ghi>")
+ }
+ })
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/regexp_test.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/regexp_test.go
new file mode 100644
index 000000000..8e65ee46a
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/regexp_test.go
@@ -0,0 +1,290 @@
+package otto
+
+import (
+ "fmt"
+ "testing"
+)
+
+func TestRegExp(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ [
+ /abc/.toString(),
+ /abc/gim.toString(),
+ ""+/abc/gi.toString(),
+ new RegExp("1(\\d+)").toString(),
+ ];
+ `, "/abc/,/abc/gim,/abc/gi,/1(\\d+)/")
+
+ test(`
+ [
+ new RegExp("abc").exec("123abc456"),
+ null === new RegExp("xyzzy").exec("123abc456"),
+ new RegExp("1(\\d+)").exec("123abc456"),
+ new RegExp("xyzzy").test("123abc456"),
+ new RegExp("1(\\d+)").test("123abc456"),
+ new RegExp("abc").exec("123abc456"),
+ ];
+ `, "abc,true,123,23,false,true,abc")
+
+ test(`new RegExp("abc").toString()`, "/abc/")
+ test(`new RegExp("abc", "g").toString()`, "/abc/g")
+ test(`new RegExp("abc", "mig").toString()`, "/abc/gim")
+
+ result := test(`/(a)?/.exec('b')`, ",")
+ is(result._object().get("0"), "")
+ is(result._object().get("1"), "undefined")
+ is(result._object().get("length"), 2)
+
+ result = test(`/(a)?(b)?/.exec('b')`, "b,,b")
+ is(result._object().get("0"), "b")
+ is(result._object().get("1"), "undefined")
+ is(result._object().get("2"), "b")
+ is(result._object().get("length"), 3)
+
+ test(`/\u0041/.source`, "\\u0041")
+ test(`/\a/.source`, "\\a")
+ test(`/\;/.source`, "\\;")
+
+ test(`/a\a/.source`, "a\\a")
+ test(`/,\;/.source`, ",\\;")
+ test(`/ \ /.source`, " \\ ")
+
+ // Start sanity check...
+ test("eval(\"/abc/\").source", "abc")
+ test("eval(\"/\u0023/\").source", "#")
+ test("eval(\"/\u0058/\").source", "X")
+ test("eval(\"/\\\u0023/\").source == \"\\\u0023\"", true)
+ test("'0x' + '0058'", "0x0058")
+ test("'\\\\' + '0x' + '0058'", "\\0x0058")
+ // ...stop sanity check
+
+ test(`abc = '\\' + String.fromCharCode('0x' + '0058'); eval('/' + abc + '/').source`, "\\X")
+ test(`abc = '\\' + String.fromCharCode('0x0058'); eval('/' + abc + '/').source == "\\\u0058"`, true)
+ test(`abc = '\\' + String.fromCharCode('0x0023'); eval('/' + abc + '/').source == "\\\u0023"`, true)
+ test(`abc = '\\' + String.fromCharCode('0x0078'); eval('/' + abc + '/').source == "\\\u0078"`, true)
+
+ test(`
+ var abc = Object.getOwnPropertyDescriptor(RegExp, "prototype");
+ [ [ typeof RegExp.prototype ],
+ [ abc.writable, abc.enumerable, abc.configurable ] ];
+ `, "object,false,false,false")
+ })
+}
+
+func TestRegExp_global(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ var abc = /(?:ab|cd)\d?/g;
+ var found = [];
+ do {
+ match = abc.exec("ab cd2 ab34 cd");
+ if (match !== null) {
+ found.push(match[0]);
+ } else {
+ break;
+ }
+ } while (true);
+ found;
+ `, "ab,cd2,ab3,cd")
+ })
+}
+
+func TestRegExp_exec(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ abc = /./g;
+ def = '123456';
+ ghi = 0;
+ while (ghi < 100 && abc.exec(def) !== null) {
+ ghi += 1;
+ }
+ [ ghi, def.length, ghi == def.length ];
+ `, "6,6,true")
+
+ test(`
+ abc = /[abc](\d)?/g;
+ def = 'a0 b c1 d3';
+ ghi = 0;
+ lastIndex = 0;
+ while (ghi < 100 && abc.exec(def) !== null) {
+ lastIndex = abc.lastIndex;
+ ghi += 1;
+
+ }
+ [ ghi, lastIndex ];
+ `, "3,7")
+
+ test(`
+ var abc = /[abc](\d)?/.exec("a0 b c1 d3");
+ [ abc.length, abc.input, abc.index, abc ];
+ `, "2,a0 b c1 d3,0,a0,0")
+
+ test(`raise:
+ var exec = RegExp.prototype.exec;
+ exec("Xyzzy");
+ `, "TypeError: Calling RegExp.exec on a non-RegExp object")
+
+ test(`
+ var abc = /\w{3}\d?/.exec("CE\uFFFFL\uFFDDbox127");
+ [ abc.input.length, abc.length, abc.input, abc.index, abc ];
+ `, "11,1,CE\uFFFFL\uFFDDbox127,5,box1")
+
+ test(`RegExp.prototype.exec.length`, 1)
+ test(`RegExp.prototype.exec.prototype`, "undefined")
+ })
+}
+
+func TestRegExp_test(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`RegExp.prototype.test.length`, 1)
+ test(`RegExp.prototype.test.prototype`, "undefined")
+ })
+}
+
+func TestRegExp_toString(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`RegExp.prototype.toString.length`, 0)
+ test(`RegExp.prototype.toString.prototype`, "undefined")
+ })
+}
+
+func TestRegExp_zaacbbbcac(t *testing.T) {
+ if true {
+ return
+ }
+
+ tt(t, func() {
+ test, _ := test()
+
+ // FIXME? TODO /(z)((a+)?(b+)?(c))*/.exec("zaacbbbcac")
+ test(`
+ var abc = /(z)((a+)?(b+)?(c))*/.exec("zaacbbbcac");
+ [ abc.length, abc.index, abc ];
+ `, "6,0,zaacbbbcac,z,ac,a,,c")
+ })
+}
+
+func TestRegExpCopying(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ abc = /xyzzy/i;
+ def = RegExp(abc);
+ abc.indicator = 1;
+ [ abc.indicator, def.indicator ];
+ `, "1,1")
+
+ test(`raise:
+ RegExp(new RegExp("\\d"), "1");
+ `, "TypeError: Cannot supply flags when constructing one RegExp from another")
+ })
+}
+
+func TestRegExp_multiline(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ var abc = /s$/m.exec("pairs\nmakes\tdouble");
+ [ abc.length, abc.index, abc ];
+ `, "1,4,s")
+ })
+}
+
+func TestRegExp_source(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ [ /xyzzy/i.source, /./i.source ];
+ `, "xyzzy,.")
+
+ test(`
+ var abc = /./i;
+ var def = new RegExp(abc);
+ [ abc.source, def.source, abc.source === def.source ];
+ `, ".,.,true")
+
+ test(`
+ var abc = /./i;
+ var def = abc.hasOwnProperty("source");
+ var ghi = abc.source;
+ abc.source = "xyzzy";
+ [ def, abc.source ];
+ `, "true,.")
+ })
+}
+
+func TestRegExp_newRegExp(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ Math.toString();
+ var abc = new RegExp(Math,eval("\"g\""));
+ [ abc, abc.global ];
+ `, "/[object Math]/g,true")
+ })
+}
+
+func TestRegExp_flags(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ var abc = /./i;
+ var def = new RegExp(abc);
+ [ abc.multiline == def.multiline, abc.global == def.global, abc.ignoreCase == def.ignoreCase ];
+ `, "true,true,true")
+ })
+}
+
+func TestRegExp_controlCharacter(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ for code := 0x41; code < 0x5a; code++ {
+ string_ := string(code - 64)
+ test(fmt.Sprintf(`
+ var code = 0x%x;
+ var string = String.fromCharCode(code %% 32);
+ var result = (new RegExp("\\c" + String.fromCharCode(code))).exec(string);
+ [ code, string, result ];
+ `, code), fmt.Sprintf("%d,%s,%s", code, string_, string_))
+ }
+ })
+}
+
+func TestRegExp_notNotEmptyCharacterClass(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ var abc = /[\s\S]a/m.exec("a\naba");
+ [ abc.length, abc.input, abc ];
+ `, "1,a\naba,\na")
+ })
+}
+
+func TestRegExp_compile(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ var abc = /[\s\S]a/;
+ abc.compile('^\w+');
+ `, "undefined")
+ })
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/result.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/result.go
new file mode 100644
index 000000000..63642e7d0
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/result.go
@@ -0,0 +1,30 @@
+package otto
+
+import ()
+
+type _resultKind int
+
+const (
+ resultNormal _resultKind = iota
+ resultReturn
+ resultBreak
+ resultContinue
+)
+
+type _result struct {
+ kind _resultKind
+ value Value
+ target string
+}
+
+func newReturnResult(value Value) _result {
+ return _result{resultReturn, value, ""}
+}
+
+func newContinueResult(target string) _result {
+ return _result{resultContinue, emptyValue, target}
+}
+
+func newBreakResult(target string) _result {
+ return _result{resultBreak, emptyValue, target}
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/runtime.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/runtime.go
new file mode 100644
index 000000000..1ac1b435e
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/runtime.go
@@ -0,0 +1,331 @@
+package otto
+
+import (
+ "errors"
+ "reflect"
+ "sync"
+
+ "github.com/robertkrimen/otto/ast"
+ "github.com/robertkrimen/otto/parser"
+)
+
+type _global struct {
+ Object *_object // Object( ... ), new Object( ... ) - 1 (length)
+ Function *_object // Function( ... ), new Function( ... ) - 1
+ Array *_object // Array( ... ), new Array( ... ) - 1
+ String *_object // String( ... ), new String( ... ) - 1
+ Boolean *_object // Boolean( ... ), new Boolean( ... ) - 1
+ Number *_object // Number( ... ), new Number( ... ) - 1
+ Math *_object
+ Date *_object // Date( ... ), new Date( ... ) - 7
+ RegExp *_object // RegExp( ... ), new RegExp( ... ) - 2
+ Error *_object // Error( ... ), new Error( ... ) - 1
+ EvalError *_object
+ TypeError *_object
+ RangeError *_object
+ ReferenceError *_object
+ SyntaxError *_object
+ URIError *_object
+ JSON *_object
+
+ ObjectPrototype *_object // Object.prototype
+ FunctionPrototype *_object // Function.prototype
+ ArrayPrototype *_object // Array.prototype
+ StringPrototype *_object // String.prototype
+ BooleanPrototype *_object // Boolean.prototype
+ NumberPrototype *_object // Number.prototype
+ DatePrototype *_object // Date.prototype
+ RegExpPrototype *_object // RegExp.prototype
+ ErrorPrototype *_object // Error.prototype
+ EvalErrorPrototype *_object
+ TypeErrorPrototype *_object
+ RangeErrorPrototype *_object
+ ReferenceErrorPrototype *_object
+ SyntaxErrorPrototype *_object
+ URIErrorPrototype *_object
+}
+
+type _runtime struct {
+ global _global
+ globalObject *_object
+ globalStash *_objectStash
+ scope *_scope
+ otto *Otto
+ eval *_object // The builtin eval, for determine indirect versus direct invocation
+
+ labels []string // FIXME
+ lck sync.Mutex
+}
+
+func (self *_runtime) enterScope(scope *_scope) {
+ scope.outer = self.scope
+ self.scope = scope
+}
+
+func (self *_runtime) leaveScope() {
+ self.scope = self.scope.outer
+}
+
+// FIXME This is used in two places (cloning)
+func (self *_runtime) enterGlobalScope() {
+ self.enterScope(newScope(self.globalStash, self.globalStash, self.globalObject))
+}
+
+func (self *_runtime) enterFunctionScope(outer _stash, this Value) *_fnStash {
+ if outer == nil {
+ outer = self.globalStash
+ }
+ stash := self.newFunctionStash(outer)
+ var thisObject *_object
+ switch this.kind {
+ case valueUndefined, valueNull:
+ thisObject = self.globalObject
+ default:
+ thisObject = self.toObject(this)
+ }
+ self.enterScope(newScope(stash, stash, thisObject))
+ return stash
+}
+
+func (self *_runtime) putValue(reference _reference, value Value) {
+ name := reference.putValue(value)
+ if name != "" {
+ // Why? -- If reference.base == nil
+ // strict = false
+ self.globalObject.defineProperty(name, value, 0111, false)
+ }
+}
+
+func (self *_runtime) tryCatchEvaluate(inner func() Value) (tryValue Value, exception bool) {
+ // resultValue = The value of the block (e.g. the last statement)
+ // throw = Something was thrown
+ // throwValue = The value of what was thrown
+ // other = Something that changes flow (return, break, continue) that is not a throw
+ // Otherwise, some sort of unknown panic happened, we'll just propagate it
+ defer func() {
+ if caught := recover(); caught != nil {
+ if exception, ok := caught.(*_exception); ok {
+ caught = exception.eject()
+ }
+ switch caught := caught.(type) {
+ case _error:
+ exception = true
+ tryValue = toValue_object(self.newError(caught.name, caught.messageValue()))
+ case Value:
+ exception = true
+ tryValue = caught
+ default:
+ panic(caught)
+ }
+ }
+ }()
+
+ tryValue = inner()
+ return
+}
+
+// toObject
+
+func (self *_runtime) toObject(value Value) *_object {
+ switch value.kind {
+ case valueEmpty, valueUndefined, valueNull:
+ panic(self.panicTypeError())
+ case valueBoolean:
+ return self.newBoolean(value)
+ case valueString:
+ return self.newString(value)
+ case valueNumber:
+ return self.newNumber(value)
+ case valueObject:
+ return value._object()
+ }
+ panic(self.panicTypeError())
+}
+
+func (self *_runtime) objectCoerce(value Value) (*_object, error) {
+ switch value.kind {
+ case valueUndefined:
+ return nil, errors.New("undefined")
+ case valueNull:
+ return nil, errors.New("null")
+ case valueBoolean:
+ return self.newBoolean(value), nil
+ case valueString:
+ return self.newString(value), nil
+ case valueNumber:
+ return self.newNumber(value), nil
+ case valueObject:
+ return value._object(), nil
+ }
+ panic(self.panicTypeError())
+}
+
+func checkObjectCoercible(rt *_runtime, value Value) {
+ isObject, mustCoerce := testObjectCoercible(value)
+ if !isObject && !mustCoerce {
+ panic(rt.panicTypeError())
+ }
+}
+
+// testObjectCoercible
+
+func testObjectCoercible(value Value) (isObject bool, mustCoerce bool) {
+ switch value.kind {
+ case valueReference, valueEmpty, valueNull, valueUndefined:
+ return false, false
+ case valueNumber, valueString, valueBoolean:
+ isObject = false
+ mustCoerce = true
+ case valueObject:
+ isObject = true
+ mustCoerce = false
+ }
+ return
+}
+
+func (self *_runtime) safeToValue(value interface{}) (Value, error) {
+ result := Value{}
+ err := catchPanic(func() {
+ result = self.toValue(value)
+ })
+ return result, err
+}
+
+func (self *_runtime) toValue(value interface{}) Value {
+ switch value := value.(type) {
+ case Value:
+ return value
+ case func(FunctionCall) Value:
+ return toValue_object(self.newNativeFunction("", value))
+ case _nativeFunction:
+ return toValue_object(self.newNativeFunction("", value))
+ case Object, *Object, _object, *_object:
+ // Nothing happens.
+ // FIXME We should really figure out what can come here.
+ // This catch-all is ugly.
+ default:
+ {
+ value := reflect.ValueOf(value)
+ switch value.Kind() {
+ case reflect.Ptr:
+ switch reflect.Indirect(value).Kind() {
+ case reflect.Struct:
+ return toValue_object(self.newGoStructObject(value))
+ case reflect.Array:
+ return toValue_object(self.newGoArray(value))
+ }
+ case reflect.Func:
+ // TODO Maybe cache this?
+ return toValue_object(self.newNativeFunction("", func(call FunctionCall) Value {
+ in := make([]reflect.Value, len(call.ArgumentList))
+ for i, value := range call.ArgumentList {
+ in[i] = reflect.ValueOf(value.export())
+ }
+
+ out := value.Call(in)
+ if len(out) == 1 {
+ return self.toValue(out[0].Interface())
+ } else if len(out) == 0 {
+ return Value{}
+ }
+
+ panic(call.runtime.panicTypeError())
+ }))
+ case reflect.Struct:
+ return toValue_object(self.newGoStructObject(value))
+ case reflect.Map:
+ return toValue_object(self.newGoMapObject(value))
+ case reflect.Slice:
+ return toValue_object(self.newGoSlice(value))
+ case reflect.Array:
+ return toValue_object(self.newGoArray(value))
+ }
+ }
+ }
+ return toValue(value)
+}
+
+func (runtime *_runtime) newGoSlice(value reflect.Value) *_object {
+ self := runtime.newGoSliceObject(value)
+ self.prototype = runtime.global.ArrayPrototype
+ return self
+}
+
+func (runtime *_runtime) newGoArray(value reflect.Value) *_object {
+ self := runtime.newGoArrayObject(value)
+ self.prototype = runtime.global.ArrayPrototype
+ return self
+}
+
+func (runtime *_runtime) parse(filename string, src interface{}) (*ast.Program, error) {
+ return parser.ParseFile(nil, filename, src, 0)
+}
+
+func (runtime *_runtime) cmpl_parse(filename string, src interface{}) (*_nodeProgram, error) {
+ program, err := parser.ParseFile(nil, filename, src, 0)
+ if err != nil {
+ return nil, err
+ }
+ return cmpl_parse(program), nil
+}
+
+func (self *_runtime) parseSource(src interface{}) (*_nodeProgram, *ast.Program, error) {
+ switch src := src.(type) {
+ case *ast.Program:
+ return nil, src, nil
+ case *Script:
+ return src.program, nil, nil
+ }
+ program, err := self.parse("", src)
+ return nil, program, err
+}
+
+func (self *_runtime) cmpl_run(src interface{}) (Value, error) {
+ result := Value{}
+ cmpl_program, program, err := self.parseSource(src)
+ if err != nil {
+ return result, err
+ }
+ if cmpl_program == nil {
+ cmpl_program = cmpl_parse(program)
+ }
+ err = catchPanic(func() {
+ result = self.cmpl_evaluate_nodeProgram(cmpl_program, false)
+ })
+ switch result.kind {
+ case valueEmpty:
+ result = Value{}
+ case valueReference:
+ result = result.resolve()
+ }
+ return result, err
+}
+
+func (self *_runtime) parseThrow(err error) {
+ if err == nil {
+ return
+ }
+ switch err := err.(type) {
+ case parser.ErrorList:
+ {
+ err := err[0]
+ if err.Message == "Invalid left-hand side in assignment" {
+ panic(self.panicReferenceError(err.Message))
+ }
+ panic(self.panicSyntaxError(err.Message))
+ }
+ }
+ panic(self.panicSyntaxError(err.Error()))
+}
+
+func (self *_runtime) parseOrThrow(source string) *ast.Program {
+ program, err := self.parse("", source)
+ self.parseThrow(err) // Will panic/throw appropriately
+ return program
+}
+
+func (self *_runtime) cmpl_parseOrThrow(source string) *_nodeProgram {
+ program, err := self.cmpl_parse("", source)
+ self.parseThrow(err) // Will panic/throw appropriately
+ return program
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/runtime_test.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/runtime_test.go
new file mode 100644
index 000000000..2510a0b3f
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/runtime_test.go
@@ -0,0 +1,778 @@
+package otto
+
+import (
+ "math"
+ "testing"
+)
+
+// FIXME terst, Review tests
+
+func TestOperator(t *testing.T) {
+ tt(t, func() {
+ test, vm := test()
+
+ test("xyzzy = 1")
+ test("xyzzy", 1)
+
+ if true {
+ vm.Set("twoPlusTwo", func(FunctionCall) Value {
+ return toValue(5)
+ })
+ test("twoPlusTwo( 1 )", 5)
+
+ test("1 + twoPlusTwo( 1 )", 6)
+
+ test("-1 + twoPlusTwo( 1 )", 4)
+ }
+
+ test("result = 4")
+ test("result", 4)
+
+ test("result += 1")
+ test("result", 5)
+
+ test("result *= 2")
+ test("result", 10)
+
+ test("result /= 2")
+ test("result", 5)
+
+ test("result = 112.51 % 3.1")
+ test("result", 0.9100000000000019)
+
+ test("result = 'Xyzzy'")
+ test("result", "Xyzzy")
+
+ test("result = 'Xyz' + 'zy'")
+ test("result", "Xyzzy")
+
+ test("result = \"Xyzzy\"")
+ test("result", "Xyzzy")
+
+ test("result = 1; result = result")
+ test("result", 1)
+
+ test(`
+ var result64
+ =
+ 64
+ , result10 =
+ 10
+ `)
+ test("result64", 64)
+ test("result10", 10)
+
+ test(`
+ result = 1;
+ result += 1;
+ `)
+ test("result", 2)
+ })
+}
+
+func TestFunction_(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ result = 2
+ xyzzy = function() {
+ result += 1
+ }
+ xyzzy()
+ result;
+ `, 3)
+
+ test(`
+ xyzzy = function() {
+ return 1
+ }
+ result = xyzzy()
+ `, 1)
+
+ test(`
+ xyzzy = function() {}
+ result = xyzzy()
+ `, "undefined")
+
+ test(`
+ xyzzy = function() {
+ return 64
+ return 1
+ }
+ result = xyzzy()
+ `, 64)
+
+ test(`
+ result = 4
+ xyzzy = function() {
+ result = 2
+ }
+ xyzzy();
+ result;
+ `, 2)
+
+ test(`
+ result = 4
+ xyzzy = function() {
+ var result
+ result = 2
+ }
+ xyzzy();
+ result;
+ `, 4)
+
+ test(`
+ xyzzy = function() {
+ var result = 4
+ return result
+ }
+ result = xyzzy()
+ `, 4)
+
+ test(`
+ xyzzy = function() {
+ function test() {
+ var result = 1
+ return result
+ }
+ return test() + 1
+ }
+ result = xyzzy() + 1
+ `, 3)
+
+ test(`
+ xyzzy = function() {
+ function test() {
+ var result = 1
+ return result
+ }
+ _xyzzy = 2
+ var result = _xyzzy + test() + 1
+ return result
+ }
+ result = xyzzy() + 1;
+ [ result, _xyzzy ];
+ `, "5,2")
+
+ test(`
+ xyzzy = function(apple) {
+ return 1
+ }
+ result = xyzzy(1)
+ `, 1)
+
+ test(`
+ xyzzy = function(apple) {
+ return apple + 1
+ }
+ result = xyzzy(2)
+ `, 3)
+
+ test(`
+ {
+ result = 1
+ result += 1;
+ }
+ `, 2)
+
+ test(`
+ var global = 1
+ outer = function() {
+ var global = 2
+ var inner = function(){
+ return global
+ }
+ return inner()
+ }
+ result = outer()
+ `, 2)
+
+ test(`
+ var apple = 1
+ var banana = function() {
+ return apple
+ }
+ var cherry = function() {
+ var apple = 2
+ return banana()
+ }
+ result = cherry()
+ `, 1)
+
+ test(`
+ function xyz() {
+ };
+ delete xyz;
+ `, false)
+
+ test(`
+ var abc = function __factorial(def){
+ if (def === 1) {
+ return def;
+ } else {
+ return __factorial(def-1)*def;
+ }
+ };
+ abc(3);
+ `, 6)
+ })
+}
+
+func TestDoWhile(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ limit = 4;
+ result = 0;
+ do {
+ result = result + 1;
+ limit = limit - 1;
+ } while (limit);
+ result;
+ `, 4)
+
+ test(`
+ result = eval("do {abc=1; break; abc=2;} while (0);");
+ [ result, abc ];
+ `, "1,1")
+ })
+}
+
+func TestContinueBreak(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ limit = 4
+ result = 0
+ while (limit) {
+ limit = limit - 1
+ if (limit) {
+ }
+ else {
+ break
+ }
+ result = result + 1
+ }
+ [ result, limit ];
+ `, "3,0")
+
+ test(`
+ limit = 4
+ result = 0
+ while (limit) {
+ limit = limit - 1
+ if (limit) {
+ continue
+ }
+ else {
+ break
+ }
+ result = result + 1
+ }
+ result;
+ `, 0)
+
+ test(`
+ limit = 4
+ result = 0
+ do {
+ limit = limit - 1
+ if (limit) {
+ continue
+ }
+ else {
+ break
+ }
+ result = result + 1
+ } while (limit)
+ result;
+ `, 0)
+ })
+}
+
+func TestTryCatchError(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ var abc
+ try {
+ 1()
+ }
+ catch (def) {
+ abc = def
+ }
+ abc;
+ `, "TypeError: 1 is not a function")
+
+ })
+}
+
+func TestPositiveNegativeZero(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`1/0`, _Infinity)
+ test(`1/-0`, -_Infinity)
+ test(`
+ abc = -0
+ 1/abc
+ `, -_Infinity)
+ })
+}
+
+func TestComparison(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ undefined = 1; undefined;
+ `, "undefined")
+
+ test("undefined == undefined", true)
+
+ test("undefined != undefined", false)
+
+ test("null == null", true)
+
+ test("null != null", false)
+
+ test("0 == 1", false)
+
+ is(negativeZero(), -0)
+ is(positiveZero(), 0)
+ is(math.Signbit(negativeZero()), true)
+ is(positiveZero() == negativeZero(), true)
+
+ test("1 == 1", true)
+
+ test("'Hello, World.' == 'Goodbye, World.'", false)
+
+ test("'Hello, World.' == true", false)
+
+ test("'Hello, World.' == false", false)
+
+ test("'Hello, World.' == 1", false)
+
+ test("1 == 'Hello, World.'", false)
+
+ is(parseNumber("-1"), -1)
+
+ test("0+Object", "0function Object() { [native code] }")
+ })
+}
+
+func TestComparisonRelational(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test("0 < 0", false)
+
+ test("0 > 0", false)
+
+ test("0 <= 0", true)
+
+ test("0 >= 0", true)
+
+ test("' 0' >= 0", true)
+
+ test("'_ 0' >= 0", false)
+ })
+}
+
+func TestArguments(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ xyzzy = function() {
+ return arguments[0]
+ }
+ result = xyzzy("xyzzy");
+ `, "xyzzy")
+
+ test(`
+ xyzzy = function() {
+ arguments[0] = "abcdef"
+ return arguments[0]
+ }
+ result = xyzzy("xyzzy");
+ `, "abcdef")
+
+ test(`
+ xyzzy = function(apple) {
+ apple = "abcdef"
+ return arguments[0]
+ }
+ result = xyzzy("xyzzy");
+ `, "abcdef")
+
+ test(`
+ (function(){
+ return arguments
+ })()
+ `, "[object Arguments]")
+
+ test(`
+ (function(){
+ return arguments.length
+ })()
+ `, 0)
+
+ test(`
+ (function(){
+ return arguments.length
+ })(1, 2, 4, 8, 10)
+ `, 5)
+ })
+}
+
+func TestObjectLiteral(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ ({});
+ `, "[object Object]")
+
+ test(`
+ var abc = {
+ xyzzy: "Nothing happens.",
+ get 1e2() {
+ return 3.14159;
+ },
+ get null() {
+ return true;
+ },
+ get "[\n]"() {
+ return "<>";
+ }
+ };
+ [ abc["1e2"], abc.null, abc["[\n]"] ];
+ `, "3.14159,true,<>")
+
+ test(`
+ var abc = {
+ xyzzy: "Nothing happens.",
+ set 1e2() {
+ this[3.14159] = 100;
+ return Math.random();
+ },
+ set null(def) {
+ this.def = def;
+ return Math.random();
+ },
+ };
+ [ abc["1e2"] = Infinity, abc[3.14159], abc.null = "xyz", abc.def ];
+ `, "Infinity,100,xyz,xyz")
+ })
+}
+
+func TestUnaryPrefix(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ var result = 0;
+ [++result, result];
+ `, "1,1")
+
+ test(`
+ result = 0;
+ [--result, result];
+ `, "-1,-1")
+
+ test(`
+ var object = { valueOf: function() { return 1; } };
+ result = ++object;
+ [ result, typeof result ];
+ `, "2,number")
+
+ test(`
+ var object = { valueOf: function() { return 1; } };
+ result = --object;
+ [ result, typeof result ];
+ `, "0,number")
+ })
+}
+
+func TestUnaryPostfix(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ var result = 0;
+ result++;
+ [ result++, result ];
+ `, "1,2")
+
+ test(`
+ result = 0;
+ result--;
+ [ result--, result ];
+ `, "-1,-2")
+
+ test(`
+ var object = { valueOf: function() { return 1; } };
+ result = object++;
+ [ result, typeof result ];
+ `, "1,number")
+
+ test(`
+ var object = { valueOf: function() { return 1; } };
+ result = object--
+ [ result, typeof result ];
+ `, "1,number")
+ })
+}
+
+func TestBinaryLogicalOperation(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ abc = true
+ def = false
+ ghi = false
+ jkl = false
+ result = abc && def || ghi && jkl
+ `, false)
+
+ test(`
+ abc = true
+ def = true
+ ghi = false
+ jkl = false
+ result = abc && def || ghi && jkl
+ `, true)
+
+ })
+}
+
+func TestBinaryBitwiseOperation(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ abc = 1 & 2;
+ def = 1 & 3;
+ ghi = 1 | 3;
+ jkl = 1 ^ 2;
+ mno = 1 ^ 3;
+ [ abc, def, ghi, jkl, mno ];
+ `, "0,1,3,3,2")
+ })
+}
+
+func TestBinaryShiftOperation(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ high = (1 << 30) - 1 + (1 << 30)
+ low = -high - 1
+ abc = 23 << 1
+ def = -105 >> 1
+ ghi = 23 << 2
+ jkl = 1 >>> 31
+ mno = 1 << 64
+ pqr = 1 >> 2
+ stu = -2 >> 4
+ vwx = low >> 1
+ yz = low >>> 1
+ `)
+ test("abc", 46)
+ test("def", -53)
+ test("ghi", 92)
+ test("jkl", 0)
+ test("mno", 1)
+ test("pqr", 0)
+ test("stu", -1)
+ test("vwx", -1073741824)
+ test("yz", 1073741824)
+ })
+}
+
+func TestParenthesizing(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ abc = 1 + 2 * 3
+ def = (1 + 2) * 3
+ ghi = !(false || true)
+ jkl = !false || true
+ `)
+ test("abc", 7)
+ test("def", 9)
+ test("ghi", false)
+ test("jkl", true)
+ })
+}
+
+func Test_instanceof(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ abc = {} instanceof Object;
+ `, true)
+
+ test(`
+ abc = "abc" instanceof Object;
+ `, false)
+
+ test(`raise:
+ abc = {} instanceof "abc";
+ `, "TypeError: Expecting a function in instanceof check, but got: abc")
+
+ test(`raise:
+ "xyzzy" instanceof Math;
+ `, "TypeError")
+ })
+}
+
+func TestIn(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ abc = "prototype" in Object;
+ def = "xyzzy" in Object;
+ [ abc, def ];
+ `, "true,false")
+ })
+}
+
+func Test_new(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ abc = new Boolean;
+ def = new Boolean(1);
+ [ abc, def ];
+ `, "false,true")
+ })
+}
+
+func TestNewFunction(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ new Function("return 11")()
+ `, 11)
+
+ test(`
+ abc = 10
+ new Function("abc += 1")()
+ abc
+ `, 11)
+
+ test(`
+ new Function("a", "b", "c", "return b + 2")(10, 11, 12)
+ `, 13)
+
+ test(`raise:
+ new 1
+ `, "TypeError: 1 is not a function")
+
+ // TODO Better error reporting: new this
+ test(`raise:
+ new this
+ `, "TypeError: [object environment] is not a function")
+
+ test(`raise:
+ new {}
+ `, "TypeError: [object Object] is not a function")
+ })
+}
+
+func TestNewPrototype(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ abc = { 'xyzzy': 'Nothing happens.' }
+ function Xyzzy(){}
+ Xyzzy.prototype = abc;
+ (new Xyzzy()).xyzzy
+ `, "Nothing happens.")
+ })
+}
+
+func TestBlock(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ var abc=0;
+ var ghi;
+ def: {
+ do {
+ abc++;
+ if (!(abc < 10)) {
+ break def;
+ ghi = "ghi";
+ }
+ } while (true);
+ }
+ [ abc,ghi ];
+ `, "10,")
+ })
+}
+
+func Test_toString(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ [undefined+""]
+ `, "undefined")
+ })
+}
+
+func TestEvaluationOrder(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ var abc = 0;
+ abc < (abc = 1) === true;
+ `, true)
+ })
+}
+
+func TestClone(t *testing.T) {
+ tt(t, func() {
+ vm1 := New()
+ vm1.Run(`
+ var abc = 1;
+ `)
+
+ vm2 := vm1.clone()
+ vm1.Run(`
+ abc += 2;
+ `)
+ vm2.Run(`
+ abc += 4;
+ `)
+
+ is(vm1.getValue("abc"), 3)
+ is(vm2.getValue("abc"), 5)
+ })
+}
+
+func Test_debugger(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ debugger;
+ `, "undefined")
+ })
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/scope.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/scope.go
new file mode 100644
index 000000000..b80808434
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/scope.go
@@ -0,0 +1,34 @@
+package otto
+
+// _scope:
+// entryFile
+// entryIdx
+// top?
+// outer => nil
+
+// _stash:
+// lexical
+// variable
+//
+// _thisStash (ObjectEnvironment)
+// _fnStash
+// _dclStash
+
+// An ECMA-262 ExecutionContext
+type _scope struct {
+ lexical _stash
+ variable _stash
+ this *_object
+ eval bool // Replace this with kind?
+ outer *_scope
+
+ frame _frame
+}
+
+func newScope(lexical _stash, variable _stash, this *_object) *_scope {
+ return &_scope{
+ lexical: lexical,
+ variable: variable,
+ this: this,
+ }
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/script.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/script.go
new file mode 100644
index 000000000..ed8aebbf4
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/script.go
@@ -0,0 +1,122 @@
+package otto
+
+import (
+ "bytes"
+ "encoding/gob"
+ "errors"
+
+ "github.com/robertkrimen/otto/parser"
+)
+
+var ErrVersion = errors.New("version mismatch")
+
+var scriptVersion = "2014-04-13/1"
+
+// Script is a handle for some (reusable) JavaScript.
+// Passing a Script value to a run method will evaluate the JavaScript.
+//
+type Script struct {
+ version string
+ program *_nodeProgram
+ filename string
+ src string
+}
+
+// Compile will parse the given source and return a Script value or nil and
+// an error if there was a problem during compilation.
+//
+// script, err := vm.Compile("", `var abc; if (!abc) abc = 0; abc += 2; abc;`)
+// vm.Run(script)
+//
+func (self *Otto) Compile(filename string, src interface{}) (*Script, error) {
+ {
+ src, err := parser.ReadSource(filename, src)
+ if err != nil {
+ return nil, err
+ }
+
+ program, err := self.runtime.parse(filename, src)
+ if err != nil {
+ return nil, err
+ }
+
+ cmpl_program := cmpl_parse(program)
+
+ script := &Script{
+ version: scriptVersion,
+ program: cmpl_program,
+ filename: filename,
+ src: string(src),
+ }
+
+ return script, nil
+ }
+}
+
+func (self *Script) String() string {
+ return "// " + self.filename + "\n" + self.src
+}
+
+// MarshalBinary will marshal a script into a binary form. A marshalled script
+// that is later unmarshalled can be executed on the same version of the otto runtime.
+//
+// The binary format can change at any time and should be considered unspecified and opaque.
+//
+func (self *Script) marshalBinary() ([]byte, error) {
+ var bfr bytes.Buffer
+ encoder := gob.NewEncoder(&bfr)
+ err := encoder.Encode(self.version)
+ if err != nil {
+ return nil, err
+ }
+ err = encoder.Encode(self.program)
+ if err != nil {
+ return nil, err
+ }
+ err = encoder.Encode(self.filename)
+ if err != nil {
+ return nil, err
+ }
+ err = encoder.Encode(self.src)
+ if err != nil {
+ return nil, err
+ }
+ return bfr.Bytes(), nil
+}
+
+// UnmarshalBinary will vivify a marshalled script into something usable. If the script was
+// originally marshalled on a different version of the otto runtime, then this method
+// will return an error.
+//
+// The binary format can change at any time and should be considered unspecified and opaque.
+//
+func (self *Script) unmarshalBinary(data []byte) error {
+ decoder := gob.NewDecoder(bytes.NewReader(data))
+ err := decoder.Decode(&self.version)
+ if err != nil {
+ goto error
+ }
+ if self.version != scriptVersion {
+ err = ErrVersion
+ goto error
+ }
+ err = decoder.Decode(&self.program)
+ if err != nil {
+ goto error
+ }
+ err = decoder.Decode(&self.filename)
+ if err != nil {
+ goto error
+ }
+ err = decoder.Decode(&self.src)
+ if err != nil {
+ goto error
+ }
+ return nil
+error:
+ self.version = ""
+ self.program = nil
+ self.filename = ""
+ self.src = ""
+ return err
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/script_test.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/script_test.go
new file mode 100644
index 000000000..4c35c646e
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/script_test.go
@@ -0,0 +1,78 @@
+package otto
+
+import (
+ "testing"
+)
+
+func TestScript(t *testing.T) {
+ tt(t, func() {
+ vm := New()
+
+ script, err := vm.Compile("xyzzy", `var abc; if (!abc) abc = 0; abc += 2; abc;`)
+ is(err, nil)
+
+ str := script.String()
+ is(str, "// xyzzy\nvar abc; if (!abc) abc = 0; abc += 2; abc;")
+
+ value, err := vm.Run(script)
+ is(err, nil)
+ is(value, 2)
+
+ if true {
+ return
+ }
+
+ tmp, err := script.marshalBinary()
+ is(err, nil)
+ is(len(tmp), 1228)
+
+ {
+ script := &Script{}
+ err = script.unmarshalBinary(tmp)
+ is(err, nil)
+
+ is(script.String(), str)
+
+ value, err = vm.Run(script)
+ is(err, nil)
+ is(value, 4)
+
+ tmp, err = script.marshalBinary()
+ is(err, nil)
+ is(len(tmp), 1228)
+ }
+
+ {
+ script := &Script{}
+ err = script.unmarshalBinary(tmp)
+ is(err, nil)
+
+ is(script.String(), str)
+
+ value, err := vm.Run(script)
+ is(err, nil)
+ is(value, 6)
+
+ tmp, err = script.marshalBinary()
+ is(err, nil)
+ is(len(tmp), 1228)
+ }
+
+ {
+ version := scriptVersion
+ scriptVersion = "bogus"
+
+ script := &Script{}
+ err = script.unmarshalBinary(tmp)
+ is(err, "version mismatch")
+
+ is(script.String(), "// \n")
+ is(script.version, "")
+ is(script.program == nil, true)
+ is(script.filename, "")
+ is(script.src, "")
+
+ scriptVersion = version
+ }
+ })
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/stash.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/stash.go
new file mode 100644
index 000000000..578708d3f
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/stash.go
@@ -0,0 +1,275 @@
+package otto
+
+import (
+ "fmt"
+)
+
+// ======
+// _stash
+// ======
+
+type _stash interface {
+ hasBinding(string) bool //
+ createBinding(string, bool, Value) // CreateMutableBinding
+ setBinding(string, Value, bool) // SetMutableBinding
+ getBinding(string, bool) Value // GetBindingValue
+ deleteBinding(string) bool //
+ setValue(string, Value, bool) // createBinding + setBinding
+
+ outer() _stash
+ runtime() *_runtime
+
+ newReference(string, bool, _at) _reference
+
+ clone(clone *_clone) _stash
+}
+
+// ==========
+// _objectStash
+// ==========
+
+type _objectStash struct {
+ _runtime *_runtime
+ _outer _stash
+ object *_object
+}
+
+func (self *_objectStash) runtime() *_runtime {
+ return self._runtime
+}
+
+func (runtime *_runtime) newObjectStash(object *_object, outer _stash) *_objectStash {
+ if object == nil {
+ object = runtime.newBaseObject()
+ object.class = "environment"
+ }
+ return &_objectStash{
+ _runtime: runtime,
+ _outer: outer,
+ object: object,
+ }
+}
+
+func (in *_objectStash) clone(clone *_clone) _stash {
+ out, exists := clone.objectStash(in)
+ if exists {
+ return out
+ }
+ *out = _objectStash{
+ clone.runtime,
+ clone.stash(in._outer),
+ clone.object(in.object),
+ }
+ return out
+}
+
+func (self *_objectStash) hasBinding(name string) bool {
+ return self.object.hasProperty(name)
+}
+
+func (self *_objectStash) createBinding(name string, deletable bool, value Value) {
+ if self.object.hasProperty(name) {
+ panic(hereBeDragons())
+ }
+ mode := _propertyMode(0111)
+ if !deletable {
+ mode = _propertyMode(0110)
+ }
+ // TODO False?
+ self.object.defineProperty(name, value, mode, false)
+}
+
+func (self *_objectStash) setBinding(name string, value Value, strict bool) {
+ self.object.put(name, value, strict)
+}
+
+func (self *_objectStash) setValue(name string, value Value, throw bool) {
+ if !self.hasBinding(name) {
+ self.createBinding(name, true, value) // Configurable by default
+ } else {
+ self.setBinding(name, value, throw)
+ }
+}
+
+func (self *_objectStash) getBinding(name string, throw bool) Value {
+ if self.object.hasProperty(name) {
+ return self.object.get(name)
+ }
+ if throw { // strict?
+ panic(self._runtime.panicReferenceError("Not Defined", name))
+ }
+ return Value{}
+}
+
+func (self *_objectStash) deleteBinding(name string) bool {
+ return self.object.delete(name, false)
+}
+
+func (self *_objectStash) outer() _stash {
+ return self._outer
+}
+
+func (self *_objectStash) newReference(name string, strict bool, at _at) _reference {
+ return newPropertyReference(self._runtime, self.object, name, strict, at)
+}
+
+// =========
+// _dclStash
+// =========
+
+type _dclStash struct {
+ _runtime *_runtime
+ _outer _stash
+ property map[string]_dclProperty
+}
+
+type _dclProperty struct {
+ value Value
+ mutable bool
+ deletable bool
+ readable bool
+}
+
+func (runtime *_runtime) newDeclarationStash(outer _stash) *_dclStash {
+ return &_dclStash{
+ _runtime: runtime,
+ _outer: outer,
+ property: map[string]_dclProperty{},
+ }
+}
+
+func (in *_dclStash) clone(clone *_clone) _stash {
+ out, exists := clone.dclStash(in)
+ if exists {
+ return out
+ }
+ property := make(map[string]_dclProperty, len(in.property))
+ for index, value := range in.property {
+ property[index] = clone.dclProperty(value)
+ }
+ *out = _dclStash{
+ clone.runtime,
+ clone.stash(in._outer),
+ property,
+ }
+ return out
+}
+
+func (self *_dclStash) hasBinding(name string) bool {
+ _, exists := self.property[name]
+ return exists
+}
+
+func (self *_dclStash) runtime() *_runtime {
+ return self._runtime
+}
+
+func (self *_dclStash) createBinding(name string, deletable bool, value Value) {
+ _, exists := self.property[name]
+ if exists {
+ panic(fmt.Errorf("createBinding: %s: already exists", name))
+ }
+ self.property[name] = _dclProperty{
+ value: value,
+ mutable: true,
+ deletable: deletable,
+ readable: false,
+ }
+}
+
+func (self *_dclStash) setBinding(name string, value Value, strict bool) {
+ property, exists := self.property[name]
+ if !exists {
+ panic(fmt.Errorf("setBinding: %s: missing", name))
+ }
+ if property.mutable {
+ property.value = value
+ self.property[name] = property
+ } else {
+ self._runtime.typeErrorResult(strict)
+ }
+}
+
+func (self *_dclStash) setValue(name string, value Value, throw bool) {
+ if !self.hasBinding(name) {
+ self.createBinding(name, false, value) // NOT deletable by default
+ } else {
+ self.setBinding(name, value, throw)
+ }
+}
+
+// FIXME This is called a __lot__
+func (self *_dclStash) getBinding(name string, throw bool) Value {
+ property, exists := self.property[name]
+ if !exists {
+ panic(fmt.Errorf("getBinding: %s: missing", name))
+ }
+ if !property.mutable && !property.readable {
+ if throw { // strict?
+ panic(self._runtime.panicTypeError())
+ }
+ return Value{}
+ }
+ return property.value
+}
+
+func (self *_dclStash) deleteBinding(name string) bool {
+ property, exists := self.property[name]
+ if !exists {
+ return true
+ }
+ if !property.deletable {
+ return false
+ }
+ delete(self.property, name)
+ return true
+}
+
+func (self *_dclStash) outer() _stash {
+ return self._outer
+}
+
+func (self *_dclStash) newReference(name string, strict bool, _ _at) _reference {
+ return &_stashReference{
+ name: name,
+ base: self,
+ }
+}
+
+// ========
+// _fnStash
+// ========
+
+type _fnStash struct {
+ _dclStash
+ arguments *_object
+ indexOfArgumentName map[string]string
+}
+
+func (runtime *_runtime) newFunctionStash(outer _stash) *_fnStash {
+ return &_fnStash{
+ _dclStash: _dclStash{
+ _runtime: runtime,
+ _outer: outer,
+ property: map[string]_dclProperty{},
+ },
+ }
+}
+
+func (in *_fnStash) clone(clone *_clone) _stash {
+ out, exists := clone.fnStash(in)
+ if exists {
+ return out
+ }
+ dclStash := in._dclStash.clone(clone).(*_dclStash)
+ index := make(map[string]string, len(in.indexOfArgumentName))
+ for name, value := range in.indexOfArgumentName {
+ index[name] = value
+ }
+ *out = _fnStash{
+ _dclStash: *dclStash,
+ arguments: clone.object(in.arguments),
+ indexOfArgumentName: index,
+ }
+ return out
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/string_test.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/string_test.go
new file mode 100644
index 000000000..b7b06324b
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/string_test.go
@@ -0,0 +1,365 @@
+package otto
+
+import (
+ "testing"
+)
+
+func TestString(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ abc = (new String("xyzzy")).length;
+ def = new String().length;
+ ghi = new String("Nothing happens.").length;
+ `)
+ test("abc", 5)
+ test("def", 0)
+ test("ghi", 16)
+ test(`"".length`, 0)
+ test(`"a\uFFFFbc".length`, 4)
+ test(`String(+0)`, "0")
+ test(`String(-0)`, "0")
+ test(`""+-0`, "0")
+ test(`
+ var abc = Object.getOwnPropertyDescriptor(String, "prototype");
+ [ [ typeof String.prototype ],
+ [ abc.writable, abc.enumerable, abc.configurable ] ];
+ `, "object,false,false,false")
+ })
+}
+
+func TestString_charAt(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ abc = "xyzzy".charAt(0)
+ def = "xyzzy".charAt(11)
+ `)
+ test("abc", "x")
+ test("def", "")
+ })
+}
+
+func TestString_charCodeAt(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`
+ abc = "xyzzy".charCodeAt(0)
+ def = "xyzzy".charCodeAt(11)
+ `)
+ test("abc", 120)
+ test("def", _NaN)
+ })
+}
+
+func TestString_fromCharCode(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`String.fromCharCode()`, []uint16{})
+ test(`String.fromCharCode(88, 121, 122, 122, 121)`, []uint16{88, 121, 122, 122, 121}) // FIXME terst, Double-check these...
+ test(`String.fromCharCode("88", 121, 122, 122.05, 121)`, []uint16{88, 121, 122, 122, 121})
+ test(`String.fromCharCode("88", 121, 122, NaN, 121)`, []uint16{88, 121, 122, 0, 121})
+ test(`String.fromCharCode("0x21")`, []uint16{33})
+ test(`String.fromCharCode(-1).charCodeAt(0)`, 65535)
+ test(`String.fromCharCode(65535).charCodeAt(0)`, 65535)
+ test(`String.fromCharCode(65534).charCodeAt(0)`, 65534)
+ test(`String.fromCharCode(4294967295).charCodeAt(0)`, 65535)
+ test(`String.fromCharCode(4294967294).charCodeAt(0)`, 65534)
+ test(`String.fromCharCode(0x0024) === "$"`, true)
+ })
+}
+
+func TestString_concat(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`"".concat()`, "")
+ test(`"".concat("abc", "def")`, "abcdef")
+ test(`"".concat("abc", undefined, "def")`, "abcundefineddef")
+ })
+}
+
+func TestString_indexOf(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`"".indexOf("")`, 0)
+ test(`"".indexOf("", 11)`, 0)
+ test(`"abc".indexOf("")`, 0)
+ test(`"abc".indexOf("", 11)`, 3)
+ test(`"abc".indexOf("a")`, 0)
+ test(`"abc".indexOf("bc")`, 1)
+ test(`"abc".indexOf("bc", 11)`, -1)
+ test(`"$$abcdabcd".indexOf("ab", function(){return -Infinity;}())`, 2)
+ test(`"$$abcdabcd".indexOf("ab", function(){return NaN;}())`, 2)
+
+ test(`
+ var abc = {toString:function(){return "\u0041B";}}
+ var def = {valueOf:function(){return true;}}
+ var ghi = "ABB\u0041BABAB";
+ var jkl;
+ with(ghi) {
+ jkl = indexOf(abc, def);
+ }
+ jkl;
+ `, 3)
+ })
+}
+
+func TestString_lastIndexOf(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`"".lastIndexOf("")`, 0)
+ test(`"".lastIndexOf("", 11)`, 0)
+ test(`"abc".lastIndexOf("")`, 3)
+ test(`"abc".lastIndexOf("", 11)`, 3)
+ test(`"abc".lastIndexOf("a")`, 0)
+ test(`"abc".lastIndexOf("bc")`, 1)
+ test(`"abc".lastIndexOf("bc", 11)`, 1)
+ test(`"abc".lastIndexOf("bc", 0)`, -1)
+ test(`"abc".lastIndexOf("abcabcabc", 2)`, -1)
+ test(`"abc".lastIndexOf("abc", 0)`, 0)
+ test(`"abc".lastIndexOf("abc", 1)`, 0)
+ test(`"abc".lastIndexOf("abc", 2)`, 0)
+ test(`"abc".lastIndexOf("abc", 3)`, 0)
+
+ test(`
+ abc = new Object(true);
+ abc.lastIndexOf = String.prototype.lastIndexOf;
+ abc.lastIndexOf(true, false);
+ `, 0)
+ })
+}
+
+func TestString_match(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`"abc____abc_abc___".match(/__abc/)`, "__abc")
+ test(`"abc___abc_abc__abc__abc".match(/abc/g)`, "abc,abc,abc,abc,abc")
+ test(`"abc____abc_abc___".match(/__abc/g)`, "__abc")
+ test(`
+ abc = /abc/g
+ "abc___abc_abc__abc__abc".match(abc)
+ `, "abc,abc,abc,abc,abc")
+ test(`abc.lastIndex`, 23)
+ })
+}
+
+func TestString_replace(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`"abc_abc".replace(/abc/, "$&123")`, "abc123_abc")
+ test(`"abc_abc".replace(/abc/g, "$&123")`, "abc123_abc123")
+ test(`"abc_abc_".replace(/abc/g, "$&123")`, "abc123_abc123_")
+ test(`"_abc_abc_".replace(/abc/g, "$&123")`, "_abc123_abc123_")
+ test(`"abc".replace(/abc/, "$&123")`, "abc123")
+ test(`"abc_".replace(/abc/, "$&123")`, "abc123_")
+ test("\"^abc$\".replace(/abc/, \"$`def\")", "^^def$")
+ test("\"^abc$\".replace(/abc/, \"def$`\")", "^def^$")
+ test(`"_abc_abd_".replace(/ab(c|d)/g, "$1")`, "_c_d_")
+ test(`
+ "_abc_abd_".replace(/ab(c|d)/g, function(){
+ })
+ `, "_undefined_undefined_")
+
+ test(`"b".replace(/(a)?(b)?/, "_$1_")`, "__")
+ test(`
+ "b".replace(/(a)?(b)?/, function(a, b, c, d, e, f){
+ return [a, b, c, d, e, f]
+ })
+ `, "b,,b,0,b,")
+
+ test(`
+ var abc = 'She sells seashells by the seashore.';
+ var def = /sh/;
+ [ abc.replace(def, "$'" + 'sch') ];
+ `, "She sells seaells by the seashore.schells by the seashore.")
+ })
+}
+
+func TestString_search(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`"abc".search(/abc/)`, 0)
+ test(`"abc".search(/def/)`, -1)
+ test(`"abc".search(/c$/)`, 2)
+ test(`"abc".search(/$/)`, 3)
+ })
+}
+
+func TestString_split(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`"abc".split("", 1)`, "a")
+ test(`"abc".split("", 2)`, "a,b")
+ test(`"abc".split("", 3)`, "a,b,c")
+ test(`"abc".split("", 4)`, "a,b,c")
+ test(`"abc".split("", 11)`, "a,b,c")
+ test(`"abc".split("", 0)`, "")
+ test(`"abc".split("")`, "a,b,c")
+
+ test(`"abc".split(undefined)`, "abc")
+
+ test(`"__1__3_1__2__".split("_")`, ",,1,,3,1,,2,,")
+
+ test(`"__1__3_1__2__".split(/_/)`, ",,1,,3,1,,2,,")
+
+ test(`"ab".split(/a*/)`, ",b")
+
+ test(`_ = "A<B>bold</B>and<CODE>coded</CODE>".split(/<(\/)?([^<>]+)>/)`, "A,,B,bold,/,B,and,,CODE,coded,/,CODE,")
+ test(`_.length`, 13)
+ test(`_[1] === undefined`, true)
+ test(`_[12] === ""`, true)
+
+ test(`
+ var abc = new String("one-1 two-2 three-3");
+ var def = abc.split(new RegExp);
+
+ [ def.constructor === Array, abc.length, def.length, def.join('') ];
+ `, "true,19,19,one-1 two-2 three-3")
+ })
+}
+
+func TestString_slice(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`"abc".slice()`, "abc")
+ test(`"abc".slice(0)`, "abc")
+ test(`"abc".slice(0,11)`, "abc")
+ test(`"abc".slice(0,-1)`, "ab")
+ test(`"abc".slice(-1,11)`, "c")
+ test(`abc = "abc"; abc.slice(abc.length+1, 0)`, "")
+ })
+}
+
+func TestString_substring(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`"abc".substring()`, "abc")
+ test(`"abc".substring(0)`, "abc")
+ test(`"abc".substring(0,11)`, "abc")
+ test(`"abc".substring(11,0)`, "abc")
+ test(`"abc".substring(0,-1)`, "")
+ test(`"abc".substring(-1,11)`, "abc")
+ test(`"abc".substring(11,1)`, "bc")
+ test(`"abc".substring(1)`, "bc")
+ test(`"abc".substring(Infinity, Infinity)`, "")
+ })
+}
+
+func TestString_toCase(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`"abc".toLowerCase()`, "abc")
+ test(`"ABC".toLowerCase()`, "abc")
+ test(`"abc".toLocaleLowerCase()`, "abc")
+ test(`"ABC".toLocaleLowerCase()`, "abc")
+ test(`"abc".toUpperCase()`, "ABC")
+ test(`"ABC".toUpperCase()`, "ABC")
+ test(`"abc".toLocaleUpperCase()`, "ABC")
+ test(`"ABC".toLocaleUpperCase()`, "ABC")
+ })
+}
+
+func Test_floatToString(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`String(-1234567890)`, "-1234567890")
+ test(`-+String(-(-1234567890))`, -1234567890)
+ test(`String(-1e128)`, "-1e+128")
+ test(`String(0.12345)`, "0.12345")
+ test(`String(-0.00000012345)`, "-1.2345e-7")
+ test(`String(0.0000012345)`, "0.0000012345")
+ test(`String(1000000000000000000000)`, "1e+21")
+ test(`String(1e21)`, "1e+21")
+ test(`String(1E21)`, "1e+21")
+ test(`String(-1000000000000000000000)`, "-1e+21")
+ test(`String(-1e21)`, "-1e+21")
+ test(`String(-1E21)`, "-1e+21")
+ test(`String(0.0000001)`, "1e-7")
+ test(`String(1e-7)`, "1e-7")
+ test(`String(1E-7)`, "1e-7")
+ test(`String(-0.0000001)`, "-1e-7")
+ test(`String(-1e-7)`, "-1e-7")
+ test(`String(-1E-7)`, "-1e-7")
+ })
+}
+
+func TestString_indexing(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ // Actually a test of stringToArrayIndex, under the hood.
+ test(`
+ abc = new String("abc");
+ index = Math.pow(2, 32);
+ [ abc.length, abc[index], abc[index+1], abc[index+2], abc[index+3] ];
+ `, "3,,,,")
+ })
+}
+
+func TestString_trim(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`' \n abc \t \n'.trim();`, "abc")
+ test(`" abc\u000B".trim()`, "abc")
+ test(`"abc ".trim()`, "abc")
+ test(`
+ var a = "\u180Eabc \u000B "
+ var b = a.trim()
+ a.length + b.length
+ `, 10)
+ })
+}
+
+func TestString_trimLeft(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`" abc\u000B".trimLeft()`, "abc\u000B")
+ test(`"abc ".trimLeft()`, "abc ")
+ test(`
+ var a = "\u180Eabc \u000B "
+ var b = a.trimLeft()
+ a.length + b.length
+ `, 13)
+ })
+}
+
+func TestString_trimRight(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`" abc\u000B".trimRight()`, " abc")
+ test(`" abc ".trimRight()`, " abc")
+ test(`
+ var a = "\u180Eabc \u000B "
+ var b = a.trimRight()
+ a.length + b.length
+ `, 11)
+ })
+}
+
+func TestString_localeCompare(t *testing.T) {
+ tt(t, func() {
+ test, _ := test()
+
+ test(`'a'.localeCompare('c');`, -1)
+ test(`'c'.localeCompare('a');`, 1)
+ test(`'a'.localeCompare('a');`, 0)
+ })
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/terst/terst.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/terst/terst.go
new file mode 100644
index 000000000..a25ca8b9c
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/terst/terst.go
@@ -0,0 +1,669 @@
+// This file was AUTOMATICALLY GENERATED by terst-import (smuggol) from github.com/robertkrimen/terst
+
+/*
+Package terst is a terse (terst = test + terse), easy-to-use testing library for Go.
+
+terst is compatible with (and works via) the standard testing package: http://golang.org/pkg/testing
+
+ var is = terst.Is
+
+ func Test(t *testing.T) {
+ terst.Terst(t, func() {
+ is("abc", "abc")
+
+ is(1, ">", 0)
+
+ var abc []int
+ is(abc, nil)
+ }
+ }
+
+Do not import terst directly, instead use `terst-import` to copy it into your testing environment:
+
+https://github.com/robertkrimen/terst/tree/master/terst-import
+
+ $ go get github.com/robertkrimen/terst/terst-import
+
+ $ terst-import
+
+*/
+package terst
+
+import (
+ "bytes"
+ "errors"
+ "fmt"
+ "math/big"
+ "reflect"
+ "regexp"
+ "runtime"
+ "strings"
+ "sync"
+ "testing"
+ "time"
+)
+
+// Is compares two values (got & expect) and returns true if the comparison is true,
+// false otherwise. In addition, if the comparison is false, Is will report the error
+// in a manner similar to testing.T.Error(...). Is also takes an optional argument,
+// a comparator, that changes how the comparison is made. The following
+// comparators are available:
+//
+// == # got == expect (default)
+// != # got != expect
+//
+// > # got > expect (float32, uint, uint16, int, int64, ...)
+// >= # got >= expect
+// < # got < expect
+// <= # got <= expect
+//
+// =~ # regexp.MustCompile(expect).Match{String}(got)
+// !~ # !regexp.MustCompile(expect).Match{String}(got)
+//
+// Basic usage with the default comparator (==):
+//
+// Is(<got>, <expect>)
+//
+// Specifying a different comparator:
+//
+// Is(<got>, <comparator>, <expect>)
+//
+// A simple comparison:
+//
+// Is(2 + 2, 4)
+//
+// A bit trickier:
+//
+// Is(1, ">", 0)
+// Is(2 + 2, "!=", 5)
+// Is("Nothing happens.", "=~", `ing(\s+)happens\.$`)
+//
+// Is should only be called under a Terst(t, ...) call. For a standalone version,
+// use IsErr. If no scope is found and the comparison is false, then Is will panic the error.
+//
+func Is(arguments ...interface{}) bool {
+ err := IsErr(arguments...)
+ if err != nil {
+ call := Caller()
+ if call == nil {
+ panic(err)
+ }
+ call.Error(err)
+ return false
+ }
+ return true
+}
+
+type (
+ // ErrFail indicates a comparison failure (e.g. 0 > 1).
+ ErrFail error
+
+ // ErrInvalid indicates an invalid comparison (e.g. bool == string).
+ ErrInvalid error
+)
+
+var errInvalid = errors.New("invalid")
+
+var registry = struct {
+ table map[uintptr]*_scope
+ lock sync.RWMutex
+}{
+ table: map[uintptr]*_scope{},
+}
+
+func registerScope(pc uintptr, scope *_scope) {
+ registry.lock.Lock()
+ defer registry.lock.Unlock()
+ registry.table[pc] = scope
+}
+
+func scope() *_scope {
+ scope, _ := findScope()
+ return scope
+}
+
+func floatCompare(a float64, b float64) int {
+ if a > b {
+ return 1
+ } else if a < b {
+ return -1
+ }
+ // NaN == NaN
+ return 0
+}
+
+func bigIntCompare(a *big.Int, b *big.Int) int {
+ return a.Cmp(b)
+}
+
+func bigInt(value int64) *big.Int {
+ return big.NewInt(value)
+}
+
+func bigUint(value uint64) *big.Int {
+ return big.NewInt(0).SetUint64(value)
+}
+
+type _toString interface {
+ String() string
+}
+
+func toString(value interface{}) (string, error) {
+ switch value := value.(type) {
+ case string:
+ return value, nil
+ case _toString:
+ return value.String(), nil
+ case error:
+ return value.Error(), nil
+ }
+ return "", errInvalid
+}
+
+func matchString(got string, expect *regexp.Regexp) (int, error) {
+ if expect.MatchString(got) {
+ return 0, nil
+ }
+ return -1, nil
+}
+
+func match(got []byte, expect *regexp.Regexp) (int, error) {
+ if expect.Match(got) {
+ return 0, nil
+ }
+ return -1, nil
+}
+
+func compareMatch(got, expect interface{}) (int, error) {
+ switch got := got.(type) {
+ case []byte:
+ switch expect := expect.(type) {
+ case string:
+ matcher, err := regexp.Compile(expect)
+ if err != nil {
+ return 0, err
+ }
+ return match(got, matcher)
+ case *regexp.Regexp:
+ return match(got, expect)
+ }
+ default:
+ if got, err := toString(got); err == nil {
+ switch expect := expect.(type) {
+ case string:
+ matcher, err := regexp.Compile(expect)
+ if err != nil {
+ return 0, err
+ }
+ return matchString(got, matcher)
+ case *regexp.Regexp:
+ return matchString(got, expect)
+ }
+ } else {
+ return 0, err
+ }
+ }
+ return 0, errInvalid
+}
+
+func floatPromote(value reflect.Value) (float64, error) {
+ kind := value.Kind()
+ if reflect.Int <= kind && kind <= reflect.Int64 {
+ return float64(value.Int()), nil
+ }
+ if reflect.Uint <= kind && kind <= reflect.Uint64 {
+ return float64(value.Uint()), nil
+ }
+ if reflect.Float32 <= kind && kind <= reflect.Float64 {
+ return value.Float(), nil
+ }
+ return 0, errInvalid
+}
+
+func bigIntPromote(value reflect.Value) (*big.Int, error) {
+ kind := value.Kind()
+ if reflect.Int <= kind && kind <= reflect.Int64 {
+ return bigInt(value.Int()), nil
+ }
+ if reflect.Uint <= kind && kind <= reflect.Uint64 {
+ return bigUint(value.Uint()), nil
+ }
+ return nil, errInvalid
+}
+
+func compareOther(got, expect interface{}) (int, error) {
+ {
+ switch expect.(type) {
+ case float32, float64:
+ return compareNumber(got, expect)
+ case uint, uint8, uint16, uint32, uint64:
+ return compareNumber(got, expect)
+ case int, int8, int16, int32, int64:
+ return compareNumber(got, expect)
+ case string:
+ var err error
+ got, err = toString(got)
+ if err != nil {
+ return 0, err
+ }
+ case nil:
+ got := reflect.ValueOf(got)
+ switch got.Kind() {
+ case reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr, reflect.Slice, reflect.Interface:
+ if got.IsNil() {
+ return 0, nil
+ }
+ return -1, nil
+ case reflect.Invalid: // reflect.Invalid: var abc interface{} = nil
+ return 0, nil
+ }
+ return 0, errInvalid
+ }
+ }
+
+ if reflect.ValueOf(got).Type() != reflect.ValueOf(expect).Type() {
+ return 0, errInvalid
+ }
+
+ if reflect.DeepEqual(got, expect) {
+ return 0, nil
+ }
+ return -1, nil
+}
+
+func compareNumber(got, expect interface{}) (int, error) {
+ {
+ got := reflect.ValueOf(got)
+ k0 := got.Kind()
+ expect := reflect.ValueOf(expect)
+ k1 := expect.Kind()
+ if reflect.Float32 <= k0 && k0 <= reflect.Float64 ||
+ reflect.Float32 <= k1 && k1 <= reflect.Float64 {
+ got, err := floatPromote(got)
+ if err != nil {
+ return 0, err
+ }
+ expect, err := floatPromote(expect)
+ if err != nil {
+ return 0, err
+ }
+ return floatCompare(got, expect), nil
+ } else {
+ got, err := bigIntPromote(got)
+ if err != nil {
+ return 0, err
+ }
+ expect, err := bigIntPromote(expect)
+ if err != nil {
+ return 0, err
+ }
+ return got.Cmp(expect), nil
+ }
+ }
+
+ return 0, errInvalid
+}
+
+// IsErr compares two values (got & expect) and returns nil if the comparison is true, an ErrFail if
+// the comparison is false, or an ErrInvalid if the comparison is invalid. IsErr also
+// takes an optional argument, a comparator, that changes how the comparison is made.
+//
+// Is & IsErr are similar but different:
+//
+// Is(...) // Should only be called within a Terst(...) call
+// IsErr(...) // A standalone comparator, the same as Is, just without the automatic reporting
+//
+func IsErr(arguments ...interface{}) error {
+ var got, expect interface{}
+ comparator := "=="
+ switch len(arguments) {
+ case 0, 1:
+ return fmt.Errorf("invalid number of arguments to IsErr: %d", len(arguments))
+ case 2:
+ got, expect = arguments[0], arguments[1]
+ default:
+ if value, ok := arguments[1].(string); ok {
+ comparator = value
+ } else {
+ return fmt.Errorf("invalid comparator: %v", arguments[1])
+ }
+ got, expect = arguments[0], arguments[2]
+ }
+
+ var result int
+ var err error
+
+ switch comparator {
+ case "<", "<=", ">", ">=":
+ result, err = compareNumber(got, expect)
+ case "=~", "!~":
+ result, err = compareMatch(got, expect)
+ case "==", "!=":
+ result, err = compareOther(got, expect)
+ default:
+ return fmt.Errorf("invalid comparator: %s", comparator)
+ }
+
+ if err == errInvalid {
+ return ErrInvalid(fmt.Errorf(
+ "\nINVALID (%s):\n got: %v (%T)\n expected: %v (%T)",
+ comparator,
+ got, got,
+ expect, expect,
+ ))
+ } else if err != nil {
+ return err
+ }
+
+ equality, pass := false, false
+
+ switch comparator {
+ case "==", "=~":
+ equality = true
+ pass = result == 0
+ case "!=", "!~":
+ equality = true
+ pass = result != 0
+ case "<":
+ pass = result < 0
+ case "<=":
+ pass = result <= 0
+ case ">":
+ pass = result > 0
+ case ">=":
+ pass = result >= 0
+ }
+
+ if !pass {
+ if equality {
+ if comparator[1] == '~' {
+ if value, ok := got.([]byte); ok {
+ return ErrFail(fmt.Errorf(
+ "\nFAIL (%s)\n got: %s %v%s\nexpected: %v%s",
+ comparator,
+ value, got, typeKindString(got),
+ expect, typeKindString(expect),
+ ))
+ }
+ }
+ return ErrFail(fmt.Errorf(
+ "\nFAIL (%s)\n got: %v%s\nexpected: %v%s",
+ comparator,
+ got, typeKindString(got),
+ expect, typeKindString(expect),
+ ))
+ }
+ return ErrFail(fmt.Errorf(
+ "\nFAIL (%s)\n got: %v%s\nexpected: %s %v%s",
+ comparator,
+ got, typeKindString(got),
+ comparator, expect, typeKindString(expect),
+ ))
+ }
+
+ return nil
+}
+
+func typeKindString(value interface{}) string {
+ reflectValue := reflect.ValueOf(value)
+ kind := reflectValue.Kind().String()
+ result := fmt.Sprintf("%T", value)
+ if kind == result {
+ if kind == "string" {
+ return ""
+ }
+ return fmt.Sprintf(" (%T)", value)
+ }
+ return fmt.Sprintf(" (%T=%s)", value, kind)
+}
+
+func (scope *_scope) reset() {
+ scope.name = ""
+ scope.output = scope.output[:]
+ scope.start = time.Time{}
+ scope.duration = 0
+}
+
+// Terst creates a testing scope, where Is can be called and errors will be reported
+// according to the top-level location of the comparison, and not where the Is call
+// actually takes place. For example:
+//
+// func test(value int) {
+// Is(value, 5) // <--- This failure is reported below.
+// }
+//
+// Terst(t, func(){
+//
+// Is(2, ">", 3) // <--- An error is reported here.
+//
+// test(5) // <--- An error is reported here.
+//
+// })
+//
+func Terst(t *testing.T, arguments ...func()) {
+ scope := &_scope{
+ t: t,
+ }
+
+ pc, _, _, ok := runtime.Caller(1) // TODO Associate with the Test... func
+ if !ok {
+ panic("Here be dragons.")
+ }
+
+ _, scope.testFunc = findTestFunc()
+
+ registerScope(pc, scope)
+
+ for _, fn := range arguments {
+ func() {
+ scope.reset()
+ name := scope.testFunc.Name()
+ index := strings.LastIndex(scope.testFunc.Name(), ".")
+ if index >= 0 {
+ name = name[index+1:] + "(Terst)"
+ } else {
+ name = "(Terst)"
+ }
+ name = "(Terst)"
+ scope.name = name
+ scope.start = time.Now()
+ defer func() {
+ scope.duration = time.Now().Sub(scope.start)
+ if err := recover(); err != nil {
+ scope.t.Fail()
+ scope.report()
+ panic(err)
+ }
+ scope.report()
+ }()
+ fn()
+ }()
+ }
+}
+
+// From "testing"
+func (scope *_scope) report() {
+ format := "~~~ %s: (Terst)\n%s"
+ if scope.t.Failed() {
+ fmt.Printf(format, "FAIL", scope.output)
+ } else if testing.Verbose() && len(scope.output) > 0 {
+ fmt.Printf(format, "PASS", scope.output)
+ }
+}
+
+func (scope *_scope) log(call _entry, str string) {
+ scope.mu.Lock()
+ defer scope.mu.Unlock()
+ scope.output = append(scope.output, decorate(call, str)...)
+}
+
+// decorate prefixes the string with the file and line of the call site
+// and inserts the final newline if needed and indentation tabs for formascing.
+func decorate(call _entry, s string) string {
+
+ file, line := call.File, call.Line
+ if call.PC > 0 {
+ // Truncate file name at last file name separator.
+ if index := strings.LastIndex(file, "/"); index >= 0 {
+ file = file[index+1:]
+ } else if index = strings.LastIndex(file, "\\"); index >= 0 {
+ file = file[index+1:]
+ }
+ } else {
+ file = "???"
+ line = 1
+ }
+ buf := new(bytes.Buffer)
+ // Every line is indented at least one tab.
+ buf.WriteByte('\t')
+ fmt.Fprintf(buf, "%s:%d: ", file, line)
+ lines := strings.Split(s, "\n")
+ if l := len(lines); l > 1 && lines[l-1] == "" {
+ lines = lines[:l-1]
+ }
+ for i, line := range lines {
+ if i > 0 {
+ // Second and subsequent lines are indented an extra tab.
+ buf.WriteString("\n\t\t")
+ }
+ buf.WriteString(line)
+ }
+ buf.WriteByte('\n')
+ return buf.String()
+}
+
+func findScope() (*_scope, _entry) {
+ registry.lock.RLock()
+ defer registry.lock.RUnlock()
+ table := registry.table
+ depth := 2 // Starting depth
+ call := _entry{}
+ for {
+ pc, _, _, ok := runtime.Caller(depth)
+ if !ok {
+ break
+ }
+ if scope, exists := table[pc]; exists {
+ pc, file, line, _ := runtime.Caller(depth - 3) // Terst(...) + func(){}() + fn() => ???()
+ call.PC = pc
+ call.File = file
+ call.Line = line
+ return scope, call
+ }
+ depth++
+ }
+ return nil, _entry{}
+}
+
+// Call is a reference to a line immediately under a Terst testing scope.
+type Call struct {
+ scope *_scope
+ entry _entry
+}
+
+// Caller will search the stack, looking for a Terst testing scope. If a scope
+// is found, then Caller returns a Call for logging errors, accessing testing.T, etc.
+// If no scope is found, Caller returns nil.
+func Caller() *Call {
+ scope, entry := findScope()
+ if scope == nil {
+ return nil
+ }
+ return &Call{
+ scope: scope,
+ entry: entry,
+ }
+}
+
+// TestFunc returns the *runtime.Func entry for the top-level Test...(t testing.T)
+// function.
+func (cl *Call) TestFunc() *runtime.Func {
+ return cl.scope.testFunc
+}
+
+// T returns the original testing.T passed to Terst(...)
+func (cl *Call) T() *testing.T {
+ return cl.scope.t
+}
+
+// Log is the terst version of `testing.T.Log`
+func (cl *Call) Log(arguments ...interface{}) {
+ cl.scope.log(cl.entry, fmt.Sprintln(arguments...))
+}
+
+// Logf is the terst version of `testing.T.Logf`
+func (cl *Call) Logf(format string, arguments ...interface{}) {
+ cl.scope.log(cl.entry, fmt.Sprintf(format, arguments...))
+}
+
+// Error is the terst version of `testing.T.Error`
+func (cl *Call) Error(arguments ...interface{}) {
+ cl.scope.log(cl.entry, fmt.Sprintln(arguments...))
+ cl.scope.t.Fail()
+}
+
+// Errorf is the terst version of `testing.T.Errorf`
+func (cl *Call) Errorf(format string, arguments ...interface{}) {
+ cl.scope.log(cl.entry, fmt.Sprintf(format, arguments...))
+ cl.scope.t.Fail()
+}
+
+// Skip is the terst version of `testing.T.Skip`
+func (cl *Call) Skip(arguments ...interface{}) {
+ cl.scope.log(cl.entry, fmt.Sprintln(arguments...))
+ cl.scope.t.SkipNow()
+}
+
+// Skipf is the terst version of `testing.T.Skipf`
+func (cl *Call) Skipf(format string, arguments ...interface{}) {
+ cl.scope.log(cl.entry, fmt.Sprintf(format, arguments...))
+ cl.scope.t.SkipNow()
+}
+
+type _scope struct {
+ t *testing.T
+ testFunc *runtime.Func
+ name string
+ mu sync.RWMutex
+ output []byte
+ start time.Time
+ duration time.Duration
+}
+
+type _entry struct {
+ PC uintptr
+ File string
+ Line int
+ Func *runtime.Func
+}
+
+func _findFunc(match string) (_entry, *runtime.Func) {
+ depth := 2 // Starting depth
+ for {
+ pc, file, line, ok := runtime.Caller(depth)
+ if !ok {
+ break
+ }
+ fn := runtime.FuncForPC(pc)
+ name := fn.Name()
+ if index := strings.LastIndex(name, match); index >= 0 {
+ // Assume we have an instance of TestXyzzy in a _test file
+ return _entry{
+ PC: pc,
+ File: file,
+ Line: line,
+ Func: fn,
+ }, fn
+ }
+ depth++
+ }
+ return _entry{}, nil
+}
+
+func findTestFunc() (_entry, *runtime.Func) {
+ return _findFunc(".Test")
+}
+
+func findTerstFunc() (_entry, *runtime.Func) {
+ return _findFunc(".Terst")
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/test/Makefile b/Godeps/_workspace/src/github.com/robertkrimen/otto/test/Makefile
new file mode 100644
index 000000000..ac76fdeac
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/test/Makefile
@@ -0,0 +1,26 @@
+.PHONY: test fetch clean build err report
+
+TESTER := tester
+
+test: $(TESTER)
+ for test in test-*.js; do ./$^ -test=true $$test 1>/dev/null || exit 1; done
+ @echo PASS
+
+report: $(TESTER)
+ ./$^ -report | grep -v "MT READY"
+
+fetch: $(TESTER)
+ ./$^ fetch
+
+build:
+ go build -a -o $(TESTER)
+
+$(TESTER): tester.go
+ $(MAKE) build
+
+clean:
+ rm -f test-*.js
+ rm -f $(TESTER)
+
+err: $(TESTER)
+ for test in test-*.js; do ./$^ $$test; done 2>$@
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/test/tester.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/test/tester.go
new file mode 100644
index 000000000..ea694fd8d
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/test/tester.go
@@ -0,0 +1,196 @@
+package main
+
+import (
+ "encoding/json"
+ "flag"
+ "fmt"
+ "io/ioutil"
+ "net/http"
+ "os"
+ "regexp"
+ "strings"
+ "sync"
+ "text/tabwriter"
+
+ "github.com/robertkrimen/otto"
+ "github.com/robertkrimen/otto/parser"
+)
+
+var flag_test *bool = flag.Bool("test", false, "")
+var flag_report *bool = flag.Bool("report", false, "")
+
+var match_ReferenceError_not_defined = regexp.MustCompile(`^ReferenceError: \S+ is not defined$`)
+var match_lookahead = regexp.MustCompile(`Invalid regular expression: re2: Invalid \(\?[=!]\) <lookahead>`)
+var match_backreference = regexp.MustCompile(`Invalid regular expression: re2: Invalid \\\d <backreference>`)
+var match_TypeError_undefined = regexp.MustCompile(`^TypeError: Cannot access member '[^']+' of undefined$`)
+
+var target = map[string]string{
+ "test-angular-bindonce.js": "fail", // (anonymous): Line 1:944 Unexpected token ( (and 40 more errors)
+ "test-jsforce.js": "fail", // (anonymous): Line 9:28329 RuneError (and 5 more errors)
+ "test-chaplin.js": "parse", // Error: Chaplin requires Common.js or AMD modules
+ "test-dropbox.js.js": "parse", // Error: dropbox.js loaded in an unsupported JavaScript environment.
+ "test-epitome.js": "parse", // TypeError: undefined is not a function
+ "test-portal.js": "parse", // TypeError
+ "test-reactive-coffee.js": "parse", // Dependencies are not met for reactive: _ and $ not found
+ "test-scriptaculous.js": "parse", // script.aculo.us requires the Prototype JavaScript framework >= 1.6.0.3
+ "test-waypoints.js": "parse", // TypeError: undefined is not a function
+ "test-webuploader.js": "parse", // Error: `jQuery` is undefined
+ "test-xuijs.js": "parse", // TypeError: undefined is not a function
+}
+
+// http://cdnjs.com/
+// http://api.cdnjs.com/libraries
+
+func fetch(name, location string) error {
+ response, err := http.Get(location)
+ if err != nil {
+ return err
+ }
+ defer response.Body.Close()
+ body, err := ioutil.ReadAll(response.Body)
+ if err != nil {
+ return err
+ }
+
+ if !strings.HasSuffix(location, ".js") {
+ return nil
+ }
+
+ filename := "test-" + name + ".js"
+ fmt.Println(filename, len(body))
+ return ioutil.WriteFile(filename, body, 0644)
+}
+
+func test(filename string) error {
+ script, err := ioutil.ReadFile(filename)
+ if err != nil {
+ return err
+ }
+
+ if !*flag_report {
+ fmt.Fprintln(os.Stdout, filename, len(script))
+ }
+
+ parse := false
+ option := target[filename]
+
+ if option != "parse" {
+ vm := otto.New()
+ _, err = vm.Run(string(script))
+ if err != nil {
+ value := err.Error()
+ switch {
+ case match_ReferenceError_not_defined.MatchString(value):
+ case match_TypeError_undefined.MatchString(value):
+ case match_lookahead.MatchString(value):
+ case match_backreference.MatchString(value):
+ default:
+ return err
+ }
+ parse = true
+ }
+ }
+
+ if parse {
+ _, err = parser.ParseFile(nil, filename, string(script), parser.IgnoreRegExpErrors)
+ if err != nil {
+ return err
+ }
+ target[filename] = "parse"
+ }
+
+ return nil
+}
+
+func main() {
+ flag.Parse()
+
+ filename := ""
+
+ err := func() error {
+
+ if flag.Arg(0) == "fetch" {
+ response, err := http.Get("http://api.cdnjs.com/libraries")
+ if err != nil {
+ return err
+ }
+ defer response.Body.Close()
+ body, err := ioutil.ReadAll(response.Body)
+ if err != nil {
+ return err
+ }
+
+ var tmp map[string]interface{}
+
+ err = json.Unmarshal(body, &tmp)
+ if err != nil {
+ return err
+ }
+
+ var wg sync.WaitGroup
+
+ for _, value := range tmp["results"].([]interface{}) {
+ wg.Add(1)
+ library := value.(map[string]interface{})
+ go func() {
+ defer wg.Done()
+ fetch(library["name"].(string), library["latest"].(string))
+ }()
+ }
+
+ wg.Wait()
+
+ return nil
+ }
+
+ if *flag_report {
+ files, err := ioutil.ReadDir(".")
+ if err != nil {
+ return err
+ }
+ writer := tabwriter.NewWriter(os.Stdout, 0, 8, 0, '\t', 0)
+ fmt.Fprintln(writer, "", "\t| Status")
+ fmt.Fprintln(writer, "---", "\t| ---")
+ for _, file := range files {
+ filename := file.Name()
+ if !strings.HasPrefix(filename, "test-") {
+ continue
+ }
+ err := test(filename)
+ option := target[filename]
+ name := strings.TrimPrefix(strings.TrimSuffix(filename, ".js"), "test-")
+ if err == nil {
+ switch option {
+ case "":
+ fmt.Fprintln(writer, name, "\t| pass")
+ case "parse":
+ fmt.Fprintln(writer, name, "\t| pass (parse)")
+ case "re2":
+ continue
+ fmt.Fprintln(writer, name, "\t| unknown (re2)")
+ }
+ } else {
+ fmt.Fprintln(writer, name, "\t| fail")
+ }
+ }
+ writer.Flush()
+ return nil
+ }
+
+ filename = flag.Arg(0)
+ return test(filename)
+
+ }()
+ if err != nil {
+ if filename != "" {
+ if *flag_test && target[filename] == "fail" {
+ goto exit
+ }
+ fmt.Fprintf(os.Stderr, "%s: %s\n", filename, err.Error())
+ } else {
+ fmt.Fprintln(os.Stderr, err)
+ }
+ os.Exit(64)
+ }
+exit:
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/testing_test.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/testing_test.go
new file mode 100644
index 000000000..bf820bc0c
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/testing_test.go
@@ -0,0 +1,135 @@
+package otto
+
+import (
+ "./terst"
+ "errors"
+ "strings"
+ "testing"
+ "time"
+)
+
+func tt(t *testing.T, arguments ...func()) {
+ halt := errors.New("A test was taking too long")
+ timer := time.AfterFunc(2*time.Second, func() {
+ panic(halt)
+ })
+ defer func() {
+ timer.Stop()
+ }()
+ terst.Terst(t, arguments...)
+}
+
+func is(arguments ...interface{}) bool {
+ var got, expect interface{}
+
+ switch len(arguments) {
+ case 0, 1:
+ return terst.Is(arguments...)
+ case 2:
+ got, expect = arguments[0], arguments[1]
+ default:
+ got, expect = arguments[0], arguments[2]
+ }
+
+ switch value := got.(type) {
+ case Value:
+ if value.value != nil {
+ got = value.value
+ }
+ case *Error:
+ if value != nil {
+ got = value.Error()
+ }
+ if expect == nil {
+ // FIXME This is weird
+ expect = ""
+ }
+ }
+
+ if len(arguments) == 2 {
+ arguments[0] = got
+ arguments[1] = expect
+ } else {
+ arguments[0] = got
+ arguments[2] = expect
+ }
+
+ return terst.Is(arguments...)
+}
+
+func test(arguments ...interface{}) (func(string, ...interface{}) Value, *_tester) {
+ tester := newTester()
+ if len(arguments) > 0 {
+ tester.test(arguments[0].(string))
+ }
+ return tester.test, tester
+}
+
+type _tester struct {
+ vm *Otto
+}
+
+func newTester() *_tester {
+ return &_tester{
+ vm: New(),
+ }
+}
+
+func (self *_tester) Get(name string) (Value, error) {
+ return self.vm.Get(name)
+}
+
+func (self *_tester) Set(name string, value interface{}) Value {
+ err := self.vm.Set(name, value)
+ is(err, nil)
+ if err != nil {
+ terst.Caller().T().FailNow()
+ }
+ return self.vm.getValue(name)
+}
+
+func (self *_tester) Run(src interface{}) (Value, error) {
+ return self.vm.Run(src)
+}
+
+func (self *_tester) test(name string, expect ...interface{}) Value {
+ vm := self.vm
+ raise := false
+ defer func() {
+ if caught := recover(); caught != nil {
+ if exception, ok := caught.(*_exception); ok {
+ caught = exception.eject()
+ }
+ if raise {
+ if len(expect) > 0 {
+ is(caught, expect[0])
+ }
+ } else {
+ dbg("Panic, caught:", caught)
+ panic(caught)
+ }
+ }
+ }()
+ var value Value
+ var err error
+ if isIdentifier(name) {
+ value = vm.getValue(name)
+ } else {
+ source := name
+ index := strings.Index(source, "raise:")
+ if index == 0 {
+ raise = true
+ source = source[6:]
+ source = strings.TrimLeft(source, " ")
+ }
+ value, err = vm.runtime.cmpl_run(source)
+ if err != nil {
+ panic(err)
+ }
+ }
+ value = value.resolve()
+ if len(expect) > 0 {
+ is(value, expect[0])
+ }
+ return value
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/type_arguments.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/type_arguments.go
new file mode 100644
index 000000000..841d75855
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/type_arguments.go
@@ -0,0 +1,106 @@
+package otto
+
+import (
+ "strconv"
+)
+
+func (runtime *_runtime) newArgumentsObject(indexOfParameterName []string, stash _stash, length int) *_object {
+ self := runtime.newClassObject("Arguments")
+
+ for index, _ := range indexOfParameterName {
+ name := strconv.FormatInt(int64(index), 10)
+ objectDefineOwnProperty(self, name, _property{Value{}, 0111}, false)
+ }
+
+ self.objectClass = _classArguments
+ self.value = _argumentsObject{
+ indexOfParameterName: indexOfParameterName,
+ stash: stash,
+ }
+
+ self.prototype = runtime.global.ObjectPrototype
+
+ self.defineProperty("length", toValue_int(length), 0101, false)
+
+ return self
+}
+
+type _argumentsObject struct {
+ indexOfParameterName []string
+ // function(abc, def, ghi)
+ // indexOfParameterName[0] = "abc"
+ // indexOfParameterName[1] = "def"
+ // indexOfParameterName[2] = "ghi"
+ // ...
+ stash _stash
+}
+
+func (in _argumentsObject) clone(clone *_clone) _argumentsObject {
+ indexOfParameterName := make([]string, len(in.indexOfParameterName))
+ copy(indexOfParameterName, in.indexOfParameterName)
+ return _argumentsObject{
+ indexOfParameterName,
+ clone.stash(in.stash),
+ }
+}
+
+func (self _argumentsObject) get(name string) (Value, bool) {
+ index := stringToArrayIndex(name)
+ if index >= 0 && index < int64(len(self.indexOfParameterName)) {
+ name := self.indexOfParameterName[index]
+ if name == "" {
+ return Value{}, false
+ }
+ return self.stash.getBinding(name, false), true
+ }
+ return Value{}, false
+}
+
+func (self _argumentsObject) put(name string, value Value) {
+ index := stringToArrayIndex(name)
+ name = self.indexOfParameterName[index]
+ self.stash.setBinding(name, value, false)
+}
+
+func (self _argumentsObject) delete(name string) {
+ index := stringToArrayIndex(name)
+ self.indexOfParameterName[index] = ""
+}
+
+func argumentsGet(self *_object, name string) Value {
+ if value, exists := self.value.(_argumentsObject).get(name); exists {
+ return value
+ }
+ return objectGet(self, name)
+}
+
+func argumentsGetOwnProperty(self *_object, name string) *_property {
+ property := objectGetOwnProperty(self, name)
+ if value, exists := self.value.(_argumentsObject).get(name); exists {
+ property.value = value
+ }
+ return property
+}
+
+func argumentsDefineOwnProperty(self *_object, name string, descriptor _property, throw bool) bool {
+ if _, exists := self.value.(_argumentsObject).get(name); exists {
+ if !objectDefineOwnProperty(self, name, descriptor, false) {
+ return self.runtime.typeErrorResult(throw)
+ }
+ if value, valid := descriptor.value.(Value); valid {
+ self.value.(_argumentsObject).put(name, value)
+ }
+ return true
+ }
+ return objectDefineOwnProperty(self, name, descriptor, throw)
+}
+
+func argumentsDelete(self *_object, name string, throw bool) bool {
+ if !objectDelete(self, name, throw) {
+ return false
+ }
+ if _, exists := self.value.(_argumentsObject).get(name); exists {
+ self.value.(_argumentsObject).delete(name)
+ }
+ return true
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/type_array.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/type_array.go
new file mode 100644
index 000000000..236376a8e
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/type_array.go
@@ -0,0 +1,109 @@
+package otto
+
+import (
+ "strconv"
+)
+
+func (runtime *_runtime) newArrayObject(length uint32) *_object {
+ self := runtime.newObject()
+ self.class = "Array"
+ self.defineProperty("length", toValue_uint32(length), 0100, false)
+ self.objectClass = _classArray
+ return self
+}
+
+func isArray(object *_object) bool {
+ return object != nil && (object.class == "Array" || object.class == "GoArray")
+}
+
+func objectLength(object *_object) uint32 {
+ if object == nil {
+ return 0
+ }
+ switch object.class {
+ case "Array":
+ return object.get("length").value.(uint32)
+ case "String":
+ return uint32(object.get("length").value.(int))
+ case "GoArray":
+ return uint32(object.get("length").value.(int))
+ }
+ return 0
+}
+
+func arrayUint32(rt *_runtime, value Value) uint32 {
+ nm := value.number()
+ if nm.kind != numberInteger || !isUint32(nm.int64) {
+ // FIXME
+ panic(rt.panicRangeError())
+ }
+ return uint32(nm.int64)
+}
+
+func arrayDefineOwnProperty(self *_object, name string, descriptor _property, throw bool) bool {
+ lengthProperty := self.getOwnProperty("length")
+ lengthValue, valid := lengthProperty.value.(Value)
+ if !valid {
+ panic("Array.length != Value{}")
+ }
+ length := lengthValue.value.(uint32)
+ if name == "length" {
+ if descriptor.value == nil {
+ return objectDefineOwnProperty(self, name, descriptor, throw)
+ }
+ newLengthValue, isValue := descriptor.value.(Value)
+ if !isValue {
+ panic(self.runtime.panicTypeError())
+ }
+ newLength := arrayUint32(self.runtime, newLengthValue)
+ descriptor.value = toValue_uint32(newLength)
+ if newLength > length {
+ return objectDefineOwnProperty(self, name, descriptor, throw)
+ }
+ if !lengthProperty.writable() {
+ goto Reject
+ }
+ newWritable := true
+ if descriptor.mode&0700 == 0 {
+ // If writable is off
+ newWritable = false
+ descriptor.mode |= 0100
+ }
+ if !objectDefineOwnProperty(self, name, descriptor, throw) {
+ return false
+ }
+ for newLength < length {
+ length -= 1
+ if !self.delete(strconv.FormatInt(int64(length), 10), false) {
+ descriptor.value = toValue_uint32(length + 1)
+ if !newWritable {
+ descriptor.mode &= 0077
+ }
+ objectDefineOwnProperty(self, name, descriptor, false)
+ goto Reject
+ }
+ }
+ if !newWritable {
+ descriptor.mode &= 0077
+ objectDefineOwnProperty(self, name, descriptor, false)
+ }
+ } else if index := stringToArrayIndex(name); index >= 0 {
+ if index >= int64(length) && !lengthProperty.writable() {
+ goto Reject
+ }
+ if !objectDefineOwnProperty(self, strconv.FormatInt(index, 10), descriptor, false) {
+ goto Reject
+ }
+ if index >= int64(length) {
+ lengthProperty.value = toValue_uint32(uint32(index + 1))
+ objectDefineOwnProperty(self, "length", *lengthProperty, false)
+ return true
+ }
+ }
+ return objectDefineOwnProperty(self, name, descriptor, throw)
+Reject:
+ if throw {
+ panic(self.runtime.panicTypeError())
+ }
+ return false
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/type_boolean.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/type_boolean.go
new file mode 100644
index 000000000..afc45c69b
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/type_boolean.go
@@ -0,0 +1,13 @@
+package otto
+
+import (
+ "strconv"
+)
+
+func (runtime *_runtime) newBooleanObject(value Value) *_object {
+ return runtime.newPrimitiveObject("Boolean", toValue_bool(value.bool()))
+}
+
+func booleanToString(value bool) string {
+ return strconv.FormatBool(value)
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/type_date.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/type_date.go
new file mode 100644
index 000000000..7079e649c
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/type_date.go
@@ -0,0 +1,299 @@
+package otto
+
+import (
+ "fmt"
+ "math"
+ "regexp"
+ Time "time"
+)
+
+type _dateObject struct {
+ time Time.Time // Time from the "time" package, a cached version of time
+ epoch int64
+ value Value
+ isNaN bool
+}
+
+var (
+ invalidDateObject = _dateObject{
+ time: Time.Time{},
+ epoch: -1,
+ value: NaNValue(),
+ isNaN: true,
+ }
+)
+
+type _ecmaTime struct {
+ year int
+ month int
+ day int
+ hour int
+ minute int
+ second int
+ millisecond int
+ location *Time.Location // Basically, either local or UTC
+}
+
+func ecmaTime(goTime Time.Time) _ecmaTime {
+ return _ecmaTime{
+ goTime.Year(),
+ dateFromGoMonth(goTime.Month()),
+ goTime.Day(),
+ goTime.Hour(),
+ goTime.Minute(),
+ goTime.Second(),
+ goTime.Nanosecond() / (100 * 100 * 100),
+ goTime.Location(),
+ }
+}
+
+func (self *_ecmaTime) goTime() Time.Time {
+ return Time.Date(
+ self.year,
+ dateToGoMonth(self.month),
+ self.day,
+ self.hour,
+ self.minute,
+ self.second,
+ self.millisecond*(100*100*100),
+ self.location,
+ )
+}
+
+func (self *_dateObject) Time() Time.Time {
+ return self.time
+}
+
+func (self *_dateObject) Epoch() int64 {
+ return self.epoch
+}
+
+func (self *_dateObject) Value() Value {
+ return self.value
+}
+
+// FIXME A date should only be in the range of -100,000,000 to +100,000,000 (1970): 15.9.1.1
+func (self *_dateObject) SetNaN() {
+ self.time = Time.Time{}
+ self.epoch = -1
+ self.value = NaNValue()
+ self.isNaN = true
+}
+
+func (self *_dateObject) SetTime(time Time.Time) {
+ self.Set(timeToEpoch(time))
+}
+
+func epoch2dateObject(epoch float64) _dateObject {
+ date := _dateObject{}
+ date.Set(epoch)
+ return date
+}
+
+func (self *_dateObject) Set(epoch float64) {
+ // epoch
+ self.epoch = epochToInteger(epoch)
+
+ // time
+ time, err := epochToTime(epoch)
+ self.time = time // Is either a valid time, or the zero-value for time.Time
+
+ // value & isNaN
+ if err != nil {
+ self.isNaN = true
+ self.epoch = -1
+ self.value = NaNValue()
+ } else {
+ self.value = toValue_int64(self.epoch)
+ }
+}
+
+func epochToInteger(value float64) int64 {
+ if value > 0 {
+ return int64(math.Floor(value))
+ }
+ return int64(math.Ceil(value))
+}
+
+func epochToTime(value float64) (time Time.Time, err error) {
+ epochWithMilli := value
+ if math.IsNaN(epochWithMilli) || math.IsInf(epochWithMilli, 0) {
+ err = fmt.Errorf("Invalid time %v", value)
+ return
+ }
+
+ epoch := int64(epochWithMilli / 1000)
+ milli := int64(epochWithMilli) % 1000
+
+ time = Time.Unix(int64(epoch), milli*1000000).UTC()
+ return
+}
+
+func timeToEpoch(time Time.Time) float64 {
+ return float64(time.UnixNano() / (1000 * 1000))
+}
+
+func (runtime *_runtime) newDateObject(epoch float64) *_object {
+ self := runtime.newObject()
+ self.class = "Date"
+
+ // FIXME This is ugly...
+ date := _dateObject{}
+ date.Set(epoch)
+ self.value = date
+ return self
+}
+
+func (self *_object) dateValue() _dateObject {
+ value, _ := self.value.(_dateObject)
+ return value
+}
+
+func dateObjectOf(rt *_runtime, _dateObject *_object) _dateObject {
+ if _dateObject == nil || _dateObject.class != "Date" {
+ panic(rt.panicTypeError())
+ }
+ return _dateObject.dateValue()
+}
+
+// JavaScript is 0-based, Go is 1-based (15.9.1.4)
+func dateToGoMonth(month int) Time.Month {
+ return Time.Month(month + 1)
+}
+
+func dateFromGoMonth(month Time.Month) int {
+ return int(month) - 1
+}
+
+// Both JavaScript & Go are 0-based (Sunday == 0)
+func dateToGoDay(day int) Time.Weekday {
+ return Time.Weekday(day)
+}
+
+func dateFromGoDay(day Time.Weekday) int {
+ return int(day)
+}
+
+func newDateTime(argumentList []Value, location *Time.Location) (epoch float64) {
+
+ pick := func(index int, default_ float64) (float64, bool) {
+ if index >= len(argumentList) {
+ return default_, false
+ }
+ value := argumentList[index].float64()
+ if math.IsNaN(value) || math.IsInf(value, 0) {
+ return 0, true
+ }
+ return value, false
+ }
+
+ if len(argumentList) >= 2 { // 2-argument, 3-argument, ...
+ var year, month, day, hour, minute, second, millisecond float64
+ var invalid bool
+ if year, invalid = pick(0, 1900.0); invalid {
+ goto INVALID
+ }
+ if month, invalid = pick(1, 0.0); invalid {
+ goto INVALID
+ }
+ if day, invalid = pick(2, 1.0); invalid {
+ goto INVALID
+ }
+ if hour, invalid = pick(3, 0.0); invalid {
+ goto INVALID
+ }
+ if minute, invalid = pick(4, 0.0); invalid {
+ goto INVALID
+ }
+ if second, invalid = pick(5, 0.0); invalid {
+ goto INVALID
+ }
+ if millisecond, invalid = pick(6, 0.0); invalid {
+ goto INVALID
+ }
+
+ if year >= 0 && year <= 99 {
+ year += 1900
+ }
+
+ time := Time.Date(int(year), dateToGoMonth(int(month)), int(day), int(hour), int(minute), int(second), int(millisecond)*1000*1000, location)
+ return timeToEpoch(time)
+
+ } else if len(argumentList) == 0 { // 0-argument
+ time := Time.Now().UTC()
+ return timeToEpoch(time)
+ } else { // 1-argument
+ value := valueOfArrayIndex(argumentList, 0)
+ value = toPrimitive(value)
+ if value.IsString() {
+ return dateParse(value.string())
+ }
+
+ return value.float64()
+ }
+
+INVALID:
+ epoch = math.NaN()
+ return
+}
+
+var (
+ dateLayoutList = []string{
+ "2006",
+ "2006-01",
+ "2006-01-02",
+
+ "2006T15:04",
+ "2006-01T15:04",
+ "2006-01-02T15:04",
+
+ "2006T15:04:05",
+ "2006-01T15:04:05",
+ "2006-01-02T15:04:05",
+
+ "2006T15:04:05.000",
+ "2006-01T15:04:05.000",
+ "2006-01-02T15:04:05.000",
+
+ "2006T15:04-0700",
+ "2006-01T15:04-0700",
+ "2006-01-02T15:04-0700",
+
+ "2006T15:04:05-0700",
+ "2006-01T15:04:05-0700",
+ "2006-01-02T15:04:05-0700",
+
+ "2006T15:04:05.000-0700",
+ "2006-01T15:04:05.000-0700",
+ "2006-01-02T15:04:05.000-0700",
+
+ Time.RFC1123,
+ }
+ matchDateTimeZone = regexp.MustCompile(`^(.*)(?:(Z)|([\+\-]\d{2}):(\d{2}))$`)
+)
+
+func dateParse(date string) (epoch float64) {
+ // YYYY-MM-DDTHH:mm:ss.sssZ
+ var time Time.Time
+ var err error
+ {
+ date := date
+ if match := matchDateTimeZone.FindStringSubmatch(date); match != nil {
+ if match[2] == "Z" {
+ date = match[1] + "+0000"
+ } else {
+ date = match[1] + match[3] + match[4]
+ }
+ }
+ for _, layout := range dateLayoutList {
+ time, err = Time.Parse(layout, date)
+ if err == nil {
+ break
+ }
+ }
+ }
+ if err != nil {
+ return math.NaN()
+ }
+ return float64(time.UnixNano()) / (1000 * 1000) // UnixMilli()
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/type_error.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/type_error.go
new file mode 100644
index 000000000..c469f5fcb
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/type_error.go
@@ -0,0 +1,13 @@
+package otto
+
+func (rt *_runtime) newErrorObject(name string, message Value) *_object {
+ self := rt.newClassObject("Error")
+ if message.IsDefined() {
+ msg := message.string()
+ self.defineProperty("message", toValue_string(msg), 0111, false)
+ self.value = newError(rt, name, msg)
+ } else {
+ self.value = newError(rt, name)
+ }
+ return self
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/type_function.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/type_function.go
new file mode 100644
index 000000000..a5eb7554a
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/type_function.go
@@ -0,0 +1,262 @@
+package otto
+
+// _constructFunction
+type _constructFunction func(*_object, []Value) Value
+
+// 13.2.2 [[Construct]]
+func defaultConstruct(fn *_object, argumentList []Value) Value {
+ object := fn.runtime.newObject()
+ object.class = "Object"
+
+ prototype := fn.get("prototype")
+ if prototype.kind != valueObject {
+ prototype = toValue_object(fn.runtime.global.ObjectPrototype)
+ }
+ object.prototype = prototype._object()
+
+ this := toValue_object(object)
+ value := fn.call(this, argumentList, false, nativeFrame)
+ if value.kind == valueObject {
+ return value
+ }
+ return this
+}
+
+// _nativeFunction
+type _nativeFunction func(FunctionCall) Value
+
+// ===================== //
+// _nativeFunctionObject //
+// ===================== //
+
+type _nativeFunctionObject struct {
+ name string
+ call _nativeFunction // [[Call]]
+ construct _constructFunction // [[Construct]]
+}
+
+func (runtime *_runtime) newNativeFunctionObject(name string, native _nativeFunction, length int) *_object {
+ self := runtime.newClassObject("Function")
+ self.value = _nativeFunctionObject{
+ call: native,
+ construct: defaultConstruct,
+ }
+ self.defineProperty("length", toValue_int(length), 0000, false)
+ return self
+}
+
+// =================== //
+// _bindFunctionObject //
+// =================== //
+
+type _bindFunctionObject struct {
+ target *_object
+ this Value
+ argumentList []Value
+}
+
+func (runtime *_runtime) newBoundFunctionObject(target *_object, this Value, argumentList []Value) *_object {
+ self := runtime.newClassObject("Function")
+ self.value = _bindFunctionObject{
+ target: target,
+ this: this,
+ argumentList: argumentList,
+ }
+ length := int(toInt32(target.get("length")))
+ length -= len(argumentList)
+ if length < 0 {
+ length = 0
+ }
+ self.defineProperty("length", toValue_int(length), 0000, false)
+ self.defineProperty("caller", Value{}, 0000, false) // TODO Should throw a TypeError
+ self.defineProperty("arguments", Value{}, 0000, false) // TODO Should throw a TypeError
+ return self
+}
+
+// [[Construct]]
+func (fn _bindFunctionObject) construct(argumentList []Value) Value {
+ object := fn.target
+ switch value := object.value.(type) {
+ case _nativeFunctionObject:
+ return value.construct(object, fn.argumentList)
+ case _nodeFunctionObject:
+ argumentList = append(fn.argumentList, argumentList...)
+ return object.construct(argumentList)
+ }
+ panic(fn.target.runtime.panicTypeError())
+}
+
+// =================== //
+// _nodeFunctionObject //
+// =================== //
+
+type _nodeFunctionObject struct {
+ node *_nodeFunctionLiteral
+ stash _stash
+}
+
+func (runtime *_runtime) newNodeFunctionObject(node *_nodeFunctionLiteral, stash _stash) *_object {
+ self := runtime.newClassObject("Function")
+ self.value = _nodeFunctionObject{
+ node: node,
+ stash: stash,
+ }
+ self.defineProperty("length", toValue_int(len(node.parameterList)), 0000, false)
+ return self
+}
+
+// ======= //
+// _object //
+// ======= //
+
+func (self *_object) isCall() bool {
+ switch fn := self.value.(type) {
+ case _nativeFunctionObject:
+ return fn.call != nil
+ case _bindFunctionObject:
+ return true
+ case _nodeFunctionObject:
+ return true
+ }
+ return false
+}
+
+func (self *_object) call(this Value, argumentList []Value, eval bool, frame _frame) Value {
+ switch fn := self.value.(type) {
+
+ case _nativeFunctionObject:
+ // TODO Enter a scope, name from the native object...
+ // Since eval is a native function, we only have to check for it here
+ if eval {
+ eval = self == self.runtime.eval // If eval is true, then it IS a direct eval
+ }
+ return fn.call(FunctionCall{
+ runtime: self.runtime,
+ eval: eval,
+
+ This: this,
+ ArgumentList: argumentList,
+ Otto: self.runtime.otto,
+ })
+
+ case _bindFunctionObject:
+ // TODO Passthrough site, do not enter a scope
+ argumentList = append(fn.argumentList, argumentList...)
+ return fn.target.call(fn.this, argumentList, false, frame)
+
+ case _nodeFunctionObject:
+ rt := self.runtime
+ stash := rt.enterFunctionScope(fn.stash, this)
+ defer func() {
+ rt.leaveScope()
+ }()
+ rt.scope.frame = frame
+ callValue := rt.cmpl_call_nodeFunction(self, stash, fn.node, this, argumentList)
+ if value, valid := callValue.value.(_result); valid {
+ return value.value
+ }
+ return callValue
+ }
+
+ panic(self.runtime.panicTypeError("%v is not a function", toValue_object(self)))
+}
+
+func (self *_object) construct(argumentList []Value) Value {
+ switch fn := self.value.(type) {
+
+ case _nativeFunctionObject:
+ if fn.call == nil {
+ panic(self.runtime.panicTypeError("%v is not a function", toValue_object(self)))
+ }
+ if fn.construct == nil {
+ panic(self.runtime.panicTypeError("%v is not a constructor", toValue_object(self)))
+ }
+ return fn.construct(self, argumentList)
+
+ case _bindFunctionObject:
+ return fn.construct(argumentList)
+
+ case _nodeFunctionObject:
+ return defaultConstruct(self, argumentList)
+ }
+
+ panic(self.runtime.panicTypeError("%v is not a function", toValue_object(self)))
+}
+
+// 15.3.5.3
+func (self *_object) hasInstance(of Value) bool {
+ if !self.isCall() {
+ // We should not have a hasInstance method
+ panic(self.runtime.panicTypeError())
+ }
+ if !of.IsObject() {
+ return false
+ }
+ prototype := self.get("prototype")
+ if !prototype.IsObject() {
+ panic(self.runtime.panicTypeError())
+ }
+ prototypeObject := prototype._object()
+
+ value := of._object().prototype
+ for value != nil {
+ if value == prototypeObject {
+ return true
+ }
+ value = value.prototype
+ }
+ return false
+}
+
+// ============ //
+// FunctionCall //
+// ============ //
+
+// FunctionCall is an encapsulation of a JavaScript function call.
+type FunctionCall struct {
+ runtime *_runtime
+ _thisObject *_object
+ eval bool // This call is a direct call to eval
+
+ This Value
+ ArgumentList []Value
+ Otto *Otto
+}
+
+// Argument will return the value of the argument at the given index.
+//
+// If no such argument exists, undefined is returned.
+func (self FunctionCall) Argument(index int) Value {
+ return valueOfArrayIndex(self.ArgumentList, index)
+}
+
+func (self FunctionCall) getArgument(index int) (Value, bool) {
+ return getValueOfArrayIndex(self.ArgumentList, index)
+}
+
+func (self FunctionCall) slice(index int) []Value {
+ if index < len(self.ArgumentList) {
+ return self.ArgumentList[index:]
+ }
+ return []Value{}
+}
+
+func (self *FunctionCall) thisObject() *_object {
+ if self._thisObject == nil {
+ this := self.This.resolve() // FIXME Is this right?
+ self._thisObject = self.runtime.toObject(this)
+ }
+ return self._thisObject
+}
+
+func (self *FunctionCall) thisClassObject(class string) *_object {
+ thisObject := self.thisObject()
+ if thisObject.class != class {
+ panic(self.runtime.panicTypeError())
+ }
+ return self._thisObject
+}
+
+func (self FunctionCall) toObject(value Value) *_object {
+ return self.runtime.toObject(value)
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/type_go_array.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/type_go_array.go
new file mode 100644
index 000000000..13a0b10f2
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/type_go_array.go
@@ -0,0 +1,134 @@
+package otto
+
+import (
+ "reflect"
+ "strconv"
+)
+
+func (runtime *_runtime) newGoArrayObject(value reflect.Value) *_object {
+ self := runtime.newObject()
+ self.class = "GoArray"
+ self.objectClass = _classGoArray
+ self.value = _newGoArrayObject(value)
+ return self
+}
+
+type _goArrayObject struct {
+ value reflect.Value
+ writable bool
+ propertyMode _propertyMode
+}
+
+func _newGoArrayObject(value reflect.Value) *_goArrayObject {
+ writable := value.Kind() == reflect.Ptr // The Array is addressable (like a Slice)
+ mode := _propertyMode(0010)
+ if writable {
+ mode = 0110
+ }
+ self := &_goArrayObject{
+ value: value,
+ writable: writable,
+ propertyMode: mode,
+ }
+ return self
+}
+
+func (self _goArrayObject) getValue(index int64) (reflect.Value, bool) {
+ value := reflect.Indirect(self.value)
+ if index < int64(value.Len()) {
+ return value.Index(int(index)), true
+ }
+ return reflect.Value{}, false
+}
+
+func (self _goArrayObject) setValue(index int64, value Value) bool {
+ indexValue, exists := self.getValue(index)
+ if !exists {
+ return false
+ }
+ reflectValue, err := value.toReflectValue(reflect.Indirect(self.value).Type().Elem().Kind())
+ if err != nil {
+ panic(err)
+ }
+ indexValue.Set(reflectValue)
+ return true
+}
+
+func goArrayGetOwnProperty(self *_object, name string) *_property {
+ // length
+ if name == "length" {
+ return &_property{
+ value: toValue(reflect.Indirect(self.value.(*_goArrayObject).value).Len()),
+ mode: 0,
+ }
+ }
+
+ // .0, .1, .2, ...
+ index := stringToArrayIndex(name)
+ if index >= 0 {
+ object := self.value.(*_goArrayObject)
+ value := Value{}
+ reflectValue, exists := object.getValue(index)
+ if exists {
+ value = self.runtime.toValue(reflectValue.Interface())
+ }
+ return &_property{
+ value: value,
+ mode: object.propertyMode,
+ }
+ }
+
+ return objectGetOwnProperty(self, name)
+}
+
+func goArrayEnumerate(self *_object, all bool, each func(string) bool) {
+ object := self.value.(*_goArrayObject)
+ // .0, .1, .2, ...
+
+ for index, length := 0, object.value.Len(); index < length; index++ {
+ name := strconv.FormatInt(int64(index), 10)
+ if !each(name) {
+ return
+ }
+ }
+
+ objectEnumerate(self, all, each)
+}
+
+func goArrayDefineOwnProperty(self *_object, name string, descriptor _property, throw bool) bool {
+ if name == "length" {
+ return self.runtime.typeErrorResult(throw)
+ } else if index := stringToArrayIndex(name); index >= 0 {
+ object := self.value.(*_goArrayObject)
+ if object.writable {
+ if self.value.(*_goArrayObject).setValue(index, descriptor.value.(Value)) {
+ return true
+ }
+ }
+ return self.runtime.typeErrorResult(throw)
+ }
+ return objectDefineOwnProperty(self, name, descriptor, throw)
+}
+
+func goArrayDelete(self *_object, name string, throw bool) bool {
+ // length
+ if name == "length" {
+ return self.runtime.typeErrorResult(throw)
+ }
+
+ // .0, .1, .2, ...
+ index := stringToArrayIndex(name)
+ if index >= 0 {
+ object := self.value.(*_goArrayObject)
+ if object.writable {
+ indexValue, exists := object.getValue(index)
+ if exists {
+ indexValue.Set(reflect.Zero(reflect.Indirect(object.value).Type().Elem()))
+ return true
+ }
+ }
+ return self.runtime.typeErrorResult(throw)
+ }
+
+ return self.delete(name, throw)
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/type_go_map.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/type_go_map.go
new file mode 100644
index 000000000..542a2c29d
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/type_go_map.go
@@ -0,0 +1,87 @@
+package otto
+
+import (
+ "reflect"
+)
+
+func (runtime *_runtime) newGoMapObject(value reflect.Value) *_object {
+ self := runtime.newObject()
+ self.class = "Object" // TODO Should this be something else?
+ self.objectClass = _classGoMap
+ self.value = _newGoMapObject(value)
+ return self
+}
+
+type _goMapObject struct {
+ value reflect.Value
+ keyKind reflect.Kind
+ valueKind reflect.Kind
+}
+
+func _newGoMapObject(value reflect.Value) *_goMapObject {
+ if value.Kind() != reflect.Map {
+ dbgf("%/panic//%@: %v != reflect.Map", value.Kind())
+ }
+ self := &_goMapObject{
+ value: value,
+ keyKind: value.Type().Key().Kind(),
+ valueKind: value.Type().Elem().Kind(),
+ }
+ return self
+}
+
+func (self _goMapObject) toKey(name string) reflect.Value {
+ reflectValue, err := stringToReflectValue(name, self.keyKind)
+ if err != nil {
+ panic(err)
+ }
+ return reflectValue
+}
+
+func (self _goMapObject) toValue(value Value) reflect.Value {
+ reflectValue, err := value.toReflectValue(self.valueKind)
+ if err != nil {
+ panic(err)
+ }
+ return reflectValue
+}
+
+func goMapGetOwnProperty(self *_object, name string) *_property {
+ object := self.value.(*_goMapObject)
+ value := object.value.MapIndex(object.toKey(name))
+ if value.IsValid() {
+ return &_property{self.runtime.toValue(value.Interface()), 0111}
+ }
+
+ return nil
+}
+
+func goMapEnumerate(self *_object, all bool, each func(string) bool) {
+ object := self.value.(*_goMapObject)
+ keys := object.value.MapKeys()
+ for _, key := range keys {
+ if !each(key.String()) {
+ return
+ }
+ }
+}
+
+func goMapDefineOwnProperty(self *_object, name string, descriptor _property, throw bool) bool {
+ object := self.value.(*_goMapObject)
+ // TODO ...or 0222
+ if descriptor.mode != 0111 {
+ return self.runtime.typeErrorResult(throw)
+ }
+ if !descriptor.isDataDescriptor() {
+ return self.runtime.typeErrorResult(throw)
+ }
+ object.value.SetMapIndex(object.toKey(name), object.toValue(descriptor.value.(Value)))
+ return true
+}
+
+func goMapDelete(self *_object, name string, throw bool) bool {
+ object := self.value.(*_goMapObject)
+ object.value.SetMapIndex(object.toKey(name), reflect.Value{})
+ // FIXME
+ return true
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/type_go_slice.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/type_go_slice.go
new file mode 100644
index 000000000..7143531a8
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/type_go_slice.go
@@ -0,0 +1,118 @@
+package otto
+
+import (
+ "reflect"
+ "strconv"
+)
+
+func (runtime *_runtime) newGoSliceObject(value reflect.Value) *_object {
+ self := runtime.newObject()
+ self.class = "GoArray" // TODO GoSlice?
+ self.objectClass = _classGoSlice
+ self.value = _newGoSliceObject(value)
+ return self
+}
+
+type _goSliceObject struct {
+ value reflect.Value
+}
+
+func _newGoSliceObject(value reflect.Value) *_goSliceObject {
+ self := &_goSliceObject{
+ value: value,
+ }
+ return self
+}
+
+func (self _goSliceObject) getValue(index int64) (reflect.Value, bool) {
+ if index < int64(self.value.Len()) {
+ return self.value.Index(int(index)), true
+ }
+ return reflect.Value{}, false
+}
+
+func (self _goSliceObject) setValue(index int64, value Value) bool {
+ indexValue, exists := self.getValue(index)
+ if !exists {
+ return false
+ }
+ reflectValue, err := value.toReflectValue(self.value.Type().Elem().Kind())
+ if err != nil {
+ panic(err)
+ }
+ indexValue.Set(reflectValue)
+ return true
+}
+
+func goSliceGetOwnProperty(self *_object, name string) *_property {
+ // length
+ if name == "length" {
+ return &_property{
+ value: toValue(self.value.(*_goSliceObject).value.Len()),
+ mode: 0,
+ }
+ }
+
+ // .0, .1, .2, ...
+ index := stringToArrayIndex(name)
+ if index >= 0 {
+ value := Value{}
+ reflectValue, exists := self.value.(*_goSliceObject).getValue(index)
+ if exists {
+ value = self.runtime.toValue(reflectValue.Interface())
+ }
+ return &_property{
+ value: value,
+ mode: 0110,
+ }
+ }
+
+ return objectGetOwnProperty(self, name)
+}
+
+func goSliceEnumerate(self *_object, all bool, each func(string) bool) {
+ object := self.value.(*_goSliceObject)
+ // .0, .1, .2, ...
+
+ for index, length := 0, object.value.Len(); index < length; index++ {
+ name := strconv.FormatInt(int64(index), 10)
+ if !each(name) {
+ return
+ }
+ }
+
+ objectEnumerate(self, all, each)
+}
+
+func goSliceDefineOwnProperty(self *_object, name string, descriptor _property, throw bool) bool {
+ if name == "length" {
+ return self.runtime.typeErrorResult(throw)
+ } else if index := stringToArrayIndex(name); index >= 0 {
+ if self.value.(*_goSliceObject).setValue(index, descriptor.value.(Value)) {
+ return true
+ }
+ return self.runtime.typeErrorResult(throw)
+ }
+ return objectDefineOwnProperty(self, name, descriptor, throw)
+}
+
+func goSliceDelete(self *_object, name string, throw bool) bool {
+ // length
+ if name == "length" {
+ return self.runtime.typeErrorResult(throw)
+ }
+
+ // .0, .1, .2, ...
+ index := stringToArrayIndex(name)
+ if index >= 0 {
+ object := self.value.(*_goSliceObject)
+ indexValue, exists := object.getValue(index)
+ if exists {
+ indexValue.Set(reflect.Zero(object.value.Type().Elem()))
+ return true
+ }
+ return self.runtime.typeErrorResult(throw)
+ }
+
+ return self.delete(name, throw)
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/type_go_struct.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/type_go_struct.go
new file mode 100644
index 000000000..608ac6660
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/type_go_struct.go
@@ -0,0 +1,146 @@
+package otto
+
+import (
+ "encoding/json"
+ "reflect"
+)
+
+// FIXME Make a note about not being able to modify a struct unless it was
+// passed as a pointer-to: &struct{ ... }
+// This seems to be a limitation of the reflect package.
+// This goes for the other Go constructs too.
+// I guess we could get around it by either:
+// 1. Creating a new struct every time
+// 2. Creating an addressable? struct in the constructor
+
+func (runtime *_runtime) newGoStructObject(value reflect.Value) *_object {
+ self := runtime.newObject()
+ self.class = "Object" // TODO Should this be something else?
+ self.objectClass = _classGoStruct
+ self.value = _newGoStructObject(value)
+ return self
+}
+
+type _goStructObject struct {
+ value reflect.Value
+}
+
+func _newGoStructObject(value reflect.Value) *_goStructObject {
+ if reflect.Indirect(value).Kind() != reflect.Struct {
+ dbgf("%/panic//%@: %v != reflect.Struct", value.Kind())
+ }
+ self := &_goStructObject{
+ value: value,
+ }
+ return self
+}
+
+func (self _goStructObject) getValue(name string) reflect.Value {
+ if validGoStructName(name) {
+ // Do not reveal hidden or unexported fields
+ if field := reflect.Indirect(self.value).FieldByName(name); (field != reflect.Value{}) {
+ return field
+ }
+
+ if method := self.value.MethodByName(name); (method != reflect.Value{}) {
+ return method
+ }
+ }
+
+ return reflect.Value{}
+}
+
+func (self _goStructObject) field(name string) (reflect.StructField, bool) {
+ return reflect.Indirect(self.value).Type().FieldByName(name)
+}
+
+func (self _goStructObject) method(name string) (reflect.Method, bool) {
+ return reflect.Indirect(self.value).Type().MethodByName(name)
+}
+
+func (self _goStructObject) setValue(name string, value Value) bool {
+ field, exists := self.field(name)
+ if !exists {
+ return false
+ }
+ fieldValue := self.getValue(name)
+ reflectValue, err := value.toReflectValue(field.Type.Kind())
+ if err != nil {
+ panic(err)
+ }
+ fieldValue.Set(reflectValue)
+
+ return true
+}
+
+func goStructGetOwnProperty(self *_object, name string) *_property {
+ object := self.value.(*_goStructObject)
+ value := object.getValue(name)
+ if value.IsValid() {
+ return &_property{self.runtime.toValue(value.Interface()), 0110}
+ }
+
+ return objectGetOwnProperty(self, name)
+}
+
+func validGoStructName(name string) bool {
+ if name == "" {
+ return false
+ }
+ return 'A' <= name[0] && name[0] <= 'Z' // TODO What about Unicode?
+}
+
+func goStructEnumerate(self *_object, all bool, each func(string) bool) {
+ object := self.value.(*_goStructObject)
+
+ // Enumerate fields
+ for index := 0; index < reflect.Indirect(object.value).NumField(); index++ {
+ name := reflect.Indirect(object.value).Type().Field(index).Name
+ if validGoStructName(name) {
+ if !each(name) {
+ return
+ }
+ }
+ }
+
+ // Enumerate methods
+ for index := 0; index < object.value.NumMethod(); index++ {
+ name := object.value.Type().Method(index).Name
+ if validGoStructName(name) {
+ if !each(name) {
+ return
+ }
+ }
+ }
+
+ objectEnumerate(self, all, each)
+}
+
+func goStructCanPut(self *_object, name string) bool {
+ object := self.value.(*_goStructObject)
+ value := object.getValue(name)
+ if value.IsValid() {
+ return true
+ }
+
+ return objectCanPut(self, name)
+}
+
+func goStructPut(self *_object, name string, value Value, throw bool) {
+ object := self.value.(*_goStructObject)
+ if object.setValue(name, value) {
+ return
+ }
+
+ objectPut(self, name, value, throw)
+}
+
+func goStructMarshalJSON(self *_object) json.Marshaler {
+ object := self.value.(*_goStructObject)
+ goValue := reflect.Indirect(object.value).Interface()
+ switch marshaler := goValue.(type) {
+ case json.Marshaler:
+ return marshaler
+ }
+ return nil
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/type_number.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/type_number.go
new file mode 100644
index 000000000..28de4444c
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/type_number.go
@@ -0,0 +1,5 @@
+package otto
+
+func (runtime *_runtime) newNumberObject(value Value) *_object {
+ return runtime.newPrimitiveObject("Number", value.numberValue())
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/type_reference.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/type_reference.go
new file mode 100644
index 000000000..fd770c6f4
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/type_reference.go
@@ -0,0 +1,103 @@
+package otto
+
+type _reference interface {
+ invalid() bool // IsUnresolvableReference
+ getValue() Value // getValue
+ putValue(Value) string // PutValue
+ delete() bool
+}
+
+// PropertyReference
+
+type _propertyReference struct {
+ name string
+ strict bool
+ base *_object
+ runtime *_runtime
+ at _at
+}
+
+func newPropertyReference(rt *_runtime, base *_object, name string, strict bool, at _at) *_propertyReference {
+ return &_propertyReference{
+ runtime: rt,
+ name: name,
+ strict: strict,
+ base: base,
+ at: at,
+ }
+}
+
+func (self *_propertyReference) invalid() bool {
+ return self.base == nil
+}
+
+func (self *_propertyReference) getValue() Value {
+ if self.base == nil {
+ panic(self.runtime.panicReferenceError("'%s' is not defined", self.name, self.at))
+ }
+ return self.base.get(self.name)
+}
+
+func (self *_propertyReference) putValue(value Value) string {
+ if self.base == nil {
+ return self.name
+ }
+ self.base.put(self.name, value, self.strict)
+ return ""
+}
+
+func (self *_propertyReference) delete() bool {
+ if self.base == nil {
+ // TODO Throw an error if strict
+ return true
+ }
+ return self.base.delete(self.name, self.strict)
+}
+
+// ArgumentReference
+
+func newArgumentReference(runtime *_runtime, base *_object, name string, strict bool, at _at) *_propertyReference {
+ if base == nil {
+ panic(hereBeDragons())
+ }
+ return newPropertyReference(runtime, base, name, strict, at)
+}
+
+type _stashReference struct {
+ name string
+ strict bool
+ base _stash
+}
+
+func (self *_stashReference) invalid() bool {
+ return false // The base (an environment) will never be nil
+}
+
+func (self *_stashReference) getValue() Value {
+ return self.base.getBinding(self.name, self.strict)
+}
+
+func (self *_stashReference) putValue(value Value) string {
+ self.base.setValue(self.name, value, self.strict)
+ return ""
+}
+
+func (self *_stashReference) delete() bool {
+ if self.base == nil {
+ // This should never be reached, but just in case
+ return false
+ }
+ return self.base.deleteBinding(self.name)
+}
+
+// getIdentifierReference
+
+func getIdentifierReference(runtime *_runtime, stash _stash, name string, strict bool, at _at) _reference {
+ if stash == nil {
+ return newPropertyReference(runtime, nil, name, strict, at)
+ }
+ if stash.hasBinding(name) {
+ return stash.newReference(name, strict, at)
+ }
+ return getIdentifierReference(runtime, stash.outer(), name, strict, at)
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/type_regexp.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/type_regexp.go
new file mode 100644
index 000000000..57fe31640
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/type_regexp.go
@@ -0,0 +1,146 @@
+package otto
+
+import (
+ "fmt"
+ "regexp"
+ "unicode/utf8"
+
+ "github.com/robertkrimen/otto/parser"
+)
+
+type _regExpObject struct {
+ regularExpression *regexp.Regexp
+ global bool
+ ignoreCase bool
+ multiline bool
+ source string
+ flags string
+}
+
+func (runtime *_runtime) newRegExpObject(pattern string, flags string) *_object {
+ self := runtime.newObject()
+ self.class = "RegExp"
+
+ global := false
+ ignoreCase := false
+ multiline := false
+ re2flags := ""
+
+ // TODO Maybe clean up the panicking here... TypeError, SyntaxError, ?
+
+ for _, chr := range flags {
+ switch chr {
+ case 'g':
+ if global {
+ panic(runtime.panicSyntaxError("newRegExpObject: %s %s", pattern, flags))
+ }
+ global = true
+ case 'm':
+ if multiline {
+ panic(runtime.panicSyntaxError("newRegExpObject: %s %s", pattern, flags))
+ }
+ multiline = true
+ re2flags += "m"
+ case 'i':
+ if ignoreCase {
+ panic(runtime.panicSyntaxError("newRegExpObject: %s %s", pattern, flags))
+ }
+ ignoreCase = true
+ re2flags += "i"
+ }
+ }
+
+ re2pattern, err := parser.TransformRegExp(pattern)
+ if err != nil {
+ panic(runtime.panicTypeError("Invalid regular expression: %s", err.Error()))
+ }
+ if len(re2flags) > 0 {
+ re2pattern = fmt.Sprintf("(?%s:%s)", re2flags, re2pattern)
+ }
+
+ regularExpression, err := regexp.Compile(re2pattern)
+ if err != nil {
+ panic(runtime.panicSyntaxError("Invalid regular expression: %s", err.Error()[22:]))
+ }
+
+ self.value = _regExpObject{
+ regularExpression: regularExpression,
+ global: global,
+ ignoreCase: ignoreCase,
+ multiline: multiline,
+ source: pattern,
+ flags: flags,
+ }
+ self.defineProperty("global", toValue_bool(global), 0, false)
+ self.defineProperty("ignoreCase", toValue_bool(ignoreCase), 0, false)
+ self.defineProperty("multiline", toValue_bool(multiline), 0, false)
+ self.defineProperty("lastIndex", toValue_int(0), 0100, false)
+ self.defineProperty("source", toValue_string(pattern), 0, false)
+ return self
+}
+
+func (self *_object) regExpValue() _regExpObject {
+ value, _ := self.value.(_regExpObject)
+ return value
+}
+
+func execRegExp(this *_object, target string) (match bool, result []int) {
+ if this.class != "RegExp" {
+ panic(this.runtime.panicTypeError("Calling RegExp.exec on a non-RegExp object"))
+ }
+ lastIndex := this.get("lastIndex").number().int64
+ index := lastIndex
+ global := this.get("global").bool()
+ if !global {
+ index = 0
+ }
+ if 0 > index || index > int64(len(target)) {
+ } else {
+ result = this.regExpValue().regularExpression.FindStringSubmatchIndex(target[index:])
+ }
+ if result == nil {
+ //this.defineProperty("lastIndex", toValue_(0), 0111, true)
+ this.put("lastIndex", toValue_int(0), true)
+ return // !match
+ }
+ match = true
+ startIndex := index
+ endIndex := int(lastIndex) + result[1]
+ // We do this shift here because the .FindStringSubmatchIndex above
+ // was done on a local subordinate slice of the string, not the whole string
+ for index, _ := range result {
+ result[index] += int(startIndex)
+ }
+ if global {
+ //this.defineProperty("lastIndex", toValue_(endIndex), 0111, true)
+ this.put("lastIndex", toValue_int(endIndex), true)
+ }
+ return // match
+}
+
+func execResultToArray(runtime *_runtime, target string, result []int) *_object {
+ captureCount := len(result) / 2
+ valueArray := make([]Value, captureCount)
+ for index := 0; index < captureCount; index++ {
+ offset := 2 * index
+ if result[offset] != -1 {
+ valueArray[index] = toValue_string(target[result[offset]:result[offset+1]])
+ } else {
+ valueArray[index] = Value{}
+ }
+ }
+ matchIndex := result[0]
+ if matchIndex != 0 {
+ matchIndex = 0
+ // Find the rune index in the string, not the byte index
+ for index := 0; index < result[0]; {
+ _, size := utf8.DecodeRuneInString(target[index:])
+ matchIndex += 1
+ index += size
+ }
+ }
+ match := runtime.newArrayOf(valueArray)
+ match.defineProperty("input", toValue_string(target), 0111, false)
+ match.defineProperty("index", toValue_int(matchIndex), 0111, false)
+ return match
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/type_string.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/type_string.go
new file mode 100644
index 000000000..ef3afa42b
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/type_string.go
@@ -0,0 +1,112 @@
+package otto
+
+import (
+ "strconv"
+ "unicode/utf8"
+)
+
+type _stringObject interface {
+ Length() int
+ At(int) rune
+ String() string
+}
+
+type _stringASCII string
+
+func (str _stringASCII) Length() int {
+ return len(str)
+}
+
+func (str _stringASCII) At(at int) rune {
+ return rune(str[at])
+}
+
+func (str _stringASCII) String() string {
+ return string(str)
+}
+
+type _stringWide struct {
+ string string
+ length int
+ runes []rune
+}
+
+func (str _stringWide) Length() int {
+ return str.length
+}
+
+func (str _stringWide) At(at int) rune {
+ if str.runes == nil {
+ str.runes = []rune(str.string)
+ }
+ return str.runes[at]
+}
+
+func (str _stringWide) String() string {
+ return str.string
+}
+
+func _newStringObject(str string) _stringObject {
+ for i := 0; i < len(str); i++ {
+ if str[i] >= utf8.RuneSelf {
+ goto wide
+ }
+ }
+
+ return _stringASCII(str)
+
+wide:
+ return &_stringWide{
+ string: str,
+ length: utf8.RuneCountInString(str),
+ }
+}
+
+func stringAt(str _stringObject, index int) rune {
+ if 0 <= index && index < str.Length() {
+ return str.At(index)
+ }
+ return utf8.RuneError
+}
+
+func (runtime *_runtime) newStringObject(value Value) *_object {
+ str := _newStringObject(value.string())
+
+ self := runtime.newClassObject("String")
+ self.defineProperty("length", toValue_int(str.Length()), 0, false)
+ self.objectClass = _classString
+ self.value = str
+ return self
+}
+
+func (self *_object) stringValue() _stringObject {
+ if str, ok := self.value.(_stringObject); ok {
+ return str
+ }
+ return nil
+}
+
+func stringEnumerate(self *_object, all bool, each func(string) bool) {
+ if str := self.stringValue(); str != nil {
+ length := str.Length()
+ for index := 0; index < length; index++ {
+ if !each(strconv.FormatInt(int64(index), 10)) {
+ return
+ }
+ }
+ }
+ objectEnumerate(self, all, each)
+}
+
+func stringGetOwnProperty(self *_object, name string) *_property {
+ if property := objectGetOwnProperty(self, name); property != nil {
+ return property
+ }
+ // TODO Test a string of length >= +int32 + 1?
+ if index := stringToArrayIndex(name); index >= 0 {
+ if chr := stringAt(self.stringValue(), int(index)); chr != utf8.RuneError {
+ return &_property{toValue_string(string(chr)), 0}
+ }
+ }
+ return nil
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore/Makefile b/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore/Makefile
new file mode 100644
index 000000000..fc872917f
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore/Makefile
@@ -0,0 +1,11 @@
+.PHONY: source
+
+source: source.go
+
+underscore.js:
+ curl -kL http://underscorejs.org/underscore.js > $@
+
+source.go: underscore.js
+ go-bindata -f underscore -p underscore -u true < $< 2>/dev/null | grep -v '^//' | gofmt > $@
+ head -4 $< >> $@
+ mv $< ..
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore/README.markdown b/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore/README.markdown
new file mode 100644
index 000000000..bce37b695
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore/README.markdown
@@ -0,0 +1,53 @@
+# underscore
+--
+ import "github.com/robertkrimen/otto/underscore"
+
+Package underscore contains the source for the JavaScript utility-belt library.
+
+ import (
+ _ "github.com/robertkrimen/otto/underscore"
+ )
+ // Every Otto runtime will now include underscore
+
+http://underscorejs.org
+
+https://github.com/documentcloud/underscore
+
+By importing this package, you'll automatically load underscore every time you
+create a new Otto runtime.
+
+To prevent this behavior, you can do the following:
+
+ import (
+ "github.com/robertkrimen/otto/underscore"
+ )
+
+ func init() {
+ underscore.Disable()
+ }
+
+## Usage
+
+#### func Disable
+
+```go
+func Disable()
+```
+Disable underscore runtime inclusion.
+
+#### func Enable
+
+```go
+func Enable()
+```
+Enable underscore runtime inclusion.
+
+#### func Source
+
+```go
+func Source() string
+```
+Source returns the underscore source.
+
+--
+**godocdown** http://github.com/robertkrimen/godocdown
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore/source.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore/source.go
new file mode 100644
index 000000000..65754ab71
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore/source.go
@@ -0,0 +1,3462 @@
+package underscore
+
+func underscore() []byte {
+ return []byte{
+ 0x2f, 0x2f, 0x20, 0x20, 0x20, 0x20, 0x20, 0x55, 0x6e, 0x64, 0x65, 0x72,
+ 0x73, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x6a, 0x73, 0x20, 0x31, 0x2e, 0x34,
+ 0x2e, 0x34, 0x0a, 0x2f, 0x2f, 0x20, 0x20, 0x20, 0x20, 0x20, 0x68, 0x74,
+ 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x75, 0x6e, 0x64, 0x65, 0x72, 0x73, 0x63,
+ 0x6f, 0x72, 0x65, 0x6a, 0x73, 0x2e, 0x6f, 0x72, 0x67, 0x0a, 0x2f, 0x2f,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x28, 0x63, 0x29, 0x20, 0x32, 0x30, 0x30,
+ 0x39, 0x2d, 0x32, 0x30, 0x31, 0x33, 0x20, 0x4a, 0x65, 0x72, 0x65, 0x6d,
+ 0x79, 0x20, 0x41, 0x73, 0x68, 0x6b, 0x65, 0x6e, 0x61, 0x73, 0x2c, 0x20,
+ 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x43, 0x6c, 0x6f, 0x75,
+ 0x64, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x0a, 0x2f, 0x2f, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x55, 0x6e, 0x64, 0x65, 0x72, 0x73, 0x63, 0x6f, 0x72, 0x65,
+ 0x20, 0x6d, 0x61, 0x79, 0x20, 0x62, 0x65, 0x20, 0x66, 0x72, 0x65, 0x65,
+ 0x6c, 0x79, 0x20, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74,
+ 0x65, 0x64, 0x20, 0x75, 0x6e, 0x64, 0x65, 0x72, 0x20, 0x74, 0x68, 0x65,
+ 0x20, 0x4d, 0x49, 0x54, 0x20, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65,
+ 0x2e, 0x0a, 0x0a, 0x28, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
+ 0x28, 0x29, 0x20, 0x7b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x42,
+ 0x61, 0x73, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x20, 0x73, 0x65, 0x74, 0x75,
+ 0x70, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
+ 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x0a, 0x20,
+ 0x20, 0x2f, 0x2f, 0x20, 0x45, 0x73, 0x74, 0x61, 0x62, 0x6c, 0x69, 0x73,
+ 0x68, 0x20, 0x74, 0x68, 0x65, 0x20, 0x72, 0x6f, 0x6f, 0x74, 0x20, 0x6f,
+ 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2c, 0x20, 0x60, 0x77, 0x69, 0x6e, 0x64,
+ 0x6f, 0x77, 0x60, 0x20, 0x69, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x62,
+ 0x72, 0x6f, 0x77, 0x73, 0x65, 0x72, 0x2c, 0x20, 0x6f, 0x72, 0x20, 0x60,
+ 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x60, 0x20, 0x6f, 0x6e, 0x20, 0x74,
+ 0x68, 0x65, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x0a, 0x20,
+ 0x20, 0x76, 0x61, 0x72, 0x20, 0x72, 0x6f, 0x6f, 0x74, 0x20, 0x3d, 0x20,
+ 0x74, 0x68, 0x69, 0x73, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20,
+ 0x53, 0x61, 0x76, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20, 0x70, 0x72, 0x65,
+ 0x76, 0x69, 0x6f, 0x75, 0x73, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x20,
+ 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x60, 0x5f, 0x60, 0x20, 0x76,
+ 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x2e, 0x0a, 0x20, 0x20, 0x76,
+ 0x61, 0x72, 0x20, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x55,
+ 0x6e, 0x64, 0x65, 0x72, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x20, 0x3d, 0x20,
+ 0x72, 0x6f, 0x6f, 0x74, 0x2e, 0x5f, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f,
+ 0x2f, 0x20, 0x45, 0x73, 0x74, 0x61, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x20,
+ 0x74, 0x68, 0x65, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20, 0x74,
+ 0x68, 0x61, 0x74, 0x20, 0x67, 0x65, 0x74, 0x73, 0x20, 0x72, 0x65, 0x74,
+ 0x75, 0x72, 0x6e, 0x65, 0x64, 0x20, 0x74, 0x6f, 0x20, 0x62, 0x72, 0x65,
+ 0x61, 0x6b, 0x20, 0x6f, 0x75, 0x74, 0x20, 0x6f, 0x66, 0x20, 0x61, 0x20,
+ 0x6c, 0x6f, 0x6f, 0x70, 0x20, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x69,
+ 0x6f, 0x6e, 0x2e, 0x0a, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x62, 0x72,
+ 0x65, 0x61, 0x6b, 0x65, 0x72, 0x20, 0x3d, 0x20, 0x7b, 0x7d, 0x3b, 0x0a,
+ 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x53, 0x61, 0x76, 0x65, 0x20, 0x62,
+ 0x79, 0x74, 0x65, 0x73, 0x20, 0x69, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20,
+ 0x6d, 0x69, 0x6e, 0x69, 0x66, 0x69, 0x65, 0x64, 0x20, 0x28, 0x62, 0x75,
+ 0x74, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x67, 0x7a, 0x69, 0x70, 0x70, 0x65,
+ 0x64, 0x29, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3a, 0x0a,
+ 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x41, 0x72, 0x72, 0x61, 0x79, 0x50,
+ 0x72, 0x6f, 0x74, 0x6f, 0x20, 0x3d, 0x20, 0x41, 0x72, 0x72, 0x61, 0x79,
+ 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x74, 0x79, 0x70, 0x65, 0x2c, 0x20,
+ 0x4f, 0x62, 0x6a, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x20, 0x3d, 0x20, 0x4f,
+ 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x74,
+ 0x79, 0x70, 0x65, 0x2c, 0x20, 0x46, 0x75, 0x6e, 0x63, 0x50, 0x72, 0x6f,
+ 0x74, 0x6f, 0x20, 0x3d, 0x20, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f,
+ 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x74, 0x79, 0x70, 0x65, 0x3b,
+ 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x43, 0x72, 0x65, 0x61, 0x74,
+ 0x65, 0x20, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x20, 0x72, 0x65, 0x66, 0x65,
+ 0x72, 0x65, 0x6e, 0x63, 0x65, 0x20, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62,
+ 0x6c, 0x65, 0x73, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x73, 0x70, 0x65, 0x65,
+ 0x64, 0x20, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x20, 0x74, 0x6f, 0x20,
+ 0x63, 0x6f, 0x72, 0x65, 0x20, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x74, 0x79,
+ 0x70, 0x65, 0x73, 0x2e, 0x0a, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x70,
+ 0x75, 0x73, 0x68, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x41, 0x72, 0x72, 0x61, 0x79, 0x50,
+ 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x70, 0x75, 0x73, 0x68, 0x2c, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20,
+ 0x41, 0x72, 0x72, 0x61, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x73,
+ 0x6c, 0x69, 0x63, 0x65, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x63, 0x6f, 0x6e, 0x63, 0x61, 0x74, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x41, 0x72, 0x72, 0x61, 0x79,
+ 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6e, 0x63, 0x61, 0x74,
+ 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6f, 0x53, 0x74,
+ 0x72, 0x69, 0x6e, 0x67, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x3d, 0x20, 0x4f, 0x62, 0x6a, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
+ 0x74, 0x6f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2c, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x68, 0x61, 0x73, 0x4f, 0x77, 0x6e, 0x50, 0x72,
+ 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x4f,
+ 0x62, 0x6a, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x68, 0x61, 0x73, 0x4f,
+ 0x77, 0x6e, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x3b, 0x0a,
+ 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x41, 0x6c, 0x6c, 0x20, 0x2a, 0x2a,
+ 0x45, 0x43, 0x4d, 0x41, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x20, 0x35,
+ 0x2a, 0x2a, 0x20, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x20, 0x66, 0x75,
+ 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x69, 0x6d, 0x70, 0x6c, 0x65,
+ 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x74,
+ 0x68, 0x61, 0x74, 0x20, 0x77, 0x65, 0x20, 0x68, 0x6f, 0x70, 0x65, 0x20,
+ 0x74, 0x6f, 0x20, 0x75, 0x73, 0x65, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20,
+ 0x61, 0x72, 0x65, 0x20, 0x64, 0x65, 0x63, 0x6c, 0x61, 0x72, 0x65, 0x64,
+ 0x20, 0x68, 0x65, 0x72, 0x65, 0x2e, 0x0a, 0x20, 0x20, 0x76, 0x61, 0x72,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x46,
+ 0x6f, 0x72, 0x45, 0x61, 0x63, 0x68, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x3d, 0x20, 0x41, 0x72, 0x72, 0x61, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f,
+ 0x2e, 0x66, 0x6f, 0x72, 0x45, 0x61, 0x63, 0x68, 0x2c, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x4d, 0x61, 0x70, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x41,
+ 0x72, 0x72, 0x61, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x6d, 0x61,
+ 0x70, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6e, 0x61, 0x74, 0x69, 0x76,
+ 0x65, 0x52, 0x65, 0x64, 0x75, 0x63, 0x65, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x3d, 0x20, 0x41, 0x72, 0x72, 0x61, 0x79, 0x50, 0x72, 0x6f,
+ 0x74, 0x6f, 0x2e, 0x72, 0x65, 0x64, 0x75, 0x63, 0x65, 0x2c, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x52, 0x65, 0x64,
+ 0x75, 0x63, 0x65, 0x52, 0x69, 0x67, 0x68, 0x74, 0x20, 0x20, 0x3d, 0x20,
+ 0x41, 0x72, 0x72, 0x61, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72,
+ 0x65, 0x64, 0x75, 0x63, 0x65, 0x52, 0x69, 0x67, 0x68, 0x74, 0x2c, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x46, 0x69,
+ 0x6c, 0x74, 0x65, 0x72, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d,
+ 0x20, 0x41, 0x72, 0x72, 0x61, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
+ 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x45, 0x76, 0x65, 0x72, 0x79, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x41, 0x72, 0x72,
+ 0x61, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x76, 0x65, 0x72,
+ 0x79, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6e, 0x61, 0x74, 0x69, 0x76,
+ 0x65, 0x53, 0x6f, 0x6d, 0x65, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x3d, 0x20, 0x41, 0x72, 0x72, 0x61, 0x79, 0x50, 0x72, 0x6f,
+ 0x74, 0x6f, 0x2e, 0x73, 0x6f, 0x6d, 0x65, 0x2c, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78,
+ 0x4f, 0x66, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x41, 0x72,
+ 0x72, 0x61, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x69, 0x6e, 0x64,
+ 0x65, 0x78, 0x4f, 0x66, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6e, 0x61,
+ 0x74, 0x69, 0x76, 0x65, 0x4c, 0x61, 0x73, 0x74, 0x49, 0x6e, 0x64, 0x65,
+ 0x78, 0x4f, 0x66, 0x20, 0x20, 0x3d, 0x20, 0x41, 0x72, 0x72, 0x61, 0x79,
+ 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x6c, 0x61, 0x73, 0x74, 0x49, 0x6e,
+ 0x64, 0x65, 0x78, 0x4f, 0x66, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6e,
+ 0x61, 0x74, 0x69, 0x76, 0x65, 0x49, 0x73, 0x41, 0x72, 0x72, 0x61, 0x79,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x41, 0x72, 0x72, 0x61,
+ 0x79, 0x2e, 0x69, 0x73, 0x41, 0x72, 0x72, 0x61, 0x79, 0x2c, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x4b, 0x65, 0x79,
+ 0x73, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20,
+ 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2e, 0x6b, 0x65, 0x79, 0x73, 0x2c,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x42,
+ 0x69, 0x6e, 0x64, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x3d, 0x20, 0x46, 0x75, 0x6e, 0x63, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
+ 0x62, 0x69, 0x6e, 0x64, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20,
+ 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x20, 0x61, 0x20, 0x73, 0x61, 0x66,
+ 0x65, 0x20, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x20,
+ 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x55, 0x6e, 0x64, 0x65, 0x72,
+ 0x73, 0x63, 0x6f, 0x72, 0x65, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74,
+ 0x20, 0x66, 0x6f, 0x72, 0x20, 0x75, 0x73, 0x65, 0x20, 0x62, 0x65, 0x6c,
+ 0x6f, 0x77, 0x2e, 0x0a, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x5f, 0x20,
+ 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6f,
+ 0x62, 0x6a, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66,
+ 0x20, 0x28, 0x6f, 0x62, 0x6a, 0x20, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e,
+ 0x63, 0x65, 0x6f, 0x66, 0x20, 0x5f, 0x29, 0x20, 0x72, 0x65, 0x74, 0x75,
+ 0x72, 0x6e, 0x20, 0x6f, 0x62, 0x6a, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x69, 0x66, 0x20, 0x28, 0x21, 0x28, 0x74, 0x68, 0x69, 0x73, 0x20, 0x69,
+ 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x6f, 0x66, 0x20, 0x5f, 0x29,
+ 0x29, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6e, 0x65, 0x77,
+ 0x20, 0x5f, 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x5f, 0x77, 0x72, 0x61, 0x70, 0x70,
+ 0x65, 0x64, 0x20, 0x3d, 0x20, 0x6f, 0x62, 0x6a, 0x3b, 0x0a, 0x20, 0x20,
+ 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x45, 0x78, 0x70,
+ 0x6f, 0x72, 0x74, 0x20, 0x74, 0x68, 0x65, 0x20, 0x55, 0x6e, 0x64, 0x65,
+ 0x72, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63,
+ 0x74, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x2a, 0x2a, 0x4e, 0x6f, 0x64, 0x65,
+ 0x2e, 0x6a, 0x73, 0x2a, 0x2a, 0x2c, 0x20, 0x77, 0x69, 0x74, 0x68, 0x0a,
+ 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x62, 0x61, 0x63, 0x6b, 0x77, 0x61, 0x72,
+ 0x64, 0x73, 0x2d, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x74, 0x69, 0x62, 0x69,
+ 0x6c, 0x69, 0x74, 0x79, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x74, 0x68, 0x65,
+ 0x20, 0x6f, 0x6c, 0x64, 0x20, 0x60, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72,
+ 0x65, 0x28, 0x29, 0x60, 0x20, 0x41, 0x50, 0x49, 0x2e, 0x20, 0x49, 0x66,
+ 0x20, 0x77, 0x65, 0x27, 0x72, 0x65, 0x20, 0x69, 0x6e, 0x0a, 0x20, 0x20,
+ 0x2f, 0x2f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x62, 0x72, 0x6f, 0x77, 0x73,
+ 0x65, 0x72, 0x2c, 0x20, 0x61, 0x64, 0x64, 0x20, 0x60, 0x5f, 0x60, 0x20,
+ 0x61, 0x73, 0x20, 0x61, 0x20, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x20,
+ 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20, 0x76, 0x69, 0x61, 0x20, 0x61,
+ 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x20, 0x69, 0x64, 0x65, 0x6e,
+ 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x2c, 0x0a, 0x20, 0x20, 0x2f, 0x2f,
+ 0x20, 0x66, 0x6f, 0x72, 0x20, 0x43, 0x6c, 0x6f, 0x73, 0x75, 0x72, 0x65,
+ 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x22, 0x61,
+ 0x64, 0x76, 0x61, 0x6e, 0x63, 0x65, 0x64, 0x22, 0x20, 0x6d, 0x6f, 0x64,
+ 0x65, 0x2e, 0x0a, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x74, 0x79, 0x70,
+ 0x65, 0x6f, 0x66, 0x20, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x20,
+ 0x21, 0x3d, 0x3d, 0x20, 0x27, 0x75, 0x6e, 0x64, 0x65, 0x66, 0x69, 0x6e,
+ 0x65, 0x64, 0x27, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69,
+ 0x66, 0x20, 0x28, 0x74, 0x79, 0x70, 0x65, 0x6f, 0x66, 0x20, 0x6d, 0x6f,
+ 0x64, 0x75, 0x6c, 0x65, 0x20, 0x21, 0x3d, 0x3d, 0x20, 0x27, 0x75, 0x6e,
+ 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x64, 0x27, 0x20, 0x26, 0x26, 0x20,
+ 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x65, 0x78, 0x70, 0x6f, 0x72,
+ 0x74, 0x73, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x20, 0x3d, 0x20, 0x6d, 0x6f,
+ 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x73,
+ 0x20, 0x3d, 0x20, 0x5f, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x2e,
+ 0x5f, 0x20, 0x3d, 0x20, 0x5f, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x20, 0x65,
+ 0x6c, 0x73, 0x65, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x6f,
+ 0x6f, 0x74, 0x2e, 0x5f, 0x20, 0x3d, 0x20, 0x5f, 0x3b, 0x0a, 0x20, 0x20,
+ 0x7d, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x43, 0x75, 0x72, 0x72,
+ 0x65, 0x6e, 0x74, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x2e,
+ 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x56, 0x45, 0x52, 0x53, 0x49, 0x4f, 0x4e,
+ 0x20, 0x3d, 0x20, 0x27, 0x31, 0x2e, 0x34, 0x2e, 0x34, 0x27, 0x3b, 0x0a,
+ 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63,
+ 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f,
+ 0x6e, 0x73, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x2d, 0x2d, 0x2d, 0x2d,
+ 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
+ 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x54,
+ 0x68, 0x65, 0x20, 0x63, 0x6f, 0x72, 0x6e, 0x65, 0x72, 0x73, 0x74, 0x6f,
+ 0x6e, 0x65, 0x2c, 0x20, 0x61, 0x6e, 0x20, 0x60, 0x65, 0x61, 0x63, 0x68,
+ 0x60, 0x20, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x61,
+ 0x74, 0x69, 0x6f, 0x6e, 0x2c, 0x20, 0x61, 0x6b, 0x61, 0x20, 0x60, 0x66,
+ 0x6f, 0x72, 0x45, 0x61, 0x63, 0x68, 0x60, 0x2e, 0x0a, 0x20, 0x20, 0x2f,
+ 0x2f, 0x20, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x73, 0x20, 0x6f, 0x62,
+ 0x6a, 0x65, 0x63, 0x74, 0x73, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x74,
+ 0x68, 0x65, 0x20, 0x62, 0x75, 0x69, 0x6c, 0x74, 0x2d, 0x69, 0x6e, 0x20,
+ 0x60, 0x66, 0x6f, 0x72, 0x45, 0x61, 0x63, 0x68, 0x60, 0x2c, 0x20, 0x61,
+ 0x72, 0x72, 0x61, 0x79, 0x73, 0x2c, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x72,
+ 0x61, 0x77, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x2e, 0x0a,
+ 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x44, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74,
+ 0x65, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x2a, 0x2a, 0x45, 0x43, 0x4d, 0x41,
+ 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x20, 0x35, 0x2a, 0x2a, 0x27, 0x73,
+ 0x20, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x20, 0x60, 0x66, 0x6f, 0x72,
+ 0x45, 0x61, 0x63, 0x68, 0x60, 0x20, 0x69, 0x66, 0x20, 0x61, 0x76, 0x61,
+ 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x2e, 0x0a, 0x20, 0x20, 0x76, 0x61,
+ 0x72, 0x20, 0x65, 0x61, 0x63, 0x68, 0x20, 0x3d, 0x20, 0x5f, 0x2e, 0x65,
+ 0x61, 0x63, 0x68, 0x20, 0x3d, 0x20, 0x5f, 0x2e, 0x66, 0x6f, 0x72, 0x45,
+ 0x61, 0x63, 0x68, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69,
+ 0x6f, 0x6e, 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x69, 0x74, 0x65, 0x72,
+ 0x61, 0x74, 0x6f, 0x72, 0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78,
+ 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20,
+ 0x28, 0x6f, 0x62, 0x6a, 0x20, 0x3d, 0x3d, 0x20, 0x6e, 0x75, 0x6c, 0x6c,
+ 0x29, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x3b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65,
+ 0x46, 0x6f, 0x72, 0x45, 0x61, 0x63, 0x68, 0x20, 0x26, 0x26, 0x20, 0x6f,
+ 0x62, 0x6a, 0x2e, 0x66, 0x6f, 0x72, 0x45, 0x61, 0x63, 0x68, 0x20, 0x3d,
+ 0x3d, 0x3d, 0x20, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x46, 0x6f, 0x72,
+ 0x45, 0x61, 0x63, 0x68, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x6f, 0x62, 0x6a, 0x2e, 0x66, 0x6f, 0x72, 0x45, 0x61, 0x63,
+ 0x68, 0x28, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x2c, 0x20,
+ 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x29, 0x3b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x20, 0x69, 0x66, 0x20,
+ 0x28, 0x6f, 0x62, 0x6a, 0x2e, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x20,
+ 0x3d, 0x3d, 0x3d, 0x20, 0x2b, 0x6f, 0x62, 0x6a, 0x2e, 0x6c, 0x65, 0x6e,
+ 0x67, 0x74, 0x68, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x66, 0x6f, 0x72, 0x20, 0x28, 0x76, 0x61, 0x72, 0x20, 0x69, 0x20,
+ 0x3d, 0x20, 0x30, 0x2c, 0x20, 0x6c, 0x20, 0x3d, 0x20, 0x6f, 0x62, 0x6a,
+ 0x2e, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x3b, 0x20, 0x69, 0x20, 0x3c,
+ 0x20, 0x6c, 0x3b, 0x20, 0x69, 0x2b, 0x2b, 0x29, 0x20, 0x7b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x69,
+ 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x63, 0x61, 0x6c, 0x6c,
+ 0x28, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x2c, 0x20, 0x6f, 0x62,
+ 0x6a, 0x5b, 0x69, 0x5d, 0x2c, 0x20, 0x69, 0x2c, 0x20, 0x6f, 0x62, 0x6a,
+ 0x29, 0x20, 0x3d, 0x3d, 0x3d, 0x20, 0x62, 0x72, 0x65, 0x61, 0x6b, 0x65,
+ 0x72, 0x29, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x3b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d,
+ 0x20, 0x65, 0x6c, 0x73, 0x65, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x28, 0x76, 0x61, 0x72, 0x20, 0x6b,
+ 0x65, 0x79, 0x20, 0x69, 0x6e, 0x20, 0x6f, 0x62, 0x6a, 0x29, 0x20, 0x7b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20,
+ 0x28, 0x5f, 0x2e, 0x68, 0x61, 0x73, 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20,
+ 0x6b, 0x65, 0x79, 0x29, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x69, 0x74,
+ 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28,
+ 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x2c, 0x20, 0x6f, 0x62, 0x6a,
+ 0x5b, 0x6b, 0x65, 0x79, 0x5d, 0x2c, 0x20, 0x6b, 0x65, 0x79, 0x2c, 0x20,
+ 0x6f, 0x62, 0x6a, 0x29, 0x20, 0x3d, 0x3d, 0x3d, 0x20, 0x62, 0x72, 0x65,
+ 0x61, 0x6b, 0x65, 0x72, 0x29, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,
+ 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x7d, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f,
+ 0x20, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20,
+ 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x20, 0x6f, 0x66, 0x20, 0x61,
+ 0x70, 0x70, 0x6c, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x74, 0x68, 0x65, 0x20,
+ 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x20, 0x74, 0x6f, 0x20,
+ 0x65, 0x61, 0x63, 0x68, 0x20, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74,
+ 0x2e, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x44, 0x65, 0x6c, 0x65, 0x67,
+ 0x61, 0x74, 0x65, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x2a, 0x2a, 0x45, 0x43,
+ 0x4d, 0x41, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x20, 0x35, 0x2a, 0x2a,
+ 0x27, 0x73, 0x20, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x20, 0x60, 0x6d,
+ 0x61, 0x70, 0x60, 0x20, 0x69, 0x66, 0x20, 0x61, 0x76, 0x61, 0x69, 0x6c,
+ 0x61, 0x62, 0x6c, 0x65, 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x6d, 0x61,
+ 0x70, 0x20, 0x3d, 0x20, 0x5f, 0x2e, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63,
+ 0x74, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
+ 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74,
+ 0x6f, 0x72, 0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x29,
+ 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x72,
+ 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x20, 0x3d, 0x20, 0x5b, 0x5d, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x6f, 0x62, 0x6a,
+ 0x20, 0x3d, 0x3d, 0x20, 0x6e, 0x75, 0x6c, 0x6c, 0x29, 0x20, 0x72, 0x65,
+ 0x74, 0x75, 0x72, 0x6e, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73,
+ 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x6e, 0x61,
+ 0x74, 0x69, 0x76, 0x65, 0x4d, 0x61, 0x70, 0x20, 0x26, 0x26, 0x20, 0x6f,
+ 0x62, 0x6a, 0x2e, 0x6d, 0x61, 0x70, 0x20, 0x3d, 0x3d, 0x3d, 0x20, 0x6e,
+ 0x61, 0x74, 0x69, 0x76, 0x65, 0x4d, 0x61, 0x70, 0x29, 0x20, 0x72, 0x65,
+ 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6f, 0x62, 0x6a, 0x2e, 0x6d, 0x61, 0x70,
+ 0x28, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x2c, 0x20, 0x63,
+ 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x65, 0x61, 0x63, 0x68, 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x66,
+ 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x76, 0x61, 0x6c, 0x75,
+ 0x65, 0x2c, 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2c, 0x20, 0x6c, 0x69,
+ 0x73, 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x5b, 0x72, 0x65, 0x73, 0x75,
+ 0x6c, 0x74, 0x73, 0x2e, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x5d, 0x20,
+ 0x3d, 0x20, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x63,
+ 0x61, 0x6c, 0x6c, 0x28, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x2c,
+ 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2c, 0x20, 0x69, 0x6e, 0x64, 0x65,
+ 0x78, 0x2c, 0x20, 0x6c, 0x69, 0x73, 0x74, 0x29, 0x3b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x7d, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65,
+ 0x74, 0x75, 0x72, 0x6e, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73,
+ 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x76, 0x61,
+ 0x72, 0x20, 0x72, 0x65, 0x64, 0x75, 0x63, 0x65, 0x45, 0x72, 0x72, 0x6f,
+ 0x72, 0x20, 0x3d, 0x20, 0x27, 0x52, 0x65, 0x64, 0x75, 0x63, 0x65, 0x20,
+ 0x6f, 0x66, 0x20, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x20, 0x61, 0x72, 0x72,
+ 0x61, 0x79, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x6e, 0x6f, 0x20, 0x69,
+ 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65,
+ 0x27, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x2a, 0x2a, 0x52,
+ 0x65, 0x64, 0x75, 0x63, 0x65, 0x2a, 0x2a, 0x20, 0x62, 0x75, 0x69, 0x6c,
+ 0x64, 0x73, 0x20, 0x75, 0x70, 0x20, 0x61, 0x20, 0x73, 0x69, 0x6e, 0x67,
+ 0x6c, 0x65, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x20, 0x66, 0x72,
+ 0x6f, 0x6d, 0x20, 0x61, 0x20, 0x6c, 0x69, 0x73, 0x74, 0x20, 0x6f, 0x66,
+ 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x2c, 0x20, 0x61, 0x6b, 0x61,
+ 0x20, 0x60, 0x69, 0x6e, 0x6a, 0x65, 0x63, 0x74, 0x60, 0x2c, 0x0a, 0x20,
+ 0x20, 0x2f, 0x2f, 0x20, 0x6f, 0x72, 0x20, 0x60, 0x66, 0x6f, 0x6c, 0x64,
+ 0x6c, 0x60, 0x2e, 0x20, 0x44, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x65,
+ 0x73, 0x20, 0x74, 0x6f, 0x20, 0x2a, 0x2a, 0x45, 0x43, 0x4d, 0x41, 0x53,
+ 0x63, 0x72, 0x69, 0x70, 0x74, 0x20, 0x35, 0x2a, 0x2a, 0x27, 0x73, 0x20,
+ 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x20, 0x60, 0x72, 0x65, 0x64, 0x75,
+ 0x63, 0x65, 0x60, 0x20, 0x69, 0x66, 0x20, 0x61, 0x76, 0x61, 0x69, 0x6c,
+ 0x61, 0x62, 0x6c, 0x65, 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x72, 0x65,
+ 0x64, 0x75, 0x63, 0x65, 0x20, 0x3d, 0x20, 0x5f, 0x2e, 0x66, 0x6f, 0x6c,
+ 0x64, 0x6c, 0x20, 0x3d, 0x20, 0x5f, 0x2e, 0x69, 0x6e, 0x6a, 0x65, 0x63,
+ 0x74, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
+ 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74,
+ 0x6f, 0x72, 0x2c, 0x20, 0x6d, 0x65, 0x6d, 0x6f, 0x2c, 0x20, 0x63, 0x6f,
+ 0x6e, 0x74, 0x65, 0x78, 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x76, 0x61, 0x72, 0x20, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c,
+ 0x20, 0x3d, 0x20, 0x61, 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73,
+ 0x2e, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x20, 0x3e, 0x20, 0x32, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x6f, 0x62, 0x6a,
+ 0x20, 0x3d, 0x3d, 0x20, 0x6e, 0x75, 0x6c, 0x6c, 0x29, 0x20, 0x6f, 0x62,
+ 0x6a, 0x20, 0x3d, 0x20, 0x5b, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x69, 0x66, 0x20, 0x28, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x52, 0x65,
+ 0x64, 0x75, 0x63, 0x65, 0x20, 0x26, 0x26, 0x20, 0x6f, 0x62, 0x6a, 0x2e,
+ 0x72, 0x65, 0x64, 0x75, 0x63, 0x65, 0x20, 0x3d, 0x3d, 0x3d, 0x20, 0x6e,
+ 0x61, 0x74, 0x69, 0x76, 0x65, 0x52, 0x65, 0x64, 0x75, 0x63, 0x65, 0x29,
+ 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20,
+ 0x28, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x29, 0x20, 0x69, 0x74,
+ 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x5f, 0x2e, 0x62,
+ 0x69, 0x6e, 0x64, 0x28, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72,
+ 0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x29, 0x3b, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,
+ 0x20, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x20, 0x3f, 0x20, 0x6f,
+ 0x62, 0x6a, 0x2e, 0x72, 0x65, 0x64, 0x75, 0x63, 0x65, 0x28, 0x69, 0x74,
+ 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x2c, 0x20, 0x6d, 0x65, 0x6d, 0x6f,
+ 0x29, 0x20, 0x3a, 0x20, 0x6f, 0x62, 0x6a, 0x2e, 0x72, 0x65, 0x64, 0x75,
+ 0x63, 0x65, 0x28, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x29,
+ 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x65, 0x61, 0x63, 0x68, 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x66, 0x75,
+ 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x76, 0x61, 0x6c, 0x75, 0x65,
+ 0x2c, 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2c, 0x20, 0x6c, 0x69, 0x73,
+ 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69,
+ 0x66, 0x20, 0x28, 0x21, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x29,
+ 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6d,
+ 0x65, 0x6d, 0x6f, 0x20, 0x3d, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6e, 0x69,
+ 0x74, 0x69, 0x61, 0x6c, 0x20, 0x3d, 0x20, 0x74, 0x72, 0x75, 0x65, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, 0x73,
+ 0x65, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x6d, 0x65, 0x6d, 0x6f, 0x20, 0x3d, 0x20, 0x69, 0x74, 0x65, 0x72, 0x61,
+ 0x74, 0x6f, 0x72, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x63, 0x6f, 0x6e,
+ 0x74, 0x65, 0x78, 0x74, 0x2c, 0x20, 0x6d, 0x65, 0x6d, 0x6f, 0x2c, 0x20,
+ 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2c, 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78,
+ 0x2c, 0x20, 0x6c, 0x69, 0x73, 0x74, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x29, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x21, 0x69, 0x6e,
+ 0x69, 0x74, 0x69, 0x61, 0x6c, 0x29, 0x20, 0x74, 0x68, 0x72, 0x6f, 0x77,
+ 0x20, 0x6e, 0x65, 0x77, 0x20, 0x54, 0x79, 0x70, 0x65, 0x45, 0x72, 0x72,
+ 0x6f, 0x72, 0x28, 0x72, 0x65, 0x64, 0x75, 0x63, 0x65, 0x45, 0x72, 0x72,
+ 0x6f, 0x72, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74,
+ 0x75, 0x72, 0x6e, 0x20, 0x6d, 0x65, 0x6d, 0x6f, 0x3b, 0x0a, 0x20, 0x20,
+ 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x54, 0x68, 0x65,
+ 0x20, 0x72, 0x69, 0x67, 0x68, 0x74, 0x2d, 0x61, 0x73, 0x73, 0x6f, 0x63,
+ 0x69, 0x61, 0x74, 0x69, 0x76, 0x65, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69,
+ 0x6f, 0x6e, 0x20, 0x6f, 0x66, 0x20, 0x72, 0x65, 0x64, 0x75, 0x63, 0x65,
+ 0x2c, 0x20, 0x61, 0x6c, 0x73, 0x6f, 0x20, 0x6b, 0x6e, 0x6f, 0x77, 0x6e,
+ 0x20, 0x61, 0x73, 0x20, 0x60, 0x66, 0x6f, 0x6c, 0x64, 0x72, 0x60, 0x2e,
+ 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x44, 0x65, 0x6c, 0x65, 0x67, 0x61,
+ 0x74, 0x65, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x2a, 0x2a, 0x45, 0x43, 0x4d,
+ 0x41, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x20, 0x35, 0x2a, 0x2a, 0x27,
+ 0x73, 0x20, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x20, 0x60, 0x72, 0x65,
+ 0x64, 0x75, 0x63, 0x65, 0x52, 0x69, 0x67, 0x68, 0x74, 0x60, 0x20, 0x69,
+ 0x66, 0x20, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x2e,
+ 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x72, 0x65, 0x64, 0x75, 0x63, 0x65, 0x52,
+ 0x69, 0x67, 0x68, 0x74, 0x20, 0x3d, 0x20, 0x5f, 0x2e, 0x66, 0x6f, 0x6c,
+ 0x64, 0x72, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f,
+ 0x6e, 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x69, 0x74, 0x65, 0x72, 0x61,
+ 0x74, 0x6f, 0x72, 0x2c, 0x20, 0x6d, 0x65, 0x6d, 0x6f, 0x2c, 0x20, 0x63,
+ 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61,
+ 0x6c, 0x20, 0x3d, 0x20, 0x61, 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74,
+ 0x73, 0x2e, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x20, 0x3e, 0x20, 0x32,
+ 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x6f, 0x62,
+ 0x6a, 0x20, 0x3d, 0x3d, 0x20, 0x6e, 0x75, 0x6c, 0x6c, 0x29, 0x20, 0x6f,
+ 0x62, 0x6a, 0x20, 0x3d, 0x20, 0x5b, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x69, 0x66, 0x20, 0x28, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x52,
+ 0x65, 0x64, 0x75, 0x63, 0x65, 0x52, 0x69, 0x67, 0x68, 0x74, 0x20, 0x26,
+ 0x26, 0x20, 0x6f, 0x62, 0x6a, 0x2e, 0x72, 0x65, 0x64, 0x75, 0x63, 0x65,
+ 0x52, 0x69, 0x67, 0x68, 0x74, 0x20, 0x3d, 0x3d, 0x3d, 0x20, 0x6e, 0x61,
+ 0x74, 0x69, 0x76, 0x65, 0x52, 0x65, 0x64, 0x75, 0x63, 0x65, 0x52, 0x69,
+ 0x67, 0x68, 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x69, 0x66, 0x20, 0x28, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74,
+ 0x29, 0x20, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x20, 0x3d,
+ 0x20, 0x5f, 0x2e, 0x62, 0x69, 0x6e, 0x64, 0x28, 0x69, 0x74, 0x65, 0x72,
+ 0x61, 0x74, 0x6f, 0x72, 0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78,
+ 0x74, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65,
+ 0x74, 0x75, 0x72, 0x6e, 0x20, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c,
+ 0x20, 0x3f, 0x20, 0x6f, 0x62, 0x6a, 0x2e, 0x72, 0x65, 0x64, 0x75, 0x63,
+ 0x65, 0x52, 0x69, 0x67, 0x68, 0x74, 0x28, 0x69, 0x74, 0x65, 0x72, 0x61,
+ 0x74, 0x6f, 0x72, 0x2c, 0x20, 0x6d, 0x65, 0x6d, 0x6f, 0x29, 0x20, 0x3a,
+ 0x20, 0x6f, 0x62, 0x6a, 0x2e, 0x72, 0x65, 0x64, 0x75, 0x63, 0x65, 0x52,
+ 0x69, 0x67, 0x68, 0x74, 0x28, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f,
+ 0x72, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68,
+ 0x20, 0x3d, 0x20, 0x6f, 0x62, 0x6a, 0x2e, 0x6c, 0x65, 0x6e, 0x67, 0x74,
+ 0x68, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x6c,
+ 0x65, 0x6e, 0x67, 0x74, 0x68, 0x20, 0x21, 0x3d, 0x3d, 0x20, 0x2b, 0x6c,
+ 0x65, 0x6e, 0x67, 0x74, 0x68, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x6b, 0x65, 0x79, 0x73, 0x20,
+ 0x3d, 0x20, 0x5f, 0x2e, 0x6b, 0x65, 0x79, 0x73, 0x28, 0x6f, 0x62, 0x6a,
+ 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x6e,
+ 0x67, 0x74, 0x68, 0x20, 0x3d, 0x20, 0x6b, 0x65, 0x79, 0x73, 0x2e, 0x6c,
+ 0x65, 0x6e, 0x67, 0x74, 0x68, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x61, 0x63, 0x68, 0x28, 0x6f, 0x62,
+ 0x6a, 0x2c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28,
+ 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2c, 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78,
+ 0x2c, 0x20, 0x6c, 0x69, 0x73, 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x20, 0x3d, 0x20,
+ 0x6b, 0x65, 0x79, 0x73, 0x20, 0x3f, 0x20, 0x6b, 0x65, 0x79, 0x73, 0x5b,
+ 0x2d, 0x2d, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x5d, 0x20, 0x3a, 0x20,
+ 0x2d, 0x2d, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x3b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x21, 0x69, 0x6e, 0x69,
+ 0x74, 0x69, 0x61, 0x6c, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x6d, 0x65, 0x6d, 0x6f, 0x20, 0x3d, 0x20, 0x6f,
+ 0x62, 0x6a, 0x5b, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x5d, 0x3b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6e, 0x69, 0x74, 0x69,
+ 0x61, 0x6c, 0x20, 0x3d, 0x20, 0x74, 0x72, 0x75, 0x65, 0x3b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x20,
+ 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x65,
+ 0x6d, 0x6f, 0x20, 0x3d, 0x20, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f,
+ 0x72, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x63, 0x6f, 0x6e, 0x74, 0x65,
+ 0x78, 0x74, 0x2c, 0x20, 0x6d, 0x65, 0x6d, 0x6f, 0x2c, 0x20, 0x6f, 0x62,
+ 0x6a, 0x5b, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x5d, 0x2c, 0x20, 0x69, 0x6e,
+ 0x64, 0x65, 0x78, 0x2c, 0x20, 0x6c, 0x69, 0x73, 0x74, 0x29, 0x3b, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x7d, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28,
+ 0x21, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x29, 0x20, 0x74, 0x68,
+ 0x72, 0x6f, 0x77, 0x20, 0x6e, 0x65, 0x77, 0x20, 0x54, 0x79, 0x70, 0x65,
+ 0x45, 0x72, 0x72, 0x6f, 0x72, 0x28, 0x72, 0x65, 0x64, 0x75, 0x63, 0x65,
+ 0x45, 0x72, 0x72, 0x6f, 0x72, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6d, 0x65, 0x6d, 0x6f, 0x3b,
+ 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20,
+ 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x66,
+ 0x69, 0x72, 0x73, 0x74, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x20, 0x77,
+ 0x68, 0x69, 0x63, 0x68, 0x20, 0x70, 0x61, 0x73, 0x73, 0x65, 0x73, 0x20,
+ 0x61, 0x20, 0x74, 0x72, 0x75, 0x74, 0x68, 0x20, 0x74, 0x65, 0x73, 0x74,
+ 0x2e, 0x20, 0x41, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x64, 0x20, 0x61, 0x73,
+ 0x20, 0x60, 0x64, 0x65, 0x74, 0x65, 0x63, 0x74, 0x60, 0x2e, 0x0a, 0x20,
+ 0x20, 0x5f, 0x2e, 0x66, 0x69, 0x6e, 0x64, 0x20, 0x3d, 0x20, 0x5f, 0x2e,
+ 0x64, 0x65, 0x74, 0x65, 0x63, 0x74, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e,
+ 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x69,
+ 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x2c, 0x20, 0x63, 0x6f, 0x6e,
+ 0x74, 0x65, 0x78, 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x76, 0x61, 0x72, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x3b, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x61, 0x6e, 0x79, 0x28, 0x6f, 0x62, 0x6a, 0x2c,
+ 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x76, 0x61,
+ 0x6c, 0x75, 0x65, 0x2c, 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2c, 0x20,
+ 0x6c, 0x69, 0x73, 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74,
+ 0x6f, 0x72, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x63, 0x6f, 0x6e, 0x74,
+ 0x65, 0x78, 0x74, 0x2c, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2c, 0x20,
+ 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2c, 0x20, 0x6c, 0x69, 0x73, 0x74, 0x29,
+ 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x20, 0x3d, 0x20, 0x76, 0x61, 0x6c,
+ 0x75, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x74, 0x72, 0x75, 0x65, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x7d, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74,
+ 0x75, 0x72, 0x6e, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x3b, 0x0a,
+ 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x52,
+ 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x74, 0x68,
+ 0x65, 0x20, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x20, 0x74,
+ 0x68, 0x61, 0x74, 0x20, 0x70, 0x61, 0x73, 0x73, 0x20, 0x61, 0x20, 0x74,
+ 0x72, 0x75, 0x74, 0x68, 0x20, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x0a, 0x20,
+ 0x20, 0x2f, 0x2f, 0x20, 0x44, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x65,
+ 0x73, 0x20, 0x74, 0x6f, 0x20, 0x2a, 0x2a, 0x45, 0x43, 0x4d, 0x41, 0x53,
+ 0x63, 0x72, 0x69, 0x70, 0x74, 0x20, 0x35, 0x2a, 0x2a, 0x27, 0x73, 0x20,
+ 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x20, 0x60, 0x66, 0x69, 0x6c, 0x74,
+ 0x65, 0x72, 0x60, 0x20, 0x69, 0x66, 0x20, 0x61, 0x76, 0x61, 0x69, 0x6c,
+ 0x61, 0x62, 0x6c, 0x65, 0x2e, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x41,
+ 0x6c, 0x69, 0x61, 0x73, 0x65, 0x64, 0x20, 0x61, 0x73, 0x20, 0x60, 0x73,
+ 0x65, 0x6c, 0x65, 0x63, 0x74, 0x60, 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e,
+ 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x20, 0x3d, 0x20, 0x5f, 0x2e, 0x73,
+ 0x65, 0x6c, 0x65, 0x63, 0x74, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63,
+ 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x69, 0x74,
+ 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x74,
+ 0x65, 0x78, 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76,
+ 0x61, 0x72, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x20, 0x3d,
+ 0x20, 0x5b, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20,
+ 0x28, 0x6f, 0x62, 0x6a, 0x20, 0x3d, 0x3d, 0x20, 0x6e, 0x75, 0x6c, 0x6c,
+ 0x29, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x72, 0x65, 0x73,
+ 0x75, 0x6c, 0x74, 0x73, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66,
+ 0x20, 0x28, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x46, 0x69, 0x6c, 0x74,
+ 0x65, 0x72, 0x20, 0x26, 0x26, 0x20, 0x6f, 0x62, 0x6a, 0x2e, 0x66, 0x69,
+ 0x6c, 0x74, 0x65, 0x72, 0x20, 0x3d, 0x3d, 0x3d, 0x20, 0x6e, 0x61, 0x74,
+ 0x69, 0x76, 0x65, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x29, 0x20, 0x72,
+ 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6f, 0x62, 0x6a, 0x2e, 0x66, 0x69,
+ 0x6c, 0x74, 0x65, 0x72, 0x28, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f,
+ 0x72, 0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x29, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x61, 0x63, 0x68, 0x28, 0x6f, 0x62,
+ 0x6a, 0x2c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28,
+ 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2c, 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78,
+ 0x2c, 0x20, 0x6c, 0x69, 0x73, 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x69, 0x74, 0x65, 0x72,
+ 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x63, 0x6f,
+ 0x6e, 0x74, 0x65, 0x78, 0x74, 0x2c, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65,
+ 0x2c, 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2c, 0x20, 0x6c, 0x69, 0x73,
+ 0x74, 0x29, 0x29, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x5b,
+ 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x2e, 0x6c, 0x65, 0x6e, 0x67,
+ 0x74, 0x68, 0x5d, 0x20, 0x3d, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x72, 0x65, 0x73, 0x75,
+ 0x6c, 0x74, 0x73, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20,
+ 0x20, 0x2f, 0x2f, 0x20, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x61,
+ 0x6c, 0x6c, 0x20, 0x74, 0x68, 0x65, 0x20, 0x65, 0x6c, 0x65, 0x6d, 0x65,
+ 0x6e, 0x74, 0x73, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x77, 0x68, 0x69, 0x63,
+ 0x68, 0x20, 0x61, 0x20, 0x74, 0x72, 0x75, 0x74, 0x68, 0x20, 0x74, 0x65,
+ 0x73, 0x74, 0x20, 0x66, 0x61, 0x69, 0x6c, 0x73, 0x2e, 0x0a, 0x20, 0x20,
+ 0x5f, 0x2e, 0x72, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x20, 0x3d, 0x20, 0x66,
+ 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6f, 0x62, 0x6a, 0x2c,
+ 0x20, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x2c, 0x20, 0x63,
+ 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x2e, 0x66,
+ 0x69, 0x6c, 0x74, 0x65, 0x72, 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x66,
+ 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x76, 0x61, 0x6c, 0x75,
+ 0x65, 0x2c, 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2c, 0x20, 0x6c, 0x69,
+ 0x73, 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x21, 0x69, 0x74, 0x65, 0x72,
+ 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x63, 0x6f,
+ 0x6e, 0x74, 0x65, 0x78, 0x74, 0x2c, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65,
+ 0x2c, 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2c, 0x20, 0x6c, 0x69, 0x73,
+ 0x74, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x2c, 0x20, 0x63,
+ 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x7d,
+ 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x44, 0x65, 0x74, 0x65,
+ 0x72, 0x6d, 0x69, 0x6e, 0x65, 0x20, 0x77, 0x68, 0x65, 0x74, 0x68, 0x65,
+ 0x72, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65,
+ 0x20, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x20, 0x6d, 0x61,
+ 0x74, 0x63, 0x68, 0x20, 0x61, 0x20, 0x74, 0x72, 0x75, 0x74, 0x68, 0x20,
+ 0x74, 0x65, 0x73, 0x74, 0x2e, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x44,
+ 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x65, 0x73, 0x20, 0x74, 0x6f, 0x20,
+ 0x2a, 0x2a, 0x45, 0x43, 0x4d, 0x41, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74,
+ 0x20, 0x35, 0x2a, 0x2a, 0x27, 0x73, 0x20, 0x6e, 0x61, 0x74, 0x69, 0x76,
+ 0x65, 0x20, 0x60, 0x65, 0x76, 0x65, 0x72, 0x79, 0x60, 0x20, 0x69, 0x66,
+ 0x20, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x2e, 0x0a,
+ 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x41, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x64,
+ 0x20, 0x61, 0x73, 0x20, 0x60, 0x61, 0x6c, 0x6c, 0x60, 0x2e, 0x0a, 0x20,
+ 0x20, 0x5f, 0x2e, 0x65, 0x76, 0x65, 0x72, 0x79, 0x20, 0x3d, 0x20, 0x5f,
+ 0x2e, 0x61, 0x6c, 0x6c, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74,
+ 0x69, 0x6f, 0x6e, 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x69, 0x74, 0x65,
+ 0x72, 0x61, 0x74, 0x6f, 0x72, 0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65,
+ 0x78, 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x74,
+ 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x20, 0x7c, 0x7c, 0x20, 0x28, 0x69,
+ 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x5f, 0x2e,
+ 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x29, 0x3b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c,
+ 0x74, 0x20, 0x3d, 0x20, 0x74, 0x72, 0x75, 0x65, 0x3b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x6f, 0x62, 0x6a, 0x20, 0x3d, 0x3d,
+ 0x20, 0x6e, 0x75, 0x6c, 0x6c, 0x29, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72,
+ 0x6e, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x3b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65,
+ 0x45, 0x76, 0x65, 0x72, 0x79, 0x20, 0x26, 0x26, 0x20, 0x6f, 0x62, 0x6a,
+ 0x2e, 0x65, 0x76, 0x65, 0x72, 0x79, 0x20, 0x3d, 0x3d, 0x3d, 0x20, 0x6e,
+ 0x61, 0x74, 0x69, 0x76, 0x65, 0x45, 0x76, 0x65, 0x72, 0x79, 0x29, 0x20,
+ 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6f, 0x62, 0x6a, 0x2e, 0x65,
+ 0x76, 0x65, 0x72, 0x79, 0x28, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f,
+ 0x72, 0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x29, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x61, 0x63, 0x68, 0x28, 0x6f, 0x62,
+ 0x6a, 0x2c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28,
+ 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2c, 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78,
+ 0x2c, 0x20, 0x6c, 0x69, 0x73, 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x21, 0x28, 0x72, 0x65,
+ 0x73, 0x75, 0x6c, 0x74, 0x20, 0x3d, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c,
+ 0x74, 0x20, 0x26, 0x26, 0x20, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f,
+ 0x72, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x63, 0x6f, 0x6e, 0x74, 0x65,
+ 0x78, 0x74, 0x2c, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2c, 0x20, 0x69,
+ 0x6e, 0x64, 0x65, 0x78, 0x2c, 0x20, 0x6c, 0x69, 0x73, 0x74, 0x29, 0x29,
+ 0x29, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x62, 0x72, 0x65,
+ 0x61, 0x6b, 0x65, 0x72, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x29,
+ 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,
+ 0x20, 0x21, 0x21, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x3b, 0x0a, 0x20,
+ 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x44, 0x65,
+ 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x65, 0x20, 0x69, 0x66, 0x20, 0x61,
+ 0x74, 0x20, 0x6c, 0x65, 0x61, 0x73, 0x74, 0x20, 0x6f, 0x6e, 0x65, 0x20,
+ 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x69, 0x6e, 0x20, 0x74,
+ 0x68, 0x65, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20, 0x6d, 0x61,
+ 0x74, 0x63, 0x68, 0x65, 0x73, 0x20, 0x61, 0x20, 0x74, 0x72, 0x75, 0x74,
+ 0x68, 0x20, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x0a, 0x20, 0x20, 0x2f, 0x2f,
+ 0x20, 0x44, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x65, 0x73, 0x20, 0x74,
+ 0x6f, 0x20, 0x2a, 0x2a, 0x45, 0x43, 0x4d, 0x41, 0x53, 0x63, 0x72, 0x69,
+ 0x70, 0x74, 0x20, 0x35, 0x2a, 0x2a, 0x27, 0x73, 0x20, 0x6e, 0x61, 0x74,
+ 0x69, 0x76, 0x65, 0x20, 0x60, 0x73, 0x6f, 0x6d, 0x65, 0x60, 0x20, 0x69,
+ 0x66, 0x20, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x2e,
+ 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x41, 0x6c, 0x69, 0x61, 0x73, 0x65,
+ 0x64, 0x20, 0x61, 0x73, 0x20, 0x60, 0x61, 0x6e, 0x79, 0x60, 0x2e, 0x0a,
+ 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x61, 0x6e, 0x79, 0x20, 0x3d, 0x20,
+ 0x5f, 0x2e, 0x73, 0x6f, 0x6d, 0x65, 0x20, 0x3d, 0x20, 0x5f, 0x2e, 0x61,
+ 0x6e, 0x79, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f,
+ 0x6e, 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x69, 0x74, 0x65, 0x72, 0x61,
+ 0x74, 0x6f, 0x72, 0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74,
+ 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x74, 0x65, 0x72,
+ 0x61, 0x74, 0x6f, 0x72, 0x20, 0x7c, 0x7c, 0x20, 0x28, 0x69, 0x74, 0x65,
+ 0x72, 0x61, 0x74, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x5f, 0x2e, 0x69, 0x64,
+ 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x76, 0x61, 0x72, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x20,
+ 0x3d, 0x20, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x69, 0x66, 0x20, 0x28, 0x6f, 0x62, 0x6a, 0x20, 0x3d, 0x3d, 0x20,
+ 0x6e, 0x75, 0x6c, 0x6c, 0x29, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,
+ 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x3b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x69, 0x66, 0x20, 0x28, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x53,
+ 0x6f, 0x6d, 0x65, 0x20, 0x26, 0x26, 0x20, 0x6f, 0x62, 0x6a, 0x2e, 0x73,
+ 0x6f, 0x6d, 0x65, 0x20, 0x3d, 0x3d, 0x3d, 0x20, 0x6e, 0x61, 0x74, 0x69,
+ 0x76, 0x65, 0x53, 0x6f, 0x6d, 0x65, 0x29, 0x20, 0x72, 0x65, 0x74, 0x75,
+ 0x72, 0x6e, 0x20, 0x6f, 0x62, 0x6a, 0x2e, 0x73, 0x6f, 0x6d, 0x65, 0x28,
+ 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x2c, 0x20, 0x63, 0x6f,
+ 0x6e, 0x74, 0x65, 0x78, 0x74, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x65, 0x61, 0x63, 0x68, 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x66, 0x75,
+ 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x76, 0x61, 0x6c, 0x75, 0x65,
+ 0x2c, 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2c, 0x20, 0x6c, 0x69, 0x73,
+ 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69,
+ 0x66, 0x20, 0x28, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x20, 0x7c, 0x7c,
+ 0x20, 0x28, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x20, 0x3d, 0x20, 0x69,
+ 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x63, 0x61, 0x6c, 0x6c,
+ 0x28, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x2c, 0x20, 0x76, 0x61,
+ 0x6c, 0x75, 0x65, 0x2c, 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2c, 0x20,
+ 0x6c, 0x69, 0x73, 0x74, 0x29, 0x29, 0x29, 0x20, 0x72, 0x65, 0x74, 0x75,
+ 0x72, 0x6e, 0x20, 0x62, 0x72, 0x65, 0x61, 0x6b, 0x65, 0x72, 0x3b, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x7d, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x21, 0x21, 0x72, 0x65, 0x73,
+ 0x75, 0x6c, 0x74, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20,
+ 0x20, 0x2f, 0x2f, 0x20, 0x44, 0x65, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e,
+ 0x65, 0x20, 0x69, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x61, 0x72, 0x72,
+ 0x61, 0x79, 0x20, 0x6f, 0x72, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74,
+ 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x73, 0x20, 0x61, 0x20,
+ 0x67, 0x69, 0x76, 0x65, 0x6e, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x20,
+ 0x28, 0x75, 0x73, 0x69, 0x6e, 0x67, 0x20, 0x60, 0x3d, 0x3d, 0x3d, 0x60,
+ 0x29, 0x2e, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x41, 0x6c, 0x69, 0x61,
+ 0x73, 0x65, 0x64, 0x20, 0x61, 0x73, 0x20, 0x60, 0x69, 0x6e, 0x63, 0x6c,
+ 0x75, 0x64, 0x65, 0x60, 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x63, 0x6f,
+ 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x73, 0x20, 0x3d, 0x20, 0x5f, 0x2e, 0x69,
+ 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e,
+ 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x74,
+ 0x61, 0x72, 0x67, 0x65, 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x69, 0x66, 0x20, 0x28, 0x6f, 0x62, 0x6a, 0x20, 0x3d, 0x3d, 0x20,
+ 0x6e, 0x75, 0x6c, 0x6c, 0x29, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,
+ 0x20, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x69, 0x66, 0x20, 0x28, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x49, 0x6e,
+ 0x64, 0x65, 0x78, 0x4f, 0x66, 0x20, 0x26, 0x26, 0x20, 0x6f, 0x62, 0x6a,
+ 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x4f, 0x66, 0x20, 0x3d, 0x3d, 0x3d,
+ 0x20, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78,
+ 0x4f, 0x66, 0x29, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6f,
+ 0x62, 0x6a, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x4f, 0x66, 0x28, 0x74,
+ 0x61, 0x72, 0x67, 0x65, 0x74, 0x29, 0x20, 0x21, 0x3d, 0x20, 0x2d, 0x31,
+ 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,
+ 0x20, 0x61, 0x6e, 0x79, 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x66, 0x75,
+ 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x76, 0x61, 0x6c, 0x75, 0x65,
+ 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65,
+ 0x74, 0x75, 0x72, 0x6e, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x20, 0x3d,
+ 0x3d, 0x3d, 0x20, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x3b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x7d, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a,
+ 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x49, 0x6e, 0x76, 0x6f, 0x6b, 0x65,
+ 0x20, 0x61, 0x20, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x20, 0x28, 0x77,
+ 0x69, 0x74, 0x68, 0x20, 0x61, 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74,
+ 0x73, 0x29, 0x20, 0x6f, 0x6e, 0x20, 0x65, 0x76, 0x65, 0x72, 0x79, 0x20,
+ 0x69, 0x74, 0x65, 0x6d, 0x20, 0x69, 0x6e, 0x20, 0x61, 0x20, 0x63, 0x6f,
+ 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x0a, 0x20, 0x20,
+ 0x5f, 0x2e, 0x69, 0x6e, 0x76, 0x6f, 0x6b, 0x65, 0x20, 0x3d, 0x20, 0x66,
+ 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6f, 0x62, 0x6a, 0x2c,
+ 0x20, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x29, 0x20, 0x7b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x61, 0x72, 0x67, 0x73, 0x20,
+ 0x3d, 0x20, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x2e, 0x63, 0x61, 0x6c, 0x6c,
+ 0x28, 0x61, 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2c, 0x20,
+ 0x32, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20,
+ 0x69, 0x73, 0x46, 0x75, 0x6e, 0x63, 0x20, 0x3d, 0x20, 0x5f, 0x2e, 0x69,
+ 0x73, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6d, 0x65,
+ 0x74, 0x68, 0x6f, 0x64, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72,
+ 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x2e, 0x6d, 0x61, 0x70, 0x28,
+ 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f,
+ 0x6e, 0x28, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x29, 0x20, 0x7b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20,
+ 0x28, 0x69, 0x73, 0x46, 0x75, 0x6e, 0x63, 0x20, 0x3f, 0x20, 0x6d, 0x65,
+ 0x74, 0x68, 0x6f, 0x64, 0x20, 0x3a, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65,
+ 0x5b, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x5d, 0x29, 0x2e, 0x61, 0x70,
+ 0x70, 0x6c, 0x79, 0x28, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2c, 0x20, 0x61,
+ 0x72, 0x67, 0x73, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x29,
+ 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f,
+ 0x20, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x6e, 0x69, 0x65, 0x6e, 0x63, 0x65,
+ 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x66, 0x20,
+ 0x61, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x20, 0x75, 0x73, 0x65,
+ 0x20, 0x63, 0x61, 0x73, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x60, 0x6d, 0x61,
+ 0x70, 0x60, 0x3a, 0x20, 0x66, 0x65, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67,
+ 0x20, 0x61, 0x20, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x2e,
+ 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x70, 0x6c, 0x75, 0x63, 0x6b, 0x20, 0x3d,
+ 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6f, 0x62,
+ 0x6a, 0x2c, 0x20, 0x6b, 0x65, 0x79, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x2e, 0x6d,
+ 0x61, 0x70, 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x66, 0x75, 0x6e, 0x63,
+ 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x29, 0x7b,
+ 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x76, 0x61, 0x6c, 0x75,
+ 0x65, 0x5b, 0x6b, 0x65, 0x79, 0x5d, 0x3b, 0x20, 0x7d, 0x29, 0x3b, 0x0a,
+ 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x43,
+ 0x6f, 0x6e, 0x76, 0x65, 0x6e, 0x69, 0x65, 0x6e, 0x63, 0x65, 0x20, 0x76,
+ 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x66, 0x20, 0x61, 0x20,
+ 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x20, 0x75, 0x73, 0x65, 0x20, 0x63,
+ 0x61, 0x73, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x60, 0x66, 0x69, 0x6c, 0x74,
+ 0x65, 0x72, 0x60, 0x3a, 0x20, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x69,
+ 0x6e, 0x67, 0x20, 0x6f, 0x6e, 0x6c, 0x79, 0x20, 0x6f, 0x62, 0x6a, 0x65,
+ 0x63, 0x74, 0x73, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x63, 0x6f, 0x6e,
+ 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x20, 0x73, 0x70, 0x65, 0x63,
+ 0x69, 0x66, 0x69, 0x63, 0x20, 0x60, 0x6b, 0x65, 0x79, 0x3a, 0x76, 0x61,
+ 0x6c, 0x75, 0x65, 0x60, 0x20, 0x70, 0x61, 0x69, 0x72, 0x73, 0x2e, 0x0a,
+ 0x20, 0x20, 0x5f, 0x2e, 0x77, 0x68, 0x65, 0x72, 0x65, 0x20, 0x3d, 0x20,
+ 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6f, 0x62, 0x6a,
+ 0x2c, 0x20, 0x61, 0x74, 0x74, 0x72, 0x73, 0x2c, 0x20, 0x66, 0x69, 0x72,
+ 0x73, 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66,
+ 0x20, 0x28, 0x5f, 0x2e, 0x69, 0x73, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x28,
+ 0x61, 0x74, 0x74, 0x72, 0x73, 0x29, 0x29, 0x20, 0x72, 0x65, 0x74, 0x75,
+ 0x72, 0x6e, 0x20, 0x66, 0x69, 0x72, 0x73, 0x74, 0x20, 0x3f, 0x20, 0x6e,
+ 0x75, 0x6c, 0x6c, 0x20, 0x3a, 0x20, 0x5b, 0x5d, 0x3b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x5b, 0x66,
+ 0x69, 0x72, 0x73, 0x74, 0x20, 0x3f, 0x20, 0x27, 0x66, 0x69, 0x6e, 0x64,
+ 0x27, 0x20, 0x3a, 0x20, 0x27, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x27,
+ 0x5d, 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74,
+ 0x69, 0x6f, 0x6e, 0x28, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x29, 0x20, 0x7b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x28,
+ 0x76, 0x61, 0x72, 0x20, 0x6b, 0x65, 0x79, 0x20, 0x69, 0x6e, 0x20, 0x61,
+ 0x74, 0x74, 0x72, 0x73, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x61, 0x74, 0x74, 0x72,
+ 0x73, 0x5b, 0x6b, 0x65, 0x79, 0x5d, 0x20, 0x21, 0x3d, 0x3d, 0x20, 0x76,
+ 0x61, 0x6c, 0x75, 0x65, 0x5b, 0x6b, 0x65, 0x79, 0x5d, 0x29, 0x20, 0x72,
+ 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x74, 0x72,
+ 0x75, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x29, 0x3b, 0x0a,
+ 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x43,
+ 0x6f, 0x6e, 0x76, 0x65, 0x6e, 0x69, 0x65, 0x6e, 0x63, 0x65, 0x20, 0x76,
+ 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x66, 0x20, 0x61, 0x20,
+ 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x20, 0x75, 0x73, 0x65, 0x20, 0x63,
+ 0x61, 0x73, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x60, 0x66, 0x69, 0x6e, 0x64,
+ 0x60, 0x3a, 0x20, 0x67, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x20, 0x74,
+ 0x68, 0x65, 0x20, 0x66, 0x69, 0x72, 0x73, 0x74, 0x20, 0x6f, 0x62, 0x6a,
+ 0x65, 0x63, 0x74, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x63, 0x6f, 0x6e,
+ 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x20, 0x73, 0x70, 0x65, 0x63,
+ 0x69, 0x66, 0x69, 0x63, 0x20, 0x60, 0x6b, 0x65, 0x79, 0x3a, 0x76, 0x61,
+ 0x6c, 0x75, 0x65, 0x60, 0x20, 0x70, 0x61, 0x69, 0x72, 0x73, 0x2e, 0x0a,
+ 0x20, 0x20, 0x5f, 0x2e, 0x66, 0x69, 0x6e, 0x64, 0x57, 0x68, 0x65, 0x72,
+ 0x65, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
+ 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x61, 0x74, 0x74, 0x72, 0x73, 0x29,
+ 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72,
+ 0x6e, 0x20, 0x5f, 0x2e, 0x77, 0x68, 0x65, 0x72, 0x65, 0x28, 0x6f, 0x62,
+ 0x6a, 0x2c, 0x20, 0x61, 0x74, 0x74, 0x72, 0x73, 0x2c, 0x20, 0x74, 0x72,
+ 0x75, 0x65, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20,
+ 0x20, 0x2f, 0x2f, 0x20, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x74,
+ 0x68, 0x65, 0x20, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x20, 0x65,
+ 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x6f, 0x72, 0x20, 0x28, 0x65,
+ 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2d, 0x62, 0x61, 0x73, 0x65, 0x64,
+ 0x20, 0x63, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e,
+ 0x29, 0x2e, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x43, 0x61, 0x6e, 0x27,
+ 0x74, 0x20, 0x6f, 0x70, 0x74, 0x69, 0x6d, 0x69, 0x7a, 0x65, 0x20, 0x61,
+ 0x72, 0x72, 0x61, 0x79, 0x73, 0x20, 0x6f, 0x66, 0x20, 0x69, 0x6e, 0x74,
+ 0x65, 0x67, 0x65, 0x72, 0x73, 0x20, 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72,
+ 0x20, 0x74, 0x68, 0x61, 0x6e, 0x20, 0x36, 0x35, 0x2c, 0x35, 0x33, 0x35,
+ 0x20, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x0a, 0x20,
+ 0x20, 0x2f, 0x2f, 0x20, 0x53, 0x65, 0x65, 0x3a, 0x20, 0x68, 0x74, 0x74,
+ 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x62, 0x75, 0x67, 0x73, 0x2e, 0x77, 0x65,
+ 0x62, 0x6b, 0x69, 0x74, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x73, 0x68, 0x6f,
+ 0x77, 0x5f, 0x62, 0x75, 0x67, 0x2e, 0x63, 0x67, 0x69, 0x3f, 0x69, 0x64,
+ 0x3d, 0x38, 0x30, 0x37, 0x39, 0x37, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x6d,
+ 0x61, 0x78, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f,
+ 0x6e, 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x69, 0x74, 0x65, 0x72, 0x61,
+ 0x74, 0x6f, 0x72, 0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74,
+ 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28,
+ 0x21, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x20, 0x26, 0x26,
+ 0x20, 0x5f, 0x2e, 0x69, 0x73, 0x41, 0x72, 0x72, 0x61, 0x79, 0x28, 0x6f,
+ 0x62, 0x6a, 0x29, 0x20, 0x26, 0x26, 0x20, 0x6f, 0x62, 0x6a, 0x5b, 0x30,
+ 0x5d, 0x20, 0x3d, 0x3d, 0x3d, 0x20, 0x2b, 0x6f, 0x62, 0x6a, 0x5b, 0x30,
+ 0x5d, 0x20, 0x26, 0x26, 0x20, 0x6f, 0x62, 0x6a, 0x2e, 0x6c, 0x65, 0x6e,
+ 0x67, 0x74, 0x68, 0x20, 0x3c, 0x20, 0x36, 0x35, 0x35, 0x33, 0x35, 0x29,
+ 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74,
+ 0x75, 0x72, 0x6e, 0x20, 0x4d, 0x61, 0x74, 0x68, 0x2e, 0x6d, 0x61, 0x78,
+ 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x28, 0x4d, 0x61, 0x74, 0x68, 0x2c,
+ 0x20, 0x6f, 0x62, 0x6a, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x21, 0x69, 0x74,
+ 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x20, 0x26, 0x26, 0x20, 0x5f, 0x2e,
+ 0x69, 0x73, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x28, 0x6f, 0x62, 0x6a, 0x29,
+ 0x29, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x2d, 0x49, 0x6e,
+ 0x66, 0x69, 0x6e, 0x69, 0x74, 0x79, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x76, 0x61, 0x72, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x20, 0x3d,
+ 0x20, 0x7b, 0x63, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x65, 0x64, 0x20, 0x3a,
+ 0x20, 0x2d, 0x49, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x79, 0x2c, 0x20,
+ 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x20, 0x2d, 0x49, 0x6e, 0x66, 0x69,
+ 0x6e, 0x69, 0x74, 0x79, 0x7d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65,
+ 0x61, 0x63, 0x68, 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x66, 0x75, 0x6e,
+ 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2c,
+ 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2c, 0x20, 0x6c, 0x69, 0x73, 0x74,
+ 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61,
+ 0x72, 0x20, 0x63, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x65, 0x64, 0x20, 0x3d,
+ 0x20, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x20, 0x3f, 0x20,
+ 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x63, 0x61, 0x6c,
+ 0x6c, 0x28, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x2c, 0x20, 0x76,
+ 0x61, 0x6c, 0x75, 0x65, 0x2c, 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2c,
+ 0x20, 0x6c, 0x69, 0x73, 0x74, 0x29, 0x20, 0x3a, 0x20, 0x76, 0x61, 0x6c,
+ 0x75, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f,
+ 0x6d, 0x70, 0x75, 0x74, 0x65, 0x64, 0x20, 0x3e, 0x3d, 0x20, 0x72, 0x65,
+ 0x73, 0x75, 0x6c, 0x74, 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x65,
+ 0x64, 0x20, 0x26, 0x26, 0x20, 0x28, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74,
+ 0x20, 0x3d, 0x20, 0x7b, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x20, 0x3a, 0x20,
+ 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2c, 0x20, 0x63, 0x6f, 0x6d, 0x70, 0x75,
+ 0x74, 0x65, 0x64, 0x20, 0x3a, 0x20, 0x63, 0x6f, 0x6d, 0x70, 0x75, 0x74,
+ 0x65, 0x64, 0x7d, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x29,
+ 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,
+ 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x2e, 0x76, 0x61, 0x6c, 0x75,
+ 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f,
+ 0x2f, 0x20, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x74, 0x68, 0x65,
+ 0x20, 0x6d, 0x69, 0x6e, 0x69, 0x6d, 0x75, 0x6d, 0x20, 0x65, 0x6c, 0x65,
+ 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x28, 0x6f, 0x72, 0x20, 0x65, 0x6c, 0x65,
+ 0x6d, 0x65, 0x6e, 0x74, 0x2d, 0x62, 0x61, 0x73, 0x65, 0x64, 0x20, 0x63,
+ 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x29, 0x2e,
+ 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x6d, 0x69, 0x6e, 0x20, 0x3d, 0x20, 0x66,
+ 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6f, 0x62, 0x6a, 0x2c,
+ 0x20, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x2c, 0x20, 0x63,
+ 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x21, 0x69, 0x74, 0x65, 0x72, 0x61,
+ 0x74, 0x6f, 0x72, 0x20, 0x26, 0x26, 0x20, 0x5f, 0x2e, 0x69, 0x73, 0x41,
+ 0x72, 0x72, 0x61, 0x79, 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x20, 0x26, 0x26,
+ 0x20, 0x6f, 0x62, 0x6a, 0x5b, 0x30, 0x5d, 0x20, 0x3d, 0x3d, 0x3d, 0x20,
+ 0x2b, 0x6f, 0x62, 0x6a, 0x5b, 0x30, 0x5d, 0x20, 0x26, 0x26, 0x20, 0x6f,
+ 0x62, 0x6a, 0x2e, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x20, 0x3c, 0x20,
+ 0x36, 0x35, 0x35, 0x33, 0x35, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x4d, 0x61,
+ 0x74, 0x68, 0x2e, 0x6d, 0x69, 0x6e, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x79,
+ 0x28, 0x4d, 0x61, 0x74, 0x68, 0x2c, 0x20, 0x6f, 0x62, 0x6a, 0x29, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69,
+ 0x66, 0x20, 0x28, 0x21, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72,
+ 0x20, 0x26, 0x26, 0x20, 0x5f, 0x2e, 0x69, 0x73, 0x45, 0x6d, 0x70, 0x74,
+ 0x79, 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x29, 0x20, 0x72, 0x65, 0x74, 0x75,
+ 0x72, 0x6e, 0x20, 0x49, 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x79, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x72, 0x65, 0x73,
+ 0x75, 0x6c, 0x74, 0x20, 0x3d, 0x20, 0x7b, 0x63, 0x6f, 0x6d, 0x70, 0x75,
+ 0x74, 0x65, 0x64, 0x20, 0x3a, 0x20, 0x49, 0x6e, 0x66, 0x69, 0x6e, 0x69,
+ 0x74, 0x79, 0x2c, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x20, 0x49,
+ 0x6e, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x79, 0x7d, 0x3b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x65, 0x61, 0x63, 0x68, 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20,
+ 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x76, 0x61, 0x6c,
+ 0x75, 0x65, 0x2c, 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2c, 0x20, 0x6c,
+ 0x69, 0x73, 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x76, 0x61, 0x72, 0x20, 0x63, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x65,
+ 0x64, 0x20, 0x3d, 0x20, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72,
+ 0x20, 0x3f, 0x20, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x2e,
+ 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74,
+ 0x2c, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2c, 0x20, 0x69, 0x6e, 0x64,
+ 0x65, 0x78, 0x2c, 0x20, 0x6c, 0x69, 0x73, 0x74, 0x29, 0x20, 0x3a, 0x20,
+ 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x63, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x65, 0x64, 0x20, 0x3c, 0x20,
+ 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x75,
+ 0x74, 0x65, 0x64, 0x20, 0x26, 0x26, 0x20, 0x28, 0x72, 0x65, 0x73, 0x75,
+ 0x6c, 0x74, 0x20, 0x3d, 0x20, 0x7b, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x20,
+ 0x3a, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2c, 0x20, 0x63, 0x6f, 0x6d,
+ 0x70, 0x75, 0x74, 0x65, 0x64, 0x20, 0x3a, 0x20, 0x63, 0x6f, 0x6d, 0x70,
+ 0x75, 0x74, 0x65, 0x64, 0x7d, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x7d, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75,
+ 0x72, 0x6e, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x2e, 0x76, 0x61,
+ 0x6c, 0x75, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20,
+ 0x20, 0x2f, 0x2f, 0x20, 0x53, 0x68, 0x75, 0x66, 0x66, 0x6c, 0x65, 0x20,
+ 0x61, 0x6e, 0x20, 0x61, 0x72, 0x72, 0x61, 0x79, 0x2e, 0x0a, 0x20, 0x20,
+ 0x5f, 0x2e, 0x73, 0x68, 0x75, 0x66, 0x66, 0x6c, 0x65, 0x20, 0x3d, 0x20,
+ 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6f, 0x62, 0x6a,
+ 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20,
+ 0x72, 0x61, 0x6e, 0x64, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61,
+ 0x72, 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x20, 0x3d, 0x20, 0x30, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x73, 0x68, 0x75,
+ 0x66, 0x66, 0x6c, 0x65, 0x64, 0x20, 0x3d, 0x20, 0x5b, 0x5d, 0x3b, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x65, 0x61, 0x63, 0x68, 0x28, 0x6f, 0x62, 0x6a,
+ 0x2c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x76,
+ 0x61, 0x6c, 0x75, 0x65, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x72, 0x61, 0x6e, 0x64, 0x20, 0x3d, 0x20, 0x5f, 0x2e, 0x72,
+ 0x61, 0x6e, 0x64, 0x6f, 0x6d, 0x28, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2b,
+ 0x2b, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x73, 0x68,
+ 0x75, 0x66, 0x66, 0x6c, 0x65, 0x64, 0x5b, 0x69, 0x6e, 0x64, 0x65, 0x78,
+ 0x20, 0x2d, 0x20, 0x31, 0x5d, 0x20, 0x3d, 0x20, 0x73, 0x68, 0x75, 0x66,
+ 0x66, 0x6c, 0x65, 0x64, 0x5b, 0x72, 0x61, 0x6e, 0x64, 0x5d, 0x3b, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x73, 0x68, 0x75, 0x66, 0x66, 0x6c,
+ 0x65, 0x64, 0x5b, 0x72, 0x61, 0x6e, 0x64, 0x5d, 0x20, 0x3d, 0x20, 0x76,
+ 0x61, 0x6c, 0x75, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x29,
+ 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,
+ 0x20, 0x73, 0x68, 0x75, 0x66, 0x66, 0x6c, 0x65, 0x64, 0x3b, 0x0a, 0x20,
+ 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x41, 0x6e,
+ 0x20, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x20, 0x66, 0x75,
+ 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x74, 0x6f, 0x20, 0x67, 0x65,
+ 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x20, 0x6c, 0x6f, 0x6f, 0x6b, 0x75,
+ 0x70, 0x20, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x2e,
+ 0x0a, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x6c, 0x6f, 0x6f, 0x6b, 0x75,
+ 0x70, 0x49, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x20, 0x3d, 0x20,
+ 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x76, 0x61, 0x6c,
+ 0x75, 0x65, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65,
+ 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x2e, 0x69, 0x73, 0x46, 0x75, 0x6e,
+ 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x29,
+ 0x20, 0x3f, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x20, 0x3a, 0x20, 0x66,
+ 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6f, 0x62, 0x6a, 0x29,
+ 0x7b, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6f, 0x62, 0x6a,
+ 0x5b, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5d, 0x3b, 0x20, 0x7d, 0x3b, 0x0a,
+ 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x53,
+ 0x6f, 0x72, 0x74, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6f, 0x62, 0x6a, 0x65,
+ 0x63, 0x74, 0x27, 0x73, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x20,
+ 0x62, 0x79, 0x20, 0x61, 0x20, 0x63, 0x72, 0x69, 0x74, 0x65, 0x72, 0x69,
+ 0x6f, 0x6e, 0x20, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x64, 0x20,
+ 0x62, 0x79, 0x20, 0x61, 0x6e, 0x20, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74,
+ 0x6f, 0x72, 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x73, 0x6f, 0x72, 0x74,
+ 0x42, 0x79, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f,
+ 0x6e, 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65,
+ 0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x29, 0x20, 0x7b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x69, 0x74, 0x65,
+ 0x72, 0x61, 0x74, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x6c, 0x6f, 0x6f, 0x6b,
+ 0x75, 0x70, 0x49, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x28, 0x76,
+ 0x61, 0x6c, 0x75, 0x65, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72,
+ 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x2e, 0x70, 0x6c, 0x75, 0x63,
+ 0x6b, 0x28, 0x5f, 0x2e, 0x6d, 0x61, 0x70, 0x28, 0x6f, 0x62, 0x6a, 0x2c,
+ 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x76, 0x61,
+ 0x6c, 0x75, 0x65, 0x2c, 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2c, 0x20,
+ 0x6c, 0x69, 0x73, 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x7b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65,
+ 0x20, 0x3a, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2c, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x20,
+ 0x3a, 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2c, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x72, 0x69, 0x74, 0x65, 0x72, 0x69,
+ 0x61, 0x20, 0x3a, 0x20, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72,
+ 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78,
+ 0x74, 0x2c, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2c, 0x20, 0x69, 0x6e,
+ 0x64, 0x65, 0x78, 0x2c, 0x20, 0x6c, 0x69, 0x73, 0x74, 0x29, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x7d, 0x29, 0x2e, 0x73, 0x6f, 0x72, 0x74, 0x28, 0x66, 0x75, 0x6e, 0x63,
+ 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6c, 0x65, 0x66, 0x74, 0x2c, 0x20, 0x72,
+ 0x69, 0x67, 0x68, 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x61, 0x20, 0x3d, 0x20, 0x6c, 0x65,
+ 0x66, 0x74, 0x2e, 0x63, 0x72, 0x69, 0x74, 0x65, 0x72, 0x69, 0x61, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x62,
+ 0x20, 0x3d, 0x20, 0x72, 0x69, 0x67, 0x68, 0x74, 0x2e, 0x63, 0x72, 0x69,
+ 0x74, 0x65, 0x72, 0x69, 0x61, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x69, 0x66, 0x20, 0x28, 0x61, 0x20, 0x21, 0x3d, 0x3d, 0x20, 0x62,
+ 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x69, 0x66, 0x20, 0x28, 0x61, 0x20, 0x3e, 0x20, 0x62, 0x20, 0x7c, 0x7c,
+ 0x20, 0x61, 0x20, 0x3d, 0x3d, 0x3d, 0x20, 0x76, 0x6f, 0x69, 0x64, 0x20,
+ 0x30, 0x29, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x31, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20,
+ 0x28, 0x61, 0x20, 0x3c, 0x20, 0x62, 0x20, 0x7c, 0x7c, 0x20, 0x62, 0x20,
+ 0x3d, 0x3d, 0x3d, 0x20, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x30, 0x29, 0x20,
+ 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x2d, 0x31, 0x3b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6c, 0x65, 0x66, 0x74,
+ 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x20, 0x3c, 0x20, 0x72, 0x69, 0x67,
+ 0x68, 0x74, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x20, 0x3f, 0x20, 0x2d,
+ 0x31, 0x20, 0x3a, 0x20, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d,
+ 0x29, 0x2c, 0x20, 0x27, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x27, 0x29, 0x3b,
+ 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20,
+ 0x41, 0x6e, 0x20, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x20,
+ 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x75, 0x73, 0x65,
+ 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67,
+ 0x61, 0x74, 0x65, 0x20, 0x22, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x20, 0x62,
+ 0x79, 0x22, 0x20, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e,
+ 0x73, 0x2e, 0x0a, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x67, 0x72, 0x6f,
+ 0x75, 0x70, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f,
+ 0x6e, 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65,
+ 0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x2c, 0x20, 0x62,
+ 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x72, 0x29, 0x20, 0x7b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c,
+ 0x74, 0x20, 0x3d, 0x20, 0x7b, 0x7d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x76, 0x61, 0x72, 0x20, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72,
+ 0x20, 0x3d, 0x20, 0x6c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x49, 0x74, 0x65,
+ 0x72, 0x61, 0x74, 0x6f, 0x72, 0x28, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x20,
+ 0x7c, 0x7c, 0x20, 0x5f, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74,
+ 0x79, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x61, 0x63, 0x68,
+ 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69,
+ 0x6f, 0x6e, 0x28, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2c, 0x20, 0x69, 0x6e,
+ 0x64, 0x65, 0x78, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x76, 0x61, 0x72, 0x20, 0x6b, 0x65, 0x79, 0x20, 0x3d, 0x20, 0x69,
+ 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x63, 0x61, 0x6c, 0x6c,
+ 0x28, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x2c, 0x20, 0x76, 0x61,
+ 0x6c, 0x75, 0x65, 0x2c, 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2c, 0x20,
+ 0x6f, 0x62, 0x6a, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x62, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x72, 0x28, 0x72, 0x65, 0x73,
+ 0x75, 0x6c, 0x74, 0x2c, 0x20, 0x6b, 0x65, 0x79, 0x2c, 0x20, 0x76, 0x61,
+ 0x6c, 0x75, 0x65, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x29,
+ 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,
+ 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x3b, 0x0a, 0x20, 0x20, 0x7d,
+ 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x47, 0x72, 0x6f, 0x75,
+ 0x70, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63,
+ 0x74, 0x27, 0x73, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x20, 0x62,
+ 0x79, 0x20, 0x61, 0x20, 0x63, 0x72, 0x69, 0x74, 0x65, 0x72, 0x69, 0x6f,
+ 0x6e, 0x2e, 0x20, 0x50, 0x61, 0x73, 0x73, 0x20, 0x65, 0x69, 0x74, 0x68,
+ 0x65, 0x72, 0x20, 0x61, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x20,
+ 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x0a, 0x20, 0x20,
+ 0x2f, 0x2f, 0x20, 0x74, 0x6f, 0x20, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x20,
+ 0x62, 0x79, 0x2c, 0x20, 0x6f, 0x72, 0x20, 0x61, 0x20, 0x66, 0x75, 0x6e,
+ 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x74, 0x68, 0x61, 0x74, 0x20, 0x72,
+ 0x65, 0x74, 0x75, 0x72, 0x6e, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63,
+ 0x72, 0x69, 0x74, 0x65, 0x72, 0x69, 0x6f, 0x6e, 0x2e, 0x0a, 0x20, 0x20,
+ 0x5f, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x42, 0x79, 0x20, 0x3d, 0x20,
+ 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6f, 0x62, 0x6a,
+ 0x2c, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2c, 0x20, 0x63, 0x6f, 0x6e,
+ 0x74, 0x65, 0x78, 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x67, 0x72, 0x6f, 0x75, 0x70,
+ 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2c,
+ 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x2c, 0x20, 0x66, 0x75,
+ 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x72, 0x65, 0x73, 0x75, 0x6c,
+ 0x74, 0x2c, 0x20, 0x6b, 0x65, 0x79, 0x2c, 0x20, 0x76, 0x61, 0x6c, 0x75,
+ 0x65, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x28,
+ 0x5f, 0x2e, 0x68, 0x61, 0x73, 0x28, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74,
+ 0x2c, 0x20, 0x6b, 0x65, 0x79, 0x29, 0x20, 0x3f, 0x20, 0x72, 0x65, 0x73,
+ 0x75, 0x6c, 0x74, 0x5b, 0x6b, 0x65, 0x79, 0x5d, 0x20, 0x3a, 0x20, 0x28,
+ 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5b, 0x6b, 0x65, 0x79, 0x5d, 0x20,
+ 0x3d, 0x20, 0x5b, 0x5d, 0x29, 0x29, 0x2e, 0x70, 0x75, 0x73, 0x68, 0x28,
+ 0x76, 0x61, 0x6c, 0x75, 0x65, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x7d, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20,
+ 0x2f, 0x2f, 0x20, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x20, 0x69, 0x6e,
+ 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x20, 0x6f, 0x66, 0x20, 0x61,
+ 0x6e, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20, 0x74, 0x68, 0x61,
+ 0x74, 0x20, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x20, 0x62, 0x79, 0x20, 0x61,
+ 0x20, 0x63, 0x65, 0x72, 0x74, 0x61, 0x69, 0x6e, 0x20, 0x63, 0x72, 0x69,
+ 0x74, 0x65, 0x72, 0x69, 0x6f, 0x6e, 0x2e, 0x20, 0x50, 0x61, 0x73, 0x73,
+ 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x65, 0x69, 0x74, 0x68, 0x65, 0x72,
+ 0x20, 0x61, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x20, 0x61, 0x74,
+ 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x20, 0x74, 0x6f, 0x20, 0x63,
+ 0x6f, 0x75, 0x6e, 0x74, 0x20, 0x62, 0x79, 0x2c, 0x20, 0x6f, 0x72, 0x20,
+ 0x61, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x74,
+ 0x68, 0x61, 0x74, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x73, 0x20,
+ 0x74, 0x68, 0x65, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x63, 0x72, 0x69,
+ 0x74, 0x65, 0x72, 0x69, 0x6f, 0x6e, 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e,
+ 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x42, 0x79, 0x20, 0x3d, 0x20, 0x66, 0x75,
+ 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20,
+ 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65,
+ 0x78, 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65,
+ 0x74, 0x75, 0x72, 0x6e, 0x20, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x28, 0x6f,
+ 0x62, 0x6a, 0x2c, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2c, 0x20, 0x63,
+ 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x2c, 0x20, 0x66, 0x75, 0x6e, 0x63,
+ 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x2c,
+ 0x20, 0x6b, 0x65, 0x79, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x21, 0x5f, 0x2e, 0x68, 0x61, 0x73,
+ 0x28, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x2c, 0x20, 0x6b, 0x65, 0x79,
+ 0x29, 0x29, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5b, 0x6b, 0x65,
+ 0x79, 0x5d, 0x20, 0x3d, 0x20, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5b, 0x6b, 0x65, 0x79,
+ 0x5d, 0x2b, 0x2b, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x29, 0x3b,
+ 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20,
+ 0x55, 0x73, 0x65, 0x20, 0x61, 0x20, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x72,
+ 0x61, 0x74, 0x6f, 0x72, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f,
+ 0x6e, 0x20, 0x74, 0x6f, 0x20, 0x66, 0x69, 0x67, 0x75, 0x72, 0x65, 0x20,
+ 0x6f, 0x75, 0x74, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x6d, 0x61, 0x6c,
+ 0x6c, 0x65, 0x73, 0x74, 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x20, 0x61,
+ 0x74, 0x20, 0x77, 0x68, 0x69, 0x63, 0x68, 0x0a, 0x20, 0x20, 0x2f, 0x2f,
+ 0x20, 0x61, 0x6e, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20, 0x73,
+ 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x20, 0x62, 0x65, 0x20, 0x69, 0x6e, 0x73,
+ 0x65, 0x72, 0x74, 0x65, 0x64, 0x20, 0x73, 0x6f, 0x20, 0x61, 0x73, 0x20,
+ 0x74, 0x6f, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x20,
+ 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2e, 0x20, 0x55, 0x73, 0x65, 0x73, 0x20,
+ 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x20, 0x73, 0x65, 0x61, 0x72, 0x63,
+ 0x68, 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x73, 0x6f, 0x72, 0x74, 0x65,
+ 0x64, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e,
+ 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x61, 0x72, 0x72, 0x61, 0x79, 0x2c,
+ 0x20, 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74,
+ 0x6f, 0x72, 0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x29,
+ 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x74, 0x65, 0x72, 0x61,
+ 0x74, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74,
+ 0x6f, 0x72, 0x20, 0x3d, 0x3d, 0x20, 0x6e, 0x75, 0x6c, 0x6c, 0x20, 0x3f,
+ 0x20, 0x5f, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x20,
+ 0x3a, 0x20, 0x6c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x49, 0x74, 0x65, 0x72,
+ 0x61, 0x74, 0x6f, 0x72, 0x28, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f,
+ 0x72, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20,
+ 0x76, 0x61, 0x6c, 0x75, 0x65, 0x20, 0x3d, 0x20, 0x69, 0x74, 0x65, 0x72,
+ 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x63, 0x6f,
+ 0x6e, 0x74, 0x65, 0x78, 0x74, 0x2c, 0x20, 0x6f, 0x62, 0x6a, 0x29, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x6c, 0x6f, 0x77,
+ 0x20, 0x3d, 0x20, 0x30, 0x2c, 0x20, 0x68, 0x69, 0x67, 0x68, 0x20, 0x3d,
+ 0x20, 0x61, 0x72, 0x72, 0x61, 0x79, 0x2e, 0x6c, 0x65, 0x6e, 0x67, 0x74,
+ 0x68, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x77, 0x68, 0x69, 0x6c, 0x65,
+ 0x20, 0x28, 0x6c, 0x6f, 0x77, 0x20, 0x3c, 0x20, 0x68, 0x69, 0x67, 0x68,
+ 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61,
+ 0x72, 0x20, 0x6d, 0x69, 0x64, 0x20, 0x3d, 0x20, 0x28, 0x6c, 0x6f, 0x77,
+ 0x20, 0x2b, 0x20, 0x68, 0x69, 0x67, 0x68, 0x29, 0x20, 0x3e, 0x3e, 0x3e,
+ 0x20, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x74,
+ 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28,
+ 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x2c, 0x20, 0x61, 0x72, 0x72,
+ 0x61, 0x79, 0x5b, 0x6d, 0x69, 0x64, 0x5d, 0x29, 0x20, 0x3c, 0x20, 0x76,
+ 0x61, 0x6c, 0x75, 0x65, 0x20, 0x3f, 0x20, 0x6c, 0x6f, 0x77, 0x20, 0x3d,
+ 0x20, 0x6d, 0x69, 0x64, 0x20, 0x2b, 0x20, 0x31, 0x20, 0x3a, 0x20, 0x68,
+ 0x69, 0x67, 0x68, 0x20, 0x3d, 0x20, 0x6d, 0x69, 0x64, 0x3b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74,
+ 0x75, 0x72, 0x6e, 0x20, 0x6c, 0x6f, 0x77, 0x3b, 0x0a, 0x20, 0x20, 0x7d,
+ 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x53, 0x61, 0x66, 0x65,
+ 0x6c, 0x79, 0x20, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x20, 0x61,
+ 0x6e, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x20, 0x69, 0x74, 0x65, 0x72,
+ 0x61, 0x62, 0x6c, 0x65, 0x20, 0x69, 0x6e, 0x74, 0x6f, 0x20, 0x61, 0x20,
+ 0x72, 0x65, 0x61, 0x6c, 0x2c, 0x20, 0x6c, 0x69, 0x76, 0x65, 0x20, 0x61,
+ 0x72, 0x72, 0x61, 0x79, 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x74, 0x6f,
+ 0x41, 0x72, 0x72, 0x61, 0x79, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63,
+ 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x20, 0x7b, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x21, 0x6f, 0x62, 0x6a,
+ 0x29, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5b, 0x5d, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x5f, 0x2e, 0x69,
+ 0x73, 0x41, 0x72, 0x72, 0x61, 0x79, 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x29,
+ 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x73, 0x6c, 0x69, 0x63,
+ 0x65, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x6f, 0x62, 0x6a,
+ 0x2e, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x20, 0x3d, 0x3d, 0x3d, 0x20,
+ 0x2b, 0x6f, 0x62, 0x6a, 0x2e, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x29,
+ 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x2e, 0x6d, 0x61,
+ 0x70, 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x5f, 0x2e, 0x69, 0x64, 0x65,
+ 0x6e, 0x74, 0x69, 0x74, 0x79, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x2e, 0x76, 0x61, 0x6c,
+ 0x75, 0x65, 0x73, 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x3b, 0x0a, 0x20, 0x20,
+ 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x52, 0x65, 0x74,
+ 0x75, 0x72, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6e, 0x75, 0x6d, 0x62,
+ 0x65, 0x72, 0x20, 0x6f, 0x66, 0x20, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x6e,
+ 0x74, 0x73, 0x20, 0x69, 0x6e, 0x20, 0x61, 0x6e, 0x20, 0x6f, 0x62, 0x6a,
+ 0x65, 0x63, 0x74, 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x73, 0x69, 0x7a,
+ 0x65, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
+ 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x69, 0x66, 0x20, 0x28, 0x6f, 0x62, 0x6a, 0x20, 0x3d, 0x3d, 0x20, 0x6e,
+ 0x75, 0x6c, 0x6c, 0x29, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20,
+ 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72,
+ 0x6e, 0x20, 0x28, 0x6f, 0x62, 0x6a, 0x2e, 0x6c, 0x65, 0x6e, 0x67, 0x74,
+ 0x68, 0x20, 0x3d, 0x3d, 0x3d, 0x20, 0x2b, 0x6f, 0x62, 0x6a, 0x2e, 0x6c,
+ 0x65, 0x6e, 0x67, 0x74, 0x68, 0x29, 0x20, 0x3f, 0x20, 0x6f, 0x62, 0x6a,
+ 0x2e, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x20, 0x3a, 0x20, 0x5f, 0x2e,
+ 0x6b, 0x65, 0x79, 0x73, 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x2e, 0x6c, 0x65,
+ 0x6e, 0x67, 0x74, 0x68, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a,
+ 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x41, 0x72, 0x72, 0x61, 0x79, 0x20, 0x46,
+ 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x0a, 0x20, 0x20, 0x2f,
+ 0x2f, 0x20, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
+ 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20,
+ 0x47, 0x65, 0x74, 0x20, 0x74, 0x68, 0x65, 0x20, 0x66, 0x69, 0x72, 0x73,
+ 0x74, 0x20, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x6f, 0x66,
+ 0x20, 0x61, 0x6e, 0x20, 0x61, 0x72, 0x72, 0x61, 0x79, 0x2e, 0x20, 0x50,
+ 0x61, 0x73, 0x73, 0x69, 0x6e, 0x67, 0x20, 0x2a, 0x2a, 0x6e, 0x2a, 0x2a,
+ 0x20, 0x77, 0x69, 0x6c, 0x6c, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,
+ 0x20, 0x74, 0x68, 0x65, 0x20, 0x66, 0x69, 0x72, 0x73, 0x74, 0x20, 0x4e,
+ 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73,
+ 0x20, 0x69, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x61, 0x72, 0x72, 0x61,
+ 0x79, 0x2e, 0x20, 0x41, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x64, 0x20, 0x61,
+ 0x73, 0x20, 0x60, 0x68, 0x65, 0x61, 0x64, 0x60, 0x20, 0x61, 0x6e, 0x64,
+ 0x20, 0x60, 0x74, 0x61, 0x6b, 0x65, 0x60, 0x2e, 0x20, 0x54, 0x68, 0x65,
+ 0x20, 0x2a, 0x2a, 0x67, 0x75, 0x61, 0x72, 0x64, 0x2a, 0x2a, 0x20, 0x63,
+ 0x68, 0x65, 0x63, 0x6b, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x61, 0x6c,
+ 0x6c, 0x6f, 0x77, 0x73, 0x20, 0x69, 0x74, 0x20, 0x74, 0x6f, 0x20, 0x77,
+ 0x6f, 0x72, 0x6b, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x60, 0x5f, 0x2e,
+ 0x6d, 0x61, 0x70, 0x60, 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x66, 0x69,
+ 0x72, 0x73, 0x74, 0x20, 0x3d, 0x20, 0x5f, 0x2e, 0x68, 0x65, 0x61, 0x64,
+ 0x20, 0x3d, 0x20, 0x5f, 0x2e, 0x74, 0x61, 0x6b, 0x65, 0x20, 0x3d, 0x20,
+ 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x61, 0x72, 0x72,
+ 0x61, 0x79, 0x2c, 0x20, 0x6e, 0x2c, 0x20, 0x67, 0x75, 0x61, 0x72, 0x64,
+ 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28,
+ 0x61, 0x72, 0x72, 0x61, 0x79, 0x20, 0x3d, 0x3d, 0x20, 0x6e, 0x75, 0x6c,
+ 0x6c, 0x29, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x76, 0x6f,
+ 0x69, 0x64, 0x20, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65,
+ 0x74, 0x75, 0x72, 0x6e, 0x20, 0x28, 0x6e, 0x20, 0x21, 0x3d, 0x20, 0x6e,
+ 0x75, 0x6c, 0x6c, 0x29, 0x20, 0x26, 0x26, 0x20, 0x21, 0x67, 0x75, 0x61,
+ 0x72, 0x64, 0x20, 0x3f, 0x20, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x2e, 0x63,
+ 0x61, 0x6c, 0x6c, 0x28, 0x61, 0x72, 0x72, 0x61, 0x79, 0x2c, 0x20, 0x30,
+ 0x2c, 0x20, 0x6e, 0x29, 0x20, 0x3a, 0x20, 0x61, 0x72, 0x72, 0x61, 0x79,
+ 0x5b, 0x30, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20,
+ 0x20, 0x2f, 0x2f, 0x20, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x73, 0x20,
+ 0x65, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x20, 0x62,
+ 0x75, 0x74, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6c, 0x61, 0x73, 0x74, 0x20,
+ 0x65, 0x6e, 0x74, 0x72, 0x79, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65,
+ 0x20, 0x61, 0x72, 0x72, 0x61, 0x79, 0x2e, 0x20, 0x45, 0x73, 0x70, 0x65,
+ 0x63, 0x69, 0x61, 0x6c, 0x6c, 0x79, 0x20, 0x75, 0x73, 0x65, 0x66, 0x75,
+ 0x6c, 0x20, 0x6f, 0x6e, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x74, 0x68,
+ 0x65, 0x20, 0x61, 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x20,
+ 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2e, 0x20, 0x50, 0x61, 0x73, 0x73,
+ 0x69, 0x6e, 0x67, 0x20, 0x2a, 0x2a, 0x6e, 0x2a, 0x2a, 0x20, 0x77, 0x69,
+ 0x6c, 0x6c, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x61, 0x6c,
+ 0x6c, 0x20, 0x74, 0x68, 0x65, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73,
+ 0x20, 0x69, 0x6e, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x74, 0x68, 0x65,
+ 0x20, 0x61, 0x72, 0x72, 0x61, 0x79, 0x2c, 0x20, 0x65, 0x78, 0x63, 0x6c,
+ 0x75, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6c, 0x61,
+ 0x73, 0x74, 0x20, 0x4e, 0x2e, 0x20, 0x54, 0x68, 0x65, 0x20, 0x2a, 0x2a,
+ 0x67, 0x75, 0x61, 0x72, 0x64, 0x2a, 0x2a, 0x20, 0x63, 0x68, 0x65, 0x63,
+ 0x6b, 0x20, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x73, 0x20, 0x69, 0x74, 0x20,
+ 0x74, 0x6f, 0x20, 0x77, 0x6f, 0x72, 0x6b, 0x20, 0x77, 0x69, 0x74, 0x68,
+ 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x60, 0x5f, 0x2e, 0x6d, 0x61, 0x70,
+ 0x60, 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x69, 0x6e, 0x69, 0x74, 0x69,
+ 0x61, 0x6c, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f,
+ 0x6e, 0x28, 0x61, 0x72, 0x72, 0x61, 0x79, 0x2c, 0x20, 0x6e, 0x2c, 0x20,
+ 0x67, 0x75, 0x61, 0x72, 0x64, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x73, 0x6c, 0x69, 0x63,
+ 0x65, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x61, 0x72, 0x72, 0x61, 0x79,
+ 0x2c, 0x20, 0x30, 0x2c, 0x20, 0x61, 0x72, 0x72, 0x61, 0x79, 0x2e, 0x6c,
+ 0x65, 0x6e, 0x67, 0x74, 0x68, 0x20, 0x2d, 0x20, 0x28, 0x28, 0x6e, 0x20,
+ 0x3d, 0x3d, 0x20, 0x6e, 0x75, 0x6c, 0x6c, 0x29, 0x20, 0x7c, 0x7c, 0x20,
+ 0x67, 0x75, 0x61, 0x72, 0x64, 0x20, 0x3f, 0x20, 0x31, 0x20, 0x3a, 0x20,
+ 0x6e, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20,
+ 0x20, 0x2f, 0x2f, 0x20, 0x47, 0x65, 0x74, 0x20, 0x74, 0x68, 0x65, 0x20,
+ 0x6c, 0x61, 0x73, 0x74, 0x20, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74,
+ 0x20, 0x6f, 0x66, 0x20, 0x61, 0x6e, 0x20, 0x61, 0x72, 0x72, 0x61, 0x79,
+ 0x2e, 0x20, 0x50, 0x61, 0x73, 0x73, 0x69, 0x6e, 0x67, 0x20, 0x2a, 0x2a,
+ 0x6e, 0x2a, 0x2a, 0x20, 0x77, 0x69, 0x6c, 0x6c, 0x20, 0x72, 0x65, 0x74,
+ 0x75, 0x72, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6c, 0x61, 0x73, 0x74,
+ 0x20, 0x4e, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x76, 0x61, 0x6c, 0x75,
+ 0x65, 0x73, 0x20, 0x69, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x61, 0x72,
+ 0x72, 0x61, 0x79, 0x2e, 0x20, 0x54, 0x68, 0x65, 0x20, 0x2a, 0x2a, 0x67,
+ 0x75, 0x61, 0x72, 0x64, 0x2a, 0x2a, 0x20, 0x63, 0x68, 0x65, 0x63, 0x6b,
+ 0x20, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x73, 0x20, 0x69, 0x74, 0x20, 0x74,
+ 0x6f, 0x20, 0x77, 0x6f, 0x72, 0x6b, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20,
+ 0x60, 0x5f, 0x2e, 0x6d, 0x61, 0x70, 0x60, 0x2e, 0x0a, 0x20, 0x20, 0x5f,
+ 0x2e, 0x6c, 0x61, 0x73, 0x74, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63,
+ 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x61, 0x72, 0x72, 0x61, 0x79, 0x2c, 0x20,
+ 0x6e, 0x2c, 0x20, 0x67, 0x75, 0x61, 0x72, 0x64, 0x29, 0x20, 0x7b, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x61, 0x72, 0x72, 0x61,
+ 0x79, 0x20, 0x3d, 0x3d, 0x20, 0x6e, 0x75, 0x6c, 0x6c, 0x29, 0x20, 0x72,
+ 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x30,
+ 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x28, 0x6e,
+ 0x20, 0x21, 0x3d, 0x20, 0x6e, 0x75, 0x6c, 0x6c, 0x29, 0x20, 0x26, 0x26,
+ 0x20, 0x21, 0x67, 0x75, 0x61, 0x72, 0x64, 0x29, 0x20, 0x7b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20,
+ 0x73, 0x6c, 0x69, 0x63, 0x65, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x61,
+ 0x72, 0x72, 0x61, 0x79, 0x2c, 0x20, 0x4d, 0x61, 0x74, 0x68, 0x2e, 0x6d,
+ 0x61, 0x78, 0x28, 0x61, 0x72, 0x72, 0x61, 0x79, 0x2e, 0x6c, 0x65, 0x6e,
+ 0x67, 0x74, 0x68, 0x20, 0x2d, 0x20, 0x6e, 0x2c, 0x20, 0x30, 0x29, 0x29,
+ 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, 0x73, 0x65,
+ 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74,
+ 0x75, 0x72, 0x6e, 0x20, 0x61, 0x72, 0x72, 0x61, 0x79, 0x5b, 0x61, 0x72,
+ 0x72, 0x61, 0x79, 0x2e, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x20, 0x2d,
+ 0x20, 0x31, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20,
+ 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x52, 0x65,
+ 0x74, 0x75, 0x72, 0x6e, 0x73, 0x20, 0x65, 0x76, 0x65, 0x72, 0x79, 0x74,
+ 0x68, 0x69, 0x6e, 0x67, 0x20, 0x62, 0x75, 0x74, 0x20, 0x74, 0x68, 0x65,
+ 0x20, 0x66, 0x69, 0x72, 0x73, 0x74, 0x20, 0x65, 0x6e, 0x74, 0x72, 0x79,
+ 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x61, 0x72, 0x72, 0x61,
+ 0x79, 0x2e, 0x20, 0x41, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x64, 0x20, 0x61,
+ 0x73, 0x20, 0x60, 0x74, 0x61, 0x69, 0x6c, 0x60, 0x20, 0x61, 0x6e, 0x64,
+ 0x20, 0x60, 0x64, 0x72, 0x6f, 0x70, 0x60, 0x2e, 0x0a, 0x20, 0x20, 0x2f,
+ 0x2f, 0x20, 0x45, 0x73, 0x70, 0x65, 0x63, 0x69, 0x61, 0x6c, 0x6c, 0x79,
+ 0x20, 0x75, 0x73, 0x65, 0x66, 0x75, 0x6c, 0x20, 0x6f, 0x6e, 0x20, 0x74,
+ 0x68, 0x65, 0x20, 0x61, 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73,
+ 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2e, 0x20, 0x50, 0x61, 0x73,
+ 0x73, 0x69, 0x6e, 0x67, 0x20, 0x61, 0x6e, 0x20, 0x2a, 0x2a, 0x6e, 0x2a,
+ 0x2a, 0x20, 0x77, 0x69, 0x6c, 0x6c, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72,
+ 0x6e, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x72,
+ 0x65, 0x73, 0x74, 0x20, 0x4e, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73,
+ 0x20, 0x69, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x61, 0x72, 0x72, 0x61,
+ 0x79, 0x2e, 0x20, 0x54, 0x68, 0x65, 0x20, 0x2a, 0x2a, 0x67, 0x75, 0x61,
+ 0x72, 0x64, 0x2a, 0x2a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x63, 0x68,
+ 0x65, 0x63, 0x6b, 0x20, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x73, 0x20, 0x69,
+ 0x74, 0x20, 0x74, 0x6f, 0x20, 0x77, 0x6f, 0x72, 0x6b, 0x20, 0x77, 0x69,
+ 0x74, 0x68, 0x20, 0x60, 0x5f, 0x2e, 0x6d, 0x61, 0x70, 0x60, 0x2e, 0x0a,
+ 0x20, 0x20, 0x5f, 0x2e, 0x72, 0x65, 0x73, 0x74, 0x20, 0x3d, 0x20, 0x5f,
+ 0x2e, 0x74, 0x61, 0x69, 0x6c, 0x20, 0x3d, 0x20, 0x5f, 0x2e, 0x64, 0x72,
+ 0x6f, 0x70, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f,
+ 0x6e, 0x28, 0x61, 0x72, 0x72, 0x61, 0x79, 0x2c, 0x20, 0x6e, 0x2c, 0x20,
+ 0x67, 0x75, 0x61, 0x72, 0x64, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x73, 0x6c, 0x69, 0x63,
+ 0x65, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x61, 0x72, 0x72, 0x61, 0x79,
+ 0x2c, 0x20, 0x28, 0x6e, 0x20, 0x3d, 0x3d, 0x20, 0x6e, 0x75, 0x6c, 0x6c,
+ 0x29, 0x20, 0x7c, 0x7c, 0x20, 0x67, 0x75, 0x61, 0x72, 0x64, 0x20, 0x3f,
+ 0x20, 0x31, 0x20, 0x3a, 0x20, 0x6e, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x7d,
+ 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x54, 0x72, 0x69, 0x6d,
+ 0x20, 0x6f, 0x75, 0x74, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x66, 0x61, 0x6c,
+ 0x73, 0x79, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x20, 0x66, 0x72,
+ 0x6f, 0x6d, 0x20, 0x61, 0x6e, 0x20, 0x61, 0x72, 0x72, 0x61, 0x79, 0x2e,
+ 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63, 0x74,
+ 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28,
+ 0x61, 0x72, 0x72, 0x61, 0x79, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x2e, 0x66, 0x69,
+ 0x6c, 0x74, 0x65, 0x72, 0x28, 0x61, 0x72, 0x72, 0x61, 0x79, 0x2c, 0x20,
+ 0x5f, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x29, 0x3b,
+ 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20,
+ 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x20, 0x69, 0x6d, 0x70,
+ 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20,
+ 0x6f, 0x66, 0x20, 0x61, 0x20, 0x72, 0x65, 0x63, 0x75, 0x72, 0x73, 0x69,
+ 0x76, 0x65, 0x20, 0x60, 0x66, 0x6c, 0x61, 0x74, 0x74, 0x65, 0x6e, 0x60,
+ 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x0a, 0x20,
+ 0x20, 0x76, 0x61, 0x72, 0x20, 0x66, 0x6c, 0x61, 0x74, 0x74, 0x65, 0x6e,
+ 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28,
+ 0x69, 0x6e, 0x70, 0x75, 0x74, 0x2c, 0x20, 0x73, 0x68, 0x61, 0x6c, 0x6c,
+ 0x6f, 0x77, 0x2c, 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x29, 0x20,
+ 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x61, 0x63, 0x68, 0x28, 0x69,
+ 0x6e, 0x70, 0x75, 0x74, 0x2c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69,
+ 0x6f, 0x6e, 0x28, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x29, 0x20, 0x7b, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x5f, 0x2e,
+ 0x69, 0x73, 0x41, 0x72, 0x72, 0x61, 0x79, 0x28, 0x76, 0x61, 0x6c, 0x75,
+ 0x65, 0x29, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x73, 0x68, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x20, 0x3f, 0x20,
+ 0x70, 0x75, 0x73, 0x68, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x28, 0x6f,
+ 0x75, 0x74, 0x70, 0x75, 0x74, 0x2c, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65,
+ 0x29, 0x20, 0x3a, 0x20, 0x66, 0x6c, 0x61, 0x74, 0x74, 0x65, 0x6e, 0x28,
+ 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2c, 0x20, 0x73, 0x68, 0x61, 0x6c, 0x6c,
+ 0x6f, 0x77, 0x2c, 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x29, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, 0x73,
+ 0x65, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2e, 0x70, 0x75, 0x73, 0x68, 0x28,
+ 0x76, 0x61, 0x6c, 0x75, 0x65, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x29, 0x3b, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6f,
+ 0x75, 0x74, 0x70, 0x75, 0x74, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a,
+ 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e,
+ 0x20, 0x61, 0x20, 0x63, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x6c,
+ 0x79, 0x20, 0x66, 0x6c, 0x61, 0x74, 0x74, 0x65, 0x6e, 0x65, 0x64, 0x20,
+ 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x66, 0x20, 0x61,
+ 0x6e, 0x20, 0x61, 0x72, 0x72, 0x61, 0x79, 0x2e, 0x0a, 0x20, 0x20, 0x5f,
+ 0x2e, 0x66, 0x6c, 0x61, 0x74, 0x74, 0x65, 0x6e, 0x20, 0x3d, 0x20, 0x66,
+ 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x61, 0x72, 0x72, 0x61,
+ 0x79, 0x2c, 0x20, 0x73, 0x68, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x29, 0x20,
+ 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,
+ 0x20, 0x66, 0x6c, 0x61, 0x74, 0x74, 0x65, 0x6e, 0x28, 0x61, 0x72, 0x72,
+ 0x61, 0x79, 0x2c, 0x20, 0x73, 0x68, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x2c,
+ 0x20, 0x5b, 0x5d, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a,
+ 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20,
+ 0x61, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x66,
+ 0x20, 0x74, 0x68, 0x65, 0x20, 0x61, 0x72, 0x72, 0x61, 0x79, 0x20, 0x74,
+ 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x65, 0x73, 0x20, 0x6e, 0x6f, 0x74,
+ 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x20, 0x74, 0x68, 0x65,
+ 0x20, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x65, 0x64, 0x20, 0x76,
+ 0x61, 0x6c, 0x75, 0x65, 0x28, 0x73, 0x29, 0x2e, 0x0a, 0x20, 0x20, 0x5f,
+ 0x2e, 0x77, 0x69, 0x74, 0x68, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x66,
+ 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x61, 0x72, 0x72, 0x61,
+ 0x79, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74,
+ 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x2e, 0x64, 0x69, 0x66, 0x66, 0x65, 0x72,
+ 0x65, 0x6e, 0x63, 0x65, 0x28, 0x61, 0x72, 0x72, 0x61, 0x79, 0x2c, 0x20,
+ 0x73, 0x6c, 0x69, 0x63, 0x65, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x61,
+ 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2c, 0x20, 0x31, 0x29,
+ 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f,
+ 0x2f, 0x20, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x20, 0x61, 0x20,
+ 0x64, 0x75, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x65, 0x2d, 0x66, 0x72,
+ 0x65, 0x65, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x6f,
+ 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x61, 0x72, 0x72, 0x61, 0x79, 0x2e,
+ 0x20, 0x49, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x61, 0x72, 0x72, 0x61,
+ 0x79, 0x20, 0x68, 0x61, 0x73, 0x20, 0x61, 0x6c, 0x72, 0x65, 0x61, 0x64,
+ 0x79, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x62, 0x65, 0x65, 0x6e, 0x20,
+ 0x73, 0x6f, 0x72, 0x74, 0x65, 0x64, 0x2c, 0x20, 0x79, 0x6f, 0x75, 0x20,
+ 0x68, 0x61, 0x76, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6f, 0x70, 0x74,
+ 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x66, 0x20, 0x75, 0x73, 0x69, 0x6e, 0x67,
+ 0x20, 0x61, 0x20, 0x66, 0x61, 0x73, 0x74, 0x65, 0x72, 0x20, 0x61, 0x6c,
+ 0x67, 0x6f, 0x72, 0x69, 0x74, 0x68, 0x6d, 0x2e, 0x0a, 0x20, 0x20, 0x2f,
+ 0x2f, 0x20, 0x41, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x64, 0x20, 0x61, 0x73,
+ 0x20, 0x60, 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x60, 0x2e, 0x0a, 0x20,
+ 0x20, 0x5f, 0x2e, 0x75, 0x6e, 0x69, 0x71, 0x20, 0x3d, 0x20, 0x5f, 0x2e,
+ 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e,
+ 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x61, 0x72, 0x72, 0x61, 0x79, 0x2c,
+ 0x20, 0x69, 0x73, 0x53, 0x6f, 0x72, 0x74, 0x65, 0x64, 0x2c, 0x20, 0x69,
+ 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x2c, 0x20, 0x63, 0x6f, 0x6e,
+ 0x74, 0x65, 0x78, 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x69, 0x66, 0x20, 0x28, 0x5f, 0x2e, 0x69, 0x73, 0x46, 0x75, 0x6e, 0x63,
+ 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x69, 0x73, 0x53, 0x6f, 0x72, 0x74, 0x65,
+ 0x64, 0x29, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x20, 0x3d, 0x20, 0x69, 0x74,
+ 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x20, 0x3d,
+ 0x20, 0x69, 0x73, 0x53, 0x6f, 0x72, 0x74, 0x65, 0x64, 0x3b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x73, 0x53, 0x6f, 0x72, 0x74, 0x65,
+ 0x64, 0x20, 0x3d, 0x20, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x3b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72,
+ 0x20, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x20, 0x3d, 0x20, 0x69,
+ 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x20, 0x3f, 0x20, 0x5f, 0x2e,
+ 0x6d, 0x61, 0x70, 0x28, 0x61, 0x72, 0x72, 0x61, 0x79, 0x2c, 0x20, 0x69,
+ 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x2c, 0x20, 0x63, 0x6f, 0x6e,
+ 0x74, 0x65, 0x78, 0x74, 0x29, 0x20, 0x3a, 0x20, 0x61, 0x72, 0x72, 0x61,
+ 0x79, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x72,
+ 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x20, 0x3d, 0x20, 0x5b, 0x5d, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x73, 0x65, 0x65,
+ 0x6e, 0x20, 0x3d, 0x20, 0x5b, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x65, 0x61, 0x63, 0x68, 0x28, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c,
+ 0x2c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x76,
+ 0x61, 0x6c, 0x75, 0x65, 0x2c, 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x29,
+ 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20,
+ 0x28, 0x69, 0x73, 0x53, 0x6f, 0x72, 0x74, 0x65, 0x64, 0x20, 0x3f, 0x20,
+ 0x28, 0x21, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x20, 0x7c, 0x7c, 0x20, 0x73,
+ 0x65, 0x65, 0x6e, 0x5b, 0x73, 0x65, 0x65, 0x6e, 0x2e, 0x6c, 0x65, 0x6e,
+ 0x67, 0x74, 0x68, 0x20, 0x2d, 0x20, 0x31, 0x5d, 0x20, 0x21, 0x3d, 0x3d,
+ 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x29, 0x20, 0x3a, 0x20, 0x21, 0x5f,
+ 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x73, 0x28, 0x73, 0x65,
+ 0x65, 0x6e, 0x2c, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x29, 0x29, 0x20,
+ 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x73, 0x65,
+ 0x65, 0x6e, 0x2e, 0x70, 0x75, 0x73, 0x68, 0x28, 0x76, 0x61, 0x6c, 0x75,
+ 0x65, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x2e, 0x70, 0x75, 0x73, 0x68,
+ 0x28, 0x61, 0x72, 0x72, 0x61, 0x79, 0x5b, 0x69, 0x6e, 0x64, 0x65, 0x78,
+ 0x5d, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x7d, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c,
+ 0x74, 0x73, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20,
+ 0x2f, 0x2f, 0x20, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x20, 0x61,
+ 0x6e, 0x20, 0x61, 0x72, 0x72, 0x61, 0x79, 0x20, 0x74, 0x68, 0x61, 0x74,
+ 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x73, 0x20, 0x74, 0x68,
+ 0x65, 0x20, 0x75, 0x6e, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x65, 0x61, 0x63,
+ 0x68, 0x20, 0x64, 0x69, 0x73, 0x74, 0x69, 0x6e, 0x63, 0x74, 0x20, 0x65,
+ 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x66, 0x72, 0x6f, 0x6d, 0x20,
+ 0x61, 0x6c, 0x6c, 0x20, 0x6f, 0x66, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20,
+ 0x74, 0x68, 0x65, 0x20, 0x70, 0x61, 0x73, 0x73, 0x65, 0x64, 0x2d, 0x69,
+ 0x6e, 0x20, 0x61, 0x72, 0x72, 0x61, 0x79, 0x73, 0x2e, 0x0a, 0x20, 0x20,
+ 0x5f, 0x2e, 0x75, 0x6e, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x66, 0x75,
+ 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x29, 0x20, 0x7b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x2e,
+ 0x75, 0x6e, 0x69, 0x71, 0x28, 0x63, 0x6f, 0x6e, 0x63, 0x61, 0x74, 0x2e,
+ 0x61, 0x70, 0x70, 0x6c, 0x79, 0x28, 0x41, 0x72, 0x72, 0x61, 0x79, 0x50,
+ 0x72, 0x6f, 0x74, 0x6f, 0x2c, 0x20, 0x61, 0x72, 0x67, 0x75, 0x6d, 0x65,
+ 0x6e, 0x74, 0x73, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a,
+ 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63,
+ 0x65, 0x20, 0x61, 0x6e, 0x20, 0x61, 0x72, 0x72, 0x61, 0x79, 0x20, 0x74,
+ 0x68, 0x61, 0x74, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x73,
+ 0x20, 0x65, 0x76, 0x65, 0x72, 0x79, 0x20, 0x69, 0x74, 0x65, 0x6d, 0x20,
+ 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x20, 0x62, 0x65, 0x74, 0x77, 0x65,
+ 0x65, 0x6e, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x74, 0x68, 0x65, 0x0a, 0x20,
+ 0x20, 0x2f, 0x2f, 0x20, 0x70, 0x61, 0x73, 0x73, 0x65, 0x64, 0x2d, 0x69,
+ 0x6e, 0x20, 0x61, 0x72, 0x72, 0x61, 0x79, 0x73, 0x2e, 0x0a, 0x20, 0x20,
+ 0x5f, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x73, 0x65, 0x63, 0x74, 0x69,
+ 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f,
+ 0x6e, 0x28, 0x61, 0x72, 0x72, 0x61, 0x79, 0x29, 0x20, 0x7b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x72, 0x65, 0x73, 0x74, 0x20,
+ 0x3d, 0x20, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x2e, 0x63, 0x61, 0x6c, 0x6c,
+ 0x28, 0x61, 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2c, 0x20,
+ 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75,
+ 0x72, 0x6e, 0x20, 0x5f, 0x2e, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x28,
+ 0x5f, 0x2e, 0x75, 0x6e, 0x69, 0x71, 0x28, 0x61, 0x72, 0x72, 0x61, 0x79,
+ 0x29, 0x2c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28,
+ 0x69, 0x74, 0x65, 0x6d, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x2e, 0x65,
+ 0x76, 0x65, 0x72, 0x79, 0x28, 0x72, 0x65, 0x73, 0x74, 0x2c, 0x20, 0x66,
+ 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6f, 0x74, 0x68, 0x65,
+ 0x72, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x2e, 0x69, 0x6e,
+ 0x64, 0x65, 0x78, 0x4f, 0x66, 0x28, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x2c,
+ 0x20, 0x69, 0x74, 0x65, 0x6d, 0x29, 0x20, 0x3e, 0x3d, 0x20, 0x30, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x29, 0x3b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x7d, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a,
+ 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x54, 0x61, 0x6b, 0x65, 0x20, 0x74,
+ 0x68, 0x65, 0x20, 0x64, 0x69, 0x66, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63,
+ 0x65, 0x20, 0x62, 0x65, 0x74, 0x77, 0x65, 0x65, 0x6e, 0x20, 0x6f, 0x6e,
+ 0x65, 0x20, 0x61, 0x72, 0x72, 0x61, 0x79, 0x20, 0x61, 0x6e, 0x64, 0x20,
+ 0x61, 0x20, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x20, 0x6f, 0x66, 0x20,
+ 0x6f, 0x74, 0x68, 0x65, 0x72, 0x20, 0x61, 0x72, 0x72, 0x61, 0x79, 0x73,
+ 0x2e, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x4f, 0x6e, 0x6c, 0x79, 0x20,
+ 0x74, 0x68, 0x65, 0x20, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73,
+ 0x20, 0x70, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x74, 0x20, 0x69, 0x6e, 0x20,
+ 0x6a, 0x75, 0x73, 0x74, 0x20, 0x74, 0x68, 0x65, 0x20, 0x66, 0x69, 0x72,
+ 0x73, 0x74, 0x20, 0x61, 0x72, 0x72, 0x61, 0x79, 0x20, 0x77, 0x69, 0x6c,
+ 0x6c, 0x20, 0x72, 0x65, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x0a, 0x20, 0x20,
+ 0x5f, 0x2e, 0x64, 0x69, 0x66, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65,
+ 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28,
+ 0x61, 0x72, 0x72, 0x61, 0x79, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x76, 0x61, 0x72, 0x20, 0x72, 0x65, 0x73, 0x74, 0x20, 0x3d, 0x20,
+ 0x63, 0x6f, 0x6e, 0x63, 0x61, 0x74, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x79,
+ 0x28, 0x41, 0x72, 0x72, 0x61, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x2c,
+ 0x20, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28,
+ 0x61, 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2c, 0x20, 0x31,
+ 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75,
+ 0x72, 0x6e, 0x20, 0x5f, 0x2e, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x28,
+ 0x61, 0x72, 0x72, 0x61, 0x79, 0x2c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74,
+ 0x69, 0x6f, 0x6e, 0x28, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x29, 0x7b, 0x20,
+ 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x21, 0x5f, 0x2e, 0x63, 0x6f,
+ 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x73, 0x28, 0x72, 0x65, 0x73, 0x74, 0x2c,
+ 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x29, 0x3b, 0x20, 0x7d, 0x29, 0x3b,
+ 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20,
+ 0x5a, 0x69, 0x70, 0x20, 0x74, 0x6f, 0x67, 0x65, 0x74, 0x68, 0x65, 0x72,
+ 0x20, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x20, 0x6c, 0x69,
+ 0x73, 0x74, 0x73, 0x20, 0x69, 0x6e, 0x74, 0x6f, 0x20, 0x61, 0x20, 0x73,
+ 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x20, 0x61, 0x72, 0x72, 0x61, 0x79, 0x20,
+ 0x2d, 0x2d, 0x20, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x20,
+ 0x74, 0x68, 0x61, 0x74, 0x20, 0x73, 0x68, 0x61, 0x72, 0x65, 0x0a, 0x20,
+ 0x20, 0x2f, 0x2f, 0x20, 0x61, 0x6e, 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78,
+ 0x20, 0x67, 0x6f, 0x20, 0x74, 0x6f, 0x67, 0x65, 0x74, 0x68, 0x65, 0x72,
+ 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x7a, 0x69, 0x70, 0x20, 0x3d, 0x20,
+ 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x29, 0x20, 0x7b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x61, 0x72, 0x67,
+ 0x73, 0x20, 0x3d, 0x20, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x2e, 0x63, 0x61,
+ 0x6c, 0x6c, 0x28, 0x61, 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73,
+ 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x6c,
+ 0x65, 0x6e, 0x67, 0x74, 0x68, 0x20, 0x3d, 0x20, 0x5f, 0x2e, 0x6d, 0x61,
+ 0x78, 0x28, 0x5f, 0x2e, 0x70, 0x6c, 0x75, 0x63, 0x6b, 0x28, 0x61, 0x72,
+ 0x67, 0x73, 0x2c, 0x20, 0x27, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x27,
+ 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20,
+ 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x20, 0x3d, 0x20, 0x6e, 0x65,
+ 0x77, 0x20, 0x41, 0x72, 0x72, 0x61, 0x79, 0x28, 0x6c, 0x65, 0x6e, 0x67,
+ 0x74, 0x68, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x72,
+ 0x20, 0x28, 0x76, 0x61, 0x72, 0x20, 0x69, 0x20, 0x3d, 0x20, 0x30, 0x3b,
+ 0x20, 0x69, 0x20, 0x3c, 0x20, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x3b,
+ 0x20, 0x69, 0x2b, 0x2b, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x5b, 0x69, 0x5d,
+ 0x20, 0x3d, 0x20, 0x5f, 0x2e, 0x70, 0x6c, 0x75, 0x63, 0x6b, 0x28, 0x61,
+ 0x72, 0x67, 0x73, 0x2c, 0x20, 0x22, 0x22, 0x20, 0x2b, 0x20, 0x69, 0x29,
+ 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c,
+ 0x74, 0x73, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20,
+ 0x2f, 0x2f, 0x20, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x73, 0x20,
+ 0x6c, 0x69, 0x73, 0x74, 0x73, 0x20, 0x69, 0x6e, 0x74, 0x6f, 0x20, 0x6f,
+ 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x2e, 0x20, 0x50, 0x61, 0x73, 0x73,
+ 0x20, 0x65, 0x69, 0x74, 0x68, 0x65, 0x72, 0x20, 0x61, 0x20, 0x73, 0x69,
+ 0x6e, 0x67, 0x6c, 0x65, 0x20, 0x61, 0x72, 0x72, 0x61, 0x79, 0x20, 0x6f,
+ 0x66, 0x20, 0x60, 0x5b, 0x6b, 0x65, 0x79, 0x2c, 0x20, 0x76, 0x61, 0x6c,
+ 0x75, 0x65, 0x5d, 0x60, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x70, 0x61,
+ 0x69, 0x72, 0x73, 0x2c, 0x20, 0x6f, 0x72, 0x20, 0x74, 0x77, 0x6f, 0x20,
+ 0x70, 0x61, 0x72, 0x61, 0x6c, 0x6c, 0x65, 0x6c, 0x20, 0x61, 0x72, 0x72,
+ 0x61, 0x79, 0x73, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73,
+ 0x61, 0x6d, 0x65, 0x20, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x20, 0x2d,
+ 0x2d, 0x20, 0x6f, 0x6e, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x6b, 0x65, 0x79,
+ 0x73, 0x2c, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x6f, 0x6e, 0x65, 0x20, 0x6f,
+ 0x66, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63,
+ 0x6f, 0x72, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x64, 0x69, 0x6e, 0x67,
+ 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x2e, 0x0a, 0x20, 0x20, 0x5f,
+ 0x2e, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20, 0x3d, 0x20, 0x66, 0x75,
+ 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6c, 0x69, 0x73, 0x74, 0x2c,
+ 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x29, 0x20, 0x7b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x6c, 0x69, 0x73, 0x74, 0x20,
+ 0x3d, 0x3d, 0x20, 0x6e, 0x75, 0x6c, 0x6c, 0x29, 0x20, 0x72, 0x65, 0x74,
+ 0x75, 0x72, 0x6e, 0x20, 0x7b, 0x7d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x76, 0x61, 0x72, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x20, 0x3d,
+ 0x20, 0x7b, 0x7d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x72,
+ 0x20, 0x28, 0x76, 0x61, 0x72, 0x20, 0x69, 0x20, 0x3d, 0x20, 0x30, 0x2c,
+ 0x20, 0x6c, 0x20, 0x3d, 0x20, 0x6c, 0x69, 0x73, 0x74, 0x2e, 0x6c, 0x65,
+ 0x6e, 0x67, 0x74, 0x68, 0x3b, 0x20, 0x69, 0x20, 0x3c, 0x20, 0x6c, 0x3b,
+ 0x20, 0x69, 0x2b, 0x2b, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73,
+ 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5b, 0x6c, 0x69, 0x73, 0x74, 0x5b,
+ 0x69, 0x5d, 0x5d, 0x20, 0x3d, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73,
+ 0x5b, 0x69, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d,
+ 0x20, 0x65, 0x6c, 0x73, 0x65, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5b, 0x6c,
+ 0x69, 0x73, 0x74, 0x5b, 0x69, 0x5d, 0x5b, 0x30, 0x5d, 0x5d, 0x20, 0x3d,
+ 0x20, 0x6c, 0x69, 0x73, 0x74, 0x5b, 0x69, 0x5d, 0x5b, 0x31, 0x5d, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72,
+ 0x6e, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x3b, 0x0a, 0x20, 0x20,
+ 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x49, 0x66, 0x20,
+ 0x74, 0x68, 0x65, 0x20, 0x62, 0x72, 0x6f, 0x77, 0x73, 0x65, 0x72, 0x20,
+ 0x64, 0x6f, 0x65, 0x73, 0x6e, 0x27, 0x74, 0x20, 0x73, 0x75, 0x70, 0x70,
+ 0x6c, 0x79, 0x20, 0x75, 0x73, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x69,
+ 0x6e, 0x64, 0x65, 0x78, 0x4f, 0x66, 0x20, 0x28, 0x49, 0x27, 0x6d, 0x20,
+ 0x6c, 0x6f, 0x6f, 0x6b, 0x69, 0x6e, 0x67, 0x20, 0x61, 0x74, 0x20, 0x79,
+ 0x6f, 0x75, 0x2c, 0x20, 0x2a, 0x2a, 0x4d, 0x53, 0x49, 0x45, 0x2a, 0x2a,
+ 0x29, 0x2c, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x77, 0x65, 0x20, 0x6e,
+ 0x65, 0x65, 0x64, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x66, 0x75, 0x6e,
+ 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x20, 0x52, 0x65, 0x74, 0x75, 0x72,
+ 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69,
+ 0x6f, 0x6e, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x66, 0x69,
+ 0x72, 0x73, 0x74, 0x20, 0x6f, 0x63, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e,
+ 0x63, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x61, 0x6e, 0x0a, 0x20, 0x20, 0x2f,
+ 0x2f, 0x20, 0x69, 0x74, 0x65, 0x6d, 0x20, 0x69, 0x6e, 0x20, 0x61, 0x6e,
+ 0x20, 0x61, 0x72, 0x72, 0x61, 0x79, 0x2c, 0x20, 0x6f, 0x72, 0x20, 0x2d,
+ 0x31, 0x20, 0x69, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x69, 0x74, 0x65,
+ 0x6d, 0x20, 0x69, 0x73, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x69, 0x6e, 0x63,
+ 0x6c, 0x75, 0x64, 0x65, 0x64, 0x20, 0x69, 0x6e, 0x20, 0x74, 0x68, 0x65,
+ 0x20, 0x61, 0x72, 0x72, 0x61, 0x79, 0x2e, 0x0a, 0x20, 0x20, 0x2f, 0x2f,
+ 0x20, 0x44, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x65, 0x73, 0x20, 0x74,
+ 0x6f, 0x20, 0x2a, 0x2a, 0x45, 0x43, 0x4d, 0x41, 0x53, 0x63, 0x72, 0x69,
+ 0x70, 0x74, 0x20, 0x35, 0x2a, 0x2a, 0x27, 0x73, 0x20, 0x6e, 0x61, 0x74,
+ 0x69, 0x76, 0x65, 0x20, 0x60, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x4f, 0x66,
+ 0x60, 0x20, 0x69, 0x66, 0x20, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62,
+ 0x6c, 0x65, 0x2e, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x49, 0x66, 0x20,
+ 0x74, 0x68, 0x65, 0x20, 0x61, 0x72, 0x72, 0x61, 0x79, 0x20, 0x69, 0x73,
+ 0x20, 0x6c, 0x61, 0x72, 0x67, 0x65, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x61,
+ 0x6c, 0x72, 0x65, 0x61, 0x64, 0x79, 0x20, 0x69, 0x6e, 0x20, 0x73, 0x6f,
+ 0x72, 0x74, 0x20, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2c, 0x20, 0x70, 0x61,
+ 0x73, 0x73, 0x20, 0x60, 0x74, 0x72, 0x75, 0x65, 0x60, 0x0a, 0x20, 0x20,
+ 0x2f, 0x2f, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x2a, 0x2a, 0x69, 0x73, 0x53,
+ 0x6f, 0x72, 0x74, 0x65, 0x64, 0x2a, 0x2a, 0x20, 0x74, 0x6f, 0x20, 0x75,
+ 0x73, 0x65, 0x20, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x20, 0x73, 0x65,
+ 0x61, 0x72, 0x63, 0x68, 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x69, 0x6e,
+ 0x64, 0x65, 0x78, 0x4f, 0x66, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63,
+ 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x61, 0x72, 0x72, 0x61, 0x79, 0x2c, 0x20,
+ 0x69, 0x74, 0x65, 0x6d, 0x2c, 0x20, 0x69, 0x73, 0x53, 0x6f, 0x72, 0x74,
+ 0x65, 0x64, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66,
+ 0x20, 0x28, 0x61, 0x72, 0x72, 0x61, 0x79, 0x20, 0x3d, 0x3d, 0x20, 0x6e,
+ 0x75, 0x6c, 0x6c, 0x29, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20,
+ 0x2d, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20,
+ 0x69, 0x20, 0x3d, 0x20, 0x30, 0x2c, 0x20, 0x6c, 0x20, 0x3d, 0x20, 0x61,
+ 0x72, 0x72, 0x61, 0x79, 0x2e, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x69, 0x73, 0x53,
+ 0x6f, 0x72, 0x74, 0x65, 0x64, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x74, 0x79, 0x70, 0x65, 0x6f,
+ 0x66, 0x20, 0x69, 0x73, 0x53, 0x6f, 0x72, 0x74, 0x65, 0x64, 0x20, 0x3d,
+ 0x3d, 0x20, 0x27, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x27, 0x29, 0x20,
+ 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x20,
+ 0x3d, 0x20, 0x28, 0x69, 0x73, 0x53, 0x6f, 0x72, 0x74, 0x65, 0x64, 0x20,
+ 0x3c, 0x20, 0x30, 0x20, 0x3f, 0x20, 0x4d, 0x61, 0x74, 0x68, 0x2e, 0x6d,
+ 0x61, 0x78, 0x28, 0x30, 0x2c, 0x20, 0x6c, 0x20, 0x2b, 0x20, 0x69, 0x73,
+ 0x53, 0x6f, 0x72, 0x74, 0x65, 0x64, 0x29, 0x20, 0x3a, 0x20, 0x69, 0x73,
+ 0x53, 0x6f, 0x72, 0x74, 0x65, 0x64, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x20, 0x7b, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x20, 0x3d, 0x20,
+ 0x5f, 0x2e, 0x73, 0x6f, 0x72, 0x74, 0x65, 0x64, 0x49, 0x6e, 0x64, 0x65,
+ 0x78, 0x28, 0x61, 0x72, 0x72, 0x61, 0x79, 0x2c, 0x20, 0x69, 0x74, 0x65,
+ 0x6d, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x61, 0x72, 0x72, 0x61, 0x79,
+ 0x5b, 0x69, 0x5d, 0x20, 0x3d, 0x3d, 0x3d, 0x20, 0x69, 0x74, 0x65, 0x6d,
+ 0x20, 0x3f, 0x20, 0x69, 0x20, 0x3a, 0x20, 0x2d, 0x31, 0x3b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x6e, 0x61, 0x74,
+ 0x69, 0x76, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x4f, 0x66, 0x20, 0x26,
+ 0x26, 0x20, 0x61, 0x72, 0x72, 0x61, 0x79, 0x2e, 0x69, 0x6e, 0x64, 0x65,
+ 0x78, 0x4f, 0x66, 0x20, 0x3d, 0x3d, 0x3d, 0x20, 0x6e, 0x61, 0x74, 0x69,
+ 0x76, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x4f, 0x66, 0x29, 0x20, 0x72,
+ 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x61, 0x72, 0x72, 0x61, 0x79, 0x2e,
+ 0x69, 0x6e, 0x64, 0x65, 0x78, 0x4f, 0x66, 0x28, 0x69, 0x74, 0x65, 0x6d,
+ 0x2c, 0x20, 0x69, 0x73, 0x53, 0x6f, 0x72, 0x74, 0x65, 0x64, 0x29, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x28, 0x3b, 0x20,
+ 0x69, 0x20, 0x3c, 0x20, 0x6c, 0x3b, 0x20, 0x69, 0x2b, 0x2b, 0x29, 0x20,
+ 0x69, 0x66, 0x20, 0x28, 0x61, 0x72, 0x72, 0x61, 0x79, 0x5b, 0x69, 0x5d,
+ 0x20, 0x3d, 0x3d, 0x3d, 0x20, 0x69, 0x74, 0x65, 0x6d, 0x29, 0x20, 0x72,
+ 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x69, 0x3b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x2d, 0x31, 0x3b, 0x0a,
+ 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x44,
+ 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x65, 0x73, 0x20, 0x74, 0x6f, 0x20,
+ 0x2a, 0x2a, 0x45, 0x43, 0x4d, 0x41, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74,
+ 0x20, 0x35, 0x2a, 0x2a, 0x27, 0x73, 0x20, 0x6e, 0x61, 0x74, 0x69, 0x76,
+ 0x65, 0x20, 0x60, 0x6c, 0x61, 0x73, 0x74, 0x49, 0x6e, 0x64, 0x65, 0x78,
+ 0x4f, 0x66, 0x60, 0x20, 0x69, 0x66, 0x20, 0x61, 0x76, 0x61, 0x69, 0x6c,
+ 0x61, 0x62, 0x6c, 0x65, 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x6c, 0x61,
+ 0x73, 0x74, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x4f, 0x66, 0x20, 0x3d, 0x20,
+ 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x61, 0x72, 0x72,
+ 0x61, 0x79, 0x2c, 0x20, 0x69, 0x74, 0x65, 0x6d, 0x2c, 0x20, 0x66, 0x72,
+ 0x6f, 0x6d, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66,
+ 0x20, 0x28, 0x61, 0x72, 0x72, 0x61, 0x79, 0x20, 0x3d, 0x3d, 0x20, 0x6e,
+ 0x75, 0x6c, 0x6c, 0x29, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20,
+ 0x2d, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20,
+ 0x68, 0x61, 0x73, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x20, 0x3d, 0x20, 0x66,
+ 0x72, 0x6f, 0x6d, 0x20, 0x21, 0x3d, 0x20, 0x6e, 0x75, 0x6c, 0x6c, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x6e, 0x61, 0x74,
+ 0x69, 0x76, 0x65, 0x4c, 0x61, 0x73, 0x74, 0x49, 0x6e, 0x64, 0x65, 0x78,
+ 0x4f, 0x66, 0x20, 0x26, 0x26, 0x20, 0x61, 0x72, 0x72, 0x61, 0x79, 0x2e,
+ 0x6c, 0x61, 0x73, 0x74, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x4f, 0x66, 0x20,
+ 0x3d, 0x3d, 0x3d, 0x20, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x4c, 0x61,
+ 0x73, 0x74, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x4f, 0x66, 0x29, 0x20, 0x7b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72,
+ 0x6e, 0x20, 0x68, 0x61, 0x73, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x20, 0x3f,
+ 0x20, 0x61, 0x72, 0x72, 0x61, 0x79, 0x2e, 0x6c, 0x61, 0x73, 0x74, 0x49,
+ 0x6e, 0x64, 0x65, 0x78, 0x4f, 0x66, 0x28, 0x69, 0x74, 0x65, 0x6d, 0x2c,
+ 0x20, 0x66, 0x72, 0x6f, 0x6d, 0x29, 0x20, 0x3a, 0x20, 0x61, 0x72, 0x72,
+ 0x61, 0x79, 0x2e, 0x6c, 0x61, 0x73, 0x74, 0x49, 0x6e, 0x64, 0x65, 0x78,
+ 0x4f, 0x66, 0x28, 0x69, 0x74, 0x65, 0x6d, 0x29, 0x3b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20,
+ 0x69, 0x20, 0x3d, 0x20, 0x28, 0x68, 0x61, 0x73, 0x49, 0x6e, 0x64, 0x65,
+ 0x78, 0x20, 0x3f, 0x20, 0x66, 0x72, 0x6f, 0x6d, 0x20, 0x3a, 0x20, 0x61,
+ 0x72, 0x72, 0x61, 0x79, 0x2e, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x29,
+ 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x20,
+ 0x28, 0x69, 0x2d, 0x2d, 0x29, 0x20, 0x69, 0x66, 0x20, 0x28, 0x61, 0x72,
+ 0x72, 0x61, 0x79, 0x5b, 0x69, 0x5d, 0x20, 0x3d, 0x3d, 0x3d, 0x20, 0x69,
+ 0x74, 0x65, 0x6d, 0x29, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20,
+ 0x69, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72,
+ 0x6e, 0x20, 0x2d, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a,
+ 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74,
+ 0x65, 0x20, 0x61, 0x6e, 0x20, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72,
+ 0x20, 0x41, 0x72, 0x72, 0x61, 0x79, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x61,
+ 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x20, 0x61, 0x6e, 0x20, 0x61, 0x72, 0x69,
+ 0x74, 0x68, 0x6d, 0x65, 0x74, 0x69, 0x63, 0x20, 0x70, 0x72, 0x6f, 0x67,
+ 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x20, 0x41, 0x20, 0x70,
+ 0x6f, 0x72, 0x74, 0x20, 0x6f, 0x66, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20,
+ 0x74, 0x68, 0x65, 0x20, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x20, 0x50,
+ 0x79, 0x74, 0x68, 0x6f, 0x6e, 0x20, 0x60, 0x72, 0x61, 0x6e, 0x67, 0x65,
+ 0x28, 0x29, 0x60, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
+ 0x2e, 0x20, 0x53, 0x65, 0x65, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x5b,
+ 0x74, 0x68, 0x65, 0x20, 0x50, 0x79, 0x74, 0x68, 0x6f, 0x6e, 0x20, 0x64,
+ 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e,
+ 0x5d, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 0x6f, 0x63,
+ 0x73, 0x2e, 0x70, 0x79, 0x74, 0x68, 0x6f, 0x6e, 0x2e, 0x6f, 0x72, 0x67,
+ 0x2f, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x2f, 0x66, 0x75, 0x6e,
+ 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x23,
+ 0x72, 0x61, 0x6e, 0x67, 0x65, 0x29, 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e,
+ 0x72, 0x61, 0x6e, 0x67, 0x65, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63,
+ 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x73, 0x74, 0x61, 0x72, 0x74, 0x2c, 0x20,
+ 0x73, 0x74, 0x6f, 0x70, 0x2c, 0x20, 0x73, 0x74, 0x65, 0x70, 0x29, 0x20,
+ 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x61, 0x72,
+ 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x6c, 0x65, 0x6e, 0x67,
+ 0x74, 0x68, 0x20, 0x3c, 0x3d, 0x20, 0x31, 0x29, 0x20, 0x7b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x73, 0x74, 0x6f, 0x70, 0x20, 0x3d, 0x20,
+ 0x73, 0x74, 0x61, 0x72, 0x74, 0x20, 0x7c, 0x7c, 0x20, 0x30, 0x3b, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74, 0x20,
+ 0x3d, 0x20, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x73, 0x74, 0x65, 0x70, 0x20, 0x3d, 0x20, 0x61, 0x72,
+ 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x5b, 0x32, 0x5d, 0x20, 0x7c,
+ 0x7c, 0x20, 0x31, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61,
+ 0x72, 0x20, 0x6c, 0x65, 0x6e, 0x20, 0x3d, 0x20, 0x4d, 0x61, 0x74, 0x68,
+ 0x2e, 0x6d, 0x61, 0x78, 0x28, 0x4d, 0x61, 0x74, 0x68, 0x2e, 0x63, 0x65,
+ 0x69, 0x6c, 0x28, 0x28, 0x73, 0x74, 0x6f, 0x70, 0x20, 0x2d, 0x20, 0x73,
+ 0x74, 0x61, 0x72, 0x74, 0x29, 0x20, 0x2f, 0x20, 0x73, 0x74, 0x65, 0x70,
+ 0x29, 0x2c, 0x20, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76,
+ 0x61, 0x72, 0x20, 0x69, 0x64, 0x78, 0x20, 0x3d, 0x20, 0x30, 0x3b, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x72, 0x61, 0x6e, 0x67,
+ 0x65, 0x20, 0x3d, 0x20, 0x6e, 0x65, 0x77, 0x20, 0x41, 0x72, 0x72, 0x61,
+ 0x79, 0x28, 0x6c, 0x65, 0x6e, 0x29, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x28, 0x69, 0x64, 0x78, 0x20, 0x3c,
+ 0x20, 0x6c, 0x65, 0x6e, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x5b, 0x69, 0x64, 0x78, 0x2b,
+ 0x2b, 0x5d, 0x20, 0x3d, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74, 0x3b, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74, 0x20,
+ 0x2b, 0x3d, 0x20, 0x73, 0x74, 0x65, 0x70, 0x3b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x7d, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75,
+ 0x72, 0x6e, 0x20, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x3b, 0x0a, 0x20, 0x20,
+ 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x46, 0x75, 0x6e,
+ 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x28, 0x61, 0x68, 0x65, 0x6d, 0x29,
+ 0x20, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x0a, 0x20,
+ 0x20, 0x2f, 0x2f, 0x20, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
+ 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x0a,
+ 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x20,
+ 0x61, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x62,
+ 0x6f, 0x75, 0x6e, 0x64, 0x20, 0x74, 0x6f, 0x20, 0x61, 0x20, 0x67, 0x69,
+ 0x76, 0x65, 0x6e, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20, 0x28,
+ 0x61, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x20, 0x60, 0x74,
+ 0x68, 0x69, 0x73, 0x60, 0x2c, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x61, 0x72,
+ 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2c, 0x0a, 0x20, 0x20, 0x2f,
+ 0x2f, 0x20, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x6c, 0x79,
+ 0x29, 0x2e, 0x20, 0x44, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x65, 0x73,
+ 0x20, 0x74, 0x6f, 0x20, 0x2a, 0x2a, 0x45, 0x43, 0x4d, 0x41, 0x53, 0x63,
+ 0x72, 0x69, 0x70, 0x74, 0x20, 0x35, 0x2a, 0x2a, 0x27, 0x73, 0x20, 0x6e,
+ 0x61, 0x74, 0x69, 0x76, 0x65, 0x20, 0x60, 0x46, 0x75, 0x6e, 0x63, 0x74,
+ 0x69, 0x6f, 0x6e, 0x2e, 0x62, 0x69, 0x6e, 0x64, 0x60, 0x20, 0x69, 0x66,
+ 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61,
+ 0x62, 0x6c, 0x65, 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x62, 0x69, 0x6e,
+ 0x64, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
+ 0x28, 0x66, 0x75, 0x6e, 0x63, 0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65,
+ 0x78, 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66,
+ 0x20, 0x28, 0x66, 0x75, 0x6e, 0x63, 0x2e, 0x62, 0x69, 0x6e, 0x64, 0x20,
+ 0x3d, 0x3d, 0x3d, 0x20, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x42, 0x69,
+ 0x6e, 0x64, 0x20, 0x26, 0x26, 0x20, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65,
+ 0x42, 0x69, 0x6e, 0x64, 0x29, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,
+ 0x20, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x42, 0x69, 0x6e, 0x64, 0x2e,
+ 0x61, 0x70, 0x70, 0x6c, 0x79, 0x28, 0x66, 0x75, 0x6e, 0x63, 0x2c, 0x20,
+ 0x73, 0x6c, 0x69, 0x63, 0x65, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x61,
+ 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2c, 0x20, 0x31, 0x29,
+ 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x61,
+ 0x72, 0x67, 0x73, 0x20, 0x3d, 0x20, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x2e,
+ 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x61, 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e,
+ 0x74, 0x73, 0x2c, 0x20, 0x32, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74,
+ 0x69, 0x6f, 0x6e, 0x28, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x66, 0x75, 0x6e,
+ 0x63, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x28, 0x63, 0x6f, 0x6e, 0x74,
+ 0x65, 0x78, 0x74, 0x2c, 0x20, 0x61, 0x72, 0x67, 0x73, 0x2e, 0x63, 0x6f,
+ 0x6e, 0x63, 0x61, 0x74, 0x28, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x2e, 0x63,
+ 0x61, 0x6c, 0x6c, 0x28, 0x61, 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74,
+ 0x73, 0x29, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x3b,
+ 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20,
+ 0x50, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x6c, 0x79, 0x20, 0x61, 0x70,
+ 0x70, 0x6c, 0x79, 0x20, 0x61, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69,
+ 0x6f, 0x6e, 0x20, 0x62, 0x79, 0x20, 0x63, 0x72, 0x65, 0x61, 0x74, 0x69,
+ 0x6e, 0x67, 0x20, 0x61, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e,
+ 0x20, 0x74, 0x68, 0x61, 0x74, 0x20, 0x68, 0x61, 0x73, 0x20, 0x68, 0x61,
+ 0x64, 0x20, 0x73, 0x6f, 0x6d, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x69, 0x74,
+ 0x73, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x61, 0x72, 0x67, 0x75, 0x6d,
+ 0x65, 0x6e, 0x74, 0x73, 0x20, 0x70, 0x72, 0x65, 0x2d, 0x66, 0x69, 0x6c,
+ 0x6c, 0x65, 0x64, 0x2c, 0x20, 0x77, 0x69, 0x74, 0x68, 0x6f, 0x75, 0x74,
+ 0x20, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x69, 0x6e, 0x67, 0x20, 0x69, 0x74,
+ 0x73, 0x20, 0x64, 0x79, 0x6e, 0x61, 0x6d, 0x69, 0x63, 0x20, 0x60, 0x74,
+ 0x68, 0x69, 0x73, 0x60, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74,
+ 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x70, 0x61, 0x72, 0x74, 0x69, 0x61,
+ 0x6c, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
+ 0x28, 0x66, 0x75, 0x6e, 0x63, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x76, 0x61, 0x72, 0x20, 0x61, 0x72, 0x67, 0x73, 0x20, 0x3d, 0x20,
+ 0x73, 0x6c, 0x69, 0x63, 0x65, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x61,
+ 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2c, 0x20, 0x31, 0x29,
+ 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,
+ 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x29, 0x20,
+ 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75,
+ 0x72, 0x6e, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x2e, 0x61, 0x70, 0x70, 0x6c,
+ 0x79, 0x28, 0x74, 0x68, 0x69, 0x73, 0x2c, 0x20, 0x61, 0x72, 0x67, 0x73,
+ 0x2e, 0x63, 0x6f, 0x6e, 0x63, 0x61, 0x74, 0x28, 0x73, 0x6c, 0x69, 0x63,
+ 0x65, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x61, 0x72, 0x67, 0x75, 0x6d,
+ 0x65, 0x6e, 0x74, 0x73, 0x29, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x7d, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20,
+ 0x2f, 0x2f, 0x20, 0x42, 0x69, 0x6e, 0x64, 0x20, 0x61, 0x6c, 0x6c, 0x20,
+ 0x6f, 0x66, 0x20, 0x61, 0x6e, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74,
+ 0x27, 0x73, 0x20, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x20, 0x74,
+ 0x6f, 0x20, 0x74, 0x68, 0x61, 0x74, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63,
+ 0x74, 0x2e, 0x20, 0x55, 0x73, 0x65, 0x66, 0x75, 0x6c, 0x20, 0x66, 0x6f,
+ 0x72, 0x20, 0x65, 0x6e, 0x73, 0x75, 0x72, 0x69, 0x6e, 0x67, 0x20, 0x74,
+ 0x68, 0x61, 0x74, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x61, 0x6c, 0x6c,
+ 0x20, 0x63, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x73, 0x20, 0x64,
+ 0x65, 0x66, 0x69, 0x6e, 0x65, 0x64, 0x20, 0x6f, 0x6e, 0x20, 0x61, 0x6e,
+ 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20, 0x62, 0x65, 0x6c, 0x6f,
+ 0x6e, 0x67, 0x20, 0x74, 0x6f, 0x20, 0x69, 0x74, 0x2e, 0x0a, 0x20, 0x20,
+ 0x5f, 0x2e, 0x62, 0x69, 0x6e, 0x64, 0x41, 0x6c, 0x6c, 0x20, 0x3d, 0x20,
+ 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6f, 0x62, 0x6a,
+ 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20,
+ 0x66, 0x75, 0x6e, 0x63, 0x73, 0x20, 0x3d, 0x20, 0x73, 0x6c, 0x69, 0x63,
+ 0x65, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x61, 0x72, 0x67, 0x75, 0x6d,
+ 0x65, 0x6e, 0x74, 0x73, 0x2c, 0x20, 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x66, 0x75, 0x6e, 0x63, 0x73, 0x2e,
+ 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x20, 0x3d, 0x3d, 0x3d, 0x20, 0x30,
+ 0x29, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x73, 0x20, 0x3d, 0x20, 0x5f, 0x2e,
+ 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x28, 0x6f, 0x62,
+ 0x6a, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x61, 0x63, 0x68,
+ 0x28, 0x66, 0x75, 0x6e, 0x63, 0x73, 0x2c, 0x20, 0x66, 0x75, 0x6e, 0x63,
+ 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x66, 0x29, 0x20, 0x7b, 0x20, 0x6f, 0x62,
+ 0x6a, 0x5b, 0x66, 0x5d, 0x20, 0x3d, 0x20, 0x5f, 0x2e, 0x62, 0x69, 0x6e,
+ 0x64, 0x28, 0x6f, 0x62, 0x6a, 0x5b, 0x66, 0x5d, 0x2c, 0x20, 0x6f, 0x62,
+ 0x6a, 0x29, 0x3b, 0x20, 0x7d, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6f, 0x62, 0x6a, 0x3b, 0x0a,
+ 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x4d,
+ 0x65, 0x6d, 0x6f, 0x69, 0x7a, 0x65, 0x20, 0x61, 0x6e, 0x20, 0x65, 0x78,
+ 0x70, 0x65, 0x6e, 0x73, 0x69, 0x76, 0x65, 0x20, 0x66, 0x75, 0x6e, 0x63,
+ 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x62, 0x79, 0x20, 0x73, 0x74, 0x6f, 0x72,
+ 0x69, 0x6e, 0x67, 0x20, 0x69, 0x74, 0x73, 0x20, 0x72, 0x65, 0x73, 0x75,
+ 0x6c, 0x74, 0x73, 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x6d, 0x65, 0x6d,
+ 0x6f, 0x69, 0x7a, 0x65, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74,
+ 0x69, 0x6f, 0x6e, 0x28, 0x66, 0x75, 0x6e, 0x63, 0x2c, 0x20, 0x68, 0x61,
+ 0x73, 0x68, 0x65, 0x72, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x76, 0x61, 0x72, 0x20, 0x6d, 0x65, 0x6d, 0x6f, 0x20, 0x3d, 0x20, 0x7b,
+ 0x7d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x68, 0x61, 0x73, 0x68, 0x65,
+ 0x72, 0x20, 0x7c, 0x7c, 0x20, 0x28, 0x68, 0x61, 0x73, 0x68, 0x65, 0x72,
+ 0x20, 0x3d, 0x20, 0x5f, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74,
+ 0x79, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75,
+ 0x72, 0x6e, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28,
+ 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61,
+ 0x72, 0x20, 0x6b, 0x65, 0x79, 0x20, 0x3d, 0x20, 0x68, 0x61, 0x73, 0x68,
+ 0x65, 0x72, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x28, 0x74, 0x68, 0x69,
+ 0x73, 0x2c, 0x20, 0x61, 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73,
+ 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74,
+ 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x2e, 0x68, 0x61, 0x73, 0x28, 0x6d, 0x65,
+ 0x6d, 0x6f, 0x2c, 0x20, 0x6b, 0x65, 0x79, 0x29, 0x20, 0x3f, 0x20, 0x6d,
+ 0x65, 0x6d, 0x6f, 0x5b, 0x6b, 0x65, 0x79, 0x5d, 0x20, 0x3a, 0x20, 0x28,
+ 0x6d, 0x65, 0x6d, 0x6f, 0x5b, 0x6b, 0x65, 0x79, 0x5d, 0x20, 0x3d, 0x20,
+ 0x66, 0x75, 0x6e, 0x63, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x28, 0x74,
+ 0x68, 0x69, 0x73, 0x2c, 0x20, 0x61, 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e,
+ 0x74, 0x73, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x3b,
+ 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20,
+ 0x44, 0x65, 0x6c, 0x61, 0x79, 0x73, 0x20, 0x61, 0x20, 0x66, 0x75, 0x6e,
+ 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x74, 0x68,
+ 0x65, 0x20, 0x67, 0x69, 0x76, 0x65, 0x6e, 0x20, 0x6e, 0x75, 0x6d, 0x62,
+ 0x65, 0x72, 0x20, 0x6f, 0x66, 0x20, 0x6d, 0x69, 0x6c, 0x6c, 0x69, 0x73,
+ 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x2c, 0x20, 0x61, 0x6e, 0x64, 0x20,
+ 0x74, 0x68, 0x65, 0x6e, 0x20, 0x63, 0x61, 0x6c, 0x6c, 0x73, 0x0a, 0x20,
+ 0x20, 0x2f, 0x2f, 0x20, 0x69, 0x74, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20,
+ 0x74, 0x68, 0x65, 0x20, 0x61, 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74,
+ 0x73, 0x20, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x64, 0x2e, 0x0a,
+ 0x20, 0x20, 0x5f, 0x2e, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x20, 0x3d, 0x20,
+ 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x66, 0x75, 0x6e,
+ 0x63, 0x2c, 0x20, 0x77, 0x61, 0x69, 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x61, 0x72, 0x67, 0x73, 0x20,
+ 0x3d, 0x20, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x2e, 0x63, 0x61, 0x6c, 0x6c,
+ 0x28, 0x61, 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2c, 0x20,
+ 0x32, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75,
+ 0x72, 0x6e, 0x20, 0x73, 0x65, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75,
+ 0x74, 0x28, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x29,
+ 0x7b, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x66, 0x75, 0x6e,
+ 0x63, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x28, 0x6e, 0x75, 0x6c, 0x6c,
+ 0x2c, 0x20, 0x61, 0x72, 0x67, 0x73, 0x29, 0x3b, 0x20, 0x7d, 0x2c, 0x20,
+ 0x77, 0x61, 0x69, 0x74, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a,
+ 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x44, 0x65, 0x66, 0x65, 0x72, 0x73,
+ 0x20, 0x61, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2c,
+ 0x20, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x69, 0x6e, 0x67, 0x20,
+ 0x69, 0x74, 0x20, 0x74, 0x6f, 0x20, 0x72, 0x75, 0x6e, 0x20, 0x61, 0x66,
+ 0x74, 0x65, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x75, 0x72, 0x72,
+ 0x65, 0x6e, 0x74, 0x20, 0x63, 0x61, 0x6c, 0x6c, 0x20, 0x73, 0x74, 0x61,
+ 0x63, 0x6b, 0x20, 0x68, 0x61, 0x73, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20,
+ 0x63, 0x6c, 0x65, 0x61, 0x72, 0x65, 0x64, 0x2e, 0x0a, 0x20, 0x20, 0x5f,
+ 0x2e, 0x64, 0x65, 0x66, 0x65, 0x72, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e,
+ 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x66, 0x75, 0x6e, 0x63, 0x29, 0x20,
+ 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,
+ 0x20, 0x5f, 0x2e, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70,
+ 0x6c, 0x79, 0x28, 0x5f, 0x2c, 0x20, 0x5b, 0x66, 0x75, 0x6e, 0x63, 0x2c,
+ 0x20, 0x31, 0x5d, 0x2e, 0x63, 0x6f, 0x6e, 0x63, 0x61, 0x74, 0x28, 0x73,
+ 0x6c, 0x69, 0x63, 0x65, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x61, 0x72,
+ 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2c, 0x20, 0x31, 0x29, 0x29,
+ 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f,
+ 0x2f, 0x20, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x73, 0x20, 0x61, 0x20,
+ 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2c, 0x20, 0x74, 0x68,
+ 0x61, 0x74, 0x2c, 0x20, 0x77, 0x68, 0x65, 0x6e, 0x20, 0x69, 0x6e, 0x76,
+ 0x6f, 0x6b, 0x65, 0x64, 0x2c, 0x20, 0x77, 0x69, 0x6c, 0x6c, 0x20, 0x6f,
+ 0x6e, 0x6c, 0x79, 0x20, 0x62, 0x65, 0x20, 0x74, 0x72, 0x69, 0x67, 0x67,
+ 0x65, 0x72, 0x65, 0x64, 0x20, 0x61, 0x74, 0x20, 0x6d, 0x6f, 0x73, 0x74,
+ 0x20, 0x6f, 0x6e, 0x63, 0x65, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x64,
+ 0x75, 0x72, 0x69, 0x6e, 0x67, 0x20, 0x61, 0x20, 0x67, 0x69, 0x76, 0x65,
+ 0x6e, 0x20, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x20, 0x6f, 0x66, 0x20,
+ 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x74, 0x68,
+ 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e,
+ 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x66, 0x75, 0x6e, 0x63, 0x2c, 0x20,
+ 0x77, 0x61, 0x69, 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x76, 0x61, 0x72, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x2c,
+ 0x20, 0x61, 0x72, 0x67, 0x73, 0x2c, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x6f,
+ 0x75, 0x74, 0x2c, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x3b, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x70, 0x72, 0x65, 0x76,
+ 0x69, 0x6f, 0x75, 0x73, 0x20, 0x3d, 0x20, 0x30, 0x3b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x6c, 0x61, 0x74, 0x65, 0x72, 0x20,
+ 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x29,
+ 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x70, 0x72, 0x65,
+ 0x76, 0x69, 0x6f, 0x75, 0x73, 0x20, 0x3d, 0x20, 0x6e, 0x65, 0x77, 0x20,
+ 0x44, 0x61, 0x74, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x6e, 0x75,
+ 0x6c, 0x6c, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65,
+ 0x73, 0x75, 0x6c, 0x74, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x2e,
+ 0x61, 0x70, 0x70, 0x6c, 0x79, 0x28, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78,
+ 0x74, 0x2c, 0x20, 0x61, 0x72, 0x67, 0x73, 0x29, 0x3b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74,
+ 0x75, 0x72, 0x6e, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
+ 0x28, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76,
+ 0x61, 0x72, 0x20, 0x6e, 0x6f, 0x77, 0x20, 0x3d, 0x20, 0x6e, 0x65, 0x77,
+ 0x20, 0x44, 0x61, 0x74, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x76, 0x61, 0x72, 0x20, 0x72, 0x65, 0x6d, 0x61, 0x69, 0x6e, 0x69,
+ 0x6e, 0x67, 0x20, 0x3d, 0x20, 0x77, 0x61, 0x69, 0x74, 0x20, 0x2d, 0x20,
+ 0x28, 0x6e, 0x6f, 0x77, 0x20, 0x2d, 0x20, 0x70, 0x72, 0x65, 0x76, 0x69,
+ 0x6f, 0x75, 0x73, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x20, 0x3d, 0x20, 0x74, 0x68,
+ 0x69, 0x73, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x61, 0x72,
+ 0x67, 0x73, 0x20, 0x3d, 0x20, 0x61, 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e,
+ 0x74, 0x73, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66,
+ 0x20, 0x28, 0x72, 0x65, 0x6d, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x20,
+ 0x3c, 0x3d, 0x20, 0x30, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x54, 0x69, 0x6d,
+ 0x65, 0x6f, 0x75, 0x74, 0x28, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74,
+ 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x74,
+ 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x6e, 0x75, 0x6c,
+ 0x6c, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x70,
+ 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x20, 0x3d, 0x20, 0x6e, 0x6f,
+ 0x77, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72,
+ 0x65, 0x73, 0x75, 0x6c, 0x74, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63,
+ 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x28, 0x63, 0x6f, 0x6e, 0x74, 0x65,
+ 0x78, 0x74, 0x2c, 0x20, 0x61, 0x72, 0x67, 0x73, 0x29, 0x3b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x20,
+ 0x69, 0x66, 0x20, 0x28, 0x21, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74,
+ 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x73, 0x65,
+ 0x74, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x28, 0x6c, 0x61, 0x74,
+ 0x65, 0x72, 0x2c, 0x20, 0x72, 0x65, 0x6d, 0x61, 0x69, 0x6e, 0x69, 0x6e,
+ 0x67, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,
+ 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x3b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x7d, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20,
+ 0x2f, 0x2f, 0x20, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x73, 0x20, 0x61,
+ 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2c, 0x20, 0x74,
+ 0x68, 0x61, 0x74, 0x2c, 0x20, 0x61, 0x73, 0x20, 0x6c, 0x6f, 0x6e, 0x67,
+ 0x20, 0x61, 0x73, 0x20, 0x69, 0x74, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x69,
+ 0x6e, 0x75, 0x65, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x62, 0x65, 0x20, 0x69,
+ 0x6e, 0x76, 0x6f, 0x6b, 0x65, 0x64, 0x2c, 0x20, 0x77, 0x69, 0x6c, 0x6c,
+ 0x20, 0x6e, 0x6f, 0x74, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x62, 0x65,
+ 0x20, 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x65, 0x64, 0x2e, 0x20,
+ 0x54, 0x68, 0x65, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
+ 0x20, 0x77, 0x69, 0x6c, 0x6c, 0x20, 0x62, 0x65, 0x20, 0x63, 0x61, 0x6c,
+ 0x6c, 0x65, 0x64, 0x20, 0x61, 0x66, 0x74, 0x65, 0x72, 0x20, 0x69, 0x74,
+ 0x20, 0x73, 0x74, 0x6f, 0x70, 0x73, 0x20, 0x62, 0x65, 0x69, 0x6e, 0x67,
+ 0x20, 0x63, 0x61, 0x6c, 0x6c, 0x65, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x0a,
+ 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x4e, 0x20, 0x6d, 0x69, 0x6c, 0x6c, 0x69,
+ 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x2e, 0x20, 0x49, 0x66, 0x20,
+ 0x60, 0x69, 0x6d, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x74, 0x65, 0x60, 0x20,
+ 0x69, 0x73, 0x20, 0x70, 0x61, 0x73, 0x73, 0x65, 0x64, 0x2c, 0x20, 0x74,
+ 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20, 0x66,
+ 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x6e, 0x20, 0x74,
+ 0x68, 0x65, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x6c, 0x65, 0x61, 0x64,
+ 0x69, 0x6e, 0x67, 0x20, 0x65, 0x64, 0x67, 0x65, 0x2c, 0x20, 0x69, 0x6e,
+ 0x73, 0x74, 0x65, 0x61, 0x64, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65,
+ 0x20, 0x74, 0x72, 0x61, 0x69, 0x6c, 0x69, 0x6e, 0x67, 0x2e, 0x0a, 0x20,
+ 0x20, 0x5f, 0x2e, 0x64, 0x65, 0x62, 0x6f, 0x75, 0x6e, 0x63, 0x65, 0x20,
+ 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x66,
+ 0x75, 0x6e, 0x63, 0x2c, 0x20, 0x77, 0x61, 0x69, 0x74, 0x2c, 0x20, 0x69,
+ 0x6d, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x74, 0x65, 0x29, 0x20, 0x7b, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x74, 0x69, 0x6d, 0x65,
+ 0x6f, 0x75, 0x74, 0x2c, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20,
+ 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x29, 0x20, 0x7b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x63,
+ 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x20, 0x3d, 0x20, 0x74, 0x68, 0x69,
+ 0x73, 0x2c, 0x20, 0x61, 0x72, 0x67, 0x73, 0x20, 0x3d, 0x20, 0x61, 0x72,
+ 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x3b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x6c, 0x61, 0x74, 0x65, 0x72,
+ 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28,
+ 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x6e, 0x75,
+ 0x6c, 0x6c, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x69, 0x66, 0x20, 0x28, 0x21, 0x69, 0x6d, 0x6d, 0x65, 0x64, 0x69, 0x61,
+ 0x74, 0x65, 0x29, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x20, 0x3d,
+ 0x20, 0x66, 0x75, 0x6e, 0x63, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x28,
+ 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x2c, 0x20, 0x61, 0x72, 0x67,
+ 0x73, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x63,
+ 0x61, 0x6c, 0x6c, 0x4e, 0x6f, 0x77, 0x20, 0x3d, 0x20, 0x69, 0x6d, 0x6d,
+ 0x65, 0x64, 0x69, 0x61, 0x74, 0x65, 0x20, 0x26, 0x26, 0x20, 0x21, 0x74,
+ 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x54, 0x69, 0x6d, 0x65, 0x6f,
+ 0x75, 0x74, 0x28, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x29, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x6f,
+ 0x75, 0x74, 0x20, 0x3d, 0x20, 0x73, 0x65, 0x74, 0x54, 0x69, 0x6d, 0x65,
+ 0x6f, 0x75, 0x74, 0x28, 0x6c, 0x61, 0x74, 0x65, 0x72, 0x2c, 0x20, 0x77,
+ 0x61, 0x69, 0x74, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x69, 0x66, 0x20, 0x28, 0x63, 0x61, 0x6c, 0x6c, 0x4e, 0x6f, 0x77, 0x29,
+ 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x20, 0x3d, 0x20, 0x66, 0x75,
+ 0x6e, 0x63, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x28, 0x63, 0x6f, 0x6e,
+ 0x74, 0x65, 0x78, 0x74, 0x2c, 0x20, 0x61, 0x72, 0x67, 0x73, 0x29, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72,
+ 0x6e, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x3b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20,
+ 0x20, 0x2f, 0x2f, 0x20, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x73, 0x20,
+ 0x61, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x74,
+ 0x68, 0x61, 0x74, 0x20, 0x77, 0x69, 0x6c, 0x6c, 0x20, 0x62, 0x65, 0x20,
+ 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x64, 0x20, 0x61, 0x74, 0x20,
+ 0x6d, 0x6f, 0x73, 0x74, 0x20, 0x6f, 0x6e, 0x65, 0x20, 0x74, 0x69, 0x6d,
+ 0x65, 0x2c, 0x20, 0x6e, 0x6f, 0x20, 0x6d, 0x61, 0x74, 0x74, 0x65, 0x72,
+ 0x20, 0x68, 0x6f, 0x77, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x6f, 0x66,
+ 0x74, 0x65, 0x6e, 0x20, 0x79, 0x6f, 0x75, 0x20, 0x63, 0x61, 0x6c, 0x6c,
+ 0x20, 0x69, 0x74, 0x2e, 0x20, 0x55, 0x73, 0x65, 0x66, 0x75, 0x6c, 0x20,
+ 0x66, 0x6f, 0x72, 0x20, 0x6c, 0x61, 0x7a, 0x79, 0x20, 0x69, 0x6e, 0x69,
+ 0x74, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e,
+ 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x6f, 0x6e, 0x63, 0x65, 0x20, 0x3d, 0x20,
+ 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x66, 0x75, 0x6e,
+ 0x63, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72,
+ 0x20, 0x72, 0x61, 0x6e, 0x20, 0x3d, 0x20, 0x66, 0x61, 0x6c, 0x73, 0x65,
+ 0x2c, 0x20, 0x6d, 0x65, 0x6d, 0x6f, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74,
+ 0x69, 0x6f, 0x6e, 0x28, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x72, 0x61, 0x6e, 0x29, 0x20, 0x72,
+ 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6d, 0x65, 0x6d, 0x6f, 0x3b, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x61, 0x6e, 0x20, 0x3d, 0x20,
+ 0x74, 0x72, 0x75, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x6d, 0x65, 0x6d, 0x6f, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x2e,
+ 0x61, 0x70, 0x70, 0x6c, 0x79, 0x28, 0x74, 0x68, 0x69, 0x73, 0x2c, 0x20,
+ 0x61, 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x29, 0x3b, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x20, 0x3d,
+ 0x20, 0x6e, 0x75, 0x6c, 0x6c, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6d, 0x65, 0x6d, 0x6f,
+ 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x20, 0x20, 0x7d,
+ 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x52, 0x65, 0x74, 0x75,
+ 0x72, 0x6e, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x66, 0x69, 0x72, 0x73,
+ 0x74, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x70,
+ 0x61, 0x73, 0x73, 0x65, 0x64, 0x20, 0x61, 0x73, 0x20, 0x61, 0x6e, 0x20,
+ 0x61, 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x74, 0x6f, 0x20,
+ 0x74, 0x68, 0x65, 0x20, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x2c, 0x0a,
+ 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x69, 0x6e,
+ 0x67, 0x20, 0x79, 0x6f, 0x75, 0x20, 0x74, 0x6f, 0x20, 0x61, 0x64, 0x6a,
+ 0x75, 0x73, 0x74, 0x20, 0x61, 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74,
+ 0x73, 0x2c, 0x20, 0x72, 0x75, 0x6e, 0x20, 0x63, 0x6f, 0x64, 0x65, 0x20,
+ 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x61,
+ 0x66, 0x74, 0x65, 0x72, 0x2c, 0x20, 0x61, 0x6e, 0x64, 0x0a, 0x20, 0x20,
+ 0x2f, 0x2f, 0x20, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e,
+ 0x61, 0x6c, 0x6c, 0x79, 0x20, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65,
+ 0x20, 0x74, 0x68, 0x65, 0x20, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61,
+ 0x6c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x0a,
+ 0x20, 0x20, 0x5f, 0x2e, 0x77, 0x72, 0x61, 0x70, 0x20, 0x3d, 0x20, 0x66,
+ 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x66, 0x75, 0x6e, 0x63,
+ 0x2c, 0x20, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x29, 0x20, 0x7b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20,
+ 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x29, 0x20, 0x7b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x61,
+ 0x72, 0x67, 0x73, 0x20, 0x3d, 0x20, 0x5b, 0x66, 0x75, 0x6e, 0x63, 0x5d,
+ 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x70, 0x75, 0x73, 0x68,
+ 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x28, 0x61, 0x72, 0x67, 0x73, 0x2c,
+ 0x20, 0x61, 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x29, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72,
+ 0x6e, 0x20, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x2e, 0x61, 0x70,
+ 0x70, 0x6c, 0x79, 0x28, 0x74, 0x68, 0x69, 0x73, 0x2c, 0x20, 0x61, 0x72,
+ 0x67, 0x73, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x3b, 0x0a,
+ 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x52,
+ 0x65, 0x74, 0x75, 0x72, 0x6e, 0x73, 0x20, 0x61, 0x20, 0x66, 0x75, 0x6e,
+ 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x74, 0x68, 0x61, 0x74, 0x20, 0x69,
+ 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73,
+ 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x66, 0x20, 0x61, 0x20, 0x6c,
+ 0x69, 0x73, 0x74, 0x20, 0x6f, 0x66, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74,
+ 0x69, 0x6f, 0x6e, 0x73, 0x2c, 0x20, 0x65, 0x61, 0x63, 0x68, 0x0a, 0x20,
+ 0x20, 0x2f, 0x2f, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x69, 0x6e,
+ 0x67, 0x20, 0x74, 0x68, 0x65, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,
+ 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68,
+ 0x65, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x74,
+ 0x68, 0x61, 0x74, 0x20, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x73, 0x2e,
+ 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65,
+ 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28,
+ 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20,
+ 0x66, 0x75, 0x6e, 0x63, 0x73, 0x20, 0x3d, 0x20, 0x61, 0x72, 0x67, 0x75,
+ 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72,
+ 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69,
+ 0x6f, 0x6e, 0x28, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x76, 0x61, 0x72, 0x20, 0x61, 0x72, 0x67, 0x73, 0x20, 0x3d, 0x20,
+ 0x61, 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x3b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x28, 0x76, 0x61,
+ 0x72, 0x20, 0x69, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x73, 0x2e,
+ 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x20, 0x2d, 0x20, 0x31, 0x3b, 0x20,
+ 0x69, 0x20, 0x3e, 0x3d, 0x20, 0x30, 0x3b, 0x20, 0x69, 0x2d, 0x2d, 0x29,
+ 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x61,
+ 0x72, 0x67, 0x73, 0x20, 0x3d, 0x20, 0x5b, 0x66, 0x75, 0x6e, 0x63, 0x73,
+ 0x5b, 0x69, 0x5d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x28, 0x74, 0x68,
+ 0x69, 0x73, 0x2c, 0x20, 0x61, 0x72, 0x67, 0x73, 0x29, 0x5d, 0x3b, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x61, 0x72, 0x67,
+ 0x73, 0x5b, 0x30, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x3b,
+ 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20,
+ 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x73, 0x20, 0x61, 0x20, 0x66, 0x75,
+ 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x74, 0x68, 0x61, 0x74, 0x20,
+ 0x77, 0x69, 0x6c, 0x6c, 0x20, 0x6f, 0x6e, 0x6c, 0x79, 0x20, 0x62, 0x65,
+ 0x20, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x64, 0x20, 0x61, 0x66,
+ 0x74, 0x65, 0x72, 0x20, 0x62, 0x65, 0x69, 0x6e, 0x67, 0x20, 0x63, 0x61,
+ 0x6c, 0x6c, 0x65, 0x64, 0x20, 0x4e, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x73,
+ 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x61, 0x66, 0x74, 0x65, 0x72, 0x20,
+ 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x74,
+ 0x69, 0x6d, 0x65, 0x73, 0x2c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x29, 0x20,
+ 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x74, 0x69,
+ 0x6d, 0x65, 0x73, 0x20, 0x3c, 0x3d, 0x20, 0x30, 0x29, 0x20, 0x72, 0x65,
+ 0x74, 0x75, 0x72, 0x6e, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x28, 0x29, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20,
+ 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x29, 0x20, 0x7b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x2d,
+ 0x2d, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x20, 0x3c, 0x20, 0x31, 0x29, 0x20,
+ 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65,
+ 0x74, 0x75, 0x72, 0x6e, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x2e, 0x61, 0x70,
+ 0x70, 0x6c, 0x79, 0x28, 0x74, 0x68, 0x69, 0x73, 0x2c, 0x20, 0x61, 0x72,
+ 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x29, 0x3b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x3b,
+ 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20,
+ 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20, 0x46, 0x75, 0x6e, 0x63, 0x74,
+ 0x69, 0x6f, 0x6e, 0x73, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x2d, 0x2d,
+ 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
+ 0x2d, 0x2d, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x52, 0x65, 0x74,
+ 0x72, 0x69, 0x65, 0x76, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6e, 0x61,
+ 0x6d, 0x65, 0x73, 0x20, 0x6f, 0x66, 0x20, 0x61, 0x6e, 0x20, 0x6f, 0x62,
+ 0x6a, 0x65, 0x63, 0x74, 0x27, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x70, 0x65,
+ 0x72, 0x74, 0x69, 0x65, 0x73, 0x2e, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20,
+ 0x44, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x65, 0x73, 0x20, 0x74, 0x6f,
+ 0x20, 0x2a, 0x2a, 0x45, 0x43, 0x4d, 0x41, 0x53, 0x63, 0x72, 0x69, 0x70,
+ 0x74, 0x20, 0x35, 0x2a, 0x2a, 0x27, 0x73, 0x20, 0x6e, 0x61, 0x74, 0x69,
+ 0x76, 0x65, 0x20, 0x60, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2e, 0x6b,
+ 0x65, 0x79, 0x73, 0x60, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x6b, 0x65, 0x79,
+ 0x73, 0x20, 0x3d, 0x20, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x4b, 0x65,
+ 0x79, 0x73, 0x20, 0x7c, 0x7c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69,
+ 0x6f, 0x6e, 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x6f, 0x62, 0x6a, 0x20, 0x21, 0x3d,
+ 0x3d, 0x20, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x28, 0x6f, 0x62, 0x6a,
+ 0x29, 0x29, 0x20, 0x74, 0x68, 0x72, 0x6f, 0x77, 0x20, 0x6e, 0x65, 0x77,
+ 0x20, 0x54, 0x79, 0x70, 0x65, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x28, 0x27,
+ 0x49, 0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x20, 0x6f, 0x62, 0x6a, 0x65,
+ 0x63, 0x74, 0x27, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61,
+ 0x72, 0x20, 0x6b, 0x65, 0x79, 0x73, 0x20, 0x3d, 0x20, 0x5b, 0x5d, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x28, 0x76, 0x61,
+ 0x72, 0x20, 0x6b, 0x65, 0x79, 0x20, 0x69, 0x6e, 0x20, 0x6f, 0x62, 0x6a,
+ 0x29, 0x20, 0x69, 0x66, 0x20, 0x28, 0x5f, 0x2e, 0x68, 0x61, 0x73, 0x28,
+ 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x6b, 0x65, 0x79, 0x29, 0x29, 0x20, 0x6b,
+ 0x65, 0x79, 0x73, 0x5b, 0x6b, 0x65, 0x79, 0x73, 0x2e, 0x6c, 0x65, 0x6e,
+ 0x67, 0x74, 0x68, 0x5d, 0x20, 0x3d, 0x20, 0x6b, 0x65, 0x79, 0x3b, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6b,
+ 0x65, 0x79, 0x73, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20,
+ 0x20, 0x2f, 0x2f, 0x20, 0x52, 0x65, 0x74, 0x72, 0x69, 0x65, 0x76, 0x65,
+ 0x20, 0x74, 0x68, 0x65, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x20,
+ 0x6f, 0x66, 0x20, 0x61, 0x6e, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74,
+ 0x27, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65,
+ 0x73, 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x76, 0x61, 0x6c, 0x75, 0x65,
+ 0x73, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
+ 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x76, 0x61, 0x72, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x20, 0x3d,
+ 0x20, 0x5b, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x72,
+ 0x20, 0x28, 0x76, 0x61, 0x72, 0x20, 0x6b, 0x65, 0x79, 0x20, 0x69, 0x6e,
+ 0x20, 0x6f, 0x62, 0x6a, 0x29, 0x20, 0x69, 0x66, 0x20, 0x28, 0x5f, 0x2e,
+ 0x68, 0x61, 0x73, 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x6b, 0x65, 0x79,
+ 0x29, 0x29, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x2e, 0x70, 0x75,
+ 0x73, 0x68, 0x28, 0x6f, 0x62, 0x6a, 0x5b, 0x6b, 0x65, 0x79, 0x5d, 0x29,
+ 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,
+ 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x3b, 0x0a, 0x20, 0x20, 0x7d,
+ 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x43, 0x6f, 0x6e, 0x76,
+ 0x65, 0x72, 0x74, 0x20, 0x61, 0x6e, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63,
+ 0x74, 0x20, 0x69, 0x6e, 0x74, 0x6f, 0x20, 0x61, 0x20, 0x6c, 0x69, 0x73,
+ 0x74, 0x20, 0x6f, 0x66, 0x20, 0x60, 0x5b, 0x6b, 0x65, 0x79, 0x2c, 0x20,
+ 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5d, 0x60, 0x20, 0x70, 0x61, 0x69, 0x72,
+ 0x73, 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x70, 0x61, 0x69, 0x72, 0x73,
+ 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28,
+ 0x6f, 0x62, 0x6a, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76,
+ 0x61, 0x72, 0x20, 0x70, 0x61, 0x69, 0x72, 0x73, 0x20, 0x3d, 0x20, 0x5b,
+ 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x28,
+ 0x76, 0x61, 0x72, 0x20, 0x6b, 0x65, 0x79, 0x20, 0x69, 0x6e, 0x20, 0x6f,
+ 0x62, 0x6a, 0x29, 0x20, 0x69, 0x66, 0x20, 0x28, 0x5f, 0x2e, 0x68, 0x61,
+ 0x73, 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x6b, 0x65, 0x79, 0x29, 0x29,
+ 0x20, 0x70, 0x61, 0x69, 0x72, 0x73, 0x2e, 0x70, 0x75, 0x73, 0x68, 0x28,
+ 0x5b, 0x6b, 0x65, 0x79, 0x2c, 0x20, 0x6f, 0x62, 0x6a, 0x5b, 0x6b, 0x65,
+ 0x79, 0x5d, 0x5d, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65,
+ 0x74, 0x75, 0x72, 0x6e, 0x20, 0x70, 0x61, 0x69, 0x72, 0x73, 0x3b, 0x0a,
+ 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x49,
+ 0x6e, 0x76, 0x65, 0x72, 0x74, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6b, 0x65,
+ 0x79, 0x73, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65,
+ 0x73, 0x20, 0x6f, 0x66, 0x20, 0x61, 0x6e, 0x20, 0x6f, 0x62, 0x6a, 0x65,
+ 0x63, 0x74, 0x2e, 0x20, 0x54, 0x68, 0x65, 0x20, 0x76, 0x61, 0x6c, 0x75,
+ 0x65, 0x73, 0x20, 0x6d, 0x75, 0x73, 0x74, 0x20, 0x62, 0x65, 0x20, 0x73,
+ 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x62, 0x6c, 0x65, 0x2e,
+ 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x69, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x20,
+ 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6f,
+ 0x62, 0x6a, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61,
+ 0x72, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x20, 0x3d, 0x20, 0x7b,
+ 0x7d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x28,
+ 0x76, 0x61, 0x72, 0x20, 0x6b, 0x65, 0x79, 0x20, 0x69, 0x6e, 0x20, 0x6f,
+ 0x62, 0x6a, 0x29, 0x20, 0x69, 0x66, 0x20, 0x28, 0x5f, 0x2e, 0x68, 0x61,
+ 0x73, 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x6b, 0x65, 0x79, 0x29, 0x29,
+ 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5b, 0x6f, 0x62, 0x6a, 0x5b,
+ 0x6b, 0x65, 0x79, 0x5d, 0x5d, 0x20, 0x3d, 0x20, 0x6b, 0x65, 0x79, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20,
+ 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b,
+ 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x52, 0x65, 0x74, 0x75, 0x72,
+ 0x6e, 0x20, 0x61, 0x20, 0x73, 0x6f, 0x72, 0x74, 0x65, 0x64, 0x20, 0x6c,
+ 0x69, 0x73, 0x74, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x66,
+ 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6e, 0x61, 0x6d, 0x65,
+ 0x73, 0x20, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x20,
+ 0x6f, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63,
+ 0x74, 0x2e, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x41, 0x6c, 0x69, 0x61,
+ 0x73, 0x65, 0x64, 0x20, 0x61, 0x73, 0x20, 0x60, 0x6d, 0x65, 0x74, 0x68,
+ 0x6f, 0x64, 0x73, 0x60, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x66, 0x75, 0x6e,
+ 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x3d, 0x20, 0x5f, 0x2e, 0x6d,
+ 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e,
+ 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x20, 0x7b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x6e, 0x61, 0x6d,
+ 0x65, 0x73, 0x20, 0x3d, 0x20, 0x5b, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x66, 0x6f, 0x72, 0x20, 0x28, 0x76, 0x61, 0x72, 0x20, 0x6b, 0x65,
+ 0x79, 0x20, 0x69, 0x6e, 0x20, 0x6f, 0x62, 0x6a, 0x29, 0x20, 0x7b, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x5f, 0x2e,
+ 0x69, 0x73, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6f,
+ 0x62, 0x6a, 0x5b, 0x6b, 0x65, 0x79, 0x5d, 0x29, 0x29, 0x20, 0x6e, 0x61,
+ 0x6d, 0x65, 0x73, 0x2e, 0x70, 0x75, 0x73, 0x68, 0x28, 0x6b, 0x65, 0x79,
+ 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6e, 0x61, 0x6d, 0x65,
+ 0x73, 0x2e, 0x73, 0x6f, 0x72, 0x74, 0x28, 0x29, 0x3b, 0x0a, 0x20, 0x20,
+ 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x45, 0x78, 0x74,
+ 0x65, 0x6e, 0x64, 0x20, 0x61, 0x20, 0x67, 0x69, 0x76, 0x65, 0x6e, 0x20,
+ 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20,
+ 0x61, 0x6c, 0x6c, 0x20, 0x74, 0x68, 0x65, 0x20, 0x70, 0x72, 0x6f, 0x70,
+ 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x20, 0x69, 0x6e, 0x20, 0x70, 0x61,
+ 0x73, 0x73, 0x65, 0x64, 0x2d, 0x69, 0x6e, 0x20, 0x6f, 0x62, 0x6a, 0x65,
+ 0x63, 0x74, 0x28, 0x73, 0x29, 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x65,
+ 0x78, 0x74, 0x65, 0x6e, 0x64, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63,
+ 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x20, 0x7b, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x65, 0x61, 0x63, 0x68, 0x28, 0x73, 0x6c, 0x69,
+ 0x63, 0x65, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x61, 0x72, 0x67, 0x75,
+ 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2c, 0x20, 0x31, 0x29, 0x2c, 0x20, 0x66,
+ 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x73, 0x6f, 0x75, 0x72,
+ 0x63, 0x65, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x69, 0x66, 0x20, 0x28, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x29, 0x20,
+ 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f,
+ 0x72, 0x20, 0x28, 0x76, 0x61, 0x72, 0x20, 0x70, 0x72, 0x6f, 0x70, 0x20,
+ 0x69, 0x6e, 0x20, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x29, 0x20, 0x7b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6f,
+ 0x62, 0x6a, 0x5b, 0x70, 0x72, 0x6f, 0x70, 0x5d, 0x20, 0x3d, 0x20, 0x73,
+ 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5b, 0x70, 0x72, 0x6f, 0x70, 0x5d, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d,
+ 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72,
+ 0x6e, 0x20, 0x6f, 0x62, 0x6a, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a,
+ 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e,
+ 0x20, 0x61, 0x20, 0x63, 0x6f, 0x70, 0x79, 0x20, 0x6f, 0x66, 0x20, 0x74,
+ 0x68, 0x65, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20, 0x6f, 0x6e,
+ 0x6c, 0x79, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e,
+ 0x67, 0x20, 0x74, 0x68, 0x65, 0x20, 0x77, 0x68, 0x69, 0x74, 0x65, 0x6c,
+ 0x69, 0x73, 0x74, 0x65, 0x64, 0x20, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72,
+ 0x74, 0x69, 0x65, 0x73, 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x70, 0x69,
+ 0x63, 0x6b, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f,
+ 0x6e, 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x76, 0x61, 0x72, 0x20, 0x63, 0x6f, 0x70, 0x79, 0x20, 0x3d, 0x20,
+ 0x7b, 0x7d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20,
+ 0x6b, 0x65, 0x79, 0x73, 0x20, 0x3d, 0x20, 0x63, 0x6f, 0x6e, 0x63, 0x61,
+ 0x74, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x28, 0x41, 0x72, 0x72, 0x61,
+ 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x2c, 0x20, 0x73, 0x6c, 0x69, 0x63,
+ 0x65, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x61, 0x72, 0x67, 0x75, 0x6d,
+ 0x65, 0x6e, 0x74, 0x73, 0x2c, 0x20, 0x31, 0x29, 0x29, 0x3b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x65, 0x61, 0x63, 0x68, 0x28, 0x6b, 0x65, 0x79, 0x73,
+ 0x2c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6b,
+ 0x65, 0x79, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x69, 0x66, 0x20, 0x28, 0x6b, 0x65, 0x79, 0x20, 0x69, 0x6e, 0x20, 0x6f,
+ 0x62, 0x6a, 0x29, 0x20, 0x63, 0x6f, 0x70, 0x79, 0x5b, 0x6b, 0x65, 0x79,
+ 0x5d, 0x20, 0x3d, 0x20, 0x6f, 0x62, 0x6a, 0x5b, 0x6b, 0x65, 0x79, 0x5d,
+ 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x29, 0x3b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x63, 0x6f, 0x70,
+ 0x79, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20,
+ 0x2f, 0x2f, 0x20, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x61, 0x20,
+ 0x63, 0x6f, 0x70, 0x79, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20,
+ 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20, 0x77, 0x69, 0x74, 0x68, 0x6f,
+ 0x75, 0x74, 0x20, 0x74, 0x68, 0x65, 0x20, 0x62, 0x6c, 0x61, 0x63, 0x6b,
+ 0x6c, 0x69, 0x73, 0x74, 0x65, 0x64, 0x20, 0x70, 0x72, 0x6f, 0x70, 0x65,
+ 0x72, 0x74, 0x69, 0x65, 0x73, 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x6f,
+ 0x6d, 0x69, 0x74, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69,
+ 0x6f, 0x6e, 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x63, 0x6f, 0x70, 0x79, 0x20, 0x3d,
+ 0x20, 0x7b, 0x7d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72,
+ 0x20, 0x6b, 0x65, 0x79, 0x73, 0x20, 0x3d, 0x20, 0x63, 0x6f, 0x6e, 0x63,
+ 0x61, 0x74, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x28, 0x41, 0x72, 0x72,
+ 0x61, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x2c, 0x20, 0x73, 0x6c, 0x69,
+ 0x63, 0x65, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x61, 0x72, 0x67, 0x75,
+ 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2c, 0x20, 0x31, 0x29, 0x29, 0x3b, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x28, 0x76, 0x61, 0x72,
+ 0x20, 0x6b, 0x65, 0x79, 0x20, 0x69, 0x6e, 0x20, 0x6f, 0x62, 0x6a, 0x29,
+ 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20,
+ 0x28, 0x21, 0x5f, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x73,
+ 0x28, 0x6b, 0x65, 0x79, 0x73, 0x2c, 0x20, 0x6b, 0x65, 0x79, 0x29, 0x29,
+ 0x20, 0x63, 0x6f, 0x70, 0x79, 0x5b, 0x6b, 0x65, 0x79, 0x5d, 0x20, 0x3d,
+ 0x20, 0x6f, 0x62, 0x6a, 0x5b, 0x6b, 0x65, 0x79, 0x5d, 0x3b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74,
+ 0x75, 0x72, 0x6e, 0x20, 0x63, 0x6f, 0x70, 0x79, 0x3b, 0x0a, 0x20, 0x20,
+ 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x46, 0x69, 0x6c,
+ 0x6c, 0x20, 0x69, 0x6e, 0x20, 0x61, 0x20, 0x67, 0x69, 0x76, 0x65, 0x6e,
+ 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20, 0x77, 0x69, 0x74, 0x68,
+ 0x20, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x20, 0x70, 0x72, 0x6f,
+ 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x2e, 0x0a, 0x20, 0x20, 0x5f,
+ 0x2e, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x20, 0x3d, 0x20,
+ 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6f, 0x62, 0x6a,
+ 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x61, 0x63, 0x68,
+ 0x28, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28,
+ 0x61, 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2c, 0x20, 0x31,
+ 0x29, 0x2c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28,
+ 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x73, 0x6f, 0x75, 0x72,
+ 0x63, 0x65, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x28, 0x76, 0x61, 0x72, 0x20, 0x70,
+ 0x72, 0x6f, 0x70, 0x20, 0x69, 0x6e, 0x20, 0x73, 0x6f, 0x75, 0x72, 0x63,
+ 0x65, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x6f, 0x62, 0x6a, 0x5b, 0x70,
+ 0x72, 0x6f, 0x70, 0x5d, 0x20, 0x3d, 0x3d, 0x20, 0x6e, 0x75, 0x6c, 0x6c,
+ 0x29, 0x20, 0x6f, 0x62, 0x6a, 0x5b, 0x70, 0x72, 0x6f, 0x70, 0x5d, 0x20,
+ 0x3d, 0x20, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5b, 0x70, 0x72, 0x6f,
+ 0x70, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x7d, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65,
+ 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6f, 0x62, 0x6a, 0x3b, 0x0a, 0x20, 0x20,
+ 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x43, 0x72, 0x65,
+ 0x61, 0x74, 0x65, 0x20, 0x61, 0x20, 0x28, 0x73, 0x68, 0x61, 0x6c, 0x6c,
+ 0x6f, 0x77, 0x2d, 0x63, 0x6c, 0x6f, 0x6e, 0x65, 0x64, 0x29, 0x20, 0x64,
+ 0x75, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x65, 0x20, 0x6f, 0x66, 0x20,
+ 0x61, 0x6e, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2e, 0x0a, 0x20,
+ 0x20, 0x5f, 0x2e, 0x63, 0x6c, 0x6f, 0x6e, 0x65, 0x20, 0x3d, 0x20, 0x66,
+ 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6f, 0x62, 0x6a, 0x29,
+ 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x21,
+ 0x5f, 0x2e, 0x69, 0x73, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x28, 0x6f,
+ 0x62, 0x6a, 0x29, 0x29, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20,
+ 0x6f, 0x62, 0x6a, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74,
+ 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x2e, 0x69, 0x73, 0x41, 0x72, 0x72, 0x61,
+ 0x79, 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x20, 0x3f, 0x20, 0x6f, 0x62, 0x6a,
+ 0x2e, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x28, 0x29, 0x20, 0x3a, 0x20, 0x5f,
+ 0x2e, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x64, 0x28, 0x7b, 0x7d, 0x2c, 0x20,
+ 0x6f, 0x62, 0x6a, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a,
+ 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x49, 0x6e, 0x76, 0x6f, 0x6b, 0x65, 0x73,
+ 0x20, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x65, 0x70, 0x74, 0x6f, 0x72,
+ 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6f, 0x62,
+ 0x6a, 0x2c, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x20,
+ 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x73, 0x20, 0x6f, 0x62, 0x6a, 0x2e,
+ 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x54, 0x68, 0x65, 0x20, 0x70, 0x72,
+ 0x69, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x70, 0x75, 0x72, 0x70, 0x6f, 0x73,
+ 0x65, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x6d, 0x65,
+ 0x74, 0x68, 0x6f, 0x64, 0x20, 0x69, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x22,
+ 0x74, 0x61, 0x70, 0x20, 0x69, 0x6e, 0x74, 0x6f, 0x22, 0x20, 0x61, 0x20,
+ 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x20, 0x63, 0x68, 0x61, 0x69, 0x6e,
+ 0x2c, 0x20, 0x69, 0x6e, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x6f, 0x72,
+ 0x64, 0x65, 0x72, 0x20, 0x74, 0x6f, 0x20, 0x70, 0x65, 0x72, 0x66, 0x6f,
+ 0x72, 0x6d, 0x20, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e,
+ 0x73, 0x20, 0x6f, 0x6e, 0x20, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6d, 0x65,
+ 0x64, 0x69, 0x61, 0x74, 0x65, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74,
+ 0x73, 0x20, 0x77, 0x69, 0x74, 0x68, 0x69, 0x6e, 0x20, 0x74, 0x68, 0x65,
+ 0x20, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e,
+ 0x74, 0x61, 0x70, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69,
+ 0x6f, 0x6e, 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x69, 0x6e, 0x74, 0x65,
+ 0x72, 0x63, 0x65, 0x70, 0x74, 0x6f, 0x72, 0x29, 0x20, 0x7b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x65, 0x70, 0x74,
+ 0x6f, 0x72, 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6f, 0x62, 0x6a, 0x3b,
+ 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20,
+ 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x20, 0x72, 0x65, 0x63,
+ 0x75, 0x72, 0x73, 0x69, 0x76, 0x65, 0x20, 0x63, 0x6f, 0x6d, 0x70, 0x61,
+ 0x72, 0x69, 0x73, 0x6f, 0x6e, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69,
+ 0x6f, 0x6e, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x60, 0x69, 0x73, 0x45, 0x71,
+ 0x75, 0x61, 0x6c, 0x60, 0x2e, 0x0a, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20,
+ 0x65, 0x71, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f,
+ 0x6e, 0x28, 0x61, 0x2c, 0x20, 0x62, 0x2c, 0x20, 0x61, 0x53, 0x74, 0x61,
+ 0x63, 0x6b, 0x2c, 0x20, 0x62, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x29, 0x20,
+ 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x49, 0x64, 0x65,
+ 0x6e, 0x74, 0x69, 0x63, 0x61, 0x6c, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63,
+ 0x74, 0x73, 0x20, 0x61, 0x72, 0x65, 0x20, 0x65, 0x71, 0x75, 0x61, 0x6c,
+ 0x2e, 0x20, 0x60, 0x30, 0x20, 0x3d, 0x3d, 0x3d, 0x20, 0x2d, 0x30, 0x60,
+ 0x2c, 0x20, 0x62, 0x75, 0x74, 0x20, 0x74, 0x68, 0x65, 0x79, 0x20, 0x61,
+ 0x72, 0x65, 0x6e, 0x27, 0x74, 0x20, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69,
+ 0x63, 0x61, 0x6c, 0x2e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2f, 0x2f, 0x20,
+ 0x53, 0x65, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20, 0x48, 0x61, 0x72, 0x6d,
+ 0x6f, 0x6e, 0x79, 0x20, 0x60, 0x65, 0x67, 0x61, 0x6c, 0x60, 0x20, 0x70,
+ 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x3a, 0x20, 0x68, 0x74, 0x74,
+ 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x69, 0x6b, 0x69, 0x2e, 0x65, 0x63, 0x6d,
+ 0x61, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x2e, 0x6f, 0x72, 0x67, 0x2f,
+ 0x64, 0x6f, 0x6b, 0x75, 0x2e, 0x70, 0x68, 0x70, 0x3f, 0x69, 0x64, 0x3d,
+ 0x68, 0x61, 0x72, 0x6d, 0x6f, 0x6e, 0x79, 0x3a, 0x65, 0x67, 0x61, 0x6c,
+ 0x2e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x61, 0x20,
+ 0x3d, 0x3d, 0x3d, 0x20, 0x62, 0x29, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72,
+ 0x6e, 0x20, 0x61, 0x20, 0x21, 0x3d, 0x3d, 0x20, 0x30, 0x20, 0x7c, 0x7c,
+ 0x20, 0x31, 0x20, 0x2f, 0x20, 0x61, 0x20, 0x3d, 0x3d, 0x20, 0x31, 0x20,
+ 0x2f, 0x20, 0x62, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2f, 0x2f, 0x20,
+ 0x41, 0x20, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x20, 0x63, 0x6f, 0x6d,
+ 0x70, 0x61, 0x72, 0x69, 0x73, 0x6f, 0x6e, 0x20, 0x69, 0x73, 0x20, 0x6e,
+ 0x65, 0x63, 0x65, 0x73, 0x73, 0x61, 0x72, 0x79, 0x20, 0x62, 0x65, 0x63,
+ 0x61, 0x75, 0x73, 0x65, 0x20, 0x60, 0x6e, 0x75, 0x6c, 0x6c, 0x20, 0x3d,
+ 0x3d, 0x20, 0x75, 0x6e, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x64, 0x60,
+ 0x2e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x61, 0x20,
+ 0x3d, 0x3d, 0x20, 0x6e, 0x75, 0x6c, 0x6c, 0x20, 0x7c, 0x7c, 0x20, 0x62,
+ 0x20, 0x3d, 0x3d, 0x20, 0x6e, 0x75, 0x6c, 0x6c, 0x29, 0x20, 0x72, 0x65,
+ 0x74, 0x75, 0x72, 0x6e, 0x20, 0x61, 0x20, 0x3d, 0x3d, 0x3d, 0x20, 0x62,
+ 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x55, 0x6e, 0x77,
+ 0x72, 0x61, 0x70, 0x20, 0x61, 0x6e, 0x79, 0x20, 0x77, 0x72, 0x61, 0x70,
+ 0x70, 0x65, 0x64, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x2e,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x61, 0x20, 0x69,
+ 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x6f, 0x66, 0x20, 0x5f, 0x29,
+ 0x20, 0x61, 0x20, 0x3d, 0x20, 0x61, 0x2e, 0x5f, 0x77, 0x72, 0x61, 0x70,
+ 0x70, 0x65, 0x64, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20,
+ 0x28, 0x62, 0x20, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x6f,
+ 0x66, 0x20, 0x5f, 0x29, 0x20, 0x62, 0x20, 0x3d, 0x20, 0x62, 0x2e, 0x5f,
+ 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x64, 0x3b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x2f, 0x2f, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x72, 0x65, 0x20,
+ 0x60, 0x5b, 0x5b, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x5d, 0x5d, 0x60, 0x20,
+ 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x2e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76,
+ 0x61, 0x72, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x4e, 0x61, 0x6d, 0x65,
+ 0x20, 0x3d, 0x20, 0x74, 0x6f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2e,
+ 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x61, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x69, 0x66, 0x20, 0x28, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x4e, 0x61,
+ 0x6d, 0x65, 0x20, 0x21, 0x3d, 0x20, 0x74, 0x6f, 0x53, 0x74, 0x72, 0x69,
+ 0x6e, 0x67, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x62, 0x29, 0x29, 0x20,
+ 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x66, 0x61, 0x6c, 0x73, 0x65,
+ 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68,
+ 0x20, 0x28, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x4e, 0x61, 0x6d, 0x65, 0x29,
+ 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2f, 0x2f, 0x20,
+ 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x73, 0x2c, 0x20, 0x6e, 0x75, 0x6d,
+ 0x62, 0x65, 0x72, 0x73, 0x2c, 0x20, 0x64, 0x61, 0x74, 0x65, 0x73, 0x2c,
+ 0x20, 0x61, 0x6e, 0x64, 0x20, 0x62, 0x6f, 0x6f, 0x6c, 0x65, 0x61, 0x6e,
+ 0x73, 0x20, 0x61, 0x72, 0x65, 0x20, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x72,
+ 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2e,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x61, 0x73, 0x65, 0x20,
+ 0x27, 0x5b, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20, 0x53, 0x74, 0x72,
+ 0x69, 0x6e, 0x67, 0x5d, 0x27, 0x3a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x50, 0x72, 0x69, 0x6d, 0x69, 0x74,
+ 0x69, 0x76, 0x65, 0x73, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x74, 0x68, 0x65,
+ 0x69, 0x72, 0x20, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e,
+ 0x64, 0x69, 0x6e, 0x67, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20,
+ 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x20, 0x61, 0x72, 0x65,
+ 0x20, 0x65, 0x71, 0x75, 0x69, 0x76, 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x3b,
+ 0x20, 0x74, 0x68, 0x75, 0x73, 0x2c, 0x20, 0x60, 0x22, 0x35, 0x22, 0x60,
+ 0x20, 0x69, 0x73, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x2f, 0x2f, 0x20, 0x65, 0x71, 0x75, 0x69, 0x76, 0x61, 0x6c, 0x65, 0x6e,
+ 0x74, 0x20, 0x74, 0x6f, 0x20, 0x60, 0x6e, 0x65, 0x77, 0x20, 0x53, 0x74,
+ 0x72, 0x69, 0x6e, 0x67, 0x28, 0x22, 0x35, 0x22, 0x29, 0x60, 0x2e, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75,
+ 0x72, 0x6e, 0x20, 0x61, 0x20, 0x3d, 0x3d, 0x20, 0x53, 0x74, 0x72, 0x69,
+ 0x6e, 0x67, 0x28, 0x62, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x63, 0x61, 0x73, 0x65, 0x20, 0x27, 0x5b, 0x6f, 0x62, 0x6a, 0x65,
+ 0x63, 0x74, 0x20, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x5d, 0x27, 0x3a,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2f, 0x2f, 0x20,
+ 0x60, 0x4e, 0x61, 0x4e, 0x60, 0x73, 0x20, 0x61, 0x72, 0x65, 0x20, 0x65,
+ 0x71, 0x75, 0x69, 0x76, 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x2c, 0x20, 0x62,
+ 0x75, 0x74, 0x20, 0x6e, 0x6f, 0x6e, 0x2d, 0x72, 0x65, 0x66, 0x6c, 0x65,
+ 0x78, 0x69, 0x76, 0x65, 0x2e, 0x20, 0x41, 0x6e, 0x20, 0x60, 0x65, 0x67,
+ 0x61, 0x6c, 0x60, 0x20, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x72, 0x69, 0x73,
+ 0x6f, 0x6e, 0x20, 0x69, 0x73, 0x20, 0x70, 0x65, 0x72, 0x66, 0x6f, 0x72,
+ 0x6d, 0x65, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x6f, 0x74, 0x68, 0x65, 0x72,
+ 0x20, 0x6e, 0x75, 0x6d, 0x65, 0x72, 0x69, 0x63, 0x20, 0x76, 0x61, 0x6c,
+ 0x75, 0x65, 0x73, 0x2e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x61, 0x20, 0x21, 0x3d,
+ 0x20, 0x2b, 0x61, 0x20, 0x3f, 0x20, 0x62, 0x20, 0x21, 0x3d, 0x20, 0x2b,
+ 0x62, 0x20, 0x3a, 0x20, 0x28, 0x61, 0x20, 0x3d, 0x3d, 0x20, 0x30, 0x20,
+ 0x3f, 0x20, 0x31, 0x20, 0x2f, 0x20, 0x61, 0x20, 0x3d, 0x3d, 0x20, 0x31,
+ 0x20, 0x2f, 0x20, 0x62, 0x20, 0x3a, 0x20, 0x61, 0x20, 0x3d, 0x3d, 0x20,
+ 0x2b, 0x62, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63,
+ 0x61, 0x73, 0x65, 0x20, 0x27, 0x5b, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74,
+ 0x20, 0x44, 0x61, 0x74, 0x65, 0x5d, 0x27, 0x3a, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x63, 0x61, 0x73, 0x65, 0x20, 0x27, 0x5b, 0x6f, 0x62,
+ 0x6a, 0x65, 0x63, 0x74, 0x20, 0x42, 0x6f, 0x6f, 0x6c, 0x65, 0x61, 0x6e,
+ 0x5d, 0x27, 0x3a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x2f, 0x2f, 0x20, 0x43, 0x6f, 0x65, 0x72, 0x63, 0x65, 0x20, 0x64, 0x61,
+ 0x74, 0x65, 0x73, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x62, 0x6f, 0x6f, 0x6c,
+ 0x65, 0x61, 0x6e, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x6e, 0x75, 0x6d, 0x65,
+ 0x72, 0x69, 0x63, 0x20, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76,
+ 0x65, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x2e, 0x20, 0x44, 0x61,
+ 0x74, 0x65, 0x73, 0x20, 0x61, 0x72, 0x65, 0x20, 0x63, 0x6f, 0x6d, 0x70,
+ 0x61, 0x72, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x74, 0x68, 0x65, 0x69,
+ 0x72, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2f, 0x2f,
+ 0x20, 0x6d, 0x69, 0x6c, 0x6c, 0x69, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64,
+ 0x20, 0x72, 0x65, 0x70, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x74, 0x61, 0x74,
+ 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x20, 0x4e, 0x6f, 0x74, 0x65, 0x20, 0x74,
+ 0x68, 0x61, 0x74, 0x20, 0x69, 0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x20,
+ 0x64, 0x61, 0x74, 0x65, 0x73, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x6d,
+ 0x69, 0x6c, 0x6c, 0x69, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x20, 0x72,
+ 0x65, 0x70, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f,
+ 0x6e, 0x73, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2f,
+ 0x2f, 0x20, 0x6f, 0x66, 0x20, 0x60, 0x4e, 0x61, 0x4e, 0x60, 0x20, 0x61,
+ 0x72, 0x65, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x65, 0x71, 0x75, 0x69, 0x76,
+ 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x2e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x2b, 0x61,
+ 0x20, 0x3d, 0x3d, 0x20, 0x2b, 0x62, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x52, 0x65, 0x67, 0x45, 0x78, 0x70, 0x73,
+ 0x20, 0x61, 0x72, 0x65, 0x20, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x72, 0x65,
+ 0x64, 0x20, 0x62, 0x79, 0x20, 0x74, 0x68, 0x65, 0x69, 0x72, 0x20, 0x73,
+ 0x6f, 0x75, 0x72, 0x63, 0x65, 0x20, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72,
+ 0x6e, 0x73, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x66, 0x6c, 0x61, 0x67, 0x73,
+ 0x2e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x61, 0x73, 0x65,
+ 0x20, 0x27, 0x5b, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20, 0x52, 0x65,
+ 0x67, 0x45, 0x78, 0x70, 0x5d, 0x27, 0x3a, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x61,
+ 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x20, 0x3d, 0x3d, 0x20, 0x62,
+ 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x20, 0x26, 0x26, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x61, 0x2e, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x20, 0x3d,
+ 0x3d, 0x20, 0x62, 0x2e, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x20, 0x26,
+ 0x26, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x61, 0x2e, 0x6d, 0x75, 0x6c, 0x74, 0x69,
+ 0x6c, 0x69, 0x6e, 0x65, 0x20, 0x3d, 0x3d, 0x20, 0x62, 0x2e, 0x6d, 0x75,
+ 0x6c, 0x74, 0x69, 0x6c, 0x69, 0x6e, 0x65, 0x20, 0x26, 0x26, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x61, 0x2e, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x43, 0x61,
+ 0x73, 0x65, 0x20, 0x3d, 0x3d, 0x20, 0x62, 0x2e, 0x69, 0x67, 0x6e, 0x6f,
+ 0x72, 0x65, 0x43, 0x61, 0x73, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x74, 0x79,
+ 0x70, 0x65, 0x6f, 0x66, 0x20, 0x61, 0x20, 0x21, 0x3d, 0x20, 0x27, 0x6f,
+ 0x62, 0x6a, 0x65, 0x63, 0x74, 0x27, 0x20, 0x7c, 0x7c, 0x20, 0x74, 0x79,
+ 0x70, 0x65, 0x6f, 0x66, 0x20, 0x62, 0x20, 0x21, 0x3d, 0x20, 0x27, 0x6f,
+ 0x62, 0x6a, 0x65, 0x63, 0x74, 0x27, 0x29, 0x20, 0x72, 0x65, 0x74, 0x75,
+ 0x72, 0x6e, 0x20, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x3b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x41, 0x73, 0x73, 0x75, 0x6d, 0x65, 0x20,
+ 0x65, 0x71, 0x75, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x20, 0x66, 0x6f, 0x72,
+ 0x20, 0x63, 0x79, 0x63, 0x6c, 0x69, 0x63, 0x20, 0x73, 0x74, 0x72, 0x75,
+ 0x63, 0x74, 0x75, 0x72, 0x65, 0x73, 0x2e, 0x20, 0x54, 0x68, 0x65, 0x20,
+ 0x61, 0x6c, 0x67, 0x6f, 0x72, 0x69, 0x74, 0x68, 0x6d, 0x20, 0x66, 0x6f,
+ 0x72, 0x20, 0x64, 0x65, 0x74, 0x65, 0x63, 0x74, 0x69, 0x6e, 0x67, 0x20,
+ 0x63, 0x79, 0x63, 0x6c, 0x69, 0x63, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2f,
+ 0x2f, 0x20, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x75, 0x72, 0x65, 0x73,
+ 0x20, 0x69, 0x73, 0x20, 0x61, 0x64, 0x61, 0x70, 0x74, 0x65, 0x64, 0x20,
+ 0x66, 0x72, 0x6f, 0x6d, 0x20, 0x45, 0x53, 0x20, 0x35, 0x2e, 0x31, 0x20,
+ 0x73, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x31, 0x35, 0x2e, 0x31,
+ 0x32, 0x2e, 0x33, 0x2c, 0x20, 0x61, 0x62, 0x73, 0x74, 0x72, 0x61, 0x63,
+ 0x74, 0x20, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20,
+ 0x60, 0x4a, 0x4f, 0x60, 0x2e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61,
+ 0x72, 0x20, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x20, 0x3d, 0x20, 0x61,
+ 0x53, 0x74, 0x61, 0x63, 0x6b, 0x2e, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68,
+ 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x20,
+ 0x28, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x2d, 0x2d, 0x29, 0x20, 0x7b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x4c, 0x69,
+ 0x6e, 0x65, 0x61, 0x72, 0x20, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x2e,
+ 0x20, 0x50, 0x65, 0x72, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65,
+ 0x20, 0x69, 0x73, 0x20, 0x69, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x65, 0x6c,
+ 0x79, 0x20, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6f, 0x6e,
+ 0x61, 0x6c, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6e, 0x75,
+ 0x6d, 0x62, 0x65, 0x72, 0x20, 0x6f, 0x66, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x20,
+ 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x20, 0x73, 0x74, 0x72, 0x75, 0x63,
+ 0x74, 0x75, 0x72, 0x65, 0x73, 0x2e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x69, 0x66, 0x20, 0x28, 0x61, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x5b,
+ 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x5d, 0x20, 0x3d, 0x3d, 0x20, 0x61,
+ 0x29, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x62, 0x53, 0x74,
+ 0x61, 0x63, 0x6b, 0x5b, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x5d, 0x20,
+ 0x3d, 0x3d, 0x20, 0x62, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x41, 0x64, 0x64, 0x20, 0x74,
+ 0x68, 0x65, 0x20, 0x66, 0x69, 0x72, 0x73, 0x74, 0x20, 0x6f, 0x62, 0x6a,
+ 0x65, 0x63, 0x74, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73,
+ 0x74, 0x61, 0x63, 0x6b, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x72, 0x61, 0x76,
+ 0x65, 0x72, 0x73, 0x65, 0x64, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74,
+ 0x73, 0x2e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x61, 0x53, 0x74, 0x61, 0x63,
+ 0x6b, 0x2e, 0x70, 0x75, 0x73, 0x68, 0x28, 0x61, 0x29, 0x3b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x62, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x2e, 0x70, 0x75,
+ 0x73, 0x68, 0x28, 0x62, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76,
+ 0x61, 0x72, 0x20, 0x73, 0x69, 0x7a, 0x65, 0x20, 0x3d, 0x20, 0x30, 0x2c,
+ 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x20, 0x3d, 0x20, 0x74, 0x72,
+ 0x75, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x52,
+ 0x65, 0x63, 0x75, 0x72, 0x73, 0x69, 0x76, 0x65, 0x6c, 0x79, 0x20, 0x63,
+ 0x6f, 0x6d, 0x70, 0x61, 0x72, 0x65, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63,
+ 0x74, 0x73, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x61, 0x72, 0x72, 0x61, 0x79,
+ 0x73, 0x2e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x63,
+ 0x6c, 0x61, 0x73, 0x73, 0x4e, 0x61, 0x6d, 0x65, 0x20, 0x3d, 0x3d, 0x20,
+ 0x27, 0x5b, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20, 0x41, 0x72, 0x72,
+ 0x61, 0x79, 0x5d, 0x27, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x72, 0x65,
+ 0x20, 0x61, 0x72, 0x72, 0x61, 0x79, 0x20, 0x6c, 0x65, 0x6e, 0x67, 0x74,
+ 0x68, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x64, 0x65, 0x74, 0x65, 0x72, 0x6d,
+ 0x69, 0x6e, 0x65, 0x20, 0x69, 0x66, 0x20, 0x61, 0x20, 0x64, 0x65, 0x65,
+ 0x70, 0x20, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x72, 0x69, 0x73, 0x6f, 0x6e,
+ 0x20, 0x69, 0x73, 0x20, 0x6e, 0x65, 0x63, 0x65, 0x73, 0x73, 0x61, 0x72,
+ 0x79, 0x2e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x73, 0x69, 0x7a,
+ 0x65, 0x20, 0x3d, 0x20, 0x61, 0x2e, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68,
+ 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x73, 0x75,
+ 0x6c, 0x74, 0x20, 0x3d, 0x20, 0x73, 0x69, 0x7a, 0x65, 0x20, 0x3d, 0x3d,
+ 0x20, 0x62, 0x2e, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x3b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x72, 0x65, 0x73,
+ 0x75, 0x6c, 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x44, 0x65, 0x65, 0x70, 0x20, 0x63,
+ 0x6f, 0x6d, 0x70, 0x61, 0x72, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63,
+ 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x2c, 0x20, 0x69, 0x67, 0x6e,
+ 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x20, 0x6e, 0x6f, 0x6e, 0x2d, 0x6e, 0x75,
+ 0x6d, 0x65, 0x72, 0x69, 0x63, 0x20, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72,
+ 0x74, 0x69, 0x65, 0x73, 0x2e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x20, 0x28, 0x73, 0x69, 0x7a,
+ 0x65, 0x2d, 0x2d, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x21, 0x28, 0x72,
+ 0x65, 0x73, 0x75, 0x6c, 0x74, 0x20, 0x3d, 0x20, 0x65, 0x71, 0x28, 0x61,
+ 0x5b, 0x73, 0x69, 0x7a, 0x65, 0x5d, 0x2c, 0x20, 0x62, 0x5b, 0x73, 0x69,
+ 0x7a, 0x65, 0x5d, 0x2c, 0x20, 0x61, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x2c,
+ 0x20, 0x62, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x29, 0x29, 0x29, 0x20, 0x62,
+ 0x72, 0x65, 0x61, 0x6b, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x20, 0x7b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x4f, 0x62,
+ 0x6a, 0x65, 0x63, 0x74, 0x73, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x64,
+ 0x69, 0x66, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x74, 0x20, 0x63, 0x6f, 0x6e,
+ 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x6f, 0x72, 0x73, 0x20, 0x61, 0x72,
+ 0x65, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x65, 0x71, 0x75, 0x69, 0x76, 0x61,
+ 0x6c, 0x65, 0x6e, 0x74, 0x2c, 0x20, 0x62, 0x75, 0x74, 0x20, 0x60, 0x4f,
+ 0x62, 0x6a, 0x65, 0x63, 0x74, 0x60, 0x73, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x66, 0x72, 0x6f, 0x6d, 0x20, 0x64, 0x69,
+ 0x66, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x74, 0x20, 0x66, 0x72, 0x61, 0x6d,
+ 0x65, 0x73, 0x20, 0x61, 0x72, 0x65, 0x2e, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x61, 0x43, 0x74, 0x6f, 0x72, 0x20,
+ 0x3d, 0x20, 0x61, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x75, 0x63,
+ 0x74, 0x6f, 0x72, 0x2c, 0x20, 0x62, 0x43, 0x74, 0x6f, 0x72, 0x20, 0x3d,
+ 0x20, 0x62, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74,
+ 0x6f, 0x72, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66,
+ 0x20, 0x28, 0x61, 0x43, 0x74, 0x6f, 0x72, 0x20, 0x21, 0x3d, 0x3d, 0x20,
+ 0x62, 0x43, 0x74, 0x6f, 0x72, 0x20, 0x26, 0x26, 0x20, 0x21, 0x28, 0x5f,
+ 0x2e, 0x69, 0x73, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28,
+ 0x61, 0x43, 0x74, 0x6f, 0x72, 0x29, 0x20, 0x26, 0x26, 0x20, 0x28, 0x61,
+ 0x43, 0x74, 0x6f, 0x72, 0x20, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63,
+ 0x65, 0x6f, 0x66, 0x20, 0x61, 0x43, 0x74, 0x6f, 0x72, 0x29, 0x20, 0x26,
+ 0x26, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x2e, 0x69,
+ 0x73, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x62, 0x43,
+ 0x74, 0x6f, 0x72, 0x29, 0x20, 0x26, 0x26, 0x20, 0x28, 0x62, 0x43, 0x74,
+ 0x6f, 0x72, 0x20, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x6f,
+ 0x66, 0x20, 0x62, 0x43, 0x74, 0x6f, 0x72, 0x29, 0x29, 0x29, 0x20, 0x7b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74,
+ 0x75, 0x72, 0x6e, 0x20, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x3b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x2f, 0x2f, 0x20, 0x44, 0x65, 0x65, 0x70, 0x20, 0x63, 0x6f, 0x6d,
+ 0x70, 0x61, 0x72, 0x65, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73,
+ 0x2e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x72, 0x20,
+ 0x28, 0x76, 0x61, 0x72, 0x20, 0x6b, 0x65, 0x79, 0x20, 0x69, 0x6e, 0x20,
+ 0x61, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x69, 0x66, 0x20, 0x28, 0x5f, 0x2e, 0x68, 0x61, 0x73, 0x28, 0x61,
+ 0x2c, 0x20, 0x6b, 0x65, 0x79, 0x29, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x43,
+ 0x6f, 0x75, 0x6e, 0x74, 0x20, 0x74, 0x68, 0x65, 0x20, 0x65, 0x78, 0x70,
+ 0x65, 0x63, 0x74, 0x65, 0x64, 0x20, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72,
+ 0x20, 0x6f, 0x66, 0x20, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69,
+ 0x65, 0x73, 0x2e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x73, 0x69, 0x7a, 0x65, 0x2b, 0x2b, 0x3b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x44,
+ 0x65, 0x65, 0x70, 0x20, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x72, 0x65, 0x20,
+ 0x65, 0x61, 0x63, 0x68, 0x20, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x2e,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69,
+ 0x66, 0x20, 0x28, 0x21, 0x28, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x20,
+ 0x3d, 0x20, 0x5f, 0x2e, 0x68, 0x61, 0x73, 0x28, 0x62, 0x2c, 0x20, 0x6b,
+ 0x65, 0x79, 0x29, 0x20, 0x26, 0x26, 0x20, 0x65, 0x71, 0x28, 0x61, 0x5b,
+ 0x6b, 0x65, 0x79, 0x5d, 0x2c, 0x20, 0x62, 0x5b, 0x6b, 0x65, 0x79, 0x5d,
+ 0x2c, 0x20, 0x61, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x2c, 0x20, 0x62, 0x53,
+ 0x74, 0x61, 0x63, 0x6b, 0x29, 0x29, 0x29, 0x20, 0x62, 0x72, 0x65, 0x61,
+ 0x6b, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x45, 0x6e, 0x73, 0x75, 0x72, 0x65,
+ 0x20, 0x74, 0x68, 0x61, 0x74, 0x20, 0x62, 0x6f, 0x74, 0x68, 0x20, 0x6f,
+ 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x61,
+ 0x69, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x61, 0x6d, 0x65, 0x20,
+ 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x20, 0x6f, 0x66, 0x20, 0x70, 0x72,
+ 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x2e, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x72, 0x65, 0x73, 0x75,
+ 0x6c, 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x28, 0x6b, 0x65, 0x79, 0x20, 0x69,
+ 0x6e, 0x20, 0x62, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x5f, 0x2e, 0x68,
+ 0x61, 0x73, 0x28, 0x62, 0x2c, 0x20, 0x6b, 0x65, 0x79, 0x29, 0x20, 0x26,
+ 0x26, 0x20, 0x21, 0x28, 0x73, 0x69, 0x7a, 0x65, 0x2d, 0x2d, 0x29, 0x29,
+ 0x20, 0x62, 0x72, 0x65, 0x61, 0x6b, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x20, 0x3d, 0x20, 0x21,
+ 0x73, 0x69, 0x7a, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x2f, 0x2f, 0x20, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x20, 0x74, 0x68,
+ 0x65, 0x20, 0x66, 0x69, 0x72, 0x73, 0x74, 0x20, 0x6f, 0x62, 0x6a, 0x65,
+ 0x63, 0x74, 0x20, 0x66, 0x72, 0x6f, 0x6d, 0x20, 0x74, 0x68, 0x65, 0x20,
+ 0x73, 0x74, 0x61, 0x63, 0x6b, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x72, 0x61,
+ 0x76, 0x65, 0x72, 0x73, 0x65, 0x64, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63,
+ 0x74, 0x73, 0x2e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x61, 0x53, 0x74, 0x61,
+ 0x63, 0x6b, 0x2e, 0x70, 0x6f, 0x70, 0x28, 0x29, 0x3b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x62, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x2e, 0x70, 0x6f, 0x70,
+ 0x28, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75,
+ 0x72, 0x6e, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x3b, 0x0a, 0x20,
+ 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x50, 0x65,
+ 0x72, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x61, 0x20, 0x64, 0x65, 0x65, 0x70,
+ 0x20, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x72, 0x69, 0x73, 0x6f, 0x6e, 0x20,
+ 0x74, 0x6f, 0x20, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x20, 0x69, 0x66, 0x20,
+ 0x74, 0x77, 0x6f, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x20,
+ 0x61, 0x72, 0x65, 0x20, 0x65, 0x71, 0x75, 0x61, 0x6c, 0x2e, 0x0a, 0x20,
+ 0x20, 0x5f, 0x2e, 0x69, 0x73, 0x45, 0x71, 0x75, 0x61, 0x6c, 0x20, 0x3d,
+ 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x61, 0x2c,
+ 0x20, 0x62, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65,
+ 0x74, 0x75, 0x72, 0x6e, 0x20, 0x65, 0x71, 0x28, 0x61, 0x2c, 0x20, 0x62,
+ 0x2c, 0x20, 0x5b, 0x5d, 0x2c, 0x20, 0x5b, 0x5d, 0x29, 0x3b, 0x0a, 0x20,
+ 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x49, 0x73,
+ 0x20, 0x61, 0x20, 0x67, 0x69, 0x76, 0x65, 0x6e, 0x20, 0x61, 0x72, 0x72,
+ 0x61, 0x79, 0x2c, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2c, 0x20,
+ 0x6f, 0x72, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20, 0x65, 0x6d,
+ 0x70, 0x74, 0x79, 0x3f, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x41, 0x6e,
+ 0x20, 0x22, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x20, 0x6f, 0x62, 0x6a,
+ 0x65, 0x63, 0x74, 0x20, 0x68, 0x61, 0x73, 0x20, 0x6e, 0x6f, 0x20, 0x65,
+ 0x6e, 0x75, 0x6d, 0x65, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x6f, 0x77,
+ 0x6e, 0x2d, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73,
+ 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x69, 0x73, 0x45, 0x6d, 0x70, 0x74,
+ 0x79, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
+ 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x69, 0x66, 0x20, 0x28, 0x6f, 0x62, 0x6a, 0x20, 0x3d, 0x3d, 0x20, 0x6e,
+ 0x75, 0x6c, 0x6c, 0x29, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20,
+ 0x74, 0x72, 0x75, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66,
+ 0x20, 0x28, 0x5f, 0x2e, 0x69, 0x73, 0x41, 0x72, 0x72, 0x61, 0x79, 0x28,
+ 0x6f, 0x62, 0x6a, 0x29, 0x20, 0x7c, 0x7c, 0x20, 0x5f, 0x2e, 0x69, 0x73,
+ 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x29,
+ 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6f, 0x62, 0x6a, 0x2e,
+ 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x20, 0x3d, 0x3d, 0x3d, 0x20, 0x30,
+ 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x28, 0x76,
+ 0x61, 0x72, 0x20, 0x6b, 0x65, 0x79, 0x20, 0x69, 0x6e, 0x20, 0x6f, 0x62,
+ 0x6a, 0x29, 0x20, 0x69, 0x66, 0x20, 0x28, 0x5f, 0x2e, 0x68, 0x61, 0x73,
+ 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x6b, 0x65, 0x79, 0x29, 0x29, 0x20,
+ 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x66, 0x61, 0x6c, 0x73, 0x65,
+ 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,
+ 0x20, 0x74, 0x72, 0x75, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a,
+ 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x49, 0x73, 0x20, 0x61, 0x20, 0x67,
+ 0x69, 0x76, 0x65, 0x6e, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x20, 0x61,
+ 0x20, 0x44, 0x4f, 0x4d, 0x20, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74,
+ 0x3f, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x69, 0x73, 0x45, 0x6c, 0x65, 0x6d,
+ 0x65, 0x6e, 0x74, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69,
+ 0x6f, 0x6e, 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x21, 0x21, 0x28,
+ 0x6f, 0x62, 0x6a, 0x20, 0x26, 0x26, 0x20, 0x6f, 0x62, 0x6a, 0x2e, 0x6e,
+ 0x6f, 0x64, 0x65, 0x54, 0x79, 0x70, 0x65, 0x20, 0x3d, 0x3d, 0x3d, 0x20,
+ 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20,
+ 0x2f, 0x2f, 0x20, 0x49, 0x73, 0x20, 0x61, 0x20, 0x67, 0x69, 0x76, 0x65,
+ 0x6e, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x20, 0x61, 0x6e, 0x20, 0x61,
+ 0x72, 0x72, 0x61, 0x79, 0x3f, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x44,
+ 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x65, 0x73, 0x20, 0x74, 0x6f, 0x20,
+ 0x45, 0x43, 0x4d, 0x41, 0x35, 0x27, 0x73, 0x20, 0x6e, 0x61, 0x74, 0x69,
+ 0x76, 0x65, 0x20, 0x41, 0x72, 0x72, 0x61, 0x79, 0x2e, 0x69, 0x73, 0x41,
+ 0x72, 0x72, 0x61, 0x79, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x69, 0x73, 0x41,
+ 0x72, 0x72, 0x61, 0x79, 0x20, 0x3d, 0x20, 0x6e, 0x61, 0x74, 0x69, 0x76,
+ 0x65, 0x49, 0x73, 0x41, 0x72, 0x72, 0x61, 0x79, 0x20, 0x7c, 0x7c, 0x20,
+ 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6f, 0x62, 0x6a,
+ 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75,
+ 0x72, 0x6e, 0x20, 0x74, 0x6f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2e,
+ 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x20, 0x3d, 0x3d,
+ 0x20, 0x27, 0x5b, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20, 0x41, 0x72,
+ 0x72, 0x61, 0x79, 0x5d, 0x27, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a,
+ 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x49, 0x73, 0x20, 0x61, 0x20, 0x67,
+ 0x69, 0x76, 0x65, 0x6e, 0x20, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c,
+ 0x65, 0x20, 0x61, 0x6e, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x3f,
+ 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x69, 0x73, 0x4f, 0x62, 0x6a, 0x65, 0x63,
+ 0x74, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
+ 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6f, 0x62, 0x6a, 0x20, 0x3d,
+ 0x3d, 0x3d, 0x20, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x28, 0x6f, 0x62,
+ 0x6a, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20,
+ 0x2f, 0x2f, 0x20, 0x41, 0x64, 0x64, 0x20, 0x73, 0x6f, 0x6d, 0x65, 0x20,
+ 0x69, 0x73, 0x54, 0x79, 0x70, 0x65, 0x20, 0x6d, 0x65, 0x74, 0x68, 0x6f,
+ 0x64, 0x73, 0x3a, 0x20, 0x69, 0x73, 0x41, 0x72, 0x67, 0x75, 0x6d, 0x65,
+ 0x6e, 0x74, 0x73, 0x2c, 0x20, 0x69, 0x73, 0x46, 0x75, 0x6e, 0x63, 0x74,
+ 0x69, 0x6f, 0x6e, 0x2c, 0x20, 0x69, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e,
+ 0x67, 0x2c, 0x20, 0x69, 0x73, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x2c,
+ 0x20, 0x69, 0x73, 0x44, 0x61, 0x74, 0x65, 0x2c, 0x20, 0x69, 0x73, 0x52,
+ 0x65, 0x67, 0x45, 0x78, 0x70, 0x2e, 0x0a, 0x20, 0x20, 0x65, 0x61, 0x63,
+ 0x68, 0x28, 0x5b, 0x27, 0x41, 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74,
+ 0x73, 0x27, 0x2c, 0x20, 0x27, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f,
+ 0x6e, 0x27, 0x2c, 0x20, 0x27, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x27,
+ 0x2c, 0x20, 0x27, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x27, 0x2c, 0x20,
+ 0x27, 0x44, 0x61, 0x74, 0x65, 0x27, 0x2c, 0x20, 0x27, 0x52, 0x65, 0x67,
+ 0x45, 0x78, 0x70, 0x27, 0x5d, 0x2c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74,
+ 0x69, 0x6f, 0x6e, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x29, 0x20, 0x7b, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x5f, 0x5b, 0x27, 0x69, 0x73, 0x27, 0x20, 0x2b,
+ 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x5d, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e,
+ 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x20, 0x7b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72,
+ 0x6e, 0x20, 0x74, 0x6f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x63,
+ 0x61, 0x6c, 0x6c, 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x20, 0x3d, 0x3d, 0x20,
+ 0x27, 0x5b, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20, 0x27, 0x20, 0x2b,
+ 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x20, 0x2b, 0x20, 0x27, 0x5d, 0x27, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x29,
+ 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x44, 0x65, 0x66, 0x69,
+ 0x6e, 0x65, 0x20, 0x61, 0x20, 0x66, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63,
+ 0x6b, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x66,
+ 0x20, 0x74, 0x68, 0x65, 0x20, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x20,
+ 0x69, 0x6e, 0x20, 0x62, 0x72, 0x6f, 0x77, 0x73, 0x65, 0x72, 0x73, 0x20,
+ 0x28, 0x61, 0x68, 0x65, 0x6d, 0x2c, 0x20, 0x49, 0x45, 0x29, 0x2c, 0x20,
+ 0x77, 0x68, 0x65, 0x72, 0x65, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x74,
+ 0x68, 0x65, 0x72, 0x65, 0x20, 0x69, 0x73, 0x6e, 0x27, 0x74, 0x20, 0x61,
+ 0x6e, 0x79, 0x20, 0x69, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x61, 0x62,
+ 0x6c, 0x65, 0x20, 0x22, 0x41, 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74,
+ 0x73, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x0a, 0x20, 0x20, 0x69,
+ 0x66, 0x20, 0x28, 0x21, 0x5f, 0x2e, 0x69, 0x73, 0x41, 0x72, 0x67, 0x75,
+ 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x28, 0x61, 0x72, 0x67, 0x75, 0x6d, 0x65,
+ 0x6e, 0x74, 0x73, 0x29, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x5f, 0x2e, 0x69, 0x73, 0x41, 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74,
+ 0x73, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
+ 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x21, 0x21, 0x28,
+ 0x6f, 0x62, 0x6a, 0x20, 0x26, 0x26, 0x20, 0x5f, 0x2e, 0x68, 0x61, 0x73,
+ 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x27, 0x63, 0x61, 0x6c, 0x6c, 0x65,
+ 0x65, 0x27, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x3b,
+ 0x0a, 0x20, 0x20, 0x7d, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x4f,
+ 0x70, 0x74, 0x69, 0x6d, 0x69, 0x7a, 0x65, 0x20, 0x60, 0x69, 0x73, 0x46,
+ 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x60, 0x20, 0x69, 0x66, 0x20,
+ 0x61, 0x70, 0x70, 0x72, 0x6f, 0x70, 0x72, 0x69, 0x61, 0x74, 0x65, 0x2e,
+ 0x0a, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x74, 0x79, 0x70, 0x65, 0x6f,
+ 0x66, 0x20, 0x28, 0x2f, 0x2e, 0x2f, 0x29, 0x20, 0x21, 0x3d, 0x3d, 0x20,
+ 0x27, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x27, 0x29, 0x20,
+ 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x2e, 0x69, 0x73, 0x46, 0x75,
+ 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e,
+ 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x20, 0x7b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72,
+ 0x6e, 0x20, 0x74, 0x79, 0x70, 0x65, 0x6f, 0x66, 0x20, 0x6f, 0x62, 0x6a,
+ 0x20, 0x3d, 0x3d, 0x3d, 0x20, 0x27, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69,
+ 0x6f, 0x6e, 0x27, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x3b, 0x0a,
+ 0x20, 0x20, 0x7d, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x49, 0x73,
+ 0x20, 0x61, 0x20, 0x67, 0x69, 0x76, 0x65, 0x6e, 0x20, 0x6f, 0x62, 0x6a,
+ 0x65, 0x63, 0x74, 0x20, 0x61, 0x20, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x65,
+ 0x20, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x3f, 0x0a, 0x20, 0x20, 0x5f,
+ 0x2e, 0x69, 0x73, 0x46, 0x69, 0x6e, 0x69, 0x74, 0x65, 0x20, 0x3d, 0x20,
+ 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6f, 0x62, 0x6a,
+ 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75,
+ 0x72, 0x6e, 0x20, 0x69, 0x73, 0x46, 0x69, 0x6e, 0x69, 0x74, 0x65, 0x28,
+ 0x6f, 0x62, 0x6a, 0x29, 0x20, 0x26, 0x26, 0x20, 0x21, 0x69, 0x73, 0x4e,
+ 0x61, 0x4e, 0x28, 0x70, 0x61, 0x72, 0x73, 0x65, 0x46, 0x6c, 0x6f, 0x61,
+ 0x74, 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x7d,
+ 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x49, 0x73, 0x20, 0x74,
+ 0x68, 0x65, 0x20, 0x67, 0x69, 0x76, 0x65, 0x6e, 0x20, 0x76, 0x61, 0x6c,
+ 0x75, 0x65, 0x20, 0x60, 0x4e, 0x61, 0x4e, 0x60, 0x3f, 0x20, 0x28, 0x4e,
+ 0x61, 0x4e, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6f, 0x6e,
+ 0x6c, 0x79, 0x20, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x20, 0x77, 0x68,
+ 0x69, 0x63, 0x68, 0x20, 0x64, 0x6f, 0x65, 0x73, 0x20, 0x6e, 0x6f, 0x74,
+ 0x20, 0x65, 0x71, 0x75, 0x61, 0x6c, 0x20, 0x69, 0x74, 0x73, 0x65, 0x6c,
+ 0x66, 0x29, 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x69, 0x73, 0x4e, 0x61,
+ 0x4e, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
+ 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x2e, 0x69, 0x73, 0x4e,
+ 0x75, 0x6d, 0x62, 0x65, 0x72, 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x20, 0x26,
+ 0x26, 0x20, 0x6f, 0x62, 0x6a, 0x20, 0x21, 0x3d, 0x20, 0x2b, 0x6f, 0x62,
+ 0x6a, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f,
+ 0x2f, 0x20, 0x49, 0x73, 0x20, 0x61, 0x20, 0x67, 0x69, 0x76, 0x65, 0x6e,
+ 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x20, 0x61, 0x20, 0x62, 0x6f, 0x6f,
+ 0x6c, 0x65, 0x61, 0x6e, 0x3f, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x69, 0x73,
+ 0x42, 0x6f, 0x6f, 0x6c, 0x65, 0x61, 0x6e, 0x20, 0x3d, 0x20, 0x66, 0x75,
+ 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x20,
+ 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,
+ 0x20, 0x6f, 0x62, 0x6a, 0x20, 0x3d, 0x3d, 0x3d, 0x20, 0x74, 0x72, 0x75,
+ 0x65, 0x20, 0x7c, 0x7c, 0x20, 0x6f, 0x62, 0x6a, 0x20, 0x3d, 0x3d, 0x3d,
+ 0x20, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x20, 0x7c, 0x7c, 0x20, 0x74, 0x6f,
+ 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28,
+ 0x6f, 0x62, 0x6a, 0x29, 0x20, 0x3d, 0x3d, 0x20, 0x27, 0x5b, 0x6f, 0x62,
+ 0x6a, 0x65, 0x63, 0x74, 0x20, 0x42, 0x6f, 0x6f, 0x6c, 0x65, 0x61, 0x6e,
+ 0x5d, 0x27, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20,
+ 0x2f, 0x2f, 0x20, 0x49, 0x73, 0x20, 0x61, 0x20, 0x67, 0x69, 0x76, 0x65,
+ 0x6e, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x20, 0x65, 0x71, 0x75, 0x61,
+ 0x6c, 0x20, 0x74, 0x6f, 0x20, 0x6e, 0x75, 0x6c, 0x6c, 0x3f, 0x0a, 0x20,
+ 0x20, 0x5f, 0x2e, 0x69, 0x73, 0x4e, 0x75, 0x6c, 0x6c, 0x20, 0x3d, 0x20,
+ 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6f, 0x62, 0x6a,
+ 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75,
+ 0x72, 0x6e, 0x20, 0x6f, 0x62, 0x6a, 0x20, 0x3d, 0x3d, 0x3d, 0x20, 0x6e,
+ 0x75, 0x6c, 0x6c, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20,
+ 0x20, 0x2f, 0x2f, 0x20, 0x49, 0x73, 0x20, 0x61, 0x20, 0x67, 0x69, 0x76,
+ 0x65, 0x6e, 0x20, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x20,
+ 0x75, 0x6e, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x64, 0x3f, 0x0a, 0x20,
+ 0x20, 0x5f, 0x2e, 0x69, 0x73, 0x55, 0x6e, 0x64, 0x65, 0x66, 0x69, 0x6e,
+ 0x65, 0x64, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f,
+ 0x6e, 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6f, 0x62, 0x6a, 0x20,
+ 0x3d, 0x3d, 0x3d, 0x20, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x30, 0x3b, 0x0a,
+ 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x53,
+ 0x68, 0x6f, 0x72, 0x74, 0x63, 0x75, 0x74, 0x20, 0x66, 0x75, 0x6e, 0x63,
+ 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x63, 0x68, 0x65,
+ 0x63, 0x6b, 0x69, 0x6e, 0x67, 0x20, 0x69, 0x66, 0x20, 0x61, 0x6e, 0x20,
+ 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20, 0x68, 0x61, 0x73, 0x20, 0x61,
+ 0x20, 0x67, 0x69, 0x76, 0x65, 0x6e, 0x20, 0x70, 0x72, 0x6f, 0x70, 0x65,
+ 0x72, 0x74, 0x79, 0x20, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6c, 0x79,
+ 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x6f, 0x6e, 0x20, 0x69, 0x74, 0x73,
+ 0x65, 0x6c, 0x66, 0x20, 0x28, 0x69, 0x6e, 0x20, 0x6f, 0x74, 0x68, 0x65,
+ 0x72, 0x20, 0x77, 0x6f, 0x72, 0x64, 0x73, 0x2c, 0x20, 0x6e, 0x6f, 0x74,
+ 0x20, 0x6f, 0x6e, 0x20, 0x61, 0x20, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x74,
+ 0x79, 0x70, 0x65, 0x29, 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x68, 0x61,
+ 0x73, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
+ 0x28, 0x6f, 0x62, 0x6a, 0x2c, 0x20, 0x6b, 0x65, 0x79, 0x29, 0x20, 0x7b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20,
+ 0x68, 0x61, 0x73, 0x4f, 0x77, 0x6e, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72,
+ 0x74, 0x79, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x6f, 0x62, 0x6a, 0x2c,
+ 0x20, 0x6b, 0x65, 0x79, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a,
+ 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x55, 0x74, 0x69, 0x6c, 0x69, 0x74,
+ 0x79, 0x20, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x0a,
+ 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
+ 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x0a,
+ 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x52, 0x75, 0x6e, 0x20, 0x55, 0x6e, 0x64,
+ 0x65, 0x72, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x6a, 0x73, 0x20, 0x69,
+ 0x6e, 0x20, 0x2a, 0x6e, 0x6f, 0x43, 0x6f, 0x6e, 0x66, 0x6c, 0x69, 0x63,
+ 0x74, 0x2a, 0x20, 0x6d, 0x6f, 0x64, 0x65, 0x2c, 0x20, 0x72, 0x65, 0x74,
+ 0x75, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x20, 0x74, 0x68, 0x65, 0x20, 0x60,
+ 0x5f, 0x60, 0x20, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x20,
+ 0x74, 0x6f, 0x20, 0x69, 0x74, 0x73, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20,
+ 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x20, 0x6f, 0x77, 0x6e,
+ 0x65, 0x72, 0x2e, 0x20, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x73, 0x20,
+ 0x61, 0x20, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x20,
+ 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x55, 0x6e, 0x64, 0x65, 0x72,
+ 0x73, 0x63, 0x6f, 0x72, 0x65, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74,
+ 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x6e, 0x6f, 0x43, 0x6f, 0x6e, 0x66,
+ 0x6c, 0x69, 0x63, 0x74, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74,
+ 0x69, 0x6f, 0x6e, 0x28, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x72, 0x6f, 0x6f, 0x74, 0x2e, 0x5f, 0x20, 0x3d, 0x20, 0x70, 0x72, 0x65,
+ 0x76, 0x69, 0x6f, 0x75, 0x73, 0x55, 0x6e, 0x64, 0x65, 0x72, 0x73, 0x63,
+ 0x6f, 0x72, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74,
+ 0x75, 0x72, 0x6e, 0x20, 0x74, 0x68, 0x69, 0x73, 0x3b, 0x0a, 0x20, 0x20,
+ 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x4b, 0x65, 0x65,
+ 0x70, 0x20, 0x74, 0x68, 0x65, 0x20, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69,
+ 0x74, 0x79, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20,
+ 0x61, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x64,
+ 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x20, 0x69, 0x74, 0x65, 0x72, 0x61,
+ 0x74, 0x6f, 0x72, 0x73, 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x69, 0x64,
+ 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e,
+ 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x29,
+ 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72,
+ 0x6e, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x7d,
+ 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x52, 0x75, 0x6e, 0x20,
+ 0x61, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x2a,
+ 0x2a, 0x6e, 0x2a, 0x2a, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x2e, 0x0a,
+ 0x20, 0x20, 0x5f, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x20, 0x3d, 0x20,
+ 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6e, 0x2c, 0x20,
+ 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x2c, 0x20, 0x63, 0x6f,
+ 0x6e, 0x74, 0x65, 0x78, 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x76, 0x61, 0x72, 0x20, 0x61, 0x63, 0x63, 0x75, 0x6d, 0x20, 0x3d,
+ 0x20, 0x41, 0x72, 0x72, 0x61, 0x79, 0x28, 0x6e, 0x29, 0x3b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x28, 0x76, 0x61, 0x72, 0x20,
+ 0x69, 0x20, 0x3d, 0x20, 0x30, 0x3b, 0x20, 0x69, 0x20, 0x3c, 0x20, 0x6e,
+ 0x3b, 0x20, 0x69, 0x2b, 0x2b, 0x29, 0x20, 0x61, 0x63, 0x63, 0x75, 0x6d,
+ 0x5b, 0x69, 0x5d, 0x20, 0x3d, 0x20, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74,
+ 0x6f, 0x72, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x63, 0x6f, 0x6e, 0x74,
+ 0x65, 0x78, 0x74, 0x2c, 0x20, 0x69, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x61, 0x63, 0x63, 0x75,
+ 0x6d, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f,
+ 0x2f, 0x20, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x61, 0x20, 0x72,
+ 0x61, 0x6e, 0x64, 0x6f, 0x6d, 0x20, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65,
+ 0x72, 0x20, 0x62, 0x65, 0x74, 0x77, 0x65, 0x65, 0x6e, 0x20, 0x6d, 0x69,
+ 0x6e, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x6d, 0x61, 0x78, 0x20, 0x28, 0x69,
+ 0x6e, 0x63, 0x6c, 0x75, 0x73, 0x69, 0x76, 0x65, 0x29, 0x2e, 0x0a, 0x20,
+ 0x20, 0x5f, 0x2e, 0x72, 0x61, 0x6e, 0x64, 0x6f, 0x6d, 0x20, 0x3d, 0x20,
+ 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6d, 0x69, 0x6e,
+ 0x2c, 0x20, 0x6d, 0x61, 0x78, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x69, 0x66, 0x20, 0x28, 0x6d, 0x61, 0x78, 0x20, 0x3d, 0x3d, 0x20,
+ 0x6e, 0x75, 0x6c, 0x6c, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x6d, 0x61, 0x78, 0x20, 0x3d, 0x20, 0x6d, 0x69, 0x6e, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x69, 0x6e, 0x20, 0x3d,
+ 0x20, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6d, 0x69, 0x6e,
+ 0x20, 0x2b, 0x20, 0x4d, 0x61, 0x74, 0x68, 0x2e, 0x66, 0x6c, 0x6f, 0x6f,
+ 0x72, 0x28, 0x4d, 0x61, 0x74, 0x68, 0x2e, 0x72, 0x61, 0x6e, 0x64, 0x6f,
+ 0x6d, 0x28, 0x29, 0x20, 0x2a, 0x20, 0x28, 0x6d, 0x61, 0x78, 0x20, 0x2d,
+ 0x20, 0x6d, 0x69, 0x6e, 0x20, 0x2b, 0x20, 0x31, 0x29, 0x29, 0x3b, 0x0a,
+ 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x4c,
+ 0x69, 0x73, 0x74, 0x20, 0x6f, 0x66, 0x20, 0x48, 0x54, 0x4d, 0x4c, 0x20,
+ 0x65, 0x6e, 0x74, 0x69, 0x74, 0x69, 0x65, 0x73, 0x20, 0x66, 0x6f, 0x72,
+ 0x20, 0x65, 0x73, 0x63, 0x61, 0x70, 0x69, 0x6e, 0x67, 0x2e, 0x0a, 0x20,
+ 0x20, 0x76, 0x61, 0x72, 0x20, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x4d,
+ 0x61, 0x70, 0x20, 0x3d, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65,
+ 0x73, 0x63, 0x61, 0x70, 0x65, 0x3a, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x27, 0x26, 0x27, 0x3a, 0x20, 0x27, 0x26, 0x61, 0x6d,
+ 0x70, 0x3b, 0x27, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x27,
+ 0x3c, 0x27, 0x3a, 0x20, 0x27, 0x26, 0x6c, 0x74, 0x3b, 0x27, 0x2c, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x27, 0x3e, 0x27, 0x3a, 0x20, 0x27,
+ 0x26, 0x67, 0x74, 0x3b, 0x27, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x27, 0x22, 0x27, 0x3a, 0x20, 0x27, 0x26, 0x71, 0x75, 0x6f, 0x74,
+ 0x3b, 0x27, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x27,
+ 0x22, 0x3a, 0x20, 0x27, 0x26, 0x23, 0x78, 0x32, 0x37, 0x3b, 0x27, 0x2c,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x27, 0x2f, 0x27, 0x3a, 0x20,
+ 0x27, 0x26, 0x23, 0x78, 0x32, 0x46, 0x3b, 0x27, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x20, 0x20, 0x65, 0x6e,
+ 0x74, 0x69, 0x74, 0x79, 0x4d, 0x61, 0x70, 0x2e, 0x75, 0x6e, 0x65, 0x73,
+ 0x63, 0x61, 0x70, 0x65, 0x20, 0x3d, 0x20, 0x5f, 0x2e, 0x69, 0x6e, 0x76,
+ 0x65, 0x72, 0x74, 0x28, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x4d, 0x61,
+ 0x70, 0x2e, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x29, 0x3b, 0x0a, 0x0a,
+ 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x52, 0x65, 0x67, 0x65, 0x78, 0x65, 0x73,
+ 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x20,
+ 0x74, 0x68, 0x65, 0x20, 0x6b, 0x65, 0x79, 0x73, 0x20, 0x61, 0x6e, 0x64,
+ 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x20, 0x6c, 0x69, 0x73, 0x74,
+ 0x65, 0x64, 0x20, 0x69, 0x6d, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x74, 0x65,
+ 0x6c, 0x79, 0x20, 0x61, 0x62, 0x6f, 0x76, 0x65, 0x2e, 0x0a, 0x20, 0x20,
+ 0x76, 0x61, 0x72, 0x20, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x52, 0x65,
+ 0x67, 0x65, 0x78, 0x65, 0x73, 0x20, 0x3d, 0x20, 0x7b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x3a, 0x20, 0x20, 0x20,
+ 0x6e, 0x65, 0x77, 0x20, 0x52, 0x65, 0x67, 0x45, 0x78, 0x70, 0x28, 0x27,
+ 0x5b, 0x27, 0x20, 0x2b, 0x20, 0x5f, 0x2e, 0x6b, 0x65, 0x79, 0x73, 0x28,
+ 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x4d, 0x61, 0x70, 0x2e, 0x65, 0x73,
+ 0x63, 0x61, 0x70, 0x65, 0x29, 0x2e, 0x6a, 0x6f, 0x69, 0x6e, 0x28, 0x27,
+ 0x27, 0x29, 0x20, 0x2b, 0x20, 0x27, 0x5d, 0x27, 0x2c, 0x20, 0x27, 0x67,
+ 0x27, 0x29, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x75, 0x6e, 0x65, 0x73,
+ 0x63, 0x61, 0x70, 0x65, 0x3a, 0x20, 0x6e, 0x65, 0x77, 0x20, 0x52, 0x65,
+ 0x67, 0x45, 0x78, 0x70, 0x28, 0x27, 0x28, 0x27, 0x20, 0x2b, 0x20, 0x5f,
+ 0x2e, 0x6b, 0x65, 0x79, 0x73, 0x28, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79,
+ 0x4d, 0x61, 0x70, 0x2e, 0x75, 0x6e, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65,
+ 0x29, 0x2e, 0x6a, 0x6f, 0x69, 0x6e, 0x28, 0x27, 0x7c, 0x27, 0x29, 0x20,
+ 0x2b, 0x20, 0x27, 0x29, 0x27, 0x2c, 0x20, 0x27, 0x67, 0x27, 0x29, 0x0a,
+ 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x46,
+ 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x66, 0x6f, 0x72,
+ 0x20, 0x65, 0x73, 0x63, 0x61, 0x70, 0x69, 0x6e, 0x67, 0x20, 0x61, 0x6e,
+ 0x64, 0x20, 0x75, 0x6e, 0x65, 0x73, 0x63, 0x61, 0x70, 0x69, 0x6e, 0x67,
+ 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x73, 0x20, 0x74, 0x6f, 0x2f,
+ 0x66, 0x72, 0x6f, 0x6d, 0x20, 0x48, 0x54, 0x4d, 0x4c, 0x20, 0x69, 0x6e,
+ 0x74, 0x65, 0x72, 0x70, 0x6f, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e,
+ 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x65, 0x61, 0x63, 0x68, 0x28, 0x5b, 0x27,
+ 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x27, 0x2c, 0x20, 0x27, 0x75, 0x6e,
+ 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x27, 0x5d, 0x2c, 0x20, 0x66, 0x75,
+ 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6d, 0x65, 0x74, 0x68, 0x6f,
+ 0x64, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x5b, 0x6d,
+ 0x65, 0x74, 0x68, 0x6f, 0x64, 0x5d, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e,
+ 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67,
+ 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66,
+ 0x20, 0x28, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x20, 0x3d, 0x3d, 0x20,
+ 0x6e, 0x75, 0x6c, 0x6c, 0x29, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,
+ 0x20, 0x27, 0x27, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72,
+ 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x28, 0x27, 0x27, 0x20, 0x2b, 0x20,
+ 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x29, 0x2e, 0x72, 0x65, 0x70, 0x6c,
+ 0x61, 0x63, 0x65, 0x28, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x52, 0x65,
+ 0x67, 0x65, 0x78, 0x65, 0x73, 0x5b, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64,
+ 0x5d, 0x2c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28,
+ 0x6d, 0x61, 0x74, 0x63, 0x68, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20,
+ 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x4d, 0x61, 0x70, 0x5b, 0x6d, 0x65,
+ 0x74, 0x68, 0x6f, 0x64, 0x5d, 0x5b, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x5d,
+ 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x29, 0x3b, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x29, 0x3b,
+ 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x49, 0x66, 0x20, 0x74, 0x68,
+ 0x65, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x74,
+ 0x68, 0x65, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x64, 0x20, 0x70, 0x72, 0x6f,
+ 0x70, 0x65, 0x72, 0x74, 0x79, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x66,
+ 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x6e,
+ 0x20, 0x69, 0x6e, 0x76, 0x6f, 0x6b, 0x65, 0x20, 0x69, 0x74, 0x3b, 0x0a,
+ 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x77, 0x69,
+ 0x73, 0x65, 0x2c, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x69,
+ 0x74, 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x72, 0x65, 0x73, 0x75, 0x6c,
+ 0x74, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
+ 0x28, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2c, 0x20, 0x70, 0x72, 0x6f,
+ 0x70, 0x65, 0x72, 0x74, 0x79, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x69, 0x66, 0x20, 0x28, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20,
+ 0x3d, 0x3d, 0x20, 0x6e, 0x75, 0x6c, 0x6c, 0x29, 0x20, 0x72, 0x65, 0x74,
+ 0x75, 0x72, 0x6e, 0x20, 0x6e, 0x75, 0x6c, 0x6c, 0x3b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x20,
+ 0x3d, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5b, 0x70, 0x72, 0x6f,
+ 0x70, 0x65, 0x72, 0x74, 0x79, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x2e, 0x69, 0x73, 0x46,
+ 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x76, 0x61, 0x6c, 0x75,
+ 0x65, 0x29, 0x20, 0x3f, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2e, 0x63,
+ 0x61, 0x6c, 0x6c, 0x28, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x29, 0x20,
+ 0x3a, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x7d,
+ 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x41, 0x64, 0x64, 0x20,
+ 0x79, 0x6f, 0x75, 0x72, 0x20, 0x6f, 0x77, 0x6e, 0x20, 0x63, 0x75, 0x73,
+ 0x74, 0x6f, 0x6d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
+ 0x73, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x55, 0x6e, 0x64,
+ 0x65, 0x72, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x20, 0x6f, 0x62, 0x6a, 0x65,
+ 0x63, 0x74, 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x6d, 0x69, 0x78, 0x69,
+ 0x6e, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
+ 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x65, 0x61, 0x63, 0x68, 0x28, 0x5f, 0x2e, 0x66, 0x75, 0x6e, 0x63, 0x74,
+ 0x69, 0x6f, 0x6e, 0x73, 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x2c, 0x20, 0x66,
+ 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6e, 0x61, 0x6d, 0x65,
+ 0x29, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72,
+ 0x20, 0x66, 0x75, 0x6e, 0x63, 0x20, 0x3d, 0x20, 0x5f, 0x5b, 0x6e, 0x61,
+ 0x6d, 0x65, 0x5d, 0x20, 0x3d, 0x20, 0x6f, 0x62, 0x6a, 0x5b, 0x6e, 0x61,
+ 0x6d, 0x65, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5f,
+ 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x74, 0x79, 0x70, 0x65, 0x5b, 0x6e,
+ 0x61, 0x6d, 0x65, 0x5d, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74,
+ 0x69, 0x6f, 0x6e, 0x28, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x61, 0x72, 0x67, 0x73,
+ 0x20, 0x3d, 0x20, 0x5b, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x5f, 0x77, 0x72,
+ 0x61, 0x70, 0x70, 0x65, 0x64, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x70, 0x75, 0x73, 0x68, 0x2e, 0x61, 0x70, 0x70,
+ 0x6c, 0x79, 0x28, 0x61, 0x72, 0x67, 0x73, 0x2c, 0x20, 0x61, 0x72, 0x67,
+ 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20,
+ 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28,
+ 0x74, 0x68, 0x69, 0x73, 0x2c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x2e, 0x61,
+ 0x70, 0x70, 0x6c, 0x79, 0x28, 0x5f, 0x2c, 0x20, 0x61, 0x72, 0x67, 0x73,
+ 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x3b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x7d,
+ 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x47, 0x65, 0x6e, 0x65,
+ 0x72, 0x61, 0x74, 0x65, 0x20, 0x61, 0x20, 0x75, 0x6e, 0x69, 0x71, 0x75,
+ 0x65, 0x20, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x20, 0x69, 0x64,
+ 0x20, 0x28, 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x20, 0x77, 0x69, 0x74,
+ 0x68, 0x69, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x65, 0x6e, 0x74, 0x69,
+ 0x72, 0x65, 0x20, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x73, 0x65,
+ 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x29, 0x2e, 0x0a, 0x20, 0x20, 0x2f, 0x2f,
+ 0x20, 0x55, 0x73, 0x65, 0x66, 0x75, 0x6c, 0x20, 0x66, 0x6f, 0x72, 0x20,
+ 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x72, 0x79, 0x20, 0x44, 0x4f,
+ 0x4d, 0x20, 0x69, 0x64, 0x73, 0x2e, 0x0a, 0x20, 0x20, 0x76, 0x61, 0x72,
+ 0x20, 0x69, 0x64, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x20, 0x3d,
+ 0x20, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x75, 0x6e, 0x69, 0x71,
+ 0x75, 0x65, 0x49, 0x64, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74,
+ 0x69, 0x6f, 0x6e, 0x28, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x29, 0x20,
+ 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x69, 0x64,
+ 0x20, 0x3d, 0x20, 0x2b, 0x2b, 0x69, 0x64, 0x43, 0x6f, 0x75, 0x6e, 0x74,
+ 0x65, 0x72, 0x20, 0x2b, 0x20, 0x27, 0x27, 0x3b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x70, 0x72, 0x65, 0x66,
+ 0x69, 0x78, 0x20, 0x3f, 0x20, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x20,
+ 0x2b, 0x20, 0x69, 0x64, 0x20, 0x3a, 0x20, 0x69, 0x64, 0x3b, 0x0a, 0x20,
+ 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x42, 0x79,
+ 0x20, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x2c, 0x20, 0x55, 0x6e,
+ 0x64, 0x65, 0x72, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x20, 0x75, 0x73, 0x65,
+ 0x73, 0x20, 0x45, 0x52, 0x42, 0x2d, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x20,
+ 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x20, 0x64, 0x65, 0x6c,
+ 0x69, 0x6d, 0x69, 0x74, 0x65, 0x72, 0x73, 0x2c, 0x20, 0x63, 0x68, 0x61,
+ 0x6e, 0x67, 0x65, 0x20, 0x74, 0x68, 0x65, 0x0a, 0x20, 0x20, 0x2f, 0x2f,
+ 0x20, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x69, 0x6e, 0x67, 0x20, 0x74,
+ 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x20, 0x73, 0x65, 0x74, 0x74,
+ 0x69, 0x6e, 0x67, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x75, 0x73, 0x65, 0x20,
+ 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x20,
+ 0x64, 0x65, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x65, 0x72, 0x73, 0x2e, 0x0a,
+ 0x20, 0x20, 0x5f, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65,
+ 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x20, 0x3d, 0x20, 0x7b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x76, 0x61, 0x6c, 0x75, 0x61, 0x74,
+ 0x65, 0x20, 0x20, 0x20, 0x20, 0x3a, 0x20, 0x2f, 0x3c, 0x25, 0x28, 0x5b,
+ 0x5c, 0x73, 0x5c, 0x53, 0x5d, 0x2b, 0x3f, 0x29, 0x25, 0x3e, 0x2f, 0x67,
+ 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70,
+ 0x6f, 0x6c, 0x61, 0x74, 0x65, 0x20, 0x3a, 0x20, 0x2f, 0x3c, 0x25, 0x3d,
+ 0x28, 0x5b, 0x5c, 0x73, 0x5c, 0x53, 0x5d, 0x2b, 0x3f, 0x29, 0x25, 0x3e,
+ 0x2f, 0x67, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x73, 0x63, 0x61,
+ 0x70, 0x65, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3a, 0x20, 0x2f, 0x3c,
+ 0x25, 0x2d, 0x28, 0x5b, 0x5c, 0x73, 0x5c, 0x53, 0x5d, 0x2b, 0x3f, 0x29,
+ 0x25, 0x3e, 0x2f, 0x67, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20,
+ 0x20, 0x2f, 0x2f, 0x20, 0x57, 0x68, 0x65, 0x6e, 0x20, 0x63, 0x75, 0x73,
+ 0x74, 0x6f, 0x6d, 0x69, 0x7a, 0x69, 0x6e, 0x67, 0x20, 0x60, 0x74, 0x65,
+ 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e,
+ 0x67, 0x73, 0x60, 0x2c, 0x20, 0x69, 0x66, 0x20, 0x79, 0x6f, 0x75, 0x20,
+ 0x64, 0x6f, 0x6e, 0x27, 0x74, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, 0x74,
+ 0x6f, 0x20, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x20, 0x61, 0x6e, 0x0a,
+ 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x6f,
+ 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2c, 0x20, 0x65, 0x76, 0x61, 0x6c,
+ 0x75, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x72, 0x20, 0x65, 0x73,
+ 0x63, 0x61, 0x70, 0x69, 0x6e, 0x67, 0x20, 0x72, 0x65, 0x67, 0x65, 0x78,
+ 0x2c, 0x20, 0x77, 0x65, 0x20, 0x6e, 0x65, 0x65, 0x64, 0x20, 0x6f, 0x6e,
+ 0x65, 0x20, 0x74, 0x68, 0x61, 0x74, 0x20, 0x69, 0x73, 0x0a, 0x20, 0x20,
+ 0x2f, 0x2f, 0x20, 0x67, 0x75, 0x61, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x65,
+ 0x64, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x74, 0x6f, 0x20, 0x6d, 0x61, 0x74,
+ 0x63, 0x68, 0x2e, 0x0a, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x6e, 0x6f,
+ 0x4d, 0x61, 0x74, 0x63, 0x68, 0x20, 0x3d, 0x20, 0x2f, 0x28, 0x2e, 0x29,
+ 0x5e, 0x2f, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x43, 0x65,
+ 0x72, 0x74, 0x61, 0x69, 0x6e, 0x20, 0x63, 0x68, 0x61, 0x72, 0x61, 0x63,
+ 0x74, 0x65, 0x72, 0x73, 0x20, 0x6e, 0x65, 0x65, 0x64, 0x20, 0x74, 0x6f,
+ 0x20, 0x62, 0x65, 0x20, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x64, 0x20,
+ 0x73, 0x6f, 0x20, 0x74, 0x68, 0x61, 0x74, 0x20, 0x74, 0x68, 0x65, 0x79,
+ 0x20, 0x63, 0x61, 0x6e, 0x20, 0x62, 0x65, 0x20, 0x70, 0x75, 0x74, 0x20,
+ 0x69, 0x6e, 0x74, 0x6f, 0x20, 0x61, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20,
+ 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x20, 0x6c, 0x69, 0x74, 0x65, 0x72,
+ 0x61, 0x6c, 0x2e, 0x0a, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x65, 0x73,
+ 0x63, 0x61, 0x70, 0x65, 0x73, 0x20, 0x3d, 0x20, 0x7b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x22, 0x27, 0x22, 0x3a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x22, 0x27, 0x22, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x27, 0x5c, 0x5c,
+ 0x27, 0x3a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x27, 0x5c, 0x5c, 0x27, 0x2c,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x27, 0x5c, 0x72, 0x27, 0x3a, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x27, 0x72, 0x27, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x27, 0x5c, 0x6e, 0x27, 0x3a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x27, 0x6e,
+ 0x27, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x27, 0x5c, 0x74, 0x27, 0x3a,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x27, 0x74, 0x27, 0x2c, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x27, 0x5c, 0x75, 0x32, 0x30, 0x32, 0x38, 0x27, 0x3a, 0x20,
+ 0x27, 0x75, 0x32, 0x30, 0x32, 0x38, 0x27, 0x2c, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x27, 0x5c, 0x75, 0x32, 0x30, 0x32, 0x39, 0x27, 0x3a, 0x20, 0x27,
+ 0x75, 0x32, 0x30, 0x32, 0x39, 0x27, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a,
+ 0x0a, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x65, 0x73, 0x63, 0x61, 0x70,
+ 0x65, 0x72, 0x20, 0x3d, 0x20, 0x2f, 0x5c, 0x5c, 0x7c, 0x27, 0x7c, 0x5c,
+ 0x72, 0x7c, 0x5c, 0x6e, 0x7c, 0x5c, 0x74, 0x7c, 0x5c, 0x75, 0x32, 0x30,
+ 0x32, 0x38, 0x7c, 0x5c, 0x75, 0x32, 0x30, 0x32, 0x39, 0x2f, 0x67, 0x3b,
+ 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x4a, 0x61, 0x76, 0x61, 0x53,
+ 0x63, 0x72, 0x69, 0x70, 0x74, 0x20, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2d,
+ 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x69, 0x6e, 0x67, 0x2c, 0x20,
+ 0x73, 0x69, 0x6d, 0x69, 0x6c, 0x61, 0x72, 0x20, 0x74, 0x6f, 0x20, 0x4a,
+ 0x6f, 0x68, 0x6e, 0x20, 0x52, 0x65, 0x73, 0x69, 0x67, 0x27, 0x73, 0x20,
+ 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69,
+ 0x6f, 0x6e, 0x2e, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x55, 0x6e, 0x64,
+ 0x65, 0x72, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x20, 0x74, 0x65, 0x6d, 0x70,
+ 0x6c, 0x61, 0x74, 0x69, 0x6e, 0x67, 0x20, 0x68, 0x61, 0x6e, 0x64, 0x6c,
+ 0x65, 0x73, 0x20, 0x61, 0x72, 0x62, 0x69, 0x74, 0x72, 0x61, 0x72, 0x79,
+ 0x20, 0x64, 0x65, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x65, 0x72, 0x73, 0x2c,
+ 0x20, 0x70, 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x73, 0x20, 0x77,
+ 0x68, 0x69, 0x74, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2c, 0x0a, 0x20,
+ 0x20, 0x2f, 0x2f, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x63, 0x6f, 0x72, 0x72,
+ 0x65, 0x63, 0x74, 0x6c, 0x79, 0x20, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65,
+ 0x73, 0x20, 0x71, 0x75, 0x6f, 0x74, 0x65, 0x73, 0x20, 0x77, 0x69, 0x74,
+ 0x68, 0x69, 0x6e, 0x20, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x6f, 0x6c,
+ 0x61, 0x74, 0x65, 0x64, 0x20, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x0a, 0x20,
+ 0x20, 0x5f, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x20,
+ 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x74,
+ 0x65, 0x78, 0x74, 0x2c, 0x20, 0x64, 0x61, 0x74, 0x61, 0x2c, 0x20, 0x73,
+ 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x29, 0x20, 0x7b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x72, 0x65, 0x6e, 0x64, 0x65,
+ 0x72, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x73, 0x65, 0x74, 0x74, 0x69,
+ 0x6e, 0x67, 0x73, 0x20, 0x3d, 0x20, 0x5f, 0x2e, 0x64, 0x65, 0x66, 0x61,
+ 0x75, 0x6c, 0x74, 0x73, 0x28, 0x7b, 0x7d, 0x2c, 0x20, 0x73, 0x65, 0x74,
+ 0x74, 0x69, 0x6e, 0x67, 0x73, 0x2c, 0x20, 0x5f, 0x2e, 0x74, 0x65, 0x6d,
+ 0x70, 0x6c, 0x61, 0x74, 0x65, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67,
+ 0x73, 0x29, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2f, 0x2f, 0x20,
+ 0x43, 0x6f, 0x6d, 0x62, 0x69, 0x6e, 0x65, 0x20, 0x64, 0x65, 0x6c, 0x69,
+ 0x6d, 0x69, 0x74, 0x65, 0x72, 0x73, 0x20, 0x69, 0x6e, 0x74, 0x6f, 0x20,
+ 0x6f, 0x6e, 0x65, 0x20, 0x72, 0x65, 0x67, 0x75, 0x6c, 0x61, 0x72, 0x20,
+ 0x65, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x76,
+ 0x69, 0x61, 0x20, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x69,
+ 0x6f, 0x6e, 0x2e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20,
+ 0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x20, 0x3d, 0x20, 0x6e, 0x65,
+ 0x77, 0x20, 0x52, 0x65, 0x67, 0x45, 0x78, 0x70, 0x28, 0x5b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x28, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e,
+ 0x67, 0x73, 0x2e, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x20, 0x7c, 0x7c,
+ 0x20, 0x6e, 0x6f, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x29, 0x2e, 0x73, 0x6f,
+ 0x75, 0x72, 0x63, 0x65, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x28, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x2e, 0x69, 0x6e,
+ 0x74, 0x65, 0x72, 0x70, 0x6f, 0x6c, 0x61, 0x74, 0x65, 0x20, 0x7c, 0x7c,
+ 0x20, 0x6e, 0x6f, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x29, 0x2e, 0x73, 0x6f,
+ 0x75, 0x72, 0x63, 0x65, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x28, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x2e, 0x65, 0x76,
+ 0x61, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x20, 0x7c, 0x7c, 0x20, 0x6e, 0x6f,
+ 0x4d, 0x61, 0x74, 0x63, 0x68, 0x29, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63,
+ 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x5d, 0x2e, 0x6a, 0x6f, 0x69, 0x6e,
+ 0x28, 0x27, 0x7c, 0x27, 0x29, 0x20, 0x2b, 0x20, 0x27, 0x7c, 0x24, 0x27,
+ 0x2c, 0x20, 0x27, 0x67, 0x27, 0x29, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x2f, 0x2f, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x20,
+ 0x74, 0x68, 0x65, 0x20, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65,
+ 0x20, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2c, 0x20, 0x65, 0x73, 0x63,
+ 0x61, 0x70, 0x69, 0x6e, 0x67, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67,
+ 0x20, 0x6c, 0x69, 0x74, 0x65, 0x72, 0x61, 0x6c, 0x73, 0x20, 0x61, 0x70,
+ 0x70, 0x72, 0x6f, 0x70, 0x72, 0x69, 0x61, 0x74, 0x65, 0x6c, 0x79, 0x2e,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x69, 0x6e, 0x64,
+ 0x65, 0x78, 0x20, 0x3d, 0x20, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x76, 0x61, 0x72, 0x20, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x20, 0x3d,
+ 0x20, 0x22, 0x5f, 0x5f, 0x70, 0x2b, 0x3d, 0x27, 0x22, 0x3b, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2e, 0x72, 0x65, 0x70, 0x6c,
+ 0x61, 0x63, 0x65, 0x28, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x2c,
+ 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6d, 0x61,
+ 0x74, 0x63, 0x68, 0x2c, 0x20, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x2c,
+ 0x20, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x6f, 0x6c, 0x61, 0x74, 0x65,
+ 0x2c, 0x20, 0x65, 0x76, 0x61, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x2c, 0x20,
+ 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x20, 0x2b,
+ 0x3d, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2e, 0x73, 0x6c, 0x69, 0x63, 0x65,
+ 0x28, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2c, 0x20, 0x6f, 0x66, 0x66, 0x73,
+ 0x65, 0x74, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x2e, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x28, 0x65, 0x73, 0x63,
+ 0x61, 0x70, 0x65, 0x72, 0x2c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69,
+ 0x6f, 0x6e, 0x28, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x29, 0x20, 0x7b, 0x20,
+ 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x27, 0x5c, 0x5c, 0x27, 0x20,
+ 0x2b, 0x20, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x73, 0x5b, 0x6d, 0x61,
+ 0x74, 0x63, 0x68, 0x5d, 0x3b, 0x20, 0x7d, 0x29, 0x3b, 0x0a, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x65, 0x73, 0x63,
+ 0x61, 0x70, 0x65, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x20, 0x2b, 0x3d,
+ 0x20, 0x22, 0x27, 0x2b, 0x5c, 0x6e, 0x28, 0x28, 0x5f, 0x5f, 0x74, 0x3d,
+ 0x28, 0x22, 0x20, 0x2b, 0x20, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x20,
+ 0x2b, 0x20, 0x22, 0x29, 0x29, 0x3d, 0x3d, 0x6e, 0x75, 0x6c, 0x6c, 0x3f,
+ 0x27, 0x27, 0x3a, 0x5f, 0x2e, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x28,
+ 0x5f, 0x5f, 0x74, 0x29, 0x29, 0x2b, 0x5c, 0x6e, 0x27, 0x22, 0x3b, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70,
+ 0x6f, 0x6c, 0x61, 0x74, 0x65, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x20,
+ 0x2b, 0x3d, 0x20, 0x22, 0x27, 0x2b, 0x5c, 0x6e, 0x28, 0x28, 0x5f, 0x5f,
+ 0x74, 0x3d, 0x28, 0x22, 0x20, 0x2b, 0x20, 0x69, 0x6e, 0x74, 0x65, 0x72,
+ 0x70, 0x6f, 0x6c, 0x61, 0x74, 0x65, 0x20, 0x2b, 0x20, 0x22, 0x29, 0x29,
+ 0x3d, 0x3d, 0x6e, 0x75, 0x6c, 0x6c, 0x3f, 0x27, 0x27, 0x3a, 0x5f, 0x5f,
+ 0x74, 0x29, 0x2b, 0x5c, 0x6e, 0x27, 0x22, 0x3b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69,
+ 0x66, 0x20, 0x28, 0x65, 0x76, 0x61, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x29,
+ 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x73,
+ 0x6f, 0x75, 0x72, 0x63, 0x65, 0x20, 0x2b, 0x3d, 0x20, 0x22, 0x27, 0x3b,
+ 0x5c, 0x6e, 0x22, 0x20, 0x2b, 0x20, 0x65, 0x76, 0x61, 0x6c, 0x75, 0x61,
+ 0x74, 0x65, 0x20, 0x2b, 0x20, 0x22, 0x5c, 0x6e, 0x5f, 0x5f, 0x70, 0x2b,
+ 0x3d, 0x27, 0x22, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78,
+ 0x20, 0x3d, 0x20, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x20, 0x2b, 0x20,
+ 0x6d, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68,
+ 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75,
+ 0x72, 0x6e, 0x20, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x3b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x7d, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x73, 0x6f,
+ 0x75, 0x72, 0x63, 0x65, 0x20, 0x2b, 0x3d, 0x20, 0x22, 0x27, 0x3b, 0x5c,
+ 0x6e, 0x22, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2f, 0x2f, 0x20,
+ 0x49, 0x66, 0x20, 0x61, 0x20, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c,
+ 0x65, 0x20, 0x69, 0x73, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x73, 0x70, 0x65,
+ 0x63, 0x69, 0x66, 0x69, 0x65, 0x64, 0x2c, 0x20, 0x70, 0x6c, 0x61, 0x63,
+ 0x65, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65,
+ 0x73, 0x20, 0x69, 0x6e, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x73,
+ 0x63, 0x6f, 0x70, 0x65, 0x2e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66,
+ 0x20, 0x28, 0x21, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x2e,
+ 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x29, 0x20, 0x73, 0x6f,
+ 0x75, 0x72, 0x63, 0x65, 0x20, 0x3d, 0x20, 0x27, 0x77, 0x69, 0x74, 0x68,
+ 0x28, 0x6f, 0x62, 0x6a, 0x7c, 0x7c, 0x7b, 0x7d, 0x29, 0x7b, 0x5c, 0x6e,
+ 0x27, 0x20, 0x2b, 0x20, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x20, 0x2b,
+ 0x20, 0x27, 0x7d, 0x5c, 0x6e, 0x27, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x20, 0x3d, 0x20, 0x22, 0x76,
+ 0x61, 0x72, 0x20, 0x5f, 0x5f, 0x74, 0x2c, 0x5f, 0x5f, 0x70, 0x3d, 0x27,
+ 0x27, 0x2c, 0x5f, 0x5f, 0x6a, 0x3d, 0x41, 0x72, 0x72, 0x61, 0x79, 0x2e,
+ 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x6a, 0x6f,
+ 0x69, 0x6e, 0x2c, 0x22, 0x20, 0x2b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x22, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x3d, 0x66, 0x75, 0x6e, 0x63,
+ 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x29, 0x7b, 0x5f, 0x5f, 0x70, 0x2b, 0x3d,
+ 0x5f, 0x5f, 0x6a, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x61, 0x72, 0x67,
+ 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2c, 0x27, 0x27, 0x29, 0x3b, 0x7d,
+ 0x3b, 0x5c, 0x6e, 0x22, 0x20, 0x2b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x20, 0x2b, 0x20, 0x22, 0x72,
+ 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x5f, 0x70, 0x3b, 0x5c, 0x6e,
+ 0x22, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x72, 0x79, 0x20,
+ 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x6e, 0x64,
+ 0x65, 0x72, 0x20, 0x3d, 0x20, 0x6e, 0x65, 0x77, 0x20, 0x46, 0x75, 0x6e,
+ 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e,
+ 0x67, 0x73, 0x2e, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x20,
+ 0x7c, 0x7c, 0x20, 0x27, 0x6f, 0x62, 0x6a, 0x27, 0x2c, 0x20, 0x27, 0x5f,
+ 0x27, 0x2c, 0x20, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x29, 0x3b, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x7d, 0x20, 0x63, 0x61, 0x74, 0x63, 0x68, 0x20,
+ 0x28, 0x65, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x65, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x20, 0x3d, 0x20, 0x73,
+ 0x6f, 0x75, 0x72, 0x63, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x74, 0x68, 0x72, 0x6f, 0x77, 0x20, 0x65, 0x3b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x7d, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20,
+ 0x28, 0x64, 0x61, 0x74, 0x61, 0x29, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72,
+ 0x6e, 0x20, 0x72, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x28, 0x64, 0x61, 0x74,
+ 0x61, 0x2c, 0x20, 0x5f, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76,
+ 0x61, 0x72, 0x20, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x20,
+ 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x64,
+ 0x61, 0x74, 0x61, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x72, 0x65, 0x6e, 0x64,
+ 0x65, 0x72, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x74, 0x68, 0x69, 0x73,
+ 0x2c, 0x20, 0x64, 0x61, 0x74, 0x61, 0x2c, 0x20, 0x5f, 0x29, 0x3b, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x2f, 0x2f, 0x20, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x20, 0x74,
+ 0x68, 0x65, 0x20, 0x63, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x64, 0x20,
+ 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x73, 0x6f, 0x75,
+ 0x72, 0x63, 0x65, 0x20, 0x61, 0x73, 0x20, 0x61, 0x20, 0x63, 0x6f, 0x6e,
+ 0x76, 0x65, 0x6e, 0x69, 0x65, 0x6e, 0x63, 0x65, 0x20, 0x66, 0x6f, 0x72,
+ 0x20, 0x70, 0x72, 0x65, 0x63, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x61, 0x74,
+ 0x69, 0x6f, 0x6e, 0x2e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x65, 0x6d,
+ 0x70, 0x6c, 0x61, 0x74, 0x65, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65,
+ 0x20, 0x3d, 0x20, 0x27, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
+ 0x28, 0x27, 0x20, 0x2b, 0x20, 0x28, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e,
+ 0x67, 0x73, 0x2e, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x20,
+ 0x7c, 0x7c, 0x20, 0x27, 0x6f, 0x62, 0x6a, 0x27, 0x29, 0x20, 0x2b, 0x20,
+ 0x27, 0x29, 0x7b, 0x5c, 0x6e, 0x27, 0x20, 0x2b, 0x20, 0x73, 0x6f, 0x75,
+ 0x72, 0x63, 0x65, 0x20, 0x2b, 0x20, 0x27, 0x7d, 0x27, 0x3b, 0x0a, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x74,
+ 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x7d,
+ 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x41, 0x64, 0x64, 0x20,
+ 0x61, 0x20, 0x22, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x22, 0x20, 0x66, 0x75,
+ 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2c, 0x20, 0x77, 0x68, 0x69, 0x63,
+ 0x68, 0x20, 0x77, 0x69, 0x6c, 0x6c, 0x20, 0x64, 0x65, 0x6c, 0x65, 0x67,
+ 0x61, 0x74, 0x65, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x77,
+ 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e,
+ 0x63, 0x68, 0x61, 0x69, 0x6e, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63,
+ 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x20, 0x7b, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f,
+ 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x2e, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x28,
+ 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f,
+ 0x2f, 0x20, 0x4f, 0x4f, 0x50, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x2d,
+ 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
+ 0x2d, 0x2d, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x49, 0x66, 0x20, 0x55,
+ 0x6e, 0x64, 0x65, 0x72, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x20, 0x69, 0x73,
+ 0x20, 0x63, 0x61, 0x6c, 0x6c, 0x65, 0x64, 0x20, 0x61, 0x73, 0x20, 0x61,
+ 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2c, 0x20, 0x69,
+ 0x74, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x73, 0x20, 0x61, 0x20,
+ 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x64, 0x20, 0x6f, 0x62, 0x6a, 0x65,
+ 0x63, 0x74, 0x20, 0x74, 0x68, 0x61, 0x74, 0x0a, 0x20, 0x20, 0x2f, 0x2f,
+ 0x20, 0x63, 0x61, 0x6e, 0x20, 0x62, 0x65, 0x20, 0x75, 0x73, 0x65, 0x64,
+ 0x20, 0x4f, 0x4f, 0x2d, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x2e, 0x20, 0x54,
+ 0x68, 0x69, 0x73, 0x20, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x20,
+ 0x68, 0x6f, 0x6c, 0x64, 0x73, 0x20, 0x61, 0x6c, 0x74, 0x65, 0x72, 0x65,
+ 0x64, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x6f,
+ 0x66, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x74, 0x68, 0x65, 0x0a, 0x20, 0x20,
+ 0x2f, 0x2f, 0x20, 0x75, 0x6e, 0x64, 0x65, 0x72, 0x73, 0x63, 0x6f, 0x72,
+ 0x65, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e,
+ 0x20, 0x57, 0x72, 0x61, 0x70, 0x70, 0x65, 0x64, 0x20, 0x6f, 0x62, 0x6a,
+ 0x65, 0x63, 0x74, 0x73, 0x20, 0x6d, 0x61, 0x79, 0x20, 0x62, 0x65, 0x20,
+ 0x63, 0x68, 0x61, 0x69, 0x6e, 0x65, 0x64, 0x2e, 0x0a, 0x0a, 0x20, 0x20,
+ 0x2f, 0x2f, 0x20, 0x48, 0x65, 0x6c, 0x70, 0x65, 0x72, 0x20, 0x66, 0x75,
+ 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x74, 0x6f, 0x20, 0x63, 0x6f,
+ 0x6e, 0x74, 0x69, 0x6e, 0x75, 0x65, 0x20, 0x63, 0x68, 0x61, 0x69, 0x6e,
+ 0x69, 0x6e, 0x67, 0x20, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6d, 0x65, 0x64,
+ 0x69, 0x61, 0x74, 0x65, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73,
+ 0x2e, 0x0a, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x72, 0x65, 0x73, 0x75,
+ 0x6c, 0x74, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f,
+ 0x6e, 0x28, 0x6f, 0x62, 0x6a, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x74, 0x68, 0x69, 0x73,
+ 0x2e, 0x5f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x20, 0x3f, 0x20, 0x5f, 0x28,
+ 0x6f, 0x62, 0x6a, 0x29, 0x2e, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x28, 0x29,
+ 0x20, 0x3a, 0x20, 0x6f, 0x62, 0x6a, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b,
+ 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x41, 0x64, 0x64, 0x20, 0x61,
+ 0x6c, 0x6c, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x55, 0x6e,
+ 0x64, 0x65, 0x72, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x20, 0x66, 0x75, 0x6e,
+ 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68,
+ 0x65, 0x20, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x20, 0x6f, 0x62,
+ 0x6a, 0x65, 0x63, 0x74, 0x2e, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x6d, 0x69,
+ 0x78, 0x69, 0x6e, 0x28, 0x5f, 0x29, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f,
+ 0x2f, 0x20, 0x41, 0x64, 0x64, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x6d, 0x75,
+ 0x74, 0x61, 0x74, 0x6f, 0x72, 0x20, 0x41, 0x72, 0x72, 0x61, 0x79, 0x20,
+ 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x74, 0x6f,
+ 0x20, 0x74, 0x68, 0x65, 0x20, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72,
+ 0x2e, 0x0a, 0x20, 0x20, 0x65, 0x61, 0x63, 0x68, 0x28, 0x5b, 0x27, 0x70,
+ 0x6f, 0x70, 0x27, 0x2c, 0x20, 0x27, 0x70, 0x75, 0x73, 0x68, 0x27, 0x2c,
+ 0x20, 0x27, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x27, 0x2c, 0x20,
+ 0x27, 0x73, 0x68, 0x69, 0x66, 0x74, 0x27, 0x2c, 0x20, 0x27, 0x73, 0x6f,
+ 0x72, 0x74, 0x27, 0x2c, 0x20, 0x27, 0x73, 0x70, 0x6c, 0x69, 0x63, 0x65,
+ 0x27, 0x2c, 0x20, 0x27, 0x75, 0x6e, 0x73, 0x68, 0x69, 0x66, 0x74, 0x27,
+ 0x5d, 0x2c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28,
+ 0x6e, 0x61, 0x6d, 0x65, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x76, 0x61, 0x72, 0x20, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x20, 0x3d,
+ 0x20, 0x41, 0x72, 0x72, 0x61, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x5b,
+ 0x6e, 0x61, 0x6d, 0x65, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x5f,
+ 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x74, 0x79, 0x70, 0x65, 0x5b, 0x6e,
+ 0x61, 0x6d, 0x65, 0x5d, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74,
+ 0x69, 0x6f, 0x6e, 0x28, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x6f, 0x62, 0x6a, 0x20, 0x3d, 0x20,
+ 0x74, 0x68, 0x69, 0x73, 0x2e, 0x5f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65,
+ 0x64, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x65, 0x74,
+ 0x68, 0x6f, 0x64, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x28, 0x6f, 0x62,
+ 0x6a, 0x2c, 0x20, 0x61, 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73,
+ 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20,
+ 0x28, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x20, 0x3d, 0x3d, 0x20, 0x27, 0x73,
+ 0x68, 0x69, 0x66, 0x74, 0x27, 0x20, 0x7c, 0x7c, 0x20, 0x6e, 0x61, 0x6d,
+ 0x65, 0x20, 0x3d, 0x3d, 0x20, 0x27, 0x73, 0x70, 0x6c, 0x69, 0x63, 0x65,
+ 0x27, 0x29, 0x20, 0x26, 0x26, 0x20, 0x6f, 0x62, 0x6a, 0x2e, 0x6c, 0x65,
+ 0x6e, 0x67, 0x74, 0x68, 0x20, 0x3d, 0x3d, 0x3d, 0x20, 0x30, 0x29, 0x20,
+ 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x20, 0x6f, 0x62, 0x6a, 0x5b, 0x30,
+ 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74,
+ 0x75, 0x72, 0x6e, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x2e, 0x63,
+ 0x61, 0x6c, 0x6c, 0x28, 0x74, 0x68, 0x69, 0x73, 0x2c, 0x20, 0x6f, 0x62,
+ 0x6a, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x20,
+ 0x20, 0x7d, 0x29, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x41,
+ 0x64, 0x64, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x61, 0x63, 0x63, 0x65, 0x73,
+ 0x73, 0x6f, 0x72, 0x20, 0x41, 0x72, 0x72, 0x61, 0x79, 0x20, 0x66, 0x75,
+ 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x74,
+ 0x68, 0x65, 0x20, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x2e, 0x0a,
+ 0x20, 0x20, 0x65, 0x61, 0x63, 0x68, 0x28, 0x5b, 0x27, 0x63, 0x6f, 0x6e,
+ 0x63, 0x61, 0x74, 0x27, 0x2c, 0x20, 0x27, 0x6a, 0x6f, 0x69, 0x6e, 0x27,
+ 0x2c, 0x20, 0x27, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x27, 0x5d, 0x2c, 0x20,
+ 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x6e, 0x61, 0x6d,
+ 0x65, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72,
+ 0x20, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x20, 0x3d, 0x20, 0x41, 0x72,
+ 0x72, 0x61, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x5b, 0x6e, 0x61, 0x6d,
+ 0x65, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x2e, 0x70, 0x72,
+ 0x6f, 0x74, 0x6f, 0x74, 0x79, 0x70, 0x65, 0x5b, 0x6e, 0x61, 0x6d, 0x65,
+ 0x5d, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
+ 0x28, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72,
+ 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74,
+ 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x74, 0x68, 0x69, 0x73, 0x2c, 0x20,
+ 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x79,
+ 0x28, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x5f, 0x77, 0x72, 0x61, 0x70, 0x70,
+ 0x65, 0x64, 0x2c, 0x20, 0x61, 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74,
+ 0x73, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x3b, 0x0a,
+ 0x20, 0x20, 0x7d, 0x29, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x5f, 0x2e, 0x65,
+ 0x78, 0x74, 0x65, 0x6e, 0x64, 0x28, 0x5f, 0x2e, 0x70, 0x72, 0x6f, 0x74,
+ 0x6f, 0x74, 0x79, 0x70, 0x65, 0x2c, 0x20, 0x7b, 0x0a, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x53, 0x74, 0x61, 0x72, 0x74, 0x20, 0x63,
+ 0x68, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x20, 0x61, 0x20, 0x77, 0x72,
+ 0x61, 0x70, 0x70, 0x65, 0x64, 0x20, 0x55, 0x6e, 0x64, 0x65, 0x72, 0x73,
+ 0x63, 0x6f, 0x72, 0x65, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2e,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x3a, 0x20,
+ 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x29, 0x20, 0x7b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x74, 0x68, 0x69, 0x73, 0x2e,
+ 0x5f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x20, 0x3d, 0x20, 0x74, 0x72, 0x75,
+ 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74,
+ 0x75, 0x72, 0x6e, 0x20, 0x74, 0x68, 0x69, 0x73, 0x3b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x7d, 0x2c, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2f, 0x2f,
+ 0x20, 0x45, 0x78, 0x74, 0x72, 0x61, 0x63, 0x74, 0x73, 0x20, 0x74, 0x68,
+ 0x65, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x20, 0x66, 0x72, 0x6f,
+ 0x6d, 0x20, 0x61, 0x20, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x64, 0x20,
+ 0x61, 0x6e, 0x64, 0x20, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x65, 0x64, 0x20,
+ 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2e, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74,
+ 0x69, 0x6f, 0x6e, 0x28, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x74, 0x68, 0x69,
+ 0x73, 0x2e, 0x5f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x64, 0x3b, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x0a, 0x20, 0x20, 0x7d, 0x29, 0x3b,
+ 0x0a, 0x0a, 0x7d, 0x29, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x74, 0x68,
+ 0x69, 0x73, 0x29, 0x3b, 0x0a,
+ }
+}
+// Underscore.js 1.4.4
+// http://underscorejs.org
+// (c) 2009-2013 Jeremy Ashkenas, DocumentCloud Inc.
+// Underscore may be freely distributed under the MIT license.
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore/testify b/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore/testify
new file mode 100644
index 000000000..7f6e0f7c1
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore/testify
@@ -0,0 +1,84 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+my $underscore_test = shift @ARGV || "";
+if (!-d $underscore_test) {
+ print <<_END_;
+Usage:
+
+ testify ./underscore/test
+
+ # Should look something like:
+ arrays.js
+ chaining.js
+ collections.js
+ functions.js
+ index.html
+ objects.js
+ speed.js
+ utility.js
+ vendor
+
+_END_
+ if ($underscore_test) {
+ die "!: Not a directory: $underscore_test\n"
+ }
+ exit;
+}
+
+chdir $underscore_test or die "!: $!";
+
+my @js = <*.js>;
+
+for my $file (@js) {
+ open my $fh, '<', $file or die "!: $!";
+ my $tests = join "", <$fh>;
+ my @tests = $tests =~ m/
+ ^(\s{2}test\(.*?
+ ^\s{2}}\);)$
+ /mgxs;
+ close $fh;
+ next unless @tests;
+ print "$file: ", scalar(@tests), "\n";
+ my $underscore_name = "underscore_$file";
+ $underscore_name =~ s/.js$//;
+ my $go_file = "${underscore_name}_test.go";
+ $go_file =~ s/.js$/.go/;
+ open $fh, '>', $go_file or die "!: $!";
+
+ $fh->print(<<_END_);
+package otto
+
+import (
+ "testing"
+)
+
+_END_
+
+ my $count = 0;
+ for my $test (@tests) {
+ $test =~ s/`([^`]+)`/<$1>/g;
+ my ($name) = $test =~ m/^\s*test\(['"]([^'"]+)['"]/;
+ $fh->print(<<_END_);
+// $name
+func Test_${underscore_name}_$count(t *testing.T) {
+ tt(t, func(){
+ test := underscoreTest()
+
+ test(`
+$test
+ `)
+ })
+}
+
+_END_
+ $count++;
+ }
+}
+
+# test('#779 - delimeters are applied to unescaped text.', 1, function() {
+# var template = _.template('<<\nx\n>>', null, {evaluate: /<<(.*?)>>/g});
+# strictEqual(template(), '<<\nx\n>>');
+# });
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore/underscore.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore/underscore.go
new file mode 100644
index 000000000..714b8f3cf
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore/underscore.go
@@ -0,0 +1,49 @@
+/*
+Package underscore contains the source for the JavaScript utility-belt library.
+
+ import (
+ _ "github.com/robertkrimen/otto/underscore"
+ )
+ // Every Otto runtime will now include underscore
+
+http://underscorejs.org
+
+https://github.com/documentcloud/underscore
+
+By importing this package, you'll automatically load underscore every time you create a new Otto runtime.
+
+To prevent this behavior, you can do the following:
+
+ import (
+ "github.com/robertkrimen/otto/underscore"
+ )
+
+ func init() {
+ underscore.Disable()
+ }
+
+*/
+package underscore
+
+import (
+ "github.com/robertkrimen/otto/registry"
+)
+
+var entry *registry.Entry = registry.Register(func() string {
+ return Source()
+})
+
+// Enable underscore runtime inclusion.
+func Enable() {
+ entry.Enable()
+}
+
+// Disable underscore runtime inclusion.
+func Disable() {
+ entry.Disable()
+}
+
+// Source returns the underscore source.
+func Source() string {
+ return string(underscore())
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore_arrays_test.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore_arrays_test.go
new file mode 100644
index 000000000..9d6297820
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore_arrays_test.go
@@ -0,0 +1,344 @@
+package otto
+
+import (
+ "testing"
+)
+
+// first
+func Test_underscore_arrays_0(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("first", function() {
+ equal(_.first([1,2,3]), 1, 'can pull out the first element of an array');
+ equal(_([1, 2, 3]).first(), 1, 'can perform OO-style "first()"');
+ equal(_.first([1,2,3], 0).join(', '), "", 'can pass an index to first');
+ equal(_.first([1,2,3], 2).join(', '), '1, 2', 'can pass an index to first');
+ equal(_.first([1,2,3], 5).join(', '), '1, 2, 3', 'can pass an index to first');
+ var result = (function(){ return _.first(arguments); })(4, 3, 2, 1);
+ equal(result, 4, 'works on an arguments object.');
+ result = _.map([[1,2,3],[1,2,3]], _.first);
+ equal(result.join(','), '1,1', 'works well with _.map');
+ result = (function() { return _.take([1,2,3], 2); })();
+ equal(result.join(','), '1,2', 'aliased as take');
+
+ equal(_.first(null), undefined, 'handles nulls');
+ });
+ `)
+ })
+}
+
+// rest
+func Test_underscore_arrays_1(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("rest", function() {
+ var numbers = [1, 2, 3, 4];
+ equal(_.rest(numbers).join(", "), "2, 3, 4", 'working rest()');
+ equal(_.rest(numbers, 0).join(", "), "1, 2, 3, 4", 'working rest(0)');
+ equal(_.rest(numbers, 2).join(', '), '3, 4', 'rest can take an index');
+ var result = (function(){ return _(arguments).tail(); })(1, 2, 3, 4);
+ equal(result.join(', '), '2, 3, 4', 'aliased as tail and works on arguments object');
+ result = _.map([[1,2,3],[1,2,3]], _.rest);
+ equal(_.flatten(result).join(','), '2,3,2,3', 'works well with _.map');
+ result = (function(){ return _(arguments).drop(); })(1, 2, 3, 4);
+ equal(result.join(', '), '2, 3, 4', 'aliased as drop and works on arguments object');
+ });
+ `)
+ })
+}
+
+// initial
+func Test_underscore_arrays_2(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("initial", function() {
+ equal(_.initial([1,2,3,4,5]).join(", "), "1, 2, 3, 4", 'working initial()');
+ equal(_.initial([1,2,3,4],2).join(", "), "1, 2", 'initial can take an index');
+ var result = (function(){ return _(arguments).initial(); })(1, 2, 3, 4);
+ equal(result.join(", "), "1, 2, 3", 'initial works on arguments object');
+ result = _.map([[1,2,3],[1,2,3]], _.initial);
+ equal(_.flatten(result).join(','), '1,2,1,2', 'initial works with _.map');
+ });
+ `)
+ })
+}
+
+// last
+func Test_underscore_arrays_3(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("last", function() {
+ equal(_.last([1,2,3]), 3, 'can pull out the last element of an array');
+ equal(_.last([1,2,3], 0).join(', '), "", 'can pass an index to last');
+ equal(_.last([1,2,3], 2).join(', '), '2, 3', 'can pass an index to last');
+ equal(_.last([1,2,3], 5).join(', '), '1, 2, 3', 'can pass an index to last');
+ var result = (function(){ return _(arguments).last(); })(1, 2, 3, 4);
+ equal(result, 4, 'works on an arguments object');
+ result = _.map([[1,2,3],[1,2,3]], _.last);
+ equal(result.join(','), '3,3', 'works well with _.map');
+
+ equal(_.last(null), undefined, 'handles nulls');
+ });
+ `)
+ })
+}
+
+// compact
+func Test_underscore_arrays_4(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("compact", function() {
+ equal(_.compact([0, 1, false, 2, false, 3]).length, 3, 'can trim out all falsy values');
+ var result = (function(){ return _.compact(arguments).length; })(0, 1, false, 2, false, 3);
+ equal(result, 3, 'works on an arguments object');
+ });
+ `)
+ })
+}
+
+// flatten
+func Test_underscore_arrays_5(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("flatten", function() {
+ var list = [1, [2], [3, [[[4]]]]];
+ deepEqual(_.flatten(list), [1,2,3,4], 'can flatten nested arrays');
+ deepEqual(_.flatten(list, true), [1,2,3,[[[4]]]], 'can shallowly flatten nested arrays');
+ var result = (function(){ return _.flatten(arguments); })(1, [2], [3, [[[4]]]]);
+ deepEqual(result, [1,2,3,4], 'works on an arguments object');
+ });
+ `)
+ })
+}
+
+// without
+func Test_underscore_arrays_6(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("without", function() {
+ var list = [1, 2, 1, 0, 3, 1, 4];
+ equal(_.without(list, 0, 1).join(', '), '2, 3, 4', 'can remove all instances of an object');
+ var result = (function(){ return _.without(arguments, 0, 1); })(1, 2, 1, 0, 3, 1, 4);
+ equal(result.join(', '), '2, 3, 4', 'works on an arguments object');
+
+ var list = [{one : 1}, {two : 2}];
+ ok(_.without(list, {one : 1}).length == 2, 'uses real object identity for comparisons.');
+ ok(_.without(list, list[0]).length == 1, 'ditto.');
+ });
+ `)
+ })
+}
+
+// uniq
+func Test_underscore_arrays_7(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("uniq", function() {
+ var list = [1, 2, 1, 3, 1, 4];
+ equal(_.uniq(list).join(', '), '1, 2, 3, 4', 'can find the unique values of an unsorted array');
+
+ var list = [1, 1, 1, 2, 2, 3];
+ equal(_.uniq(list, true).join(', '), '1, 2, 3', 'can find the unique values of a sorted array faster');
+
+ var list = [{name:'moe'}, {name:'curly'}, {name:'larry'}, {name:'curly'}];
+ var iterator = function(value) { return value.name; };
+ equal(_.map(_.uniq(list, false, iterator), iterator).join(', '), 'moe, curly, larry', 'can find the unique values of an array using a custom iterator');
+
+ equal(_.map(_.uniq(list, iterator), iterator).join(', '), 'moe, curly, larry', 'can find the unique values of an array using a custom iterator without specifying whether array is sorted');
+
+ var iterator = function(value) { return value +1; };
+ var list = [1, 2, 2, 3, 4, 4];
+ equal(_.uniq(list, true, iterator).join(', '), '1, 2, 3, 4', 'iterator works with sorted array');
+
+ var result = (function(){ return _.uniq(arguments); })(1, 2, 1, 3, 1, 4);
+ equal(result.join(', '), '1, 2, 3, 4', 'works on an arguments object');
+ });
+ `)
+ })
+}
+
+// intersection
+func Test_underscore_arrays_8(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("intersection", function() {
+ var stooges = ['moe', 'curly', 'larry'], leaders = ['moe', 'groucho'];
+ equal(_.intersection(stooges, leaders).join(''), 'moe', 'can take the set intersection of two arrays');
+ equal(_(stooges).intersection(leaders).join(''), 'moe', 'can perform an OO-style intersection');
+ var result = (function(){ return _.intersection(arguments, leaders); })('moe', 'curly', 'larry');
+ equal(result.join(''), 'moe', 'works on an arguments object');
+ });
+ `)
+ })
+}
+
+// union
+func Test_underscore_arrays_9(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("union", function() {
+ var result = _.union([1, 2, 3], [2, 30, 1], [1, 40]);
+ equal(result.join(' '), '1 2 3 30 40', 'takes the union of a list of arrays');
+
+ var result = _.union([1, 2, 3], [2, 30, 1], [1, 40, [1]]);
+ equal(result.join(' '), '1 2 3 30 40 1', 'takes the union of a list of nested arrays');
+ });
+ `)
+ })
+}
+
+// difference
+func Test_underscore_arrays_10(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("difference", function() {
+ var result = _.difference([1, 2, 3], [2, 30, 40]);
+ equal(result.join(' '), '1 3', 'takes the difference of two arrays');
+
+ var result = _.difference([1, 2, 3, 4], [2, 30, 40], [1, 11, 111]);
+ equal(result.join(' '), '3 4', 'takes the difference of three arrays');
+ });
+ `)
+ })
+}
+
+// zip
+func Test_underscore_arrays_11(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('zip', function() {
+ var names = ['moe', 'larry', 'curly'], ages = [30, 40, 50], leaders = [true];
+ var stooges = _.zip(names, ages, leaders);
+ equal(String(stooges), 'moe,30,true,larry,40,,curly,50,', 'zipped together arrays of different lengths');
+ });
+ `)
+ })
+}
+
+// object
+func Test_underscore_arrays_12(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('object', function() {
+ var result = _.object(['moe', 'larry', 'curly'], [30, 40, 50]);
+ var shouldBe = {moe: 30, larry: 40, curly: 50};
+ ok(_.isEqual(result, shouldBe), 'two arrays zipped together into an object');
+
+ result = _.object([['one', 1], ['two', 2], ['three', 3]]);
+ shouldBe = {one: 1, two: 2, three: 3};
+ ok(_.isEqual(result, shouldBe), 'an array of pairs zipped together into an object');
+
+ var stooges = {moe: 30, larry: 40, curly: 50};
+ ok(_.isEqual(_.object(_.pairs(stooges)), stooges), 'an object converted to pairs and back to an object');
+
+ ok(_.isEqual(_.object(null), {}), 'handles nulls');
+ });
+ `)
+ })
+}
+
+// indexOf
+func Test_underscore_arrays_13(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("indexOf", function() {
+ var numbers = [1, 2, 3];
+ numbers.indexOf = null;
+ equal(_.indexOf(numbers, 2), 1, 'can compute indexOf, even without the native function');
+ var result = (function(){ return _.indexOf(arguments, 2); })(1, 2, 3);
+ equal(result, 1, 'works on an arguments object');
+ equal(_.indexOf(null, 2), -1, 'handles nulls properly');
+
+ var numbers = [10, 20, 30, 40, 50], num = 35;
+ var index = _.indexOf(numbers, num, true);
+ equal(index, -1, '35 is not in the list');
+
+ numbers = [10, 20, 30, 40, 50]; num = 40;
+ index = _.indexOf(numbers, num, true);
+ equal(index, 3, '40 is in the list');
+
+ numbers = [1, 40, 40, 40, 40, 40, 40, 40, 50, 60, 70]; num = 40;
+ index = _.indexOf(numbers, num, true);
+ equal(index, 1, '40 is in the list');
+
+ numbers = [1, 2, 3, 1, 2, 3, 1, 2, 3];
+ index = _.indexOf(numbers, 2, 5);
+ equal(index, 7, 'supports the fromIndex argument');
+ });
+ `)
+ })
+}
+
+// lastIndexOf
+func Test_underscore_arrays_14(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("lastIndexOf", function() {
+ var numbers = [1, 0, 1];
+ equal(_.lastIndexOf(numbers, 1), 2);
+
+ numbers = [1, 0, 1, 0, 0, 1, 0, 0, 0];
+ numbers.lastIndexOf = null;
+ equal(_.lastIndexOf(numbers, 1), 5, 'can compute lastIndexOf, even without the native function');
+ equal(_.lastIndexOf(numbers, 0), 8, 'lastIndexOf the other element');
+ var result = (function(){ return _.lastIndexOf(arguments, 1); })(1, 0, 1, 0, 0, 1, 0, 0, 0);
+ equal(result, 5, 'works on an arguments object');
+ equal(_.indexOf(null, 2), -1, 'handles nulls properly');
+
+ numbers = [1, 2, 3, 1, 2, 3, 1, 2, 3];
+ var index = _.lastIndexOf(numbers, 2, 2);
+ equal(index, 1, 'supports the fromIndex argument');
+ });
+ `)
+ })
+}
+
+// range
+func Test_underscore_arrays_15(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("range", function() {
+ equal(_.range(0).join(''), '', 'range with 0 as a first argument generates an empty array');
+ equal(_.range(4).join(' '), '0 1 2 3', 'range with a single positive argument generates an array of elements 0,1,2,...,n-1');
+ equal(_.range(5, 8).join(' '), '5 6 7', 'range with two arguments a &amp; b, a&lt;b generates an array of elements a,a+1,a+2,...,b-2,b-1');
+ equal(_.range(8, 5).join(''), '', 'range with two arguments a &amp; b, b&lt;a generates an empty array');
+ equal(_.range(3, 10, 3).join(' '), '3 6 9', 'range with three arguments a &amp; b &amp; c, c &lt; b-a, a &lt; b generates an array of elements a,a+c,a+2c,...,b - (multiplier of a) &lt; c');
+ equal(_.range(3, 10, 15).join(''), '3', 'range with three arguments a &amp; b &amp; c, c &gt; b-a, a &lt; b generates an array with a single element, equal to a');
+ equal(_.range(12, 7, -2).join(' '), '12 10 8', 'range with three arguments a &amp; b &amp; c, a &gt; b, c &lt; 0 generates an array of elements a,a-c,a-2c and ends with the number not less than b');
+ equal(_.range(0, -10, -1).join(' '), '0 -1 -2 -3 -4 -5 -6 -7 -8 -9', 'final example in the Python docs');
+ });
+ `)
+ })
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore_chaining_test.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore_chaining_test.go
new file mode 100644
index 000000000..accf04fdc
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore_chaining_test.go
@@ -0,0 +1,95 @@
+package otto
+
+import (
+ "testing"
+)
+
+// map/flatten/reduce
+func Test_underscore_chaining_0(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("map/flatten/reduce", function() {
+ var lyrics = [
+ "I'm a lumberjack and I'm okay",
+ "I sleep all night and I work all day",
+ "He's a lumberjack and he's okay",
+ "He sleeps all night and he works all day"
+ ];
+ var counts = _(lyrics).chain()
+ .map(function(line) { return line.split(''); })
+ .flatten()
+ .reduce(function(hash, l) {
+ hash[l] = hash[l] || 0;
+ hash[l]++;
+ return hash;
+ }, {}).value();
+ ok(counts['a'] == 16 && counts['e'] == 10, 'counted all the letters in the song');
+ });
+ `)
+ })
+}
+
+// select/reject/sortBy
+func Test_underscore_chaining_1(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("select/reject/sortBy", function() {
+ var numbers = [1,2,3,4,5,6,7,8,9,10];
+ numbers = _(numbers).chain().select(function(n) {
+ return n % 2 == 0;
+ }).reject(function(n) {
+ return n % 4 == 0;
+ }).sortBy(function(n) {
+ return -n;
+ }).value();
+ equal(numbers.join(', '), "10, 6, 2", "filtered and reversed the numbers");
+ });
+ `)
+ })
+}
+
+// select/reject/sortBy in functional style
+func Test_underscore_chaining_2(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("select/reject/sortBy in functional style", function() {
+ var numbers = [1,2,3,4,5,6,7,8,9,10];
+ numbers = _.chain(numbers).select(function(n) {
+ return n % 2 == 0;
+ }).reject(function(n) {
+ return n % 4 == 0;
+ }).sortBy(function(n) {
+ return -n;
+ }).value();
+ equal(numbers.join(', '), "10, 6, 2", "filtered and reversed the numbers");
+ });
+ `)
+ })
+}
+
+// reverse/concat/unshift/pop/map
+func Test_underscore_chaining_3(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("reverse/concat/unshift/pop/map", function() {
+ var numbers = [1,2,3,4,5];
+ numbers = _(numbers).chain()
+ .reverse()
+ .concat([5, 5, 5])
+ .unshift(17)
+ .pop()
+ .map(function(n){ return n * 2; })
+ .value();
+ equal(numbers.join(', '), "34, 10, 8, 6, 4, 2, 10, 10", 'can chain together array functions.');
+ });
+ `)
+ })
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore_collections_test.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore_collections_test.go
new file mode 100644
index 000000000..9afc2a2b2
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore_collections_test.go
@@ -0,0 +1,698 @@
+package otto
+
+import (
+ "testing"
+)
+
+// each
+func Test_underscore_collections_0(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("each", function() {
+ _.each([1, 2, 3], function(num, i) {
+ equal(num, i + 1, 'each iterators provide value and iteration count');
+ });
+
+ var answers = [];
+ _.each([1, 2, 3], function(num){ answers.push(num * this.multiplier);}, {multiplier : 5});
+ equal(answers.join(', '), '5, 10, 15', 'context object property accessed');
+
+ answers = [];
+ _.forEach([1, 2, 3], function(num){ answers.push(num); });
+ equal(answers.join(', '), '1, 2, 3', 'aliased as "forEach"');
+
+ answers = [];
+ var obj = {one : 1, two : 2, three : 3};
+ obj.constructor.prototype.four = 4;
+ _.each(obj, function(value, key){ answers.push(key); });
+ equal(answers.join(", "), 'one, two, three', 'iterating over objects works, and ignores the object prototype.');
+ delete obj.constructor.prototype.four;
+
+ var answer = null;
+ _.each([1, 2, 3], function(num, index, arr){ if (_.include(arr, num)) answer = true; });
+ ok(answer, 'can reference the original collection from inside the iterator');
+
+ answers = 0;
+ _.each(null, function(){ ++answers; });
+ equal(answers, 0, 'handles a null properly');
+ });
+ `)
+ })
+}
+
+// map
+func Test_underscore_collections_1(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('map', function() {
+ var doubled = _.map([1, 2, 3], function(num){ return num * 2; });
+ equal(doubled.join(', '), '2, 4, 6', 'doubled numbers');
+
+ doubled = _.collect([1, 2, 3], function(num){ return num * 2; });
+ equal(doubled.join(', '), '2, 4, 6', 'aliased as "collect"');
+
+ var tripled = _.map([1, 2, 3], function(num){ return num * this.multiplier; }, {multiplier : 3});
+ equal(tripled.join(', '), '3, 6, 9', 'tripled numbers with context');
+
+ var doubled = _([1, 2, 3]).map(function(num){ return num * 2; });
+ equal(doubled.join(', '), '2, 4, 6', 'OO-style doubled numbers');
+
+ // TEST: ReferenceError: document is not defined
+ return;
+
+ if (document.querySelectorAll) {
+ var ids = _.map(document.querySelectorAll('#map-test *'), function(n){ return n.id; });
+ deepEqual(ids, ['id1', 'id2'], 'Can use collection methods on NodeLists.');
+ }
+
+ var ids = _.map($('#map-test').children(), function(n){ return n.id; });
+ deepEqual(ids, ['id1', 'id2'], 'Can use collection methods on jQuery Array-likes.');
+
+ var ids = _.map(document.images, function(n){ return n.id; });
+ ok(ids[0] == 'chart_image', 'can use collection methods on HTMLCollections');
+
+ var ifnull = _.map(null, function(){});
+ ok(_.isArray(ifnull) && ifnull.length === 0, 'handles a null properly');
+ });
+ `)
+ })
+}
+
+// reduce
+func Test_underscore_collections_2(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('reduce', function() {
+ var sum = _.reduce([1, 2, 3], function(sum, num){ return sum + num; }, 0);
+ equal(sum, 6, 'can sum up an array');
+
+ var context = {multiplier : 3};
+ sum = _.reduce([1, 2, 3], function(sum, num){ return sum + num * this.multiplier; }, 0, context);
+ equal(sum, 18, 'can reduce with a context object');
+
+ sum = _.inject([1, 2, 3], function(sum, num){ return sum + num; }, 0);
+ equal(sum, 6, 'aliased as "inject"');
+
+ sum = _([1, 2, 3]).reduce(function(sum, num){ return sum + num; }, 0);
+ equal(sum, 6, 'OO-style reduce');
+
+ var sum = _.reduce([1, 2, 3], function(sum, num){ return sum + num; });
+ equal(sum, 6, 'default initial value');
+
+ var ifnull;
+ try {
+ _.reduce(null, function(){});
+ } catch (ex) {
+ ifnull = ex;
+ }
+ ok(ifnull instanceof TypeError, 'handles a null (without inital value) properly');
+
+ ok(_.reduce(null, function(){}, 138) === 138, 'handles a null (with initial value) properly');
+ equal(_.reduce([], function(){}, undefined), undefined, 'undefined can be passed as a special case');
+ raises(function() { _.reduce([], function(){}); }, TypeError, 'throws an error for empty arrays with no initial value');
+ });
+ `)
+ })
+}
+
+// reduceRight
+func Test_underscore_collections_3(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('reduceRight', function() {
+ var list = _.reduceRight(["foo", "bar", "baz"], function(memo, str){ return memo + str; }, '');
+ equal(list, 'bazbarfoo', 'can perform right folds');
+
+ var list = _.foldr(["foo", "bar", "baz"], function(memo, str){ return memo + str; }, '');
+ equal(list, 'bazbarfoo', 'aliased as "foldr"');
+
+ var list = _.foldr(["foo", "bar", "baz"], function(memo, str){ return memo + str; });
+ equal(list, 'bazbarfoo', 'default initial value');
+
+ var ifnull;
+ try {
+ _.reduceRight(null, function(){});
+ } catch (ex) {
+ ifnull = ex;
+ }
+ ok(ifnull instanceof TypeError, 'handles a null (without inital value) properly');
+
+ var sum = _.reduceRight({a: 1, b: 2, c: 3}, function(sum, num){ return sum + num; });
+ equal(sum, 6, 'default initial value on object');
+
+ ok(_.reduceRight(null, function(){}, 138) === 138, 'handles a null (with initial value) properly');
+
+ equal(_.reduceRight([], function(){}, undefined), undefined, 'undefined can be passed as a special case');
+ raises(function() { _.reduceRight([], function(){}); }, TypeError, 'throws an error for empty arrays with no initial value');
+
+ // Assert that the correct arguments are being passed.
+
+ var args,
+ memo = {},
+ object = {a: 1, b: 2},
+ lastKey = _.keys(object).pop();
+
+ var expected = lastKey == 'a'
+ ? [memo, 1, 'a', object]
+ : [memo, 2, 'b', object];
+
+ _.reduceRight(object, function() {
+ args || (args = _.toArray(arguments));
+ }, memo);
+
+ deepEqual(args, expected);
+
+ // And again, with numeric keys.
+
+ object = {'2': 'a', '1': 'b'};
+ lastKey = _.keys(object).pop();
+ args = null;
+
+ expected = lastKey == '2'
+ ? [memo, 'a', '2', object]
+ : [memo, 'b', '1', object];
+
+ _.reduceRight(object, function() {
+ args || (args = _.toArray(arguments));
+ }, memo);
+
+ deepEqual(args, expected);
+ });
+ `)
+ })
+}
+
+// find
+func Test_underscore_collections_4(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('find', function() {
+ var array = [1, 2, 3, 4];
+ strictEqual(_.find(array, function(n) { return n > 2; }), 3, 'should return first found <value>');
+ strictEqual(_.find(array, function() { return false; }), void 0, 'should return <undefined> if <value> is not found');
+ });
+ `)
+ })
+}
+
+// detect
+func Test_underscore_collections_5(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('detect', function() {
+ var result = _.detect([1, 2, 3], function(num){ return num * 2 == 4; });
+ equal(result, 2, 'found the first "2" and broke the loop');
+ });
+ `)
+ })
+}
+
+// select
+func Test_underscore_collections_6(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('select', function() {
+ var evens = _.select([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });
+ equal(evens.join(', '), '2, 4, 6', 'selected each even number');
+
+ evens = _.filter([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });
+ equal(evens.join(', '), '2, 4, 6', 'aliased as "filter"');
+ });
+ `)
+ })
+}
+
+// reject
+func Test_underscore_collections_7(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('reject', function() {
+ var odds = _.reject([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });
+ equal(odds.join(', '), '1, 3, 5', 'rejected each even number');
+
+ var context = "obj";
+
+ var evens = _.reject([1, 2, 3, 4, 5, 6], function(num){
+ equal(context, "obj");
+ return num % 2 != 0;
+ }, context);
+ equal(evens.join(', '), '2, 4, 6', 'rejected each odd number');
+ });
+ `)
+ })
+}
+
+// all
+func Test_underscore_collections_8(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('all', function() {
+ ok(_.all([], _.identity), 'the empty set');
+ ok(_.all([true, true, true], _.identity), 'all true values');
+ ok(!_.all([true, false, true], _.identity), 'one false value');
+ ok(_.all([0, 10, 28], function(num){ return num % 2 == 0; }), 'even numbers');
+ ok(!_.all([0, 11, 28], function(num){ return num % 2 == 0; }), 'an odd number');
+ ok(_.all([1], _.identity) === true, 'cast to boolean - true');
+ ok(_.all([0], _.identity) === false, 'cast to boolean - false');
+ ok(_.every([true, true, true], _.identity), 'aliased as "every"');
+ ok(!_.all([undefined, undefined, undefined], _.identity), 'works with arrays of undefined');
+ });
+ `)
+ })
+}
+
+// any
+func Test_underscore_collections_9(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('any', function() {
+ var nativeSome = Array.prototype.some;
+ Array.prototype.some = null;
+ ok(!_.any([]), 'the empty set');
+ ok(!_.any([false, false, false]), 'all false values');
+ ok(_.any([false, false, true]), 'one true value');
+ ok(_.any([null, 0, 'yes', false]), 'a string');
+ ok(!_.any([null, 0, '', false]), 'falsy values');
+ ok(!_.any([1, 11, 29], function(num){ return num % 2 == 0; }), 'all odd numbers');
+ ok(_.any([1, 10, 29], function(num){ return num % 2 == 0; }), 'an even number');
+ ok(_.any([1], _.identity) === true, 'cast to boolean - true');
+ ok(_.any([0], _.identity) === false, 'cast to boolean - false');
+ ok(_.some([false, false, true]), 'aliased as "some"');
+ Array.prototype.some = nativeSome;
+ });
+ `)
+ })
+}
+
+// include
+func Test_underscore_collections_10(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('include', function() {
+ ok(_.include([1,2,3], 2), 'two is in the array');
+ ok(!_.include([1,3,9], 2), 'two is not in the array');
+ ok(_.contains({moe:1, larry:3, curly:9}, 3) === true, '_.include on objects checks their values');
+ ok(_([1,2,3]).include(2), 'OO-style include');
+ });
+ `)
+ })
+}
+
+// invoke
+func Test_underscore_collections_11(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('invoke', function() {
+ var list = [[5, 1, 7], [3, 2, 1]];
+ var result = _.invoke(list, 'sort');
+ equal(result[0].join(', '), '1, 5, 7', 'first array sorted');
+ equal(result[1].join(', '), '1, 2, 3', 'second array sorted');
+ });
+ `)
+ })
+}
+
+// invoke w/ function reference
+func Test_underscore_collections_12(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('invoke w/ function reference', function() {
+ var list = [[5, 1, 7], [3, 2, 1]];
+ var result = _.invoke(list, Array.prototype.sort);
+ equal(result[0].join(', '), '1, 5, 7', 'first array sorted');
+ equal(result[1].join(', '), '1, 2, 3', 'second array sorted');
+ });
+ `)
+ })
+}
+
+// invoke when strings have a call method
+func Test_underscore_collections_13(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('invoke when strings have a call method', function() {
+ String.prototype.call = function() {
+ return 42;
+ };
+ var list = [[5, 1, 7], [3, 2, 1]];
+ var s = "foo";
+ equal(s.call(), 42, "call function exists");
+ var result = _.invoke(list, 'sort');
+ equal(result[0].join(', '), '1, 5, 7', 'first array sorted');
+ equal(result[1].join(', '), '1, 2, 3', 'second array sorted');
+ delete String.prototype.call;
+ equal(s.call, undefined, "call function removed");
+ });
+ `)
+ })
+}
+
+// pluck
+func Test_underscore_collections_14(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('pluck', function() {
+ var people = [{name : 'moe', age : 30}, {name : 'curly', age : 50}];
+ equal(_.pluck(people, 'name').join(', '), 'moe, curly', 'pulls names out of objects');
+ });
+ `)
+ })
+}
+
+// where
+func Test_underscore_collections_15(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('where', function() {
+ var list = [{a: 1, b: 2}, {a: 2, b: 2}, {a: 1, b: 3}, {a: 1, b: 4}];
+ var result = _.where(list, {a: 1});
+ equal(result.length, 3);
+ equal(result[result.length - 1].b, 4);
+ result = _.where(list, {b: 2});
+ equal(result.length, 2);
+ equal(result[0].a, 1);
+ });
+ `)
+ })
+}
+
+// findWhere
+func Test_underscore_collections_16(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('findWhere', function() {
+ var list = [{a: 1, b: 2}, {a: 2, b: 2}, {a: 1, b: 3}, {a: 1, b: 4}, {a: 2, b: 4}];
+ var result = _.findWhere(list, {a: 1});
+ deepEqual(result, {a: 1, b: 2});
+ result = _.findWhere(list, {b: 4});
+ deepEqual(result, {a: 1, b: 4});
+ });
+ `)
+ })
+}
+
+// max
+func Test_underscore_collections_17(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('max', function() {
+ equal(3, _.max([1, 2, 3]), 'can perform a regular Math.max');
+
+ var neg = _.max([1, 2, 3], function(num){ return -num; });
+ equal(neg, 1, 'can perform a computation-based max');
+
+ equal(-Infinity, _.max({}), 'Maximum value of an empty object');
+ equal(-Infinity, _.max([]), 'Maximum value of an empty array');
+ equal(_.max({'a': 'a'}), -Infinity, 'Maximum value of a non-numeric collection');
+
+ // TEST: Takes too long
+ return;
+
+ equal(299999, _.max(_.range(1,300000)), "Maximum value of a too-big array");
+ });
+ `)
+ })
+}
+
+// min
+func Test_underscore_collections_18(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('min', function() {
+ equal(1, _.min([1, 2, 3]), 'can perform a regular Math.min');
+
+ var neg = _.min([1, 2, 3], function(num){ return -num; });
+ equal(neg, 3, 'can perform a computation-based min');
+
+ equal(Infinity, _.min({}), 'Minimum value of an empty object');
+ equal(Infinity, _.min([]), 'Minimum value of an empty array');
+ equal(_.min({'a': 'a'}), Infinity, 'Minimum value of a non-numeric collection');
+
+ var now = new Date(9999999999);
+ var then = new Date(0);
+ equal(_.min([now, then]), then);
+
+ // TEST: Takes too long
+ return;
+
+ equal(1, _.min(_.range(1,300000)), "Minimum value of a too-big array");
+ });
+ `)
+ })
+}
+
+// sortBy
+func Test_underscore_collections_19(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('sortBy', function() {
+ var people = [{name : 'curly', age : 50}, {name : 'moe', age : 30}];
+ people = _.sortBy(people, function(person){ return person.age; });
+ equal(_.pluck(people, 'name').join(', '), 'moe, curly', 'stooges sorted by age');
+
+ var list = [undefined, 4, 1, undefined, 3, 2];
+ equal(_.sortBy(list, _.identity).join(','), '1,2,3,4,,', 'sortBy with undefined values');
+
+ var list = ["one", "two", "three", "four", "five"];
+ var sorted = _.sortBy(list, 'length');
+ equal(sorted.join(' '), 'one two four five three', 'sorted by length');
+
+ function Pair(x, y) {
+ this.x = x;
+ this.y = y;
+ }
+
+ var collection = [
+ new Pair(1, 1), new Pair(1, 2),
+ new Pair(1, 3), new Pair(1, 4),
+ new Pair(1, 5), new Pair(1, 6),
+ new Pair(2, 1), new Pair(2, 2),
+ new Pair(2, 3), new Pair(2, 4),
+ new Pair(2, 5), new Pair(2, 6),
+ new Pair(undefined, 1), new Pair(undefined, 2),
+ new Pair(undefined, 3), new Pair(undefined, 4),
+ new Pair(undefined, 5), new Pair(undefined, 6)
+ ];
+
+ var actual = _.sortBy(collection, function(pair) {
+ return pair.x;
+ });
+
+ deepEqual(actual, collection, 'sortBy should be stable');
+ });
+ `)
+ })
+}
+
+// groupBy
+func Test_underscore_collections_20(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('groupBy', function() {
+ var parity = _.groupBy([1, 2, 3, 4, 5, 6], function(num){ return num % 2; });
+ ok('0' in parity && '1' in parity, 'created a group for each value');
+ equal(parity[0].join(', '), '2, 4, 6', 'put each even number in the right group');
+
+ var list = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"];
+ var grouped = _.groupBy(list, 'length');
+ equal(grouped['3'].join(' '), 'one two six ten');
+ equal(grouped['4'].join(' '), 'four five nine');
+ equal(grouped['5'].join(' '), 'three seven eight');
+
+ var context = {};
+ _.groupBy([{}], function(){ ok(this === context); }, context);
+
+ grouped = _.groupBy([4.2, 6.1, 6.4], function(num) {
+ return Math.floor(num) > 4 ? 'hasOwnProperty' : 'constructor';
+ });
+ equal(grouped.constructor.length, 1);
+ equal(grouped.hasOwnProperty.length, 2);
+
+ var array = [{}];
+ _.groupBy(array, function(value, index, obj){ ok(obj === array); });
+
+ var array = [1, 2, 1, 2, 3];
+ var grouped = _.groupBy(array);
+ equal(grouped['1'].length, 2);
+ equal(grouped['3'].length, 1);
+ });
+ `)
+ })
+}
+
+// countBy
+func Test_underscore_collections_21(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('countBy', function() {
+ var parity = _.countBy([1, 2, 3, 4, 5], function(num){ return num % 2 == 0; });
+ equal(parity['true'], 2);
+ equal(parity['false'], 3);
+
+ var list = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"];
+ var grouped = _.countBy(list, 'length');
+ equal(grouped['3'], 4);
+ equal(grouped['4'], 3);
+ equal(grouped['5'], 3);
+
+ var context = {};
+ _.countBy([{}], function(){ ok(this === context); }, context);
+
+ grouped = _.countBy([4.2, 6.1, 6.4], function(num) {
+ return Math.floor(num) > 4 ? 'hasOwnProperty' : 'constructor';
+ });
+ equal(grouped.constructor, 1);
+ equal(grouped.hasOwnProperty, 2);
+
+ var array = [{}];
+ _.countBy(array, function(value, index, obj){ ok(obj === array); });
+
+ var array = [1, 2, 1, 2, 3];
+ var grouped = _.countBy(array);
+ equal(grouped['1'], 2);
+ equal(grouped['3'], 1);
+ });
+ `)
+ })
+}
+
+// sortedIndex
+func Test_underscore_collections_22(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('sortedIndex', function() {
+ var numbers = [10, 20, 30, 40, 50], num = 35;
+ var indexForNum = _.sortedIndex(numbers, num);
+ equal(indexForNum, 3, '35 should be inserted at index 3');
+
+ var indexFor30 = _.sortedIndex(numbers, 30);
+ equal(indexFor30, 2, '30 should be inserted at index 2');
+
+ var objects = [{x: 10}, {x: 20}, {x: 30}, {x: 40}];
+ var iterator = function(obj){ return obj.x; };
+ strictEqual(_.sortedIndex(objects, {x: 25}, iterator), 2);
+ strictEqual(_.sortedIndex(objects, {x: 35}, 'x'), 3);
+
+ var context = {1: 2, 2: 3, 3: 4};
+ iterator = function(obj){ return this[obj]; };
+ strictEqual(_.sortedIndex([1, 3], 2, iterator, context), 1);
+ });
+ `)
+ })
+}
+
+// shuffle
+func Test_underscore_collections_23(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('shuffle', function() {
+ var numbers = _.range(10);
+ var shuffled = _.shuffle(numbers).sort();
+ notStrictEqual(numbers, shuffled, 'original object is unmodified');
+ equal(shuffled.join(','), numbers.join(','), 'contains the same members before and after shuffle');
+ });
+ `)
+ })
+}
+
+// toArray
+func Test_underscore_collections_24(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('toArray', function() {
+ ok(!_.isArray(arguments), 'arguments object is not an array');
+ ok(_.isArray(_.toArray(arguments)), 'arguments object converted into array');
+ var a = [1,2,3];
+ ok(_.toArray(a) !== a, 'array is cloned');
+ equal(_.toArray(a).join(', '), '1, 2, 3', 'cloned array contains same elements');
+
+ var numbers = _.toArray({one : 1, two : 2, three : 3});
+ equal(numbers.join(', '), '1, 2, 3', 'object flattened into array');
+
+ // TEST: ReferenceError: document is not defined
+ return;
+
+ // test in IE < 9
+ try {
+ var actual = _.toArray(document.childNodes);
+ } catch(ex) { }
+
+ ok(_.isArray(actual), 'should not throw converting a node list');
+ });
+ `)
+ })
+}
+
+// size
+func Test_underscore_collections_25(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('size', function() {
+ equal(_.size({one : 1, two : 2, three : 3}), 3, 'can compute the size of an object');
+ equal(_.size([1, 2, 3]), 3, 'can compute the size of an array');
+
+ var func = function() {
+ return _.size(arguments);
+ };
+
+ equal(func(1, 2, 3, 4), 4, 'can test the size of the arguments object');
+
+ equal(_.size('hello'), 5, 'can compute the size of a string');
+
+ equal(_.size(null), 0, 'handles nulls');
+ });
+ `)
+ })
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore_functions_test.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore_functions_test.go
new file mode 100644
index 000000000..be59e16b3
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore_functions_test.go
@@ -0,0 +1,208 @@
+package otto
+
+import (
+ "testing"
+)
+
+// bind
+func Test_underscore_functions_0(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("bind", function() {
+ var context = {name : 'moe'};
+ var func = function(arg) { return "name: " + (this.name || arg); };
+ var bound = _.bind(func, context);
+ equal(bound(), 'name: moe', 'can bind a function to a context');
+
+ bound = _(func).bind(context);
+ equal(bound(), 'name: moe', 'can do OO-style binding');
+
+ bound = _.bind(func, null, 'curly');
+ equal(bound(), 'name: curly', 'can bind without specifying a context');
+
+ func = function(salutation, name) { return salutation + ': ' + name; };
+ func = _.bind(func, this, 'hello');
+ equal(func('moe'), 'hello: moe', 'the function was partially applied in advance');
+
+ func = _.bind(func, this, 'curly');
+ equal(func(), 'hello: curly', 'the function was completely applied in advance');
+
+ func = function(salutation, firstname, lastname) { return salutation + ': ' + firstname + ' ' + lastname; };
+ func = _.bind(func, this, 'hello', 'moe', 'curly');
+ equal(func(), 'hello: moe curly', 'the function was partially applied in advance and can accept multiple arguments');
+
+ func = function(context, message) { equal(this, context, message); };
+ _.bind(func, 0, 0, 'can bind a function to <0>')();
+ _.bind(func, '', '', 'can bind a function to an empty string')();
+ _.bind(func, false, false, 'can bind a function to <false>')();
+
+ // These tests are only meaningful when using a browser without a native bind function
+ // To test this with a modern browser, set underscore's nativeBind to undefined
+ var F = function () { return this; };
+ var Boundf = _.bind(F, {hello: "moe curly"});
+ equal(Boundf().hello, "moe curly", "When called without the new operator, it's OK to be bound to the context");
+ });
+ `)
+ })
+}
+
+// partial
+func Test_underscore_functions_1(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("partial", function() {
+ var obj = {name: 'moe'};
+ var func = function() { return this.name + ' ' + _.toArray(arguments).join(' '); };
+
+ obj.func = _.partial(func, 'a', 'b');
+ equal(obj.func('c', 'd'), 'moe a b c d', 'can partially apply');
+ });
+ `)
+ })
+}
+
+// bindAll
+func Test_underscore_functions_2(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("bindAll", function() {
+ var curly = {name : 'curly'}, moe = {
+ name : 'moe',
+ getName : function() { return 'name: ' + this.name; },
+ sayHi : function() { return 'hi: ' + this.name; }
+ };
+ curly.getName = moe.getName;
+ _.bindAll(moe, 'getName', 'sayHi');
+ curly.sayHi = moe.sayHi;
+ equal(curly.getName(), 'name: curly', 'unbound function is bound to current object');
+ equal(curly.sayHi(), 'hi: moe', 'bound function is still bound to original object');
+
+ curly = {name : 'curly'};
+ moe = {
+ name : 'moe',
+ getName : function() { return 'name: ' + this.name; },
+ sayHi : function() { return 'hi: ' + this.name; }
+ };
+ _.bindAll(moe);
+ curly.sayHi = moe.sayHi;
+ equal(curly.sayHi(), 'hi: moe', 'calling bindAll with no arguments binds all functions to the object');
+ });
+ `)
+ })
+}
+
+// memoize
+func Test_underscore_functions_3(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("memoize", function() {
+ var fib = function(n) {
+ return n < 2 ? n : fib(n - 1) + fib(n - 2);
+ };
+ var fastFib = _.memoize(fib);
+ equal(fib(10), 55, 'a memoized version of fibonacci produces identical results');
+ equal(fastFib(10), 55, 'a memoized version of fibonacci produces identical results');
+
+ var o = function(str) {
+ return str;
+ };
+ var fastO = _.memoize(o);
+ equal(o('toString'), 'toString', 'checks hasOwnProperty');
+ equal(fastO('toString'), 'toString', 'checks hasOwnProperty');
+ });
+ `)
+ })
+}
+
+// once
+func Test_underscore_functions_4(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("once", function() {
+ var num = 0;
+ var increment = _.once(function(){ num++; });
+ increment();
+ increment();
+ equal(num, 1);
+ });
+ `)
+ })
+}
+
+// wrap
+func Test_underscore_functions_5(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("wrap", function() {
+ var greet = function(name){ return "hi: " + name; };
+ var backwards = _.wrap(greet, function(func, name){ return func(name) + ' ' + name.split('').reverse().join(''); });
+ equal(backwards('moe'), 'hi: moe eom', 'wrapped the saluation function');
+
+ var inner = function(){ return "Hello "; };
+ var obj = {name : "Moe"};
+ obj.hi = _.wrap(inner, function(fn){ return fn() + this.name; });
+ equal(obj.hi(), "Hello Moe");
+
+ var noop = function(){};
+ var wrapped = _.wrap(noop, function(fn){ return Array.prototype.slice.call(arguments, 0); });
+ var ret = wrapped(['whats', 'your'], 'vector', 'victor');
+ deepEqual(ret, [noop, ['whats', 'your'], 'vector', 'victor']);
+ });
+ `)
+ })
+}
+
+// compose
+func Test_underscore_functions_6(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("compose", function() {
+ var greet = function(name){ return "hi: " + name; };
+ var exclaim = function(sentence){ return sentence + '!'; };
+ var composed = _.compose(exclaim, greet);
+ equal(composed('moe'), 'hi: moe!', 'can compose a function that takes another');
+
+ composed = _.compose(greet, exclaim);
+ equal(composed('moe'), 'hi: moe!', 'in this case, the functions are also commutative');
+ });
+ `)
+ })
+}
+
+// after
+func Test_underscore_functions_7(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("after", function() {
+ var testAfter = function(afterAmount, timesCalled) {
+ var afterCalled = 0;
+ var after = _.after(afterAmount, function() {
+ afterCalled++;
+ });
+ while (timesCalled--) after();
+ return afterCalled;
+ };
+
+ equal(testAfter(5, 5), 1, "after(N) should fire after being called N times");
+ equal(testAfter(5, 4), 0, "after(N) should not fire unless called N times");
+ equal(testAfter(0, 0), 1, "after(0) should fire immediately");
+ });
+ `)
+ })
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore_objects_test.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore_objects_test.go
new file mode 100644
index 000000000..1973af8dd
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore_objects_test.go
@@ -0,0 +1,826 @@
+package otto
+
+import (
+ "testing"
+)
+
+// keys
+func Test_underscore_objects_0(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("keys", function() {
+ equal(_.keys({one : 1, two : 2}).join(', '), 'one, two', 'can extract the keys from an object');
+ // the test above is not safe because it relies on for-in enumeration order
+ var a = []; a[1] = 0;
+ equal(_.keys(a).join(', '), '1', 'is not fooled by sparse arrays; see issue #95');
+ raises(function() { _.keys(null); }, TypeError, 'throws an error for <null> values');
+ raises(function() { _.keys(void 0); }, TypeError, 'throws an error for <undefined> values');
+ raises(function() { _.keys(1); }, TypeError, 'throws an error for number primitives');
+ raises(function() { _.keys('a'); }, TypeError, 'throws an error for string primitives');
+ raises(function() { _.keys(true); }, TypeError, 'throws an error for boolean primitives');
+ });
+ `)
+ })
+}
+
+// values
+func Test_underscore_objects_1(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("values", function() {
+ equal(_.values({one: 1, two: 2}).join(', '), '1, 2', 'can extract the values from an object');
+ equal(_.values({one: 1, two: 2, length: 3}).join(', '), '1, 2, 3', '... even when one of them is "length"');
+ });
+ `)
+ })
+}
+
+// pairs
+func Test_underscore_objects_2(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("pairs", function() {
+ deepEqual(_.pairs({one: 1, two: 2}), [['one', 1], ['two', 2]], 'can convert an object into pairs');
+ deepEqual(_.pairs({one: 1, two: 2, length: 3}), [['one', 1], ['two', 2], ['length', 3]], '... even when one of them is "length"');
+ });
+ `)
+ })
+}
+
+// invert
+func Test_underscore_objects_3(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("invert", function() {
+ var obj = {first: 'Moe', second: 'Larry', third: 'Curly'};
+ equal(_.keys(_.invert(obj)).join(' '), 'Moe Larry Curly', 'can invert an object');
+ ok(_.isEqual(_.invert(_.invert(obj)), obj), 'two inverts gets you back where you started');
+
+ var obj = {length: 3};
+ ok(_.invert(obj)['3'] == 'length', 'can invert an object with "length"')
+ });
+ `)
+ })
+}
+
+// functions
+func Test_underscore_objects_4(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("functions", function() {
+ var obj = {a : 'dash', b : _.map, c : (/yo/), d : _.reduce};
+ ok(_.isEqual(['b', 'd'], _.functions(obj)), 'can grab the function names of any passed-in object');
+
+ var Animal = function(){};
+ Animal.prototype.run = function(){};
+ equal(_.functions(new Animal).join(''), 'run', 'also looks up functions on the prototype');
+ });
+ `)
+ })
+}
+
+// extend
+func Test_underscore_objects_5(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("extend", function() {
+ var result;
+ equal(_.extend({}, {a:'b'}).a, 'b', 'can extend an object with the attributes of another');
+ equal(_.extend({a:'x'}, {a:'b'}).a, 'b', 'properties in source override destination');
+ equal(_.extend({x:'x'}, {a:'b'}).x, 'x', 'properties not in source dont get overriden');
+ result = _.extend({x:'x'}, {a:'a'}, {b:'b'});
+ ok(_.isEqual(result, {x:'x', a:'a', b:'b'}), 'can extend from multiple source objects');
+ result = _.extend({x:'x'}, {a:'a', x:2}, {a:'b'});
+ ok(_.isEqual(result, {x:2, a:'b'}), 'extending from multiple source objects last property trumps');
+ result = _.extend({}, {a: void 0, b: null});
+ equal(_.keys(result).join(''), 'ab', 'extend does not copy undefined values');
+
+ try {
+ result = {};
+ _.extend(result, null, undefined, {a:1});
+ } catch(ex) {}
+
+ equal(result.a, 1, 'should not error on <null> or <undefined> sources');
+ });
+ `)
+ })
+}
+
+// pick
+func Test_underscore_objects_6(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("pick", function() {
+ var result;
+ result = _.pick({a:1, b:2, c:3}, 'a', 'c');
+ ok(_.isEqual(result, {a:1, c:3}), 'can restrict properties to those named');
+ result = _.pick({a:1, b:2, c:3}, ['b', 'c']);
+ ok(_.isEqual(result, {b:2, c:3}), 'can restrict properties to those named in an array');
+ result = _.pick({a:1, b:2, c:3}, ['a'], 'b');
+ ok(_.isEqual(result, {a:1, b:2}), 'can restrict properties to those named in mixed args');
+
+ var Obj = function(){};
+ Obj.prototype = {a: 1, b: 2, c: 3};
+ ok(_.isEqual(_.pick(new Obj, 'a', 'c'), {a:1, c: 3}), 'include prototype props');
+ });
+ `)
+ })
+}
+
+// omit
+func Test_underscore_objects_7(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("omit", function() {
+ var result;
+ result = _.omit({a:1, b:2, c:3}, 'b');
+ ok(_.isEqual(result, {a:1, c:3}), 'can omit a single named property');
+ result = _.omit({a:1, b:2, c:3}, 'a', 'c');
+ ok(_.isEqual(result, {b:2}), 'can omit several named properties');
+ result = _.omit({a:1, b:2, c:3}, ['b', 'c']);
+ ok(_.isEqual(result, {a:1}), 'can omit properties named in an array');
+
+ var Obj = function(){};
+ Obj.prototype = {a: 1, b: 2, c: 3};
+ ok(_.isEqual(_.omit(new Obj, 'b'), {a:1, c: 3}), 'include prototype props');
+ });
+ `)
+ })
+}
+
+// defaults
+func Test_underscore_objects_8(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("defaults", function() {
+ var result;
+ var options = {zero: 0, one: 1, empty: "", nan: NaN, string: "string"};
+
+ _.defaults(options, {zero: 1, one: 10, twenty: 20});
+ equal(options.zero, 0, 'value exists');
+ equal(options.one, 1, 'value exists');
+ equal(options.twenty, 20, 'default applied');
+
+ _.defaults(options, {empty: "full"}, {nan: "nan"}, {word: "word"}, {word: "dog"});
+ equal(options.empty, "", 'value exists');
+ ok(_.isNaN(options.nan), "NaN isn't overridden");
+ equal(options.word, "word", 'new value is added, first one wins');
+
+ try {
+ options = {};
+ _.defaults(options, null, undefined, {a:1});
+ } catch(ex) {}
+
+ equal(options.a, 1, 'should not error on <null> or <undefined> sources');
+ });
+ `)
+ })
+}
+
+// clone
+func Test_underscore_objects_9(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("clone", function() {
+ var moe = {name : 'moe', lucky : [13, 27, 34]};
+ var clone = _.clone(moe);
+ equal(clone.name, 'moe', 'the clone as the attributes of the original');
+
+ clone.name = 'curly';
+ ok(clone.name == 'curly' && moe.name == 'moe', 'clones can change shallow attributes without affecting the original');
+
+ clone.lucky.push(101);
+ equal(_.last(moe.lucky), 101, 'changes to deep attributes are shared with the original');
+
+ equal(_.clone(undefined), void 0, 'non objects should not be changed by clone');
+ equal(_.clone(1), 1, 'non objects should not be changed by clone');
+ equal(_.clone(null), null, 'non objects should not be changed by clone');
+ });
+ `)
+ })
+}
+
+// isEqual
+func Test_underscore_objects_10(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("isEqual", function() {
+ function First() {
+ this.value = 1;
+ }
+ First.prototype.value = 1;
+ function Second() {
+ this.value = 1;
+ }
+ Second.prototype.value = 2;
+
+ // Basic equality and identity comparisons.
+ ok(_.isEqual(null, null), "<null> is equal to <null>");
+ ok(_.isEqual(), "<undefined> is equal to <undefined>");
+
+ ok(!_.isEqual(0, -0), "<0> is not equal to <-0>");
+ ok(!_.isEqual(-0, 0), "Commutative equality is implemented for <0> and <-0>");
+ ok(!_.isEqual(null, undefined), "<null> is not equal to <undefined>");
+ ok(!_.isEqual(undefined, null), "Commutative equality is implemented for <null> and <undefined>");
+
+ // String object and primitive comparisons.
+ ok(_.isEqual("Curly", "Curly"), "Identical string primitives are equal");
+ ok(_.isEqual(new String("Curly"), new String("Curly")), "String objects with identical primitive values are equal");
+ ok(_.isEqual(new String("Curly"), "Curly"), "String primitives and their corresponding object wrappers are equal");
+ ok(_.isEqual("Curly", new String("Curly")), "Commutative equality is implemented for string objects and primitives");
+
+ ok(!_.isEqual("Curly", "Larry"), "String primitives with different values are not equal");
+ ok(!_.isEqual(new String("Curly"), new String("Larry")), "String objects with different primitive values are not equal");
+ ok(!_.isEqual(new String("Curly"), {toString: function(){ return "Curly"; }}), "String objects and objects with a custom <toString> method are not equal");
+
+ // Number object and primitive comparisons.
+ ok(_.isEqual(75, 75), "Identical number primitives are equal");
+ ok(_.isEqual(new Number(75), new Number(75)), "Number objects with identical primitive values are equal");
+ ok(_.isEqual(75, new Number(75)), "Number primitives and their corresponding object wrappers are equal");
+ ok(_.isEqual(new Number(75), 75), "Commutative equality is implemented for number objects and primitives");
+ ok(!_.isEqual(new Number(0), -0), "<new Number(0)> and <-0> are not equal");
+ ok(!_.isEqual(0, new Number(-0)), "Commutative equality is implemented for <new Number(0)> and <-0>");
+
+ ok(!_.isEqual(new Number(75), new Number(63)), "Number objects with different primitive values are not equal");
+ ok(!_.isEqual(new Number(63), {valueOf: function(){ return 63; }}), "Number objects and objects with a <valueOf> method are not equal");
+
+ // Comparisons involving <NaN>.
+ ok(_.isEqual(NaN, NaN), "<NaN> is equal to <NaN>");
+ ok(!_.isEqual(61, NaN), "A number primitive is not equal to <NaN>");
+ ok(!_.isEqual(new Number(79), NaN), "A number object is not equal to <NaN>");
+ ok(!_.isEqual(Infinity, NaN), "<Infinity> is not equal to <NaN>");
+
+ // Boolean object and primitive comparisons.
+ ok(_.isEqual(true, true), "Identical boolean primitives are equal");
+ ok(_.isEqual(new Boolean, new Boolean), "Boolean objects with identical primitive values are equal");
+ ok(_.isEqual(true, new Boolean(true)), "Boolean primitives and their corresponding object wrappers are equal");
+ ok(_.isEqual(new Boolean(true), true), "Commutative equality is implemented for booleans");
+ ok(!_.isEqual(new Boolean(true), new Boolean), "Boolean objects with different primitive values are not equal");
+
+ // Common type coercions.
+ ok(!_.isEqual(true, new Boolean(false)), "Boolean objects are not equal to the boolean primitive <true>");
+ ok(!_.isEqual("75", 75), "String and number primitives with like values are not equal");
+ ok(!_.isEqual(new Number(63), new String(63)), "String and number objects with like values are not equal");
+ ok(!_.isEqual(75, "75"), "Commutative equality is implemented for like string and number values");
+ ok(!_.isEqual(0, ""), "Number and string primitives with like values are not equal");
+ ok(!_.isEqual(1, true), "Number and boolean primitives with like values are not equal");
+ ok(!_.isEqual(new Boolean(false), new Number(0)), "Boolean and number objects with like values are not equal");
+ ok(!_.isEqual(false, new String("")), "Boolean primitives and string objects with like values are not equal");
+ ok(!_.isEqual(12564504e5, new Date(2009, 9, 25)), "Dates and their corresponding numeric primitive values are not equal");
+
+ // Dates.
+ ok(_.isEqual(new Date(2009, 9, 25), new Date(2009, 9, 25)), "Date objects referencing identical times are equal");
+ ok(!_.isEqual(new Date(2009, 9, 25), new Date(2009, 11, 13)), "Date objects referencing different times are not equal");
+ ok(!_.isEqual(new Date(2009, 11, 13), {
+ getTime: function(){
+ return 12606876e5;
+ }
+ }), "Date objects and objects with a <getTime> method are not equal");
+ ok(!_.isEqual(new Date("Curly"), new Date("Curly")), "Invalid dates are not equal");
+
+ // Functions.
+ ok(!_.isEqual(First, Second), "Different functions with identical bodies and source code representations are not equal");
+
+ // RegExps.
+ ok(_.isEqual(/(?:)/gim, /(?:)/gim), "RegExps with equivalent patterns and flags are equal");
+ ok(!_.isEqual(/(?:)/g, /(?:)/gi), "RegExps with equivalent patterns and different flags are not equal");
+ ok(!_.isEqual(/Moe/gim, /Curly/gim), "RegExps with different patterns and equivalent flags are not equal");
+ ok(!_.isEqual(/(?:)/gi, /(?:)/g), "Commutative equality is implemented for RegExps");
+ ok(!_.isEqual(/Curly/g, {source: "Larry", global: true, ignoreCase: false, multiline: false}), "RegExps and RegExp-like objects are not equal");
+
+ // Empty arrays, array-like objects, and object literals.
+ ok(_.isEqual({}, {}), "Empty object literals are equal");
+ ok(_.isEqual([], []), "Empty array literals are equal");
+ ok(_.isEqual([{}], [{}]), "Empty nested arrays and objects are equal");
+ ok(!_.isEqual({length: 0}, []), "Array-like objects and arrays are not equal.");
+ ok(!_.isEqual([], {length: 0}), "Commutative equality is implemented for array-like objects");
+
+ ok(!_.isEqual({}, []), "Object literals and array literals are not equal");
+ ok(!_.isEqual([], {}), "Commutative equality is implemented for objects and arrays");
+
+ // Arrays with primitive and object values.
+ ok(_.isEqual([1, "Larry", true], [1, "Larry", true]), "Arrays containing identical primitives are equal");
+ ok(_.isEqual([(/Moe/g), new Date(2009, 9, 25)], [(/Moe/g), new Date(2009, 9, 25)]), "Arrays containing equivalent elements are equal");
+
+ // Multi-dimensional arrays.
+ var a = [new Number(47), false, "Larry", /Moe/, new Date(2009, 11, 13), ['running', 'biking', new String('programming')], {a: 47}];
+ var b = [new Number(47), false, "Larry", /Moe/, new Date(2009, 11, 13), ['running', 'biking', new String('programming')], {a: 47}];
+ ok(_.isEqual(a, b), "Arrays containing nested arrays and objects are recursively compared");
+
+ // Overwrite the methods defined in ES 5.1 section 15.4.4.
+ a.forEach = a.map = a.filter = a.every = a.indexOf = a.lastIndexOf = a.some = a.reduce = a.reduceRight = null;
+ b.join = b.pop = b.reverse = b.shift = b.slice = b.splice = b.concat = b.sort = b.unshift = null;
+
+ // Array elements and properties.
+ ok(_.isEqual(a, b), "Arrays containing equivalent elements and different non-numeric properties are equal");
+ a.push("White Rocks");
+ ok(!_.isEqual(a, b), "Arrays of different lengths are not equal");
+ a.push("East Boulder");
+ b.push("Gunbarrel Ranch", "Teller Farm");
+ ok(!_.isEqual(a, b), "Arrays of identical lengths containing different elements are not equal");
+
+ // Sparse arrays.
+ ok(_.isEqual(Array(3), Array(3)), "Sparse arrays of identical lengths are equal");
+ ok(!_.isEqual(Array(3), Array(6)), "Sparse arrays of different lengths are not equal when both are empty");
+
+ // Simple objects.
+ ok(_.isEqual({a: "Curly", b: 1, c: true}, {a: "Curly", b: 1, c: true}), "Objects containing identical primitives are equal");
+ ok(_.isEqual({a: /Curly/g, b: new Date(2009, 11, 13)}, {a: /Curly/g, b: new Date(2009, 11, 13)}), "Objects containing equivalent members are equal");
+ ok(!_.isEqual({a: 63, b: 75}, {a: 61, b: 55}), "Objects of identical sizes with different values are not equal");
+ ok(!_.isEqual({a: 63, b: 75}, {a: 61, c: 55}), "Objects of identical sizes with different property names are not equal");
+ ok(!_.isEqual({a: 1, b: 2}, {a: 1}), "Objects of different sizes are not equal");
+ ok(!_.isEqual({a: 1}, {a: 1, b: 2}), "Commutative equality is implemented for objects");
+ ok(!_.isEqual({x: 1, y: undefined}, {x: 1, z: 2}), "Objects with identical keys and different values are not equivalent");
+
+ // <A> contains nested objects and arrays.
+ a = {
+ name: new String("Moe Howard"),
+ age: new Number(77),
+ stooge: true,
+ hobbies: ["acting"],
+ film: {
+ name: "Sing a Song of Six Pants",
+ release: new Date(1947, 9, 30),
+ stars: [new String("Larry Fine"), "Shemp Howard"],
+ minutes: new Number(16),
+ seconds: 54
+ }
+ };
+
+ // <B> contains equivalent nested objects and arrays.
+ b = {
+ name: new String("Moe Howard"),
+ age: new Number(77),
+ stooge: true,
+ hobbies: ["acting"],
+ film: {
+ name: "Sing a Song of Six Pants",
+ release: new Date(1947, 9, 30),
+ stars: [new String("Larry Fine"), "Shemp Howard"],
+ minutes: new Number(16),
+ seconds: 54
+ }
+ };
+ ok(_.isEqual(a, b), "Objects with nested equivalent members are recursively compared");
+
+ // Instances.
+ ok(_.isEqual(new First, new First), "Object instances are equal");
+ ok(!_.isEqual(new First, new Second), "Objects with different constructors and identical own properties are not equal");
+ ok(!_.isEqual({value: 1}, new First), "Object instances and objects sharing equivalent properties are not equal");
+ ok(!_.isEqual({value: 2}, new Second), "The prototype chain of objects should not be examined");
+
+ // Circular Arrays.
+ (a = []).push(a);
+ (b = []).push(b);
+ ok(_.isEqual(a, b), "Arrays containing circular references are equal");
+ a.push(new String("Larry"));
+ b.push(new String("Larry"));
+ ok(_.isEqual(a, b), "Arrays containing circular references and equivalent properties are equal");
+ a.push("Shemp");
+ b.push("Curly");
+ ok(!_.isEqual(a, b), "Arrays containing circular references and different properties are not equal");
+
+ // More circular arrays #767.
+ a = ["everything is checked but", "this", "is not"];
+ a[1] = a;
+ b = ["everything is checked but", ["this", "array"], "is not"];
+ ok(!_.isEqual(a, b), "Comparison of circular references with non-circular references are not equal");
+
+ // Circular Objects.
+ a = {abc: null};
+ b = {abc: null};
+ a.abc = a;
+ b.abc = b;
+ ok(_.isEqual(a, b), "Objects containing circular references are equal");
+ a.def = 75;
+ b.def = 75;
+ ok(_.isEqual(a, b), "Objects containing circular references and equivalent properties are equal");
+ a.def = new Number(75);
+ b.def = new Number(63);
+ ok(!_.isEqual(a, b), "Objects containing circular references and different properties are not equal");
+
+ // More circular objects #767.
+ a = {everything: "is checked", but: "this", is: "not"};
+ a.but = a;
+ b = {everything: "is checked", but: {that:"object"}, is: "not"};
+ ok(!_.isEqual(a, b), "Comparison of circular references with non-circular object references are not equal");
+
+ // Cyclic Structures.
+ a = [{abc: null}];
+ b = [{abc: null}];
+ (a[0].abc = a).push(a);
+ (b[0].abc = b).push(b);
+ ok(_.isEqual(a, b), "Cyclic structures are equal");
+ a[0].def = "Larry";
+ b[0].def = "Larry";
+ ok(_.isEqual(a, b), "Cyclic structures containing equivalent properties are equal");
+ a[0].def = new String("Larry");
+ b[0].def = new String("Curly");
+ ok(!_.isEqual(a, b), "Cyclic structures containing different properties are not equal");
+
+ // Complex Circular References.
+ a = {foo: {b: {foo: {c: {foo: null}}}}};
+ b = {foo: {b: {foo: {c: {foo: null}}}}};
+ a.foo.b.foo.c.foo = a;
+ b.foo.b.foo.c.foo = b;
+ ok(_.isEqual(a, b), "Cyclic structures with nested and identically-named properties are equal");
+
+ // Chaining.
+ ok(!_.isEqual(_({x: 1, y: undefined}).chain(), _({x: 1, z: 2}).chain()), 'Chained objects containing different values are not equal');
+
+ a = _({x: 1, y: 2}).chain();
+ b = _({x: 1, y: 2}).chain();
+ equal(_.isEqual(a.isEqual(b), _(true)), true, '<isEqual> can be chained');
+
+ // TEST: ???
+ return;
+
+ // Objects from another frame.
+ ok(_.isEqual({}, iObject));
+ });
+ `)
+ })
+}
+
+// isEmpty
+func Test_underscore_objects_11(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("isEmpty", function() {
+ ok(!_([1]).isEmpty(), '[1] is not empty');
+ ok(_.isEmpty([]), '[] is empty');
+ ok(!_.isEmpty({one : 1}), '{one : 1} is not empty');
+ ok(_.isEmpty({}), '{} is empty');
+ ok(_.isEmpty(new RegExp('')), 'objects with prototype properties are empty');
+ ok(_.isEmpty(null), 'null is empty');
+ ok(_.isEmpty(), 'undefined is empty');
+ ok(_.isEmpty(''), 'the empty string is empty');
+ ok(!_.isEmpty('moe'), 'but other strings are not');
+
+ var obj = {one : 1};
+ delete obj.one;
+ ok(_.isEmpty(obj), 'deleting all the keys from an object empties it');
+ });
+ `)
+ })
+}
+
+// isElement
+func Test_underscore_objects_12(t *testing.T) {
+ // TEST: ReferenceError: $ is not defined
+ if true {
+ return
+ }
+
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("isElement", function() {
+ ok(!_.isElement('div'), 'strings are not dom elements');
+ ok(_.isElement($('html')[0]), 'the html tag is a DOM element');
+ ok(_.isElement(iElement), 'even from another frame');
+ });
+ `)
+ })
+}
+
+// isArguments
+func Test_underscore_objects_13(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("isArguments", function() {
+ var args = (function(){ return arguments; })(1, 2, 3);
+ ok(!_.isArguments('string'), 'a string is not an arguments object');
+ ok(!_.isArguments(_.isArguments), 'a function is not an arguments object');
+ ok(_.isArguments(args), 'but the arguments object is an arguments object');
+ ok(!_.isArguments(_.toArray(args)), 'but not when it\'s converted into an array');
+ ok(!_.isArguments([1,2,3]), 'and not vanilla arrays.');
+
+ // TEST: ReferenceError: iArguments is not defined
+ return;
+ ok(_.isArguments(iArguments), 'even from another frame');
+ });
+ `)
+ })
+}
+
+// isObject
+func Test_underscore_objects_14(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("isObject", function() {
+ ok(_.isObject(arguments), 'the arguments object is object');
+ ok(_.isObject([1, 2, 3]), 'and arrays');
+ // TEST: ReferenceError: $ is not defined
+ return;
+ ok(_.isObject($('html')[0]), 'and DOM element');
+ ok(_.isObject(iElement), 'even from another frame');
+ ok(_.isObject(function () {}), 'and functions');
+ ok(_.isObject(iFunction), 'even from another frame');
+ ok(!_.isObject(null), 'but not null');
+ ok(!_.isObject(undefined), 'and not undefined');
+ ok(!_.isObject('string'), 'and not string');
+ ok(!_.isObject(12), 'and not number');
+ ok(!_.isObject(true), 'and not boolean');
+ ok(_.isObject(new String('string')), 'but new String()');
+ });
+ `)
+ })
+}
+
+// isArray
+func Test_underscore_objects_15(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("isArray", function() {
+ ok(!_.isArray(arguments), 'the arguments object is not an array');
+ ok(_.isArray([1, 2, 3]), 'but arrays are');
+ // TEST: ???
+ return;
+ ok(_.isArray(iArray), 'even from another frame');
+ });
+ `)
+ })
+}
+
+// isString
+func Test_underscore_objects_16(t *testing.T) {
+ // TEST: ReferenceError: document is not defined
+ if true {
+ return
+ }
+
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("isString", function() {
+ ok(!_.isString(document.body), 'the document body is not a string');
+ ok(_.isString([1, 2, 3].join(', ')), 'but strings are');
+ // TEST: ???
+ return;
+ ok(_.isString(iString), 'even from another frame');
+ });
+ `)
+ })
+}
+
+// isNumber
+func Test_underscore_objects_17(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("isNumber", function() {
+ ok(!_.isNumber('string'), 'a string is not a number');
+ ok(!_.isNumber(arguments), 'the arguments object is not a number');
+ ok(!_.isNumber(undefined), 'undefined is not a number');
+ ok(_.isNumber(3 * 4 - 7 / 10), 'but numbers are');
+ ok(_.isNumber(NaN), 'NaN *is* a number');
+ ok(_.isNumber(Infinity), 'Infinity is a number');
+ // TEST: ???
+ return;
+ ok(_.isNumber(iNumber), 'even from another frame');
+ ok(!_.isNumber('1'), 'numeric strings are not numbers');
+ });
+ `)
+ })
+}
+
+// isBoolean
+func Test_underscore_objects_18(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("isBoolean", function() {
+ ok(!_.isBoolean(2), 'a number is not a boolean');
+ ok(!_.isBoolean("string"), 'a string is not a boolean');
+ ok(!_.isBoolean("false"), 'the string "false" is not a boolean');
+ ok(!_.isBoolean("true"), 'the string "true" is not a boolean');
+ ok(!_.isBoolean(arguments), 'the arguments object is not a boolean');
+ ok(!_.isBoolean(undefined), 'undefined is not a boolean');
+ ok(!_.isBoolean(NaN), 'NaN is not a boolean');
+ ok(!_.isBoolean(null), 'null is not a boolean');
+ ok(_.isBoolean(true), 'but true is');
+ ok(_.isBoolean(false), 'and so is false');
+ // TEST: ???
+ return;
+ ok(_.isBoolean(iBoolean), 'even from another frame');
+ });
+ `)
+ })
+}
+
+// isFunction
+func Test_underscore_objects_19(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("isFunction", function() {
+ ok(!_.isFunction([1, 2, 3]), 'arrays are not functions');
+ ok(!_.isFunction('moe'), 'strings are not functions');
+ ok(_.isFunction(_.isFunction), 'but functions are');
+ // TEST: ???
+ return;
+ ok(_.isFunction(iFunction), 'even from another frame');
+ });
+ `)
+ })
+}
+
+// isDate
+func Test_underscore_objects_20(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("isDate", function() {
+ ok(!_.isDate(100), 'numbers are not dates');
+ ok(!_.isDate({}), 'objects are not dates');
+ ok(_.isDate(new Date()), 'but dates are');
+ // TEST: ???
+ return;
+ ok(_.isDate(iDate), 'even from another frame');
+ });
+ `)
+ })
+}
+
+// isRegExp
+func Test_underscore_objects_21(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("isRegExp", function() {
+ ok(!_.isRegExp(_.identity), 'functions are not RegExps');
+ ok(_.isRegExp(/identity/), 'but RegExps are');
+ // TEST: ???
+ return;
+ ok(_.isRegExp(iRegExp), 'even from another frame');
+ });
+ `)
+ })
+}
+
+// isFinite
+func Test_underscore_objects_22(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("isFinite", function() {
+ ok(!_.isFinite(undefined), 'undefined is not Finite');
+ ok(!_.isFinite(null), 'null is not Finite');
+ ok(!_.isFinite(NaN), 'NaN is not Finite');
+ ok(!_.isFinite(Infinity), 'Infinity is not Finite');
+ ok(!_.isFinite(-Infinity), '-Infinity is not Finite');
+ ok(_.isFinite('12'), 'Numeric strings are numbers');
+ ok(!_.isFinite('1a'), 'Non numeric strings are not numbers');
+ ok(!_.isFinite(''), 'Empty strings are not numbers');
+ var obj = new Number(5);
+ ok(_.isFinite(obj), 'Number instances can be finite');
+ ok(_.isFinite(0), '0 is Finite');
+ ok(_.isFinite(123), 'Ints are Finite');
+ ok(_.isFinite(-12.44), 'Floats are Finite');
+ });
+ `)
+ })
+}
+
+// isNaN
+func Test_underscore_objects_23(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("isNaN", function() {
+ ok(!_.isNaN(undefined), 'undefined is not NaN');
+ ok(!_.isNaN(null), 'null is not NaN');
+ ok(!_.isNaN(0), '0 is not NaN');
+ ok(_.isNaN(NaN), 'but NaN is');
+ // TEST: ???
+ return;
+ ok(_.isNaN(iNaN), 'even from another frame');
+ ok(_.isNaN(new Number(NaN)), 'wrapped NaN is still NaN');
+ });
+ `)
+ })
+}
+
+// isNull
+func Test_underscore_objects_24(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("isNull", function() {
+ ok(!_.isNull(undefined), 'undefined is not null');
+ ok(!_.isNull(NaN), 'NaN is not null');
+ ok(_.isNull(null), 'but null is');
+ // TEST: ???
+ return;
+ ok(_.isNull(iNull), 'even from another frame');
+ });
+ `)
+ })
+}
+
+// isUndefined
+func Test_underscore_objects_25(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("isUndefined", function() {
+ ok(!_.isUndefined(1), 'numbers are defined');
+ ok(!_.isUndefined(null), 'null is defined');
+ ok(!_.isUndefined(false), 'false is defined');
+ ok(!_.isUndefined(NaN), 'NaN is defined');
+ ok(_.isUndefined(), 'nothing is undefined');
+ ok(_.isUndefined(undefined), 'undefined is undefined');
+ // TEST: ???
+ return;
+ ok(_.isUndefined(iUndefined), 'even from another frame');
+ });
+ `)
+ })
+}
+
+// tap
+func Test_underscore_objects_26(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("tap", function() {
+ var intercepted = null;
+ var interceptor = function(obj) { intercepted = obj; };
+ var returned = _.tap(1, interceptor);
+ equal(intercepted, 1, "passes tapped object to interceptor");
+ equal(returned, 1, "returns tapped object");
+
+ returned = _([1,2,3]).chain().
+ map(function(n){ return n * 2; }).
+ max().
+ tap(interceptor).
+ value();
+ ok(returned == 6 && intercepted == 6, 'can use tapped objects in a chain');
+ });
+ `)
+ })
+}
+
+// has
+func Test_underscore_objects_27(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("has", function () {
+ var obj = {foo: "bar", func: function () {} };
+ ok (_.has(obj, "foo"), "has() checks that the object has a property.");
+ ok (_.has(obj, "baz") == false, "has() returns false if the object doesn't have the property.");
+ ok (_.has(obj, "func"), "has() works for functions too.");
+ obj.hasOwnProperty = null;
+ ok (_.has(obj, "foo"), "has() works even when the hasOwnProperty method is deleted.");
+ var child = {};
+ child.prototype = obj;
+ ok (_.has(child, "foo") == false, "has() does not check the prototype chain for a property.")
+ });
+ `)
+ })
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore_test.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore_test.go
new file mode 100644
index 000000000..d8bf2da18
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore_test.go
@@ -0,0 +1,165 @@
+package otto
+
+import (
+ "./terst"
+ "testing"
+
+ "github.com/robertkrimen/otto/underscore"
+)
+
+func init() {
+ underscore.Disable()
+}
+
+// A persistent handle for the underscore tester
+// We do not run underscore tests in parallel, so it is okay to stash globally
+// (Maybe use sync.Pool in the future...)
+var tester_ *_tester
+
+// A tester for underscore: test_ => test(underscore) :)
+func test_(arguments ...interface{}) (func(string, ...interface{}) Value, *_tester) {
+ tester := tester_
+ if tester == nil {
+ tester = newTester()
+ tester.underscore() // Load underscore and testing shim, etc.
+ tester_ = tester
+ }
+
+ return tester.test, tester
+}
+
+func (self *_tester) underscore() {
+ vm := self.vm
+ _, err := vm.Run(underscore.Source())
+ if err != nil {
+ panic(err)
+ }
+
+ vm.Set("assert", func(call FunctionCall) Value {
+ if !call.Argument(0).bool() {
+ message := "Assertion failed"
+ if len(call.ArgumentList) > 1 {
+ message = call.ArgumentList[1].string()
+ }
+ t := terst.Caller().T()
+ is(message, nil)
+ t.Fail()
+ return falseValue
+ }
+ return trueValue
+ })
+
+ vm.Run(`
+ var templateSettings;
+
+ function _setup() {
+ templateSettings = _.clone(_.templateSettings);
+ }
+
+ function _teardown() {
+ _.templateSettings = templateSettings;
+ }
+
+ function module() {
+ /* Nothing happens. */
+ }
+
+ function equals(a, b, emit) {
+ assert(a == b, emit + ", <" + a + "> != <" + b + ">");
+ }
+ var equal = equals;
+
+ function notStrictEqual(a, b, emit) {
+ assert(a !== b, emit);
+ }
+
+ function strictEqual(a, b, emit) {
+ assert(a === b, emit);
+ }
+
+ function ok(a, emit) {
+ assert(a, emit);
+ }
+
+ function raises(fn, want, emit) {
+ var have, _ok = false;
+ if (typeof want === "string") {
+ emit = want;
+ want = null;
+ }
+
+ try {
+ fn();
+ } catch(tmp) {
+ have = tmp;
+ }
+
+ if (have) {
+ if (!want) {
+ _ok = true;
+ }
+ else if (want instanceof RegExp) {
+ _ok = want.test(have);
+ }
+ else if (have instanceof want) {
+ _ok = true
+ }
+ else if (want.call({}, have) === true) {
+ _ok = true;
+ }
+ }
+
+ ok(_ok, emit);
+ }
+
+ function test(name){
+ _setup()
+ try {
+ templateSettings = _.clone(_.templateSettings);
+ if (arguments.length == 3) {
+ count = 0
+ for (count = 0; count < arguments[1]; count++) {
+ arguments[2]()
+ }
+ } else {
+ // For now.
+ arguments[1]()
+ }
+ }
+ finally {
+ _teardown()
+ }
+ }
+
+ function deepEqual(a, b, emit) {
+ // Also, for now.
+ assert(_.isEqual(a, b), emit)
+ }
+ `)
+}
+
+func Test_underscore(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ _.map([1, 2, 3], function(value){
+ return value + 1
+ })
+ `, "2,3,4")
+
+ test(`
+ abc = _.find([1, 2, 3, -1], function(value) { return value == -1 })
+ `, -1)
+
+ test(`_.isEqual(1, 1)`, true)
+ test(`_.isEqual([], [])`, true)
+ test(`_.isEqual(['b', 'd'], ['b', 'd'])`, true)
+ test(`_.isEqual(['b', 'd', 'c'], ['b', 'd', 'e'])`, false)
+ test(`_.isFunction(function(){})`, true)
+ test(`_.template('<p>\u2028<%= "\\u2028\\u2029" %>\u2029</p>')()`, "<p>\u2028\u2028\u2029\u2029</p>")
+ })
+}
+
+// TODO Test: typeof An argument reference
+// TODO Test: abc = {}; abc == Object(abc)
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore_utility_test.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore_utility_test.go
new file mode 100644
index 000000000..ebabb083b
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/underscore_utility_test.go
@@ -0,0 +1,419 @@
+package otto
+
+import (
+ "testing"
+)
+
+// #750 - Return _ instance.
+func Test_underscore_utility_0(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("#750 - Return _ instance.", 2, function() {
+ var instance = _([]);
+ ok(_(instance) === instance);
+ ok(new _(instance) === instance);
+ });
+ `)
+ })
+}
+
+// identity
+func Test_underscore_utility_1(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("identity", function() {
+ var moe = {name : 'moe'};
+ equal(_.identity(moe), moe, 'moe is the same as his identity');
+ });
+ `)
+ })
+}
+
+// random
+func Test_underscore_utility_2(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("random", function() {
+ var array = _.range(1000);
+ var min = Math.pow(2, 31);
+ var max = Math.pow(2, 62);
+
+ ok(_.every(array, function() {
+ return _.random(min, max) >= min;
+ }), "should produce a random number greater than or equal to the minimum number");
+
+ ok(_.some(array, function() {
+ return _.random(Number.MAX_VALUE) > 0;
+ }), "should produce a random number when passed <Number.MAX_VALUE>");
+ });
+ `)
+ })
+}
+
+// uniqueId
+func Test_underscore_utility_3(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("uniqueId", function() {
+ var ids = [], i = 0;
+ while(i++ < 100) ids.push(_.uniqueId());
+ equal(_.uniq(ids).length, ids.length, 'can generate a globally-unique stream of ids');
+ });
+ `)
+ })
+}
+
+// times
+func Test_underscore_utility_4(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("times", function() {
+ var vals = [];
+ _.times(3, function (i) { vals.push(i); });
+ ok(_.isEqual(vals, [0,1,2]), "is 0 indexed");
+ //
+ vals = [];
+ _(3).times(function(i) { vals.push(i); });
+ ok(_.isEqual(vals, [0,1,2]), "works as a wrapper");
+ // collects return values
+ ok(_.isEqual([0, 1, 2], _.times(3, function(i) { return i; })), "collects return values");
+ });
+ `)
+ })
+}
+
+// mixin
+func Test_underscore_utility_5(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("mixin", function() {
+ _.mixin({
+ myReverse: function(string) {
+ return string.split('').reverse().join('');
+ }
+ });
+ equal(_.myReverse('panacea'), 'aecanap', 'mixed in a function to _');
+ equal(_('champ').myReverse(), 'pmahc', 'mixed in a function to the OOP wrapper');
+ });
+ `)
+ })
+}
+
+// _.escape
+func Test_underscore_utility_6(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("_.escape", function() {
+ equal(_.escape("Curly & Moe"), "Curly &amp; Moe");
+ equal(_.escape("Curly &amp; Moe"), "Curly &amp;amp; Moe");
+ equal(_.escape(null), '');
+ });
+ `)
+ })
+}
+
+// _.unescape
+func Test_underscore_utility_7(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("_.unescape", function() {
+ var string = "Curly & Moe";
+ equal(_.unescape("Curly &amp; Moe"), string);
+ equal(_.unescape("Curly &amp;amp; Moe"), "Curly &amp; Moe");
+ equal(_.unescape(null), '');
+ equal(_.unescape(_.escape(string)), string);
+ });
+ `)
+ })
+}
+
+// template
+func Test_underscore_utility_8(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test("template", function() {
+ var basicTemplate = _.template("<%= thing %> is gettin' on my noives!");
+ var result = basicTemplate({thing : 'This'});
+ equal(result, "This is gettin' on my noives!", 'can do basic attribute interpolation');
+
+ var sansSemicolonTemplate = _.template("A <% this %> B");
+ equal(sansSemicolonTemplate(), "A B");
+
+ var backslashTemplate = _.template("<%= thing %> is \\ridanculous");
+ equal(backslashTemplate({thing: 'This'}), "This is \\ridanculous");
+
+ var escapeTemplate = _.template('<%= a ? "checked=\\"checked\\"" : "" %>');
+ equal(escapeTemplate({a: true}), 'checked="checked"', 'can handle slash escapes in interpolations.');
+
+ var fancyTemplate = _.template("<ul><% \
+ for (var key in people) { \
+ %><li><%= people[key] %></li><% } %></ul>");
+ result = fancyTemplate({people : {moe : "Moe", larry : "Larry", curly : "Curly"}});
+ equal(result, "<ul><li>Moe</li><li>Larry</li><li>Curly</li></ul>", 'can run arbitrary javascript in templates');
+
+ var escapedCharsInJavascriptTemplate = _.template("<ul><% _.each(numbers.split('\\n'), function(item) { %><li><%= item %></li><% }) %></ul>");
+ result = escapedCharsInJavascriptTemplate({numbers: "one\ntwo\nthree\nfour"});
+ equal(result, "<ul><li>one</li><li>two</li><li>three</li><li>four</li></ul>", 'Can use escaped characters (e.g. \\n) in Javascript');
+
+ var namespaceCollisionTemplate = _.template("<%= pageCount %> <%= thumbnails[pageCount] %> <% _.each(thumbnails, function(p) { %><div class=\"thumbnail\" rel=\"<%= p %>\"></div><% }); %>");
+ result = namespaceCollisionTemplate({
+ pageCount: 3,
+ thumbnails: {
+ 1: "p1-thumbnail.gif",
+ 2: "p2-thumbnail.gif",
+ 3: "p3-thumbnail.gif"
+ }
+ });
+ equal(result, "3 p3-thumbnail.gif <div class=\"thumbnail\" rel=\"p1-thumbnail.gif\"></div><div class=\"thumbnail\" rel=\"p2-thumbnail.gif\"></div><div class=\"thumbnail\" rel=\"p3-thumbnail.gif\"></div>");
+
+ var noInterpolateTemplate = _.template("<div><p>Just some text. Hey, I know this is silly but it aids consistency.</p></div>");
+ result = noInterpolateTemplate();
+ equal(result, "<div><p>Just some text. Hey, I know this is silly but it aids consistency.</p></div>");
+
+ var quoteTemplate = _.template("It's its, not it's");
+ equal(quoteTemplate({}), "It's its, not it's");
+
+ var quoteInStatementAndBody = _.template("<%\
+ if(foo == 'bar'){ \
+ %>Statement quotes and 'quotes'.<% } %>");
+ equal(quoteInStatementAndBody({foo: "bar"}), "Statement quotes and 'quotes'.");
+
+ var withNewlinesAndTabs = _.template('This\n\t\tis: <%= x %>.\n\tok.\nend.');
+ equal(withNewlinesAndTabs({x: 'that'}), 'This\n\t\tis: that.\n\tok.\nend.');
+
+ var template = _.template("<i><%- value %></i>");
+ var result = template({value: "<script>"});
+ equal(result, '<i>&lt;script&gt;</i>');
+
+ var stooge = {
+ name: "Moe",
+ template: _.template("I'm <%= this.name %>")
+ };
+ equal(stooge.template(), "I'm Moe");
+
+ // TEST: ReferenceError: $ is not defined
+ if (false) {
+ if (!$.browser.msie) {
+ var fromHTML = _.template($('#template').html());
+ equal(fromHTML({data : 12345}).replace(/\s/g, ''), '<li>24690</li>');
+ }
+ }
+
+ _.templateSettings = {
+ evaluate : /\{\{([\s\S]+?)\}\}/g,
+ interpolate : /\{\{=([\s\S]+?)\}\}/g
+ };
+
+ var custom = _.template("<ul>{{ for (var key in people) { }}<li>{{= people[key] }}</li>{{ } }}</ul>");
+ result = custom({people : {moe : "Moe", larry : "Larry", curly : "Curly"}});
+ equal(result, "<ul><li>Moe</li><li>Larry</li><li>Curly</li></ul>", 'can run arbitrary javascript in templates');
+
+ var customQuote = _.template("It's its, not it's");
+ equal(customQuote({}), "It's its, not it's");
+
+ var quoteInStatementAndBody = _.template("{{ if(foo == 'bar'){ }}Statement quotes and 'quotes'.{{ } }}");
+ equal(quoteInStatementAndBody({foo: "bar"}), "Statement quotes and 'quotes'.");
+
+ _.templateSettings = {
+ evaluate : /<\?([\s\S]+?)\?>/g,
+ interpolate : /<\?=([\s\S]+?)\?>/g
+ };
+
+ var customWithSpecialChars = _.template("<ul><? for (var key in people) { ?><li><?= people[key] ?></li><? } ?></ul>");
+ result = customWithSpecialChars({people : {moe : "Moe", larry : "Larry", curly : "Curly"}});
+ equal(result, "<ul><li>Moe</li><li>Larry</li><li>Curly</li></ul>", 'can run arbitrary javascript in templates');
+
+ var customWithSpecialCharsQuote = _.template("It's its, not it's");
+ equal(customWithSpecialCharsQuote({}), "It's its, not it's");
+
+ var quoteInStatementAndBody = _.template("<? if(foo == 'bar'){ ?>Statement quotes and 'quotes'.<? } ?>");
+ equal(quoteInStatementAndBody({foo: "bar"}), "Statement quotes and 'quotes'.");
+
+ _.templateSettings = {
+ interpolate : /\{\{(.+?)\}\}/g
+ };
+
+ var mustache = _.template("Hello {{planet}}!");
+ equal(mustache({planet : "World"}), "Hello World!", "can mimic mustache.js");
+
+ var templateWithNull = _.template("a null undefined {{planet}}");
+ equal(templateWithNull({planet : "world"}), "a null undefined world", "can handle missing escape and evaluate settings");
+ });
+ `)
+ })
+}
+
+// _.template provides the generated function source, when a SyntaxError occurs
+func Test_underscore_utility_9(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('_.template provides the generated function source, when a SyntaxError occurs', function() {
+ try {
+ _.template('<b><%= if x %></b>');
+ } catch (ex) {
+ var source = ex.source;
+ }
+ ok(/__p/.test(source));
+ });
+ `)
+ })
+}
+
+// _.template handles \\u2028 & \\u2029
+func Test_underscore_utility_10(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('_.template handles \\u2028 & \\u2029', function() {
+ var tmpl = _.template('<p>\u2028<%= "\\u2028\\u2029" %>\u2029</p>');
+ strictEqual(tmpl(), '<p>\u2028\u2028\u2029\u2029</p>');
+ });
+ `)
+ })
+}
+
+// result calls functions and returns primitives
+func Test_underscore_utility_11(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('result calls functions and returns primitives', function() {
+ var obj = {w: '', x: 'x', y: function(){ return this.x; }};
+ strictEqual(_.result(obj, 'w'), '');
+ strictEqual(_.result(obj, 'x'), 'x');
+ strictEqual(_.result(obj, 'y'), 'x');
+ strictEqual(_.result(obj, 'z'), undefined);
+ strictEqual(_.result(null, 'x'), null);
+ });
+ `)
+ })
+}
+
+// _.templateSettings.variable
+func Test_underscore_utility_12(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('_.templateSettings.variable', function() {
+ var s = '<%=data.x%>';
+ var data = {x: 'x'};
+ strictEqual(_.template(s, data, {variable: 'data'}), 'x');
+ _.templateSettings.variable = 'data';
+ strictEqual(_.template(s)(data), 'x');
+ });
+ `)
+ })
+}
+
+// #547 - _.templateSettings is unchanged by custom settings.
+func Test_underscore_utility_13(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('#547 - _.templateSettings is unchanged by custom settings.', function() {
+ ok(!_.templateSettings.variable);
+ _.template('', {}, {variable: 'x'});
+ ok(!_.templateSettings.variable);
+ });
+ `)
+ })
+}
+
+// #556 - undefined template variables.
+func Test_underscore_utility_14(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('#556 - undefined template variables.', function() {
+ var template = _.template('<%=x%>');
+ strictEqual(template({x: null}), '');
+ strictEqual(template({x: undefined}), '');
+
+ var templateEscaped = _.template('<%-x%>');
+ strictEqual(templateEscaped({x: null}), '');
+ strictEqual(templateEscaped({x: undefined}), '');
+
+ var templateWithProperty = _.template('<%=x.foo%>');
+ strictEqual(templateWithProperty({x: {} }), '');
+ strictEqual(templateWithProperty({x: {} }), '');
+
+ var templateWithPropertyEscaped = _.template('<%-x.foo%>');
+ strictEqual(templateWithPropertyEscaped({x: {} }), '');
+ strictEqual(templateWithPropertyEscaped({x: {} }), '');
+ });
+ `)
+ })
+}
+
+// interpolate evaluates code only once.
+func Test_underscore_utility_15(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('interpolate evaluates code only once.', 2, function() {
+ var count = 0;
+ var template = _.template('<%= f() %>');
+ template({f: function(){ ok(!(count++)); }});
+
+ var countEscaped = 0;
+ var templateEscaped = _.template('<%- f() %>');
+ templateEscaped({f: function(){ ok(!(countEscaped++)); }});
+ });
+ `)
+ })
+}
+
+// #746 - _.template settings are not modified.
+func Test_underscore_utility_16(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('#746 - _.template settings are not modified.', 1, function() {
+ var settings = {};
+ _.template('', null, settings);
+ deepEqual(settings, {});
+ });
+ `)
+ })
+}
+
+// #779 - delimeters are applied to unescaped text.
+func Test_underscore_utility_17(t *testing.T) {
+ tt(t, func() {
+ test, _ := test_()
+
+ test(`
+ test('#779 - delimeters are applied to unescaped text.', 1, function() {
+ var template = _.template('<<\nx\n>>', null, {evaluate: /<<(.*?)>>/g});
+ strictEqual(template(), '<<\nx\n>>');
+ });
+ `)
+ })
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/value.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/value.go
new file mode 100644
index 000000000..05d61dd62
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/value.go
@@ -0,0 +1,989 @@
+package otto
+
+import (
+ "fmt"
+ "math"
+ "reflect"
+ "strconv"
+ "unicode/utf16"
+)
+
+type _valueKind int
+
+const (
+ valueUndefined _valueKind = iota
+ valueNull
+ valueNumber
+ valueString
+ valueBoolean
+ valueObject
+
+ // These are invalid outside of the runtime
+ valueEmpty
+ valueResult
+ valueReference
+)
+
+// Value is the representation of a JavaScript value.
+type Value struct {
+ kind _valueKind
+ value interface{}
+}
+
+func (vl Value) safe() bool {
+ return vl.kind < valueEmpty
+}
+
+var (
+ emptyValue = Value{kind: valueEmpty}
+ nullValue = Value{kind: valueNull}
+ falseValue = Value{kind: valueBoolean, value: false}
+ trueValue = Value{kind: valueBoolean, value: true}
+)
+
+// ToValue will convert an interface{} value to a value digestible by otto/JavaScript
+//
+// This function will not work for advanced types (struct, map, slice/array, etc.) and
+// you should use Otto.ToValue instead.
+func ToValue(value interface{}) (Value, error) {
+ result := Value{}
+ err := catchPanic(func() {
+ result = toValue(value)
+ })
+ return result, err
+}
+
+func (value Value) isEmpty() bool {
+ return value.kind == valueEmpty
+}
+
+// Undefined
+
+// UndefinedValue will return a Value representing undefined.
+func UndefinedValue() Value {
+ return Value{}
+}
+
+// IsDefined will return false if the value is undefined, and true otherwise.
+func (value Value) IsDefined() bool {
+ return value.kind != valueUndefined
+}
+
+// IsUndefined will return true if the value is undefined, and false otherwise.
+func (value Value) IsUndefined() bool {
+ return value.kind == valueUndefined
+}
+
+// NullValue will return a Value representing null.
+func NullValue() Value {
+ return Value{kind: valueNull}
+}
+
+// IsNull will return true if the value is null, and false otherwise.
+func (value Value) IsNull() bool {
+ return value.kind == valueNull
+}
+
+// ---
+
+func (value Value) isCallable() bool {
+ switch value := value.value.(type) {
+ case *_object:
+ return value.isCall()
+ }
+ return false
+}
+
+// Call the value as a function with the given this value and argument list and
+// return the result of invocation. It is essentially equivalent to:
+//
+// value.apply(thisValue, argumentList)
+//
+// An undefined value and an error will result if:
+//
+// 1. There is an error during conversion of the argument list
+// 2. The value is not actually a function
+// 3. An (uncaught) exception is thrown
+//
+func (value Value) Call(this Value, argumentList ...interface{}) (Value, error) {
+ result := Value{}
+ err := catchPanic(func() {
+ // FIXME
+ result = value.call(nil, this, argumentList...)
+ })
+ if !value.safe() {
+ value = Value{}
+ }
+ return result, err
+}
+
+func (value Value) call(rt *_runtime, this Value, argumentList ...interface{}) Value {
+ switch function := value.value.(type) {
+ case *_object:
+ return function.call(this, function.runtime.toValueArray(argumentList...), false, nativeFrame)
+ }
+ if rt == nil {
+ panic("FIXME TypeError")
+ }
+ panic(rt.panicTypeError())
+}
+
+func (value Value) constructSafe(rt *_runtime, this Value, argumentList ...interface{}) (Value, error) {
+ result := Value{}
+ err := catchPanic(func() {
+ result = value.construct(rt, this, argumentList...)
+ })
+ return result, err
+}
+
+func (value Value) construct(rt *_runtime, this Value, argumentList ...interface{}) Value {
+ switch fn := value.value.(type) {
+ case *_object:
+ return fn.construct(fn.runtime.toValueArray(argumentList...))
+ }
+ if rt == nil {
+ panic("FIXME TypeError")
+ }
+ panic(rt.panicTypeError())
+}
+
+// IsPrimitive will return true if value is a primitive (any kind of primitive).
+func (value Value) IsPrimitive() bool {
+ return !value.IsObject()
+}
+
+// IsBoolean will return true if value is a boolean (primitive).
+func (value Value) IsBoolean() bool {
+ return value.kind == valueBoolean
+}
+
+// IsNumber will return true if value is a number (primitive).
+func (value Value) IsNumber() bool {
+ return value.kind == valueNumber
+}
+
+// IsNaN will return true if value is NaN (or would convert to NaN).
+func (value Value) IsNaN() bool {
+ switch value := value.value.(type) {
+ case float64:
+ return math.IsNaN(value)
+ case float32:
+ return math.IsNaN(float64(value))
+ case int, int8, int32, int64:
+ return false
+ case uint, uint8, uint32, uint64:
+ return false
+ }
+
+ return math.IsNaN(value.float64())
+}
+
+// IsString will return true if value is a string (primitive).
+func (value Value) IsString() bool {
+ return value.kind == valueString
+}
+
+// IsObject will return true if value is an object.
+func (value Value) IsObject() bool {
+ return value.kind == valueObject
+}
+
+// IsFunction will return true if value is a function.
+func (value Value) IsFunction() bool {
+ if value.kind != valueObject {
+ return false
+ }
+ return value.value.(*_object).class == "Function"
+}
+
+// Class will return the class string of the value or the empty string if value is not an object.
+//
+// The return value will (generally) be one of:
+//
+// Object
+// Function
+// Array
+// String
+// Number
+// Boolean
+// Date
+// RegExp
+//
+func (value Value) Class() string {
+ if value.kind != valueObject {
+ return ""
+ }
+ return value.value.(*_object).class
+}
+
+func (value Value) isArray() bool {
+ if value.kind != valueObject {
+ return false
+ }
+ return isArray(value.value.(*_object))
+}
+
+func (value Value) isStringObject() bool {
+ if value.kind != valueObject {
+ return false
+ }
+ return value.value.(*_object).class == "String"
+}
+
+func (value Value) isBooleanObject() bool {
+ if value.kind != valueObject {
+ return false
+ }
+ return value.value.(*_object).class == "Boolean"
+}
+
+func (value Value) isNumberObject() bool {
+ if value.kind != valueObject {
+ return false
+ }
+ return value.value.(*_object).class == "Number"
+}
+
+func (value Value) isDate() bool {
+ if value.kind != valueObject {
+ return false
+ }
+ return value.value.(*_object).class == "Date"
+}
+
+func (value Value) isRegExp() bool {
+ if value.kind != valueObject {
+ return false
+ }
+ return value.value.(*_object).class == "RegExp"
+}
+
+func (value Value) isError() bool {
+ if value.kind != valueObject {
+ return false
+ }
+ return value.value.(*_object).class == "Error"
+}
+
+// ---
+
+func toValue_reflectValuePanic(value interface{}, kind reflect.Kind) {
+ // FIXME?
+ switch kind {
+ case reflect.Struct:
+ panic(newError(nil, "TypeError", "invalid value (struct): missing runtime: %v (%T)", value, value))
+ case reflect.Map:
+ panic(newError(nil, "TypeError", "invalid value (map): missing runtime: %v (%T)", value, value))
+ case reflect.Slice:
+ panic(newError(nil, "TypeError", "invalid value (slice): missing runtime: %v (%T)", value, value))
+ }
+}
+
+func toValue(value interface{}) Value {
+ switch value := value.(type) {
+ case Value:
+ return value
+ case bool:
+ return Value{valueBoolean, value}
+ case int:
+ return Value{valueNumber, value}
+ case int8:
+ return Value{valueNumber, value}
+ case int16:
+ return Value{valueNumber, value}
+ case int32:
+ return Value{valueNumber, value}
+ case int64:
+ return Value{valueNumber, value}
+ case uint:
+ return Value{valueNumber, value}
+ case uint8:
+ return Value{valueNumber, value}
+ case uint16:
+ return Value{valueNumber, value}
+ case uint32:
+ return Value{valueNumber, value}
+ case uint64:
+ return Value{valueNumber, value}
+ case float32:
+ return Value{valueNumber, float64(value)}
+ case float64:
+ return Value{valueNumber, value}
+ case []uint16:
+ return Value{valueString, value}
+ case string:
+ return Value{valueString, value}
+ // A rune is actually an int32, which is handled above
+ case *_object:
+ return Value{valueObject, value}
+ case *Object:
+ return Value{valueObject, value.object}
+ case Object:
+ return Value{valueObject, value.object}
+ case _reference: // reference is an interface (already a pointer)
+ return Value{valueReference, value}
+ case _result:
+ return Value{valueResult, value}
+ case nil:
+ // TODO Ugh.
+ return Value{}
+ case reflect.Value:
+ for value.Kind() == reflect.Ptr {
+ // We were given a pointer, so we'll drill down until we get a non-pointer
+ //
+ // These semantics might change if we want to start supporting pointers to values transparently
+ // (It would be best not to depend on this behavior)
+ // FIXME: UNDEFINED
+ if value.IsNil() {
+ return Value{}
+ }
+ value = value.Elem()
+ }
+ switch value.Kind() {
+ case reflect.Bool:
+ return Value{valueBoolean, bool(value.Bool())}
+ case reflect.Int:
+ return Value{valueNumber, int(value.Int())}
+ case reflect.Int8:
+ return Value{valueNumber, int8(value.Int())}
+ case reflect.Int16:
+ return Value{valueNumber, int16(value.Int())}
+ case reflect.Int32:
+ return Value{valueNumber, int32(value.Int())}
+ case reflect.Int64:
+ return Value{valueNumber, int64(value.Int())}
+ case reflect.Uint:
+ return Value{valueNumber, uint(value.Uint())}
+ case reflect.Uint8:
+ return Value{valueNumber, uint8(value.Uint())}
+ case reflect.Uint16:
+ return Value{valueNumber, uint16(value.Uint())}
+ case reflect.Uint32:
+ return Value{valueNumber, uint32(value.Uint())}
+ case reflect.Uint64:
+ return Value{valueNumber, uint64(value.Uint())}
+ case reflect.Float32:
+ return Value{valueNumber, float32(value.Float())}
+ case reflect.Float64:
+ return Value{valueNumber, float64(value.Float())}
+ case reflect.String:
+ return Value{valueString, string(value.String())}
+ default:
+ toValue_reflectValuePanic(value.Interface(), value.Kind())
+ }
+ default:
+ return toValue(reflect.ValueOf(value))
+ }
+ // FIXME?
+ panic(newError(nil, "TypeError", "invalid value: %v (%T)", value, value))
+}
+
+// String will return the value as a string.
+//
+// This method will make return the empty string if there is an error.
+func (value Value) String() string {
+ result := ""
+ catchPanic(func() {
+ result = value.string()
+ })
+ return result
+}
+
+// ToBoolean will convert the value to a boolean (bool).
+//
+// ToValue(0).ToBoolean() => false
+// ToValue("").ToBoolean() => false
+// ToValue(true).ToBoolean() => true
+// ToValue(1).ToBoolean() => true
+// ToValue("Nothing happens").ToBoolean() => true
+//
+// If there is an error during the conversion process (like an uncaught exception), then the result will be false and an error.
+func (value Value) ToBoolean() (bool, error) {
+ result := false
+ err := catchPanic(func() {
+ result = value.bool()
+ })
+ return result, err
+}
+
+func (value Value) numberValue() Value {
+ if value.kind == valueNumber {
+ return value
+ }
+ return Value{valueNumber, value.float64()}
+}
+
+// ToFloat will convert the value to a number (float64).
+//
+// ToValue(0).ToFloat() => 0.
+// ToValue(1.1).ToFloat() => 1.1
+// ToValue("11").ToFloat() => 11.
+//
+// If there is an error during the conversion process (like an uncaught exception), then the result will be 0 and an error.
+func (value Value) ToFloat() (float64, error) {
+ result := float64(0)
+ err := catchPanic(func() {
+ result = value.float64()
+ })
+ return result, err
+}
+
+// ToInteger will convert the value to a number (int64).
+//
+// ToValue(0).ToInteger() => 0
+// ToValue(1.1).ToInteger() => 1
+// ToValue("11").ToInteger() => 11
+//
+// If there is an error during the conversion process (like an uncaught exception), then the result will be 0 and an error.
+func (value Value) ToInteger() (int64, error) {
+ result := int64(0)
+ err := catchPanic(func() {
+ result = value.number().int64
+ })
+ return result, err
+}
+
+// ToString will convert the value to a string (string).
+//
+// ToValue(0).ToString() => "0"
+// ToValue(false).ToString() => "false"
+// ToValue(1.1).ToString() => "1.1"
+// ToValue("11").ToString() => "11"
+// ToValue('Nothing happens.').ToString() => "Nothing happens."
+//
+// If there is an error during the conversion process (like an uncaught exception), then the result will be the empty string ("") and an error.
+func (value Value) ToString() (string, error) {
+ result := ""
+ err := catchPanic(func() {
+ result = value.string()
+ })
+ return result, err
+}
+
+func (value Value) _object() *_object {
+ switch value := value.value.(type) {
+ case *_object:
+ return value
+ }
+ return nil
+}
+
+// Object will return the object of the value, or nil if value is not an object.
+//
+// This method will not do any implicit conversion. For example, calling this method on a string primitive value will not return a String object.
+func (value Value) Object() *Object {
+ switch object := value.value.(type) {
+ case *_object:
+ return _newObject(object, value)
+ }
+ return nil
+}
+
+func (value Value) reference() _reference {
+ switch value := value.value.(type) {
+ case _reference:
+ return value
+ }
+ return nil
+}
+
+func (value Value) resolve() Value {
+ switch value := value.value.(type) {
+ case _reference:
+ return value.getValue()
+ }
+ return value
+}
+
+var (
+ __NaN__ float64 = math.NaN()
+ __PositiveInfinity__ float64 = math.Inf(+1)
+ __NegativeInfinity__ float64 = math.Inf(-1)
+ __PositiveZero__ float64 = 0
+ __NegativeZero__ float64 = math.Float64frombits(0 | (1 << 63))
+)
+
+func positiveInfinity() float64 {
+ return __PositiveInfinity__
+}
+
+func negativeInfinity() float64 {
+ return __NegativeInfinity__
+}
+
+func positiveZero() float64 {
+ return __PositiveZero__
+}
+
+func negativeZero() float64 {
+ return __NegativeZero__
+}
+
+// NaNValue will return a value representing NaN.
+//
+// It is equivalent to:
+//
+// ToValue(math.NaN())
+//
+func NaNValue() Value {
+ return Value{valueNumber, __NaN__}
+}
+
+func positiveInfinityValue() Value {
+ return Value{valueNumber, __PositiveInfinity__}
+}
+
+func negativeInfinityValue() Value {
+ return Value{valueNumber, __NegativeInfinity__}
+}
+
+func positiveZeroValue() Value {
+ return Value{valueNumber, __PositiveZero__}
+}
+
+func negativeZeroValue() Value {
+ return Value{valueNumber, __NegativeZero__}
+}
+
+// TrueValue will return a value representing true.
+//
+// It is equivalent to:
+//
+// ToValue(true)
+//
+func TrueValue() Value {
+ return Value{valueBoolean, true}
+}
+
+// FalseValue will return a value representing false.
+//
+// It is equivalent to:
+//
+// ToValue(false)
+//
+func FalseValue() Value {
+ return Value{valueBoolean, false}
+}
+
+func sameValue(x Value, y Value) bool {
+ if x.kind != y.kind {
+ return false
+ }
+ result := false
+ switch x.kind {
+ case valueUndefined, valueNull:
+ result = true
+ case valueNumber:
+ x := x.float64()
+ y := y.float64()
+ if math.IsNaN(x) && math.IsNaN(y) {
+ result = true
+ } else {
+ result = x == y
+ if result && x == 0 {
+ // Since +0 != -0
+ result = math.Signbit(x) == math.Signbit(y)
+ }
+ }
+ case valueString:
+ result = x.string() == y.string()
+ case valueBoolean:
+ result = x.bool() == y.bool()
+ case valueObject:
+ result = x._object() == y._object()
+ default:
+ panic(hereBeDragons())
+ }
+
+ return result
+}
+
+func strictEqualityComparison(x Value, y Value) bool {
+ if x.kind != y.kind {
+ return false
+ }
+ result := false
+ switch x.kind {
+ case valueUndefined, valueNull:
+ result = true
+ case valueNumber:
+ x := x.float64()
+ y := y.float64()
+ if math.IsNaN(x) && math.IsNaN(y) {
+ result = false
+ } else {
+ result = x == y
+ }
+ case valueString:
+ result = x.string() == y.string()
+ case valueBoolean:
+ result = x.bool() == y.bool()
+ case valueObject:
+ result = x._object() == y._object()
+ default:
+ panic(hereBeDragons())
+ }
+
+ return result
+}
+
+// Export will attempt to convert the value to a Go representation
+// and return it via an interface{} kind.
+//
+// Export returns an error, but it will always be nil. It is present
+// for backwards compatibility.
+//
+// If a reasonable conversion is not possible, then the original
+// value is returned.
+//
+// undefined -> nil (FIXME?: Should be Value{})
+// null -> nil
+// boolean -> bool
+// number -> A number type (int, float32, uint64, ...)
+// string -> string
+// Array -> []interface{}
+// Object -> map[string]interface{}
+//
+func (self Value) Export() (interface{}, error) {
+ return self.export(), nil
+}
+
+func (self Value) export() interface{} {
+
+ switch self.kind {
+ case valueUndefined:
+ return nil
+ case valueNull:
+ return nil
+ case valueNumber, valueBoolean:
+ return self.value
+ case valueString:
+ switch value := self.value.(type) {
+ case string:
+ return value
+ case []uint16:
+ return string(utf16.Decode(value))
+ }
+ case valueObject:
+ object := self._object()
+ switch value := object.value.(type) {
+ case *_goStructObject:
+ return value.value.Interface()
+ case *_goMapObject:
+ return value.value.Interface()
+ case *_goArrayObject:
+ return value.value.Interface()
+ case *_goSliceObject:
+ return value.value.Interface()
+ }
+ if object.class == "Array" {
+ result := make([]interface{}, 0)
+ lengthValue := object.get("length")
+ length := lengthValue.value.(uint32)
+ for index := uint32(0); index < length; index += 1 {
+ name := strconv.FormatInt(int64(index), 10)
+ if !object.hasProperty(name) {
+ continue
+ }
+ value := object.get(name)
+ result = append(result, value.export())
+ }
+ return result
+ } else {
+ result := make(map[string]interface{})
+ // TODO Should we export everything? Or just what is enumerable?
+ object.enumerate(false, func(name string) bool {
+ value := object.get(name)
+ if value.IsDefined() {
+ result[name] = value.export()
+ }
+ return true
+ })
+ return result
+ }
+ }
+
+ if self.safe() {
+ return self
+ }
+
+ return Value{}
+}
+
+func (self Value) evaluateBreakContinue(labels []string) _resultKind {
+ result := self.value.(_result)
+ if result.kind == resultBreak || result.kind == resultContinue {
+ for _, label := range labels {
+ if label == result.target {
+ return result.kind
+ }
+ }
+ }
+ return resultReturn
+}
+
+func (self Value) evaluateBreak(labels []string) _resultKind {
+ result := self.value.(_result)
+ if result.kind == resultBreak {
+ for _, label := range labels {
+ if label == result.target {
+ return result.kind
+ }
+ }
+ }
+ return resultReturn
+}
+
+func (self Value) exportNative() interface{} {
+
+ switch self.kind {
+ case valueUndefined:
+ return self
+ case valueNull:
+ return nil
+ case valueNumber, valueBoolean:
+ return self.value
+ case valueString:
+ switch value := self.value.(type) {
+ case string:
+ return value
+ case []uint16:
+ return string(utf16.Decode(value))
+ }
+ case valueObject:
+ object := self._object()
+ switch value := object.value.(type) {
+ case *_goStructObject:
+ return value.value.Interface()
+ case *_goMapObject:
+ return value.value.Interface()
+ case *_goArrayObject:
+ return value.value.Interface()
+ case *_goSliceObject:
+ return value.value.Interface()
+ }
+ }
+
+ return self
+}
+
+// Make a best effort to return a reflect.Value corresponding to reflect.Kind, but
+// fallback to just returning the Go value we have handy.
+func (value Value) toReflectValue(kind reflect.Kind) (reflect.Value, error) {
+ switch kind {
+ case reflect.Bool: // Bool
+ return reflect.ValueOf(value.bool()), nil
+ case reflect.Int: // Int
+ // We convert to float64 here because converting to int64 will not tell us
+ // if a value is outside the range of int64
+ tmp := toIntegerFloat(value)
+ if tmp < float_minInt || tmp > float_maxInt {
+ return reflect.Value{}, fmt.Errorf("RangeError: %f (%v) to int", tmp, value)
+ } else {
+ return reflect.ValueOf(int(tmp)), nil
+ }
+ case reflect.Int8: // Int8
+ tmp := value.number().int64
+ if tmp < int64_minInt8 || tmp > int64_maxInt8 {
+ return reflect.Value{}, fmt.Errorf("RangeError: %d (%v) to int8", tmp, value)
+ } else {
+ return reflect.ValueOf(int8(tmp)), nil
+ }
+ case reflect.Int16: // Int16
+ tmp := value.number().int64
+ if tmp < int64_minInt16 || tmp > int64_maxInt16 {
+ return reflect.Value{}, fmt.Errorf("RangeError: %d (%v) to int16", tmp, value)
+ } else {
+ return reflect.ValueOf(int16(tmp)), nil
+ }
+ case reflect.Int32: // Int32
+ tmp := value.number().int64
+ if tmp < int64_minInt32 || tmp > int64_maxInt32 {
+ return reflect.Value{}, fmt.Errorf("RangeError: %d (%v) to int32", tmp, value)
+ } else {
+ return reflect.ValueOf(int32(tmp)), nil
+ }
+ case reflect.Int64: // Int64
+ // We convert to float64 here because converting to int64 will not tell us
+ // if a value is outside the range of int64
+ tmp := toIntegerFloat(value)
+ if tmp < float_minInt64 || tmp > float_maxInt64 {
+ return reflect.Value{}, fmt.Errorf("RangeError: %f (%v) to int", tmp, value)
+ } else {
+ return reflect.ValueOf(int64(tmp)), nil
+ }
+ case reflect.Uint: // Uint
+ // We convert to float64 here because converting to int64 will not tell us
+ // if a value is outside the range of uint
+ tmp := toIntegerFloat(value)
+ if tmp < 0 || tmp > float_maxUint {
+ return reflect.Value{}, fmt.Errorf("RangeError: %f (%v) to uint", tmp, value)
+ } else {
+ return reflect.ValueOf(uint(tmp)), nil
+ }
+ case reflect.Uint8: // Uint8
+ tmp := value.number().int64
+ if tmp < 0 || tmp > int64_maxUint8 {
+ return reflect.Value{}, fmt.Errorf("RangeError: %d (%v) to uint8", tmp, value)
+ } else {
+ return reflect.ValueOf(uint8(tmp)), nil
+ }
+ case reflect.Uint16: // Uint16
+ tmp := value.number().int64
+ if tmp < 0 || tmp > int64_maxUint16 {
+ return reflect.Value{}, fmt.Errorf("RangeError: %d (%v) to uint16", tmp, value)
+ } else {
+ return reflect.ValueOf(uint16(tmp)), nil
+ }
+ case reflect.Uint32: // Uint32
+ tmp := value.number().int64
+ if tmp < 0 || tmp > int64_maxUint32 {
+ return reflect.Value{}, fmt.Errorf("RangeError: %d (%v) to uint32", tmp, value)
+ } else {
+ return reflect.ValueOf(uint32(tmp)), nil
+ }
+ case reflect.Uint64: // Uint64
+ // We convert to float64 here because converting to int64 will not tell us
+ // if a value is outside the range of uint64
+ tmp := toIntegerFloat(value)
+ if tmp < 0 || tmp > float_maxUint64 {
+ return reflect.Value{}, fmt.Errorf("RangeError: %f (%v) to uint64", tmp, value)
+ } else {
+ return reflect.ValueOf(uint64(tmp)), nil
+ }
+ case reflect.Float32: // Float32
+ tmp := value.float64()
+ tmp1 := tmp
+ if 0 > tmp1 {
+ tmp1 = -tmp1
+ }
+ if tmp1 < math.SmallestNonzeroFloat32 || tmp1 > math.MaxFloat32 {
+ return reflect.Value{}, fmt.Errorf("RangeError: %f (%v) to float32", tmp, value)
+ } else {
+ return reflect.ValueOf(float32(tmp)), nil
+ }
+ case reflect.Float64: // Float64
+ value := value.float64()
+ return reflect.ValueOf(float64(value)), nil
+ case reflect.String: // String
+ return reflect.ValueOf(value.string()), nil
+ case reflect.Invalid: // Invalid
+ case reflect.Complex64: // FIXME? Complex64
+ case reflect.Complex128: // FIXME? Complex128
+ case reflect.Chan: // FIXME? Chan
+ case reflect.Func: // FIXME? Func
+ case reflect.Ptr: // FIXME? Ptr
+ case reflect.UnsafePointer: // FIXME? UnsafePointer
+ default:
+ switch value.kind {
+ case valueObject:
+ object := value._object()
+ switch vl := object.value.(type) {
+ case *_goStructObject: // Struct
+ return reflect.ValueOf(vl.value.Interface()), nil
+ case *_goMapObject: // Map
+ return reflect.ValueOf(vl.value.Interface()), nil
+ case *_goArrayObject: // Array
+ return reflect.ValueOf(vl.value.Interface()), nil
+ case *_goSliceObject: // Slice
+ return reflect.ValueOf(vl.value.Interface()), nil
+ }
+ return reflect.ValueOf(value.exportNative()), nil
+ case valueEmpty, valueResult, valueReference:
+ // These are invalid, and should panic
+ default:
+ return reflect.ValueOf(value.value), nil
+ }
+ }
+
+ // FIXME Should this end up as a TypeError?
+ panic(fmt.Errorf("invalid conversion of %v (%v) to reflect.Kind: %v", value.kind, value, kind))
+}
+
+func stringToReflectValue(value string, kind reflect.Kind) (reflect.Value, error) {
+ switch kind {
+ case reflect.Bool:
+ value, err := strconv.ParseBool(value)
+ if err != nil {
+ return reflect.Value{}, err
+ }
+ return reflect.ValueOf(value), nil
+ case reflect.Int:
+ value, err := strconv.ParseInt(value, 0, 0)
+ if err != nil {
+ return reflect.Value{}, err
+ }
+ return reflect.ValueOf(int(value)), nil
+ case reflect.Int8:
+ value, err := strconv.ParseInt(value, 0, 8)
+ if err != nil {
+ return reflect.Value{}, err
+ }
+ return reflect.ValueOf(int8(value)), nil
+ case reflect.Int16:
+ value, err := strconv.ParseInt(value, 0, 16)
+ if err != nil {
+ return reflect.Value{}, err
+ }
+ return reflect.ValueOf(int16(value)), nil
+ case reflect.Int32:
+ value, err := strconv.ParseInt(value, 0, 32)
+ if err != nil {
+ return reflect.Value{}, err
+ }
+ return reflect.ValueOf(int32(value)), nil
+ case reflect.Int64:
+ value, err := strconv.ParseInt(value, 0, 64)
+ if err != nil {
+ return reflect.Value{}, err
+ }
+ return reflect.ValueOf(int64(value)), nil
+ case reflect.Uint:
+ value, err := strconv.ParseUint(value, 0, 0)
+ if err != nil {
+ return reflect.Value{}, err
+ }
+ return reflect.ValueOf(uint(value)), nil
+ case reflect.Uint8:
+ value, err := strconv.ParseUint(value, 0, 8)
+ if err != nil {
+ return reflect.Value{}, err
+ }
+ return reflect.ValueOf(uint8(value)), nil
+ case reflect.Uint16:
+ value, err := strconv.ParseUint(value, 0, 16)
+ if err != nil {
+ return reflect.Value{}, err
+ }
+ return reflect.ValueOf(uint16(value)), nil
+ case reflect.Uint32:
+ value, err := strconv.ParseUint(value, 0, 32)
+ if err != nil {
+ return reflect.Value{}, err
+ }
+ return reflect.ValueOf(uint32(value)), nil
+ case reflect.Uint64:
+ value, err := strconv.ParseUint(value, 0, 64)
+ if err != nil {
+ return reflect.Value{}, err
+ }
+ return reflect.ValueOf(uint64(value)), nil
+ case reflect.Float32:
+ value, err := strconv.ParseFloat(value, 32)
+ if err != nil {
+ return reflect.Value{}, err
+ }
+ return reflect.ValueOf(float32(value)), nil
+ case reflect.Float64:
+ value, err := strconv.ParseFloat(value, 64)
+ if err != nil {
+ return reflect.Value{}, err
+ }
+ return reflect.ValueOf(float64(value)), nil
+ case reflect.String:
+ return reflect.ValueOf(value), nil
+ }
+
+ // FIXME This should end up as a TypeError?
+ panic(fmt.Errorf("invalid conversion of %q to reflect.Kind: %v", value, kind))
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/value_boolean.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/value_boolean.go
new file mode 100644
index 000000000..3040f4163
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/value_boolean.go
@@ -0,0 +1,40 @@
+package otto
+
+import (
+ "fmt"
+ "math"
+ "reflect"
+)
+
+func (value Value) bool() bool {
+ if value.kind == valueBoolean {
+ return value.value.(bool)
+ }
+ if value.IsUndefined() {
+ return false
+ }
+ if value.IsNull() {
+ return false
+ }
+ switch value := value.value.(type) {
+ case bool:
+ return value
+ case int, int8, int16, int32, int64:
+ return 0 != reflect.ValueOf(value).Int()
+ case uint, uint8, uint16, uint32, uint64:
+ return 0 != reflect.ValueOf(value).Uint()
+ case float32:
+ return 0 != value
+ case float64:
+ if math.IsNaN(value) || value == 0 {
+ return false
+ }
+ return true
+ case string:
+ return 0 != len(value)
+ }
+ if value.IsObject() {
+ return true
+ }
+ panic(fmt.Errorf("toBoolean(%T)", value.value))
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/value_number.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/value_number.go
new file mode 100644
index 000000000..54996c729
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/value_number.go
@@ -0,0 +1,324 @@
+package otto
+
+import (
+ "fmt"
+ "math"
+ "regexp"
+ "strconv"
+ "strings"
+)
+
+var stringToNumberParseInteger = regexp.MustCompile(`^(?:0[xX])`)
+
+func parseNumber(value string) float64 {
+ value = strings.TrimSpace(value)
+
+ if value == "" {
+ return 0
+ }
+
+ parseFloat := false
+ if strings.IndexRune(value, '.') != -1 {
+ parseFloat = true
+ } else if stringToNumberParseInteger.MatchString(value) {
+ parseFloat = false
+ } else {
+ parseFloat = true
+ }
+
+ if parseFloat {
+ number, err := strconv.ParseFloat(value, 64)
+ if err != nil && err.(*strconv.NumError).Err != strconv.ErrRange {
+ return math.NaN()
+ }
+ return number
+ }
+
+ number, err := strconv.ParseInt(value, 0, 64)
+ if err != nil {
+ return math.NaN()
+ }
+ return float64(number)
+}
+
+func (value Value) float64() float64 {
+ switch value.kind {
+ case valueUndefined:
+ return math.NaN()
+ case valueNull:
+ return 0
+ }
+ switch value := value.value.(type) {
+ case bool:
+ if value {
+ return 1
+ }
+ return 0
+ case int:
+ return float64(value)
+ case int8:
+ return float64(value)
+ case int16:
+ return float64(value)
+ case int32:
+ return float64(value)
+ case int64:
+ return float64(value)
+ case uint:
+ return float64(value)
+ case uint8:
+ return float64(value)
+ case uint16:
+ return float64(value)
+ case uint32:
+ return float64(value)
+ case uint64:
+ return float64(value)
+ case float64:
+ return value
+ case string:
+ return parseNumber(value)
+ case *_object:
+ return value.DefaultValue(defaultValueHintNumber).float64()
+ }
+ panic(fmt.Errorf("toFloat(%T)", value.value))
+}
+
+const (
+ float_2_64 float64 = 18446744073709551616.0
+ float_2_63 float64 = 9223372036854775808.0
+ float_2_32 float64 = 4294967296.0
+ float_2_31 float64 = 2147483648.0
+ float_2_16 float64 = 65536.0
+ integer_2_32 int64 = 4294967296
+ integer_2_31 int64 = 2146483648
+ sqrt1_2 float64 = math.Sqrt2 / 2
+)
+
+const (
+ maxInt8 = math.MaxInt8
+ minInt8 = math.MinInt8
+ maxInt16 = math.MaxInt16
+ minInt16 = math.MinInt16
+ maxInt32 = math.MaxInt32
+ minInt32 = math.MinInt32
+ maxInt64 = math.MaxInt64
+ minInt64 = math.MinInt64
+ maxUint8 = math.MaxUint8
+ maxUint16 = math.MaxUint16
+ maxUint32 = math.MaxUint32
+ maxUint64 = math.MaxUint64
+ maxUint = ^uint(0)
+ minUint = 0
+ maxInt = int(^uint(0) >> 1)
+ minInt = -maxInt - 1
+
+ // int64
+ int64_maxInt int64 = int64(maxInt)
+ int64_minInt int64 = int64(minInt)
+ int64_maxInt8 int64 = math.MaxInt8
+ int64_minInt8 int64 = math.MinInt8
+ int64_maxInt16 int64 = math.MaxInt16
+ int64_minInt16 int64 = math.MinInt16
+ int64_maxInt32 int64 = math.MaxInt32
+ int64_minInt32 int64 = math.MinInt32
+ int64_maxUint8 int64 = math.MaxUint8
+ int64_maxUint16 int64 = math.MaxUint16
+ int64_maxUint32 int64 = math.MaxUint32
+
+ // float64
+ float_maxInt float64 = float64(int(^uint(0) >> 1))
+ float_minInt float64 = float64(int(-maxInt - 1))
+ float_minUint float64 = float64(0)
+ float_maxUint float64 = float64(uint(^uint(0)))
+ float_minUint64 float64 = float64(0)
+ float_maxUint64 float64 = math.MaxUint64
+ float_maxInt64 float64 = math.MaxInt64
+ float_minInt64 float64 = math.MinInt64
+)
+
+func toIntegerFloat(value Value) float64 {
+ float := value.float64()
+ if math.IsInf(float, 0) {
+ } else if math.IsNaN(float) {
+ float = 0
+ } else if float > 0 {
+ float = math.Floor(float)
+ } else {
+ float = math.Ceil(float)
+ }
+ return float
+}
+
+type _numberKind int
+
+const (
+ numberInteger _numberKind = iota // 3.0 => 3.0
+ numberFloat // 3.14159 => 3.0, 1+2**63 > 2**63-1
+ numberInfinity // Infinity => 2**63-1
+ numberNaN // NaN => 0
+)
+
+type _number struct {
+ kind _numberKind
+ int64 int64
+ float64 float64
+}
+
+// FIXME
+// http://www.goinggo.net/2013/08/gustavos-ieee-754-brain-teaser.html
+// http://bazaar.launchpad.net/~niemeyer/strepr/trunk/view/6/strepr.go#L160
+func (vl Value) number() (number _number) {
+ switch vl := vl.value.(type) {
+ case int8:
+ number.int64 = int64(vl)
+ return
+ case int16:
+ number.int64 = int64(vl)
+ return
+ case uint8:
+ number.int64 = int64(vl)
+ return
+ case uint16:
+ number.int64 = int64(vl)
+ return
+ case uint32:
+ number.int64 = int64(vl)
+ return
+ case int:
+ number.int64 = int64(vl)
+ return
+ case int64:
+ number.int64 = vl
+ return
+ }
+
+ float := vl.float64()
+ if float == 0 {
+ return
+ }
+
+ number.kind = numberFloat
+ number.float64 = float
+
+ if math.IsNaN(float) {
+ number.kind = numberNaN
+ return
+ }
+
+ if math.IsInf(float, 0) {
+ number.kind = numberInfinity
+ }
+
+ if float >= float_maxInt64 {
+ number.int64 = math.MaxInt64
+ return
+ }
+
+ if float <= float_minInt64 {
+ number.int64 = math.MinInt64
+ return
+ }
+
+ integer := float64(0)
+ if float > 0 {
+ integer = math.Floor(float)
+ } else {
+ integer = math.Ceil(float)
+ }
+
+ if float == integer {
+ number.kind = numberInteger
+ }
+ number.int64 = int64(float)
+ return
+}
+
+// ECMA 262: 9.5
+func toInt32(value Value) int32 {
+ {
+ switch value := value.value.(type) {
+ case int8:
+ return int32(value)
+ case int16:
+ return int32(value)
+ case int32:
+ return value
+ }
+ }
+ floatValue := value.float64()
+ if math.IsNaN(floatValue) || math.IsInf(floatValue, 0) {
+ return 0
+ }
+ if floatValue == 0 { // This will work for +0 & -0
+ return 0
+ }
+ remainder := math.Mod(floatValue, float_2_32)
+ if remainder > 0 {
+ remainder = math.Floor(remainder)
+ } else {
+ remainder = math.Ceil(remainder) + float_2_32
+ }
+ if remainder > float_2_31 {
+ return int32(remainder - float_2_32)
+ }
+ return int32(remainder)
+}
+
+func toUint32(value Value) uint32 {
+ {
+ switch value := value.value.(type) {
+ case int8:
+ return uint32(value)
+ case int16:
+ return uint32(value)
+ case uint8:
+ return uint32(value)
+ case uint16:
+ return uint32(value)
+ case uint32:
+ return value
+ }
+ }
+ floatValue := value.float64()
+ if math.IsNaN(floatValue) || math.IsInf(floatValue, 0) {
+ return 0
+ }
+ if floatValue == 0 {
+ return 0
+ }
+ remainder := math.Mod(floatValue, float_2_32)
+ if remainder > 0 {
+ remainder = math.Floor(remainder)
+ } else {
+ remainder = math.Ceil(remainder) + float_2_32
+ }
+ return uint32(remainder)
+}
+
+func toUint16(value Value) uint16 {
+ {
+ switch value := value.value.(type) {
+ case int8:
+ return uint16(value)
+ case uint8:
+ return uint16(value)
+ case uint16:
+ return value
+ }
+ }
+ floatValue := value.float64()
+ if math.IsNaN(floatValue) || math.IsInf(floatValue, 0) {
+ return 0
+ }
+ if floatValue == 0 {
+ return 0
+ }
+ remainder := math.Mod(floatValue, float_2_16)
+ if remainder > 0 {
+ remainder = math.Floor(remainder)
+ } else {
+ remainder = math.Ceil(remainder) + float_2_16
+ }
+ return uint16(remainder)
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/value_primitive.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/value_primitive.go
new file mode 100644
index 000000000..11ed329d1
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/value_primitive.go
@@ -0,0 +1,23 @@
+package otto
+
+func toStringPrimitive(value Value) Value {
+ return _toPrimitive(value, defaultValueHintString)
+}
+
+func toNumberPrimitive(value Value) Value {
+ return _toPrimitive(value, defaultValueHintNumber)
+}
+
+func toPrimitive(value Value) Value {
+ return _toPrimitive(value, defaultValueNoHint)
+}
+
+func _toPrimitive(value Value, hint _defaultValueHint) Value {
+ switch value.kind {
+ case valueNull, valueUndefined, valueNumber, valueString, valueBoolean:
+ return value
+ case valueObject:
+ return value._object().DefaultValue(hint)
+ }
+ panic(hereBeDragons(value.kind, value))
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/value_string.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/value_string.go
new file mode 100644
index 000000000..0fbfd6b25
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/value_string.go
@@ -0,0 +1,103 @@
+package otto
+
+import (
+ "fmt"
+ "math"
+ "regexp"
+ "strconv"
+ "unicode/utf16"
+)
+
+var matchLeading0Exponent = regexp.MustCompile(`([eE][\+\-])0+([1-9])`) // 1e-07 => 1e-7
+
+// FIXME
+// https://code.google.com/p/v8/source/browse/branches/bleeding_edge/src/conversions.cc?spec=svn18082&r=18082
+func floatToString(value float64, bitsize int) string {
+ // TODO Fit to ECMA-262 9.8.1 specification
+ if math.IsNaN(value) {
+ return "NaN"
+ } else if math.IsInf(value, 0) {
+ if math.Signbit(value) {
+ return "-Infinity"
+ }
+ return "Infinity"
+ }
+ exponent := math.Log10(math.Abs(value))
+ if exponent >= 21 || exponent < -6 {
+ return matchLeading0Exponent.ReplaceAllString(strconv.FormatFloat(value, 'g', -1, bitsize), "$1$2")
+ }
+ return strconv.FormatFloat(value, 'f', -1, bitsize)
+}
+
+func numberToStringRadix(value Value, radix int) string {
+ float := value.float64()
+ if math.IsNaN(float) {
+ return "NaN"
+ } else if math.IsInf(float, 1) {
+ return "Infinity"
+ } else if math.IsInf(float, -1) {
+ return "-Infinity"
+ }
+ // FIXME This is very broken
+ // Need to do proper radix conversion for floats, ...
+ // This truncates large floats (so bad).
+ return strconv.FormatInt(int64(float), radix)
+}
+
+func (value Value) string() string {
+ if value.kind == valueString {
+ switch value := value.value.(type) {
+ case string:
+ return value
+ case []uint16:
+ return string(utf16.Decode(value))
+ }
+ }
+ if value.IsUndefined() {
+ return "undefined"
+ }
+ if value.IsNull() {
+ return "null"
+ }
+ switch value := value.value.(type) {
+ case bool:
+ return strconv.FormatBool(value)
+ case int:
+ return strconv.FormatInt(int64(value), 10)
+ case int8:
+ return strconv.FormatInt(int64(value), 10)
+ case int16:
+ return strconv.FormatInt(int64(value), 10)
+ case int32:
+ return strconv.FormatInt(int64(value), 10)
+ case int64:
+ return strconv.FormatInt(value, 10)
+ case uint:
+ return strconv.FormatUint(uint64(value), 10)
+ case uint8:
+ return strconv.FormatUint(uint64(value), 10)
+ case uint16:
+ return strconv.FormatUint(uint64(value), 10)
+ case uint32:
+ return strconv.FormatUint(uint64(value), 10)
+ case uint64:
+ return strconv.FormatUint(value, 10)
+ case float32:
+ if value == 0 {
+ return "0" // Take care not to return -0
+ }
+ return floatToString(float64(value), 32)
+ case float64:
+ if value == 0 {
+ return "0" // Take care not to return -0
+ }
+ return floatToString(value, 64)
+ case []uint16:
+ return string(utf16.Decode(value))
+ case string:
+ return value
+ case *_object:
+ return value.DefaultValue(defaultValueHintString).string()
+ }
+ panic(fmt.Errorf("%v.string( %T)", value.value, value.value))
+}
diff --git a/Godeps/_workspace/src/github.com/robertkrimen/otto/value_test.go b/Godeps/_workspace/src/github.com/robertkrimen/otto/value_test.go
new file mode 100644
index 000000000..4a9bd546f
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/robertkrimen/otto/value_test.go
@@ -0,0 +1,281 @@
+package otto
+
+import (
+ "encoding/json"
+ "math"
+ "testing"
+)
+
+func TestValue(t *testing.T) {
+ tt(t, func() {
+ value := UndefinedValue()
+ is(value.IsUndefined(), true)
+ is(value, UndefinedValue())
+ is(value, "undefined")
+
+ is(toValue(false), false)
+ is(toValue(1), 1)
+ is(toValue(1).float64(), float64(1))
+ })
+}
+
+func TestObject(t *testing.T) {
+ tt(t, func() {
+ is(emptyValue.isEmpty(), true)
+ //is(newObject().Value(), "[object]")
+ //is(newBooleanObject(false).Value(), "false")
+ //is(newFunctionObject(nil).Value(), "[function]")
+ //is(newNumberObject(1).Value(), "1")
+ //is(newStringObject("Hello, World.").Value(), "Hello, World.")
+ })
+}
+
+type intAlias int
+
+func TestToValue(t *testing.T) {
+ tt(t, func() {
+ _, tester := test()
+ vm := tester.vm
+
+ value, _ := vm.ToValue(nil)
+ is(value, "undefined")
+
+ value, _ = vm.ToValue((*byte)(nil))
+ is(value, "undefined")
+
+ value, _ = vm.ToValue(intAlias(5))
+ is(value, 5)
+
+ {
+ tmp := new(int)
+
+ value, _ = vm.ToValue(&tmp)
+ is(value, 0)
+
+ *tmp = 1
+
+ value, _ = vm.ToValue(&tmp)
+ is(value, 1)
+
+ tmp = nil
+
+ value, _ = vm.ToValue(&tmp)
+ is(value, "undefined")
+ }
+
+ {
+ tmp0 := new(int)
+ tmp1 := &tmp0
+ tmp2 := &tmp1
+
+ value, _ = vm.ToValue(&tmp2)
+ is(value, 0)
+
+ *tmp0 = 1
+
+ value, _ = vm.ToValue(&tmp2)
+ is(value, 1)
+
+ tmp0 = nil
+
+ value, _ = vm.ToValue(&tmp2)
+ is(value, "undefined")
+ }
+ })
+}
+
+func TestToBoolean(t *testing.T) {
+ tt(t, func() {
+ is := func(left interface{}, right bool) {
+ is(toValue(left).bool(), right)
+ }
+
+ is("", false)
+ is("xyzzy", true)
+ is(1, true)
+ is(0, false)
+ //is(toValue(newObject()), true)
+ is(UndefinedValue(), false)
+ is(NullValue(), false)
+ })
+}
+
+func TestToFloat(t *testing.T) {
+ tt(t, func() {
+ {
+ is := func(left interface{}, right float64) {
+ is(toValue(left).float64(), right)
+ }
+ is("", 0)
+ is("xyzzy", math.NaN())
+ is("2", 2)
+ is(1, 1)
+ is(0, 0)
+ is(NullValue(), 0)
+ //is(newObjectValue(), math.NaN())
+ }
+ is(math.IsNaN(UndefinedValue().float64()), true)
+ })
+}
+
+func TestToString(t *testing.T) {
+ tt(t, func() {
+ is("undefined", UndefinedValue().string())
+ is("null", NullValue().string())
+ is("true", toValue(true).string())
+ is("false", toValue(false).string())
+
+ is(UndefinedValue(), "undefined")
+ is(NullValue(), "null")
+ is(toValue(true), true)
+ is(toValue(false), false)
+ })
+}
+
+func Test_toInt32(t *testing.T) {
+ tt(t, func() {
+ test := []interface{}{
+ 0, int32(0),
+ 1, int32(1),
+ -2147483649.0, int32(2147483647),
+ -4294967297.0, int32(-1),
+ -4294967296.0, int32(0),
+ -4294967295.0, int32(1),
+ math.Inf(+1), int32(0),
+ math.Inf(-1), int32(0),
+ }
+ for index := 0; index < len(test)/2; index++ {
+ // FIXME terst, Make strict again?
+ is(
+ toInt32(toValue(test[index*2])),
+ test[index*2+1].(int32),
+ )
+ }
+ })
+}
+
+func Test_toUint32(t *testing.T) {
+ tt(t, func() {
+ test := []interface{}{
+ 0, uint32(0),
+ 1, uint32(1),
+ -2147483649.0, uint32(2147483647),
+ -4294967297.0, uint32(4294967295),
+ -4294967296.0, uint32(0),
+ -4294967295.0, uint32(1),
+ math.Inf(+1), uint32(0),
+ math.Inf(-1), uint32(0),
+ }
+ for index := 0; index < len(test)/2; index++ {
+ // FIXME terst, Make strict again?
+ is(
+ toUint32(toValue(test[index*2])),
+ test[index*2+1].(uint32),
+ )
+ }
+ })
+}
+
+func Test_toUint16(t *testing.T) {
+ tt(t, func() {
+ test := []interface{}{
+ 0, uint16(0),
+ 1, uint16(1),
+ -2147483649.0, uint16(65535),
+ -4294967297.0, uint16(65535),
+ -4294967296.0, uint16(0),
+ -4294967295.0, uint16(1),
+ math.Inf(+1), uint16(0),
+ math.Inf(-1), uint16(0),
+ }
+ for index := 0; index < len(test)/2; index++ {
+ // FIXME terst, Make strict again?
+ is(
+ toUint16(toValue(test[index*2])),
+ test[index*2+1].(uint16),
+ )
+ }
+ })
+}
+
+func Test_sameValue(t *testing.T) {
+ tt(t, func() {
+ is(sameValue(positiveZeroValue(), negativeZeroValue()), false)
+ is(sameValue(positiveZeroValue(), toValue(0)), true)
+ is(sameValue(NaNValue(), NaNValue()), true)
+ is(sameValue(NaNValue(), toValue("Nothing happens.")), false)
+ })
+}
+
+func TestExport(t *testing.T) {
+ tt(t, func() {
+ test, vm := test()
+
+ is(test(`null;`).export(), nil)
+ is(test(`undefined;`).export(), nil)
+ is(test(`true;`).export(), true)
+ is(test(`false;`).export(), false)
+ is(test(`0;`).export(), 0)
+ is(test(`3.1459`).export(), 3.1459)
+ is(test(`"Nothing happens";`).export(), "Nothing happens")
+ is(test(`String.fromCharCode(97,98,99,100,101,102)`).export(), "abcdef")
+ {
+ value := test(`({ abc: 1, def: true, ghi: undefined });`).export().(map[string]interface{})
+ is(value["abc"], 1)
+ is(value["def"], true)
+ _, exists := value["ghi"]
+ is(exists, false)
+ }
+ {
+ value := test(`[ "abc", 1, "def", true, undefined, null ];`).export().([]interface{})
+ is(value[0], "abc")
+ is(value[1], 1)
+ is(value[2], "def")
+ is(value[3], true)
+ is(value[4], nil)
+ is(value[5], nil)
+ is(value[5], interface{}(nil))
+ }
+
+ roundtrip := []interface{}{
+ true,
+ false,
+ 0,
+ 3.1459,
+ []interface{}{true, false, 0, 3.1459, "abc"},
+ map[string]interface{}{
+ "Boolean": true,
+ "Number": 3.1459,
+ "String": "abc",
+ "Array": []interface{}{false, 0, "", nil},
+ "Object": map[string]interface{}{
+ "Boolean": false,
+ "Number": 0,
+ "String": "def",
+ },
+ },
+ }
+
+ for _, value := range roundtrip {
+ input, err := json.Marshal(value)
+ is(err, nil)
+
+ output, err := json.Marshal(test("(" + string(input) + ");").export())
+ is(err, nil)
+
+ is(string(input), string(output))
+ }
+
+ {
+ abc := struct {
+ def int
+ ghi interface{}
+ xyz float32
+ }{}
+ abc.def = 3
+ abc.xyz = 3.1459
+ vm.Set("abc", abc)
+ is(test(`abc;`).export(), abc)
+ }
+ })
+}