diff --git a/vendor/github.com/r3labs/sse/v2/.gitignore b/vendor/github.com/r3labs/sse/v2/.gitignore
new file mode 100644
index 0000000..d48c759
--- /dev/null
+++ b/vendor/github.com/r3labs/sse/v2/.gitignore
@@ -0,0 +1,2 @@
+.idea
+.vscode
\ No newline at end of file
diff --git a/vendor/github.com/r3labs/sse/v2/.golangci.yml b/vendor/github.com/r3labs/sse/v2/.golangci.yml
new file mode 100644
index 0000000..5a76e9a
--- /dev/null
+++ b/vendor/github.com/r3labs/sse/v2/.golangci.yml
@@ -0,0 +1,15 @@
+linters:
+ enable-all: true
+ disable:
+ - gofmt
+ - gofumpt
+ - goimports
+ - golint # deprecated
+ - interfacer # deprecated
+ - maligned # deprecated
+ - scopelint # deprecated
+ - varnamelen
+
+linters-settings:
+ govet:
+ enable-all: true
diff --git a/vendor/github.com/r3labs/sse/v2/CONTRIBUTING.md b/vendor/github.com/r3labs/sse/v2/CONTRIBUTING.md
new file mode 100644
index 0000000..b9c7859
--- /dev/null
+++ b/vendor/github.com/r3labs/sse/v2/CONTRIBUTING.md
@@ -0,0 +1,80 @@
+# Contributing guidelines
+
+Looking to contribute something to this project? Here's how you can help:
+
+Please take a moment to review this document in order to make the contribution process easy and effective for everyone involved.
+
+Following these guidelines helps to communicate that you respect the time of the developers managing and developing this open source project. In return, they should reciprocate that respect in addressing your issue or assessing patches and features.
+
+We also have a [code of conduct](https://ernest.io/conduct).
+
+## Using the issue tracker
+
+The issue tracker is the preferred channel for [bug reports](#bug-reports), [features requests](#feature-requests) and [submitting pull requests](#pull-requests), but please respect the following restrictions:
+
+* Please **do not** use the issue tracker for personal support requests.
+
+* Please **do not** derail issues. Keep the discussion on topic and
+ respect the opinions of others.
+
+
+## Bug reports
+
+A bug is a _demonstrable problem_ that is caused by the code in the repository.
+Good bug reports are extremely helpful - thank you!
+
+Guidelines for bug reports:
+
+1. **Use the GitHub issue search** — check if the issue has already been
+ reported.
+
+2. **Check if the issue has been fixed** — try to reproduce it using the
+ latest `master` or `develop` branch in the repository.
+
+3. **Isolate the problem** — create a reduced test case and a live example.
+
+A good bug report shouldn't leave others needing to chase you up for more
+information. Please try to be as detailed as possible in your report. What is
+your environment? What steps will reproduce the issue? Which environment experience the problem? What would you expect to be the outcome? All these
+details will help people to fix any potential bugs.
+
+Example:
+
+> Short and descriptive example bug report title
+>
+> A summary of the issue and the environment in which it occurs. If
+> suitable, include the steps required to reproduce the bug.
+>
+> 1. This is the first step
+> 2. This is the second step
+> 3. Further steps, etc.
+>
+> `` - a link to the reduced test case
+>
+> Any other information you want to share that is relevant to the issue being
+> reported. This might include the lines of code that you have identified as
+> causing the bug, and potential solutions (and your opinions on their
+> merits).
+
+
+## Feature requests
+
+Feature requests are welcome. But take a moment to find out whether your idea
+fits with the scope and aims of the project. It's up to *you* to make a strong
+case to convince the project's developers of the merits of this feature. Please
+provide as much detail and context as possible.
+
+
+## Pull requests
+
+Good pull requests - patches, improvements, new features - are a fantastic
+help. They should remain focused in scope and avoid containing unrelated
+commits.
+
+[**Please ask first**](https://ernest.io/community) before embarking on any significant pull request (e.g.
+implementing features, refactoring code, porting to a different language),
+otherwise you risk spending a lot of time working on something that the
+project's developers might not want to merge into the project.
+
+Please adhere to the coding conventions used throughout a project (indentation,
+accurate comments, etc.) and any other requirements (such as test coverage).
diff --git a/vendor/github.com/r3labs/sse/v2/LICENSE b/vendor/github.com/r3labs/sse/v2/LICENSE
new file mode 100644
index 0000000..a612ad9
--- /dev/null
+++ b/vendor/github.com/r3labs/sse/v2/LICENSE
@@ -0,0 +1,373 @@
+Mozilla Public License Version 2.0
+==================================
+
+1. Definitions
+--------------
+
+1.1. "Contributor"
+ means each individual or legal entity that creates, contributes to
+ the creation of, or owns Covered Software.
+
+1.2. "Contributor Version"
+ means the combination of the Contributions of others (if any) used
+ by a Contributor and that particular Contributor's Contribution.
+
+1.3. "Contribution"
+ means Covered Software of a particular Contributor.
+
+1.4. "Covered Software"
+ means Source Code Form to which the initial Contributor has attached
+ the notice in Exhibit A, the Executable Form of such Source Code
+ Form, and Modifications of such Source Code Form, in each case
+ including portions thereof.
+
+1.5. "Incompatible With Secondary Licenses"
+ means
+
+ (a) that the initial Contributor has attached the notice described
+ in Exhibit B to the Covered Software; or
+
+ (b) that the Covered Software was made available under the terms of
+ version 1.1 or earlier of the License, but not also under the
+ terms of a Secondary License.
+
+1.6. "Executable Form"
+ means any form of the work other than Source Code Form.
+
+1.7. "Larger Work"
+ means a work that combines Covered Software with other material, in
+ a separate file or files, that is not Covered Software.
+
+1.8. "License"
+ means this document.
+
+1.9. "Licensable"
+ means having the right to grant, to the maximum extent possible,
+ whether at the time of the initial grant or subsequently, any and
+ all of the rights conveyed by this License.
+
+1.10. "Modifications"
+ means any of the following:
+
+ (a) any file in Source Code Form that results from an addition to,
+ deletion from, or modification of the contents of Covered
+ Software; or
+
+ (b) any new file in Source Code Form that contains any Covered
+ Software.
+
+1.11. "Patent Claims" of a Contributor
+ means any patent claim(s), including without limitation, method,
+ process, and apparatus claims, in any patent Licensable by such
+ Contributor that would be infringed, but for the grant of the
+ License, by the making, using, selling, offering for sale, having
+ made, import, or transfer of either its Contributions or its
+ Contributor Version.
+
+1.12. "Secondary License"
+ means either the GNU General Public License, Version 2.0, the GNU
+ Lesser General Public License, Version 2.1, the GNU Affero General
+ Public License, Version 3.0, or any later versions of those
+ licenses.
+
+1.13. "Source Code Form"
+ means the form of the work preferred for making modifications.
+
+1.14. "You" (or "Your")
+ means an individual or a legal entity exercising rights under this
+ License. For legal entities, "You" includes any entity that
+ controls, is controlled by, or is under common control with You. For
+ purposes of this definition, "control" means (a) the power, direct
+ or indirect, to cause the direction or management of such entity,
+ whether by contract or otherwise, or (b) ownership of more than
+ fifty percent (50%) of the outstanding shares or beneficial
+ ownership of such entity.
+
+2. License Grants and Conditions
+--------------------------------
+
+2.1. Grants
+
+Each Contributor hereby grants You a world-wide, royalty-free,
+non-exclusive license:
+
+(a) under intellectual property rights (other than patent or trademark)
+ Licensable by such Contributor to use, reproduce, make available,
+ modify, display, perform, distribute, and otherwise exploit its
+ Contributions, either on an unmodified basis, with Modifications, or
+ as part of a Larger Work; and
+
+(b) under Patent Claims of such Contributor to make, use, sell, offer
+ for sale, have made, import, and otherwise transfer either its
+ Contributions or its Contributor Version.
+
+2.2. Effective Date
+
+The licenses granted in Section 2.1 with respect to any Contribution
+become effective for each Contribution on the date the Contributor first
+distributes such Contribution.
+
+2.3. Limitations on Grant Scope
+
+The licenses granted in this Section 2 are the only rights granted under
+this License. No additional rights or licenses will be implied from the
+distribution or licensing of Covered Software under this License.
+Notwithstanding Section 2.1(b) above, no patent license is granted by a
+Contributor:
+
+(a) for any code that a Contributor has removed from Covered Software;
+ or
+
+(b) for infringements caused by: (i) Your and any other third party's
+ modifications of Covered Software, or (ii) the combination of its
+ Contributions with other software (except as part of its Contributor
+ Version); or
+
+(c) under Patent Claims infringed by Covered Software in the absence of
+ its Contributions.
+
+This License does not grant any rights in the trademarks, service marks,
+or logos of any Contributor (except as may be necessary to comply with
+the notice requirements in Section 3.4).
+
+2.4. Subsequent Licenses
+
+No Contributor makes additional grants as a result of Your choice to
+distribute the Covered Software under a subsequent version of this
+License (see Section 10.2) or under the terms of a Secondary License (if
+permitted under the terms of Section 3.3).
+
+2.5. Representation
+
+Each Contributor represents that the Contributor believes its
+Contributions are its original creation(s) or it has sufficient rights
+to grant the rights to its Contributions conveyed by this License.
+
+2.6. Fair Use
+
+This License is not intended to limit any rights You have under
+applicable copyright doctrines of fair use, fair dealing, or other
+equivalents.
+
+2.7. Conditions
+
+Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
+in Section 2.1.
+
+3. Responsibilities
+-------------------
+
+3.1. Distribution of Source Form
+
+All distribution of Covered Software in Source Code Form, including any
+Modifications that You create or to which You contribute, must be under
+the terms of this License. You must inform recipients that the Source
+Code Form of the Covered Software is governed by the terms of this
+License, and how they can obtain a copy of this License. You may not
+attempt to alter or restrict the recipients' rights in the Source Code
+Form.
+
+3.2. Distribution of Executable Form
+
+If You distribute Covered Software in Executable Form then:
+
+(a) such Covered Software must also be made available in Source Code
+ Form, as described in Section 3.1, and You must inform recipients of
+ the Executable Form how they can obtain a copy of such Source Code
+ Form by reasonable means in a timely manner, at a charge no more
+ than the cost of distribution to the recipient; and
+
+(b) You may distribute such Executable Form under the terms of this
+ License, or sublicense it under different terms, provided that the
+ license for the Executable Form does not attempt to limit or alter
+ the recipients' rights in the Source Code Form under this License.
+
+3.3. Distribution of a Larger Work
+
+You may create and distribute a Larger Work under terms of Your choice,
+provided that You also comply with the requirements of this License for
+the Covered Software. If the Larger Work is a combination of Covered
+Software with a work governed by one or more Secondary Licenses, and the
+Covered Software is not Incompatible With Secondary Licenses, this
+License permits You to additionally distribute such Covered Software
+under the terms of such Secondary License(s), so that the recipient of
+the Larger Work may, at their option, further distribute the Covered
+Software under the terms of either this License or such Secondary
+License(s).
+
+3.4. Notices
+
+You may not remove or alter the substance of any license notices
+(including copyright notices, patent notices, disclaimers of warranty,
+or limitations of liability) contained within the Source Code Form of
+the Covered Software, except that You may alter any license notices to
+the extent required to remedy known factual inaccuracies.
+
+3.5. Application of Additional Terms
+
+You may choose to offer, and to charge a fee for, warranty, support,
+indemnity or liability obligations to one or more recipients of Covered
+Software. However, You may do so only on Your own behalf, and not on
+behalf of any Contributor. You must make it absolutely clear that any
+such warranty, support, indemnity, or liability obligation is offered by
+You alone, and You hereby agree to indemnify every Contributor for any
+liability incurred by such Contributor as a result of warranty, support,
+indemnity or liability terms You offer. You may include additional
+disclaimers of warranty and limitations of liability specific to any
+jurisdiction.
+
+4. Inability to Comply Due to Statute or Regulation
+---------------------------------------------------
+
+If it is impossible for You to comply with any of the terms of this
+License with respect to some or all of the Covered Software due to
+statute, judicial order, or regulation then You must: (a) comply with
+the terms of this License to the maximum extent possible; and (b)
+describe the limitations and the code they affect. Such description must
+be placed in a text file included with all distributions of the Covered
+Software under this License. Except to the extent prohibited by statute
+or regulation, such description must be sufficiently detailed for a
+recipient of ordinary skill to be able to understand it.
+
+5. Termination
+--------------
+
+5.1. The rights granted under this License will terminate automatically
+if You fail to comply with any of its terms. However, if You become
+compliant, then the rights granted under this License from a particular
+Contributor are reinstated (a) provisionally, unless and until such
+Contributor explicitly and finally terminates Your grants, and (b) on an
+ongoing basis, if such Contributor fails to notify You of the
+non-compliance by some reasonable means prior to 60 days after You have
+come back into compliance. Moreover, Your grants from a particular
+Contributor are reinstated on an ongoing basis if such Contributor
+notifies You of the non-compliance by some reasonable means, this is the
+first time You have received notice of non-compliance with this License
+from such Contributor, and You become compliant prior to 30 days after
+Your receipt of the notice.
+
+5.2. If You initiate litigation against any entity by asserting a patent
+infringement claim (excluding declaratory judgment actions,
+counter-claims, and cross-claims) alleging that a Contributor Version
+directly or indirectly infringes any patent, then the rights granted to
+You by any and all Contributors for the Covered Software under Section
+2.1 of this License shall terminate.
+
+5.3. In the event of termination under Sections 5.1 or 5.2 above, all
+end user license agreements (excluding distributors and resellers) which
+have been validly granted by You or Your distributors under this License
+prior to termination shall survive termination.
+
+************************************************************************
+* *
+* 6. Disclaimer of Warranty *
+* ------------------------- *
+* *
+* Covered Software is provided under this License on an "as is" *
+* basis, without warranty of any kind, either expressed, implied, or *
+* statutory, including, without limitation, warranties that the *
+* Covered Software is free of defects, merchantable, fit for a *
+* particular purpose or non-infringing. The entire risk as to the *
+* quality and performance of the Covered Software is with You. *
+* Should any Covered Software prove defective in any respect, You *
+* (not any Contributor) assume the cost of any necessary servicing, *
+* repair, or correction. This disclaimer of warranty constitutes an *
+* essential part of this License. No use of any Covered Software is *
+* authorized under this License except under this disclaimer. *
+* *
+************************************************************************
+
+************************************************************************
+* *
+* 7. Limitation of Liability *
+* -------------------------- *
+* *
+* Under no circumstances and under no legal theory, whether tort *
+* (including negligence), contract, or otherwise, shall any *
+* Contributor, or anyone who distributes Covered Software as *
+* permitted above, be liable to You for any direct, indirect, *
+* special, incidental, or consequential damages of any character *
+* including, without limitation, damages for lost profits, loss of *
+* goodwill, work stoppage, computer failure or malfunction, or any *
+* and all other commercial damages or losses, even if such party *
+* shall have been informed of the possibility of such damages. This *
+* limitation of liability shall not apply to liability for death or *
+* personal injury resulting from such party's negligence to the *
+* extent applicable law prohibits such limitation. Some *
+* jurisdictions do not allow the exclusion or limitation of *
+* incidental or consequential damages, so this exclusion and *
+* limitation may not apply to You. *
+* *
+************************************************************************
+
+8. Litigation
+-------------
+
+Any litigation relating to this License may be brought only in the
+courts of a jurisdiction where the defendant maintains its principal
+place of business and such litigation shall be governed by laws of that
+jurisdiction, without reference to its conflict-of-law provisions.
+Nothing in this Section shall prevent a party's ability to bring
+cross-claims or counter-claims.
+
+9. Miscellaneous
+----------------
+
+This License represents the complete agreement concerning the subject
+matter hereof. If any provision of this License is held to be
+unenforceable, such provision shall be reformed only to the extent
+necessary to make it enforceable. Any law or regulation which provides
+that the language of a contract shall be construed against the drafter
+shall not be used to construe this License against a Contributor.
+
+10. Versions of the License
+---------------------------
+
+10.1. New Versions
+
+Mozilla Foundation is the license steward. Except as provided in Section
+10.3, no one other than the license steward has the right to modify or
+publish new versions of this License. Each version will be given a
+distinguishing version number.
+
+10.2. Effect of New Versions
+
+You may distribute the Covered Software under the terms of the version
+of the License under which You originally received the Covered Software,
+or under the terms of any subsequent version published by the license
+steward.
+
+10.3. Modified Versions
+
+If you create software not governed by this License, and you want to
+create a new license for such software, you may create and use a
+modified version of this License if you rename the license and remove
+any references to the name of the license steward (except to note that
+such modified license differs from this License).
+
+10.4. Distributing Source Code Form that is Incompatible With Secondary
+Licenses
+
+If You choose to distribute Source Code Form that is Incompatible With
+Secondary Licenses under the terms of this version of the License, the
+notice described in Exhibit B of this License must be attached.
+
+Exhibit A - Source Code Form License Notice
+-------------------------------------------
+
+ This Source Code Form is subject to the terms of the Mozilla Public
+ License, v. 2.0. If a copy of the MPL was not distributed with this
+ file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+If it is not possible or desirable to put the notice in a particular
+file, then You may include the notice in a location (such as a LICENSE
+file in a relevant directory) where a recipient would be likely to look
+for such a notice.
+
+You may add additional accurate notices of copyright ownership.
+
+Exhibit B - "Incompatible With Secondary Licenses" Notice
+---------------------------------------------------------
+
+ This Source Code Form is "Incompatible With Secondary Licenses", as
+ defined by the Mozilla Public License, v. 2.0.
diff --git a/vendor/github.com/r3labs/sse/v2/Makefile b/vendor/github.com/r3labs/sse/v2/Makefile
new file mode 100644
index 0000000..a63b700
--- /dev/null
+++ b/vendor/github.com/r3labs/sse/v2/Makefile
@@ -0,0 +1,20 @@
+install:
+ go install -v
+
+build:
+ go build -v ./...
+
+lint:
+ golint ./...
+ go vet ./...
+
+test:
+ go test -v ./... --cover
+
+deps:
+ go get -u gopkg.in/cenkalti/backoff.v1
+ go get -u github.com/golang/lint/golint
+ go get -u github.com/stretchr/testify
+
+clean:
+ go clean
diff --git a/vendor/github.com/r3labs/sse/v2/README.md b/vendor/github.com/r3labs/sse/v2/README.md
new file mode 100644
index 0000000..c2201be
--- /dev/null
+++ b/vendor/github.com/r3labs/sse/v2/README.md
@@ -0,0 +1,191 @@
+# SSE - Server Sent Events Client/Server Library for Go
+
+## Synopsis
+
+SSE is a client/server implementation for Server Sent Events for Golang.
+
+## Build status
+
+* Master: [![CircleCI Master](https://circleci.com/gh/r3labs/sse.svg?style=svg)](https://circleci.com/gh/r3labs/sse)
+
+## Quick start
+
+To install:
+```
+go get github.com/r3labs/sse/v2
+```
+
+To Test:
+
+```sh
+$ make deps
+$ make test
+```
+
+#### Example Server
+
+There are two parts of the server. It is comprised of the message scheduler and a http handler function.
+The messaging system is started when running:
+
+```go
+func main() {
+ server := sse.New()
+}
+```
+
+To add a stream to this handler:
+
+```go
+func main() {
+ server := sse.New()
+ server.CreateStream("messages")
+}
+```
+
+This creates a new stream inside of the scheduler. Seeing as there are no consumers, publishing a message to this channel will do nothing.
+Clients can connect to this stream once the http handler is started by specifying _stream_ as a url parameter, like so:
+
+```
+http://server/events?stream=messages
+```
+
+
+In order to start the http server:
+
+```go
+func main() {
+ server := sse.New()
+
+ // Create a new Mux and set the handler
+ mux := http.NewServeMux()
+ mux.HandleFunc("/events", server.ServeHTTP)
+
+ http.ListenAndServe(":8080", mux)
+}
+```
+
+To publish messages to a stream:
+
+```go
+func main() {
+ server := sse.New()
+
+ // Publish a payload to the stream
+ server.Publish("messages", &sse.Event{
+ Data: []byte("ping"),
+ })
+}
+```
+
+Please note there must be a stream with the name you specify and there must be subscribers to that stream
+
+A way to detect disconnected clients:
+
+```go
+func main() {
+ server := sse.New()
+
+ mux := http.NewServeMux()
+ mux.HandleFunc("/events", func(w http.ResponseWriter, r *http.Request) {
+ go func() {
+ // Received Browser Disconnection
+ <-r.Context().Done()
+ println("The client is disconnected here")
+ return
+ }()
+
+ server.ServeHTTP(w, r)
+ })
+
+ http.ListenAndServe(":8080", mux)
+}
+```
+
+#### Example Client
+
+The client exposes a way to connect to an SSE server. The client can also handle multiple events under the same url.
+
+To create a new client:
+
+```go
+func main() {
+ client := sse.NewClient("http://server/events")
+}
+```
+
+To subscribe to an event stream, please use the Subscribe function. This accepts the name of the stream and a handler function:
+
+```go
+func main() {
+ client := sse.NewClient("http://server/events")
+
+ client.Subscribe("messages", func(msg *sse.Event) {
+ // Got some data!
+ fmt.Println(msg.Data)
+ })
+}
+```
+
+Please note that this function will block the current thread. You can run this function in a go routine.
+
+If you wish to have events sent to a channel, you can use SubscribeChan:
+
+```go
+func main() {
+ events := make(chan *sse.Event)
+
+ client := sse.NewClient("http://server/events")
+ client.SubscribeChan("messages", events)
+}
+```
+
+#### HTTP client parameters
+
+To add additional parameters to the http client, such as disabling ssl verification for self signed certs, you can override the http client or update its options:
+
+```go
+func main() {
+ client := sse.NewClient("http://server/events")
+ client.Connection.Transport = &http.Transport{
+ TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
+ }
+}
+```
+
+#### URL query parameters
+
+To set custom query parameters on the client or disable the stream parameter altogether:
+
+```go
+func main() {
+ client := sse.NewClient("http://server/events?search=example")
+
+ client.SubscribeRaw(func(msg *sse.Event) {
+ // Got some data!
+ fmt.Println(msg.Data)
+ })
+}
+```
+
+
+## Contributing
+
+Please read through our
+[contributing guidelines](CONTRIBUTING.md).
+Included are directions for opening issues, coding standards, and notes on
+development.
+
+Moreover, if your pull request contains patches or features, you must include
+relevant unit tests.
+
+## Versioning
+
+For transparency into our release cycle and in striving to maintain backward
+compatibility, this project is maintained under [the Semantic Versioning guidelines](http://semver.org/).
+
+## Copyright and License
+
+Code and documentation copyright since 2015 r3labs.io authors.
+
+Code released under
+[the Mozilla Public License Version 2.0](LICENSE).
diff --git a/vendor/github.com/r3labs/sse/v2/client.go b/vendor/github.com/r3labs/sse/v2/client.go
new file mode 100644
index 0000000..61772b6
--- /dev/null
+++ b/vendor/github.com/r3labs/sse/v2/client.go
@@ -0,0 +1,390 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+package sse
+
+import (
+ "bytes"
+ "context"
+ "encoding/base64"
+ "errors"
+ "fmt"
+ "io"
+ "net/http"
+ "sync"
+ "sync/atomic"
+ "time"
+
+ "gopkg.in/cenkalti/backoff.v1"
+)
+
+var (
+ headerID = []byte("id:")
+ headerData = []byte("data:")
+ headerEvent = []byte("event:")
+ headerRetry = []byte("retry:")
+)
+
+func ClientMaxBufferSize(s int) func(c *Client) {
+ return func(c *Client) {
+ c.maxBufferSize = s
+ }
+}
+
+// ConnCallback defines a function to be called on a particular connection event
+type ConnCallback func(c *Client)
+
+// ResponseValidator validates a response
+type ResponseValidator func(c *Client, resp *http.Response) error
+
+// Client handles an incoming server stream
+type Client struct {
+ Retry time.Time
+ ReconnectStrategy backoff.BackOff
+ disconnectcb ConnCallback
+ connectedcb ConnCallback
+ subscribed map[chan *Event]chan struct{}
+ Headers map[string]string
+ ReconnectNotify backoff.Notify
+ ResponseValidator ResponseValidator
+ Connection *http.Client
+ URL string
+ LastEventID atomic.Value // []byte
+ maxBufferSize int
+ mu sync.Mutex
+ EncodingBase64 bool
+ Connected bool
+}
+
+// NewClient creates a new client
+func NewClient(url string, opts ...func(c *Client)) *Client {
+ c := &Client{
+ URL: url,
+ Connection: &http.Client{},
+ Headers: make(map[string]string),
+ subscribed: make(map[chan *Event]chan struct{}),
+ maxBufferSize: 1 << 16,
+ }
+
+ for _, opt := range opts {
+ opt(c)
+ }
+
+ return c
+}
+
+// Subscribe to a data stream
+func (c *Client) Subscribe(stream string, handler func(msg *Event)) error {
+ return c.SubscribeWithContext(context.Background(), stream, handler)
+}
+
+// SubscribeWithContext to a data stream with context
+func (c *Client) SubscribeWithContext(ctx context.Context, stream string, handler func(msg *Event)) error {
+ operation := func() error {
+ resp, err := c.request(ctx, stream)
+ if err != nil {
+ return err
+ }
+ if validator := c.ResponseValidator; validator != nil {
+ err = validator(c, resp)
+ if err != nil {
+ return err
+ }
+ } else if resp.StatusCode != 200 {
+ resp.Body.Close()
+ return fmt.Errorf("could not connect to stream: %s", http.StatusText(resp.StatusCode))
+ }
+ defer resp.Body.Close()
+
+ reader := NewEventStreamReader(resp.Body, c.maxBufferSize)
+ eventChan, errorChan := c.startReadLoop(reader)
+
+ for {
+ select {
+ case err = <-errorChan:
+ return err
+ case msg := <-eventChan:
+ handler(msg)
+ }
+ }
+ }
+
+ // Apply user specified reconnection strategy or default to standard NewExponentialBackOff() reconnection method
+ var err error
+ if c.ReconnectStrategy != nil {
+ err = backoff.RetryNotify(operation, c.ReconnectStrategy, c.ReconnectNotify)
+ } else {
+ err = backoff.RetryNotify(operation, backoff.NewExponentialBackOff(), c.ReconnectNotify)
+ }
+ return err
+}
+
+// SubscribeChan sends all events to the provided channel
+func (c *Client) SubscribeChan(stream string, ch chan *Event) error {
+ return c.SubscribeChanWithContext(context.Background(), stream, ch)
+}
+
+// SubscribeChanWithContext sends all events to the provided channel with context
+func (c *Client) SubscribeChanWithContext(ctx context.Context, stream string, ch chan *Event) error {
+ var connected bool
+ errch := make(chan error)
+ c.mu.Lock()
+ c.subscribed[ch] = make(chan struct{})
+ c.mu.Unlock()
+
+ operation := func() error {
+ resp, err := c.request(ctx, stream)
+ if err != nil {
+ return err
+ }
+ if validator := c.ResponseValidator; validator != nil {
+ err = validator(c, resp)
+ if err != nil {
+ return err
+ }
+ } else if resp.StatusCode != 200 {
+ resp.Body.Close()
+ return fmt.Errorf("could not connect to stream: %s", http.StatusText(resp.StatusCode))
+ }
+ defer resp.Body.Close()
+
+ if !connected {
+ // Notify connect
+ errch <- nil
+ connected = true
+ }
+
+ reader := NewEventStreamReader(resp.Body, c.maxBufferSize)
+ eventChan, errorChan := c.startReadLoop(reader)
+
+ for {
+ var msg *Event
+ // Wait for message to arrive or exit
+ select {
+ case <-c.subscribed[ch]:
+ return nil
+ case err = <-errorChan:
+ return err
+ case msg = <-eventChan:
+ }
+
+ // Wait for message to be sent or exit
+ if msg != nil {
+ select {
+ case <-c.subscribed[ch]:
+ return nil
+ case ch <- msg:
+ // message sent
+ }
+ }
+ }
+ }
+
+ go func() {
+ defer c.cleanup(ch)
+ // Apply user specified reconnection strategy or default to standard NewExponentialBackOff() reconnection method
+ var err error
+ if c.ReconnectStrategy != nil {
+ err = backoff.RetryNotify(operation, c.ReconnectStrategy, c.ReconnectNotify)
+ } else {
+ err = backoff.RetryNotify(operation, backoff.NewExponentialBackOff(), c.ReconnectNotify)
+ }
+
+ // channel closed once connected
+ if err != nil && !connected {
+ errch <- err
+ }
+ }()
+ err := <-errch
+ close(errch)
+ return err
+}
+
+func (c *Client) startReadLoop(reader *EventStreamReader) (chan *Event, chan error) {
+ outCh := make(chan *Event)
+ erChan := make(chan error)
+ go c.readLoop(reader, outCh, erChan)
+ return outCh, erChan
+}
+
+func (c *Client) readLoop(reader *EventStreamReader, outCh chan *Event, erChan chan error) {
+ for {
+ // Read each new line and process the type of event
+ event, err := reader.ReadEvent()
+ if err != nil {
+ if err == io.EOF {
+ erChan <- nil
+ return
+ }
+ // run user specified disconnect function
+ if c.disconnectcb != nil {
+ c.Connected = false
+ c.disconnectcb(c)
+ }
+ erChan <- err
+ return
+ }
+
+ if !c.Connected && c.connectedcb != nil {
+ c.Connected = true
+ c.connectedcb(c)
+ }
+
+ // If we get an error, ignore it.
+ var msg *Event
+ if msg, err = c.processEvent(event); err == nil {
+ if len(msg.ID) > 0 {
+ c.LastEventID.Store(msg.ID)
+ } else {
+ msg.ID, _ = c.LastEventID.Load().([]byte)
+ }
+
+ // Send downstream if the event has something useful
+ if msg.hasContent() {
+ outCh <- msg
+ }
+ }
+ }
+}
+
+// SubscribeRaw to an sse endpoint
+func (c *Client) SubscribeRaw(handler func(msg *Event)) error {
+ return c.Subscribe("", handler)
+}
+
+// SubscribeRawWithContext to an sse endpoint with context
+func (c *Client) SubscribeRawWithContext(ctx context.Context, handler func(msg *Event)) error {
+ return c.SubscribeWithContext(ctx, "", handler)
+}
+
+// SubscribeChanRaw sends all events to the provided channel
+func (c *Client) SubscribeChanRaw(ch chan *Event) error {
+ return c.SubscribeChan("", ch)
+}
+
+// SubscribeChanRawWithContext sends all events to the provided channel with context
+func (c *Client) SubscribeChanRawWithContext(ctx context.Context, ch chan *Event) error {
+ return c.SubscribeChanWithContext(ctx, "", ch)
+}
+
+// Unsubscribe unsubscribes a channel
+func (c *Client) Unsubscribe(ch chan *Event) {
+ c.mu.Lock()
+ defer c.mu.Unlock()
+
+ if c.subscribed[ch] != nil {
+ c.subscribed[ch] <- struct{}{}
+ }
+}
+
+// OnDisconnect specifies the function to run when the connection disconnects
+func (c *Client) OnDisconnect(fn ConnCallback) {
+ c.disconnectcb = fn
+}
+
+// OnConnect specifies the function to run when the connection is successful
+func (c *Client) OnConnect(fn ConnCallback) {
+ c.connectedcb = fn
+}
+
+func (c *Client) request(ctx context.Context, stream string) (*http.Response, error) {
+ req, err := http.NewRequest("GET", c.URL, nil)
+ if err != nil {
+ return nil, err
+ }
+ req = req.WithContext(ctx)
+
+ // Setup request, specify stream to connect to
+ if stream != "" {
+ query := req.URL.Query()
+ query.Add("stream", stream)
+ req.URL.RawQuery = query.Encode()
+ }
+
+ req.Header.Set("Cache-Control", "no-cache")
+ req.Header.Set("Accept", "text/event-stream")
+ req.Header.Set("Connection", "keep-alive")
+
+ lastID, exists := c.LastEventID.Load().([]byte)
+ if exists && lastID != nil {
+ req.Header.Set("Last-Event-ID", string(lastID))
+ }
+
+ // Add user specified headers
+ for k, v := range c.Headers {
+ req.Header.Set(k, v)
+ }
+
+ return c.Connection.Do(req)
+}
+
+func (c *Client) processEvent(msg []byte) (event *Event, err error) {
+ var e Event
+
+ if len(msg) < 1 {
+ return nil, errors.New("event message was empty")
+ }
+
+ // Normalize the crlf to lf to make it easier to split the lines.
+ // Split the line by "\n" or "\r", per the spec.
+ for _, line := range bytes.FieldsFunc(msg, func(r rune) bool { return r == '\n' || r == '\r' }) {
+ switch {
+ case bytes.HasPrefix(line, headerID):
+ e.ID = append([]byte(nil), trimHeader(len(headerID), line)...)
+ case bytes.HasPrefix(line, headerData):
+ // The spec allows for multiple data fields per event, concatenated them with "\n".
+ e.Data = append(e.Data[:], append(trimHeader(len(headerData), line), byte('\n'))...)
+ // The spec says that a line that simply contains the string "data" should be treated as a data field with an empty body.
+ case bytes.Equal(line, bytes.TrimSuffix(headerData, []byte(":"))):
+ e.Data = append(e.Data, byte('\n'))
+ case bytes.HasPrefix(line, headerEvent):
+ e.Event = append([]byte(nil), trimHeader(len(headerEvent), line)...)
+ case bytes.HasPrefix(line, headerRetry):
+ e.Retry = append([]byte(nil), trimHeader(len(headerRetry), line)...)
+ default:
+ // Ignore any garbage that doesn't match what we're looking for.
+ }
+ }
+
+ // Trim the last "\n" per the spec.
+ e.Data = bytes.TrimSuffix(e.Data, []byte("\n"))
+
+ if c.EncodingBase64 {
+ buf := make([]byte, base64.StdEncoding.DecodedLen(len(e.Data)))
+
+ n, err := base64.StdEncoding.Decode(buf, e.Data)
+ if err != nil {
+ err = fmt.Errorf("failed to decode event message: %s", err)
+ }
+ e.Data = buf[:n]
+ }
+ return &e, err
+}
+
+func (c *Client) cleanup(ch chan *Event) {
+ c.mu.Lock()
+ defer c.mu.Unlock()
+
+ if c.subscribed[ch] != nil {
+ close(c.subscribed[ch])
+ delete(c.subscribed, ch)
+ }
+}
+
+func trimHeader(size int, data []byte) []byte {
+ if data == nil || len(data) < size {
+ return data
+ }
+
+ data = data[size:]
+ // Remove optional leading whitespace
+ if len(data) > 0 && data[0] == 32 {
+ data = data[1:]
+ }
+ // Remove trailing new line
+ if len(data) > 0 && data[len(data)-1] == 10 {
+ data = data[:len(data)-1]
+ }
+ return data
+}
diff --git a/vendor/github.com/r3labs/sse/v2/event.go b/vendor/github.com/r3labs/sse/v2/event.go
new file mode 100644
index 0000000..1258038
--- /dev/null
+++ b/vendor/github.com/r3labs/sse/v2/event.go
@@ -0,0 +1,114 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+package sse
+
+import (
+ "bufio"
+ "bytes"
+ "context"
+ "io"
+ "time"
+)
+
+// Event holds all of the event source fields
+type Event struct {
+ timestamp time.Time
+ ID []byte
+ Data []byte
+ Event []byte
+ Retry []byte
+ Comment []byte
+}
+
+func (e *Event) hasContent() bool {
+ return len(e.ID) > 0 || len(e.Data) > 0 || len(e.Event) > 0 || len(e.Retry) > 0
+}
+
+// EventStreamReader scans an io.Reader looking for EventStream messages.
+type EventStreamReader struct {
+ scanner *bufio.Scanner
+}
+
+// NewEventStreamReader creates an instance of EventStreamReader.
+func NewEventStreamReader(eventStream io.Reader, maxBufferSize int) *EventStreamReader {
+ scanner := bufio.NewScanner(eventStream)
+ initBufferSize := minPosInt(4096, maxBufferSize)
+ scanner.Buffer(make([]byte, initBufferSize), maxBufferSize)
+
+ split := func(data []byte, atEOF bool) (int, []byte, error) {
+ if atEOF && len(data) == 0 {
+ return 0, nil, nil
+ }
+
+ // We have a full event payload to parse.
+ if i, nlen := containsDoubleNewline(data); i >= 0 {
+ return i + nlen, data[0:i], nil
+ }
+ // If we're at EOF, we have all of the data.
+ if atEOF {
+ return len(data), data, nil
+ }
+ // Request more data.
+ return 0, nil, nil
+ }
+ // Set the split function for the scanning operation.
+ scanner.Split(split)
+
+ return &EventStreamReader{
+ scanner: scanner,
+ }
+}
+
+// Returns a tuple containing the index of a double newline, and the number of bytes
+// represented by that sequence. If no double newline is present, the first value
+// will be negative.
+func containsDoubleNewline(data []byte) (int, int) {
+ // Search for each potentially valid sequence of newline characters
+ crcr := bytes.Index(data, []byte("\r\r"))
+ lflf := bytes.Index(data, []byte("\n\n"))
+ crlflf := bytes.Index(data, []byte("\r\n\n"))
+ lfcrlf := bytes.Index(data, []byte("\n\r\n"))
+ crlfcrlf := bytes.Index(data, []byte("\r\n\r\n"))
+ // Find the earliest position of a double newline combination
+ minPos := minPosInt(crcr, minPosInt(lflf, minPosInt(crlflf, minPosInt(lfcrlf, crlfcrlf))))
+ // Detemine the length of the sequence
+ nlen := 2
+ if minPos == crlfcrlf {
+ nlen = 4
+ } else if minPos == crlflf || minPos == lfcrlf {
+ nlen = 3
+ }
+ return minPos, nlen
+}
+
+// Returns the minimum non-negative value out of the two values. If both
+// are negative, a negative value is returned.
+func minPosInt(a, b int) int {
+ if a < 0 {
+ return b
+ }
+ if b < 0 {
+ return a
+ }
+ if a > b {
+ return b
+ }
+ return a
+}
+
+// ReadEvent scans the EventStream for events.
+func (e *EventStreamReader) ReadEvent() ([]byte, error) {
+ if e.scanner.Scan() {
+ event := e.scanner.Bytes()
+ return event, nil
+ }
+ if err := e.scanner.Err(); err != nil {
+ if err == context.Canceled {
+ return nil, io.EOF
+ }
+ return nil, err
+ }
+ return nil, io.EOF
+}
diff --git a/vendor/github.com/r3labs/sse/v2/event_log.go b/vendor/github.com/r3labs/sse/v2/event_log.go
new file mode 100644
index 0000000..aa17dad
--- /dev/null
+++ b/vendor/github.com/r3labs/sse/v2/event_log.go
@@ -0,0 +1,43 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+package sse
+
+import (
+ "strconv"
+ "time"
+)
+
+// EventLog holds all of previous events
+type EventLog []*Event
+
+// Add event to eventlog
+func (e *EventLog) Add(ev *Event) {
+ if !ev.hasContent() {
+ return
+ }
+
+ ev.ID = []byte(e.currentindex())
+ ev.timestamp = time.Now()
+ *e = append(*e, ev)
+}
+
+// Clear events from eventlog
+func (e *EventLog) Clear() {
+ *e = nil
+}
+
+// Replay events to a subscriber
+func (e *EventLog) Replay(s *Subscriber) {
+ for i := 0; i < len(*e); i++ {
+ id, _ := strconv.Atoi(string((*e)[i].ID))
+ if id >= s.eventid {
+ s.connection <- (*e)[i]
+ }
+ }
+}
+
+func (e *EventLog) currentindex() string {
+ return strconv.Itoa(len(*e))
+}
diff --git a/vendor/github.com/r3labs/sse/v2/http.go b/vendor/github.com/r3labs/sse/v2/http.go
new file mode 100644
index 0000000..c7a2b43
--- /dev/null
+++ b/vendor/github.com/r3labs/sse/v2/http.go
@@ -0,0 +1,120 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+package sse
+
+import (
+ "bytes"
+ "fmt"
+ "net/http"
+ "strconv"
+ "time"
+)
+
+// ServeHTTP serves new connections with events for a given stream ...
+func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ flusher, err := w.(http.Flusher)
+ if !err {
+ http.Error(w, "Streaming unsupported!", http.StatusInternalServerError)
+ return
+ }
+
+ w.Header().Set("Content-Type", "text/event-stream")
+ w.Header().Set("Cache-Control", "no-cache")
+ w.Header().Set("Connection", "keep-alive")
+
+ for k, v := range s.Headers {
+ w.Header().Set(k, v)
+ }
+
+ // Get the StreamID from the URL
+ streamID := r.URL.Query().Get("stream")
+ if streamID == "" {
+ http.Error(w, "Please specify a stream!", http.StatusInternalServerError)
+ return
+ }
+
+ stream := s.getStream(streamID)
+
+ if stream == nil {
+ if !s.AutoStream {
+ http.Error(w, "Stream not found!", http.StatusInternalServerError)
+ return
+ }
+
+ stream = s.CreateStream(streamID)
+ }
+
+ eventid := 0
+ if id := r.Header.Get("Last-Event-ID"); id != "" {
+ var err error
+ eventid, err = strconv.Atoi(id)
+ if err != nil {
+ http.Error(w, "Last-Event-ID must be a number!", http.StatusBadRequest)
+ return
+ }
+ }
+
+ // Create the stream subscriber
+ sub := stream.addSubscriber(eventid, r.URL)
+
+ go func() {
+ <-r.Context().Done()
+
+ sub.close()
+
+ if s.AutoStream && !s.AutoReplay && stream.getSubscriberCount() == 0 {
+ s.RemoveStream(streamID)
+ }
+ }()
+
+ w.WriteHeader(http.StatusOK)
+ flusher.Flush()
+
+ // Push events to client
+ for ev := range sub.connection {
+ // If the data buffer is an empty string abort.
+ if len(ev.Data) == 0 && len(ev.Comment) == 0 {
+ break
+ }
+
+ // if the event has expired, dont send it
+ if s.EventTTL != 0 && time.Now().After(ev.timestamp.Add(s.EventTTL)) {
+ continue
+ }
+
+ if len(ev.Data) > 0 {
+ fmt.Fprintf(w, "id: %s\n", ev.ID)
+
+ if s.SplitData {
+ sd := bytes.Split(ev.Data, []byte("\n"))
+ for i := range sd {
+ fmt.Fprintf(w, "data: %s\n", sd[i])
+ }
+ } else {
+ if bytes.HasPrefix(ev.Data, []byte(":")) {
+ fmt.Fprintf(w, "%s\n", ev.Data)
+ } else {
+ fmt.Fprintf(w, "data: %s\n", ev.Data)
+ }
+ }
+
+ if len(ev.Event) > 0 {
+ fmt.Fprintf(w, "event: %s\n", ev.Event)
+ }
+
+ if len(ev.Retry) > 0 {
+ fmt.Fprintf(w, "retry: %s\n", ev.Retry)
+ }
+ }
+
+ if len(ev.Comment) > 0 {
+ fmt.Fprintf(w, ": %s\n", ev.Comment)
+ }
+
+ fmt.Fprint(w, "\n")
+
+ flusher.Flush()
+ }
+}
diff --git a/vendor/github.com/r3labs/sse/v2/server.go b/vendor/github.com/r3labs/sse/v2/server.go
new file mode 100644
index 0000000..d1b27af
--- /dev/null
+++ b/vendor/github.com/r3labs/sse/v2/server.go
@@ -0,0 +1,156 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+package sse
+
+import (
+ "encoding/base64"
+ "sync"
+ "time"
+)
+
+// DefaultBufferSize size of the queue that holds the streams messages.
+const DefaultBufferSize = 1024
+
+// Server Is our main struct
+type Server struct {
+ // Extra headers adding to the HTTP response to each client
+ Headers map[string]string
+ // Sets a ttl that prevents old events from being transmitted
+ EventTTL time.Duration
+ // Specifies the size of the message buffer for each stream
+ BufferSize int
+ // Encodes all data as base64
+ EncodeBase64 bool
+ // Splits an events data into multiple data: entries
+ SplitData bool
+ // Enables creation of a stream when a client connects
+ AutoStream bool
+ // Enables automatic replay for each new subscriber that connects
+ AutoReplay bool
+
+ // Specifies the function to run when client subscribe or un-subscribe
+ OnSubscribe func(streamID string, sub *Subscriber)
+ OnUnsubscribe func(streamID string, sub *Subscriber)
+
+ streams map[string]*Stream
+ muStreams sync.RWMutex
+}
+
+// New will create a server and setup defaults
+func New() *Server {
+ return &Server{
+ BufferSize: DefaultBufferSize,
+ AutoStream: false,
+ AutoReplay: true,
+ streams: make(map[string]*Stream),
+ Headers: map[string]string{},
+ }
+}
+
+// NewWithCallback will create a server and setup defaults with callback function
+func NewWithCallback(onSubscribe, onUnsubscribe func(streamID string, sub *Subscriber)) *Server {
+ return &Server{
+ BufferSize: DefaultBufferSize,
+ AutoStream: false,
+ AutoReplay: true,
+ streams: make(map[string]*Stream),
+ Headers: map[string]string{},
+ OnSubscribe: onSubscribe,
+ OnUnsubscribe: onUnsubscribe,
+ }
+}
+
+// Close shuts down the server, closes all of the streams and connections
+func (s *Server) Close() {
+ s.muStreams.Lock()
+ defer s.muStreams.Unlock()
+
+ for id := range s.streams {
+ s.streams[id].close()
+ delete(s.streams, id)
+ }
+}
+
+// CreateStream will create a new stream and register it
+func (s *Server) CreateStream(id string) *Stream {
+ s.muStreams.Lock()
+ defer s.muStreams.Unlock()
+
+ if s.streams[id] != nil {
+ return s.streams[id]
+ }
+
+ str := newStream(id, s.BufferSize, s.AutoReplay, s.AutoStream, s.OnSubscribe, s.OnUnsubscribe)
+ str.run()
+
+ s.streams[id] = str
+
+ return str
+}
+
+// RemoveStream will remove a stream
+func (s *Server) RemoveStream(id string) {
+ s.muStreams.Lock()
+ defer s.muStreams.Unlock()
+
+ if s.streams[id] != nil {
+ s.streams[id].close()
+ delete(s.streams, id)
+ }
+}
+
+// StreamExists checks whether a stream by a given id exists
+func (s *Server) StreamExists(id string) bool {
+ return s.getStream(id) != nil
+}
+
+// Publish sends a mesage to every client in a streamID.
+// If the stream's buffer is full, it blocks until the message is sent out to
+// all subscribers (but not necessarily arrived the clients), or when the
+// stream is closed.
+func (s *Server) Publish(id string, event *Event) {
+ stream := s.getStream(id)
+ if stream == nil {
+ return
+ }
+
+ select {
+ case <-stream.quit:
+ case stream.event <- s.process(event):
+ }
+}
+
+// TryPublish is the same as Publish except that when the operation would cause
+// the call to be blocked, it simply drops the message and returns false.
+// Together with a small BufferSize, it can be useful when publishing the
+// latest message ASAP is more important than reliable delivery.
+func (s *Server) TryPublish(id string, event *Event) bool {
+ stream := s.getStream(id)
+ if stream == nil {
+ return false
+ }
+
+ select {
+ case stream.event <- s.process(event):
+ return true
+ default:
+ return false
+ }
+}
+
+func (s *Server) getStream(id string) *Stream {
+ s.muStreams.RLock()
+ defer s.muStreams.RUnlock()
+ return s.streams[id]
+}
+
+func (s *Server) process(event *Event) *Event {
+ if s.EncodeBase64 {
+ output := make([]byte, base64.StdEncoding.EncodedLen(len(event.Data)))
+ base64.StdEncoding.Encode(output, event.Data)
+ event.Data = output
+ }
+ return event
+}
diff --git a/vendor/github.com/r3labs/sse/v2/stream.go b/vendor/github.com/r3labs/sse/v2/stream.go
new file mode 100644
index 0000000..bfbcb9b
--- /dev/null
+++ b/vendor/github.com/r3labs/sse/v2/stream.go
@@ -0,0 +1,153 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+package sse
+
+import (
+ "net/url"
+ "sync"
+ "sync/atomic"
+)
+
+// Stream ...
+type Stream struct {
+ ID string
+ event chan *Event
+ quit chan struct{}
+ quitOnce sync.Once
+ register chan *Subscriber
+ deregister chan *Subscriber
+ subscribers []*Subscriber
+ Eventlog EventLog
+ subscriberCount int32
+ // Enables replaying of eventlog to newly added subscribers
+ AutoReplay bool
+ isAutoStream bool
+
+ // Specifies the function to run when client subscribe or un-subscribe
+ OnSubscribe func(streamID string, sub *Subscriber)
+ OnUnsubscribe func(streamID string, sub *Subscriber)
+}
+
+// newStream returns a new stream
+func newStream(id string, buffSize int, replay, isAutoStream bool, onSubscribe, onUnsubscribe func(string, *Subscriber)) *Stream {
+ return &Stream{
+ ID: id,
+ AutoReplay: replay,
+ subscribers: make([]*Subscriber, 0),
+ isAutoStream: isAutoStream,
+ register: make(chan *Subscriber),
+ deregister: make(chan *Subscriber),
+ event: make(chan *Event, buffSize),
+ quit: make(chan struct{}),
+ Eventlog: make(EventLog, 0),
+ OnSubscribe: onSubscribe,
+ OnUnsubscribe: onUnsubscribe,
+ }
+}
+
+func (str *Stream) run() {
+ go func(str *Stream) {
+ for {
+ select {
+ // Add new subscriber
+ case subscriber := <-str.register:
+ str.subscribers = append(str.subscribers, subscriber)
+ if str.AutoReplay {
+ str.Eventlog.Replay(subscriber)
+ }
+
+ // Remove closed subscriber
+ case subscriber := <-str.deregister:
+ i := str.getSubIndex(subscriber)
+ if i != -1 {
+ str.removeSubscriber(i)
+ }
+
+ if str.OnUnsubscribe != nil {
+ go str.OnUnsubscribe(str.ID, subscriber)
+ }
+
+ // Publish event to subscribers
+ case event := <-str.event:
+ if str.AutoReplay {
+ str.Eventlog.Add(event)
+ }
+ for i := range str.subscribers {
+ str.subscribers[i].connection <- event
+ }
+
+ // Shutdown if the server closes
+ case <-str.quit:
+ // remove connections
+ str.removeAllSubscribers()
+ return
+ }
+ }
+ }(str)
+}
+
+func (str *Stream) close() {
+ str.quitOnce.Do(func() {
+ close(str.quit)
+ })
+}
+
+func (str *Stream) getSubIndex(sub *Subscriber) int {
+ for i := range str.subscribers {
+ if str.subscribers[i] == sub {
+ return i
+ }
+ }
+ return -1
+}
+
+// addSubscriber will create a new subscriber on a stream
+func (str *Stream) addSubscriber(eventid int, url *url.URL) *Subscriber {
+ atomic.AddInt32(&str.subscriberCount, 1)
+ sub := &Subscriber{
+ eventid: eventid,
+ quit: str.deregister,
+ connection: make(chan *Event, 64),
+ URL: url,
+ }
+
+ if str.isAutoStream {
+ sub.removed = make(chan struct{}, 1)
+ }
+
+ str.register <- sub
+
+ if str.OnSubscribe != nil {
+ go str.OnSubscribe(str.ID, sub)
+ }
+
+ return sub
+}
+
+func (str *Stream) removeSubscriber(i int) {
+ atomic.AddInt32(&str.subscriberCount, -1)
+ close(str.subscribers[i].connection)
+ if str.subscribers[i].removed != nil {
+ str.subscribers[i].removed <- struct{}{}
+ close(str.subscribers[i].removed)
+ }
+ str.subscribers = append(str.subscribers[:i], str.subscribers[i+1:]...)
+}
+
+func (str *Stream) removeAllSubscribers() {
+ for i := 0; i < len(str.subscribers); i++ {
+ close(str.subscribers[i].connection)
+ if str.subscribers[i].removed != nil {
+ str.subscribers[i].removed <- struct{}{}
+ close(str.subscribers[i].removed)
+ }
+ }
+ atomic.StoreInt32(&str.subscriberCount, 0)
+ str.subscribers = str.subscribers[:0]
+}
+
+func (str *Stream) getSubscriberCount() int {
+ return int(atomic.LoadInt32(&str.subscriberCount))
+}
diff --git a/vendor/github.com/r3labs/sse/v2/subscriber.go b/vendor/github.com/r3labs/sse/v2/subscriber.go
new file mode 100644
index 0000000..4b54c20
--- /dev/null
+++ b/vendor/github.com/r3labs/sse/v2/subscriber.go
@@ -0,0 +1,24 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+package sse
+
+import "net/url"
+
+// Subscriber ...
+type Subscriber struct {
+ quit chan *Subscriber
+ connection chan *Event
+ removed chan struct{}
+ eventid int
+ URL *url.URL
+}
+
+// Close will let the stream know that the clients connection has terminated
+func (s *Subscriber) close() {
+ s.quit <- s
+ if s.removed != nil {
+ <-s.removed
+ }
+}
diff --git a/vendor/github.com/robertkrimen/otto/.clog.toml b/vendor/github.com/robertkrimen/otto/.clog.toml
new file mode 100644
index 0000000..74e3702
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/.clog.toml
@@ -0,0 +1,13 @@
+[clog]
+repository = "https://github.com/robertkrimen/otto"
+subtitle = "Release Notes"
+
+[sections]
+"Refactors" = ["refactor"]
+"Chores" = ["chore"]
+"Continuous Integration" = ["ci"]
+"Improvements" = ["imp", "improvement"]
+"Features" = ["feat", "feature"]
+"Legacy" = ["legacy"]
+"QA" = ["qa", "test", "tests"]
+"Documentation" = ["doc", "docs"]
diff --git a/vendor/github.com/robertkrimen/otto/.gitignore b/vendor/github.com/robertkrimen/otto/.gitignore
new file mode 100644
index 0000000..01ff960
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/.gitignore
@@ -0,0 +1,7 @@
+/.test
+/otto/otto
+/otto/otto-*
+/test/test-*.js
+/test/tester
+.idea
+dist/
diff --git a/vendor/github.com/robertkrimen/otto/.golangci.yml b/vendor/github.com/robertkrimen/otto/.golangci.yml
new file mode 100644
index 0000000..db29a5a
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/.golangci.yml
@@ -0,0 +1,73 @@
+run:
+ deadline: 6m
+ skip-dirs:
+ - terst
+ skip-files:
+ - dbg/dbg.go
+
+linters-settings:
+ govet:
+ check-shadowing: false
+ goconst:
+ min-len: 2
+ min-occurrences: 4
+
+linters:
+ enable-all: true
+ disable:
+ - dupl
+ - gas
+ - errcheck
+ - gofmt
+ - gosimple
+ - interfacer
+ - megacheck
+ - maligned
+ - structcheck
+ - staticcheck
+ - unconvert
+ - unparam
+ - varcheck
+ - lll
+ - prealloc
+ - gochecknoglobals
+ - gochecknoinits
+ - scopelint
+ - funlen
+ - godox
+ - exhaustivestruct
+ - goerr113
+ - wsl
+ - nlreturn
+ - tagliatelle
+ - gomnd
+ - paralleltest
+ - wrapcheck
+ - testpackage
+ - golint
+ - gofumpt
+ - forbidigo
+ - gocognit
+ - gocritic
+ - godot
+ - nakedret
+ - nestif
+ - revive
+ - errorlint
+ - exhaustive
+ - forcetypeassert
+ - ifshort
+ - stylecheck
+ - gocyclo
+ - misspell
+ - cyclop
+ - varnamelen
+ - nonamedreturns
+ - maintidx
+ - ireturn
+ - exhaustruct
+ - nosnakecase
+ - deadcode
+ - dupword
+ - gci
+
diff --git a/vendor/github.com/robertkrimen/otto/.goreleaser.yaml b/vendor/github.com/robertkrimen/otto/.goreleaser.yaml
new file mode 100644
index 0000000..56f72d9
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/.goreleaser.yaml
@@ -0,0 +1,70 @@
+# When adding options check the documentation at https://goreleaser.com
+before:
+ hooks:
+ - go mod tidy
+builds:
+ - env:
+ - CGO_ENABLED=0
+ goos:
+ - linux
+ - darwin
+ goarch:
+ - amd64
+ - arm64
+ main: ./otto
+ id: otto
+ binary: otto
+universal_binaries:
+ - replace: true
+ id: otto
+checksum:
+ name_template: 'checksums.txt'
+snapshot:
+ name_template: "{{ incpatch .Version }}-next"
+archives:
+ - id: otto
+ name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}"
+release:
+ header: |
+
+ ### {{.Tag}} Release Notes ({{.Date}})
+ footer: |
+ [Full Changelog](https://{{ .ModulePath }}/compare/{{ .PreviousTag }}...{{ .Tag }})
+changelog:
+ use: github
+ sort: asc
+ filters:
+ exclude:
+ - Merge pull request
+ - Merge remote-tracking branch
+ - Merge branch
+
+ # Group commits messages by given regex and title.
+ # Order value defines the order of the groups.
+ # Proving no regex means all commits will be grouped under the default group.
+ # Groups are disabled when using github-native, as it already groups things by itself.
+ # Matches are performed against strings of the form: " ".
+ # Regex use RE2 syntax as defined here: https://github.com/google/re2/wiki/Syntax.
+ #
+ # Default is no groups.
+ groups:
+ - title: Features
+ regexp: '^.*?(feat|feature)(\([[:word:]]+\))??!?:.+$'
+ order: 0
+ - title: 'Bug fixes'
+ regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$'
+ order: 1
+ - title: 'Chores'
+ regexp: '^.*?chore(\([[:word:]]+\))??!?:.+$'
+ order: 2
+ - title: 'Quality'
+ regexp: '^.*?(qa|test|tests)(\([[:word:]]+\))??!?:.+$'
+ order: 3
+ - title: 'Documentation'
+ regexp: '^.*?(doc|docs)(\([[:word:]]+\))??!?:.+$'
+ order: 4
+ - title: 'Continuous Integration'
+ regexp: '^.*?ci(\([[:word:]]+\))??!?:.+$'
+ order: 5
+ - title: Other
+ order: 999
diff --git a/vendor/github.com/robertkrimen/otto/DESIGN.markdown b/vendor/github.com/robertkrimen/otto/DESIGN.markdown
new file mode 100644
index 0000000..2887529
--- /dev/null
+++ b/vendor/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/vendor/github.com/robertkrimen/otto/LICENSE b/vendor/github.com/robertkrimen/otto/LICENSE
new file mode 100644
index 0000000..b6179fe
--- /dev/null
+++ b/vendor/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/vendor/github.com/robertkrimen/otto/Makefile b/vendor/github.com/robertkrimen/otto/Makefile
new file mode 100644
index 0000000..9868db3
--- /dev/null
+++ b/vendor/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.pl
+ ./$< > $@
+
+#################
+# 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/vendor/github.com/robertkrimen/otto/README.markdown b/vendor/github.com/robertkrimen/otto/README.markdown
new file mode 100644
index 0000000..5dfa643
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/README.markdown
@@ -0,0 +1,877 @@
+# otto
+--
+```go
+import "github.com/robertkrimen/otto"
+```
+
+Package otto is a JavaScript parser and interpreter written natively in Go.
+
+http://godoc.org/github.com/robertkrimen/otto
+
+```go
+import (
+ "github.com/robertkrimen/otto"
+)
+```
+
+Run something in the VM
+
+```go
+vm := otto.New()
+vm.Run(`
+ abc = 2 + 2;
+ console.log("The value of abc is " + abc); // 4
+`)
+```
+
+Get a value out of the VM
+
+```go
+if value, err := vm.Get("abc"); err == nil {
+ if value_int, err := value.ToInteger(); err == nil {
+ fmt.Printf("", value_int, err)
+ }
+}
+```
+
+Set a number
+
+```go
+vm.Set("def", 11)
+vm.Run(`
+ console.log("The value of def is " + def);
+ // The value of def is 11
+`)
+```
+
+Set a string
+
+```go
+vm.Set("xyzzy", "Nothing happens.")
+vm.Run(`
+ console.log(xyzzy.length); // 16
+`)
+```
+
+Get the value of an expression
+
+```go
+value, _ = vm.Run("xyzzy.length")
+{
+ // value is an int64 with a value of 16
+ value, _ := value.ToInteger()
+}
+```
+
+An error happens
+
+```go
+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
+
+```go
+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
+
+```go
+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
+
+```go
+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
+
+```go
+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:
+
+```go
+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.
+ * Otto targets ES5. ES6 features (eg: Typed Arrays) are not supported.
+
+
+### 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:
+
+```go
+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
+ watchdogCleanup := make(chan struct{})
+ defer close(watchdogCleanup)
+
+ go func() {
+ select {
+ case <-time.After(2 * time.Second): // Stop after two seconds
+ vm.Interrupt <- func() {
+ panic(halt)
+ }
+ case <-watchdogCleanup:
+ }
+ close(vm.Interrupt)
+ }()
+
+ 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 `window` 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 (:3:9)
+ at :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.
+
+```go
+// 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.
+
+```go
+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:
+
+```go
+object, _ := vm.Object(`Number`)
+```
+
+Or, creating a new object:
+
+```go
+object, _ := vm.Object(`({ xyzzy: "Nothing happens." })`)
+```
+
+Or, creating and assigning an object:
+
+```go
+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:
+
+```go
+ToValue(false)
+```
+
+#### func NaNValue
+
+```go
+func NaNValue() Value
+```
+NaNValue will return a value representing NaN.
+
+It is equivalent to:
+
+```go
+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:
+
+```go
+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/vendor/github.com/robertkrimen/otto/ast/README.markdown b/vendor/github.com/robertkrimen/otto/ast/README.markdown
new file mode 100644
index 0000000..a785da9
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/ast/README.markdown
@@ -0,0 +1,1068 @@
+# ast
+--
+ import "github.com/robertkrimen/otto/ast"
+
+Package ast declares types representing a JavaScript AST.
+
+
+### Warning
+
+The parser and AST interfaces are still works-in-progress (particularly where
+node types are concerned) and may change in the future.
+
+## Usage
+
+#### type ArrayLiteral
+
+```go
+type ArrayLiteral struct {
+ LeftBracket file.Idx
+ RightBracket file.Idx
+ Value []Expression
+}
+```
+
+
+#### func (*ArrayLiteral) Idx0
+
+```go
+func (self *ArrayLiteral) Idx0() file.Idx
+```
+
+#### func (*ArrayLiteral) Idx1
+
+```go
+func (self *ArrayLiteral) Idx1() file.Idx
+```
+
+#### type AssignExpression
+
+```go
+type AssignExpression struct {
+ Operator token.Token
+ Left Expression
+ Right Expression
+}
+```
+
+
+#### func (*AssignExpression) Idx0
+
+```go
+func (self *AssignExpression) Idx0() file.Idx
+```
+
+#### func (*AssignExpression) Idx1
+
+```go
+func (self *AssignExpression) Idx1() file.Idx
+```
+
+#### type BadExpression
+
+```go
+type BadExpression struct {
+ From file.Idx
+ To file.Idx
+}
+```
+
+
+#### func (*BadExpression) Idx0
+
+```go
+func (self *BadExpression) Idx0() file.Idx
+```
+
+#### func (*BadExpression) Idx1
+
+```go
+func (self *BadExpression) Idx1() file.Idx
+```
+
+#### type BadStatement
+
+```go
+type BadStatement struct {
+ From file.Idx
+ To file.Idx
+}
+```
+
+
+#### func (*BadStatement) Idx0
+
+```go
+func (self *BadStatement) Idx0() file.Idx
+```
+
+#### func (*BadStatement) Idx1
+
+```go
+func (self *BadStatement) Idx1() file.Idx
+```
+
+#### type BinaryExpression
+
+```go
+type BinaryExpression struct {
+ Operator token.Token
+ Left Expression
+ Right Expression
+ Comparison bool
+}
+```
+
+
+#### func (*BinaryExpression) Idx0
+
+```go
+func (self *BinaryExpression) Idx0() file.Idx
+```
+
+#### func (*BinaryExpression) Idx1
+
+```go
+func (self *BinaryExpression) Idx1() file.Idx
+```
+
+#### type BlockStatement
+
+```go
+type BlockStatement struct {
+ LeftBrace file.Idx
+ List []Statement
+ RightBrace file.Idx
+}
+```
+
+
+#### func (*BlockStatement) Idx0
+
+```go
+func (self *BlockStatement) Idx0() file.Idx
+```
+
+#### func (*BlockStatement) Idx1
+
+```go
+func (self *BlockStatement) Idx1() file.Idx
+```
+
+#### type BooleanLiteral
+
+```go
+type BooleanLiteral struct {
+ Idx file.Idx
+ Literal string
+ Value bool
+}
+```
+
+
+#### func (*BooleanLiteral) Idx0
+
+```go
+func (self *BooleanLiteral) Idx0() file.Idx
+```
+
+#### func (*BooleanLiteral) Idx1
+
+```go
+func (self *BooleanLiteral) Idx1() file.Idx
+```
+
+#### type BracketExpression
+
+```go
+type BracketExpression struct {
+ Left Expression
+ Member Expression
+ LeftBracket file.Idx
+ RightBracket file.Idx
+}
+```
+
+
+#### func (*BracketExpression) Idx0
+
+```go
+func (self *BracketExpression) Idx0() file.Idx
+```
+
+#### func (*BracketExpression) Idx1
+
+```go
+func (self *BracketExpression) Idx1() file.Idx
+```
+
+#### type BranchStatement
+
+```go
+type BranchStatement struct {
+ Idx file.Idx
+ Token token.Token
+ Label *Identifier
+}
+```
+
+
+#### func (*BranchStatement) Idx0
+
+```go
+func (self *BranchStatement) Idx0() file.Idx
+```
+
+#### func (*BranchStatement) Idx1
+
+```go
+func (self *BranchStatement) Idx1() file.Idx
+```
+
+#### type CallExpression
+
+```go
+type CallExpression struct {
+ Callee Expression
+ LeftParenthesis file.Idx
+ ArgumentList []Expression
+ RightParenthesis file.Idx
+}
+```
+
+
+#### func (*CallExpression) Idx0
+
+```go
+func (self *CallExpression) Idx0() file.Idx
+```
+
+#### func (*CallExpression) Idx1
+
+```go
+func (self *CallExpression) Idx1() file.Idx
+```
+
+#### type CaseStatement
+
+```go
+type CaseStatement struct {
+ Case file.Idx
+ Test Expression
+ Consequent []Statement
+}
+```
+
+
+#### func (*CaseStatement) Idx0
+
+```go
+func (self *CaseStatement) Idx0() file.Idx
+```
+
+#### func (*CaseStatement) Idx1
+
+```go
+func (self *CaseStatement) Idx1() file.Idx
+```
+
+#### type CatchStatement
+
+```go
+type CatchStatement struct {
+ Catch file.Idx
+ Parameter *Identifier
+ Body Statement
+}
+```
+
+
+#### func (*CatchStatement) Idx0
+
+```go
+func (self *CatchStatement) Idx0() file.Idx
+```
+
+#### func (*CatchStatement) Idx1
+
+```go
+func (self *CatchStatement) Idx1() file.Idx
+```
+
+#### type ConditionalExpression
+
+```go
+type ConditionalExpression struct {
+ Test Expression
+ Consequent Expression
+ Alternate Expression
+}
+```
+
+
+#### func (*ConditionalExpression) Idx0
+
+```go
+func (self *ConditionalExpression) Idx0() file.Idx
+```
+
+#### func (*ConditionalExpression) Idx1
+
+```go
+func (self *ConditionalExpression) Idx1() file.Idx
+```
+
+#### type DebuggerStatement
+
+```go
+type DebuggerStatement struct {
+ Debugger file.Idx
+}
+```
+
+
+#### func (*DebuggerStatement) Idx0
+
+```go
+func (self *DebuggerStatement) Idx0() file.Idx
+```
+
+#### func (*DebuggerStatement) Idx1
+
+```go
+func (self *DebuggerStatement) Idx1() file.Idx
+```
+
+#### type Declaration
+
+```go
+type Declaration interface {
+ // contains filtered or unexported methods
+}
+```
+
+All declaration nodes implement the Declaration interface.
+
+#### type DoWhileStatement
+
+```go
+type DoWhileStatement struct {
+ Do file.Idx
+ Test Expression
+ Body Statement
+}
+```
+
+
+#### func (*DoWhileStatement) Idx0
+
+```go
+func (self *DoWhileStatement) Idx0() file.Idx
+```
+
+#### func (*DoWhileStatement) Idx1
+
+```go
+func (self *DoWhileStatement) Idx1() file.Idx
+```
+
+#### type DotExpression
+
+```go
+type DotExpression struct {
+ Left Expression
+ Identifier Identifier
+}
+```
+
+
+#### func (*DotExpression) Idx0
+
+```go
+func (self *DotExpression) Idx0() file.Idx
+```
+
+#### func (*DotExpression) Idx1
+
+```go
+func (self *DotExpression) Idx1() file.Idx
+```
+
+#### type EmptyStatement
+
+```go
+type EmptyStatement struct {
+ Semicolon file.Idx
+}
+```
+
+
+#### func (*EmptyStatement) Idx0
+
+```go
+func (self *EmptyStatement) Idx0() file.Idx
+```
+
+#### func (*EmptyStatement) Idx1
+
+```go
+func (self *EmptyStatement) Idx1() file.Idx
+```
+
+#### type Expression
+
+```go
+type Expression interface {
+ Node
+ // contains filtered or unexported methods
+}
+```
+
+All expression nodes implement the Expression interface.
+
+#### type ExpressionStatement
+
+```go
+type ExpressionStatement struct {
+ Expression Expression
+}
+```
+
+
+#### func (*ExpressionStatement) Idx0
+
+```go
+func (self *ExpressionStatement) Idx0() file.Idx
+```
+
+#### func (*ExpressionStatement) Idx1
+
+```go
+func (self *ExpressionStatement) Idx1() file.Idx
+```
+
+#### type ForInStatement
+
+```go
+type ForInStatement struct {
+ For file.Idx
+ Into Expression
+ Source Expression
+ Body Statement
+}
+```
+
+
+#### func (*ForInStatement) Idx0
+
+```go
+func (self *ForInStatement) Idx0() file.Idx
+```
+
+#### func (*ForInStatement) Idx1
+
+```go
+func (self *ForInStatement) Idx1() file.Idx
+```
+
+#### type ForStatement
+
+```go
+type ForStatement struct {
+ For file.Idx
+ Initializer Expression
+ Update Expression
+ Test Expression
+ Body Statement
+}
+```
+
+
+#### func (*ForStatement) Idx0
+
+```go
+func (self *ForStatement) Idx0() file.Idx
+```
+
+#### func (*ForStatement) Idx1
+
+```go
+func (self *ForStatement) Idx1() file.Idx
+```
+
+#### type FunctionDeclaration
+
+```go
+type FunctionDeclaration struct {
+ Function *FunctionLiteral
+}
+```
+
+
+#### type FunctionLiteral
+
+```go
+type FunctionLiteral struct {
+ Function file.Idx
+ Name *Identifier
+ ParameterList *ParameterList
+ Body Statement
+ Source string
+
+ DeclarationList []Declaration
+}
+```
+
+
+#### func (*FunctionLiteral) Idx0
+
+```go
+func (self *FunctionLiteral) Idx0() file.Idx
+```
+
+#### func (*FunctionLiteral) Idx1
+
+```go
+func (self *FunctionLiteral) Idx1() file.Idx
+```
+
+#### type Identifier
+
+```go
+type Identifier struct {
+ Name string
+ Idx file.Idx
+}
+```
+
+
+#### func (*Identifier) Idx0
+
+```go
+func (self *Identifier) Idx0() file.Idx
+```
+
+#### func (*Identifier) Idx1
+
+```go
+func (self *Identifier) Idx1() file.Idx
+```
+
+#### type IfStatement
+
+```go
+type IfStatement struct {
+ If file.Idx
+ Test Expression
+ Consequent Statement
+ Alternate Statement
+}
+```
+
+
+#### func (*IfStatement) Idx0
+
+```go
+func (self *IfStatement) Idx0() file.Idx
+```
+
+#### func (*IfStatement) Idx1
+
+```go
+func (self *IfStatement) Idx1() file.Idx
+```
+
+#### type LabelledStatement
+
+```go
+type LabelledStatement struct {
+ Label *Identifier
+ Colon file.Idx
+ Statement Statement
+}
+```
+
+
+#### func (*LabelledStatement) Idx0
+
+```go
+func (self *LabelledStatement) Idx0() file.Idx
+```
+
+#### func (*LabelledStatement) Idx1
+
+```go
+func (self *LabelledStatement) Idx1() file.Idx
+```
+
+#### type NewExpression
+
+```go
+type NewExpression struct {
+ New file.Idx
+ Callee Expression
+ LeftParenthesis file.Idx
+ ArgumentList []Expression
+ RightParenthesis file.Idx
+}
+```
+
+
+#### func (*NewExpression) Idx0
+
+```go
+func (self *NewExpression) Idx0() file.Idx
+```
+
+#### func (*NewExpression) Idx1
+
+```go
+func (self *NewExpression) Idx1() file.Idx
+```
+
+#### type Node
+
+```go
+type Node interface {
+ Idx0() file.Idx // The index of the first character belonging to the node
+ Idx1() file.Idx // The index of the first character immediately after the node
+}
+```
+
+All nodes implement the Node interface.
+
+#### type NullLiteral
+
+```go
+type NullLiteral struct {
+ Idx file.Idx
+ Literal string
+}
+```
+
+
+#### func (*NullLiteral) Idx0
+
+```go
+func (self *NullLiteral) Idx0() file.Idx
+```
+
+#### func (*NullLiteral) Idx1
+
+```go
+func (self *NullLiteral) Idx1() file.Idx
+```
+
+#### type NumberLiteral
+
+```go
+type NumberLiteral struct {
+ Idx file.Idx
+ Literal string
+ Value interface{}
+}
+```
+
+
+#### func (*NumberLiteral) Idx0
+
+```go
+func (self *NumberLiteral) Idx0() file.Idx
+```
+
+#### func (*NumberLiteral) Idx1
+
+```go
+func (self *NumberLiteral) Idx1() file.Idx
+```
+
+#### type ObjectLiteral
+
+```go
+type ObjectLiteral struct {
+ LeftBrace file.Idx
+ RightBrace file.Idx
+ Value []Property
+}
+```
+
+
+#### func (*ObjectLiteral) Idx0
+
+```go
+func (self *ObjectLiteral) Idx0() file.Idx
+```
+
+#### func (*ObjectLiteral) Idx1
+
+```go
+func (self *ObjectLiteral) Idx1() file.Idx
+```
+
+#### type ParameterList
+
+```go
+type ParameterList struct {
+ Opening file.Idx
+ List []*Identifier
+ Closing file.Idx
+}
+```
+
+
+#### type Program
+
+```go
+type Program struct {
+ Body []Statement
+
+ DeclarationList []Declaration
+
+ File *file.File
+}
+```
+
+
+#### func (*Program) Idx0
+
+```go
+func (self *Program) Idx0() file.Idx
+```
+
+#### func (*Program) Idx1
+
+```go
+func (self *Program) Idx1() file.Idx
+```
+
+#### type Property
+
+```go
+type Property struct {
+ Key string
+ Kind string
+ Value Expression
+}
+```
+
+
+#### type RegExpLiteral
+
+```go
+type RegExpLiteral struct {
+ Idx file.Idx
+ Literal string
+ Pattern string
+ Flags string
+ Value string
+}
+```
+
+
+#### func (*RegExpLiteral) Idx0
+
+```go
+func (self *RegExpLiteral) Idx0() file.Idx
+```
+
+#### func (*RegExpLiteral) Idx1
+
+```go
+func (self *RegExpLiteral) Idx1() file.Idx
+```
+
+#### type ReturnStatement
+
+```go
+type ReturnStatement struct {
+ Return file.Idx
+ Argument Expression
+}
+```
+
+
+#### func (*ReturnStatement) Idx0
+
+```go
+func (self *ReturnStatement) Idx0() file.Idx
+```
+
+#### func (*ReturnStatement) Idx1
+
+```go
+func (self *ReturnStatement) Idx1() file.Idx
+```
+
+#### type SequenceExpression
+
+```go
+type SequenceExpression struct {
+ Sequence []Expression
+}
+```
+
+
+#### func (*SequenceExpression) Idx0
+
+```go
+func (self *SequenceExpression) Idx0() file.Idx
+```
+
+#### func (*SequenceExpression) Idx1
+
+```go
+func (self *SequenceExpression) Idx1() file.Idx
+```
+
+#### type Statement
+
+```go
+type Statement interface {
+ Node
+ // contains filtered or unexported methods
+}
+```
+
+All statement nodes implement the Statement interface.
+
+#### type StringLiteral
+
+```go
+type StringLiteral struct {
+ Idx file.Idx
+ Literal string
+ Value string
+}
+```
+
+
+#### func (*StringLiteral) Idx0
+
+```go
+func (self *StringLiteral) Idx0() file.Idx
+```
+
+#### func (*StringLiteral) Idx1
+
+```go
+func (self *StringLiteral) Idx1() file.Idx
+```
+
+#### type SwitchStatement
+
+```go
+type SwitchStatement struct {
+ Switch file.Idx
+ Discriminant Expression
+ Default int
+ Body []*CaseStatement
+}
+```
+
+
+#### func (*SwitchStatement) Idx0
+
+```go
+func (self *SwitchStatement) Idx0() file.Idx
+```
+
+#### func (*SwitchStatement) Idx1
+
+```go
+func (self *SwitchStatement) Idx1() file.Idx
+```
+
+#### type ThisExpression
+
+```go
+type ThisExpression struct {
+ Idx file.Idx
+}
+```
+
+
+#### func (*ThisExpression) Idx0
+
+```go
+func (self *ThisExpression) Idx0() file.Idx
+```
+
+#### func (*ThisExpression) Idx1
+
+```go
+func (self *ThisExpression) Idx1() file.Idx
+```
+
+#### type ThrowStatement
+
+```go
+type ThrowStatement struct {
+ Throw file.Idx
+ Argument Expression
+}
+```
+
+
+#### func (*ThrowStatement) Idx0
+
+```go
+func (self *ThrowStatement) Idx0() file.Idx
+```
+
+#### func (*ThrowStatement) Idx1
+
+```go
+func (self *ThrowStatement) Idx1() file.Idx
+```
+
+#### type TryStatement
+
+```go
+type TryStatement struct {
+ Try file.Idx
+ Body Statement
+ Catch *CatchStatement
+ Finally Statement
+}
+```
+
+
+#### func (*TryStatement) Idx0
+
+```go
+func (self *TryStatement) Idx0() file.Idx
+```
+
+#### func (*TryStatement) Idx1
+
+```go
+func (self *TryStatement) Idx1() file.Idx
+```
+
+#### type UnaryExpression
+
+```go
+type UnaryExpression struct {
+ Operator token.Token
+ Idx file.Idx // If a prefix operation
+ Operand Expression
+ Postfix bool
+}
+```
+
+
+#### func (*UnaryExpression) Idx0
+
+```go
+func (self *UnaryExpression) Idx0() file.Idx
+```
+
+#### func (*UnaryExpression) Idx1
+
+```go
+func (self *UnaryExpression) Idx1() file.Idx
+```
+
+#### type VariableDeclaration
+
+```go
+type VariableDeclaration struct {
+ Var file.Idx
+ List []*VariableExpression
+}
+```
+
+
+#### type VariableExpression
+
+```go
+type VariableExpression struct {
+ Name string
+ Idx file.Idx
+ Initializer Expression
+}
+```
+
+
+#### func (*VariableExpression) Idx0
+
+```go
+func (self *VariableExpression) Idx0() file.Idx
+```
+
+#### func (*VariableExpression) Idx1
+
+```go
+func (self *VariableExpression) Idx1() file.Idx
+```
+
+#### type VariableStatement
+
+```go
+type VariableStatement struct {
+ Var file.Idx
+ List []Expression
+}
+```
+
+
+#### func (*VariableStatement) Idx0
+
+```go
+func (self *VariableStatement) Idx0() file.Idx
+```
+
+#### func (*VariableStatement) Idx1
+
+```go
+func (self *VariableStatement) Idx1() file.Idx
+```
+
+#### type WhileStatement
+
+```go
+type WhileStatement struct {
+ While file.Idx
+ Test Expression
+ Body Statement
+}
+```
+
+
+#### func (*WhileStatement) Idx0
+
+```go
+func (self *WhileStatement) Idx0() file.Idx
+```
+
+#### func (*WhileStatement) Idx1
+
+```go
+func (self *WhileStatement) Idx1() file.Idx
+```
+
+#### type WithStatement
+
+```go
+type WithStatement struct {
+ With file.Idx
+ Object Expression
+ Body Statement
+}
+```
+
+
+#### func (*WithStatement) Idx0
+
+```go
+func (self *WithStatement) Idx0() file.Idx
+```
+
+#### func (*WithStatement) Idx1
+
+```go
+func (self *WithStatement) Idx1() file.Idx
+```
+
+--
+**godocdown** http://github.com/robertkrimen/godocdown
diff --git a/vendor/github.com/robertkrimen/otto/ast/comments.go b/vendor/github.com/robertkrimen/otto/ast/comments.go
new file mode 100644
index 0000000..5c94855
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/ast/comments.go
@@ -0,0 +1,279 @@
+package ast
+
+import (
+ "fmt"
+
+ "github.com/robertkrimen/otto/file"
+)
+
+// CommentPosition determines where the comment is in a given context
+type CommentPosition int
+
+const (
+ _ CommentPosition = iota
+ LEADING // Before the pertinent expression
+ TRAILING // After the pertinent expression
+ KEY // Before a key in an object
+ COLON // After a colon in a field declaration
+ FINAL // Final comments in a block, not belonging to a specific expression or the comment after a trailing , in an array or object literal
+ IF // After an if keyword
+ WHILE // After a while keyword
+ DO // After do keyword
+ FOR // After a for keyword
+ WITH // After a with keyword
+ TBD
+)
+
+// Comment contains the data of the comment
+type Comment struct {
+ Begin file.Idx
+ Text string
+ Position CommentPosition
+}
+
+// NewComment creates a new comment
+func NewComment(text string, idx file.Idx) *Comment {
+ comment := &Comment{
+ Begin: idx,
+ Text: text,
+ Position: TBD,
+ }
+
+ return comment
+}
+
+// String returns a stringified version of the position
+func (cp CommentPosition) String() string {
+ switch cp {
+ case LEADING:
+ return "Leading"
+ case TRAILING:
+ return "Trailing"
+ case KEY:
+ return "Key"
+ case COLON:
+ return "Colon"
+ case FINAL:
+ return "Final"
+ case IF:
+ return "If"
+ case WHILE:
+ return "While"
+ case DO:
+ return "Do"
+ case FOR:
+ return "For"
+ case WITH:
+ return "With"
+ default:
+ return "???"
+ }
+}
+
+// String returns a stringified version of the comment
+func (c Comment) String() string {
+ return fmt.Sprintf("Comment: %v", c.Text)
+}
+
+// Comments defines the current view of comments from the parser
+type Comments struct {
+ // CommentMap is a reference to the parser comment map
+ CommentMap CommentMap
+ // Comments lists the comments scanned, not linked to a node yet
+ Comments []*Comment
+ // future lists the comments after a line break during a sequence of comments
+ future []*Comment
+ // Current is node for which comments are linked to
+ Current Expression
+
+ // wasLineBreak determines if a line break occured while scanning for comments
+ wasLineBreak bool
+ // primary determines whether or not processing a primary expression
+ primary bool
+ // afterBlock determines whether or not being after a block statement
+ afterBlock bool
+}
+
+func NewComments() *Comments {
+ comments := &Comments{
+ CommentMap: CommentMap{},
+ }
+
+ return comments
+}
+
+func (c *Comments) String() string {
+ return fmt.Sprintf("NODE: %v, Comments: %v, Future: %v(LINEBREAK:%v)", c.Current, len(c.Comments), len(c.future), c.wasLineBreak)
+}
+
+// FetchAll returns all the currently scanned comments,
+// including those from the next line
+func (c *Comments) FetchAll() []*Comment {
+ defer func() {
+ c.Comments = nil
+ c.future = nil
+ }()
+
+ return append(c.Comments, c.future...)
+}
+
+// Fetch returns all the currently scanned comments
+func (c *Comments) Fetch() []*Comment {
+ defer func() {
+ c.Comments = nil
+ }()
+
+ return c.Comments
+}
+
+// ResetLineBreak marks the beginning of a new statement
+func (c *Comments) ResetLineBreak() {
+ c.wasLineBreak = false
+}
+
+// MarkPrimary will mark the context as processing a primary expression
+func (c *Comments) MarkPrimary() {
+ c.primary = true
+ c.wasLineBreak = false
+}
+
+// AfterBlock will mark the context as being after a block.
+func (c *Comments) AfterBlock() {
+ c.afterBlock = true
+}
+
+// AddComment adds a comment to the view.
+// Depending on the context, comments are added normally or as post line break.
+func (c *Comments) AddComment(comment *Comment) {
+ if c.primary {
+ if !c.wasLineBreak {
+ c.Comments = append(c.Comments, comment)
+ } else {
+ c.future = append(c.future, comment)
+ }
+ } else {
+ if !c.wasLineBreak || (c.Current == nil && !c.afterBlock) {
+ c.Comments = append(c.Comments, comment)
+ } else {
+ c.future = append(c.future, comment)
+ }
+ }
+}
+
+// MarkComments will mark the found comments as the given position.
+func (c *Comments) MarkComments(position CommentPosition) {
+ for _, comment := range c.Comments {
+ if comment.Position == TBD {
+ comment.Position = position
+ }
+ }
+ for _, c := range c.future {
+ if c.Position == TBD {
+ c.Position = position
+ }
+ }
+}
+
+// Unset the current node and apply the comments to the current expression.
+// Resets context variables.
+func (c *Comments) Unset() {
+ if c.Current != nil {
+ c.applyComments(c.Current, c.Current, TRAILING)
+ c.Current = nil
+ }
+ c.wasLineBreak = false
+ c.primary = false
+ c.afterBlock = false
+}
+
+// SetExpression sets the current expression.
+// It is applied the found comments, unless the previous expression has not been unset.
+// It is skipped if the node is already set or if it is a part of the previous node.
+func (c *Comments) SetExpression(node Expression) {
+ // Skipping same node
+ if c.Current == node {
+ return
+ }
+ if c.Current != nil && c.Current.Idx1() == node.Idx1() {
+ c.Current = node
+ return
+ }
+ previous := c.Current
+ c.Current = node
+
+ // Apply the found comments and futures to the node and the previous.
+ c.applyComments(node, previous, TRAILING)
+}
+
+// PostProcessNode applies all found comments to the given node
+func (c *Comments) PostProcessNode(node Node) {
+ c.applyComments(node, nil, TRAILING)
+}
+
+// applyComments applies both the comments and the future comments to the given node and the previous one,
+// based on the context.
+func (c *Comments) applyComments(node, previous Node, position CommentPosition) {
+ if previous != nil {
+ c.CommentMap.AddComments(previous, c.Comments, position)
+ c.Comments = nil
+ } else {
+ c.CommentMap.AddComments(node, c.Comments, position)
+ c.Comments = nil
+ }
+ // Only apply the future comments to the node if the previous is set.
+ // This is for detecting end of line comments and which node comments on the following lines belongs to
+ if previous != nil {
+ c.CommentMap.AddComments(node, c.future, position)
+ c.future = nil
+ }
+}
+
+// AtLineBreak will mark a line break
+func (c *Comments) AtLineBreak() {
+ c.wasLineBreak = true
+}
+
+// CommentMap is the data structure where all found comments are stored
+type CommentMap map[Node][]*Comment
+
+// AddComment adds a single comment to the map
+func (cm CommentMap) AddComment(node Node, comment *Comment) {
+ list := cm[node]
+ list = append(list, comment)
+
+ cm[node] = list
+}
+
+// AddComments adds a slice of comments, given a node and an updated position
+func (cm CommentMap) AddComments(node Node, comments []*Comment, position CommentPosition) {
+ for _, comment := range comments {
+ if comment.Position == TBD {
+ comment.Position = position
+ }
+ cm.AddComment(node, comment)
+ }
+}
+
+// Size returns the size of the map
+func (cm CommentMap) Size() int {
+ size := 0
+ for _, comments := range cm {
+ size += len(comments)
+ }
+
+ return size
+}
+
+// MoveComments moves comments with a given position from a node to another
+func (cm CommentMap) MoveComments(from, to Node, position CommentPosition) {
+ for i, c := range cm[from] {
+ if c.Position == position {
+ cm.AddComment(to, c)
+
+ // Remove the comment from the "from" slice
+ cm[from][i] = cm[from][len(cm[from])-1]
+ cm[from][len(cm[from])-1] = nil
+ cm[from] = cm[from][:len(cm[from])-1]
+ }
+ }
+}
diff --git a/vendor/github.com/robertkrimen/otto/ast/node.go b/vendor/github.com/robertkrimen/otto/ast/node.go
new file mode 100644
index 0000000..ad98198
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/ast/node.go
@@ -0,0 +1,519 @@
+/*
+Package ast declares types representing a JavaScript AST.
+
+# Warning
+
+The parser and AST interfaces are still works-in-progress (particularly where
+node types are concerned) and may change in the future.
+*/
+package ast
+
+import (
+ "github.com/robertkrimen/otto/file"
+ "github.com/robertkrimen/otto/token"
+)
+
+// All nodes implement the Node interface.
+type Node interface {
+ Idx0() file.Idx // The index of the first character belonging to the node
+ Idx1() file.Idx // The index of the first character immediately after the node
+}
+
+// ========== //
+// Expression //
+// ========== //
+
+type (
+ // All expression nodes implement the Expression interface.
+ Expression interface {
+ Node
+ _expressionNode()
+ }
+
+ ArrayLiteral struct {
+ LeftBracket file.Idx
+ RightBracket file.Idx
+ Value []Expression
+ }
+
+ AssignExpression struct {
+ Operator token.Token
+ Left Expression
+ Right Expression
+ }
+
+ BadExpression struct {
+ From file.Idx
+ To file.Idx
+ }
+
+ BinaryExpression struct {
+ Operator token.Token
+ Left Expression
+ Right Expression
+ Comparison bool
+ }
+
+ BooleanLiteral struct {
+ Idx file.Idx
+ Literal string
+ Value bool
+ }
+
+ BracketExpression struct {
+ Left Expression
+ Member Expression
+ LeftBracket file.Idx
+ RightBracket file.Idx
+ }
+
+ CallExpression struct {
+ Callee Expression
+ LeftParenthesis file.Idx
+ ArgumentList []Expression
+ RightParenthesis file.Idx
+ }
+
+ ConditionalExpression struct {
+ Test Expression
+ Consequent Expression
+ Alternate Expression
+ }
+
+ DotExpression struct {
+ Left Expression
+ Identifier *Identifier
+ }
+
+ EmptyExpression struct {
+ Begin file.Idx
+ End file.Idx
+ }
+
+ FunctionLiteral struct {
+ Function file.Idx
+ Name *Identifier
+ ParameterList *ParameterList
+ Body Statement
+ Source string
+
+ DeclarationList []Declaration
+ }
+
+ Identifier struct {
+ Name string
+ Idx file.Idx
+ }
+
+ NewExpression struct {
+ New file.Idx
+ Callee Expression
+ LeftParenthesis file.Idx
+ ArgumentList []Expression
+ RightParenthesis file.Idx
+ }
+
+ NullLiteral struct {
+ Idx file.Idx
+ Literal string
+ }
+
+ NumberLiteral struct {
+ Idx file.Idx
+ Literal string
+ Value interface{}
+ }
+
+ ObjectLiteral struct {
+ LeftBrace file.Idx
+ RightBrace file.Idx
+ Value []Property
+ }
+
+ ParameterList struct {
+ Opening file.Idx
+ List []*Identifier
+ Closing file.Idx
+ }
+
+ Property struct {
+ Key string
+ Kind string
+ Value Expression
+ }
+
+ RegExpLiteral struct {
+ Idx file.Idx
+ Literal string
+ Pattern string
+ Flags string
+ Value string
+ }
+
+ SequenceExpression struct {
+ Sequence []Expression
+ }
+
+ StringLiteral struct {
+ Idx file.Idx
+ Literal string
+ Value string
+ }
+
+ ThisExpression struct {
+ Idx file.Idx
+ }
+
+ UnaryExpression struct {
+ Operator token.Token
+ Idx file.Idx // If a prefix operation
+ Operand Expression
+ Postfix bool
+ }
+
+ VariableExpression struct {
+ Name string
+ Idx file.Idx
+ Initializer Expression
+ }
+)
+
+// _expressionNode
+
+func (*ArrayLiteral) _expressionNode() {}
+func (*AssignExpression) _expressionNode() {}
+func (*BadExpression) _expressionNode() {}
+func (*BinaryExpression) _expressionNode() {}
+func (*BooleanLiteral) _expressionNode() {}
+func (*BracketExpression) _expressionNode() {}
+func (*CallExpression) _expressionNode() {}
+func (*ConditionalExpression) _expressionNode() {}
+func (*DotExpression) _expressionNode() {}
+func (*EmptyExpression) _expressionNode() {}
+func (*FunctionLiteral) _expressionNode() {}
+func (*Identifier) _expressionNode() {}
+func (*NewExpression) _expressionNode() {}
+func (*NullLiteral) _expressionNode() {}
+func (*NumberLiteral) _expressionNode() {}
+func (*ObjectLiteral) _expressionNode() {}
+func (*RegExpLiteral) _expressionNode() {}
+func (*SequenceExpression) _expressionNode() {}
+func (*StringLiteral) _expressionNode() {}
+func (*ThisExpression) _expressionNode() {}
+func (*UnaryExpression) _expressionNode() {}
+func (*VariableExpression) _expressionNode() {}
+
+// ========= //
+// Statement //
+// ========= //
+
+type (
+ // All statement nodes implement the Statement interface.
+ Statement interface {
+ Node
+ _statementNode()
+ }
+
+ BadStatement struct {
+ From file.Idx
+ To file.Idx
+ }
+
+ BlockStatement struct {
+ LeftBrace file.Idx
+ List []Statement
+ RightBrace file.Idx
+ }
+
+ BranchStatement struct {
+ Idx file.Idx
+ Token token.Token
+ Label *Identifier
+ }
+
+ CaseStatement struct {
+ Case file.Idx
+ Test Expression
+ Consequent []Statement
+ }
+
+ CatchStatement struct {
+ Catch file.Idx
+ Parameter *Identifier
+ Body Statement
+ }
+
+ DebuggerStatement struct {
+ Debugger file.Idx
+ }
+
+ DoWhileStatement struct {
+ Do file.Idx
+ Test Expression
+ Body Statement
+ }
+
+ EmptyStatement struct {
+ Semicolon file.Idx
+ }
+
+ ExpressionStatement struct {
+ Expression Expression
+ }
+
+ ForInStatement struct {
+ For file.Idx
+ Into Expression
+ Source Expression
+ Body Statement
+ }
+
+ ForStatement struct {
+ For file.Idx
+ Initializer Expression
+ Update Expression
+ Test Expression
+ Body Statement
+ }
+
+ FunctionStatement struct {
+ Function *FunctionLiteral
+ }
+
+ IfStatement struct {
+ If file.Idx
+ Test Expression
+ Consequent Statement
+ Alternate Statement
+ }
+
+ LabelledStatement struct {
+ Label *Identifier
+ Colon file.Idx
+ Statement Statement
+ }
+
+ ReturnStatement struct {
+ Return file.Idx
+ Argument Expression
+ }
+
+ SwitchStatement struct {
+ Switch file.Idx
+ Discriminant Expression
+ Default int
+ Body []*CaseStatement
+ }
+
+ ThrowStatement struct {
+ Throw file.Idx
+ Argument Expression
+ }
+
+ TryStatement struct {
+ Try file.Idx
+ Body Statement
+ Catch *CatchStatement
+ Finally Statement
+ }
+
+ VariableStatement struct {
+ Var file.Idx
+ List []Expression
+ }
+
+ WhileStatement struct {
+ While file.Idx
+ Test Expression
+ Body Statement
+ }
+
+ WithStatement struct {
+ With file.Idx
+ Object Expression
+ Body Statement
+ }
+)
+
+// _statementNode
+
+func (*BadStatement) _statementNode() {}
+func (*BlockStatement) _statementNode() {}
+func (*BranchStatement) _statementNode() {}
+func (*CaseStatement) _statementNode() {}
+func (*CatchStatement) _statementNode() {}
+func (*DebuggerStatement) _statementNode() {}
+func (*DoWhileStatement) _statementNode() {}
+func (*EmptyStatement) _statementNode() {}
+func (*ExpressionStatement) _statementNode() {}
+func (*ForInStatement) _statementNode() {}
+func (*ForStatement) _statementNode() {}
+func (*FunctionStatement) _statementNode() {}
+func (*IfStatement) _statementNode() {}
+func (*LabelledStatement) _statementNode() {}
+func (*ReturnStatement) _statementNode() {}
+func (*SwitchStatement) _statementNode() {}
+func (*ThrowStatement) _statementNode() {}
+func (*TryStatement) _statementNode() {}
+func (*VariableStatement) _statementNode() {}
+func (*WhileStatement) _statementNode() {}
+func (*WithStatement) _statementNode() {}
+
+// =========== //
+// Declaration //
+// =========== //
+
+type (
+ // All declaration nodes implement the Declaration interface.
+ Declaration interface {
+ _declarationNode()
+ }
+
+ FunctionDeclaration struct {
+ Function *FunctionLiteral
+ }
+
+ VariableDeclaration struct {
+ Var file.Idx
+ List []*VariableExpression
+ }
+)
+
+// _declarationNode
+
+func (*FunctionDeclaration) _declarationNode() {}
+func (*VariableDeclaration) _declarationNode() {}
+
+// ==== //
+// Node //
+// ==== //
+
+type Program struct {
+ Body []Statement
+
+ DeclarationList []Declaration
+
+ File *file.File
+
+ Comments CommentMap
+}
+
+// ==== //
+// Idx0 //
+// ==== //
+
+func (self *ArrayLiteral) Idx0() file.Idx { return self.LeftBracket }
+func (self *AssignExpression) Idx0() file.Idx { return self.Left.Idx0() }
+func (self *BadExpression) Idx0() file.Idx { return self.From }
+func (self *BinaryExpression) Idx0() file.Idx { return self.Left.Idx0() }
+func (self *BooleanLiteral) Idx0() file.Idx { return self.Idx }
+func (self *BracketExpression) Idx0() file.Idx { return self.Left.Idx0() }
+func (self *CallExpression) Idx0() file.Idx { return self.Callee.Idx0() }
+func (self *ConditionalExpression) Idx0() file.Idx { return self.Test.Idx0() }
+func (self *DotExpression) Idx0() file.Idx { return self.Left.Idx0() }
+func (self *EmptyExpression) Idx0() file.Idx { return self.Begin }
+func (self *FunctionLiteral) Idx0() file.Idx { return self.Function }
+func (self *Identifier) Idx0() file.Idx { return self.Idx }
+func (self *NewExpression) Idx0() file.Idx { return self.New }
+func (self *NullLiteral) Idx0() file.Idx { return self.Idx }
+func (self *NumberLiteral) Idx0() file.Idx { return self.Idx }
+func (self *ObjectLiteral) Idx0() file.Idx { return self.LeftBrace }
+func (self *RegExpLiteral) Idx0() file.Idx { return self.Idx }
+func (self *SequenceExpression) Idx0() file.Idx { return self.Sequence[0].Idx0() }
+func (self *StringLiteral) Idx0() file.Idx { return self.Idx }
+func (self *ThisExpression) Idx0() file.Idx { return self.Idx }
+func (self *UnaryExpression) Idx0() file.Idx { return self.Idx }
+func (self *VariableExpression) Idx0() file.Idx { return self.Idx }
+
+func (self *BadStatement) Idx0() file.Idx { return self.From }
+func (self *BlockStatement) Idx0() file.Idx { return self.LeftBrace }
+func (self *BranchStatement) Idx0() file.Idx { return self.Idx }
+func (self *CaseStatement) Idx0() file.Idx { return self.Case }
+func (self *CatchStatement) Idx0() file.Idx { return self.Catch }
+func (self *DebuggerStatement) Idx0() file.Idx { return self.Debugger }
+func (self *DoWhileStatement) Idx0() file.Idx { return self.Do }
+func (self *EmptyStatement) Idx0() file.Idx { return self.Semicolon }
+func (self *ExpressionStatement) Idx0() file.Idx { return self.Expression.Idx0() }
+func (self *ForInStatement) Idx0() file.Idx { return self.For }
+func (self *ForStatement) Idx0() file.Idx { return self.For }
+func (self *FunctionStatement) Idx0() file.Idx { return self.Function.Idx0() }
+func (self *IfStatement) Idx0() file.Idx { return self.If }
+func (self *LabelledStatement) Idx0() file.Idx { return self.Label.Idx0() }
+func (self *Program) Idx0() file.Idx { return self.Body[0].Idx0() }
+func (self *ReturnStatement) Idx0() file.Idx { return self.Return }
+func (self *SwitchStatement) Idx0() file.Idx { return self.Switch }
+func (self *ThrowStatement) Idx0() file.Idx { return self.Throw }
+func (self *TryStatement) Idx0() file.Idx { return self.Try }
+func (self *VariableStatement) Idx0() file.Idx { return self.Var }
+func (self *WhileStatement) Idx0() file.Idx { return self.While }
+func (self *WithStatement) Idx0() file.Idx { return self.With }
+
+// ==== //
+// Idx1 //
+// ==== //
+
+func (self *ArrayLiteral) Idx1() file.Idx { return self.RightBracket }
+func (self *AssignExpression) Idx1() file.Idx { return self.Right.Idx1() }
+func (self *BadExpression) Idx1() file.Idx { return self.To }
+func (self *BinaryExpression) Idx1() file.Idx { return self.Right.Idx1() }
+func (self *BooleanLiteral) Idx1() file.Idx { return file.Idx(int(self.Idx) + len(self.Literal)) }
+func (self *BracketExpression) Idx1() file.Idx { return self.RightBracket + 1 }
+func (self *CallExpression) Idx1() file.Idx { return self.RightParenthesis + 1 }
+func (self *ConditionalExpression) Idx1() file.Idx { return self.Test.Idx1() }
+func (self *DotExpression) Idx1() file.Idx { return self.Identifier.Idx1() }
+func (self *EmptyExpression) Idx1() file.Idx { return self.End }
+func (self *FunctionLiteral) Idx1() file.Idx { return self.Body.Idx1() }
+func (self *Identifier) Idx1() file.Idx { return file.Idx(int(self.Idx) + len(self.Name)) }
+func (self *NewExpression) Idx1() file.Idx {
+ if self.RightParenthesis > 0 {
+ return self.RightParenthesis + 1
+ }
+ return self.Callee.Idx1()
+}
+func (self *NullLiteral) Idx1() file.Idx { return file.Idx(int(self.Idx) + 4) } // "null"
+func (self *NumberLiteral) Idx1() file.Idx { return file.Idx(int(self.Idx) + len(self.Literal)) }
+func (self *ObjectLiteral) Idx1() file.Idx { return self.RightBrace }
+func (self *RegExpLiteral) Idx1() file.Idx { return file.Idx(int(self.Idx) + len(self.Literal)) }
+func (self *SequenceExpression) Idx1() file.Idx { return self.Sequence[0].Idx1() }
+func (self *StringLiteral) Idx1() file.Idx { return file.Idx(int(self.Idx) + len(self.Literal)) }
+func (self *ThisExpression) Idx1() file.Idx { return self.Idx + 4 }
+func (self *UnaryExpression) Idx1() file.Idx {
+ if self.Postfix {
+ return self.Operand.Idx1() + 2 // ++ --
+ }
+ return self.Operand.Idx1()
+}
+func (self *VariableExpression) Idx1() file.Idx {
+ if self.Initializer == nil {
+ return file.Idx(int(self.Idx) + len(self.Name) + 1)
+ }
+ return self.Initializer.Idx1()
+}
+
+func (self *BadStatement) Idx1() file.Idx { return self.To }
+func (self *BlockStatement) Idx1() file.Idx { return self.RightBrace + 1 }
+func (self *BranchStatement) Idx1() file.Idx { return self.Idx }
+func (self *CaseStatement) Idx1() file.Idx { return self.Consequent[len(self.Consequent)-1].Idx1() }
+func (self *CatchStatement) Idx1() file.Idx { return self.Body.Idx1() }
+func (self *DebuggerStatement) Idx1() file.Idx { return self.Debugger + 8 }
+func (self *DoWhileStatement) Idx1() file.Idx { return self.Test.Idx1() }
+func (self *EmptyStatement) Idx1() file.Idx { return self.Semicolon + 1 }
+func (self *ExpressionStatement) Idx1() file.Idx { return self.Expression.Idx1() }
+func (self *ForInStatement) Idx1() file.Idx { return self.Body.Idx1() }
+func (self *ForStatement) Idx1() file.Idx { return self.Body.Idx1() }
+func (self *FunctionStatement) Idx1() file.Idx { return self.Function.Idx1() }
+func (self *IfStatement) Idx1() file.Idx {
+ if self.Alternate != nil {
+ return self.Alternate.Idx1()
+ }
+ return self.Consequent.Idx1()
+}
+func (self *LabelledStatement) Idx1() file.Idx { return self.Colon + 1 }
+func (self *Program) Idx1() file.Idx { return self.Body[len(self.Body)-1].Idx1() }
+func (self *ReturnStatement) Idx1() file.Idx { return self.Return }
+func (self *SwitchStatement) Idx1() file.Idx { return self.Body[len(self.Body)-1].Idx1() }
+func (self *ThrowStatement) Idx1() file.Idx { return self.Throw }
+func (self *TryStatement) Idx1() file.Idx { return self.Try }
+func (self *VariableStatement) Idx1() file.Idx { return self.List[len(self.List)-1].Idx1() }
+func (self *WhileStatement) Idx1() file.Idx { return self.Body.Idx1() }
+func (self *WithStatement) Idx1() file.Idx { return self.Body.Idx1() }
diff --git a/vendor/github.com/robertkrimen/otto/ast/walk.go b/vendor/github.com/robertkrimen/otto/ast/walk.go
new file mode 100644
index 0000000..521445b
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/ast/walk.go
@@ -0,0 +1,219 @@
+package ast
+
+import "fmt"
+
+// Visitor Enter method is invoked for each node encountered by Walk.
+// If the result visitor w is not nil, Walk visits each of the children
+// of node with the visitor v, followed by a call of the Exit method.
+type Visitor interface {
+ Enter(n Node) (v Visitor)
+ Exit(n Node)
+}
+
+// Walk traverses an AST in depth-first order: It starts by calling
+// v.Enter(node); node must not be nil. If the visitor v returned by
+// v.Enter(node) is not nil, Walk is invoked recursively with visitor
+// v for each of the non-nil children of node, followed by a call
+// of v.Exit(node).
+func Walk(v Visitor, n Node) {
+ if n == nil {
+ return
+ }
+ if v = v.Enter(n); v == nil {
+ return
+ }
+
+ defer v.Exit(n)
+
+ switch n := n.(type) {
+ case *ArrayLiteral:
+ if n != nil {
+ for _, ex := range n.Value {
+ Walk(v, ex)
+ }
+ }
+ case *AssignExpression:
+ if n != nil {
+ Walk(v, n.Left)
+ Walk(v, n.Right)
+ }
+ case *BadExpression:
+ case *BinaryExpression:
+ if n != nil {
+ Walk(v, n.Left)
+ Walk(v, n.Right)
+ }
+ case *BlockStatement:
+ if n != nil {
+ for _, s := range n.List {
+ Walk(v, s)
+ }
+ }
+ case *BooleanLiteral:
+ case *BracketExpression:
+ if n != nil {
+ Walk(v, n.Left)
+ Walk(v, n.Member)
+ }
+ case *BranchStatement:
+ if n != nil {
+ Walk(v, n.Label)
+ }
+ case *CallExpression:
+ if n != nil {
+ Walk(v, n.Callee)
+ for _, a := range n.ArgumentList {
+ Walk(v, a)
+ }
+ }
+ case *CaseStatement:
+ if n != nil {
+ Walk(v, n.Test)
+ for _, c := range n.Consequent {
+ Walk(v, c)
+ }
+ }
+ case *CatchStatement:
+ if n != nil {
+ Walk(v, n.Parameter)
+ Walk(v, n.Body)
+ }
+ case *ConditionalExpression:
+ if n != nil {
+ Walk(v, n.Test)
+ Walk(v, n.Consequent)
+ Walk(v, n.Alternate)
+ }
+ case *DebuggerStatement:
+ case *DoWhileStatement:
+ if n != nil {
+ Walk(v, n.Test)
+ Walk(v, n.Body)
+ }
+ case *DotExpression:
+ if n != nil {
+ Walk(v, n.Left)
+ Walk(v, n.Identifier)
+ }
+ case *EmptyExpression:
+ case *EmptyStatement:
+ case *ExpressionStatement:
+ if n != nil {
+ Walk(v, n.Expression)
+ }
+ case *ForInStatement:
+ if n != nil {
+ Walk(v, n.Into)
+ Walk(v, n.Source)
+ Walk(v, n.Body)
+ }
+ case *ForStatement:
+ if n != nil {
+ Walk(v, n.Initializer)
+ Walk(v, n.Update)
+ Walk(v, n.Test)
+ Walk(v, n.Body)
+ }
+ case *FunctionLiteral:
+ if n != nil {
+ Walk(v, n.Name)
+ for _, p := range n.ParameterList.List {
+ Walk(v, p)
+ }
+ Walk(v, n.Body)
+ }
+ case *FunctionStatement:
+ if n != nil {
+ Walk(v, n.Function)
+ }
+ case *Identifier:
+ case *IfStatement:
+ if n != nil {
+ Walk(v, n.Test)
+ Walk(v, n.Consequent)
+ Walk(v, n.Alternate)
+ }
+ case *LabelledStatement:
+ if n != nil {
+ Walk(v, n.Label)
+ Walk(v, n.Statement)
+ }
+ case *NewExpression:
+ if n != nil {
+ Walk(v, n.Callee)
+ for _, a := range n.ArgumentList {
+ Walk(v, a)
+ }
+ }
+ case *NullLiteral:
+ case *NumberLiteral:
+ case *ObjectLiteral:
+ if n != nil {
+ for _, p := range n.Value {
+ Walk(v, p.Value)
+ }
+ }
+ case *Program:
+ if n != nil {
+ for _, b := range n.Body {
+ Walk(v, b)
+ }
+ }
+ case *RegExpLiteral:
+ case *ReturnStatement:
+ if n != nil {
+ Walk(v, n.Argument)
+ }
+ case *SequenceExpression:
+ if n != nil {
+ for _, e := range n.Sequence {
+ Walk(v, e)
+ }
+ }
+ case *StringLiteral:
+ case *SwitchStatement:
+ if n != nil {
+ Walk(v, n.Discriminant)
+ for _, c := range n.Body {
+ Walk(v, c)
+ }
+ }
+ case *ThisExpression:
+ case *ThrowStatement:
+ if n != nil {
+ Walk(v, n.Argument)
+ }
+ case *TryStatement:
+ if n != nil {
+ Walk(v, n.Body)
+ Walk(v, n.Catch)
+ Walk(v, n.Finally)
+ }
+ case *UnaryExpression:
+ if n != nil {
+ Walk(v, n.Operand)
+ }
+ case *VariableExpression:
+ if n != nil {
+ Walk(v, n.Initializer)
+ }
+ case *VariableStatement:
+ if n != nil {
+ for _, e := range n.List {
+ Walk(v, e)
+ }
+ }
+ case *WhileStatement:
+ if n != nil {
+ Walk(v, n.Test)
+ Walk(v, n.Body)
+ }
+ case *WithStatement:
+ if n != nil {
+ Walk(v, n.Object)
+ Walk(v, n.Body)
+ }
+ default:
+ panic(fmt.Sprintf("Walk: unexpected node type %T", n))
+ }
+}
diff --git a/vendor/github.com/robertkrimen/otto/builtin.go b/vendor/github.com/robertkrimen/otto/builtin.go
new file mode 100644
index 0000000..b178d50
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/builtin.go
@@ -0,0 +1,336 @@
+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(), nil)
+ 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))
+}
+
+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.Trim(call.Argument(0).string(), builtinString_trim_whitespace)
+ 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 {
+ return NaNValue()
+ }
+ value = value*base + digit
+ }
+ if negative {
+ value *= -1
+ }
+ return toValue_float64(value)
+ }
+ 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.Trim(call.Argument(0).string(), builtinString_trim_whitespace)
+
+ if parseFloat_matchBadSpecial.MatchString(input) {
+ return NaNValue()
+ }
+ value, err := strconv.ParseFloat(input, 64)
+ if err != nil {
+ for end := len(input); end > 0; end-- {
+ 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/vendor/github.com/robertkrimen/otto/builtin_array.go b/vendor/github.com/robertkrimen/otto/builtin_array.go
new file mode 100644
index 0000000..20e89ee
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/builtin_array.go
@@ -0,0 +1,683 @@
+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(propertyLength)))
+ 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(propertyLength).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(propertyLength)))
+ if 0 == length {
+ thisObject.put(propertyLength, 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(propertyLength, toValue_int64(length-1), true)
+ return first
+}
+
+func builtinArray_push(call FunctionCall) Value {
+ thisObject := call.thisObject()
+ itemList := call.ArgumentList
+ index := int64(toUint32(thisObject.get(propertyLength)))
+ for len(itemList) > 0 {
+ thisObject.put(arrayIndexToString(index), itemList[0], true)
+ itemList = itemList[1:]
+ index += 1
+ }
+ length := toValue_int64(index)
+ thisObject.put(propertyLength, length, true)
+ return length
+}
+
+func builtinArray_pop(call FunctionCall) Value {
+ thisObject := call.thisObject()
+ length := int64(toUint32(thisObject.get(propertyLength)))
+ if 0 == length {
+ thisObject.put(propertyLength, toValue_uint32(0), true)
+ return Value{}
+ }
+ last := thisObject.get(arrayIndexToString(length - 1))
+ thisObject.delete(arrayIndexToString(length-1), true)
+ thisObject.put(propertyLength, 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(propertyLength)))
+ 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(propertyLength)))
+
+ start := valueToRangeIndex(call.Argument(0), length, false)
+ deleteCount := length - start
+ if arg, ok := call.getArgument(1); ok {
+ deleteCount = valueToRangeIndex(arg, 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 (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(propertyLength, 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(propertyLength)))
+ 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(propertyLength)))
+ 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(propertyLength, newLength, true)
+ return newLength
+}
+
+func builtinArray_reverse(call FunctionCall) Value {
+ thisObject := call.thisObject()
+ length := int64(toUint32(thisObject.get(propertyLength)))
+
+ 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 toIntSign(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, uint) {
+ arraySortSwap(thisObject, pivot, right) // Right is now the pivot value
+ cursor := left
+ cursor2 := left
+ for index := left; index < right; index++ {
+ comparison := sortCompare(thisObject, index, right, compare) // Compare to the pivot value
+ if comparison < 0 {
+ arraySortSwap(thisObject, index, cursor)
+ if cursor < cursor2 {
+ arraySortSwap(thisObject, index, cursor2)
+ }
+ cursor += 1
+ cursor2 += 1
+ } else if comparison == 0 {
+ arraySortSwap(thisObject, index, cursor2)
+ cursor2 += 1
+ }
+ }
+ arraySortSwap(thisObject, cursor2, right)
+ return cursor, cursor2
+}
+
+func arraySortQuickSort(thisObject *_object, left, right uint, compare *_object) {
+ if left < right {
+ middle := left + (right-left)/2
+ pivot, pivot2 := arraySortQuickPartition(thisObject, left, right, middle, compare)
+ if pivot > 0 {
+ arraySortQuickSort(thisObject, left, pivot-1, compare)
+ }
+ arraySortQuickSort(thisObject, pivot2+1, right, compare)
+ }
+}
+
+func builtinArray_sort(call FunctionCall) Value {
+ thisObject := call.thisObject()
+ length := uint(toUint32(thisObject.get(propertyLength)))
+ 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(propertyLength))); 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(propertyLength)))
+ 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(propertyLength)))
+ 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(propertyLength)))
+ 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(propertyLength)))
+ 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(propertyLength)))
+ 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(propertyLength)))
+ 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(propertyLength)))
+ 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), index, 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(propertyLength)))
+ 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--
+ 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/vendor/github.com/robertkrimen/otto/builtin_boolean.go b/vendor/github.com/robertkrimen/otto/builtin_boolean.go
new file mode 100644
index 0000000..25a596e
--- /dev/null
+++ b/vendor/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(classBoolean).primitiveValue()
+ }
+ return toValue_string(value.string())
+}
+
+func builtinBoolean_valueOf(call FunctionCall) Value {
+ value := call.This
+ if !value.IsBoolean() {
+ value = call.thisClassObject(classBoolean).primitiveValue()
+ }
+ return value
+}
diff --git a/vendor/github.com/robertkrimen/otto/builtin_date.go b/vendor/github.com/robertkrimen/otto/builtin_date.go
new file mode 100644
index 0000000..ff6dbb7
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/builtin_date.go
@@ -0,0 +1,622 @@
+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"
+)
+
+var (
+ // utcTimeZone is the time zone used for UTC calculations.
+ // It is GMT not UTC as that's what Javascript does because toUTCString is
+ // actually an alias to toGMTString.
+ utcTimeZone = Time.FixedZone("GMT", 0)
+)
+
+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().In(utcTimeZone).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/vendor/github.com/robertkrimen/otto/builtin_error.go b/vendor/github.com/robertkrimen/otto/builtin_error.go
new file mode 100644
index 0000000..95f9cd9
--- /dev/null
+++ b/vendor/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(classError, call.Argument(0), 1))
+}
+
+func builtinNewError(self *_object, argumentList []Value) Value {
+ return toValue_object(self.runtime.newError(classError, valueOfArrayIndex(argumentList, 0), 0))
+}
+
+func builtinError_toString(call FunctionCall) Value {
+ thisObject := call.thisObject()
+ if thisObject == nil {
+ panic(call.runtime.panicTypeError())
+ }
+
+ name := classError
+ 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, 0)
+ 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, 0)
+ 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, 0)
+ 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, 0)
+ self.prototype = runtime.global.URIErrorPrototype
+ return self
+}
+
+func (runtime *_runtime) newReferenceError(message Value) *_object {
+ self := runtime.newErrorObject("ReferenceError", message, 0)
+ 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, 0)
+ 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/vendor/github.com/robertkrimen/otto/builtin_function.go b/vendor/github.com/robertkrimen/otto/builtin_function.go
new file mode 100644
index 0000000..f988c83
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/builtin_function.go
@@ -0,0 +1,126 @@
+package otto
+
+import (
+ "fmt"
+ "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
+}
+
+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(classFunction) // 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(propertyLength)))
+ 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/vendor/github.com/robertkrimen/otto/builtin_json.go b/vendor/github.com/robertkrimen/otto/builtin_json.go
new file mode 100644
index 0000000..adfc76f
--- /dev/null
+++ b/vendor/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 classString:
+ case classNumber:
+ 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 == classFunction {
+ value := toValue_object(replacer)
+ ctx.replacerFunction = &value
+ }
+ }
+ if spaceValue, exists := call.getArgument(2); exists {
+ if spaceValue.kind == valueObject {
+ switch spaceValue.value.(*_object).class {
+ case classString:
+ spaceValue = toValue_string(spaceValue.string())
+ case classNumber:
+ 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 classBoolean:
+ value = value._object().value.(Value)
+ case classString:
+ value = toValue_string(value.string())
+ case classNumber:
+ 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(propertyLength).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 != classFunction {
+ 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/vendor/github.com/robertkrimen/otto/builtin_math.go b/vendor/github.com/robertkrimen/otto/builtin_math.go
new file mode 100644
index 0000000..7ce90c3
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/builtin_math.go
@@ -0,0 +1,151 @@
+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 {
+ var v float64
+ if call.runtime.random != nil {
+ v = call.runtime.random()
+ } else {
+ v = rand.Float64()
+ }
+ return toValue_float64(v)
+}
+
+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/vendor/github.com/robertkrimen/otto/builtin_number.go b/vendor/github.com/robertkrimen/otto/builtin_number.go
new file mode 100644
index 0000000..202a81c
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/builtin_number.go
@@ -0,0 +1,112 @@
+package otto
+
+import (
+ "math"
+ "strconv"
+
+ "golang.org/x/text/language"
+ "golang.org/x/text/message"
+ "golang.org/x/text/number"
+)
+
+// 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(classNumber).primitiveValue()
+ radix := 10
+ radixArgument := call.Argument(0)
+ if radixArgument.IsDefined() {
+ integer := toIntegerFloat(radixArgument)
+ if integer < 2 || integer > 36 {
+ panic(call.runtime.panicRangeError("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(classNumber).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("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("toPrecision() precision must be greater than 1"))
+ }
+ return toValue_string(strconv.FormatFloat(call.This.float64(), 'g', int(precision), 64))
+}
+
+func builtinNumber_isNaN(call FunctionCall) Value {
+ if len(call.ArgumentList) < 1 {
+ return toValue_bool(false)
+ }
+ return toValue_bool(call.Argument(0).IsNaN())
+}
+
+func builtinNumber_toLocaleString(call FunctionCall) Value {
+ value := call.thisClassObject(classNumber).primitiveValue()
+ locale := call.Argument(0)
+ lang := defaultLanguage
+ if locale.IsDefined() {
+ lang = language.MustParse(locale.string())
+ }
+
+ p := message.NewPrinter(lang)
+ return toValue_string(p.Sprintf("%v", number.Decimal(value.value)))
+}
diff --git a/vendor/github.com/robertkrimen/otto/builtin_object.go b/vendor/github.com/robertkrimen/otto/builtin_object.go
new file mode 100644
index 0000000..f9a39d3
--- /dev/null
+++ b/vendor/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 {
+ var result string
+ 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/vendor/github.com/robertkrimen/otto/builtin_regexp.go b/vendor/github.com/robertkrimen/otto/builtin_regexp.go
new file mode 100644
index 0000000..b577bcc
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/builtin_regexp.go
@@ -0,0 +1,98 @@
+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 == classRegExp && 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, result := execRegExp(thisObject, target)
+
+ if !match {
+ return toValue_bool(match)
+ }
+
+ // Match extract and assign input, $_ and $1 -> $9 on global RegExp.
+ input := toValue_string(target)
+ call.runtime.global.RegExp.defineProperty("$_", input, 0100, false)
+ call.runtime.global.RegExp.defineProperty("input", input, 0100, false)
+
+ var start int
+ n := 1
+ re := call.runtime.global.RegExp
+ for i, v := range result[2:] {
+ if i%2 == 0 {
+ start = v
+ } else {
+ re.defineProperty(fmt.Sprintf("$%d", n), toValue_string(target[start:v]), 0100, false)
+ n++
+ if n == 10 {
+ break
+ }
+ }
+ }
+
+ if n <= 9 {
+ // Erase remaining.
+ empty := toValue_string("")
+ for i := n; i <= 9; i++ {
+ re.defineProperty(fmt.Sprintf("$%d", i), empty, 0100, false)
+ }
+ }
+
+ 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/vendor/github.com/robertkrimen/otto/builtin_string.go b/vendor/github.com/robertkrimen/otto/builtin_string.go
new file mode 100644
index 0000000..3ac24ea
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/builtin_string.go
@@ -0,0 +1,508 @@
+package otto
+
+import (
+ "bytes"
+ "regexp"
+ "strconv"
+ "strings"
+ "unicode/utf16"
+ "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(classString).primitiveValue()
+}
+func builtinString_valueOf(call FunctionCall) Value {
+ return call.thisClassObject(classString).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 lastIndexRune(s, substr string) int {
+ if i := strings.LastIndex(s, substr); i >= 0 {
+ return utf16Length(s[:i])
+ }
+ return -1
+}
+
+func indexRune(s, substr string) int {
+ if i := strings.Index(s, substr); i >= 0 {
+ return utf16Length(s[:i])
+ }
+ return -1
+}
+
+func utf16Length(s string) int {
+ return len(utf16.Encode([]rune(s)))
+}
+
+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(indexRune(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 := indexRune(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(lastIndexRune(value, target))
+ }
+ length := len(value)
+ if length == 0 {
+ return toValue_int(lastIndexRune(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(lastIndexRune(value, target))
+ }
+ if 0 > start.int64 {
+ start.int64 = 0
+ }
+ end := int(start.int64) + len(target)
+ if end > length {
+ end = length
+ }
+ return toValue_int(lastIndexRune(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 != classRegExp {
+ 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)
+ 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]:]
+ }
+ matchNumberParse, err := strconv.ParseInt(string(part[1:]), 10, 64)
+ if err != nil {
+ return []byte{}
+ }
+ matchNumber := int(matchNumberParse)
+ if 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 == classRegExp {
+ 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 != classRegExp {
+ 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 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(string(target[start:end]))
+}
+
+func builtinString_substring(call FunctionCall) Value {
+ checkObjectCoercible(call.runtime, call.This)
+ target := []rune(call.This.string())
+
+ length := int64(len(target))
+ start, end := rangeStartEnd(call.ArgumentList, length, true)
+ if start > end {
+ start, end = end, start
+ }
+ return toValue_string(string(target[start:end]))
+}
+
+func builtinString_substr(call FunctionCall) Value {
+ target := []rune(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(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/vendor/github.com/robertkrimen/otto/clone.go b/vendor/github.com/robertkrimen/otto/clone.go
new file mode 100644
index 0000000..0e1e879
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/clone.go
@@ -0,0 +1,172 @@
+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{
+ debugger: in.debugger,
+ random: in.random,
+ stackLimit: in.stackLimit,
+ traceLimit: in.traceLimit,
+ }
+
+ 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
+
+ switch value := in.value.(type) {
+ case Value:
+ out.value = clone.value(value)
+ case _propertyGetSet:
+ p := _propertyGetSet{}
+ if value[0] != nil {
+ p[0] = clone.object(value[0])
+ }
+ if value[1] != nil {
+ p[1] = clone.object(value[1])
+ }
+ out.value = p
+ default:
+ panic(fmt.Errorf("in.value.(Value) != true; in.value is %T", in.value))
+ }
+
+ return out
+}
+
+func (clone *_clone) dclProperty(in _dclProperty) _dclProperty {
+ out := in
+ out.value = clone.value(in.value)
+ return out
+}
diff --git a/vendor/github.com/robertkrimen/otto/cmpl.go b/vendor/github.com/robertkrimen/otto/cmpl.go
new file mode 100644
index 0000000..0153159
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/cmpl.go
@@ -0,0 +1,18 @@
+package otto
+
+import (
+ "github.com/robertkrimen/otto/ast"
+ "github.com/robertkrimen/otto/file"
+)
+
+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/vendor/github.com/robertkrimen/otto/cmpl_evaluate.go b/vendor/github.com/robertkrimen/otto/cmpl_evaluate.go
new file mode 100644
index 0000000..692c672
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/cmpl_evaluate.go
@@ -0,0 +1,95 @@
+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/vendor/github.com/robertkrimen/otto/cmpl_evaluate_expression.go b/vendor/github.com/robertkrimen/otto/cmpl_evaluate_expression.go
new file mode 100644
index 0000000..325a7e8
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/cmpl_evaluate_expression.go
@@ -0,0 +1,453 @@
+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?
+ object, err := self.objectCoerce(targetValue)
+ if err != nil {
+ panic(self.panicTypeError("Cannot access member '%s' of %s", memberValue.string(), err.Error(), _at(node.idx)))
+ }
+ return toValue(newPropertyReference(self, object, 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(), _at(node.idx)))
+ }
+ 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/vendor/github.com/robertkrimen/otto/cmpl_evaluate_statement.go b/vendor/github.com/robertkrimen/otto/cmpl_evaluate_statement.go
new file mode 100644
index 0000000..6dc4676
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/cmpl_evaluate_statement.go
@@ -0,0 +1,428 @@
+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:
+ if self.debugger != nil {
+ self.debugger(self.otto)
+ }
+ 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
+ }
+ }
+
+ // this is to prevent for cycles with no body from running forever
+ if len(body) == 0 && self.otto.Interrupt != nil {
+ runtime.Gosched()
+ select {
+ case value := <-self.otto.Interrupt:
+ value()
+ default:
+ }
+ }
+
+ 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 => 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/vendor/github.com/robertkrimen/otto/cmpl_parse.go b/vendor/github.com/robertkrimen/otto/cmpl_parse.go
new file mode 100644
index 0000000..1cb47bb
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/cmpl_parse.go
@@ -0,0 +1,652 @@
+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.EmptyExpression:
+ return nil
+
+ 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.FunctionStatement:
+ return emptyStatement
+
+ 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/vendor/github.com/robertkrimen/otto/console.go b/vendor/github.com/robertkrimen/otto/console.go
new file mode 100644
index 0000000..8fba6cc
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/console.go
@@ -0,0 +1,50 @@
+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/vendor/github.com/robertkrimen/otto/consts.go b/vendor/github.com/robertkrimen/otto/consts.go
new file mode 100644
index 0000000..d8a8e6d
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/consts.go
@@ -0,0 +1,19 @@
+package otto
+
+const (
+ // Common classes.
+ classString = "String"
+ classGoArray = "GoArray"
+ classGoSlice = "GoSlice"
+ classNumber = "Number"
+ classDate = "Date"
+ classArray = "Array"
+ classFunction = "Function"
+ classObject = "Object"
+ classRegExp = "RegExp"
+ classBoolean = "Boolean"
+ classError = "Error"
+
+ // Common properties.
+ propertyLength = "length"
+)
diff --git a/vendor/github.com/robertkrimen/otto/dbg.go b/vendor/github.com/robertkrimen/otto/dbg.go
new file mode 100644
index 0000000..51fbdc2
--- /dev/null
+++ b/vendor/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/vendor/github.com/robertkrimen/otto/dbg/dbg.go b/vendor/github.com/robertkrimen/otto/dbg/dbg.go
new file mode 100644
index 0000000..8c27fa2
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/dbg/dbg.go
@@ -0,0 +1,387 @@
+// This file was AUTOMATICALLY GENERATED by dbg-import (smuggol) from github.com/robertkrimen/dbg
+
+/*
+Package dbg is a println/printf/log-debugging utility library.
+
+ import (
+ Dbg "github.com/robertkrimen/dbg"
+ )
+
+ dbg, dbgf := Dbg.New()
+
+ dbg("Emit some debug stuff", []byte{120, 121, 122, 122, 121}, math.Pi)
+ # "2013/01/28 16:50:03 Emit some debug stuff [120 121 122 122 121] 3.141592653589793"
+
+ dbgf("With a %s formatting %.2f", "little", math.Pi)
+ # "2013/01/28 16:51:55 With a little formatting (3.14)"
+
+ dbgf("%/fatal//A fatal debug statement: should not be here")
+ # "A fatal debug statement: should not be here"
+ # ...and then, os.Exit(1)
+
+ dbgf("%/panic//Can also panic %s", "this")
+ # "Can also panic this"
+ # ...as a panic, equivalent to: panic("Can also panic this")
+
+ dbgf("Any %s arguments without a corresponding %%", "extra", "are treated like arguments to dbg()")
+ # "2013/01/28 17:14:40 Any extra arguments (without a corresponding %) are treated like arguments to dbg()"
+
+ dbgf("%d %d", 1, 2, 3, 4, 5)
+ # "2013/01/28 17:16:32 Another example: 1 2 3 4 5"
+
+ dbgf("%@: Include the function name for a little context (via %s)", "%@")
+ # "2013... github.com/robertkrimen/dbg.TestSynopsis: Include the function name for a little context (via %@)"
+
+By default, dbg uses log (log.Println, log.Printf, log.Panic, etc.) for output.
+However, you can also provide your own output destination by invoking dbg.New with
+a customization function:
+
+ import (
+ "bytes"
+ Dbg "github.com/robertkrimen/dbg"
+ "os"
+ )
+
+ # dbg to os.Stderr
+ dbg, dbgf := Dbg.New(func(dbgr *Dbgr) {
+ dbgr.SetOutput(os.Stderr)
+ })
+
+ # A slightly contrived example:
+ var buffer bytes.Buffer
+ dbg, dbgf := New(func(dbgr *Dbgr) {
+ dbgr.SetOutput(&buffer)
+ })
+
+*/
+package dbg
+
+import (
+ "bytes"
+ "fmt"
+ "io"
+ "log"
+ "os"
+ "regexp"
+ "runtime"
+ "strings"
+ "unicode"
+)
+
+type _frmt struct {
+ ctl string
+ format string
+ operandCount int
+ panic bool
+ fatal bool
+ check bool
+}
+
+var (
+ ctlTest = regexp.MustCompile(`^\s*%/`)
+ ctlScan = regexp.MustCompile(`%?/(panic|fatal|check)(?:\s|$)`)
+)
+
+func operandCount(format string) int {
+ count := 0
+ end := len(format)
+ for at := 0; at < end; {
+ for at < end && format[at] != '%' {
+ at++
+ }
+ at++
+ if at < end {
+ if format[at] != '%' && format[at] != '@' {
+ count++
+ }
+ at++
+ }
+ }
+ return count
+}
+
+func parseFormat(format string) (frmt _frmt) {
+ if ctlTest.MatchString(format) {
+ format = strings.TrimLeftFunc(format, unicode.IsSpace)
+ index := strings.Index(format, "//")
+ if index != -1 {
+ frmt.ctl = format[0:index]
+ format = format[index+2:] // Skip the second slash via +2 (instead of +1)
+ } else {
+ frmt.ctl = format
+ format = ""
+ }
+ for _, tmp := range ctlScan.FindAllStringSubmatch(frmt.ctl, -1) {
+ for _, value := range tmp[1:] {
+ switch value {
+ case "panic":
+ frmt.panic = true
+ case "fatal":
+ frmt.fatal = true
+ case "check":
+ frmt.check = true
+ }
+ }
+ }
+ }
+ frmt.format = format
+ frmt.operandCount = operandCount(format)
+ return
+}
+
+type Dbgr struct {
+ emit _emit
+}
+
+type DbgFunction func(values ...interface{})
+
+func NewDbgr() *Dbgr {
+ self := &Dbgr{}
+ return self
+}
+
+/*
+New will create and return a pair of debugging functions. You can customize where
+they output to by passing in an (optional) customization function:
+
+ import (
+ Dbg "github.com/robertkrimen/dbg"
+ "os"
+ )
+
+ # dbg to os.Stderr
+ dbg, dbgf := Dbg.New(func(dbgr *Dbgr) {
+ dbgr.SetOutput(os.Stderr)
+ })
+
+*/
+func New(options ...interface{}) (dbg DbgFunction, dbgf DbgFunction) {
+ dbgr := NewDbgr()
+ if len(options) > 0 {
+ if fn, ok := options[0].(func(*Dbgr)); ok {
+ fn(dbgr)
+ }
+ }
+ return dbgr.DbgDbgf()
+}
+
+func (self Dbgr) Dbg(values ...interface{}) {
+ self.getEmit().emit(_frmt{}, "", values...)
+}
+
+func (self Dbgr) Dbgf(values ...interface{}) {
+ self.dbgf(values...)
+}
+
+func (self Dbgr) DbgDbgf() (dbg DbgFunction, dbgf DbgFunction) {
+ dbg = func(vl ...interface{}) {
+ self.Dbg(vl...)
+ }
+ dbgf = func(vl ...interface{}) {
+ self.dbgf(vl...)
+ }
+ return dbg, dbgf // Redundant, but...
+}
+
+func (self Dbgr) dbgf(values ...interface{}) {
+
+ var frmt _frmt
+ if len(values) > 0 {
+ tmp := fmt.Sprint(values[0])
+ frmt = parseFormat(tmp)
+ values = values[1:]
+ }
+
+ buffer_f := bytes.Buffer{}
+ format := frmt.format
+ end := len(format)
+ for at := 0; at < end; {
+ last := at
+ for at < end && format[at] != '%' {
+ at++
+ }
+ if at > last {
+ buffer_f.WriteString(format[last:at])
+ }
+ if at >= end {
+ break
+ }
+ // format[at] == '%'
+ at++
+ // format[at] == ?
+ if format[at] == '@' {
+ depth := 2
+ pc, _, _, _ := runtime.Caller(depth)
+ name := runtime.FuncForPC(pc).Name()
+ buffer_f.WriteString(name)
+ } else {
+ buffer_f.WriteString(format[at-1 : at+1])
+ }
+ at++
+ }
+
+ //values_f := append([]interface{}{}, values[0:frmt.operandCount]...)
+ values_f := values[0:frmt.operandCount]
+ values_dbg := values[frmt.operandCount:]
+ if len(values_dbg) > 0 {
+ // Adjust frmt.format:
+ // (%v instead of %s because: frmt.check)
+ {
+ tmp := format
+ if len(tmp) > 0 {
+ if unicode.IsSpace(rune(tmp[len(tmp)-1])) {
+ buffer_f.WriteString("%v")
+ } else {
+ buffer_f.WriteString(" %v")
+ }
+ } else if frmt.check {
+ // Performing a check, so no output
+ } else {
+ buffer_f.WriteString("%v")
+ }
+ }
+
+ // Adjust values_f:
+ if !frmt.check {
+ tmp := []string{}
+ for _, value := range values_dbg {
+ tmp = append(tmp, fmt.Sprintf("%v", value))
+ }
+ // First, make a copy of values_f, so we avoid overwriting values_dbg when appending
+ values_f = append([]interface{}{}, values_f...)
+ values_f = append(values_f, strings.Join(tmp, " "))
+ }
+ }
+
+ format = buffer_f.String()
+ if frmt.check {
+ // We do not actually emit to the log, but panic if
+ // a non-nil value is detected (e.g. a non-nil error)
+ for _, value := range values_dbg {
+ if value != nil {
+ if format == "" {
+ panic(value)
+ } else {
+ panic(fmt.Sprintf(format, append(values_f, value)...))
+ }
+ }
+ }
+ } else {
+ self.getEmit().emit(frmt, format, values_f...)
+ }
+}
+
+// Idiot-proof &Dbgr{}, etc.
+func (self *Dbgr) getEmit() _emit {
+ if self.emit == nil {
+ self.emit = standardEmit()
+ }
+ return self.emit
+}
+
+// SetOutput will accept the following as a destination for output:
+//
+// *log.Logger Print*/Panic*/Fatal* of the logger
+// io.Writer -
+// nil Reset to the default output (os.Stderr)
+// "log" Print*/Panic*/Fatal* via the "log" package
+//
+func (self *Dbgr) SetOutput(output interface{}) {
+ if output == nil {
+ self.emit = standardEmit()
+ return
+ }
+ switch output := output.(type) {
+ case *log.Logger:
+ self.emit = _emitLogger{
+ logger: output,
+ }
+ return
+ case io.Writer:
+ self.emit = _emitWriter{
+ writer: output,
+ }
+ return
+ case string:
+ if output == "log" {
+ self.emit = _emitLog{}
+ return
+ }
+ }
+ panic(output)
+}
+
+// ======== //
+// = emit = //
+// ======== //
+
+func standardEmit() _emit {
+ return _emitWriter{
+ writer: os.Stderr,
+ }
+}
+
+func ln(tmp string) string {
+ length := len(tmp)
+ if length > 0 && tmp[length-1] != '\n' {
+ return tmp + "\n"
+ }
+ return tmp
+}
+
+type _emit interface {
+ emit(_frmt, string, ...interface{})
+}
+
+type _emitWriter struct {
+ writer io.Writer
+}
+
+func (self _emitWriter) emit(frmt _frmt, format string, values ...interface{}) {
+ if format == "" {
+ fmt.Fprintln(self.writer, values...)
+ } else {
+ if frmt.panic {
+ panic(fmt.Sprintf(format, values...))
+ }
+ fmt.Fprintf(self.writer, ln(format), values...)
+ if frmt.fatal {
+ os.Exit(1)
+ }
+ }
+}
+
+type _emitLogger struct {
+ logger *log.Logger
+}
+
+func (self _emitLogger) emit(frmt _frmt, format string, values ...interface{}) {
+ if format == "" {
+ self.logger.Println(values...)
+ } else {
+ if frmt.panic {
+ self.logger.Panicf(format, values...)
+ } else if frmt.fatal {
+ self.logger.Fatalf(format, values...)
+ } else {
+ self.logger.Printf(format, values...)
+ }
+ }
+}
+
+type _emitLog struct {
+}
+
+func (self _emitLog) emit(frmt _frmt, format string, values ...interface{}) {
+ if format == "" {
+ log.Println(values...)
+ } else {
+ if frmt.panic {
+ log.Panicf(format, values...)
+ } else if frmt.fatal {
+ log.Fatalf(format, values...)
+ } else {
+ log.Printf(format, values...)
+ }
+ }
+}
diff --git a/vendor/github.com/robertkrimen/otto/error.go b/vendor/github.com/robertkrimen/otto/error.go
new file mode 100644
index 0000000..16e96ba
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/error.go
@@ -0,0 +1,257 @@
+package otto
+
+import (
+ "errors"
+ "fmt"
+
+ "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
+}
+
+func (err _error) format() 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)
+}
+
+func (err _error) formatWithStack() string {
+ str := err.format() + "\n"
+ for _, frame := range err.trace {
+ str += " at " + frame.location() + "\n"
+ }
+ return str
+}
+
+type _frame struct {
+ native bool
+ nativeFile string
+ nativeLine int
+ file *file.File
+ offset int
+ callee string
+ fn interface{}
+}
+
+var (
+ nativeFrame = _frame{}
+)
+
+type _at int
+
+func (fr _frame) location() string {
+ str := ""
+
+ switch {
+ case fr.native:
+ str = ""
+ if fr.nativeFile != "" && fr.nativeLine != 0 {
+ str = fmt.Sprintf("%s:%d", fr.nativeFile, fr.nativeLine)
+ }
+ case fr.file != nil:
+ if p := fr.file.Position(file.Idx(fr.offset)); p != nil {
+ path, line, column := p.Filename, p.Line, p.Column
+
+ if path == "" {
+ path = ""
+ }
+
+ str = fmt.Sprintf("%s:%d:%d", path, line, column)
+ }
+ }
+
+ if fr.callee != "" {
+ str = fmt.Sprintf("%s (%s)", fr.callee, str)
+ }
+
+ return str
+}
+
+// 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 {
+ return err.format()
+}
+
+// String returns a description of the error and a trace of where the
+// error occurred.
+//
+// TypeError: 'def' is not a function
+// at xyz (:3:9)
+// at :7:1/
+func (err Error) String() string {
+ return err.formatWithStack()
+}
+
+// GoString returns a description of the error and a trace of where the
+// error occurred. Printing with %#v will trigger this behaviour.
+func (err Error) GoString() string {
+ return err.formatWithStack()
+}
+
+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, stackFramesToPop int, in ...interface{}) _error {
+ err := _error{
+ name: name,
+ offset: -1,
+ }
+ description := ""
+ length := len(in)
+
+ if rt != nil && rt.scope != nil {
+ scope := rt.scope
+
+ for i := 0; i < stackFramesToPop; i++ {
+ if scope.outer != nil {
+ scope = scope.outer
+ }
+ }
+
+ 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--
+ }
+ if length > 0 {
+ description, in = in[0].(string), in[1:]
+ }
+ }
+
+ limit := rt.traceLimit
+
+ err.trace = append(err.trace, frame)
+ if scope != nil {
+ for scope = scope.outer; scope != nil; scope = scope.outer {
+ if limit--; limit == 0 {
+ break
+ }
+
+ if scope.frame.offset >= 0 {
+ err.trace = append(err.trace, scope.frame)
+ }
+ }
+ }
+ } 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", 0, argumentList...),
+ }
+}
+
+func (rt *_runtime) panicReferenceError(argumentList ...interface{}) *_exception {
+ return &_exception{
+ value: newError(rt, "ReferenceError", 0, argumentList...),
+ }
+}
+
+func (rt *_runtime) panicURIError(argumentList ...interface{}) *_exception {
+ return &_exception{
+ value: newError(rt, "URIError", 0, argumentList...),
+ }
+}
+
+func (rt *_runtime) panicSyntaxError(argumentList ...interface{}) *_exception {
+ return &_exception{
+ value: newError(rt, "SyntaxError", 0, argumentList...),
+ }
+}
+
+func (rt *_runtime) panicRangeError(argumentList ...interface{}) *_exception {
+ return &_exception{
+ value: newError(rt, "RangeError", 0, 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 = caught
+ return
+ 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/vendor/github.com/robertkrimen/otto/evaluate.go b/vendor/github.com/robertkrimen/otto/evaluate.go
new file mode 100644
index 0000000..8995273
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/evaluate.go
@@ -0,0 +1,295 @@
+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))
+}
+
+type _lessThanResult int
+
+const (
+ lessThanFalse _lessThanResult = iota
+ lessThanTrue
+ lessThanUndefined
+)
+
+func calculateLessThan(left Value, right Value, leftFirst bool) _lessThanResult {
+ var x, y Value
+ if leftFirst {
+ x = toNumberPrimitive(left)
+ y = toNumberPrimitive(right)
+ } else {
+ y = toNumberPrimitive(right)
+ x = toNumberPrimitive(left)
+ }
+
+ var result bool
+ 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/vendor/github.com/robertkrimen/otto/file/README.markdown b/vendor/github.com/robertkrimen/otto/file/README.markdown
new file mode 100644
index 0000000..79757ba
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/file/README.markdown
@@ -0,0 +1,110 @@
+# file
+--
+ import "github.com/robertkrimen/otto/file"
+
+Package file encapsulates the file abstractions used by the ast & parser.
+
+## Usage
+
+#### type File
+
+```go
+type File struct {
+}
+```
+
+
+#### func NewFile
+
+```go
+func NewFile(filename, src string, base int) *File
+```
+
+#### func (*File) Base
+
+```go
+func (fl *File) Base() int
+```
+
+#### func (*File) Name
+
+```go
+func (fl *File) Name() string
+```
+
+#### func (*File) Source
+
+```go
+func (fl *File) Source() string
+```
+
+#### type FileSet
+
+```go
+type FileSet struct {
+}
+```
+
+A FileSet represents a set of source files.
+
+#### func (*FileSet) AddFile
+
+```go
+func (self *FileSet) AddFile(filename, src string) int
+```
+AddFile adds a new file with the given filename and src.
+
+This an internal method, but exported for cross-package use.
+
+#### func (*FileSet) File
+
+```go
+func (self *FileSet) File(idx Idx) *File
+```
+
+#### func (*FileSet) Position
+
+```go
+func (self *FileSet) Position(idx Idx) *Position
+```
+Position converts an Idx in the FileSet into a Position.
+
+#### type Idx
+
+```go
+type Idx int
+```
+
+Idx is a compact encoding of a source position within a file set. It can be
+converted into a Position for a more convenient, but much larger,
+representation.
+
+#### type Position
+
+```go
+type Position struct {
+ Filename string // The filename where the error occurred, if any
+ Offset int // The src offset
+ Line int // The line number, starting at 1
+ Column int // The column number, starting at 1 (The character count)
+
+}
+```
+
+Position describes an arbitrary source position including the filename, line,
+and column location.
+
+#### func (*Position) String
+
+```go
+func (self *Position) String() string
+```
+String returns a string in one of several forms:
+
+ file:line:column A valid position with filename
+ line:column A valid position without filename
+ file An invalid position with filename
+ - An invalid position without filename
+
+--
+**godocdown** http://github.com/robertkrimen/godocdown
diff --git a/vendor/github.com/robertkrimen/otto/file/file.go b/vendor/github.com/robertkrimen/otto/file/file.go
new file mode 100644
index 0000000..2884e99
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/file/file.go
@@ -0,0 +1,162 @@
+// Package file encapsulates the file abstractions used by the ast & parser.
+package file
+
+import (
+ "fmt"
+ "strings"
+
+ "gopkg.in/sourcemap.v1"
+)
+
+// Idx is a compact encoding of a source position within a file set.
+// It can be converted into a Position for a more convenient, but much
+// larger, representation.
+type Idx int
+
+// Position describes an arbitrary source position
+// including the filename, line, and column location.
+type Position struct {
+ Filename string // The filename where the error occurred, if any
+ Offset int // The src offset
+ Line int // The line number, starting at 1
+ Column int // The column number, starting at 1 (The character count)
+
+}
+
+// A Position is valid if the line number is > 0.
+
+func (self *Position) isValid() bool {
+ return self.Line > 0
+}
+
+// String returns a string in one of several forms:
+//
+// file:line:column A valid position with filename
+// line:column A valid position without filename
+// file An invalid position with filename
+// - An invalid position without filename
+func (self *Position) String() string {
+ str := self.Filename
+ if self.isValid() {
+ if str != "" {
+ str += ":"
+ }
+ str += fmt.Sprintf("%d:%d", self.Line, self.Column)
+ }
+ if str == "" {
+ str = "-"
+ }
+ return str
+}
+
+// FileSet
+
+// A FileSet represents a set of source files.
+type FileSet struct {
+ files []*File
+ last *File
+}
+
+// AddFile adds a new file with the given filename and src.
+//
+// This an internal method, but exported for cross-package use.
+func (self *FileSet) AddFile(filename, src string) int {
+ base := self.nextBase()
+ file := &File{
+ name: filename,
+ src: src,
+ base: base,
+ }
+ self.files = append(self.files, file)
+ self.last = file
+ return base
+}
+
+func (self *FileSet) nextBase() int {
+ if self.last == nil {
+ return 1
+ }
+ return self.last.base + len(self.last.src) + 1
+}
+
+func (self *FileSet) File(idx Idx) *File {
+ for _, file := range self.files {
+ if idx <= Idx(file.base+len(file.src)) {
+ return file
+ }
+ }
+ return nil
+}
+
+// Position converts an Idx in the FileSet into a Position.
+func (self *FileSet) Position(idx Idx) *Position {
+ for _, file := range self.files {
+ if idx <= Idx(file.base+len(file.src)) {
+ return file.Position(idx - Idx(file.base))
+ }
+ }
+
+ return nil
+}
+
+type File struct {
+ name string
+ src string
+ base int // This will always be 1 or greater
+ sm *sourcemap.Consumer
+}
+
+func NewFile(filename, src string, base int) *File {
+ return &File{
+ name: filename,
+ src: src,
+ base: base,
+ }
+}
+
+func (fl *File) WithSourceMap(sm *sourcemap.Consumer) *File {
+ fl.sm = sm
+ return fl
+}
+
+func (fl *File) Name() string {
+ return fl.name
+}
+
+func (fl *File) Source() string {
+ return fl.src
+}
+
+func (fl *File) Base() int {
+ return fl.base
+}
+
+func (fl *File) Position(idx Idx) *Position {
+ position := &Position{}
+
+ offset := int(idx) - fl.base
+
+ if offset >= len(fl.src) || offset < 0 {
+ return nil
+ }
+
+ src := fl.src[:offset]
+
+ position.Filename = fl.name
+ position.Offset = offset
+ position.Line = strings.Count(src, "\n") + 1
+
+ if index := strings.LastIndex(src, "\n"); index >= 0 {
+ position.Column = offset - index
+ } else {
+ position.Column = len(src) + 1
+ }
+
+ if fl.sm != nil {
+ if f, _, l, c, ok := fl.sm.Source(position.Line, position.Column); ok {
+ position.Filename, position.Line, position.Column = f, l, c
+ }
+ }
+
+ return position
+}
diff --git a/vendor/github.com/robertkrimen/otto/global.go b/vendor/github.com/robertkrimen/otto/global.go
new file mode 100644
index 0000000..3159c86
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/global.go
@@ -0,0 +1,218 @@
+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(classObject)
+ 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 == classRegExp {
+ 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, stackFramesToPop int) *_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, stackFramesToPop)
+ self.prototype = runtime.global.ErrorPrototype
+ if name != "" {
+ self.defineProperty("name", toValue_string(name), 0111, false)
+ }
+ return self
+}
+
+func (runtime *_runtime) newNativeFunction(name, file string, line int, _nativeFunction _nativeFunction) *_object {
+ self := runtime.newNativeFunctionObject(name, file, line, _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/vendor/github.com/robertkrimen/otto/inline.go b/vendor/github.com/robertkrimen/otto/inline.go
new file mode 100644
index 0000000..d599b17
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/inline.go
@@ -0,0 +1,6638 @@
+package otto
+
+import (
+ "math"
+)
+
+func _newContext(runtime *_runtime) {
+ {
+ runtime.global.ObjectPrototype = &_object{
+ runtime: runtime,
+ class: classObject,
+ objectClass: _classObject,
+ prototype: nil,
+ extensible: true,
+ value: prototypeValueObject,
+ }
+ }
+ {
+ runtime.global.FunctionPrototype = &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.ObjectPrototype,
+ extensible: true,
+ value: prototypeValueFunction,
+ }
+ }
+ {
+ valueOf_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "valueOf",
+ call: builtinObject_valueOf,
+ },
+ }
+ toString_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "toString",
+ call: builtinObject_toString,
+ },
+ }
+ toLocaleString_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "toLocaleString",
+ call: builtinObject_toLocaleString,
+ },
+ }
+ hasOwnProperty_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "hasOwnProperty",
+ call: builtinObject_hasOwnProperty,
+ },
+ }
+ isPrototypeOf_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "isPrototypeOf",
+ call: builtinObject_isPrototypeOf,
+ },
+ }
+ propertyIsEnumerable_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ 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: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "toString",
+ call: builtinFunction_toString,
+ },
+ }
+ apply_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "apply",
+ call: builtinFunction_apply,
+ },
+ }
+ call_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "call",
+ call: builtinFunction_call,
+ },
+ }
+ bind_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ 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{},
+ },
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ }
+ runtime.global.FunctionPrototype.propertyOrder = []string{
+ "toString",
+ "apply",
+ "call",
+ "bind",
+ "constructor",
+ propertyLength,
+ }
+ }
+ {
+ getPrototypeOf_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "getPrototypeOf",
+ call: builtinObject_getPrototypeOf,
+ },
+ }
+ getOwnPropertyDescriptor_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "getOwnPropertyDescriptor",
+ call: builtinObject_getOwnPropertyDescriptor,
+ },
+ }
+ defineProperty_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 3,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "defineProperty",
+ call: builtinObject_defineProperty,
+ },
+ }
+ defineProperties_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "defineProperties",
+ call: builtinObject_defineProperties,
+ },
+ }
+ create_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "create",
+ call: builtinObject_create,
+ },
+ }
+ isExtensible_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "isExtensible",
+ call: builtinObject_isExtensible,
+ },
+ }
+ preventExtensions_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "preventExtensions",
+ call: builtinObject_preventExtensions,
+ },
+ }
+ isSealed_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "isSealed",
+ call: builtinObject_isSealed,
+ },
+ }
+ seal_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "seal",
+ call: builtinObject_seal,
+ },
+ }
+ isFrozen_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "isFrozen",
+ call: builtinObject_isFrozen,
+ },
+ }
+ freeze_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "freeze",
+ call: builtinObject_freeze,
+ },
+ }
+ keys_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "keys",
+ call: builtinObject_keys,
+ },
+ }
+ getOwnPropertyNames_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "getOwnPropertyNames",
+ call: builtinObject_getOwnPropertyNames,
+ },
+ }
+ runtime.global.Object = &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ value: _nativeFunctionObject{
+ name: classObject,
+ call: builtinObject,
+ construct: builtinNewObject,
+ },
+ property: map[string]_property{
+ propertyLength: _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{
+ propertyLength,
+ "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: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ value: _nativeFunctionObject{
+ name: classFunction,
+ call: builtinFunction,
+ construct: builtinNewFunction,
+ },
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ "prototype": _property{
+ mode: 0,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.FunctionPrototype,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ "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: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "toString",
+ call: builtinArray_toString,
+ },
+ }
+ toLocaleString_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "toLocaleString",
+ call: builtinArray_toLocaleString,
+ },
+ }
+ concat_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "concat",
+ call: builtinArray_concat,
+ },
+ }
+ join_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "join",
+ call: builtinArray_join,
+ },
+ }
+ splice_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "splice",
+ call: builtinArray_splice,
+ },
+ }
+ shift_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "shift",
+ call: builtinArray_shift,
+ },
+ }
+ pop_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "pop",
+ call: builtinArray_pop,
+ },
+ }
+ push_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "push",
+ call: builtinArray_push,
+ },
+ }
+ slice_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "slice",
+ call: builtinArray_slice,
+ },
+ }
+ unshift_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "unshift",
+ call: builtinArray_unshift,
+ },
+ }
+ reverse_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "reverse",
+ call: builtinArray_reverse,
+ },
+ }
+ sort_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "sort",
+ call: builtinArray_sort,
+ },
+ }
+ indexOf_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "indexOf",
+ call: builtinArray_indexOf,
+ },
+ }
+ lastIndexOf_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "lastIndexOf",
+ call: builtinArray_lastIndexOf,
+ },
+ }
+ every_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "every",
+ call: builtinArray_every,
+ },
+ }
+ some_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "some",
+ call: builtinArray_some,
+ },
+ }
+ forEach_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "forEach",
+ call: builtinArray_forEach,
+ },
+ }
+ map_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "map",
+ call: builtinArray_map,
+ },
+ }
+ filter_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "filter",
+ call: builtinArray_filter,
+ },
+ }
+ reduce_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "reduce",
+ call: builtinArray_reduce,
+ },
+ }
+ reduceRight_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "reduceRight",
+ call: builtinArray_reduceRight,
+ },
+ }
+ isArray_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "isArray",
+ call: builtinArray_isArray,
+ },
+ }
+ runtime.global.ArrayPrototype = &_object{
+ runtime: runtime,
+ class: classArray,
+ objectClass: _classArray,
+ prototype: runtime.global.ObjectPrototype,
+ extensible: true,
+ value: nil,
+ property: map[string]_property{
+ propertyLength: _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{
+ propertyLength,
+ "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: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ value: _nativeFunctionObject{
+ name: classArray,
+ call: builtinArray,
+ construct: builtinNewArray,
+ },
+ property: map[string]_property{
+ propertyLength: _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{
+ propertyLength,
+ "prototype",
+ "isArray",
+ },
+ }
+ runtime.global.ArrayPrototype.property["constructor"] =
+ _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.Array,
+ },
+ }
+ }
+ {
+ toString_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "toString",
+ call: builtinString_toString,
+ },
+ }
+ valueOf_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "valueOf",
+ call: builtinString_valueOf,
+ },
+ }
+ charAt_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "charAt",
+ call: builtinString_charAt,
+ },
+ }
+ charCodeAt_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "charCodeAt",
+ call: builtinString_charCodeAt,
+ },
+ }
+ concat_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "concat",
+ call: builtinString_concat,
+ },
+ }
+ indexOf_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "indexOf",
+ call: builtinString_indexOf,
+ },
+ }
+ lastIndexOf_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "lastIndexOf",
+ call: builtinString_lastIndexOf,
+ },
+ }
+ match_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "match",
+ call: builtinString_match,
+ },
+ }
+ replace_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "replace",
+ call: builtinString_replace,
+ },
+ }
+ search_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "search",
+ call: builtinString_search,
+ },
+ }
+ split_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "split",
+ call: builtinString_split,
+ },
+ }
+ slice_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "slice",
+ call: builtinString_slice,
+ },
+ }
+ substring_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "substring",
+ call: builtinString_substring,
+ },
+ }
+ toLowerCase_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "toLowerCase",
+ call: builtinString_toLowerCase,
+ },
+ }
+ toUpperCase_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "toUpperCase",
+ call: builtinString_toUpperCase,
+ },
+ }
+ substr_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "substr",
+ call: builtinString_substr,
+ },
+ }
+ trim_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "trim",
+ call: builtinString_trim,
+ },
+ }
+ trimLeft_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "trimLeft",
+ call: builtinString_trimLeft,
+ },
+ }
+ trimRight_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "trimRight",
+ call: builtinString_trimRight,
+ },
+ }
+ localeCompare_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "localeCompare",
+ call: builtinString_localeCompare,
+ },
+ }
+ toLocaleLowerCase_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "toLocaleLowerCase",
+ call: builtinString_toLocaleLowerCase,
+ },
+ }
+ toLocaleUpperCase_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "toLocaleUpperCase",
+ call: builtinString_toLocaleUpperCase,
+ },
+ }
+ fromCharCode_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "fromCharCode",
+ call: builtinString_fromCharCode,
+ },
+ }
+ runtime.global.StringPrototype = &_object{
+ runtime: runtime,
+ class: classString,
+ objectClass: _classString,
+ prototype: runtime.global.ObjectPrototype,
+ extensible: true,
+ value: prototypeValueString,
+ property: map[string]_property{
+ propertyLength: _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{
+ propertyLength,
+ "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: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ value: _nativeFunctionObject{
+ name: classString,
+ call: builtinString,
+ construct: builtinNewString,
+ },
+ property: map[string]_property{
+ propertyLength: _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{
+ propertyLength,
+ "prototype",
+ "fromCharCode",
+ },
+ }
+ runtime.global.StringPrototype.property["constructor"] =
+ _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.String,
+ },
+ }
+ }
+ {
+ toString_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "toString",
+ call: builtinBoolean_toString,
+ },
+ }
+ valueOf_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "valueOf",
+ call: builtinBoolean_valueOf,
+ },
+ }
+ runtime.global.BooleanPrototype = &_object{
+ runtime: runtime,
+ class: classBoolean,
+ 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: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ value: _nativeFunctionObject{
+ name: classBoolean,
+ call: builtinBoolean,
+ construct: builtinNewBoolean,
+ },
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ "prototype": _property{
+ mode: 0,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.BooleanPrototype,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ "prototype",
+ },
+ }
+ runtime.global.BooleanPrototype.property["constructor"] =
+ _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.Boolean,
+ },
+ }
+ }
+ {
+ toString_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "toString",
+ call: builtinNumber_toString,
+ },
+ }
+ valueOf_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "valueOf",
+ call: builtinNumber_valueOf,
+ },
+ }
+ toFixed_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "toFixed",
+ call: builtinNumber_toFixed,
+ },
+ }
+ toExponential_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "toExponential",
+ call: builtinNumber_toExponential,
+ },
+ }
+ toPrecision_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "toPrecision",
+ call: builtinNumber_toPrecision,
+ },
+ }
+ toLocaleString_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "toLocaleString",
+ call: builtinNumber_toLocaleString,
+ },
+ }
+ isNaN_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "isNaN",
+ call: builtinNumber_isNaN,
+ },
+ }
+ runtime.global.NumberPrototype = &_object{
+ runtime: runtime,
+ class: classNumber,
+ 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: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ value: _nativeFunctionObject{
+ name: classNumber,
+ call: builtinNumber,
+ construct: builtinNewNumber,
+ },
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ "prototype": _property{
+ mode: 0,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.NumberPrototype,
+ },
+ },
+ "isNaN": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: isNaN_function,
+ },
+ },
+ "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{
+ propertyLength,
+ "prototype",
+ "isNaN",
+ "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: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "abs",
+ call: builtinMath_abs,
+ },
+ }
+ acos_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "acos",
+ call: builtinMath_acos,
+ },
+ }
+ asin_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "asin",
+ call: builtinMath_asin,
+ },
+ }
+ atan_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "atan",
+ call: builtinMath_atan,
+ },
+ }
+ atan2_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "atan2",
+ call: builtinMath_atan2,
+ },
+ }
+ ceil_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "ceil",
+ call: builtinMath_ceil,
+ },
+ }
+ cos_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "cos",
+ call: builtinMath_cos,
+ },
+ }
+ exp_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "exp",
+ call: builtinMath_exp,
+ },
+ }
+ floor_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "floor",
+ call: builtinMath_floor,
+ },
+ }
+ log_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "log",
+ call: builtinMath_log,
+ },
+ }
+ max_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "max",
+ call: builtinMath_max,
+ },
+ }
+ min_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "min",
+ call: builtinMath_min,
+ },
+ }
+ pow_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "pow",
+ call: builtinMath_pow,
+ },
+ }
+ random_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "random",
+ call: builtinMath_random,
+ },
+ }
+ round_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "round",
+ call: builtinMath_round,
+ },
+ }
+ sin_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "sin",
+ call: builtinMath_sin,
+ },
+ }
+ sqrt_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "sqrt",
+ call: builtinMath_sqrt,
+ },
+ }
+ tan_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ 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: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "toString",
+ call: builtinDate_toString,
+ },
+ }
+ toDateString_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "toDateString",
+ call: builtinDate_toDateString,
+ },
+ }
+ toTimeString_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "toTimeString",
+ call: builtinDate_toTimeString,
+ },
+ }
+ toUTCString_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "toUTCString",
+ call: builtinDate_toUTCString,
+ },
+ }
+ toISOString_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "toISOString",
+ call: builtinDate_toISOString,
+ },
+ }
+ toJSON_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "toJSON",
+ call: builtinDate_toJSON,
+ },
+ }
+ toGMTString_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "toGMTString",
+ call: builtinDate_toGMTString,
+ },
+ }
+ toLocaleString_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "toLocaleString",
+ call: builtinDate_toLocaleString,
+ },
+ }
+ toLocaleDateString_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "toLocaleDateString",
+ call: builtinDate_toLocaleDateString,
+ },
+ }
+ toLocaleTimeString_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "toLocaleTimeString",
+ call: builtinDate_toLocaleTimeString,
+ },
+ }
+ valueOf_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "valueOf",
+ call: builtinDate_valueOf,
+ },
+ }
+ getTime_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "getTime",
+ call: builtinDate_getTime,
+ },
+ }
+ getYear_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "getYear",
+ call: builtinDate_getYear,
+ },
+ }
+ getFullYear_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "getFullYear",
+ call: builtinDate_getFullYear,
+ },
+ }
+ getUTCFullYear_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "getUTCFullYear",
+ call: builtinDate_getUTCFullYear,
+ },
+ }
+ getMonth_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "getMonth",
+ call: builtinDate_getMonth,
+ },
+ }
+ getUTCMonth_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "getUTCMonth",
+ call: builtinDate_getUTCMonth,
+ },
+ }
+ getDate_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "getDate",
+ call: builtinDate_getDate,
+ },
+ }
+ getUTCDate_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "getUTCDate",
+ call: builtinDate_getUTCDate,
+ },
+ }
+ getDay_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "getDay",
+ call: builtinDate_getDay,
+ },
+ }
+ getUTCDay_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "getUTCDay",
+ call: builtinDate_getUTCDay,
+ },
+ }
+ getHours_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "getHours",
+ call: builtinDate_getHours,
+ },
+ }
+ getUTCHours_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "getUTCHours",
+ call: builtinDate_getUTCHours,
+ },
+ }
+ getMinutes_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "getMinutes",
+ call: builtinDate_getMinutes,
+ },
+ }
+ getUTCMinutes_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "getUTCMinutes",
+ call: builtinDate_getUTCMinutes,
+ },
+ }
+ getSeconds_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "getSeconds",
+ call: builtinDate_getSeconds,
+ },
+ }
+ getUTCSeconds_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "getUTCSeconds",
+ call: builtinDate_getUTCSeconds,
+ },
+ }
+ getMilliseconds_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "getMilliseconds",
+ call: builtinDate_getMilliseconds,
+ },
+ }
+ getUTCMilliseconds_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "getUTCMilliseconds",
+ call: builtinDate_getUTCMilliseconds,
+ },
+ }
+ getTimezoneOffset_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "getTimezoneOffset",
+ call: builtinDate_getTimezoneOffset,
+ },
+ }
+ setTime_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "setTime",
+ call: builtinDate_setTime,
+ },
+ }
+ setMilliseconds_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "setMilliseconds",
+ call: builtinDate_setMilliseconds,
+ },
+ }
+ setUTCMilliseconds_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "setUTCMilliseconds",
+ call: builtinDate_setUTCMilliseconds,
+ },
+ }
+ setSeconds_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "setSeconds",
+ call: builtinDate_setSeconds,
+ },
+ }
+ setUTCSeconds_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "setUTCSeconds",
+ call: builtinDate_setUTCSeconds,
+ },
+ }
+ setMinutes_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 3,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "setMinutes",
+ call: builtinDate_setMinutes,
+ },
+ }
+ setUTCMinutes_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 3,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "setUTCMinutes",
+ call: builtinDate_setUTCMinutes,
+ },
+ }
+ setHours_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 4,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "setHours",
+ call: builtinDate_setHours,
+ },
+ }
+ setUTCHours_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 4,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "setUTCHours",
+ call: builtinDate_setUTCHours,
+ },
+ }
+ setDate_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "setDate",
+ call: builtinDate_setDate,
+ },
+ }
+ setUTCDate_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "setUTCDate",
+ call: builtinDate_setUTCDate,
+ },
+ }
+ setMonth_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "setMonth",
+ call: builtinDate_setMonth,
+ },
+ }
+ setUTCMonth_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "setUTCMonth",
+ call: builtinDate_setUTCMonth,
+ },
+ }
+ setYear_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "setYear",
+ call: builtinDate_setYear,
+ },
+ }
+ setFullYear_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 3,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "setFullYear",
+ call: builtinDate_setFullYear,
+ },
+ }
+ setUTCFullYear_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 3,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "setUTCFullYear",
+ call: builtinDate_setUTCFullYear,
+ },
+ }
+ parse_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "parse",
+ call: builtinDate_parse,
+ },
+ }
+ UTC_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 7,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "UTC",
+ call: builtinDate_UTC,
+ },
+ }
+ now_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "now",
+ call: builtinDate_now,
+ },
+ }
+ runtime.global.DatePrototype = &_object{
+ runtime: runtime,
+ class: classDate,
+ 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: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ value: _nativeFunctionObject{
+ name: classDate,
+ call: builtinDate,
+ construct: builtinNewDate,
+ },
+ property: map[string]_property{
+ propertyLength: _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{
+ propertyLength,
+ "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: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "toString",
+ call: builtinRegExp_toString,
+ },
+ }
+ exec_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "exec",
+ call: builtinRegExp_exec,
+ },
+ }
+ test_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "test",
+ call: builtinRegExp_test,
+ },
+ }
+ compile_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "compile",
+ call: builtinRegExp_compile,
+ },
+ }
+ runtime.global.RegExpPrototype = &_object{
+ runtime: runtime,
+ class: classRegExp,
+ 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: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ value: _nativeFunctionObject{
+ name: classRegExp,
+ call: builtinRegExp,
+ construct: builtinNewRegExp,
+ },
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ "prototype": _property{
+ mode: 0,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.RegExpPrototype,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ "prototype",
+ },
+ }
+ runtime.global.RegExpPrototype.property["constructor"] =
+ _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.RegExp,
+ },
+ }
+ }
+ {
+ toString_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "toString",
+ call: builtinError_toString,
+ },
+ }
+ runtime.global.ErrorPrototype = &_object{
+ runtime: runtime,
+ class: classError,
+ 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: classError,
+ },
+ },
+ "message": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueString,
+ value: "",
+ },
+ },
+ },
+ propertyOrder: []string{
+ "toString",
+ "name",
+ "message",
+ },
+ }
+ runtime.global.Error = &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ value: _nativeFunctionObject{
+ name: classError,
+ call: builtinError,
+ construct: builtinNewError,
+ },
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ "prototype": _property{
+ mode: 0,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.ErrorPrototype,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ "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: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ value: _nativeFunctionObject{
+ name: "EvalError",
+ call: builtinEvalError,
+ construct: builtinNewEvalError,
+ },
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ "prototype": _property{
+ mode: 0,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.EvalErrorPrototype,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ "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: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ value: _nativeFunctionObject{
+ name: "TypeError",
+ call: builtinTypeError,
+ construct: builtinNewTypeError,
+ },
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ "prototype": _property{
+ mode: 0,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.TypeErrorPrototype,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ "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: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ value: _nativeFunctionObject{
+ name: "RangeError",
+ call: builtinRangeError,
+ construct: builtinNewRangeError,
+ },
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ "prototype": _property{
+ mode: 0,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.RangeErrorPrototype,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ "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: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ value: _nativeFunctionObject{
+ name: "ReferenceError",
+ call: builtinReferenceError,
+ construct: builtinNewReferenceError,
+ },
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ "prototype": _property{
+ mode: 0,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.ReferenceErrorPrototype,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ "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: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ value: _nativeFunctionObject{
+ name: "SyntaxError",
+ call: builtinSyntaxError,
+ construct: builtinNewSyntaxError,
+ },
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ "prototype": _property{
+ mode: 0,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.SyntaxErrorPrototype,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ "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: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ value: _nativeFunctionObject{
+ name: "URIError",
+ call: builtinURIError,
+ construct: builtinNewURIError,
+ },
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ "prototype": _property{
+ mode: 0,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.URIErrorPrototype,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ "prototype",
+ },
+ }
+ runtime.global.URIErrorPrototype.property["constructor"] =
+ _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.URIError,
+ },
+ }
+ }
+ {
+ parse_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "parse",
+ call: builtinJSON_parse,
+ },
+ }
+ stringify_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 3,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ 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: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "eval",
+ call: builtinGlobal_eval,
+ },
+ }
+ parseInt_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 2,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "parseInt",
+ call: builtinGlobal_parseInt,
+ },
+ }
+ parseFloat_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "parseFloat",
+ call: builtinGlobal_parseFloat,
+ },
+ }
+ isNaN_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "isNaN",
+ call: builtinGlobal_isNaN,
+ },
+ }
+ isFinite_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "isFinite",
+ call: builtinGlobal_isFinite,
+ },
+ }
+ decodeURI_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "decodeURI",
+ call: builtinGlobal_decodeURI,
+ },
+ }
+ decodeURIComponent_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "decodeURIComponent",
+ call: builtinGlobal_decodeURIComponent,
+ },
+ }
+ encodeURI_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "encodeURI",
+ call: builtinGlobal_encodeURI,
+ },
+ }
+ encodeURIComponent_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "encodeURIComponent",
+ call: builtinGlobal_encodeURIComponent,
+ },
+ }
+ escape_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "escape",
+ call: builtinGlobal_escape,
+ },
+ }
+ unescape_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 1,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ 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,
+ },
+ },
+ classObject: _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.Object,
+ },
+ },
+ classFunction: _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.Function,
+ },
+ },
+ classArray: _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.Array,
+ },
+ },
+ classString: _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.String,
+ },
+ },
+ classBoolean: _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.Boolean,
+ },
+ },
+ classNumber: _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.Number,
+ },
+ },
+ "Math": _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.Math,
+ },
+ },
+ classDate: _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.Date,
+ },
+ },
+ classRegExp: _property{
+ mode: 0101,
+ value: Value{
+ kind: valueObject,
+ value: runtime.global.RegExp,
+ },
+ },
+ classError: _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",
+ classObject,
+ classFunction,
+ classArray,
+ classString,
+ classBoolean,
+ classNumber,
+ "Math",
+ classDate,
+ classRegExp,
+ classError,
+ "EvalError",
+ "TypeError",
+ "RangeError",
+ "ReferenceError",
+ "SyntaxError",
+ "URIError",
+ "JSON",
+ "undefined",
+ "NaN",
+ "Infinity",
+ }
+ }
+}
+
+func newConsoleObject(runtime *_runtime) *_object {
+ {
+ log_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "log",
+ call: builtinConsole_log,
+ },
+ }
+ debug_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "debug",
+ call: builtinConsole_log,
+ },
+ }
+ info_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "info",
+ call: builtinConsole_log,
+ },
+ }
+ error_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "error",
+ call: builtinConsole_error,
+ },
+ }
+ warn_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "warn",
+ call: builtinConsole_error,
+ },
+ }
+ dir_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "dir",
+ call: builtinConsole_dir,
+ },
+ }
+ time_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "time",
+ call: builtinConsole_time,
+ },
+ }
+ timeEnd_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "timeEnd",
+ call: builtinConsole_timeEnd,
+ },
+ }
+ trace_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "trace",
+ call: builtinConsole_trace,
+ },
+ }
+ assert_function := &_object{
+ runtime: runtime,
+ class: classFunction,
+ objectClass: _classObject,
+ prototype: runtime.global.FunctionPrototype,
+ extensible: true,
+ property: map[string]_property{
+ propertyLength: _property{
+ mode: 0,
+ value: Value{
+ kind: valueNumber,
+ value: 0,
+ },
+ },
+ },
+ propertyOrder: []string{
+ propertyLength,
+ },
+ value: _nativeFunctionObject{
+ name: "assert",
+ call: builtinConsole_assert,
+ },
+ }
+ return &_object{
+ runtime: runtime,
+ class: classObject,
+ 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_int32(value int32) Value {
+ return Value{
+ kind: valueNumber,
+ value: value,
+ }
+}
+
+func toValue_int64(value int64) 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_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/vendor/github.com/robertkrimen/otto/inline.pl b/vendor/github.com/robertkrimen/otto/inline.pl
new file mode 100644
index 0000000..e21444d
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/inline.pl
@@ -0,0 +1,1087 @@
+#!/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,
+ "isNaN", 1,
+ ),
+ $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/vendor/github.com/robertkrimen/otto/locale.go b/vendor/github.com/robertkrimen/otto/locale.go
new file mode 100644
index 0000000..e16aa5d
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/locale.go
@@ -0,0 +1,7 @@
+package otto
+
+import "golang.org/x/text/language"
+
+var (
+ defaultLanguage = language.MustParse("en-US")
+)
diff --git a/vendor/github.com/robertkrimen/otto/object.go b/vendor/github.com/robertkrimen/otto/object.go
new file mode 100644
index 0000000..854cf52
--- /dev/null
+++ b/vendor/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 == classDate {
+ // 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/vendor/github.com/robertkrimen/otto/object_class.go b/vendor/github.com/robertkrimen/otto/object_class.go
new file mode 100644
index 0000000..8b90ece
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/object_class.go
@@ -0,0 +1,492 @@
+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/vendor/github.com/robertkrimen/otto/otto.go b/vendor/github.com/robertkrimen/otto/otto.go
new file mode 100644
index 0000000..567ac1b
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/otto.go
@@ -0,0 +1,790 @@
+/*
+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.
+ - Otto targets ES5. ES6 features (eg: Typed Arrays) are not supported.
+
+# 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 (
+ "encoding/json"
+ "fmt"
+ "strings"
+
+ "github.com/robertkrimen/otto/file"
+ "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.runtime.traceLimit = 10
+ 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, nil)
+ if !value.safe() {
+ value = Value{}
+ }
+ return value, err
+}
+
+// Eval will do the same thing as Run, except without leaving the current scope.
+//
+// By staying in the same scope, the code evaluated has access to everything
+// already defined in the current stack frame. This is most useful in, for
+// example, a debugger call.
+func (self Otto) Eval(src interface{}) (Value, error) {
+ if self.runtime.scope == nil {
+ self.runtime.enterGlobalScope()
+ defer self.runtime.leaveScope()
+ }
+
+ value, err := self.runtime.cmpl_eval(src, nil)
+ 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)
+}
+
+func (self Otto) SetDebuggerHandler(fn func(vm *Otto)) {
+ self.runtime.debugger = fn
+}
+
+func (self Otto) SetRandomSource(fn func() float64) {
+ self.runtime.random = fn
+}
+
+// SetStackDepthLimit sets an upper limit to the depth of the JavaScript
+// stack. In simpler terms, this limits the number of "nested" function calls
+// you can make in a particular interpreter instance.
+//
+// Note that this doesn't take into account the Go stack depth. If your
+// JavaScript makes a call to a Go function, otto won't keep track of what
+// happens outside the interpreter. So if your Go function is infinitely
+// recursive, you're still in trouble.
+func (self Otto) SetStackDepthLimit(limit int) {
+ self.runtime.stackLimit = limit
+}
+
+// SetStackTraceLimit sets an upper limit to the number of stack frames that
+// otto will use when formatting an error's stack trace. By default, the limit
+// is 10. This is consistent with V8 and SpiderMonkey.
+//
+// TODO: expose via `Error.stackTraceLimit`
+func (self Otto) SetStackTraceLimit(limit int) {
+ self.runtime.traceLimit = limit
+}
+
+// MakeCustomError creates a new Error object with the given name and message,
+// returning it as a Value.
+func (self Otto) MakeCustomError(name, message string) Value {
+ return self.runtime.toValue(self.runtime.newError(name, self.runtime.toValue(message), 0))
+}
+
+// MakeRangeError creates a new RangeError object with the given message,
+// returning it as a Value.
+func (self Otto) MakeRangeError(message string) Value {
+ return self.runtime.toValue(self.runtime.newRangeError(self.runtime.toValue(message)))
+}
+
+// MakeSyntaxError creates a new SyntaxError object with the given message,
+// returning it as a Value.
+func (self Otto) MakeSyntaxError(message string) Value {
+ return self.runtime.toValue(self.runtime.newSyntaxError(self.runtime.toValue(message)))
+}
+
+// MakeTypeError creates a new TypeError object with the given message,
+// returning it as a Value.
+func (self Otto) MakeTypeError(message string) Value {
+ return self.runtime.toValue(self.runtime.newTypeError(self.runtime.toValue(message)))
+}
+
+// Context is a structure that contains information about the current execution
+// context.
+type Context struct {
+ Filename string
+ Line int
+ Column int
+ Callee string
+ Symbols map[string]Value
+ This Value
+ Stacktrace []string
+}
+
+// Context returns the current execution context of the vm, traversing up to
+// ten stack frames, and skipping any innermost native function stack frames.
+func (self Otto) Context() Context {
+ return self.ContextSkip(10, true)
+}
+
+// ContextLimit returns the current execution context of the vm, with a
+// specific limit on the number of stack frames to traverse, skipping any
+// innermost native function stack frames.
+func (self Otto) ContextLimit(limit int) Context {
+ return self.ContextSkip(limit, true)
+}
+
+// ContextSkip returns the current execution context of the vm, with a
+// specific limit on the number of stack frames to traverse, optionally
+// skipping any innermost native function stack frames.
+func (self Otto) ContextSkip(limit int, skipNative bool) (ctx Context) {
+ // Ensure we are operating in a scope
+ if self.runtime.scope == nil {
+ self.runtime.enterGlobalScope()
+ defer self.runtime.leaveScope()
+ }
+
+ scope := self.runtime.scope
+ frame := scope.frame
+
+ for skipNative && frame.native && scope.outer != nil {
+ scope = scope.outer
+ frame = scope.frame
+ }
+
+ // Get location information
+ ctx.Filename = ""
+ ctx.Callee = frame.callee
+
+ switch {
+ case frame.native:
+ ctx.Filename = frame.nativeFile
+ ctx.Line = frame.nativeLine
+ ctx.Column = 0
+ case frame.file != nil:
+ ctx.Filename = ""
+
+ if p := frame.file.Position(file.Idx(frame.offset)); p != nil {
+ ctx.Line = p.Line
+ ctx.Column = p.Column
+
+ if p.Filename != "" {
+ ctx.Filename = p.Filename
+ }
+ }
+ }
+
+ // Get the current scope this Value
+ ctx.This = toValue_object(scope.this)
+
+ // Build stacktrace (up to 10 levels deep)
+ ctx.Symbols = make(map[string]Value)
+ ctx.Stacktrace = append(ctx.Stacktrace, frame.location())
+ for limit != 0 {
+ // Get variables
+ stash := scope.lexical
+ for {
+ for _, name := range getStashProperties(stash) {
+ if _, ok := ctx.Symbols[name]; !ok {
+ ctx.Symbols[name] = stash.getBinding(name, true)
+ }
+ }
+ stash = stash.outer()
+ if stash == nil || stash.outer() == nil {
+ break
+ }
+ }
+
+ scope = scope.outer
+ if scope == nil {
+ break
+ }
+ if scope.frame.offset >= 0 {
+ ctx.Stacktrace = append(ctx.Stacktrace, scope.frame.location())
+ }
+ limit--
+ }
+
+ return
+}
+
+// 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+"()", nil)
+ 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, nil)
+ 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
+ }
+}
+
+// Keys gets the keys for the given 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
+}
+
+// KeysByParent gets the keys (and those of the parents) for the given object,
+// in order of "closest" to "furthest".
+func (self Object) KeysByParent() [][]string {
+ var a [][]string
+
+ for o := self.object; o != nil; o = o.prototype {
+ var l []string
+
+ o.enumerate(false, func(name string) bool {
+ l = append(l, name)
+ return true
+ })
+
+ a = append(a, l)
+ }
+
+ return a
+}
+
+// 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
+}
+
+func (self Object) MarshalJSON() ([]byte, error) {
+ var goValue interface{}
+ switch value := self.object.value.(type) {
+ case *_goStructObject:
+ goValue = value.value.Interface()
+ case *_goMapObject:
+ goValue = value.value.Interface()
+ case *_goArrayObject:
+ goValue = value.value.Interface()
+ case *_goSliceObject:
+ goValue = value.value.Interface()
+ default:
+ // It's a JS object; pass it to JSON.stringify:
+ var result []byte
+ err := catchPanic(func() {
+ resultVal := builtinJSON_stringify(FunctionCall{
+ runtime: self.object.runtime,
+ ArgumentList: []Value{self.value},
+ })
+ result = []byte(resultVal.String())
+ })
+ return result, err
+ }
+ return json.Marshal(goValue)
+}
diff --git a/vendor/github.com/robertkrimen/otto/otto_.go b/vendor/github.com/robertkrimen/otto/otto_.go
new file mode 100644
index 0000000..f4f9193
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/otto_.go
@@ -0,0 +1,152 @@
+package otto
+
+import (
+ "fmt"
+ "regexp"
+ runtime_ "runtime"
+ "strconv"
+)
+
+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{self.toValue(arguments[0])}
+ }
+
+ valueArray := make([]Value, length)
+ for index, value := range arguments {
+ valueArray[index] = self.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 hereBeDragons(arguments ...interface{}) string {
+ pc, _, _, _ := runtime_.Caller(1) //nolint: dogsled
+ 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
+}
diff --git a/vendor/github.com/robertkrimen/otto/parser/Makefile b/vendor/github.com/robertkrimen/otto/parser/Makefile
new file mode 100644
index 0000000..766fd4d
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/parser/Makefile
@@ -0,0 +1,4 @@
+.PHONY: test
+
+test:
+ go test
diff --git a/vendor/github.com/robertkrimen/otto/parser/README.markdown b/vendor/github.com/robertkrimen/otto/parser/README.markdown
new file mode 100644
index 0000000..c3cae5b
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/parser/README.markdown
@@ -0,0 +1,190 @@
+# parser
+--
+ import "github.com/robertkrimen/otto/parser"
+
+Package parser implements a parser for JavaScript.
+
+ import (
+ "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)
+
+
+### Warning
+
+The parser and AST interfaces are still works-in-progress (particularly where
+node types are concerned) and may change in the future.
+
+## Usage
+
+#### func ParseFile
+
+```go
+func ParseFile(fileSet *file.FileSet, filename string, src interface{}, mode Mode) (*ast.Program, error)
+```
+ParseFile parses the source code of a single JavaScript/ECMAScript source file
+and returns the corresponding ast.Program node.
+
+If fileSet == nil, ParseFile parses source without a FileSet. If fileSet != nil,
+ParseFile first adds filename and src to fileSet.
+
+The filename argument is optional and is used for labelling errors, etc.
+
+src may be a string, a byte slice, a bytes.Buffer, or an io.Reader, but it MUST
+always be in UTF-8.
+
+ // Parse some JavaScript, yielding a *ast.Program and/or an ErrorList
+ program, err := parser.ParseFile(nil, "", `if (abc > 1) {}`, 0)
+
+#### func ParseFunction
+
+```go
+func ParseFunction(parameterList, body string) (*ast.FunctionLiteral, error)
+```
+ParseFunction parses a given parameter list and body as a function and returns
+the corresponding ast.FunctionLiteral node.
+
+The parameter list, if any, should be a comma-separated list of identifiers.
+
+#### func ReadSource
+
+```go
+func ReadSource(filename string, src interface{}) ([]byte, error)
+```
+
+#### func TransformRegExp
+
+```go
+func TransformRegExp(pattern string) (string, error)
+```
+TransformRegExp transforms a JavaScript pattern into a Go "regexp" pattern.
+
+re2 (Go) cannot do backtracking, so the presence of a lookahead (?=) (?!) or
+backreference (\1, \2, ...) will cause an error.
+
+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.
+
+If the pattern is invalid (not valid even in JavaScript), then this function
+returns the empty string and an error.
+
+If the pattern is valid, but incompatible (contains a lookahead or
+backreference), then this function returns the transformation (a non-empty
+string) AND an error.
+
+#### type Error
+
+```go
+type Error struct {
+ Position file.Position
+ Message string
+}
+```
+
+An Error represents a parsing error. It includes the position where the error
+occurred and a message/description.
+
+#### func (Error) Error
+
+```go
+func (self Error) Error() string
+```
+
+#### type ErrorList
+
+```go
+type ErrorList []*Error
+```
+
+ErrorList is a list of *Errors.
+
+#### func (*ErrorList) Add
+
+```go
+func (self *ErrorList) Add(position file.Position, msg string)
+```
+Add adds an Error with given position and message to an ErrorList.
+
+#### func (ErrorList) Err
+
+```go
+func (self ErrorList) Err() error
+```
+Err returns an error equivalent to this ErrorList. If the list is empty, Err
+returns nil.
+
+#### func (ErrorList) Error
+
+```go
+func (self ErrorList) Error() string
+```
+Error implements the Error interface.
+
+#### func (ErrorList) Len
+
+```go
+func (self ErrorList) Len() int
+```
+
+#### func (ErrorList) Less
+
+```go
+func (self ErrorList) Less(i, j int) bool
+```
+
+#### func (*ErrorList) Reset
+
+```go
+func (self *ErrorList) Reset()
+```
+Reset resets an ErrorList to no errors.
+
+#### func (ErrorList) Sort
+
+```go
+func (self ErrorList) Sort()
+```
+
+#### func (ErrorList) Swap
+
+```go
+func (self ErrorList) Swap(i, j int)
+```
+
+#### type Mode
+
+```go
+type Mode uint
+```
+
+A Mode value is a set of flags (or 0). They control optional parser
+functionality.
+
+```go
+const (
+ IgnoreRegExpErrors Mode = 1 << iota // Ignore RegExp compatibility errors (allow backtracking)
+)
+```
+
+--
+**godocdown** http://github.com/robertkrimen/godocdown
diff --git a/vendor/github.com/robertkrimen/otto/parser/error.go b/vendor/github.com/robertkrimen/otto/parser/error.go
new file mode 100644
index 0000000..3fb5838
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/parser/error.go
@@ -0,0 +1,173 @@
+package parser
+
+import (
+ "fmt"
+ "sort"
+
+ "github.com/robertkrimen/otto/file"
+ "github.com/robertkrimen/otto/token"
+)
+
+const (
+ err_UnexpectedToken = "Unexpected token %v"
+ err_UnexpectedEndOfInput = "Unexpected end of input"
+)
+
+// UnexpectedNumber: 'Unexpected number',
+// UnexpectedString: 'Unexpected string',
+// UnexpectedIdentifier: 'Unexpected identifier',
+// UnexpectedReserved: 'Unexpected reserved word',
+// NewlineAfterThrow: 'Illegal newline after throw',
+// InvalidRegExp: 'Invalid regular expression',
+// UnterminatedRegExp: 'Invalid regular expression: missing /',
+// InvalidLHSInAssignment: 'Invalid left-hand side in assignment',
+// InvalidLHSInForIn: 'Invalid left-hand side in for-in',
+// MultipleDefaultsInSwitch: 'More than one default clause in switch statement',
+// NoCatchOrFinally: 'Missing catch or finally after try',
+// UnknownLabel: 'Undefined label \'%0\'',
+// Redeclaration: '%0 \'%1\' has already been declared',
+// IllegalContinue: 'Illegal continue statement',
+// IllegalBreak: 'Illegal break statement',
+// IllegalReturn: 'Illegal return statement',
+// StrictModeWith: 'Strict mode code may not include a with statement',
+// StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode',
+// StrictVarName: 'Variable name may not be eval or arguments in strict mode',
+// StrictParamName: 'Parameter name eval or arguments is not allowed in strict mode',
+// StrictParamDupe: 'Strict mode function may not have duplicate parameter names',
+// StrictFunctionName: 'Function name may not be eval or arguments in strict mode',
+// StrictOctalLiteral: 'Octal literals are not allowed in strict mode.',
+// StrictDelete: 'Delete of an unqualified identifier in strict mode.',
+// StrictDuplicateProperty: 'Duplicate data property in object literal not allowed in strict mode',
+// AccessorDataProperty: 'Object literal may not have data and accessor property with the same name',
+// AccessorGetSet: 'Object literal may not have multiple get/set accessors with the same name',
+// StrictLHSAssignment: 'Assignment to eval or arguments is not allowed in strict mode',
+// StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode',
+// StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode',
+// StrictReservedWord: 'Use of future reserved word in strict mode'
+
+// A SyntaxError is a description of an ECMAScript syntax error.
+
+// An Error represents a parsing error. It includes the position where the error occurred and a message/description.
+type Error struct {
+ Position file.Position
+ Message string
+}
+
+// FIXME Should this be "SyntaxError"?
+
+func (self Error) Error() string {
+ filename := self.Position.Filename
+ if filename == "" {
+ filename = "(anonymous)"
+ }
+ return fmt.Sprintf("%s: Line %d:%d %s",
+ filename,
+ self.Position.Line,
+ self.Position.Column,
+ self.Message,
+ )
+}
+
+func (self *_parser) error(place interface{}, msg string, msgValues ...interface{}) *Error {
+ var idx file.Idx
+ switch place := place.(type) {
+ case int:
+ idx = self.idxOf(place)
+ case file.Idx:
+ if place == 0 {
+ idx = self.idxOf(self.chrOffset)
+ } else {
+ idx = place
+ }
+ default:
+ panic(fmt.Errorf("error(%T, ...)", place))
+ }
+
+ position := self.position(idx)
+ msg = fmt.Sprintf(msg, msgValues...)
+ self.errors.Add(position, msg)
+ return self.errors[len(self.errors)-1]
+}
+
+func (self *_parser) errorUnexpected(idx file.Idx, chr rune) error {
+ if chr == -1 {
+ return self.error(idx, err_UnexpectedEndOfInput)
+ }
+ return self.error(idx, err_UnexpectedToken, token.ILLEGAL)
+}
+
+func (self *_parser) errorUnexpectedToken(tkn token.Token) error {
+ switch tkn {
+ case token.EOF:
+ return self.error(file.Idx(0), err_UnexpectedEndOfInput)
+ }
+ value := tkn.String()
+ switch tkn {
+ case token.BOOLEAN, token.NULL:
+ value = self.literal
+ case token.IDENTIFIER:
+ return self.error(self.idx, "Unexpected identifier")
+ case token.KEYWORD:
+ // TODO Might be a future reserved word
+ return self.error(self.idx, "Unexpected reserved word")
+ case token.NUMBER:
+ return self.error(self.idx, "Unexpected number")
+ case token.STRING:
+ return self.error(self.idx, "Unexpected string")
+ }
+ return self.error(self.idx, err_UnexpectedToken, value)
+}
+
+// ErrorList is a list of *Errors.
+type ErrorList []*Error //nolint: errname
+
+// Add adds an Error with given position and message to an ErrorList.
+func (self *ErrorList) Add(position file.Position, msg string) {
+ *self = append(*self, &Error{position, msg})
+}
+
+// Reset resets an ErrorList to no errors.
+func (self *ErrorList) Reset() { *self = (*self)[0:0] }
+
+func (self ErrorList) Len() int { return len(self) }
+func (self ErrorList) Swap(i, j int) { self[i], self[j] = self[j], self[i] }
+func (self ErrorList) Less(i, j int) bool {
+ x := &self[i].Position
+ y := &self[j].Position
+ if x.Filename < y.Filename {
+ return true
+ }
+ if x.Filename == y.Filename {
+ if x.Line < y.Line {
+ return true
+ }
+ if x.Line == y.Line {
+ return x.Column < y.Column
+ }
+ }
+ return false
+}
+
+func (self ErrorList) Sort() {
+ sort.Sort(self)
+}
+
+// Error implements the Error interface.
+func (self ErrorList) Error() string {
+ switch len(self) {
+ case 0:
+ return "no errors"
+ case 1:
+ return self[0].Error()
+ }
+ return fmt.Sprintf("%s (and %d more errors)", self[0].Error(), len(self)-1)
+}
+
+// Err returns an error equivalent to this ErrorList.
+// If the list is empty, Err returns nil.
+func (self ErrorList) Err() error {
+ if len(self) == 0 {
+ return nil
+ }
+ return self
+}
diff --git a/vendor/github.com/robertkrimen/otto/parser/expression.go b/vendor/github.com/robertkrimen/otto/parser/expression.go
new file mode 100644
index 0000000..bbfd498
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/parser/expression.go
@@ -0,0 +1,998 @@
+package parser
+
+import (
+ "regexp"
+
+ "github.com/robertkrimen/otto/ast"
+ "github.com/robertkrimen/otto/file"
+ "github.com/robertkrimen/otto/token"
+)
+
+func (self *_parser) parseIdentifier() *ast.Identifier {
+ literal := self.literal
+ idx := self.idx
+ if self.mode&StoreComments != 0 {
+ self.comments.MarkComments(ast.LEADING)
+ }
+ self.next()
+ exp := &ast.Identifier{
+ Name: literal,
+ Idx: idx,
+ }
+
+ if self.mode&StoreComments != 0 {
+ self.comments.SetExpression(exp)
+ }
+
+ return exp
+}
+
+func (self *_parser) parsePrimaryExpression() ast.Expression {
+ literal := self.literal
+ idx := self.idx
+ switch self.token {
+ case token.IDENTIFIER:
+ self.next()
+ if len(literal) > 1 {
+ tkn, strict := token.IsKeyword(literal)
+ if tkn == token.KEYWORD {
+ if !strict {
+ self.error(idx, "Unexpected reserved word")
+ }
+ }
+ }
+ return &ast.Identifier{
+ Name: literal,
+ Idx: idx,
+ }
+ case token.NULL:
+ self.next()
+ return &ast.NullLiteral{
+ Idx: idx,
+ Literal: literal,
+ }
+ case token.BOOLEAN:
+ self.next()
+ value := false
+ switch literal {
+ case "true":
+ value = true
+ case "false":
+ value = false
+ default:
+ self.error(idx, "Illegal boolean literal")
+ }
+ return &ast.BooleanLiteral{
+ Idx: idx,
+ Literal: literal,
+ Value: value,
+ }
+ case token.STRING:
+ self.next()
+ value, err := parseStringLiteral(literal[1 : len(literal)-1])
+ if err != nil {
+ self.error(idx, err.Error())
+ }
+ return &ast.StringLiteral{
+ Idx: idx,
+ Literal: literal,
+ Value: value,
+ }
+ case token.NUMBER:
+ self.next()
+ value, err := parseNumberLiteral(literal)
+ if err != nil {
+ self.error(idx, err.Error())
+ value = 0
+ }
+ return &ast.NumberLiteral{
+ Idx: idx,
+ Literal: literal,
+ Value: value,
+ }
+ case token.SLASH, token.QUOTIENT_ASSIGN:
+ return self.parseRegExpLiteral()
+ case token.LEFT_BRACE:
+ return self.parseObjectLiteral()
+ case token.LEFT_BRACKET:
+ return self.parseArrayLiteral()
+ case token.LEFT_PARENTHESIS:
+ self.expect(token.LEFT_PARENTHESIS)
+ expression := self.parseExpression()
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ self.expect(token.RIGHT_PARENTHESIS)
+ return expression
+ case token.THIS:
+ self.next()
+ return &ast.ThisExpression{
+ Idx: idx,
+ }
+ case token.FUNCTION:
+ return self.parseFunction(false)
+ }
+
+ self.errorUnexpectedToken(self.token)
+ self.nextStatement()
+ return &ast.BadExpression{From: idx, To: self.idx}
+}
+
+func (self *_parser) parseRegExpLiteral() *ast.RegExpLiteral {
+ offset := self.chrOffset - 1 // Opening slash already gotten
+ if self.token == token.QUOTIENT_ASSIGN {
+ offset -= 1 // =
+ }
+ idx := self.idxOf(offset)
+
+ pattern, err := self.scanString(offset)
+ endOffset := self.chrOffset
+
+ self.next()
+ if err == nil {
+ pattern = pattern[1 : len(pattern)-1]
+ }
+
+ flags := ""
+ if self.token == token.IDENTIFIER { // gim
+ flags = self.literal
+ self.next()
+ endOffset = self.chrOffset - 1
+ }
+
+ var value string
+ // TODO 15.10
+ {
+ // Test during parsing that this is a valid regular expression
+ // Sorry, (?=) and (?!) are invalid (for now)
+ pattern, err := TransformRegExp(pattern)
+ if err != nil {
+ if pattern == "" || self.mode&IgnoreRegExpErrors == 0 {
+ self.error(idx, "Invalid regular expression: %s", err.Error())
+ }
+ } else {
+ _, err = regexp.Compile(pattern)
+ if err != nil {
+ // We should not get here, ParseRegExp should catch any errors
+ self.error(idx, "Invalid regular expression: %s", err.Error()[22:]) // Skip redundant "parse regexp error"
+ } else {
+ value = pattern
+ }
+ }
+ }
+
+ literal := self.str[offset:endOffset]
+
+ return &ast.RegExpLiteral{
+ Idx: idx,
+ Literal: literal,
+ Pattern: pattern,
+ Flags: flags,
+ Value: value,
+ }
+}
+
+func (self *_parser) parseVariableDeclaration(declarationList *[]*ast.VariableExpression) ast.Expression {
+ if self.token != token.IDENTIFIER {
+ idx := self.expect(token.IDENTIFIER)
+ self.nextStatement()
+ return &ast.BadExpression{From: idx, To: self.idx}
+ }
+
+ literal := self.literal
+ idx := self.idx
+ self.next()
+ node := &ast.VariableExpression{
+ Name: literal,
+ Idx: idx,
+ }
+ if self.mode&StoreComments != 0 {
+ self.comments.SetExpression(node)
+ }
+
+ if declarationList != nil {
+ *declarationList = append(*declarationList, node)
+ }
+
+ if self.token == token.ASSIGN {
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ self.next()
+ node.Initializer = self.parseAssignmentExpression()
+ }
+
+ return node
+}
+
+func (self *_parser) parseVariableDeclarationList(var_ file.Idx) []ast.Expression {
+ var declarationList []*ast.VariableExpression // Avoid bad expressions
+ var list []ast.Expression
+
+ for {
+ if self.mode&StoreComments != 0 {
+ self.comments.MarkComments(ast.LEADING)
+ }
+ decl := self.parseVariableDeclaration(&declarationList)
+ list = append(list, decl)
+ if self.token != token.COMMA {
+ break
+ }
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ self.next()
+ }
+
+ self.scope.declare(&ast.VariableDeclaration{
+ Var: var_,
+ List: declarationList,
+ })
+
+ return list
+}
+
+func (self *_parser) parseObjectPropertyKey() (string, string) {
+ idx, tkn, literal := self.idx, self.token, self.literal
+ value := ""
+ if self.mode&StoreComments != 0 {
+ self.comments.MarkComments(ast.KEY)
+ }
+ self.next()
+
+ switch tkn {
+ case token.IDENTIFIER:
+ value = literal
+ case token.NUMBER:
+ var err error
+ _, err = parseNumberLiteral(literal)
+ if err != nil {
+ self.error(idx, err.Error())
+ } else {
+ value = literal
+ }
+ case token.STRING:
+ var err error
+ value, err = parseStringLiteral(literal[1 : len(literal)-1])
+ if err != nil {
+ self.error(idx, err.Error())
+ }
+ default:
+ // null, false, class, etc.
+ if matchIdentifier.MatchString(literal) {
+ value = literal
+ }
+ }
+ return literal, value
+}
+
+func (self *_parser) parseObjectProperty() ast.Property {
+ literal, value := self.parseObjectPropertyKey()
+ if literal == "get" && self.token != token.COLON {
+ idx := self.idx
+ _, value := self.parseObjectPropertyKey()
+ parameterList := self.parseFunctionParameterList()
+
+ node := &ast.FunctionLiteral{
+ Function: idx,
+ ParameterList: parameterList,
+ }
+ self.parseFunctionBlock(node)
+ return ast.Property{
+ Key: value,
+ Kind: "get",
+ Value: node,
+ }
+ } else if literal == "set" && self.token != token.COLON {
+ idx := self.idx
+ _, value := self.parseObjectPropertyKey()
+ parameterList := self.parseFunctionParameterList()
+
+ node := &ast.FunctionLiteral{
+ Function: idx,
+ ParameterList: parameterList,
+ }
+ self.parseFunctionBlock(node)
+ return ast.Property{
+ Key: value,
+ Kind: "set",
+ Value: node,
+ }
+ }
+
+ if self.mode&StoreComments != 0 {
+ self.comments.MarkComments(ast.COLON)
+ }
+ self.expect(token.COLON)
+
+ exp := ast.Property{
+ Key: value,
+ Kind: "value",
+ Value: self.parseAssignmentExpression(),
+ }
+
+ if self.mode&StoreComments != 0 {
+ self.comments.SetExpression(exp.Value)
+ }
+ return exp
+}
+
+func (self *_parser) parseObjectLiteral() ast.Expression {
+ var value []ast.Property
+ idx0 := self.expect(token.LEFT_BRACE)
+ for self.token != token.RIGHT_BRACE && self.token != token.EOF {
+ value = append(value, self.parseObjectProperty())
+ if self.token == token.COMMA {
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ self.next()
+ continue
+ }
+ }
+ if self.mode&StoreComments != 0 {
+ self.comments.MarkComments(ast.FINAL)
+ }
+ idx1 := self.expect(token.RIGHT_BRACE)
+
+ return &ast.ObjectLiteral{
+ LeftBrace: idx0,
+ RightBrace: idx1,
+ Value: value,
+ }
+}
+
+func (self *_parser) parseArrayLiteral() ast.Expression {
+ idx0 := self.expect(token.LEFT_BRACKET)
+ var value []ast.Expression
+ for self.token != token.RIGHT_BRACKET && self.token != token.EOF {
+ if self.token == token.COMMA {
+ // This kind of comment requires a special empty expression node.
+ empty := &ast.EmptyExpression{Begin: self.idx, End: self.idx}
+
+ if self.mode&StoreComments != 0 {
+ self.comments.SetExpression(empty)
+ self.comments.Unset()
+ }
+ value = append(value, empty)
+ self.next()
+ continue
+ }
+
+ exp := self.parseAssignmentExpression()
+
+ value = append(value, exp)
+ if self.token != token.RIGHT_BRACKET {
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ self.expect(token.COMMA)
+ }
+ }
+ if self.mode&StoreComments != 0 {
+ self.comments.MarkComments(ast.FINAL)
+ }
+ idx1 := self.expect(token.RIGHT_BRACKET)
+
+ return &ast.ArrayLiteral{
+ LeftBracket: idx0,
+ RightBracket: idx1,
+ Value: value,
+ }
+}
+
+func (self *_parser) parseArgumentList() (argumentList []ast.Expression, idx0, idx1 file.Idx) {
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ idx0 = self.expect(token.LEFT_PARENTHESIS)
+ if self.token != token.RIGHT_PARENTHESIS {
+ for {
+ exp := self.parseAssignmentExpression()
+ if self.mode&StoreComments != 0 {
+ self.comments.SetExpression(exp)
+ }
+ argumentList = append(argumentList, exp)
+ if self.token != token.COMMA {
+ break
+ }
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ self.next()
+ }
+ }
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ idx1 = self.expect(token.RIGHT_PARENTHESIS)
+ return
+}
+
+func (self *_parser) parseCallExpression(left ast.Expression) ast.Expression {
+ argumentList, idx0, idx1 := self.parseArgumentList()
+ exp := &ast.CallExpression{
+ Callee: left,
+ LeftParenthesis: idx0,
+ ArgumentList: argumentList,
+ RightParenthesis: idx1,
+ }
+
+ if self.mode&StoreComments != 0 {
+ self.comments.SetExpression(exp)
+ }
+ return exp
+}
+
+func (self *_parser) parseDotMember(left ast.Expression) ast.Expression {
+ period := self.expect(token.PERIOD)
+
+ literal := self.literal
+ idx := self.idx
+
+ if !matchIdentifier.MatchString(literal) {
+ self.expect(token.IDENTIFIER)
+ self.nextStatement()
+ return &ast.BadExpression{From: period, To: self.idx}
+ }
+
+ self.next()
+
+ return &ast.DotExpression{
+ Left: left,
+ Identifier: &ast.Identifier{
+ Idx: idx,
+ Name: literal,
+ },
+ }
+}
+
+func (self *_parser) parseBracketMember(left ast.Expression) ast.Expression {
+ idx0 := self.expect(token.LEFT_BRACKET)
+ member := self.parseExpression()
+ idx1 := self.expect(token.RIGHT_BRACKET)
+ return &ast.BracketExpression{
+ LeftBracket: idx0,
+ Left: left,
+ Member: member,
+ RightBracket: idx1,
+ }
+}
+
+func (self *_parser) parseNewExpression() ast.Expression {
+ idx := self.expect(token.NEW)
+ callee := self.parseLeftHandSideExpression()
+ node := &ast.NewExpression{
+ New: idx,
+ Callee: callee,
+ }
+ if self.token == token.LEFT_PARENTHESIS {
+ argumentList, idx0, idx1 := self.parseArgumentList()
+ node.ArgumentList = argumentList
+ node.LeftParenthesis = idx0
+ node.RightParenthesis = idx1
+ }
+
+ if self.mode&StoreComments != 0 {
+ self.comments.SetExpression(node)
+ }
+
+ return node
+}
+
+func (self *_parser) parseLeftHandSideExpression() ast.Expression {
+ var left ast.Expression
+ if self.token == token.NEW {
+ left = self.parseNewExpression()
+ } else {
+ if self.mode&StoreComments != 0 {
+ self.comments.MarkComments(ast.LEADING)
+ self.comments.MarkPrimary()
+ }
+ left = self.parsePrimaryExpression()
+ }
+
+ if self.mode&StoreComments != 0 {
+ self.comments.SetExpression(left)
+ }
+
+ for {
+ if self.token == token.PERIOD {
+ left = self.parseDotMember(left)
+ } else if self.token == token.LEFT_BRACKET {
+ left = self.parseBracketMember(left)
+ } else {
+ break
+ }
+ }
+
+ return left
+}
+
+func (self *_parser) parseLeftHandSideExpressionAllowCall() ast.Expression {
+ allowIn := self.scope.allowIn
+ self.scope.allowIn = true
+ defer func() {
+ self.scope.allowIn = allowIn
+ }()
+
+ var left ast.Expression
+ if self.token == token.NEW {
+ var newComments []*ast.Comment
+ if self.mode&StoreComments != 0 {
+ newComments = self.comments.FetchAll()
+ self.comments.MarkComments(ast.LEADING)
+ self.comments.MarkPrimary()
+ }
+ left = self.parseNewExpression()
+ if self.mode&StoreComments != 0 {
+ self.comments.CommentMap.AddComments(left, newComments, ast.LEADING)
+ }
+ } else {
+ if self.mode&StoreComments != 0 {
+ self.comments.MarkComments(ast.LEADING)
+ self.comments.MarkPrimary()
+ }
+ left = self.parsePrimaryExpression()
+ }
+
+ if self.mode&StoreComments != 0 {
+ self.comments.SetExpression(left)
+ }
+
+ for {
+ if self.token == token.PERIOD {
+ left = self.parseDotMember(left)
+ } else if self.token == token.LEFT_BRACKET {
+ left = self.parseBracketMember(left)
+ } else if self.token == token.LEFT_PARENTHESIS {
+ left = self.parseCallExpression(left)
+ } else {
+ break
+ }
+ }
+
+ return left
+}
+
+func (self *_parser) parsePostfixExpression() ast.Expression {
+ operand := self.parseLeftHandSideExpressionAllowCall()
+
+ switch self.token {
+ case token.INCREMENT, token.DECREMENT:
+ // Make sure there is no line terminator here
+ if self.implicitSemicolon {
+ break
+ }
+ tkn := self.token
+ idx := self.idx
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ self.next()
+ switch operand.(type) {
+ case *ast.Identifier, *ast.DotExpression, *ast.BracketExpression:
+ default:
+ self.error(idx, "Invalid left-hand side in assignment")
+ self.nextStatement()
+ return &ast.BadExpression{From: idx, To: self.idx}
+ }
+ exp := &ast.UnaryExpression{
+ Operator: tkn,
+ Idx: idx,
+ Operand: operand,
+ Postfix: true,
+ }
+
+ if self.mode&StoreComments != 0 {
+ self.comments.SetExpression(exp)
+ }
+
+ return exp
+ }
+
+ return operand
+}
+
+func (self *_parser) parseUnaryExpression() ast.Expression {
+ switch self.token {
+ case token.PLUS, token.MINUS, token.NOT, token.BITWISE_NOT:
+ fallthrough
+ case token.DELETE, token.VOID, token.TYPEOF:
+ tkn := self.token
+ idx := self.idx
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ self.next()
+
+ return &ast.UnaryExpression{
+ Operator: tkn,
+ Idx: idx,
+ Operand: self.parseUnaryExpression(),
+ }
+ case token.INCREMENT, token.DECREMENT:
+ tkn := self.token
+ idx := self.idx
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ self.next()
+ operand := self.parseUnaryExpression()
+ switch operand.(type) {
+ case *ast.Identifier, *ast.DotExpression, *ast.BracketExpression:
+ default:
+ self.error(idx, "Invalid left-hand side in assignment")
+ self.nextStatement()
+ return &ast.BadExpression{From: idx, To: self.idx}
+ }
+ return &ast.UnaryExpression{
+ Operator: tkn,
+ Idx: idx,
+ Operand: operand,
+ }
+ }
+
+ return self.parsePostfixExpression()
+}
+
+func (self *_parser) parseMultiplicativeExpression() ast.Expression {
+ next := self.parseUnaryExpression
+ left := next()
+
+ for self.token == token.MULTIPLY || self.token == token.SLASH ||
+ self.token == token.REMAINDER {
+ tkn := self.token
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ self.next()
+
+ left = &ast.BinaryExpression{
+ Operator: tkn,
+ Left: left,
+ Right: next(),
+ }
+ }
+
+ return left
+}
+
+func (self *_parser) parseAdditiveExpression() ast.Expression {
+ next := self.parseMultiplicativeExpression
+ left := next()
+
+ for self.token == token.PLUS || self.token == token.MINUS {
+ tkn := self.token
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ self.next()
+
+ left = &ast.BinaryExpression{
+ Operator: tkn,
+ Left: left,
+ Right: next(),
+ }
+ }
+
+ return left
+}
+
+func (self *_parser) parseShiftExpression() ast.Expression {
+ next := self.parseAdditiveExpression
+ left := next()
+
+ for self.token == token.SHIFT_LEFT || self.token == token.SHIFT_RIGHT ||
+ self.token == token.UNSIGNED_SHIFT_RIGHT {
+ tkn := self.token
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ self.next()
+
+ left = &ast.BinaryExpression{
+ Operator: tkn,
+ Left: left,
+ Right: next(),
+ }
+ }
+
+ return left
+}
+
+func (self *_parser) parseRelationalExpression() ast.Expression {
+ next := self.parseShiftExpression
+ left := next()
+
+ allowIn := self.scope.allowIn
+ self.scope.allowIn = true
+ defer func() {
+ self.scope.allowIn = allowIn
+ }()
+
+ switch self.token {
+ case token.LESS, token.LESS_OR_EQUAL, token.GREATER, token.GREATER_OR_EQUAL:
+ tkn := self.token
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ self.next()
+
+ exp := &ast.BinaryExpression{
+ Operator: tkn,
+ Left: left,
+ Right: self.parseRelationalExpression(),
+ Comparison: true,
+ }
+ return exp
+ case token.INSTANCEOF:
+ tkn := self.token
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ self.next()
+
+ exp := &ast.BinaryExpression{
+ Operator: tkn,
+ Left: left,
+ Right: self.parseRelationalExpression(),
+ }
+ return exp
+ case token.IN:
+ if !allowIn {
+ return left
+ }
+ tkn := self.token
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ self.next()
+
+ exp := &ast.BinaryExpression{
+ Operator: tkn,
+ Left: left,
+ Right: self.parseRelationalExpression(),
+ }
+ return exp
+ }
+
+ return left
+}
+
+func (self *_parser) parseEqualityExpression() ast.Expression {
+ next := self.parseRelationalExpression
+ left := next()
+
+ for self.token == token.EQUAL || self.token == token.NOT_EQUAL ||
+ self.token == token.STRICT_EQUAL || self.token == token.STRICT_NOT_EQUAL {
+ tkn := self.token
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ self.next()
+
+ left = &ast.BinaryExpression{
+ Operator: tkn,
+ Left: left,
+ Right: next(),
+ Comparison: true,
+ }
+ }
+
+ return left
+}
+
+func (self *_parser) parseBitwiseAndExpression() ast.Expression {
+ next := self.parseEqualityExpression
+ left := next()
+
+ for self.token == token.AND {
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ tkn := self.token
+ self.next()
+
+ left = &ast.BinaryExpression{
+ Operator: tkn,
+ Left: left,
+ Right: next(),
+ }
+ }
+
+ return left
+}
+
+func (self *_parser) parseBitwiseExclusiveOrExpression() ast.Expression {
+ next := self.parseBitwiseAndExpression
+ left := next()
+
+ for self.token == token.EXCLUSIVE_OR {
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ tkn := self.token
+ self.next()
+
+ left = &ast.BinaryExpression{
+ Operator: tkn,
+ Left: left,
+ Right: next(),
+ }
+ }
+
+ return left
+}
+
+func (self *_parser) parseBitwiseOrExpression() ast.Expression {
+ next := self.parseBitwiseExclusiveOrExpression
+ left := next()
+
+ for self.token == token.OR {
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ tkn := self.token
+ self.next()
+
+ left = &ast.BinaryExpression{
+ Operator: tkn,
+ Left: left,
+ Right: next(),
+ }
+ }
+
+ return left
+}
+
+func (self *_parser) parseLogicalAndExpression() ast.Expression {
+ next := self.parseBitwiseOrExpression
+ left := next()
+
+ for self.token == token.LOGICAL_AND {
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ tkn := self.token
+ self.next()
+
+ left = &ast.BinaryExpression{
+ Operator: tkn,
+ Left: left,
+ Right: next(),
+ }
+ }
+
+ return left
+}
+
+func (self *_parser) parseLogicalOrExpression() ast.Expression {
+ next := self.parseLogicalAndExpression
+ left := next()
+
+ for self.token == token.LOGICAL_OR {
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ tkn := self.token
+ self.next()
+
+ left = &ast.BinaryExpression{
+ Operator: tkn,
+ Left: left,
+ Right: next(),
+ }
+ }
+
+ return left
+}
+
+func (self *_parser) parseConditionlExpression() ast.Expression {
+ left := self.parseLogicalOrExpression()
+
+ if self.token == token.QUESTION_MARK {
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ self.next()
+
+ consequent := self.parseAssignmentExpression()
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ self.expect(token.COLON)
+ exp := &ast.ConditionalExpression{
+ Test: left,
+ Consequent: consequent,
+ Alternate: self.parseAssignmentExpression(),
+ }
+
+ return exp
+ }
+
+ return left
+}
+
+func (self *_parser) parseAssignmentExpression() ast.Expression {
+ left := self.parseConditionlExpression()
+ var operator token.Token
+ switch self.token {
+ case token.ASSIGN:
+ operator = self.token
+ case token.ADD_ASSIGN:
+ operator = token.PLUS
+ case token.SUBTRACT_ASSIGN:
+ operator = token.MINUS
+ case token.MULTIPLY_ASSIGN:
+ operator = token.MULTIPLY
+ case token.QUOTIENT_ASSIGN:
+ operator = token.SLASH
+ case token.REMAINDER_ASSIGN:
+ operator = token.REMAINDER
+ case token.AND_ASSIGN:
+ operator = token.AND
+ case token.AND_NOT_ASSIGN:
+ operator = token.AND_NOT
+ case token.OR_ASSIGN:
+ operator = token.OR
+ case token.EXCLUSIVE_OR_ASSIGN:
+ operator = token.EXCLUSIVE_OR
+ case token.SHIFT_LEFT_ASSIGN:
+ operator = token.SHIFT_LEFT
+ case token.SHIFT_RIGHT_ASSIGN:
+ operator = token.SHIFT_RIGHT
+ case token.UNSIGNED_SHIFT_RIGHT_ASSIGN:
+ operator = token.UNSIGNED_SHIFT_RIGHT
+ }
+
+ if operator != 0 {
+ idx := self.idx
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ self.next()
+ switch left.(type) {
+ case *ast.Identifier, *ast.DotExpression, *ast.BracketExpression:
+ default:
+ self.error(left.Idx0(), "Invalid left-hand side in assignment")
+ self.nextStatement()
+ return &ast.BadExpression{From: idx, To: self.idx}
+ }
+
+ exp := &ast.AssignExpression{
+ Left: left,
+ Operator: operator,
+ Right: self.parseAssignmentExpression(),
+ }
+
+ if self.mode&StoreComments != 0 {
+ self.comments.SetExpression(exp)
+ }
+
+ return exp
+ }
+
+ return left
+}
+
+func (self *_parser) parseExpression() ast.Expression {
+ next := self.parseAssignmentExpression
+ left := next()
+
+ if self.token == token.COMMA {
+ sequence := []ast.Expression{left}
+ for {
+ if self.token != token.COMMA {
+ break
+ }
+ self.next()
+ sequence = append(sequence, next())
+ }
+ return &ast.SequenceExpression{
+ Sequence: sequence,
+ }
+ }
+
+ return left
+}
diff --git a/vendor/github.com/robertkrimen/otto/parser/lexer.go b/vendor/github.com/robertkrimen/otto/parser/lexer.go
new file mode 100644
index 0000000..0ddad65
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/parser/lexer.go
@@ -0,0 +1,860 @@
+package parser
+
+import (
+ "bytes"
+ "errors"
+ "fmt"
+ "regexp"
+ "strconv"
+ "strings"
+ "unicode"
+ "unicode/utf8"
+
+ "github.com/robertkrimen/otto/ast"
+ "github.com/robertkrimen/otto/file"
+ "github.com/robertkrimen/otto/token"
+)
+
+type _chr struct {
+ value rune
+ width int
+}
+
+var matchIdentifier = regexp.MustCompile(`^[$_\p{L}][$_\p{L}\d}]*$`)
+
+func isDecimalDigit(chr rune) bool {
+ return '0' <= chr && chr <= '9'
+}
+
+func digitValue(chr rune) int {
+ switch {
+ case '0' <= chr && chr <= '9':
+ return int(chr - '0')
+ case 'a' <= chr && chr <= 'f':
+ return int(chr - 'a' + 10)
+ case 'A' <= chr && chr <= 'F':
+ return int(chr - 'A' + 10)
+ }
+ return 16 // Larger than any legal digit value
+}
+
+func isDigit(chr rune, base int) bool {
+ return digitValue(chr) < base
+}
+
+func isIdentifierStart(chr rune) bool {
+ return chr == '$' || chr == '_' || chr == '\\' ||
+ 'a' <= chr && chr <= 'z' || 'A' <= chr && chr <= 'Z' ||
+ chr >= utf8.RuneSelf && unicode.IsLetter(chr)
+}
+
+func isIdentifierPart(chr rune) bool {
+ return chr == '$' || chr == '_' || chr == '\\' ||
+ 'a' <= chr && chr <= 'z' || 'A' <= chr && chr <= 'Z' ||
+ '0' <= chr && chr <= '9' ||
+ chr >= utf8.RuneSelf && (unicode.IsLetter(chr) || unicode.IsDigit(chr))
+}
+
+func (self *_parser) scanIdentifier() (string, error) {
+ offset := self.chrOffset
+ parse := false
+ for isIdentifierPart(self.chr) {
+ if self.chr == '\\' {
+ distance := self.chrOffset - offset
+ self.read()
+ if self.chr != 'u' {
+ return "", fmt.Errorf("Invalid identifier escape character: %c (%s)", self.chr, string(self.chr))
+ }
+ parse = true
+ var value rune
+ for j := 0; j < 4; j++ {
+ self.read()
+ decimal, ok := hex2decimal(byte(self.chr))
+ if !ok {
+ return "", fmt.Errorf("Invalid identifier escape character: %c (%s)", self.chr, string(self.chr))
+ }
+ value = value<<4 | decimal
+ }
+ if value == '\\' {
+ return "", fmt.Errorf("Invalid identifier escape value: %c (%s)", value, string(value))
+ } else if distance == 0 {
+ if !isIdentifierStart(value) {
+ return "", fmt.Errorf("Invalid identifier escape value: %c (%s)", value, string(value))
+ }
+ } else if distance > 0 {
+ if !isIdentifierPart(value) {
+ return "", fmt.Errorf("Invalid identifier escape value: %c (%s)", value, string(value))
+ }
+ }
+ }
+ self.read()
+ }
+ literal := string(self.str[offset:self.chrOffset])
+ if parse {
+ return parseStringLiteral(literal)
+ }
+ return literal, nil
+}
+
+// 7.2
+func isLineWhiteSpace(chr rune) bool {
+ switch chr {
+ case '\u0009', '\u000b', '\u000c', '\u0020', '\u00a0', '\ufeff':
+ return true
+ case '\u000a', '\u000d', '\u2028', '\u2029':
+ return false
+ case '\u0085':
+ return false
+ }
+ return unicode.IsSpace(chr)
+}
+
+// 7.3
+func isLineTerminator(chr rune) bool {
+ switch chr {
+ case '\u000a', '\u000d', '\u2028', '\u2029':
+ return true
+ }
+ return false
+}
+
+func (self *_parser) scan() (tkn token.Token, literal string, idx file.Idx) {
+ self.implicitSemicolon = false
+
+ for {
+ self.skipWhiteSpace()
+
+ idx = self.idxOf(self.chrOffset)
+ insertSemicolon := false
+
+ switch chr := self.chr; {
+ case isIdentifierStart(chr):
+ var err error
+ literal, err = self.scanIdentifier()
+ if err != nil {
+ tkn = token.ILLEGAL
+ break
+ }
+ if len(literal) > 1 {
+ // Keywords are longer than 1 character, avoid lookup otherwise
+ var strict bool
+ tkn, strict = token.IsKeyword(literal)
+
+ switch tkn {
+ case 0: // Not a keyword
+ if literal == "true" || literal == "false" {
+ self.insertSemicolon = true
+ tkn = token.BOOLEAN
+ return
+ } else if literal == "null" {
+ self.insertSemicolon = true
+ tkn = token.NULL
+ return
+ }
+
+ case token.KEYWORD:
+ tkn = token.KEYWORD
+ if strict {
+ // TODO If strict and in strict mode, then this is not a break
+ break
+ }
+ return
+
+ case
+ token.THIS,
+ token.BREAK,
+ token.THROW, // A newline after a throw is not allowed, but we need to detect it
+ token.RETURN,
+ token.CONTINUE,
+ token.DEBUGGER:
+ self.insertSemicolon = true
+ return
+
+ default:
+ return
+ }
+ }
+ self.insertSemicolon = true
+ tkn = token.IDENTIFIER
+ return
+ case '0' <= chr && chr <= '9':
+ self.insertSemicolon = true
+ tkn, literal = self.scanNumericLiteral(false)
+ return
+ default:
+ self.read()
+ switch chr {
+ case -1:
+ if self.insertSemicolon {
+ self.insertSemicolon = false
+ self.implicitSemicolon = true
+ }
+ tkn = token.EOF
+ case '\r', '\n', '\u2028', '\u2029':
+ self.insertSemicolon = false
+ self.implicitSemicolon = true
+ self.comments.AtLineBreak()
+ continue
+ case ':':
+ tkn = token.COLON
+ case '.':
+ if digitValue(self.chr) < 10 {
+ insertSemicolon = true
+ tkn, literal = self.scanNumericLiteral(true)
+ } else {
+ tkn = token.PERIOD
+ }
+ case ',':
+ tkn = token.COMMA
+ case ';':
+ tkn = token.SEMICOLON
+ case '(':
+ tkn = token.LEFT_PARENTHESIS
+ case ')':
+ tkn = token.RIGHT_PARENTHESIS
+ insertSemicolon = true
+ case '[':
+ tkn = token.LEFT_BRACKET
+ case ']':
+ tkn = token.RIGHT_BRACKET
+ insertSemicolon = true
+ case '{':
+ tkn = token.LEFT_BRACE
+ case '}':
+ tkn = token.RIGHT_BRACE
+ insertSemicolon = true
+ case '+':
+ tkn = self.switch3(token.PLUS, token.ADD_ASSIGN, '+', token.INCREMENT)
+ if tkn == token.INCREMENT {
+ insertSemicolon = true
+ }
+ case '-':
+ tkn = self.switch3(token.MINUS, token.SUBTRACT_ASSIGN, '-', token.DECREMENT)
+ if tkn == token.DECREMENT {
+ insertSemicolon = true
+ }
+ case '*':
+ tkn = self.switch2(token.MULTIPLY, token.MULTIPLY_ASSIGN)
+ case '/':
+ if self.chr == '/' {
+ if self.mode&StoreComments != 0 {
+ literal := string(self.readSingleLineComment())
+ self.comments.AddComment(ast.NewComment(literal, self.idx))
+ continue
+ }
+ self.skipSingleLineComment()
+ continue
+ } else if self.chr == '*' {
+ if self.mode&StoreComments != 0 {
+ literal = string(self.readMultiLineComment())
+ self.comments.AddComment(ast.NewComment(literal, self.idx))
+ continue
+ }
+ self.skipMultiLineComment()
+ continue
+ } else {
+ // Could be division, could be RegExp literal
+ tkn = self.switch2(token.SLASH, token.QUOTIENT_ASSIGN)
+ insertSemicolon = true
+ }
+ case '%':
+ tkn = self.switch2(token.REMAINDER, token.REMAINDER_ASSIGN)
+ case '^':
+ tkn = self.switch2(token.EXCLUSIVE_OR, token.EXCLUSIVE_OR_ASSIGN)
+ case '<':
+ tkn = self.switch4(token.LESS, token.LESS_OR_EQUAL, '<', token.SHIFT_LEFT, token.SHIFT_LEFT_ASSIGN)
+ case '>':
+ tkn = self.switch6(token.GREATER, token.GREATER_OR_EQUAL, '>', token.SHIFT_RIGHT, token.SHIFT_RIGHT_ASSIGN, '>', token.UNSIGNED_SHIFT_RIGHT, token.UNSIGNED_SHIFT_RIGHT_ASSIGN)
+ case '=':
+ tkn = self.switch2(token.ASSIGN, token.EQUAL)
+ if tkn == token.EQUAL && self.chr == '=' {
+ self.read()
+ tkn = token.STRICT_EQUAL
+ }
+ case '!':
+ tkn = self.switch2(token.NOT, token.NOT_EQUAL)
+ if tkn == token.NOT_EQUAL && self.chr == '=' {
+ self.read()
+ tkn = token.STRICT_NOT_EQUAL
+ }
+ case '&':
+ if self.chr == '^' {
+ self.read()
+ tkn = self.switch2(token.AND_NOT, token.AND_NOT_ASSIGN)
+ } else {
+ tkn = self.switch3(token.AND, token.AND_ASSIGN, '&', token.LOGICAL_AND)
+ }
+ case '|':
+ tkn = self.switch3(token.OR, token.OR_ASSIGN, '|', token.LOGICAL_OR)
+ case '~':
+ tkn = token.BITWISE_NOT
+ case '?':
+ tkn = token.QUESTION_MARK
+ case '"', '\'':
+ insertSemicolon = true
+ tkn = token.STRING
+ var err error
+ literal, err = self.scanString(self.chrOffset - 1)
+ if err != nil {
+ tkn = token.ILLEGAL
+ }
+ default:
+ self.errorUnexpected(idx, chr)
+ tkn = token.ILLEGAL
+ }
+ }
+ self.insertSemicolon = insertSemicolon
+ return
+ }
+}
+
+func (self *_parser) switch2(tkn0, tkn1 token.Token) token.Token {
+ if self.chr == '=' {
+ self.read()
+ return tkn1
+ }
+ return tkn0
+}
+
+func (self *_parser) switch3(tkn0, tkn1 token.Token, chr2 rune, tkn2 token.Token) token.Token {
+ if self.chr == '=' {
+ self.read()
+ return tkn1
+ }
+ if self.chr == chr2 {
+ self.read()
+ return tkn2
+ }
+ return tkn0
+}
+
+func (self *_parser) switch4(tkn0, tkn1 token.Token, chr2 rune, tkn2, tkn3 token.Token) token.Token {
+ if self.chr == '=' {
+ self.read()
+ return tkn1
+ }
+ if self.chr == chr2 {
+ self.read()
+ if self.chr == '=' {
+ self.read()
+ return tkn3
+ }
+ return tkn2
+ }
+ return tkn0
+}
+
+func (self *_parser) switch6(tkn0, tkn1 token.Token, chr2 rune, tkn2, tkn3 token.Token, chr3 rune, tkn4, tkn5 token.Token) token.Token {
+ if self.chr == '=' {
+ self.read()
+ return tkn1
+ }
+ if self.chr == chr2 {
+ self.read()
+ if self.chr == '=' {
+ self.read()
+ return tkn3
+ }
+ if self.chr == chr3 {
+ self.read()
+ if self.chr == '=' {
+ self.read()
+ return tkn5
+ }
+ return tkn4
+ }
+ return tkn2
+ }
+ return tkn0
+}
+
+func (self *_parser) chrAt(index int) _chr {
+ value, width := utf8.DecodeRuneInString(self.str[index:])
+ return _chr{
+ value: value,
+ width: width,
+ }
+}
+
+func (self *_parser) _peek() rune {
+ if self.offset+1 < self.length {
+ return rune(self.str[self.offset+1])
+ }
+ return -1
+}
+
+func (self *_parser) read() {
+ if self.offset < self.length {
+ self.chrOffset = self.offset
+ chr, width := rune(self.str[self.offset]), 1
+ if chr >= utf8.RuneSelf { // !ASCII
+ chr, width = utf8.DecodeRuneInString(self.str[self.offset:])
+ if chr == utf8.RuneError && width == 1 {
+ self.error(self.chrOffset, "Invalid UTF-8 character")
+ }
+ }
+ self.offset += width
+ self.chr = chr
+ } else {
+ self.chrOffset = self.length
+ self.chr = -1 // EOF
+ }
+}
+
+// This is here since the functions are so similar
+func (self *_RegExp_parser) read() {
+ if self.offset < self.length {
+ self.chrOffset = self.offset
+ chr, width := rune(self.str[self.offset]), 1
+ if chr >= utf8.RuneSelf { // !ASCII
+ chr, width = utf8.DecodeRuneInString(self.str[self.offset:])
+ if chr == utf8.RuneError && width == 1 {
+ self.error(self.chrOffset, "Invalid UTF-8 character")
+ }
+ }
+ self.offset += width
+ self.chr = chr
+ } else {
+ self.chrOffset = self.length
+ self.chr = -1 // EOF
+ }
+}
+
+func (self *_parser) readSingleLineComment() (result []rune) {
+ for self.chr != -1 {
+ self.read()
+ if isLineTerminator(self.chr) {
+ return
+ }
+ result = append(result, self.chr)
+ }
+
+ // Get rid of the trailing -1
+ result = result[:len(result)-1]
+
+ return
+}
+
+func (self *_parser) readMultiLineComment() (result []rune) {
+ self.read()
+ for self.chr >= 0 {
+ chr := self.chr
+ self.read()
+ if chr == '*' && self.chr == '/' {
+ self.read()
+ return
+ }
+
+ result = append(result, chr)
+ }
+
+ self.errorUnexpected(0, self.chr)
+
+ return
+}
+
+func (self *_parser) skipSingleLineComment() {
+ for self.chr != -1 {
+ self.read()
+ if isLineTerminator(self.chr) {
+ return
+ }
+ }
+}
+
+func (self *_parser) skipMultiLineComment() {
+ self.read()
+ for self.chr >= 0 {
+ chr := self.chr
+ self.read()
+ if chr == '*' && self.chr == '/' {
+ self.read()
+ return
+ }
+ }
+
+ self.errorUnexpected(0, self.chr)
+}
+
+func (self *_parser) skipWhiteSpace() {
+ for {
+ switch self.chr {
+ case ' ', '\t', '\f', '\v', '\u00a0', '\ufeff':
+ self.read()
+ continue
+ case '\r':
+ if self._peek() == '\n' {
+ self.comments.AtLineBreak()
+ self.read()
+ }
+ fallthrough
+ case '\u2028', '\u2029', '\n':
+ if self.insertSemicolon {
+ return
+ }
+ self.comments.AtLineBreak()
+ self.read()
+ continue
+ }
+ if self.chr >= utf8.RuneSelf {
+ if unicode.IsSpace(self.chr) {
+ self.read()
+ continue
+ }
+ }
+ break
+ }
+}
+
+func (self *_parser) skipLineWhiteSpace() {
+ for isLineWhiteSpace(self.chr) {
+ self.read()
+ }
+}
+
+func (self *_parser) scanMantissa(base int) {
+ for digitValue(self.chr) < base {
+ self.read()
+ }
+}
+
+func (self *_parser) scanEscape(quote rune) {
+ var length, base uint32
+ switch self.chr {
+ //case '0', '1', '2', '3', '4', '5', '6', '7':
+ // Octal:
+ // length, base, limit = 3, 8, 255
+ case 'a', 'b', 'f', 'n', 'r', 't', 'v', '\\', '"', '\'', '0':
+ self.read()
+ return
+ case '\r', '\n', '\u2028', '\u2029':
+ self.scanNewline()
+ return
+ case 'x':
+ self.read()
+ length, base = 2, 16
+ case 'u':
+ self.read()
+ length, base = 4, 16
+ default:
+ self.read() // Always make progress
+ return
+ }
+
+ var value uint32
+ for ; length > 0 && self.chr != quote && self.chr >= 0; length-- {
+ digit := uint32(digitValue(self.chr))
+ if digit >= base {
+ break
+ }
+ value = value*base + digit
+ self.read()
+ }
+}
+
+func (self *_parser) scanString(offset int) (string, error) {
+ // " ' /
+ quote := rune(self.str[offset])
+
+ for self.chr != quote {
+ chr := self.chr
+ if chr == '\n' || chr == '\r' || chr == '\u2028' || chr == '\u2029' || chr < 0 {
+ goto newline
+ }
+ self.read()
+ if chr == '\\' {
+ if quote == '/' {
+ if self.chr == '\n' || self.chr == '\r' || self.chr == '\u2028' || self.chr == '\u2029' || self.chr < 0 {
+ goto newline
+ }
+ self.read()
+ } else {
+ self.scanEscape(quote)
+ }
+ } else if chr == '[' && quote == '/' {
+ // Allow a slash (/) in a bracket character class ([...])
+ // TODO Fix this, this is hacky...
+ quote = -1
+ } else if chr == ']' && quote == -1 {
+ quote = '/'
+ }
+ }
+
+ // " ' /
+ self.read()
+
+ return string(self.str[offset:self.chrOffset]), nil
+
+newline:
+ self.scanNewline()
+ err := "String not terminated"
+ if quote == '/' {
+ err = "Invalid regular expression: missing /"
+ self.error(self.idxOf(offset), err)
+ }
+ return "", errors.New(err)
+}
+
+func (self *_parser) scanNewline() {
+ if self.chr == '\r' {
+ self.read()
+ if self.chr != '\n' {
+ return
+ }
+ }
+ self.read()
+}
+
+func hex2decimal(chr byte) (value rune, ok bool) {
+ {
+ chr := rune(chr)
+ switch {
+ case '0' <= chr && chr <= '9':
+ return chr - '0', true
+ case 'a' <= chr && chr <= 'f':
+ return chr - 'a' + 10, true
+ case 'A' <= chr && chr <= 'F':
+ return chr - 'A' + 10, true
+ }
+ return
+ }
+}
+
+func parseNumberLiteral(literal string) (value interface{}, err error) {
+ // TODO Is Uint okay? What about -MAX_UINT
+ value, err = strconv.ParseInt(literal, 0, 64)
+ if err == nil {
+ return value, nil
+ }
+
+ parseIntErr := err // Save this first error, just in case
+
+ value, err = strconv.ParseFloat(literal, 64)
+ if err == nil {
+ return value, nil
+ } else if err.(*strconv.NumError).Err == strconv.ErrRange {
+ // Infinity, etc.
+ return value, nil
+ }
+
+ err = parseIntErr
+
+ if err.(*strconv.NumError).Err == strconv.ErrRange {
+ if len(literal) > 2 && literal[0] == '0' && (literal[1] == 'X' || literal[1] == 'x') {
+ // Could just be a very large number (e.g. 0x8000000000000000)
+ var value float64
+ literal = literal[2:]
+ for _, chr := range literal {
+ digit := digitValue(chr)
+ if digit >= 16 {
+ return nil, errors.New("Illegal numeric literal")
+ }
+ value = value*16 + float64(digit)
+ }
+ return value, nil
+ }
+ }
+
+ return nil, errors.New("Illegal numeric literal")
+}
+
+func parseStringLiteral(literal string) (string, error) {
+ // Best case scenario...
+ if literal == "" {
+ return "", nil
+ }
+
+ // Slightly less-best case scenario...
+ if !strings.ContainsRune(literal, '\\') {
+ return literal, nil
+ }
+
+ str := literal
+ buffer := bytes.NewBuffer(make([]byte, 0, 3*len(literal)/2))
+
+ for len(str) > 0 {
+ switch chr := str[0]; {
+ // We do not explicitly handle the case of the quote
+ // value, which can be: " ' /
+ // This assumes we're already passed a partially well-formed literal
+ case chr >= utf8.RuneSelf:
+ chr, size := utf8.DecodeRuneInString(str)
+ buffer.WriteRune(chr)
+ str = str[size:]
+ continue
+ case chr != '\\':
+ buffer.WriteByte(chr)
+ str = str[1:]
+ continue
+ }
+
+ if len(str) <= 1 {
+ panic("len(str) <= 1")
+ }
+ chr := str[1]
+ var value rune
+ if chr >= utf8.RuneSelf {
+ str = str[1:]
+ var size int
+ value, size = utf8.DecodeRuneInString(str)
+ str = str[size:] // \ +
+ } else {
+ str = str[2:] // \
+ switch chr {
+ case 'b':
+ value = '\b'
+ case 'f':
+ value = '\f'
+ case 'n':
+ value = '\n'
+ case 'r':
+ value = '\r'
+ case 't':
+ value = '\t'
+ case 'v':
+ value = '\v'
+ case 'x', 'u':
+ size := 0
+ switch chr {
+ case 'x':
+ size = 2
+ case 'u':
+ size = 4
+ }
+ if len(str) < size {
+ return "", fmt.Errorf("invalid escape: \\%s: len(%q) != %d", string(chr), str, size)
+ }
+ for j := 0; j < size; j++ {
+ decimal, ok := hex2decimal(str[j])
+ if !ok {
+ return "", fmt.Errorf("invalid escape: \\%s: %q", string(chr), str[:size])
+ }
+ value = value<<4 | decimal
+ }
+ str = str[size:]
+ if chr == 'x' {
+ break
+ }
+ if value > utf8.MaxRune {
+ panic("value > utf8.MaxRune")
+ }
+ case '0':
+ if len(str) == 0 || '0' > str[0] || str[0] > '7' {
+ value = 0
+ break
+ }
+ fallthrough
+ case '1', '2', '3', '4', '5', '6', '7':
+ // TODO strict
+ value = rune(chr) - '0'
+ j := 0
+ for ; j < 2; j++ {
+ if len(str) < j+1 {
+ break
+ }
+ chr := str[j]
+ if '0' > chr || chr > '7' {
+ break
+ }
+ decimal := rune(str[j]) - '0'
+ value = (value << 3) | decimal
+ }
+ str = str[j:]
+ case '\\':
+ value = '\\'
+ case '\'', '"':
+ value = rune(chr)
+ case '\r':
+ if len(str) > 0 {
+ if str[0] == '\n' {
+ str = str[1:]
+ }
+ }
+ fallthrough
+ case '\n':
+ continue
+ default:
+ value = rune(chr)
+ }
+ }
+ buffer.WriteRune(value)
+ }
+
+ return buffer.String(), nil
+}
+
+func (self *_parser) scanNumericLiteral(decimalPoint bool) (token.Token, string) {
+ offset := self.chrOffset
+ tkn := token.NUMBER
+
+ if decimalPoint {
+ offset--
+ self.scanMantissa(10)
+ goto exponent
+ }
+
+ if self.chr == '0' {
+ offset := self.chrOffset
+ self.read()
+ if self.chr == 'x' || self.chr == 'X' {
+ // Hexadecimal
+ self.read()
+ if isDigit(self.chr, 16) {
+ self.read()
+ } else {
+ return token.ILLEGAL, self.str[offset:self.chrOffset]
+ }
+ self.scanMantissa(16)
+
+ if self.chrOffset-offset <= 2 {
+ // Only "0x" or "0X"
+ self.error(0, "Illegal hexadecimal number")
+ }
+
+ goto hexadecimal
+ } else if self.chr == '.' {
+ // Float
+ goto float
+ } else {
+ // Octal, Float
+ if self.chr == 'e' || self.chr == 'E' {
+ goto exponent
+ }
+ self.scanMantissa(8)
+ if self.chr == '8' || self.chr == '9' {
+ return token.ILLEGAL, self.str[offset:self.chrOffset]
+ }
+ goto octal
+ }
+ }
+
+ self.scanMantissa(10)
+
+float:
+ if self.chr == '.' {
+ self.read()
+ self.scanMantissa(10)
+ }
+
+exponent:
+ if self.chr == 'e' || self.chr == 'E' {
+ self.read()
+ if self.chr == '-' || self.chr == '+' {
+ self.read()
+ }
+ if isDecimalDigit(self.chr) {
+ self.read()
+ self.scanMantissa(10)
+ } else {
+ return token.ILLEGAL, self.str[offset:self.chrOffset]
+ }
+ }
+
+hexadecimal:
+octal:
+ if isIdentifierStart(self.chr) || isDecimalDigit(self.chr) {
+ return token.ILLEGAL, self.str[offset:self.chrOffset]
+ }
+
+ return tkn, self.str[offset:self.chrOffset]
+}
diff --git a/vendor/github.com/robertkrimen/otto/parser/parser.go b/vendor/github.com/robertkrimen/otto/parser/parser.go
new file mode 100644
index 0000000..a170147
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/parser/parser.go
@@ -0,0 +1,340 @@
+/*
+Package parser implements a parser for JavaScript.
+
+ import (
+ "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)
+
+# Warning
+
+The parser and AST interfaces are still works-in-progress (particularly where
+node types are concerned) and may change in the future.
+*/
+package parser
+
+import (
+ "bytes"
+ "encoding/base64"
+ "errors"
+ "io"
+ "io/ioutil"
+
+ "github.com/robertkrimen/otto/ast"
+ "github.com/robertkrimen/otto/file"
+ "github.com/robertkrimen/otto/token"
+ "gopkg.in/sourcemap.v1"
+)
+
+// A Mode value is a set of flags (or 0). They control optional parser functionality.
+type Mode uint
+
+const (
+ IgnoreRegExpErrors Mode = 1 << iota // Ignore RegExp compatibility errors (allow backtracking)
+ StoreComments // Store the comments from source to the comments map
+)
+
+type _parser struct {
+ str string
+ length int
+ base int
+
+ chr rune // The current character
+ chrOffset int // The offset of current character
+ offset int // The offset after current character (may be greater than 1)
+
+ idx file.Idx // The index of token
+ token token.Token // The token
+ literal string // The literal of the token, if any
+
+ scope *_scope
+ insertSemicolon bool // If we see a newline, then insert an implicit semicolon
+ implicitSemicolon bool // An implicit semicolon exists
+
+ errors ErrorList
+
+ recover struct {
+ // Scratch when trying to seek to the next statement, etc.
+ idx file.Idx
+ count int
+ }
+
+ mode Mode
+
+ file *file.File
+
+ comments *ast.Comments
+}
+
+type Parser interface {
+ Scan() (tkn token.Token, literal string, idx file.Idx)
+}
+
+func _newParser(filename, src string, base int, sm *sourcemap.Consumer) *_parser {
+ return &_parser{
+ chr: ' ', // This is set so we can start scanning by skipping whitespace
+ str: src,
+ length: len(src),
+ base: base,
+ file: file.NewFile(filename, src, base).WithSourceMap(sm),
+ comments: ast.NewComments(),
+ }
+}
+
+// Returns a new Parser.
+func NewParser(filename, src string) Parser {
+ return _newParser(filename, src, 1, nil)
+}
+
+func ReadSource(filename string, src interface{}) ([]byte, error) {
+ if src != nil {
+ switch src := src.(type) {
+ case string:
+ return []byte(src), nil
+ case []byte:
+ return src, nil
+ case *bytes.Buffer:
+ if src != nil {
+ return src.Bytes(), nil
+ }
+ case io.Reader:
+ var bfr bytes.Buffer
+ if _, err := io.Copy(&bfr, src); err != nil {
+ return nil, err
+ }
+ return bfr.Bytes(), nil
+ }
+ return nil, errors.New("invalid source")
+ }
+ return ioutil.ReadFile(filename)
+}
+
+func ReadSourceMap(filename string, src interface{}) (*sourcemap.Consumer, error) {
+ if src == nil {
+ return nil, nil //nolint: nilnil
+ }
+
+ switch src := src.(type) {
+ case string:
+ return sourcemap.Parse(filename, []byte(src))
+ case []byte:
+ return sourcemap.Parse(filename, src)
+ case *bytes.Buffer:
+ if src != nil {
+ return sourcemap.Parse(filename, src.Bytes())
+ }
+ case io.Reader:
+ var bfr bytes.Buffer
+ if _, err := io.Copy(&bfr, src); err != nil {
+ return nil, err
+ }
+ return sourcemap.Parse(filename, bfr.Bytes())
+ case *sourcemap.Consumer:
+ return src, nil
+ }
+
+ return nil, errors.New("invalid sourcemap type")
+}
+
+func ParseFileWithSourceMap(fileSet *file.FileSet, filename string, javascriptSource, sourcemapSource interface{}, mode Mode) (*ast.Program, error) {
+ src, err := ReadSource(filename, javascriptSource)
+ if err != nil {
+ return nil, err
+ }
+
+ if sourcemapSource == nil {
+ lines := bytes.Split(src, []byte("\n"))
+ lastLine := lines[len(lines)-1]
+ if bytes.HasPrefix(lastLine, []byte("//# sourceMappingURL=data:application/json")) {
+ bits := bytes.SplitN(lastLine, []byte(","), 2)
+ if len(bits) == 2 {
+ if d, err := base64.StdEncoding.DecodeString(string(bits[1])); err == nil {
+ sourcemapSource = d
+ }
+ }
+ }
+ }
+
+ sm, err := ReadSourceMap(filename, sourcemapSource)
+ if err != nil {
+ return nil, err
+ }
+
+ base := 1
+ if fileSet != nil {
+ base = fileSet.AddFile(filename, string(src))
+ }
+
+ parser := _newParser(filename, string(src), base, sm)
+ parser.mode = mode
+ program, err := parser.parse()
+ program.Comments = parser.comments.CommentMap
+
+ return program, err
+}
+
+// ParseFile parses the source code of a single JavaScript/ECMAScript source file and returns
+// the corresponding ast.Program node.
+//
+// If fileSet == nil, ParseFile parses source without a FileSet.
+// If fileSet != nil, ParseFile first adds filename and src to fileSet.
+//
+// The filename argument is optional and is used for labelling errors, etc.
+//
+// src may be a string, a byte slice, a bytes.Buffer, or an io.Reader, but it MUST always be in UTF-8.
+//
+// // Parse some JavaScript, yielding a *ast.Program and/or an ErrorList
+// program, err := parser.ParseFile(nil, "", `if (abc > 1) {}`, 0)
+func ParseFile(fileSet *file.FileSet, filename string, src interface{}, mode Mode) (*ast.Program, error) {
+ return ParseFileWithSourceMap(fileSet, filename, src, nil, mode)
+}
+
+// ParseFunction parses a given parameter list and body as a function and returns the
+// corresponding ast.FunctionLiteral node.
+//
+// The parameter list, if any, should be a comma-separated list of identifiers.
+func ParseFunction(parameterList, body string) (*ast.FunctionLiteral, error) {
+ src := "(function(" + parameterList + ") {\n" + body + "\n})"
+
+ parser := _newParser("", src, 1, nil)
+ program, err := parser.parse()
+ if err != nil {
+ return nil, err
+ }
+
+ return program.Body[0].(*ast.ExpressionStatement).Expression.(*ast.FunctionLiteral), nil
+}
+
+// Scan reads a single token from the source at the current offset, increments the offset and
+// returns the token.Token token, a string literal representing the value of the token (if applicable)
+// and it's current file.Idx index.
+func (self *_parser) Scan() (tkn token.Token, literal string, idx file.Idx) {
+ return self.scan()
+}
+
+func (self *_parser) slice(idx0, idx1 file.Idx) string {
+ from := int(idx0) - self.base
+ to := int(idx1) - self.base
+ if from >= 0 && to <= len(self.str) {
+ return self.str[from:to]
+ }
+
+ return ""
+}
+
+func (self *_parser) parse() (*ast.Program, error) {
+ self.next()
+ program := self.parseProgram()
+ if false {
+ self.errors.Sort()
+ }
+
+ if self.mode&StoreComments != 0 {
+ self.comments.CommentMap.AddComments(program, self.comments.FetchAll(), ast.TRAILING)
+ }
+
+ return program, self.errors.Err()
+}
+
+func (self *_parser) next() {
+ self.token, self.literal, self.idx = self.scan()
+}
+
+func (self *_parser) optionalSemicolon() {
+ if self.token == token.SEMICOLON {
+ self.next()
+ return
+ }
+
+ if self.implicitSemicolon {
+ self.implicitSemicolon = false
+ return
+ }
+
+ if self.token != token.EOF && self.token != token.RIGHT_BRACE {
+ self.expect(token.SEMICOLON)
+ }
+}
+
+func (self *_parser) semicolon() {
+ if self.token != token.RIGHT_PARENTHESIS && self.token != token.RIGHT_BRACE {
+ if self.implicitSemicolon {
+ self.implicitSemicolon = false
+ return
+ }
+
+ self.expect(token.SEMICOLON)
+ }
+}
+
+func (self *_parser) idxOf(offset int) file.Idx {
+ return file.Idx(self.base + offset)
+}
+
+func (self *_parser) expect(value token.Token) file.Idx {
+ idx := self.idx
+ if self.token != value {
+ self.errorUnexpectedToken(self.token)
+ }
+ self.next()
+ return idx
+}
+
+func lineCount(str string) (int, int) {
+ line, last := 0, -1
+ pair := false
+ for index, chr := range str {
+ switch chr {
+ case '\r':
+ line += 1
+ last = index
+ pair = true
+ continue
+ case '\n':
+ if !pair {
+ line += 1
+ }
+ last = index
+ case '\u2028', '\u2029':
+ line += 1
+ last = index + 2
+ }
+ pair = false
+ }
+ return line, last
+}
+
+func (self *_parser) position(idx file.Idx) file.Position {
+ position := file.Position{}
+ offset := int(idx) - self.base
+ str := self.str[:offset]
+ position.Filename = self.file.Name()
+ line, last := lineCount(str)
+ position.Line = 1 + line
+ if last >= 0 {
+ position.Column = offset - last
+ } else {
+ position.Column = 1 + len(str)
+ }
+
+ return position
+}
diff --git a/vendor/github.com/robertkrimen/otto/parser/regexp.go b/vendor/github.com/robertkrimen/otto/parser/regexp.go
new file mode 100644
index 0000000..e6df9fa
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/parser/regexp.go
@@ -0,0 +1,356 @@
+package parser
+
+import (
+ "bytes"
+ "fmt"
+ "strconv"
+)
+
+type _RegExp_parser struct {
+ str string
+ length int
+
+ chr rune // The current character
+ chrOffset int // The offset of current character
+ offset int // The offset after current character (may be greater than 1)
+
+ errors []error
+ invalid bool // The input is an invalid JavaScript RegExp
+
+ goRegexp *bytes.Buffer
+}
+
+// TransformRegExp transforms a JavaScript pattern into a Go "regexp" pattern.
+//
+// re2 (Go) cannot do backtracking, so the presence of a lookahead (?=) (?!) or
+// backreference (\1, \2, ...) will cause an error.
+//
+// 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.
+//
+// If the pattern is invalid (not valid even in JavaScript), then this function
+// returns the empty string and an error.
+//
+// If the pattern is valid, but incompatible (contains a lookahead or backreference),
+// then this function returns the transformation (a non-empty string) AND an error.
+func TransformRegExp(pattern string) (string, error) {
+ if pattern == "" {
+ return "", nil
+ }
+
+ // TODO If without \, if without (?=, (?!, then another shortcut
+
+ parser := _RegExp_parser{
+ str: pattern,
+ length: len(pattern),
+ goRegexp: bytes.NewBuffer(make([]byte, 0, 3*len(pattern)/2)),
+ }
+ parser.read() // Pull in the first character
+ parser.scan()
+ var err error
+ if len(parser.errors) > 0 {
+ err = parser.errors[0]
+ }
+ if parser.invalid {
+ return "", err
+ }
+
+ // Might not be re2 compatible, but is still a valid JavaScript RegExp
+ return parser.goRegexp.String(), err
+}
+
+func (self *_RegExp_parser) scan() {
+ for self.chr != -1 {
+ switch self.chr {
+ case '\\':
+ self.read()
+ self.scanEscape(false)
+ case '(':
+ self.pass()
+ self.scanGroup()
+ case '[':
+ self.pass()
+ self.scanBracket()
+ case ')':
+ self.error(-1, "Unmatched ')'")
+ self.invalid = true
+ self.pass()
+ default:
+ self.pass()
+ }
+ }
+}
+
+// (...)
+func (self *_RegExp_parser) scanGroup() {
+ str := self.str[self.chrOffset:]
+ if len(str) > 1 { // A possibility of (?= or (?!
+ if str[0] == '?' {
+ if str[1] == '=' || str[1] == '!' {
+ self.error(-1, "re2: Invalid (%s) ", self.str[self.chrOffset:self.chrOffset+2])
+ }
+ }
+ }
+ for self.chr != -1 && self.chr != ')' {
+ switch self.chr {
+ case '\\':
+ self.read()
+ self.scanEscape(false)
+ case '(':
+ self.pass()
+ self.scanGroup()
+ case '[':
+ self.pass()
+ self.scanBracket()
+ default:
+ self.pass()
+ continue
+ }
+ }
+ if self.chr != ')' {
+ self.error(-1, "Unterminated group")
+ self.invalid = true
+ return
+ }
+ self.pass()
+}
+
+// [...]
+func (self *_RegExp_parser) scanBracket() {
+ for self.chr != -1 {
+ if self.chr == ']' {
+ break
+ } else if self.chr == '\\' {
+ self.read()
+ self.scanEscape(true)
+ continue
+ }
+ self.pass()
+ }
+ if self.chr != ']' {
+ self.error(-1, "Unterminated character class")
+ self.invalid = true
+ return
+ }
+ self.pass()
+}
+
+// \...
+func (self *_RegExp_parser) scanEscape(inClass bool) {
+ offset := self.chrOffset
+
+ var length, base uint32
+ switch self.chr {
+ case '0', '1', '2', '3', '4', '5', '6', '7':
+ var value int64
+ size := 0
+ for {
+ digit := int64(digitValue(self.chr))
+ if digit >= 8 {
+ // Not a valid digit
+ break
+ }
+ value = value*8 + digit
+ self.read()
+ size += 1
+ }
+ if size == 1 { // The number of characters read
+ _, err := self.goRegexp.Write([]byte{'\\', byte(value) + '0'})
+ if err != nil {
+ self.errors = append(self.errors, err)
+ }
+ if value != 0 {
+ // An invalid backreference
+ self.error(-1, "re2: Invalid \\%d ", value)
+ }
+ return
+ }
+ tmp := []byte{'\\', 'x', '0', 0}
+ if value >= 16 {
+ tmp = tmp[0:2]
+ } else {
+ tmp = tmp[0:3]
+ }
+ tmp = strconv.AppendInt(tmp, value, 16)
+ _, err := self.goRegexp.Write(tmp)
+ if err != nil {
+ self.errors = append(self.errors, err)
+ }
+ return
+
+ case '8', '9':
+ size := 0
+ for {
+ digit := digitValue(self.chr)
+ if digit >= 10 {
+ // Not a valid digit
+ break
+ }
+ self.read()
+ size += 1
+ }
+ err := self.goRegexp.WriteByte('\\')
+ if err != nil {
+ self.errors = append(self.errors, err)
+ }
+ _, err = self.goRegexp.WriteString(self.str[offset:self.chrOffset])
+ if err != nil {
+ self.errors = append(self.errors, err)
+ }
+ self.error(-1, "re2: Invalid \\%s ", self.str[offset:self.chrOffset])
+ return
+
+ case 'x':
+ self.read()
+ length, base = 2, 16
+
+ case 'u':
+ self.read()
+ length, base = 4, 16
+
+ case 'b':
+ if inClass {
+ _, err := self.goRegexp.Write([]byte{'\\', 'x', '0', '8'})
+ if err != nil {
+ self.errors = append(self.errors, err)
+ }
+ self.read()
+ return
+ }
+ fallthrough
+
+ case 'B':
+ fallthrough
+
+ case 'd', 'D', 's', 'S', 'w', 'W':
+ // This is slightly broken, because ECMAScript
+ // includes \v in \s, \S, while re2 does not
+ fallthrough
+
+ case '\\':
+ fallthrough
+
+ case 'f', 'n', 'r', 't', 'v':
+ err := self.goRegexp.WriteByte('\\')
+ if err != nil {
+ self.errors = append(self.errors, err)
+ }
+ self.pass()
+ return
+
+ case 'c':
+ self.read()
+ var value int64
+ if 'a' <= self.chr && self.chr <= 'z' {
+ value = int64(self.chr) - 'a' + 1
+ } else if 'A' <= self.chr && self.chr <= 'Z' {
+ value = int64(self.chr) - 'A' + 1
+ } else {
+ err := self.goRegexp.WriteByte('c')
+ if err != nil {
+ self.errors = append(self.errors, err)
+ }
+ return
+ }
+ tmp := []byte{'\\', 'x', '0', 0}
+ if value >= 16 {
+ tmp = tmp[0:2]
+ } else {
+ tmp = tmp[0:3]
+ }
+ tmp = strconv.AppendInt(tmp, value, 16)
+ _, err := self.goRegexp.Write(tmp)
+ if err != nil {
+ self.errors = append(self.errors, err)
+ }
+ self.read()
+ return
+
+ default:
+ // $ is an identifier character, so we have to have
+ // a special case for it here
+ if self.chr == '$' || !isIdentifierPart(self.chr) {
+ // A non-identifier character needs escaping
+ err := self.goRegexp.WriteByte('\\')
+ if err != nil {
+ self.errors = append(self.errors, err)
+ }
+ } else {
+ // Unescape the character for re2
+ }
+ self.pass()
+ return
+ }
+
+ // Otherwise, we're a \u.... or \x...
+ valueOffset := self.chrOffset
+
+ var value uint32
+ {
+ length := length
+ for ; length > 0; length-- {
+ digit := uint32(digitValue(self.chr))
+ if digit >= base {
+ // Not a valid digit
+ goto skip
+ }
+ value = value*base + digit
+ self.read()
+ }
+ }
+
+ if length == 4 {
+ _, err := self.goRegexp.Write([]byte{
+ '\\',
+ 'x',
+ '{',
+ self.str[valueOffset+0],
+ self.str[valueOffset+1],
+ self.str[valueOffset+2],
+ self.str[valueOffset+3],
+ '}',
+ })
+ if err != nil {
+ self.errors = append(self.errors, err)
+ }
+ } else if length == 2 {
+ _, err := self.goRegexp.Write([]byte{
+ '\\',
+ 'x',
+ self.str[valueOffset+0],
+ self.str[valueOffset+1],
+ })
+ if err != nil {
+ self.errors = append(self.errors, err)
+ }
+ } else {
+ // Should never, ever get here...
+ self.error(-1, "re2: Illegal branch in scanEscape")
+ goto skip
+ }
+
+ return
+
+skip:
+ _, err := self.goRegexp.WriteString(self.str[offset:self.chrOffset])
+ if err != nil {
+ self.errors = append(self.errors, err)
+ }
+}
+
+func (self *_RegExp_parser) pass() {
+ if self.chr != -1 {
+ _, err := self.goRegexp.WriteRune(self.chr)
+ if err != nil {
+ self.errors = append(self.errors, err)
+ }
+ }
+ self.read()
+}
+
+// TODO Better error reporting, use the offset, etc.
+func (self *_RegExp_parser) error(offset int, msg string, msgValues ...interface{}) error {
+ err := fmt.Errorf(msg, msgValues...)
+ self.errors = append(self.errors, err)
+ return err
+}
diff --git a/vendor/github.com/robertkrimen/otto/parser/scope.go b/vendor/github.com/robertkrimen/otto/parser/scope.go
new file mode 100644
index 0000000..e1dbdda
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/parser/scope.go
@@ -0,0 +1,44 @@
+package parser
+
+import (
+ "github.com/robertkrimen/otto/ast"
+)
+
+type _scope struct {
+ outer *_scope
+ allowIn bool
+ inIteration bool
+ inSwitch bool
+ inFunction bool
+ declarationList []ast.Declaration
+
+ labels []string
+}
+
+func (self *_parser) openScope() {
+ self.scope = &_scope{
+ outer: self.scope,
+ allowIn: true,
+ }
+}
+
+func (self *_parser) closeScope() {
+ self.scope = self.scope.outer
+}
+
+func (self *_scope) declare(declaration ast.Declaration) {
+ self.declarationList = append(self.declarationList, declaration)
+}
+
+func (self *_scope) hasLabel(name string) bool {
+ for _, label := range self.labels {
+ if label == name {
+ return true
+ }
+ }
+ if self.outer != nil && !self.inFunction {
+ // Crossing a function boundary to look for a label is verboten
+ return self.outer.hasLabel(name)
+ }
+ return false
+}
diff --git a/vendor/github.com/robertkrimen/otto/parser/statement.go b/vendor/github.com/robertkrimen/otto/parser/statement.go
new file mode 100644
index 0000000..12d2716
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/parser/statement.go
@@ -0,0 +1,936 @@
+package parser
+
+import (
+ "github.com/robertkrimen/otto/ast"
+ "github.com/robertkrimen/otto/token"
+)
+
+func (self *_parser) parseBlockStatement() *ast.BlockStatement {
+ node := &ast.BlockStatement{}
+
+ // Find comments before the leading brace
+ if self.mode&StoreComments != 0 {
+ self.comments.CommentMap.AddComments(node, self.comments.FetchAll(), ast.LEADING)
+ self.comments.Unset()
+ }
+
+ node.LeftBrace = self.expect(token.LEFT_BRACE)
+ node.List = self.parseStatementList()
+
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ self.comments.CommentMap.AddComments(node, self.comments.FetchAll(), ast.FINAL)
+ self.comments.AfterBlock()
+ }
+
+ node.RightBrace = self.expect(token.RIGHT_BRACE)
+
+ // Find comments after the trailing brace
+ if self.mode&StoreComments != 0 {
+ self.comments.ResetLineBreak()
+ self.comments.CommentMap.AddComments(node, self.comments.Fetch(), ast.TRAILING)
+ }
+
+ return node
+}
+
+func (self *_parser) parseEmptyStatement() ast.Statement {
+ idx := self.expect(token.SEMICOLON)
+ return &ast.EmptyStatement{Semicolon: idx}
+}
+
+func (self *_parser) parseStatementList() (list []ast.Statement) {
+ for self.token != token.RIGHT_BRACE && self.token != token.EOF {
+ statement := self.parseStatement()
+ list = append(list, statement)
+ }
+
+ return
+}
+
+func (self *_parser) parseStatement() ast.Statement {
+ if self.token == token.EOF {
+ self.errorUnexpectedToken(self.token)
+ return &ast.BadStatement{From: self.idx, To: self.idx + 1}
+ }
+
+ if self.mode&StoreComments != 0 {
+ self.comments.ResetLineBreak()
+ }
+
+ switch self.token {
+ case token.SEMICOLON:
+ return self.parseEmptyStatement()
+ case token.LEFT_BRACE:
+ return self.parseBlockStatement()
+ case token.IF:
+ return self.parseIfStatement()
+ case token.DO:
+ statement := self.parseDoWhileStatement()
+ self.comments.PostProcessNode(statement)
+ return statement
+ case token.WHILE:
+ return self.parseWhileStatement()
+ case token.FOR:
+ return self.parseForOrForInStatement()
+ case token.BREAK:
+ return self.parseBreakStatement()
+ case token.CONTINUE:
+ return self.parseContinueStatement()
+ case token.DEBUGGER:
+ return self.parseDebuggerStatement()
+ case token.WITH:
+ return self.parseWithStatement()
+ case token.VAR:
+ return self.parseVariableStatement()
+ case token.FUNCTION:
+ return self.parseFunctionStatement()
+ case token.SWITCH:
+ return self.parseSwitchStatement()
+ case token.RETURN:
+ return self.parseReturnStatement()
+ case token.THROW:
+ return self.parseThrowStatement()
+ case token.TRY:
+ return self.parseTryStatement()
+ }
+
+ var comments []*ast.Comment
+ if self.mode&StoreComments != 0 {
+ comments = self.comments.FetchAll()
+ }
+
+ expression := self.parseExpression()
+
+ if identifier, isIdentifier := expression.(*ast.Identifier); isIdentifier && self.token == token.COLON {
+ // LabelledStatement
+ colon := self.idx
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ self.next() // :
+
+ label := identifier.Name
+ for _, value := range self.scope.labels {
+ if label == value {
+ self.error(identifier.Idx0(), "Label '%s' already exists", label)
+ }
+ }
+ var labelComments []*ast.Comment
+ if self.mode&StoreComments != 0 {
+ labelComments = self.comments.FetchAll()
+ }
+ self.scope.labels = append(self.scope.labels, label) // Push the label
+ statement := self.parseStatement()
+ self.scope.labels = self.scope.labels[:len(self.scope.labels)-1] // Pop the label
+ exp := &ast.LabelledStatement{
+ Label: identifier,
+ Colon: colon,
+ Statement: statement,
+ }
+ if self.mode&StoreComments != 0 {
+ self.comments.CommentMap.AddComments(exp, labelComments, ast.LEADING)
+ }
+
+ return exp
+ }
+
+ self.optionalSemicolon()
+
+ statement := &ast.ExpressionStatement{
+ Expression: expression,
+ }
+
+ if self.mode&StoreComments != 0 {
+ self.comments.CommentMap.AddComments(statement, comments, ast.LEADING)
+ }
+ return statement
+}
+
+func (self *_parser) parseTryStatement() ast.Statement {
+ var tryComments []*ast.Comment
+ if self.mode&StoreComments != 0 {
+ tryComments = self.comments.FetchAll()
+ }
+ node := &ast.TryStatement{
+ Try: self.expect(token.TRY),
+ Body: self.parseBlockStatement(),
+ }
+ if self.mode&StoreComments != 0 {
+ self.comments.CommentMap.AddComments(node, tryComments, ast.LEADING)
+ self.comments.CommentMap.AddComments(node.Body, self.comments.FetchAll(), ast.TRAILING)
+ }
+
+ if self.token == token.CATCH {
+ catch := self.idx
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ self.next()
+ self.expect(token.LEFT_PARENTHESIS)
+ if self.token != token.IDENTIFIER {
+ self.expect(token.IDENTIFIER)
+ self.nextStatement()
+ return &ast.BadStatement{From: catch, To: self.idx}
+ } else {
+ identifier := self.parseIdentifier()
+ self.expect(token.RIGHT_PARENTHESIS)
+ node.Catch = &ast.CatchStatement{
+ Catch: catch,
+ Parameter: identifier,
+ Body: self.parseBlockStatement(),
+ }
+
+ if self.mode&StoreComments != 0 {
+ self.comments.CommentMap.AddComments(node.Catch.Body, self.comments.FetchAll(), ast.TRAILING)
+ }
+ }
+ }
+
+ if self.token == token.FINALLY {
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ self.next()
+ if self.mode&StoreComments != 0 {
+ tryComments = self.comments.FetchAll()
+ }
+
+ node.Finally = self.parseBlockStatement()
+
+ if self.mode&StoreComments != 0 {
+ self.comments.CommentMap.AddComments(node.Finally, tryComments, ast.LEADING)
+ }
+ }
+
+ if node.Catch == nil && node.Finally == nil {
+ self.error(node.Try, "Missing catch or finally after try")
+ return &ast.BadStatement{From: node.Try, To: node.Body.Idx1()}
+ }
+
+ return node
+}
+
+func (self *_parser) parseFunctionParameterList() *ast.ParameterList {
+ opening := self.expect(token.LEFT_PARENTHESIS)
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ var list []*ast.Identifier
+ for self.token != token.RIGHT_PARENTHESIS && self.token != token.EOF {
+ if self.token != token.IDENTIFIER {
+ self.expect(token.IDENTIFIER)
+ } else {
+ identifier := self.parseIdentifier()
+ list = append(list, identifier)
+ }
+ if self.token != token.RIGHT_PARENTHESIS {
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ self.expect(token.COMMA)
+ }
+ }
+ closing := self.expect(token.RIGHT_PARENTHESIS)
+
+ return &ast.ParameterList{
+ Opening: opening,
+ List: list,
+ Closing: closing,
+ }
+}
+
+func (self *_parser) parseParameterList() (list []string) {
+ for self.token != token.EOF {
+ if self.token != token.IDENTIFIER {
+ self.expect(token.IDENTIFIER)
+ }
+ list = append(list, self.literal)
+ self.next()
+ if self.token != token.EOF {
+ self.expect(token.COMMA)
+ }
+ }
+ return
+}
+
+func (self *_parser) parseFunctionStatement() *ast.FunctionStatement {
+ var comments []*ast.Comment
+ if self.mode&StoreComments != 0 {
+ comments = self.comments.FetchAll()
+ }
+ function := &ast.FunctionStatement{
+ Function: self.parseFunction(true),
+ }
+ if self.mode&StoreComments != 0 {
+ self.comments.CommentMap.AddComments(function, comments, ast.LEADING)
+ }
+
+ return function
+}
+
+func (self *_parser) parseFunction(declaration bool) *ast.FunctionLiteral {
+ node := &ast.FunctionLiteral{
+ Function: self.expect(token.FUNCTION),
+ }
+
+ var name *ast.Identifier
+ if self.token == token.IDENTIFIER {
+ name = self.parseIdentifier()
+ if declaration {
+ self.scope.declare(&ast.FunctionDeclaration{
+ Function: node,
+ })
+ }
+ } else if declaration {
+ // Use expect error handling
+ self.expect(token.IDENTIFIER)
+ }
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ node.Name = name
+ node.ParameterList = self.parseFunctionParameterList()
+ self.parseFunctionBlock(node)
+ node.Source = self.slice(node.Idx0(), node.Idx1())
+
+ return node
+}
+
+func (self *_parser) parseFunctionBlock(node *ast.FunctionLiteral) {
+ {
+ self.openScope()
+ inFunction := self.scope.inFunction
+ self.scope.inFunction = true
+ defer func() {
+ self.scope.inFunction = inFunction
+ self.closeScope()
+ }()
+ node.Body = self.parseBlockStatement()
+ node.DeclarationList = self.scope.declarationList
+ }
+}
+
+func (self *_parser) parseDebuggerStatement() ast.Statement {
+ idx := self.expect(token.DEBUGGER)
+
+ node := &ast.DebuggerStatement{
+ Debugger: idx,
+ }
+ if self.mode&StoreComments != 0 {
+ self.comments.CommentMap.AddComments(node, self.comments.FetchAll(), ast.TRAILING)
+ }
+
+ self.semicolon()
+ return node
+}
+
+func (self *_parser) parseReturnStatement() ast.Statement {
+ idx := self.expect(token.RETURN)
+ var comments []*ast.Comment
+ if self.mode&StoreComments != 0 {
+ comments = self.comments.FetchAll()
+ }
+
+ if !self.scope.inFunction {
+ self.error(idx, "Illegal return statement")
+ self.nextStatement()
+ return &ast.BadStatement{From: idx, To: self.idx}
+ }
+
+ node := &ast.ReturnStatement{
+ Return: idx,
+ }
+
+ if !self.implicitSemicolon && self.token != token.SEMICOLON && self.token != token.RIGHT_BRACE && self.token != token.EOF {
+ node.Argument = self.parseExpression()
+ }
+ if self.mode&StoreComments != 0 {
+ self.comments.CommentMap.AddComments(node, comments, ast.LEADING)
+ }
+
+ self.semicolon()
+
+ return node
+}
+
+func (self *_parser) parseThrowStatement() ast.Statement {
+ var comments []*ast.Comment
+ if self.mode&StoreComments != 0 {
+ comments = self.comments.FetchAll()
+ }
+ idx := self.expect(token.THROW)
+
+ if self.implicitSemicolon {
+ if self.chr == -1 { // Hackish
+ self.error(idx, "Unexpected end of input")
+ } else {
+ self.error(idx, "Illegal newline after throw")
+ }
+ self.nextStatement()
+ return &ast.BadStatement{From: idx, To: self.idx}
+ }
+
+ node := &ast.ThrowStatement{
+ Throw: self.idx,
+ Argument: self.parseExpression(),
+ }
+ if self.mode&StoreComments != 0 {
+ self.comments.CommentMap.AddComments(node, comments, ast.LEADING)
+ }
+
+ self.semicolon()
+
+ return node
+}
+
+func (self *_parser) parseSwitchStatement() ast.Statement {
+ var comments []*ast.Comment
+ if self.mode&StoreComments != 0 {
+ comments = self.comments.FetchAll()
+ }
+ self.expect(token.SWITCH)
+ if self.mode&StoreComments != 0 {
+ comments = append(comments, self.comments.FetchAll()...)
+ }
+ self.expect(token.LEFT_PARENTHESIS)
+ node := &ast.SwitchStatement{
+ Discriminant: self.parseExpression(),
+ Default: -1,
+ }
+ self.expect(token.RIGHT_PARENTHESIS)
+ if self.mode&StoreComments != 0 {
+ comments = append(comments, self.comments.FetchAll()...)
+ }
+
+ self.expect(token.LEFT_BRACE)
+
+ inSwitch := self.scope.inSwitch
+ self.scope.inSwitch = true
+ defer func() {
+ self.scope.inSwitch = inSwitch
+ }()
+
+ for index := 0; self.token != token.EOF; index++ {
+ if self.token == token.RIGHT_BRACE {
+ self.next()
+ break
+ }
+
+ clause := self.parseCaseStatement()
+ if clause.Test == nil {
+ if node.Default != -1 {
+ self.error(clause.Case, "Already saw a default in switch")
+ }
+ node.Default = index
+ }
+ node.Body = append(node.Body, clause)
+ }
+
+ if self.mode&StoreComments != 0 {
+ self.comments.CommentMap.AddComments(node, comments, ast.LEADING)
+ }
+
+ return node
+}
+
+func (self *_parser) parseWithStatement() ast.Statement {
+ var comments []*ast.Comment
+ if self.mode&StoreComments != 0 {
+ comments = self.comments.FetchAll()
+ }
+ self.expect(token.WITH)
+ var withComments []*ast.Comment
+ if self.mode&StoreComments != 0 {
+ withComments = self.comments.FetchAll()
+ }
+
+ self.expect(token.LEFT_PARENTHESIS)
+
+ node := &ast.WithStatement{
+ Object: self.parseExpression(),
+ }
+ self.expect(token.RIGHT_PARENTHESIS)
+
+ if self.mode&StoreComments != 0 {
+ self.comments.CommentMap.AddComments(node, comments, ast.LEADING)
+ self.comments.CommentMap.AddComments(node, withComments, ast.WITH)
+ }
+
+ node.Body = self.parseStatement()
+
+ return node
+}
+
+func (self *_parser) parseCaseStatement() *ast.CaseStatement {
+ node := &ast.CaseStatement{
+ Case: self.idx,
+ }
+
+ var comments []*ast.Comment
+ if self.mode&StoreComments != 0 {
+ comments = self.comments.FetchAll()
+ self.comments.Unset()
+ }
+
+ if self.token == token.DEFAULT {
+ self.next()
+ } else {
+ self.expect(token.CASE)
+ node.Test = self.parseExpression()
+ }
+
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ self.expect(token.COLON)
+
+ for {
+ if self.token == token.EOF ||
+ self.token == token.RIGHT_BRACE ||
+ self.token == token.CASE ||
+ self.token == token.DEFAULT {
+ break
+ }
+ consequent := self.parseStatement()
+ node.Consequent = append(node.Consequent, consequent)
+ }
+
+ // Link the comments to the case statement
+ if self.mode&StoreComments != 0 {
+ self.comments.CommentMap.AddComments(node, comments, ast.LEADING)
+ }
+
+ return node
+}
+
+func (self *_parser) parseIterationStatement() ast.Statement {
+ inIteration := self.scope.inIteration
+ self.scope.inIteration = true
+ defer func() {
+ self.scope.inIteration = inIteration
+ }()
+ return self.parseStatement()
+}
+
+func (self *_parser) parseForIn(into ast.Expression) *ast.ForInStatement {
+ // Already have consumed " in"
+
+ source := self.parseExpression()
+ self.expect(token.RIGHT_PARENTHESIS)
+ body := self.parseIterationStatement()
+
+ forin := &ast.ForInStatement{
+ Into: into,
+ Source: source,
+ Body: body,
+ }
+
+ return forin
+}
+
+func (self *_parser) parseFor(initializer ast.Expression) *ast.ForStatement {
+ // Already have consumed " ;"
+
+ var test, update ast.Expression
+
+ if self.token != token.SEMICOLON {
+ test = self.parseExpression()
+ }
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ self.expect(token.SEMICOLON)
+
+ if self.token != token.RIGHT_PARENTHESIS {
+ update = self.parseExpression()
+ }
+ self.expect(token.RIGHT_PARENTHESIS)
+ body := self.parseIterationStatement()
+
+ forstatement := &ast.ForStatement{
+ Initializer: initializer,
+ Test: test,
+ Update: update,
+ Body: body,
+ }
+
+ return forstatement
+}
+
+func (self *_parser) parseForOrForInStatement() ast.Statement {
+ var comments []*ast.Comment
+ if self.mode&StoreComments != 0 {
+ comments = self.comments.FetchAll()
+ }
+ idx := self.expect(token.FOR)
+ var forComments []*ast.Comment
+ if self.mode&StoreComments != 0 {
+ forComments = self.comments.FetchAll()
+ }
+ self.expect(token.LEFT_PARENTHESIS)
+
+ var left []ast.Expression
+
+ forIn := false
+ if self.token != token.SEMICOLON {
+ allowIn := self.scope.allowIn
+ self.scope.allowIn = false
+ if self.token == token.VAR {
+ var_ := self.idx
+ var varComments []*ast.Comment
+ if self.mode&StoreComments != 0 {
+ varComments = self.comments.FetchAll()
+ self.comments.Unset()
+ }
+ self.next()
+ list := self.parseVariableDeclarationList(var_)
+ if len(list) == 1 && self.token == token.IN {
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ self.next() // in
+ forIn = true
+ left = []ast.Expression{list[0]} // There is only one declaration
+ } else {
+ left = list
+ }
+ if self.mode&StoreComments != 0 {
+ self.comments.CommentMap.AddComments(left[0], varComments, ast.LEADING)
+ }
+ } else {
+ left = append(left, self.parseExpression())
+ if self.token == token.IN {
+ self.next()
+ forIn = true
+ }
+ }
+ self.scope.allowIn = allowIn
+ }
+
+ if forIn {
+ switch left[0].(type) {
+ case *ast.Identifier, *ast.DotExpression, *ast.BracketExpression, *ast.VariableExpression:
+ // These are all acceptable
+ default:
+ self.error(idx, "Invalid left-hand side in for-in")
+ self.nextStatement()
+ return &ast.BadStatement{From: idx, To: self.idx}
+ }
+
+ forin := self.parseForIn(left[0])
+ if self.mode&StoreComments != 0 {
+ self.comments.CommentMap.AddComments(forin, comments, ast.LEADING)
+ self.comments.CommentMap.AddComments(forin, forComments, ast.FOR)
+ }
+ return forin
+ }
+
+ if self.mode&StoreComments != 0 {
+ self.comments.Unset()
+ }
+ self.expect(token.SEMICOLON)
+ initializer := &ast.SequenceExpression{Sequence: left}
+ forstatement := self.parseFor(initializer)
+ if self.mode&StoreComments != 0 {
+ self.comments.CommentMap.AddComments(forstatement, comments, ast.LEADING)
+ self.comments.CommentMap.AddComments(forstatement, forComments, ast.FOR)
+ }
+ return forstatement
+}
+
+func (self *_parser) parseVariableStatement() *ast.VariableStatement {
+ var comments []*ast.Comment
+ if self.mode&StoreComments != 0 {
+ comments = self.comments.FetchAll()
+ }
+ idx := self.expect(token.VAR)
+
+ list := self.parseVariableDeclarationList(idx)
+
+ statement := &ast.VariableStatement{
+ Var: idx,
+ List: list,
+ }
+ if self.mode&StoreComments != 0 {
+ self.comments.CommentMap.AddComments(statement, comments, ast.LEADING)
+ self.comments.Unset()
+ }
+ self.semicolon()
+
+ return statement
+}
+
+func (self *_parser) parseDoWhileStatement() ast.Statement {
+ inIteration := self.scope.inIteration
+ self.scope.inIteration = true
+ defer func() {
+ self.scope.inIteration = inIteration
+ }()
+
+ var comments []*ast.Comment
+ if self.mode&StoreComments != 0 {
+ comments = self.comments.FetchAll()
+ }
+ self.expect(token.DO)
+ var doComments []*ast.Comment
+ if self.mode&StoreComments != 0 {
+ doComments = self.comments.FetchAll()
+ }
+
+ node := &ast.DoWhileStatement{}
+ if self.token == token.LEFT_BRACE {
+ node.Body = self.parseBlockStatement()
+ } else {
+ node.Body = self.parseStatement()
+ }
+
+ self.expect(token.WHILE)
+ var whileComments []*ast.Comment
+ if self.mode&StoreComments != 0 {
+ whileComments = self.comments.FetchAll()
+ }
+ self.expect(token.LEFT_PARENTHESIS)
+ node.Test = self.parseExpression()
+ self.expect(token.RIGHT_PARENTHESIS)
+
+ self.implicitSemicolon = true
+ self.optionalSemicolon()
+
+ if self.mode&StoreComments != 0 {
+ self.comments.CommentMap.AddComments(node, comments, ast.LEADING)
+ self.comments.CommentMap.AddComments(node, doComments, ast.DO)
+ self.comments.CommentMap.AddComments(node, whileComments, ast.WHILE)
+ }
+
+ return node
+}
+
+func (self *_parser) parseWhileStatement() ast.Statement {
+ var comments []*ast.Comment
+ if self.mode&StoreComments != 0 {
+ comments = self.comments.FetchAll()
+ }
+ self.expect(token.WHILE)
+
+ var whileComments []*ast.Comment
+ if self.mode&StoreComments != 0 {
+ whileComments = self.comments.FetchAll()
+ }
+
+ self.expect(token.LEFT_PARENTHESIS)
+ node := &ast.WhileStatement{
+ Test: self.parseExpression(),
+ }
+ self.expect(token.RIGHT_PARENTHESIS)
+ node.Body = self.parseIterationStatement()
+
+ if self.mode&StoreComments != 0 {
+ self.comments.CommentMap.AddComments(node, comments, ast.LEADING)
+ self.comments.CommentMap.AddComments(node, whileComments, ast.WHILE)
+ }
+
+ return node
+}
+
+func (self *_parser) parseIfStatement() ast.Statement {
+ var comments []*ast.Comment
+ if self.mode&StoreComments != 0 {
+ comments = self.comments.FetchAll()
+ }
+ self.expect(token.IF)
+ var ifComments []*ast.Comment
+ if self.mode&StoreComments != 0 {
+ ifComments = self.comments.FetchAll()
+ }
+
+ self.expect(token.LEFT_PARENTHESIS)
+ node := &ast.IfStatement{
+ If: self.idx,
+ Test: self.parseExpression(),
+ }
+ self.expect(token.RIGHT_PARENTHESIS)
+ if self.token == token.LEFT_BRACE {
+ node.Consequent = self.parseBlockStatement()
+ } else {
+ node.Consequent = self.parseStatement()
+ }
+
+ if self.token == token.ELSE {
+ self.next()
+ node.Alternate = self.parseStatement()
+ }
+
+ if self.mode&StoreComments != 0 {
+ self.comments.CommentMap.AddComments(node, comments, ast.LEADING)
+ self.comments.CommentMap.AddComments(node, ifComments, ast.IF)
+ }
+
+ return node
+}
+
+func (self *_parser) parseSourceElement() ast.Statement {
+ statement := self.parseStatement()
+ return statement
+}
+
+func (self *_parser) parseSourceElements() []ast.Statement {
+ body := []ast.Statement(nil)
+
+ for {
+ if self.token != token.STRING {
+ break
+ }
+ body = append(body, self.parseSourceElement())
+ }
+
+ for self.token != token.EOF {
+ body = append(body, self.parseSourceElement())
+ }
+
+ return body
+}
+
+func (self *_parser) parseProgram() *ast.Program {
+ self.openScope()
+ defer self.closeScope()
+ return &ast.Program{
+ Body: self.parseSourceElements(),
+ DeclarationList: self.scope.declarationList,
+ File: self.file,
+ }
+}
+
+func (self *_parser) parseBreakStatement() ast.Statement {
+ var comments []*ast.Comment
+ if self.mode&StoreComments != 0 {
+ comments = self.comments.FetchAll()
+ }
+ idx := self.expect(token.BREAK)
+ semicolon := self.implicitSemicolon
+ if self.token == token.SEMICOLON {
+ semicolon = true
+ self.next()
+ }
+
+ if semicolon || self.token == token.RIGHT_BRACE {
+ self.implicitSemicolon = false
+ if !self.scope.inIteration && !self.scope.inSwitch {
+ goto illegal
+ }
+ breakStatement := &ast.BranchStatement{
+ Idx: idx,
+ Token: token.BREAK,
+ }
+
+ if self.mode&StoreComments != 0 {
+ self.comments.CommentMap.AddComments(breakStatement, comments, ast.LEADING)
+ self.comments.CommentMap.AddComments(breakStatement, self.comments.FetchAll(), ast.TRAILING)
+ }
+
+ return breakStatement
+ }
+
+ if self.token == token.IDENTIFIER {
+ identifier := self.parseIdentifier()
+ if !self.scope.hasLabel(identifier.Name) {
+ self.error(idx, "Undefined label '%s'", identifier.Name)
+ return &ast.BadStatement{From: idx, To: identifier.Idx1()}
+ }
+ self.semicolon()
+ breakStatement := &ast.BranchStatement{
+ Idx: idx,
+ Token: token.BREAK,
+ Label: identifier,
+ }
+ if self.mode&StoreComments != 0 {
+ self.comments.CommentMap.AddComments(breakStatement, comments, ast.LEADING)
+ }
+
+ return breakStatement
+ }
+
+ self.expect(token.IDENTIFIER)
+
+illegal:
+ self.error(idx, "Illegal break statement")
+ self.nextStatement()
+ return &ast.BadStatement{From: idx, To: self.idx}
+}
+
+func (self *_parser) parseContinueStatement() ast.Statement {
+ idx := self.expect(token.CONTINUE)
+ semicolon := self.implicitSemicolon
+ if self.token == token.SEMICOLON {
+ semicolon = true
+ self.next()
+ }
+
+ if semicolon || self.token == token.RIGHT_BRACE {
+ self.implicitSemicolon = false
+ if !self.scope.inIteration {
+ goto illegal
+ }
+ return &ast.BranchStatement{
+ Idx: idx,
+ Token: token.CONTINUE,
+ }
+ }
+
+ if self.token == token.IDENTIFIER {
+ identifier := self.parseIdentifier()
+ if !self.scope.hasLabel(identifier.Name) {
+ self.error(idx, "Undefined label '%s'", identifier.Name)
+ return &ast.BadStatement{From: idx, To: identifier.Idx1()}
+ }
+ if !self.scope.inIteration {
+ goto illegal
+ }
+ self.semicolon()
+ return &ast.BranchStatement{
+ Idx: idx,
+ Token: token.CONTINUE,
+ Label: identifier,
+ }
+ }
+
+ self.expect(token.IDENTIFIER)
+
+illegal:
+ self.error(idx, "Illegal continue statement")
+ self.nextStatement()
+ return &ast.BadStatement{From: idx, To: self.idx}
+}
+
+// Find the next statement after an error (recover)
+func (self *_parser) nextStatement() {
+ for {
+ switch self.token {
+ case token.BREAK, token.CONTINUE,
+ token.FOR, token.IF, token.RETURN, token.SWITCH,
+ token.VAR, token.DO, token.TRY, token.WITH,
+ token.WHILE, token.THROW, token.CATCH, token.FINALLY:
+ // Return only if parser made some progress since last
+ // sync or if it has not reached 10 next calls without
+ // progress. Otherwise consume at least one token to
+ // avoid an endless parser loop
+ if self.idx == self.recover.idx && self.recover.count < 10 {
+ self.recover.count++
+ return
+ }
+ if self.idx > self.recover.idx {
+ self.recover.idx = self.idx
+ self.recover.count = 0
+ return
+ }
+ // Reaching here indicates a parser bug, likely an
+ // incorrect token list in this function, but it only
+ // leads to skipping of possibly correct code if a
+ // previous error is present, and thus is preferred
+ // over a non-terminating parse.
+ case token.EOF:
+ return
+ }
+ self.next()
+ }
+}
diff --git a/vendor/github.com/robertkrimen/otto/property.go b/vendor/github.com/robertkrimen/otto/property.go
new file mode 100644
index 0000000..23ea258
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/property.go
@@ -0,0 +1,219 @@
+package otto
+
+// property
+
+type _propertyMode int
+
+const (
+ modeWriteMask _propertyMode = 0700
+ modeEnumerateMask = 0070
+ modeConfigureMask = 0007
+ modeOnMask = 0111
+ 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/vendor/github.com/robertkrimen/otto/registry/README.markdown b/vendor/github.com/robertkrimen/otto/registry/README.markdown
new file mode 100644
index 0000000..ba2d389
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/registry/README.markdown
@@ -0,0 +1,51 @@
+# registry
+--
+ import "github.com/robertkrimen/otto/registry"
+
+Package registry is an expirmental package to facillitate altering the otto
+runtime via import.
+
+This interface can change at any time.
+
+## Usage
+
+#### func Apply
+
+```go
+func Apply(callback func(Entry))
+```
+
+#### type Entry
+
+```go
+type Entry struct {
+}
+```
+
+
+#### func Register
+
+```go
+func Register(source func() string) *Entry
+```
+
+#### func (*Entry) Disable
+
+```go
+func (self *Entry) Disable()
+```
+
+#### func (*Entry) Enable
+
+```go
+func (self *Entry) Enable()
+```
+
+#### func (Entry) Source
+
+```go
+func (self Entry) Source() string
+```
+
+--
+**godocdown** http://github.com/robertkrimen/godocdown
diff --git a/vendor/github.com/robertkrimen/otto/registry/registry.go b/vendor/github.com/robertkrimen/otto/registry/registry.go
new file mode 100644
index 0000000..966638a
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/registry/registry.go
@@ -0,0 +1,47 @@
+/*
+Package registry is an expirmental package to facillitate altering the otto runtime via import.
+
+This interface can change at any time.
+*/
+package registry
+
+var registry []*Entry = make([]*Entry, 0)
+
+type Entry struct {
+ active bool
+ source func() string
+}
+
+func newEntry(source func() string) *Entry {
+ return &Entry{
+ active: true,
+ source: source,
+ }
+}
+
+func (self *Entry) Enable() {
+ self.active = true
+}
+
+func (self *Entry) Disable() {
+ self.active = false
+}
+
+func (self Entry) Source() string {
+ return self.source()
+}
+
+func Apply(callback func(Entry)) {
+ for _, entry := range registry {
+ if !entry.active {
+ continue
+ }
+ callback(*entry)
+ }
+}
+
+func Register(source func() string) *Entry {
+ entry := newEntry(source)
+ registry = append(registry, entry)
+ return entry
+}
diff --git a/vendor/github.com/robertkrimen/otto/result.go b/vendor/github.com/robertkrimen/otto/result.go
new file mode 100644
index 0000000..4daa923
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/result.go
@@ -0,0 +1,28 @@
+package otto
+
+type _resultKind int
+
+const (
+ _ _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/vendor/github.com/robertkrimen/otto/runtime.go b/vendor/github.com/robertkrimen/otto/runtime.go
new file mode 100644
index 0000000..cfdbb1e
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/runtime.go
@@ -0,0 +1,879 @@
+package otto
+
+import (
+ "encoding"
+ "encoding/json"
+ "errors"
+ "fmt"
+ "math"
+ "path"
+ "reflect"
+ "runtime"
+ "strconv"
+ "strings"
+ "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
+ debugger func(*Otto)
+ random func() float64
+ stackLimit int
+ traceLimit int
+
+ labels []string // FIXME
+ lck sync.Mutex
+}
+
+func (self *_runtime) enterScope(scope *_scope) {
+ scope.outer = self.scope
+ if self.scope != nil {
+ if self.stackLimit != 0 && self.scope.depth+1 >= self.stackLimit {
+ panic(self.panicRangeError("Maximum call stack size exceeded"))
+ }
+
+ scope.depth = self.scope.depth + 1
+ }
+
+ 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.newErrorObjectError(caught))
+ case Value:
+ exception = true
+ tryValue = caught
+ default:
+ exception = true
+ tryValue = toValue(caught)
+ }
+ }
+ }()
+
+ return inner(), false
+}
+
+// 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:
+ return false, true
+ case valueObject:
+ return true, false
+ default:
+ panic("this should never happen")
+ }
+}
+
+func (self *_runtime) safeToValue(value interface{}) (Value, error) {
+ result := Value{}
+ err := catchPanic(func() {
+ result = self.toValue(value)
+ })
+ return result, err
+}
+
+// convertNumeric converts numeric parameter val from js to that of type t if it is safe to do so, otherwise it panics.
+// This allows literals (int64), bitwise values (int32) and the general form (float64) of javascript numerics to be passed as parameters to go functions easily.
+func (self *_runtime) convertNumeric(v Value, t reflect.Type) reflect.Value {
+ val := reflect.ValueOf(v.export())
+
+ if val.Kind() == t.Kind() {
+ return val
+ }
+
+ if val.Kind() == reflect.Interface {
+ val = reflect.ValueOf(val.Interface())
+ }
+
+ switch val.Kind() {
+ case reflect.Float32, reflect.Float64:
+ f64 := val.Float()
+ switch t.Kind() {
+ case reflect.Float64:
+ return reflect.ValueOf(f64)
+ case reflect.Float32:
+ if reflect.Zero(t).OverflowFloat(f64) {
+ panic(self.panicRangeError("converting float64 to float32 would overflow"))
+ }
+
+ return val.Convert(t)
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
+ i64 := int64(f64)
+ if float64(i64) != f64 {
+ panic(self.panicRangeError(fmt.Sprintf("converting %v to %v would cause loss of precision", val.Type(), t)))
+ }
+
+ // The float represents an integer
+ val = reflect.ValueOf(i64)
+ default:
+ panic(self.panicTypeError(fmt.Sprintf("cannot convert %v to %v", val.Type(), t)))
+ }
+ }
+
+ switch val.Kind() {
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ i64 := val.Int()
+ switch t.Kind() {
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ if reflect.Zero(t).OverflowInt(i64) {
+ panic(self.panicRangeError(fmt.Sprintf("converting %v to %v would overflow", val.Type(), t)))
+ }
+ return val.Convert(t)
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
+ if i64 < 0 {
+ panic(self.panicRangeError(fmt.Sprintf("converting %v to %v would underflow", val.Type(), t)))
+ }
+ if reflect.Zero(t).OverflowUint(uint64(i64)) {
+ panic(self.panicRangeError(fmt.Sprintf("converting %v to %v would overflow", val.Type(), t)))
+ }
+ return val.Convert(t)
+ case reflect.Float32, reflect.Float64:
+ return val.Convert(t)
+ }
+
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
+ u64 := val.Uint()
+ switch t.Kind() {
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ if u64 > math.MaxInt64 || reflect.Zero(t).OverflowInt(int64(u64)) {
+ panic(self.panicRangeError(fmt.Sprintf("converting %v to %v would overflow", val.Type(), t)))
+ }
+ return val.Convert(t)
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
+ if reflect.Zero(t).OverflowUint(u64) {
+ panic(self.panicRangeError(fmt.Sprintf("converting %v to %v would overflow", val.Type(), t)))
+ }
+ return val.Convert(t)
+ case reflect.Float32, reflect.Float64:
+ return val.Convert(t)
+ }
+ }
+
+ panic(self.panicTypeError(fmt.Sprintf("unsupported type %v -> %v for numeric conversion", val.Type(), t)))
+}
+
+func fieldIndexByName(t reflect.Type, name string) []int {
+ for t.Kind() == reflect.Ptr {
+ t = t.Elem()
+ }
+
+ for i := 0; i < t.NumField(); i++ {
+ f := t.Field(i)
+
+ if !validGoStructName(f.Name) {
+ continue
+ }
+
+ if f.Anonymous {
+ for t.Kind() == reflect.Ptr {
+ t = t.Elem()
+ }
+
+ if f.Type.Kind() == reflect.Struct {
+ if a := fieldIndexByName(f.Type, name); a != nil {
+ return append([]int{i}, a...)
+ }
+ }
+ }
+
+ if a := strings.SplitN(f.Tag.Get("json"), ",", 2); a[0] != "" {
+ if a[0] == "-" {
+ continue
+ }
+
+ if a[0] == name {
+ return []int{i}
+ }
+ }
+
+ if f.Name == name {
+ return []int{i}
+ }
+ }
+
+ return nil
+}
+
+var typeOfValue = reflect.TypeOf(Value{})
+var typeOfJSONRawMessage = reflect.TypeOf(json.RawMessage{})
+
+// convertCallParameter converts request val to type t if possible.
+// If the conversion fails due to overflow or type miss-match then it panics.
+// If no conversion is known then the original value is returned.
+func (self *_runtime) convertCallParameter(v Value, t reflect.Type) (reflect.Value, error) {
+ if t == typeOfValue {
+ return reflect.ValueOf(v), nil
+ }
+
+ if t == typeOfJSONRawMessage {
+ if d, err := json.Marshal(v.export()); err == nil {
+ return reflect.ValueOf(d), nil
+ }
+ }
+
+ if v.kind == valueObject {
+ if gso, ok := v._object().value.(*_goStructObject); ok {
+ if gso.value.Type().AssignableTo(t) {
+ // please see TestDynamicFunctionReturningInterface for why this exists
+ if t.Kind() == reflect.Interface && gso.value.Type().ConvertibleTo(t) {
+ return gso.value.Convert(t), nil
+ } else {
+ return gso.value, nil
+ }
+ }
+ }
+
+ if gao, ok := v._object().value.(*_goArrayObject); ok {
+ if gao.value.Type().AssignableTo(t) {
+ // please see TestDynamicFunctionReturningInterface for why this exists
+ if t.Kind() == reflect.Interface && gao.value.Type().ConvertibleTo(t) {
+ return gao.value.Convert(t), nil
+ } else {
+ return gao.value, nil
+ }
+ }
+ }
+ }
+
+ tk := t.Kind()
+
+ if tk == reflect.Interface {
+ e := v.export()
+ if e == nil {
+ return reflect.Zero(t), nil
+ }
+ iv := reflect.ValueOf(e)
+ if iv.Type().AssignableTo(t) {
+ return iv, nil
+ }
+ }
+
+ if tk == reflect.Ptr {
+ switch v.kind {
+ case valueEmpty, valueNull, valueUndefined:
+ return reflect.Zero(t), nil
+ default:
+ var vv reflect.Value
+ vv, err := self.convertCallParameter(v, t.Elem())
+ if err != nil {
+ return reflect.Zero(t), fmt.Errorf("can't convert to %s: %s", t, err.Error())
+ }
+
+ if vv.CanAddr() {
+ return vv.Addr(), nil
+ }
+
+ pv := reflect.New(vv.Type())
+ pv.Elem().Set(vv)
+ return pv, nil
+ }
+ }
+
+ switch tk {
+ case reflect.Bool:
+ return reflect.ValueOf(v.bool()), nil
+ case reflect.String:
+ switch v.kind {
+ case valueString:
+ return reflect.ValueOf(v.value), nil
+ case valueNumber:
+ return reflect.ValueOf(fmt.Sprintf("%v", v.value)), nil
+ }
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Float32, reflect.Float64:
+ switch v.kind {
+ case valueNumber:
+ return self.convertNumeric(v, t), nil
+ }
+ case reflect.Slice:
+ if o := v._object(); o != nil {
+ if lv := o.get(propertyLength); lv.IsNumber() {
+ l := lv.number().int64
+
+ s := reflect.MakeSlice(t, int(l), int(l))
+
+ tt := t.Elem()
+
+ switch o.class {
+ case classArray:
+ for i := int64(0); i < l; i++ {
+ p, ok := o.property[strconv.FormatInt(i, 10)]
+ if !ok {
+ continue
+ }
+
+ e, ok := p.value.(Value)
+ if !ok {
+ continue
+ }
+
+ ev, err := self.convertCallParameter(e, tt)
+ if err != nil {
+ return reflect.Zero(t), fmt.Errorf("couldn't convert element %d of %s: %s", i, t, err.Error())
+ }
+
+ s.Index(int(i)).Set(ev)
+ }
+ case classGoArray, classGoSlice:
+ var gslice bool
+ switch o.value.(type) {
+ case *_goSliceObject:
+ gslice = true
+ case *_goArrayObject:
+ gslice = false
+ }
+
+ for i := int64(0); i < l; i++ {
+ var p *_property
+ if gslice {
+ p = goSliceGetOwnProperty(o, strconv.FormatInt(i, 10))
+ } else {
+ p = goArrayGetOwnProperty(o, strconv.FormatInt(i, 10))
+ }
+ if p == nil {
+ continue
+ }
+
+ e, ok := p.value.(Value)
+ if !ok {
+ continue
+ }
+
+ ev, err := self.convertCallParameter(e, tt)
+ if err != nil {
+ return reflect.Zero(t), fmt.Errorf("couldn't convert element %d of %s: %s", i, t, err.Error())
+ }
+
+ s.Index(int(i)).Set(ev)
+ }
+ }
+
+ return s, nil
+ }
+ }
+ case reflect.Map:
+ if o := v._object(); o != nil && t.Key().Kind() == reflect.String {
+ m := reflect.MakeMap(t)
+
+ var err error
+
+ o.enumerate(false, func(k string) bool {
+ v, verr := self.convertCallParameter(o.get(k), t.Elem())
+ if verr != nil {
+ err = fmt.Errorf("couldn't convert property %q of %s: %s", k, t, verr.Error())
+ return false
+ }
+ m.SetMapIndex(reflect.ValueOf(k), v)
+ return true
+ })
+
+ if err != nil {
+ return reflect.Zero(t), err
+ }
+
+ return m, nil
+ }
+ case reflect.Func:
+ if t.NumOut() > 1 {
+ return reflect.Zero(t), fmt.Errorf("converting JavaScript values to Go functions with more than one return value is currently not supported")
+ }
+
+ if o := v._object(); o != nil && o.class == classFunction {
+ return reflect.MakeFunc(t, func(args []reflect.Value) []reflect.Value {
+ l := make([]interface{}, len(args))
+ for i, a := range args {
+ if a.CanInterface() {
+ l[i] = a.Interface()
+ }
+ }
+
+ rv, err := v.Call(nullValue, l...)
+ if err != nil {
+ panic(err)
+ }
+
+ if t.NumOut() == 0 {
+ return nil
+ }
+
+ r, err := self.convertCallParameter(rv, t.Out(0))
+ if err != nil {
+ panic(self.panicTypeError(err.Error()))
+ }
+
+ return []reflect.Value{r}
+ }), nil
+ }
+ case reflect.Struct:
+ if o := v._object(); o != nil && o.class == classObject {
+ s := reflect.New(t)
+
+ for _, k := range o.propertyOrder {
+ idx := fieldIndexByName(t, k)
+
+ if idx == nil {
+ return reflect.Zero(t), fmt.Errorf("can't convert property %q of %s: field does not exist", k, t)
+ }
+
+ ss := s
+
+ for _, i := range idx {
+ if ss.Kind() == reflect.Ptr {
+ if ss.IsNil() {
+ if !ss.CanSet() {
+ return reflect.Zero(t), fmt.Errorf("can't convert property %q of %s: %s is unexported", k, t, ss.Type().Elem())
+ }
+
+ ss.Set(reflect.New(ss.Type().Elem()))
+ }
+
+ ss = ss.Elem()
+ }
+
+ ss = ss.Field(i)
+ }
+
+ v, err := self.convertCallParameter(o.get(k), ss.Type())
+ if err != nil {
+ return reflect.Zero(t), fmt.Errorf("couldn't convert property %q of %s: %s", k, t, err.Error())
+ }
+
+ ss.Set(v)
+ }
+
+ return s.Elem(), nil
+ }
+ }
+
+ if tk == reflect.String {
+ if o := v._object(); o != nil && o.hasProperty("toString") {
+ if fn := o.get("toString"); fn.IsFunction() {
+ sv, err := fn.Call(v)
+ if err != nil {
+ return reflect.Zero(t), fmt.Errorf("couldn't call toString: %s", err.Error())
+ }
+
+ r, err := self.convertCallParameter(sv, t)
+ if err != nil {
+ return reflect.Zero(t), fmt.Errorf("couldn't convert toString result: %s", err.Error())
+ }
+ return r, nil
+ }
+ }
+
+ return reflect.ValueOf(v.String()), nil
+ }
+
+ if v.kind == valueString {
+ var s encoding.TextUnmarshaler
+
+ if reflect.PtrTo(t).Implements(reflect.TypeOf(&s).Elem()) {
+ r := reflect.New(t)
+
+ if err := r.Interface().(encoding.TextUnmarshaler).UnmarshalText([]byte(v.string())); err != nil {
+ return reflect.Zero(t), fmt.Errorf("can't convert to %s as TextUnmarshaller: %s", t.String(), err.Error())
+ }
+
+ return r.Elem(), nil
+ }
+ }
+
+ s := "OTTO DOES NOT UNDERSTAND THIS TYPE"
+ switch v.kind {
+ case valueBoolean:
+ s = "boolean"
+ case valueNull:
+ s = "null"
+ case valueNumber:
+ s = "number"
+ case valueString:
+ s = "string"
+ case valueUndefined:
+ s = "undefined"
+ case valueObject:
+ s = v.Class()
+ }
+
+ return reflect.Zero(t), fmt.Errorf("can't convert from %q to %q", s, t)
+}
+
+func (self *_runtime) toValue(value interface{}) Value {
+ rv, ok := value.(reflect.Value)
+ if ok {
+ value = rv.Interface()
+ }
+
+ switch value := value.(type) {
+ case Value:
+ return value
+ case func(FunctionCall) Value:
+ var name, file string
+ var line int
+ pc := reflect.ValueOf(value).Pointer()
+ fn := runtime.FuncForPC(pc)
+ if fn != nil {
+ name = fn.Name()
+ file, line = fn.FileLine(pc)
+ file = path.Base(file)
+ }
+ return toValue_object(self.newNativeFunction(name, file, line, value))
+ case _nativeFunction:
+ var name, file string
+ var line int
+ pc := reflect.ValueOf(value).Pointer()
+ fn := runtime.FuncForPC(pc)
+ if fn != nil {
+ name = fn.Name()
+ file, line = fn.FileLine(pc)
+ file = path.Base(file)
+ }
+ return toValue_object(self.newNativeFunction(name, file, line, 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)
+ if ok && value.Kind() == rv.Kind() {
+ // Use passed in rv which may be writable.
+ value = rv
+ }
+
+ 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.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))
+ case reflect.Func:
+ var name, file string
+ var line int
+ if v := reflect.ValueOf(value); v.Kind() == reflect.Ptr {
+ pc := v.Pointer()
+ fn := runtime.FuncForPC(pc)
+ if fn != nil {
+ name = fn.Name()
+ file, line = fn.FileLine(pc)
+ file = path.Base(file)
+ }
+ }
+
+ typ := value.Type()
+
+ return toValue_object(self.newNativeFunction(name, file, line, func(c FunctionCall) Value {
+ nargs := typ.NumIn()
+
+ if len(c.ArgumentList) != nargs {
+ if typ.IsVariadic() {
+ if len(c.ArgumentList) < nargs-1 {
+ panic(self.panicRangeError(fmt.Sprintf("expected at least %d arguments; got %d", nargs-1, len(c.ArgumentList))))
+ }
+ } else {
+ panic(self.panicRangeError(fmt.Sprintf("expected %d argument(s); got %d", nargs, len(c.ArgumentList))))
+ }
+ }
+
+ in := make([]reflect.Value, len(c.ArgumentList))
+
+ callSlice := false
+
+ for i, a := range c.ArgumentList {
+ var t reflect.Type
+
+ n := i
+ if n >= nargs-1 && typ.IsVariadic() {
+ if n > nargs-1 {
+ n = nargs - 1
+ }
+
+ t = typ.In(n).Elem()
+ } else {
+ t = typ.In(n)
+ }
+
+ // if this is a variadic Go function, and the caller has supplied
+ // exactly the number of JavaScript arguments required, and this
+ // is the last JavaScript argument, try treating the it as the
+ // actual set of variadic Go arguments. if that succeeds, break
+ // out of the loop.
+ if typ.IsVariadic() && len(c.ArgumentList) == nargs && i == nargs-1 {
+ if v, err := self.convertCallParameter(a, typ.In(n)); err == nil {
+ in[i] = v
+ callSlice = true
+ break
+ }
+ }
+
+ v, err := self.convertCallParameter(a, t)
+ if err != nil {
+ panic(self.panicTypeError(err.Error()))
+ }
+
+ in[i] = v
+ }
+
+ var out []reflect.Value
+ if callSlice {
+ out = value.CallSlice(in)
+ } else {
+ out = value.Call(in)
+ }
+
+ switch len(out) {
+ case 0:
+ return Value{}
+ case 1:
+ return self.toValue(out[0].Interface())
+ default:
+ s := make([]interface{}, len(out))
+ for i, v := range out {
+ s[i] = self.toValue(v.Interface())
+ }
+
+ return self.toValue(s)
+ }
+ }))
+ }
+ }
+ }
+
+ 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, sm interface{}) (*ast.Program, error) {
+ return parser.ParseFileWithSourceMap(nil, filename, src, sm, 0)
+}
+
+func (runtime *_runtime) cmpl_parse(filename string, src, sm interface{}) (*_nodeProgram, error) {
+ program, err := parser.ParseFileWithSourceMap(nil, filename, src, sm, 0)
+ if err != nil {
+ return nil, err
+ }
+
+ return cmpl_parse(program), nil
+}
+
+func (self *_runtime) parseSource(src, sm 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, sm)
+
+ return nil, program, err
+}
+
+func (self *_runtime) cmpl_runOrEval(src, sm interface{}, eval bool) (Value, error) {
+ result := Value{}
+ cmpl_program, program, err := self.parseSource(src, sm)
+ 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, eval)
+ })
+ switch result.kind {
+ case valueEmpty:
+ result = Value{}
+ case valueReference:
+ result = result.resolve()
+ }
+ return result, err
+}
+
+func (self *_runtime) cmpl_run(src, sm interface{}) (Value, error) {
+ return self.cmpl_runOrEval(src, sm, false)
+}
+
+func (self *_runtime) cmpl_eval(src, sm interface{}) (Value, error) {
+ return self.cmpl_runOrEval(src, sm, true)
+}
+
+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) cmpl_parseOrThrow(src, sm interface{}) *_nodeProgram {
+ program, err := self.cmpl_parse("", src, sm)
+ self.parseThrow(err) // Will panic/throw appropriately
+ return program
+}
diff --git a/vendor/github.com/robertkrimen/otto/scope.go b/vendor/github.com/robertkrimen/otto/scope.go
new file mode 100644
index 0000000..465e6b9
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/scope.go
@@ -0,0 +1,35 @@
+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
+ depth int
+
+ frame _frame
+}
+
+func newScope(lexical _stash, variable _stash, this *_object) *_scope {
+ return &_scope{
+ lexical: lexical,
+ variable: variable,
+ this: this,
+ }
+}
diff --git a/vendor/github.com/robertkrimen/otto/script.go b/vendor/github.com/robertkrimen/otto/script.go
new file mode 100644
index 0000000..8280d41
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/script.go
@@ -0,0 +1,109 @@
+package otto
+
+import (
+ "bytes"
+ "encoding/gob"
+ "errors"
+)
+
+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) {
+ return self.CompileWithSourceMap(filename, src, nil)
+}
+
+// CompileWithSourceMap does the same thing as Compile, but with the obvious
+// difference of applying a source map.
+func (self *Otto) CompileWithSourceMap(filename string, src, sm interface{}) (*Script, error) {
+ program, err := self.runtime.parse(filename, src, sm)
+ if err != nil {
+ return nil, err
+ }
+
+ cmpl_program := cmpl_parse(program)
+
+ script := &Script{
+ version: scriptVersion,
+ program: cmpl_program,
+ filename: filename,
+ src: program.File.Source(),
+ }
+
+ 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) (err error) {
+ decoder := gob.NewDecoder(bytes.NewReader(data))
+ defer func() {
+ if err != nil {
+ self.version = ""
+ self.program = nil
+ self.filename = ""
+ self.src = ""
+ }
+ }()
+ if err = decoder.Decode(&self.version); err != nil {
+ return err
+ }
+ if self.version != scriptVersion {
+ return ErrVersion
+ }
+ if err = decoder.Decode(&self.program); err != nil {
+ return err
+ }
+ if err = decoder.Decode(&self.filename); err != nil {
+ return err
+ }
+ return decoder.Decode(&self.src)
+}
diff --git a/vendor/github.com/robertkrimen/otto/stash.go b/vendor/github.com/robertkrimen/otto/stash.go
new file mode 100644
index 0000000..0d3ffa5
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/stash.go
@@ -0,0 +1,296 @@
+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
+}
+
+func getStashProperties(stash _stash) (keys []string) {
+ switch vars := stash.(type) {
+ case *_dclStash:
+ for k := range vars.property {
+ keys = append(keys, k)
+ }
+ case *_fnStash:
+ for k := range vars.property {
+ keys = append(keys, k)
+ }
+ case *_objectStash:
+ for k := range vars.object.property {
+ keys = append(keys, k)
+ }
+ default:
+ panic("unknown stash type")
+ }
+
+ return
+}
diff --git a/vendor/github.com/robertkrimen/otto/token/Makefile b/vendor/github.com/robertkrimen/otto/token/Makefile
new file mode 100644
index 0000000..1e85c73
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/token/Makefile
@@ -0,0 +1,2 @@
+token_const.go: tokenfmt
+ ./$^ | gofmt > $@
diff --git a/vendor/github.com/robertkrimen/otto/token/README.markdown b/vendor/github.com/robertkrimen/otto/token/README.markdown
new file mode 100644
index 0000000..ff3b161
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/token/README.markdown
@@ -0,0 +1,171 @@
+# token
+--
+ import "github.com/robertkrimen/otto/token"
+
+Package token defines constants representing the lexical tokens of JavaScript
+(ECMA5).
+
+## Usage
+
+```go
+const (
+ ILLEGAL
+ EOF
+ COMMENT
+ KEYWORD
+
+ STRING
+ BOOLEAN
+ NULL
+ NUMBER
+ IDENTIFIER
+
+ PLUS // +
+ MINUS // -
+ MULTIPLY // *
+ SLASH // /
+ REMAINDER // %
+
+ AND // &
+ OR // |
+ EXCLUSIVE_OR // ^
+ SHIFT_LEFT // <<
+ SHIFT_RIGHT // >>
+ UNSIGNED_SHIFT_RIGHT // >>>
+ AND_NOT // &^
+
+ ADD_ASSIGN // +=
+ SUBTRACT_ASSIGN // -=
+ MULTIPLY_ASSIGN // *=
+ QUOTIENT_ASSIGN // /=
+ REMAINDER_ASSIGN // %=
+
+ AND_ASSIGN // &=
+ OR_ASSIGN // |=
+ EXCLUSIVE_OR_ASSIGN // ^=
+ SHIFT_LEFT_ASSIGN // <<=
+ SHIFT_RIGHT_ASSIGN // >>=
+ UNSIGNED_SHIFT_RIGHT_ASSIGN // >>>=
+ AND_NOT_ASSIGN // &^=
+
+ LOGICAL_AND // &&
+ LOGICAL_OR // ||
+ INCREMENT // ++
+ DECREMENT // --
+
+ EQUAL // ==
+ STRICT_EQUAL // ===
+ LESS // <
+ GREATER // >
+ ASSIGN // =
+ NOT // !
+
+ BITWISE_NOT // ~
+
+ NOT_EQUAL // !=
+ STRICT_NOT_EQUAL // !==
+ LESS_OR_EQUAL // <=
+ GREATER_OR_EQUAL // >=
+
+ LEFT_PARENTHESIS // (
+ LEFT_BRACKET // [
+ LEFT_BRACE // {
+ COMMA // ,
+ PERIOD // .
+
+ RIGHT_PARENTHESIS // )
+ RIGHT_BRACKET // ]
+ RIGHT_BRACE // }
+ SEMICOLON // ;
+ COLON // :
+ QUESTION_MARK // ?
+
+ IF
+ IN
+ DO
+
+ VAR
+ FOR
+ NEW
+ TRY
+
+ THIS
+ ELSE
+ CASE
+ VOID
+ WITH
+
+ WHILE
+ BREAK
+ CATCH
+ THROW
+
+ RETURN
+ TYPEOF
+ DELETE
+ SWITCH
+
+ DEFAULT
+ FINALLY
+
+ FUNCTION
+ CONTINUE
+ DEBUGGER
+
+ INSTANCEOF
+)
+```
+
+#### type Token
+
+```go
+type Token int
+```
+
+Token is the set of lexical tokens in JavaScript (ECMA5).
+
+#### func IsKeyword
+
+```go
+func IsKeyword(literal string) (Token, bool)
+```
+IsKeyword returns the keyword token if literal is a keyword, a KEYWORD token if
+the literal is a future keyword (const, let, class, super, ...), or 0 if the
+literal is not a keyword.
+
+If the literal is a keyword, IsKeyword returns a second value indicating if the
+literal is considered a future keyword in strict-mode only.
+
+7.6.1.2 Future Reserved Words:
+
+ const
+ class
+ enum
+ export
+ extends
+ import
+ super
+
+7.6.1.2 Future Reserved Words (strict):
+
+ implements
+ interface
+ let
+ package
+ private
+ protected
+ public
+ static
+
+#### func (Token) String
+
+```go
+func (tkn Token) String() string
+```
+String returns the string corresponding to the token. For operators, delimiters,
+and keywords the string is the actual token string (e.g., for the token PLUS,
+the String() is "+"). For all other tokens the string corresponds to the token
+name (e.g. for the token IDENTIFIER, the string is "IDENTIFIER").
+
+--
+**godocdown** http://github.com/robertkrimen/godocdown
diff --git a/vendor/github.com/robertkrimen/otto/token/token.go b/vendor/github.com/robertkrimen/otto/token/token.go
new file mode 100644
index 0000000..d57c8c0
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/token/token.go
@@ -0,0 +1,113 @@
+// Package token defines constants representing the lexical tokens of JavaScript (ECMA5).
+package token
+
+import (
+ "strconv"
+)
+
+// Token is the set of lexical tokens in JavaScript (ECMA5).
+type Token int
+
+// String returns the string corresponding to the token.
+// For operators, delimiters, and keywords the string is the actual
+// token string (e.g., for the token PLUS, the String() is
+// "+"). For all other tokens the string corresponds to the token
+// name (e.g. for the token IDENTIFIER, the string is "IDENTIFIER").
+func (tkn Token) String() string {
+ if 0 == tkn {
+ return "UNKNOWN"
+ }
+ if tkn < Token(len(token2string)) {
+ return token2string[tkn]
+ }
+ return "token(" + strconv.Itoa(int(tkn)) + ")"
+}
+
+// This is not used for anything
+func (tkn Token) precedence(in bool) int {
+ switch tkn {
+ case LOGICAL_OR:
+ return 1
+
+ case LOGICAL_AND:
+ return 2
+
+ case OR, OR_ASSIGN:
+ return 3
+
+ case EXCLUSIVE_OR:
+ return 4
+
+ case AND, AND_ASSIGN, AND_NOT, AND_NOT_ASSIGN:
+ return 5
+
+ case EQUAL,
+ NOT_EQUAL,
+ STRICT_EQUAL,
+ STRICT_NOT_EQUAL:
+ return 6
+
+ case LESS, GREATER, LESS_OR_EQUAL, GREATER_OR_EQUAL, INSTANCEOF:
+ return 7
+
+ case IN:
+ if in {
+ return 7
+ }
+ return 0
+
+ case SHIFT_LEFT, SHIFT_RIGHT, UNSIGNED_SHIFT_RIGHT:
+ fallthrough
+ case SHIFT_LEFT_ASSIGN, SHIFT_RIGHT_ASSIGN, UNSIGNED_SHIFT_RIGHT_ASSIGN:
+ return 8
+
+ case PLUS, MINUS, ADD_ASSIGN, SUBTRACT_ASSIGN:
+ return 9
+
+ case MULTIPLY, SLASH, REMAINDER, MULTIPLY_ASSIGN, QUOTIENT_ASSIGN, REMAINDER_ASSIGN:
+ return 11
+ }
+ return 0
+}
+
+type _keyword struct {
+ token Token
+ futureKeyword bool
+ strict bool
+}
+
+// IsKeyword returns the keyword token if literal is a keyword, a KEYWORD token
+// if the literal is a future keyword (const, let, class, super, ...), or 0 if the literal is not a keyword.
+//
+// If the literal is a keyword, IsKeyword returns a second value indicating if the literal
+// is considered a future keyword in strict-mode only.
+//
+// 7.6.1.2 Future Reserved Words:
+//
+// const
+// class
+// enum
+// export
+// extends
+// import
+// super
+//
+// 7.6.1.2 Future Reserved Words (strict):
+//
+// implements
+// interface
+// let
+// package
+// private
+// protected
+// public
+// static
+func IsKeyword(literal string) (Token, bool) {
+ if keyword, exists := keywordTable[literal]; exists {
+ if keyword.futureKeyword {
+ return KEYWORD, keyword.strict
+ }
+ return keyword.token, false
+ }
+ return 0, false
+}
diff --git a/vendor/github.com/robertkrimen/otto/token/token_const.go b/vendor/github.com/robertkrimen/otto/token/token_const.go
new file mode 100644
index 0000000..323f4a0
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/token/token_const.go
@@ -0,0 +1,349 @@
+package token
+
+const (
+ _ Token = iota
+
+ ILLEGAL
+ EOF
+ COMMENT
+ KEYWORD
+
+ STRING
+ BOOLEAN
+ NULL
+ NUMBER
+ IDENTIFIER
+
+ PLUS // +
+ MINUS // -
+ MULTIPLY // *
+ SLASH // /
+ REMAINDER // %
+
+ AND // &
+ OR // |
+ EXCLUSIVE_OR // ^
+ SHIFT_LEFT // <<
+ SHIFT_RIGHT // >>
+ UNSIGNED_SHIFT_RIGHT // >>>
+ AND_NOT // &^
+
+ ADD_ASSIGN // +=
+ SUBTRACT_ASSIGN // -=
+ MULTIPLY_ASSIGN // *=
+ QUOTIENT_ASSIGN // /=
+ REMAINDER_ASSIGN // %=
+
+ AND_ASSIGN // &=
+ OR_ASSIGN // |=
+ EXCLUSIVE_OR_ASSIGN // ^=
+ SHIFT_LEFT_ASSIGN // <<=
+ SHIFT_RIGHT_ASSIGN // >>=
+ UNSIGNED_SHIFT_RIGHT_ASSIGN // >>>=
+ AND_NOT_ASSIGN // &^=
+
+ LOGICAL_AND // &&
+ LOGICAL_OR // ||
+ INCREMENT // ++
+ DECREMENT // --
+
+ EQUAL // ==
+ STRICT_EQUAL // ===
+ LESS // <
+ GREATER // >
+ ASSIGN // =
+ NOT // !
+
+ BITWISE_NOT // ~
+
+ NOT_EQUAL // !=
+ STRICT_NOT_EQUAL // !==
+ LESS_OR_EQUAL // <=
+ GREATER_OR_EQUAL // >=
+
+ LEFT_PARENTHESIS // (
+ LEFT_BRACKET // [
+ LEFT_BRACE // {
+ COMMA // ,
+ PERIOD // .
+
+ RIGHT_PARENTHESIS // )
+ RIGHT_BRACKET // ]
+ RIGHT_BRACE // }
+ SEMICOLON // ;
+ COLON // :
+ QUESTION_MARK // ?
+
+ firstKeyword //nolint: deadcode
+ IF
+ IN
+ DO
+
+ VAR
+ FOR
+ NEW
+ TRY
+
+ THIS
+ ELSE
+ CASE
+ VOID
+ WITH
+
+ WHILE
+ BREAK
+ CATCH
+ THROW
+
+ RETURN
+ TYPEOF
+ DELETE
+ SWITCH
+
+ DEFAULT
+ FINALLY
+
+ FUNCTION
+ CONTINUE
+ DEBUGGER
+
+ INSTANCEOF
+ lastKeyword //nolint: deadcode
+)
+
+var token2string = [...]string{
+ ILLEGAL: "ILLEGAL",
+ EOF: "EOF",
+ COMMENT: "COMMENT",
+ KEYWORD: "KEYWORD",
+ STRING: "STRING",
+ BOOLEAN: "BOOLEAN",
+ NULL: "NULL",
+ NUMBER: "NUMBER",
+ IDENTIFIER: "IDENTIFIER",
+ PLUS: "+",
+ MINUS: "-",
+ MULTIPLY: "*",
+ SLASH: "/",
+ REMAINDER: "%",
+ AND: "&",
+ OR: "|",
+ EXCLUSIVE_OR: "^",
+ SHIFT_LEFT: "<<",
+ SHIFT_RIGHT: ">>",
+ UNSIGNED_SHIFT_RIGHT: ">>>",
+ AND_NOT: "&^",
+ ADD_ASSIGN: "+=",
+ SUBTRACT_ASSIGN: "-=",
+ MULTIPLY_ASSIGN: "*=",
+ QUOTIENT_ASSIGN: "/=",
+ REMAINDER_ASSIGN: "%=",
+ AND_ASSIGN: "&=",
+ OR_ASSIGN: "|=",
+ EXCLUSIVE_OR_ASSIGN: "^=",
+ SHIFT_LEFT_ASSIGN: "<<=",
+ SHIFT_RIGHT_ASSIGN: ">>=",
+ UNSIGNED_SHIFT_RIGHT_ASSIGN: ">>>=",
+ AND_NOT_ASSIGN: "&^=",
+ LOGICAL_AND: "&&",
+ LOGICAL_OR: "||",
+ INCREMENT: "++",
+ DECREMENT: "--",
+ EQUAL: "==",
+ STRICT_EQUAL: "===",
+ LESS: "<",
+ GREATER: ">",
+ ASSIGN: "=",
+ NOT: "!",
+ BITWISE_NOT: "~",
+ NOT_EQUAL: "!=",
+ STRICT_NOT_EQUAL: "!==",
+ LESS_OR_EQUAL: "<=",
+ GREATER_OR_EQUAL: ">=",
+ LEFT_PARENTHESIS: "(",
+ LEFT_BRACKET: "[",
+ LEFT_BRACE: "{",
+ COMMA: ",",
+ PERIOD: ".",
+ RIGHT_PARENTHESIS: ")",
+ RIGHT_BRACKET: "]",
+ RIGHT_BRACE: "}",
+ SEMICOLON: ";",
+ COLON: ":",
+ QUESTION_MARK: "?",
+ IF: "if",
+ IN: "in",
+ DO: "do",
+ VAR: "var",
+ FOR: "for",
+ NEW: "new",
+ TRY: "try",
+ THIS: "this",
+ ELSE: "else",
+ CASE: "case",
+ VOID: "void",
+ WITH: "with",
+ WHILE: "while",
+ BREAK: "break",
+ CATCH: "catch",
+ THROW: "throw",
+ RETURN: "return",
+ TYPEOF: "typeof",
+ DELETE: "delete",
+ SWITCH: "switch",
+ DEFAULT: "default",
+ FINALLY: "finally",
+ FUNCTION: "function",
+ CONTINUE: "continue",
+ DEBUGGER: "debugger",
+ INSTANCEOF: "instanceof",
+}
+
+var keywordTable = map[string]_keyword{
+ "if": _keyword{
+ token: IF,
+ },
+ "in": _keyword{
+ token: IN,
+ },
+ "do": _keyword{
+ token: DO,
+ },
+ "var": _keyword{
+ token: VAR,
+ },
+ "for": _keyword{
+ token: FOR,
+ },
+ "new": _keyword{
+ token: NEW,
+ },
+ "try": _keyword{
+ token: TRY,
+ },
+ "this": _keyword{
+ token: THIS,
+ },
+ "else": _keyword{
+ token: ELSE,
+ },
+ "case": _keyword{
+ token: CASE,
+ },
+ "void": _keyword{
+ token: VOID,
+ },
+ "with": _keyword{
+ token: WITH,
+ },
+ "while": _keyword{
+ token: WHILE,
+ },
+ "break": _keyword{
+ token: BREAK,
+ },
+ "catch": _keyword{
+ token: CATCH,
+ },
+ "throw": _keyword{
+ token: THROW,
+ },
+ "return": _keyword{
+ token: RETURN,
+ },
+ "typeof": _keyword{
+ token: TYPEOF,
+ },
+ "delete": _keyword{
+ token: DELETE,
+ },
+ "switch": _keyword{
+ token: SWITCH,
+ },
+ "default": _keyword{
+ token: DEFAULT,
+ },
+ "finally": _keyword{
+ token: FINALLY,
+ },
+ "function": _keyword{
+ token: FUNCTION,
+ },
+ "continue": _keyword{
+ token: CONTINUE,
+ },
+ "debugger": _keyword{
+ token: DEBUGGER,
+ },
+ "instanceof": _keyword{
+ token: INSTANCEOF,
+ },
+ "const": _keyword{
+ token: KEYWORD,
+ futureKeyword: true,
+ },
+ "class": _keyword{
+ token: KEYWORD,
+ futureKeyword: true,
+ },
+ "enum": _keyword{
+ token: KEYWORD,
+ futureKeyword: true,
+ },
+ "export": _keyword{
+ token: KEYWORD,
+ futureKeyword: true,
+ },
+ "extends": _keyword{
+ token: KEYWORD,
+ futureKeyword: true,
+ },
+ "import": _keyword{
+ token: KEYWORD,
+ futureKeyword: true,
+ },
+ "super": _keyword{
+ token: KEYWORD,
+ futureKeyword: true,
+ },
+ "implements": _keyword{
+ token: KEYWORD,
+ futureKeyword: true,
+ strict: true,
+ },
+ "interface": _keyword{
+ token: KEYWORD,
+ futureKeyword: true,
+ strict: true,
+ },
+ "let": _keyword{
+ token: KEYWORD,
+ futureKeyword: true,
+ strict: true,
+ },
+ "package": _keyword{
+ token: KEYWORD,
+ futureKeyword: true,
+ strict: true,
+ },
+ "private": _keyword{
+ token: KEYWORD,
+ futureKeyword: true,
+ strict: true,
+ },
+ "protected": _keyword{
+ token: KEYWORD,
+ futureKeyword: true,
+ strict: true,
+ },
+ "public": _keyword{
+ token: KEYWORD,
+ futureKeyword: true,
+ strict: true,
+ },
+ "static": _keyword{
+ token: KEYWORD,
+ futureKeyword: true,
+ strict: true,
+ },
+}
diff --git a/vendor/github.com/robertkrimen/otto/token/tokenfmt b/vendor/github.com/robertkrimen/otto/token/tokenfmt
new file mode 100644
index 0000000..63dd5d9
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/token/tokenfmt
@@ -0,0 +1,222 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+my (%token, @order, @keywords);
+
+{
+ my $keywords;
+ my @const;
+ push @const, <<_END_;
+package token
+
+const(
+ _ Token = iota
+_END_
+
+ for (split m/\n/, <<_END_) {
+ILLEGAL
+EOF
+COMMENT
+KEYWORD
+
+STRING
+BOOLEAN
+NULL
+NUMBER
+IDENTIFIER
+
+PLUS +
+MINUS -
+MULTIPLY *
+SLASH /
+REMAINDER %
+
+AND &
+OR |
+EXCLUSIVE_OR ^
+SHIFT_LEFT <<
+SHIFT_RIGHT >>
+UNSIGNED_SHIFT_RIGHT >>>
+AND_NOT &^
+
+ADD_ASSIGN +=
+SUBTRACT_ASSIGN -=
+MULTIPLY_ASSIGN *=
+QUOTIENT_ASSIGN /=
+REMAINDER_ASSIGN %=
+
+AND_ASSIGN &=
+OR_ASSIGN |=
+EXCLUSIVE_OR_ASSIGN ^=
+SHIFT_LEFT_ASSIGN <<=
+SHIFT_RIGHT_ASSIGN >>=
+UNSIGNED_SHIFT_RIGHT_ASSIGN >>>=
+AND_NOT_ASSIGN &^=
+
+LOGICAL_AND &&
+LOGICAL_OR ||
+INCREMENT ++
+DECREMENT --
+
+EQUAL ==
+STRICT_EQUAL ===
+LESS <
+GREATER >
+ASSIGN =
+NOT !
+
+BITWISE_NOT ~
+
+NOT_EQUAL !=
+STRICT_NOT_EQUAL !==
+LESS_OR_EQUAL <=
+GREATER_OR_EQUAL <=
+
+LEFT_PARENTHESIS (
+LEFT_BRACKET [
+LEFT_BRACE {
+COMMA ,
+PERIOD .
+
+RIGHT_PARENTHESIS )
+RIGHT_BRACKET ]
+RIGHT_BRACE }
+SEMICOLON ;
+COLON :
+QUESTION_MARK ?
+
+firstKeyword
+IF
+IN
+DO
+
+VAR
+FOR
+NEW
+TRY
+
+THIS
+ELSE
+CASE
+VOID
+WITH
+
+WHILE
+BREAK
+CATCH
+THROW
+
+RETURN
+TYPEOF
+DELETE
+SWITCH
+
+DEFAULT
+FINALLY
+
+FUNCTION
+CONTINUE
+DEBUGGER
+
+INSTANCEOF
+lastKeyword
+_END_
+ chomp;
+
+ next if m/^\s*#/;
+
+ my ($name, $symbol) = m/(\w+)\s*(\S+)?/;
+
+ if (defined $symbol) {
+ push @order, $name;
+ push @const, "$name // $symbol";
+ $token{$name} = $symbol;
+ } elsif (defined $name) {
+ $keywords ||= $name eq 'firstKeyword';
+
+ push @const, $name;
+ #$const[-1] .= " Token = iota" if 2 == @const;
+ if ($name =~ m/^([A-Z]+)/) {
+ push @keywords, $name if $keywords;
+ push @order, $name;
+ if ($token{SEMICOLON}) {
+ $token{$name} = lc $1;
+ } else {
+ $token{$name} = $name;
+ }
+ }
+ } else {
+ push @const, "";
+ }
+
+ }
+ push @const, ")";
+ print join "\n", @const, "";
+}
+
+{
+ print <<_END_;
+
+var token2string = [...]string{
+_END_
+ for my $name (@order) {
+ print "$name: \"$token{$name}\",\n";
+ }
+ print <<_END_;
+}
+_END_
+
+ print <<_END_;
+
+var keywordTable = map[string]_keyword{
+_END_
+ for my $name (@keywords) {
+ print <<_END_
+ "@{[ lc $name ]}": _keyword{
+ token: $name,
+ },
+_END_
+ }
+
+ for my $name (qw/
+ const
+ class
+ enum
+ export
+ extends
+ import
+ super
+ /) {
+ print <<_END_
+ "$name": _keyword{
+ token: KEYWORD,
+ futureKeyword: true,
+ },
+_END_
+ }
+
+ for my $name (qw/
+ implements
+ interface
+ let
+ package
+ private
+ protected
+ public
+ static
+ /) {
+ print <<_END_
+ "$name": _keyword{
+ token: KEYWORD,
+ futureKeyword: true,
+ strict: true,
+ },
+_END_
+ }
+
+ print <<_END_;
+}
+_END_
+}
diff --git a/vendor/github.com/robertkrimen/otto/type_arguments.go b/vendor/github.com/robertkrimen/otto/type_arguments.go
new file mode 100644
index 0000000..0a3ddcb
--- /dev/null
+++ b/vendor/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(propertyLength, 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/vendor/github.com/robertkrimen/otto/type_array.go b/vendor/github.com/robertkrimen/otto/type_array.go
new file mode 100644
index 0000000..67af78a
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/type_array.go
@@ -0,0 +1,118 @@
+package otto
+
+import (
+ "strconv"
+)
+
+func (runtime *_runtime) newArrayObject(length uint32) *_object {
+ self := runtime.newObject()
+ self.class = classArray
+ self.defineProperty(propertyLength, toValue_uint32(length), 0100, false)
+ self.objectClass = _classArray
+ return self
+}
+
+func isArray(object *_object) bool {
+ if object == nil {
+ return false
+ }
+
+ switch object.class {
+ case classArray, classGoArray, classGoSlice:
+ return true
+ default:
+ return false
+ }
+}
+
+func objectLength(object *_object) uint32 {
+ if object == nil {
+ return 0
+ }
+ switch object.class {
+ case classArray:
+ return object.get(propertyLength).value.(uint32)
+ case classString:
+ return uint32(object.get(propertyLength).value.(int))
+ case classGoArray, classGoSlice:
+ return uint32(object.get(propertyLength).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(propertyLength)
+ lengthValue, valid := lengthProperty.value.(Value)
+ if !valid {
+ panic("Array.length != Value{}")
+ }
+ length := lengthValue.value.(uint32)
+ if name == propertyLength {
+ 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--
+ 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, propertyLength, *lengthProperty, false)
+ return true
+ }
+ }
+ return objectDefineOwnProperty(self, name, descriptor, throw)
+Reject:
+ if throw {
+ panic(self.runtime.panicTypeError())
+ }
+ return false
+}
diff --git a/vendor/github.com/robertkrimen/otto/type_boolean.go b/vendor/github.com/robertkrimen/otto/type_boolean.go
new file mode 100644
index 0000000..9710436
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/type_boolean.go
@@ -0,0 +1,5 @@
+package otto
+
+func (runtime *_runtime) newBooleanObject(value Value) *_object {
+ return runtime.newPrimitiveObject(classBoolean, toValue_bool(value.bool()))
+}
diff --git a/vendor/github.com/robertkrimen/otto/type_date.go b/vendor/github.com/robertkrimen/otto/type_date.go
new file mode 100644
index 0000000..9b75068
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/type_date.go
@@ -0,0 +1,287 @@
+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 (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).In(utcTimeZone)
+ return
+}
+
+func timeToEpoch(time Time.Time) float64 {
+ return float64(time.UnixMilli())
+}
+
+func (runtime *_runtime) newDateObject(epoch float64) *_object {
+ self := runtime.newObject()
+ self.class = classDate
+
+ // 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 != classDate {
+ 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
+}
+
+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().In(utcTimeZone)
+ 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
+
+ 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.UnixMilli())
+}
diff --git a/vendor/github.com/robertkrimen/otto/type_error.go b/vendor/github.com/robertkrimen/otto/type_error.go
new file mode 100644
index 0000000..190b2b4
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/type_error.go
@@ -0,0 +1,58 @@
+package otto
+
+func (rt *_runtime) newErrorObject(name string, message Value, stackFramesToPop int) *_object {
+ self := rt.newClassObject(classError)
+ if message.IsDefined() {
+ msg := message.string()
+ self.defineProperty("message", toValue_string(msg), 0111, false)
+ self.value = newError(rt, name, stackFramesToPop, msg)
+ } else {
+ self.value = newError(rt, name, stackFramesToPop)
+ }
+
+ self.defineOwnProperty("stack", _property{
+ value: _propertyGetSet{
+ rt.newNativeFunction("get", "internal", 0, func(FunctionCall) Value {
+ return toValue_string(self.value.(_error).formatWithStack())
+ }),
+ &_nilGetSetObject,
+ },
+ mode: modeConfigureMask & modeOnMask,
+ }, false)
+
+ return self
+}
+
+func (rt *_runtime) newErrorObjectError(err _error) *_object {
+ self := rt.newClassObject(classError)
+ self.defineProperty("message", err.messageValue(), 0111, false)
+ self.value = err
+ switch err.name {
+ case "EvalError":
+ self.prototype = rt.global.EvalErrorPrototype
+ case "TypeError":
+ self.prototype = rt.global.TypeErrorPrototype
+ case "RangeError":
+ self.prototype = rt.global.RangeErrorPrototype
+ case "ReferenceError":
+ self.prototype = rt.global.ReferenceErrorPrototype
+ case "SyntaxError":
+ self.prototype = rt.global.SyntaxErrorPrototype
+ case "URIError":
+ self.prototype = rt.global.URIErrorPrototype
+ default:
+ self.prototype = rt.global.ErrorPrototype
+ }
+
+ self.defineOwnProperty("stack", _property{
+ value: _propertyGetSet{
+ rt.newNativeFunction("get", "internal", 0, func(FunctionCall) Value {
+ return toValue_string(self.value.(_error).formatWithStack())
+ }),
+ &_nilGetSetObject,
+ },
+ mode: modeConfigureMask & modeOnMask,
+ }, false)
+
+ return self
+}
diff --git a/vendor/github.com/robertkrimen/otto/type_function.go b/vendor/github.com/robertkrimen/otto/type_function.go
new file mode 100644
index 0000000..671269b
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/type_function.go
@@ -0,0 +1,338 @@
+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 = classObject
+
+ 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
+ file string
+ line int
+ call _nativeFunction // [[Call]]
+ construct _constructFunction // [[Construct]]
+}
+
+func (runtime *_runtime) _newNativeFunctionObject(name, file string, line int, native _nativeFunction, length int) *_object {
+ self := runtime.newClassObject(classFunction)
+ self.value = _nativeFunctionObject{
+ name: name,
+ file: file,
+ line: line,
+ call: native,
+ construct: defaultConstruct,
+ }
+ self.defineProperty("name", toValue_string(name), 0000, false)
+ self.defineProperty(propertyLength, toValue_int(length), 0000, false)
+ return self
+}
+
+func (runtime *_runtime) newNativeFunctionObject(name, file string, line int, native _nativeFunction, length int) *_object {
+ self := runtime._newNativeFunctionObject(name, file, line, native, length)
+ self.defineOwnProperty("caller", _property{
+ value: _propertyGetSet{
+ runtime._newNativeFunctionObject("get", "internal", 0, func(fc FunctionCall) Value {
+ for sc := runtime.scope; sc != nil; sc = sc.outer {
+ if sc.frame.fn == self {
+ if sc.outer == nil || sc.outer.frame.fn == nil {
+ return nullValue
+ }
+
+ return runtime.toValue(sc.outer.frame.fn)
+ }
+ }
+
+ return nullValue
+ }, 0),
+ &_nilGetSetObject,
+ },
+ mode: 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(classFunction)
+ self.value = _bindFunctionObject{
+ target: target,
+ this: this,
+ argumentList: argumentList,
+ }
+ length := int(toInt32(target.get(propertyLength)))
+ length -= len(argumentList)
+ if length < 0 {
+ length = 0
+ }
+ self.defineProperty("name", toValue_string("bound "+target.get("name").String()), 0000, false)
+ self.defineProperty(propertyLength, 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(classFunction)
+ self.value = _nodeFunctionObject{
+ node: node,
+ stash: stash,
+ }
+ self.defineProperty("name", toValue_string(node.name), 0000, false)
+ self.defineProperty(propertyLength, toValue_int(len(node.parameterList)), 0000, false)
+ self.defineOwnProperty("caller", _property{
+ value: _propertyGetSet{
+ runtime.newNativeFunction("get", "internal", 0, func(fc FunctionCall) Value {
+ for sc := runtime.scope; sc != nil; sc = sc.outer {
+ if sc.frame.fn == self {
+ if sc.outer == nil || sc.outer.frame.fn == nil {
+ return nullValue
+ }
+
+ return runtime.toValue(sc.outer.frame.fn)
+ }
+ }
+
+ return nullValue
+ }),
+ &_nilGetSetObject,
+ },
+ mode: 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:
+ // 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
+ }
+
+ // Enter a scope, name from the native object...
+ rt := self.runtime
+ if rt.scope != nil && !eval {
+ rt.enterFunctionScope(rt.scope.lexical, this)
+ rt.scope.frame = _frame{
+ native: true,
+ nativeFile: fn.file,
+ nativeLine: fn.line,
+ callee: fn.name,
+ file: nil,
+ fn: self,
+ }
+ defer func() {
+ rt.leaveScope()
+ }()
+ }
+
+ 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)
+ rt.scope.frame = _frame{
+ callee: fn.node.name,
+ file: fn.node.file,
+ fn: self,
+ }
+ defer func() {
+ rt.leaveScope()
+ }()
+ 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)
+}
+
+// CallerLocation will return file location information (file:line:pos) where this function is being called.
+func (self FunctionCall) CallerLocation() string {
+ // see error.go for location()
+ return self.runtime.scope.outer.frame.location()
+}
diff --git a/vendor/github.com/robertkrimen/otto/type_go_array.go b/vendor/github.com/robertkrimen/otto/type_go_array.go
new file mode 100644
index 0000000..b9af796
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/type_go_array.go
@@ -0,0 +1,156 @@
+package otto
+
+import (
+ "reflect"
+ "strconv"
+)
+
+func (runtime *_runtime) newGoArrayObject(value reflect.Value) *_object {
+ self := runtime.newObject()
+ self.class = classGoArray
+ 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 || value.CanSet() // 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(name string) (reflect.Value, bool) {
+ if index, err := strconv.ParseInt(name, 10, 64); err != nil {
+ v, ok := self.getValueIndex(index)
+ if ok {
+ return v, ok
+ }
+ }
+
+ if m := self.value.MethodByName(name); m != (reflect.Value{}) {
+ return m, true
+ }
+
+ return reflect.Value{}, false
+}
+
+func (self _goArrayObject) getValueIndex(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.getValueIndex(index)
+ if !exists {
+ return false
+ }
+ reflectValue, err := value.toReflectValue(reflect.Indirect(self.value).Type().Elem())
+ if err != nil {
+ panic(err)
+ }
+ indexValue.Set(reflectValue)
+ return true
+}
+
+func goArrayGetOwnProperty(self *_object, name string) *_property {
+ // length
+ if name == propertyLength {
+ return &_property{
+ value: toValue(reflect.Indirect(self.value.(*_goArrayObject).value).Len()),
+ mode: 0,
+ }
+ }
+
+ // .0, .1, .2, ...
+ if index := stringToArrayIndex(name); index >= 0 {
+ object := self.value.(*_goArrayObject)
+ value := Value{}
+ reflectValue, exists := object.getValueIndex(index)
+ if exists {
+ value = self.runtime.toValue(reflectValue.Interface())
+ }
+ return &_property{
+ value: value,
+ mode: object.propertyMode,
+ }
+ }
+
+ if method := self.value.(*_goArrayObject).value.MethodByName(name); method != (reflect.Value{}) {
+ return &_property{
+ self.runtime.toValue(method.Interface()),
+ 0110,
+ }
+ }
+
+ 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 == propertyLength {
+ 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 == propertyLength {
+ return self.runtime.typeErrorResult(throw)
+ }
+
+ // .0, .1, .2, ...
+ index := stringToArrayIndex(name)
+ if index >= 0 {
+ object := self.value.(*_goArrayObject)
+ if object.writable {
+ indexValue, exists := object.getValueIndex(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/vendor/github.com/robertkrimen/otto/type_go_map.go b/vendor/github.com/robertkrimen/otto/type_go_map.go
new file mode 100644
index 0000000..88ae40b
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/type_go_map.go
@@ -0,0 +1,95 @@
+package otto
+
+import (
+ "reflect"
+)
+
+func (runtime *_runtime) newGoMapObject(value reflect.Value) *_object {
+ self := runtime.newObject()
+ self.class = classObject // TODO Should this be something else?
+ self.objectClass = _classGoMap
+ self.value = _newGoMapObject(value)
+ return self
+}
+
+type _goMapObject struct {
+ value reflect.Value
+ keyType reflect.Type
+ valueType reflect.Type
+}
+
+func _newGoMapObject(value reflect.Value) *_goMapObject {
+ if value.Kind() != reflect.Map {
+ dbgf("%/panic//%@: %v != reflect.Map", value.Kind())
+ }
+ self := &_goMapObject{
+ value: value,
+ keyType: value.Type().Key(),
+ valueType: value.Type().Elem(),
+ }
+ return self
+}
+
+func (self _goMapObject) toKey(name string) reflect.Value {
+ reflectValue, err := stringToReflectValue(name, self.keyType.Kind())
+ if err != nil {
+ panic(err)
+ }
+ return reflectValue
+}
+
+func (self _goMapObject) toValue(value Value) reflect.Value {
+ reflectValue, err := value.toReflectValue(self.valueType)
+ 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}
+ }
+
+ // Other methods
+ if method := self.value.(*_goMapObject).value.MethodByName(name); method.IsValid() {
+ return &_property{
+ value: self.runtime.toValue(method.Interface()),
+ mode: 0110,
+ }
+ }
+
+ 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(toValue(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/vendor/github.com/robertkrimen/otto/type_go_slice.go b/vendor/github.com/robertkrimen/otto/type_go_slice.go
new file mode 100644
index 0000000..6c1253a
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/type_go_slice.go
@@ -0,0 +1,154 @@
+package otto
+
+import (
+ "reflect"
+ "strconv"
+)
+
+func (runtime *_runtime) newGoSliceObject(value reflect.Value) *_object {
+ self := runtime.newObject()
+ self.class = classGoSlice
+ 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) setLength(value Value) {
+ want, err := value.ToInteger()
+ if err != nil {
+ panic(err)
+ }
+
+ wantInt := int(want)
+ switch {
+ case wantInt == self.value.Len():
+ // No change needed.
+ case wantInt < self.value.Cap():
+ // Fits in current capacity.
+ self.value.SetLen(wantInt)
+ default:
+ // Needs expanding.
+ newSlice := reflect.MakeSlice(self.value.Type(), wantInt, wantInt)
+ reflect.Copy(newSlice, self.value)
+ self.value = newSlice
+ }
+}
+
+func (self *_goSliceObject) setValue(index int64, value Value) bool {
+ reflectValue, err := value.toReflectValue(self.value.Type().Elem())
+ if err != nil {
+ panic(err)
+ }
+
+ indexValue, exists := self.getValue(index)
+ if !exists {
+ if int64(self.value.Len()) == index {
+ // Trying to append e.g. slice.push(...), allow it.
+ self.value = reflect.Append(self.value, reflectValue)
+ return true
+ }
+ return false
+ }
+
+ indexValue.Set(reflectValue)
+ return true
+}
+
+func goSliceGetOwnProperty(self *_object, name string) *_property {
+ // length
+ if name == propertyLength {
+ return &_property{
+ value: toValue(self.value.(*_goSliceObject).value.Len()),
+ mode: 0110,
+ }
+ }
+
+ // .0, .1, .2, ...
+ if index := stringToArrayIndex(name); 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,
+ }
+ }
+
+ // Other methods
+ if method := self.value.(*_goSliceObject).value.MethodByName(name); method.IsValid() {
+ return &_property{
+ value: self.runtime.toValue(method.Interface()),
+ 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 == propertyLength {
+ self.value.(*_goSliceObject).setLength(descriptor.value.(Value))
+ return true
+ } 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 == propertyLength {
+ 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/vendor/github.com/robertkrimen/otto/type_go_struct.go b/vendor/github.com/robertkrimen/otto/type_go_struct.go
new file mode 100644
index 0000000..5741b6a
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/type_go_struct.go
@@ -0,0 +1,150 @@
+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 = classObject // 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 idx := fieldIndexByName(reflect.Indirect(self.value).Type(), name); len(idx) > 0 {
+ return reflect.Indirect(self.value).FieldByIndex(idx)
+ }
+
+ if validGoStructName(name) {
+ // Do not reveal hidden or unexported fields.
+ if field := reflect.Indirect(self.value).FieldByName(name); field.IsValid() {
+ return field
+ }
+
+ if method := self.value.MethodByName(name); method.IsValid() {
+ return method
+ }
+ }
+
+ return reflect.Value{}
+}
+
+func (self _goStructObject) fieldIndex(name string) []int {
+ return fieldIndexByName(reflect.Indirect(self.value).Type(), name)
+}
+
+func (self _goStructObject) method(name string) (reflect.Method, bool) {
+ return reflect.Indirect(self.value).Type().MethodByName(name)
+}
+
+func (self _goStructObject) setValue(rt *_runtime, name string, value Value) bool {
+ if idx := fieldIndexByName(reflect.Indirect(self.value).Type(), name); len(idx) == 0 {
+ return false
+ }
+
+ fieldValue := self.getValue(name)
+ converted, err := rt.convertCallParameter(value, fieldValue.Type())
+ if err != nil {
+ panic(rt.panicTypeError(err.Error()))
+ }
+ fieldValue.Set(converted)
+
+ 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), 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(self.runtime, 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/vendor/github.com/robertkrimen/otto/type_number.go b/vendor/github.com/robertkrimen/otto/type_number.go
new file mode 100644
index 0000000..7992480
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/type_number.go
@@ -0,0 +1,5 @@
+package otto
+
+func (runtime *_runtime) newNumberObject(value Value) *_object {
+ return runtime.newPrimitiveObject(classNumber, value.numberValue())
+}
diff --git a/vendor/github.com/robertkrimen/otto/type_reference.go b/vendor/github.com/robertkrimen/otto/type_reference.go
new file mode 100644
index 0000000..8fd23c1
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/type_reference.go
@@ -0,0 +1,94 @@
+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)
+}
+
+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/vendor/github.com/robertkrimen/otto/type_regexp.go b/vendor/github.com/robertkrimen/otto/type_regexp.go
new file mode 100644
index 0000000..c66cac4
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/type_regexp.go
@@ -0,0 +1,140 @@
+package otto
+
+import (
+ "fmt"
+ "regexp"
+
+ "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 = classRegExp
+
+ 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 != classRegExp {
+ 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.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, offset := range result {
+ if offset != -1 {
+ result[index] += int(startIndex)
+ }
+ }
+ if global {
+ 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 {
+ // Find the utf16 index in the string, not the byte index.
+ matchIndex = utf16Length(target[:matchIndex])
+ }
+ 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/vendor/github.com/robertkrimen/otto/type_string.go b/vendor/github.com/robertkrimen/otto/type_string.go
new file mode 100644
index 0000000..f08a618
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/type_string.go
@@ -0,0 +1,114 @@
+package otto
+
+import (
+ "strconv"
+ "unicode/utf16"
+ "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
+ value16 []uint16
+}
+
+func (str _stringWide) Length() int {
+ if str.value16 == nil {
+ str.value16 = utf16.Encode([]rune(str.string))
+ }
+ return len(str.value16)
+}
+
+func (str _stringWide) At(at int) rune {
+ if str.value16 == nil {
+ str.value16 = utf16.Encode([]rune(str.string))
+ }
+ return rune(str.value16[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,
+ }
+}
+
+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(classString)
+ self.defineProperty(propertyLength, 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/vendor/github.com/robertkrimen/otto/value.go b/vendor/github.com/robertkrimen/otto/value.go
new file mode 100644
index 0000000..c55fc95
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/value.go
@@ -0,0 +1,1007 @@
+package otto
+
+import (
+ "encoding/json"
+ "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 (value Value) safe() bool {
+ return value.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 {
+ v, ok := value.value.(*_object)
+ return ok && v.isCall()
+}
+
+// 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 {
+ if function, ok := value.value.(*_object); ok {
+ 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 {
+ if fn, ok := value.value.(*_object); ok {
+ 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 == classFunction
+}
+
+// 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 == classString
+}
+
+func (value Value) isBooleanObject() bool {
+ if value.kind != valueObject {
+ return false
+ }
+ return value.value.(*_object).class == classBoolean
+}
+
+func (value Value) isNumberObject() bool {
+ if value.kind != valueObject {
+ return false
+ }
+ return value.value.(*_object).class == classNumber
+}
+
+func (value Value) isDate() bool {
+ if value.kind != valueObject {
+ return false
+ }
+ return value.value.(*_object).class == classDate
+}
+
+func (value Value) isRegExp() bool {
+ if value.kind != valueObject {
+ return false
+ }
+ return value.value.(*_object).class == classRegExp
+}
+
+func (value Value) isError() bool {
+ if value.kind != valueObject {
+ return false
+ }
+ return value.value.(*_object).class == classError
+}
+
+// ---
+
+func toValue_reflectValuePanic(value interface{}, kind reflect.Kind) {
+ // FIXME?
+ switch kind {
+ case reflect.Struct:
+ panic(newError(nil, "TypeError", 0, "invalid value (struct): missing runtime: %v (%T)", value, value))
+ case reflect.Map:
+ panic(newError(nil, "TypeError", 0, "invalid value (map): missing runtime: %v (%T)", value, value))
+ case reflect.Slice:
+ panic(newError(nil, "TypeError", 0, "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", 0, "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 {
+ if v, ok := value.value.(*_object); ok {
+ return v
+ }
+ 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 {
+ if object, ok := value.value.(*_object); ok {
+ return _newObject(object, value)
+ }
+ return nil
+}
+
+func (value Value) reference() _reference {
+ if value, ok := value.value.(_reference); ok {
+ return value
+ }
+ return nil
+}
+
+func (value Value) resolve() Value {
+ if value, ok := value.value.(_reference); ok {
+ 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 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
+ }
+
+ switch x.kind {
+ case valueUndefined, valueNull:
+ return true
+ case valueNumber:
+ x := x.float64()
+ y := y.float64()
+ if math.IsNaN(x) && math.IsNaN(y) {
+ return true
+ }
+
+ if x == y {
+ if x == 0 {
+ // Since +0 != -0
+ return math.Signbit(x) == math.Signbit(y)
+ }
+ return true
+ }
+ return false
+ case valueString:
+ return x.string() == y.string()
+ case valueBoolean:
+ return x.bool() == y.bool()
+ case valueObject:
+ return x._object() == y._object()
+ default:
+ panic(hereBeDragons())
+ }
+}
+
+func strictEqualityComparison(x Value, y Value) bool {
+ if x.kind != y.kind {
+ return false
+ }
+
+ switch x.kind {
+ case valueUndefined, valueNull:
+ return true
+ case valueNumber:
+ x := x.float64()
+ y := y.float64()
+ if math.IsNaN(x) && math.IsNaN(y) {
+ return false
+ }
+ return x == y
+ case valueString:
+ return x.string() == y.string()
+ case valueBoolean:
+ return x.bool() == y.bool()
+ case valueObject:
+ return x._object() == y._object()
+ default:
+ panic(hereBeDragons())
+ }
+}
+
+// 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 == classArray {
+ result := make([]interface{}, 0)
+ lengthValue := object.get(propertyLength)
+ length := lengthValue.value.(uint32)
+ kind := reflect.Invalid
+ keyKind := reflect.Invalid
+ elemKind := reflect.Invalid
+ state := 0
+ var t reflect.Type
+ for index := uint32(0); index < length; index += 1 {
+ name := strconv.FormatInt(int64(index), 10)
+ if !object.hasProperty(name) {
+ continue
+ }
+ value := object.get(name).export()
+
+ t = reflect.TypeOf(value)
+
+ var k, kk, ek reflect.Kind
+ if t != nil {
+ k = t.Kind()
+ switch k {
+ case reflect.Map:
+ kk = t.Key().Kind()
+ fallthrough
+ case reflect.Array, reflect.Chan, reflect.Ptr, reflect.Slice:
+ ek = t.Elem().Kind()
+ }
+ }
+
+ if state == 0 {
+ kind = k
+ keyKind = kk
+ elemKind = ek
+ state = 1
+ } else if state == 1 && (kind != k || keyKind != kk || elemKind != ek) {
+ state = 2
+ }
+
+ result = append(result, value)
+ }
+
+ if state != 1 || kind == reflect.Interface || t == nil {
+ // No common type
+ return result
+ }
+
+ // Convert to the common type
+ val := reflect.MakeSlice(reflect.SliceOf(t), len(result), len(result))
+ for i, v := range result {
+ val.Index(i).Set(reflect.ValueOf(v))
+ }
+ return val.Interface()
+ } 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
+}
+
+// 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(typ reflect.Type) (reflect.Value, error) {
+ kind := typ.Kind()
+ switch kind {
+ case reflect.Float32, reflect.Float64, reflect.Interface:
+ default:
+ switch value := value.value.(type) {
+ case float32:
+ _, frac := math.Modf(float64(value))
+ if frac > 0 {
+ return reflect.Value{}, fmt.Errorf("RangeError: %v to reflect.Kind: %v", value, kind)
+ }
+ case float64:
+ _, frac := math.Modf(value)
+ if frac > 0 {
+ return reflect.Value{}, fmt.Errorf("RangeError: %v to reflect.Kind: %v", value, kind)
+ }
+ }
+ }
+
+ switch kind {
+ case reflect.Bool: // Bool
+ return reflect.ValueOf(value.bool()).Convert(typ), 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)).Convert(typ), 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)).Convert(typ), 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)).Convert(typ), 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)).Convert(typ), 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)).Convert(typ), 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)).Convert(typ), 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)).Convert(typ), 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)).Convert(typ), 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)).Convert(typ), 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)).Convert(typ), nil
+ }
+ case reflect.Float32: // Float32
+ tmp := value.float64()
+ tmp1 := tmp
+ if 0 > tmp1 {
+ tmp1 = -tmp1
+ }
+ if tmp1 > 0 && (tmp1 < math.SmallestNonzeroFloat32 || tmp1 > math.MaxFloat32) {
+ return reflect.Value{}, fmt.Errorf("RangeError: %f (%v) to float32", tmp, value)
+ } else {
+ return reflect.ValueOf(float32(tmp)).Convert(typ), nil
+ }
+ case reflect.Float64: // Float64
+ value := value.float64()
+ return reflect.ValueOf(float64(value)).Convert(typ), nil
+ case reflect.String: // String
+ return reflect.ValueOf(value.string()).Convert(typ), 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
+ }
+ exported := reflect.ValueOf(value.export())
+ if exported.Type().ConvertibleTo(typ) {
+ return exported.Convert(typ), nil
+ }
+ return reflect.Value{}, fmt.Errorf("TypeError: could not convert %v to reflect.Type: %v", exported, typ)
+ 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.Type: %v", value.kind, value, typ))
+}
+
+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))
+}
+
+func (self Value) MarshalJSON() ([]byte, error) {
+ switch self.kind {
+ case valueUndefined, valueNull:
+ return []byte("null"), nil
+ case valueBoolean, valueNumber:
+ return json.Marshal(self.value)
+ case valueString:
+ return json.Marshal(self.string())
+ case valueObject:
+ return self.Object().MarshalJSON()
+ }
+ return nil, fmt.Errorf("invalid type %v", self.kind)
+}
diff --git a/vendor/github.com/robertkrimen/otto/value_boolean.go b/vendor/github.com/robertkrimen/otto/value_boolean.go
new file mode 100644
index 0000000..b631507
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/value_boolean.go
@@ -0,0 +1,43 @@
+package otto
+
+import (
+ "fmt"
+ "math"
+ "reflect"
+ "unicode/utf16"
+)
+
+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)
+ case []uint16:
+ return 0 != len(utf16.Decode(value))
+ }
+ if value.IsObject() {
+ return true
+ }
+ panic(fmt.Errorf("toBoolean(%T)", value.value))
+}
diff --git a/vendor/github.com/robertkrimen/otto/value_number.go b/vendor/github.com/robertkrimen/otto/value_number.go
new file mode 100644
index 0000000..e2a169c
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/value_number.go
@@ -0,0 +1,335 @@
+package otto
+
+import (
+ "fmt"
+ "math"
+ "regexp"
+ "strconv"
+ "strings"
+)
+
+var stringToNumberParseInteger = regexp.MustCompile(`^(?:0[xX])`)
+
+func parseNumber(value string) float64 {
+ value = strings.Trim(value, builtinString_trim_whitespace)
+
+ 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_32 float64 = 4294967296.0
+ float_2_31 float64 = 2147483648.0
+ float_2_16 float64 = 65536.0
+ sqrt1_2 float64 = math.Sqrt2 / 2
+)
+
+const (
+ maxUint32 = math.MaxUint32
+ maxInt = int(^uint(0) >> 1)
+
+ // int64
+ 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_maxUint float64 = float64(uint(^uint(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 (value Value) number() (number _number) {
+ switch value := value.value.(type) {
+ case int8:
+ number.int64 = int64(value)
+ return
+ case int16:
+ number.int64 = int64(value)
+ return
+ case uint8:
+ number.int64 = int64(value)
+ return
+ case uint16:
+ number.int64 = int64(value)
+ return
+ case uint32:
+ number.int64 = int64(value)
+ return
+ case int:
+ number.int64 = int64(value)
+ return
+ case int64:
+ number.int64 = value
+ return
+ }
+
+ float := value.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
+ }
+
+ var integer float64
+ 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) || floatValue == 0 {
+ return 0
+ }
+
+ // Convert to int64 before int32 to force correct wrapping.
+ return int32(int64(floatValue))
+}
+
+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) || floatValue == 0 {
+ return 0
+ }
+
+ // Convert to int64 before uint32 to force correct wrapping.
+ return uint32(int64(floatValue))
+}
+
+// ECMA 262 - 6.0 - 7.1.8.
+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) || floatValue == 0 {
+ return 0
+ }
+
+ // Convert to int64 before uint16 to force correct wrapping.
+ return uint16(int64(floatValue))
+}
+
+// toIntSign returns sign of a number converted to -1, 0 ,1
+func toIntSign(value Value) int {
+ switch value := value.value.(type) {
+ case int8:
+ if int8(value) > 0 {
+ return 1
+ } else if int8(value) < 0 {
+ return -1
+ }
+
+ return 0
+ case int16:
+ if int16(value) > 0 {
+ return 1
+ } else if int16(value) < 0 {
+ return -1
+ }
+
+ return 0
+ case int32:
+ if int32(value) > 0 {
+ return 1
+ } else if int32(value) < 0 {
+ return -1
+ }
+
+ return 0
+ case uint8:
+ if uint8(value) > 0 {
+ return 1
+ }
+
+ return 0
+ case uint16:
+ if uint16(value) > 0 {
+ return 1
+ }
+
+ return 0
+ case uint32:
+ if uint32(value) > 0 {
+ return 1
+ }
+
+ return 0
+ }
+ floatValue := value.float64()
+ switch {
+ case math.IsNaN(floatValue), math.IsInf(floatValue, 0):
+ return 0
+ case floatValue == 0:
+ return 0
+ case floatValue > 0:
+ return 1
+ default:
+ return -1
+ }
+}
diff --git a/vendor/github.com/robertkrimen/otto/value_primitive.go b/vendor/github.com/robertkrimen/otto/value_primitive.go
new file mode 100644
index 0000000..e76147c
--- /dev/null
+++ b/vendor/github.com/robertkrimen/otto/value_primitive.go
@@ -0,0 +1,19 @@
+package otto
+
+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/vendor/github.com/robertkrimen/otto/value_string.go b/vendor/github.com/robertkrimen/otto/value_string.go
new file mode 100644
index 0000000..0fbfd6b
--- /dev/null
+++ b/vendor/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/vendor/github.com/tylertravisty/go-utils/LICENSE b/vendor/github.com/tylertravisty/go-utils/LICENSE
new file mode 100644
index 0000000..978afcd
--- /dev/null
+++ b/vendor/github.com/tylertravisty/go-utils/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2021 Tyler
+
+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/vendor/github.com/tylertravisty/go-utils/random/random.go b/vendor/github.com/tylertravisty/go-utils/random/random.go
new file mode 100644
index 0000000..3cb1512
--- /dev/null
+++ b/vendor/github.com/tylertravisty/go-utils/random/random.go
@@ -0,0 +1,36 @@
+package random
+
+import (
+ "crypto/rand"
+ "encoding/base64"
+ "fmt"
+)
+
+// Bytes creates an array of random bytes with specified size.
+// If used to generate password salt, then size of 16 bytes (128 bits) is recommended.
+func Bytes(size int) ([]byte, error) {
+ if size < 0 {
+ return nil, fmt.Errorf("random: size cannot be less than zero")
+ }
+ random := make([]byte, size)
+
+ _, err := rand.Read(random)
+ if err != nil {
+ return nil, fmt.Errorf("random: error while reading random bytes: %v", err)
+ }
+
+ return random, nil
+}
+
+// String creates a Base64-encoded string of random bytes with specified length.
+// If used to generate a session token, then length of 48 (36 bytes) is recommended.
+func String(length int) (string, error) {
+ b, err := Bytes(length)
+ if err != nil {
+ return "", fmt.Errorf("random: error while generating random bytes: %v", err)
+ }
+
+ str := base64.URLEncoding.EncodeToString(b)
+
+ return str[:length], nil
+}
diff --git a/vendor/golang.org/x/net/AUTHORS b/vendor/golang.org/x/net/AUTHORS
new file mode 100644
index 0000000..15167cd
--- /dev/null
+++ b/vendor/golang.org/x/net/AUTHORS
@@ -0,0 +1,3 @@
+# This source code refers to The Go Authors for copyright purposes.
+# The master list of authors is in the main Go distribution,
+# visible at http://tip.golang.org/AUTHORS.
diff --git a/vendor/golang.org/x/net/CONTRIBUTORS b/vendor/golang.org/x/net/CONTRIBUTORS
new file mode 100644
index 0000000..1c4577e
--- /dev/null
+++ b/vendor/golang.org/x/net/CONTRIBUTORS
@@ -0,0 +1,3 @@
+# This source code was written by the Go contributors.
+# The master list of contributors is in the main Go distribution,
+# visible at http://tip.golang.org/CONTRIBUTORS.
diff --git a/vendor/golang.org/x/net/LICENSE b/vendor/golang.org/x/net/LICENSE
new file mode 100644
index 0000000..6a66aea
--- /dev/null
+++ b/vendor/golang.org/x/net/LICENSE
@@ -0,0 +1,27 @@
+Copyright (c) 2009 The Go Authors. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/vendor/golang.org/x/net/PATENTS b/vendor/golang.org/x/net/PATENTS
new file mode 100644
index 0000000..7330990
--- /dev/null
+++ b/vendor/golang.org/x/net/PATENTS
@@ -0,0 +1,22 @@
+Additional IP Rights Grant (Patents)
+
+"This implementation" means the copyrightable works distributed by
+Google as part of the Go project.
+
+Google hereby grants to You a perpetual, worldwide, non-exclusive,
+no-charge, royalty-free, irrevocable (except as stated in this section)
+patent license to make, have made, use, offer to sell, sell, import,
+transfer and otherwise run, modify and propagate the contents of this
+implementation of Go, where such license applies only to those patent
+claims, both currently owned or controlled by Google and acquired in
+the future, licensable by Google that are necessarily infringed by this
+implementation of Go. This grant does not include claims that would be
+infringed only as a consequence of further modification of this
+implementation. If you or your agent or exclusive licensee institute or
+order or agree to the institution of patent litigation against any
+entity (including a cross-claim or counterclaim in a lawsuit) alleging
+that this implementation of Go or any code incorporated within this
+implementation of Go constitutes direct or contributory patent
+infringement, or inducement of patent infringement, then any patent
+rights granted to you under this License for this implementation of Go
+shall terminate as of the date such litigation is filed.
diff --git a/vendor/golang.org/x/net/context/context.go b/vendor/golang.org/x/net/context/context.go
new file mode 100644
index 0000000..a3c021d
--- /dev/null
+++ b/vendor/golang.org/x/net/context/context.go
@@ -0,0 +1,56 @@
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package context defines the Context type, which carries deadlines,
+// cancelation signals, and other request-scoped values across API boundaries
+// and between processes.
+// As of Go 1.7 this package is available in the standard library under the
+// name context. https://golang.org/pkg/context.
+//
+// Incoming requests to a server should create a Context, and outgoing calls to
+// servers should accept a Context. The chain of function calls between must
+// propagate the Context, optionally replacing it with a modified copy created
+// using WithDeadline, WithTimeout, WithCancel, or WithValue.
+//
+// Programs that use Contexts should follow these rules to keep interfaces
+// consistent across packages and enable static analysis tools to check context
+// propagation:
+//
+// Do not store Contexts inside a struct type; instead, pass a Context
+// explicitly to each function that needs it. The Context should be the first
+// parameter, typically named ctx:
+//
+// func DoSomething(ctx context.Context, arg Arg) error {
+// // ... use ctx ...
+// }
+//
+// Do not pass a nil Context, even if a function permits it. Pass context.TODO
+// if you are unsure about which Context to use.
+//
+// Use context Values only for request-scoped data that transits processes and
+// APIs, not for passing optional parameters to functions.
+//
+// The same Context may be passed to functions running in different goroutines;
+// Contexts are safe for simultaneous use by multiple goroutines.
+//
+// See http://blog.golang.org/context for example code for a server that uses
+// Contexts.
+package context // import "golang.org/x/net/context"
+
+// Background returns a non-nil, empty Context. It is never canceled, has no
+// values, and has no deadline. It is typically used by the main function,
+// initialization, and tests, and as the top-level Context for incoming
+// requests.
+func Background() Context {
+ return background
+}
+
+// TODO returns a non-nil, empty Context. Code should use context.TODO when
+// it's unclear which Context to use or it is not yet available (because the
+// surrounding function has not yet been extended to accept a Context
+// parameter). TODO is recognized by static analysis tools that determine
+// whether Contexts are propagated correctly in a program.
+func TODO() Context {
+ return todo
+}
diff --git a/vendor/golang.org/x/net/context/go17.go b/vendor/golang.org/x/net/context/go17.go
new file mode 100644
index 0000000..d20f52b
--- /dev/null
+++ b/vendor/golang.org/x/net/context/go17.go
@@ -0,0 +1,72 @@
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build go1.7
+
+package context
+
+import (
+ "context" // standard library's context, as of Go 1.7
+ "time"
+)
+
+var (
+ todo = context.TODO()
+ background = context.Background()
+)
+
+// Canceled is the error returned by Context.Err when the context is canceled.
+var Canceled = context.Canceled
+
+// DeadlineExceeded is the error returned by Context.Err when the context's
+// deadline passes.
+var DeadlineExceeded = context.DeadlineExceeded
+
+// WithCancel returns a copy of parent with a new Done channel. The returned
+// context's Done channel is closed when the returned cancel function is called
+// or when the parent context's Done channel is closed, whichever happens first.
+//
+// Canceling this context releases resources associated with it, so code should
+// call cancel as soon as the operations running in this Context complete.
+func WithCancel(parent Context) (ctx Context, cancel CancelFunc) {
+ ctx, f := context.WithCancel(parent)
+ return ctx, CancelFunc(f)
+}
+
+// WithDeadline returns a copy of the parent context with the deadline adjusted
+// to be no later than d. If the parent's deadline is already earlier than d,
+// WithDeadline(parent, d) is semantically equivalent to parent. The returned
+// context's Done channel is closed when the deadline expires, when the returned
+// cancel function is called, or when the parent context's Done channel is
+// closed, whichever happens first.
+//
+// Canceling this context releases resources associated with it, so code should
+// call cancel as soon as the operations running in this Context complete.
+func WithDeadline(parent Context, deadline time.Time) (Context, CancelFunc) {
+ ctx, f := context.WithDeadline(parent, deadline)
+ return ctx, CancelFunc(f)
+}
+
+// WithTimeout returns WithDeadline(parent, time.Now().Add(timeout)).
+//
+// Canceling this context releases resources associated with it, so code should
+// call cancel as soon as the operations running in this Context complete:
+//
+// func slowOperationWithTimeout(ctx context.Context) (Result, error) {
+// ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond)
+// defer cancel() // releases resources if slowOperation completes before timeout elapses
+// return slowOperation(ctx)
+// }
+func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) {
+ return WithDeadline(parent, time.Now().Add(timeout))
+}
+
+// WithValue returns a copy of parent in which the value associated with key is
+// val.
+//
+// Use context Values only for request-scoped data that transits processes and
+// APIs, not for passing optional parameters to functions.
+func WithValue(parent Context, key interface{}, val interface{}) Context {
+ return context.WithValue(parent, key, val)
+}
diff --git a/vendor/golang.org/x/net/context/go19.go b/vendor/golang.org/x/net/context/go19.go
new file mode 100644
index 0000000..d88bd1d
--- /dev/null
+++ b/vendor/golang.org/x/net/context/go19.go
@@ -0,0 +1,20 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build go1.9
+
+package context
+
+import "context" // standard library's context, as of Go 1.7
+
+// A Context carries a deadline, a cancelation signal, and other values across
+// API boundaries.
+//
+// Context's methods may be called by multiple goroutines simultaneously.
+type Context = context.Context
+
+// A CancelFunc tells an operation to abandon its work.
+// A CancelFunc does not wait for the work to stop.
+// After the first call, subsequent calls to a CancelFunc do nothing.
+type CancelFunc = context.CancelFunc
diff --git a/vendor/golang.org/x/net/context/pre_go17.go b/vendor/golang.org/x/net/context/pre_go17.go
new file mode 100644
index 0000000..0f35592
--- /dev/null
+++ b/vendor/golang.org/x/net/context/pre_go17.go
@@ -0,0 +1,300 @@
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !go1.7
+
+package context
+
+import (
+ "errors"
+ "fmt"
+ "sync"
+ "time"
+)
+
+// An emptyCtx is never canceled, has no values, and has no deadline. It is not
+// struct{}, since vars of this type must have distinct addresses.
+type emptyCtx int
+
+func (*emptyCtx) Deadline() (deadline time.Time, ok bool) {
+ return
+}
+
+func (*emptyCtx) Done() <-chan struct{} {
+ return nil
+}
+
+func (*emptyCtx) Err() error {
+ return nil
+}
+
+func (*emptyCtx) Value(key interface{}) interface{} {
+ return nil
+}
+
+func (e *emptyCtx) String() string {
+ switch e {
+ case background:
+ return "context.Background"
+ case todo:
+ return "context.TODO"
+ }
+ return "unknown empty Context"
+}
+
+var (
+ background = new(emptyCtx)
+ todo = new(emptyCtx)
+)
+
+// Canceled is the error returned by Context.Err when the context is canceled.
+var Canceled = errors.New("context canceled")
+
+// DeadlineExceeded is the error returned by Context.Err when the context's
+// deadline passes.
+var DeadlineExceeded = errors.New("context deadline exceeded")
+
+// WithCancel returns a copy of parent with a new Done channel. The returned
+// context's Done channel is closed when the returned cancel function is called
+// or when the parent context's Done channel is closed, whichever happens first.
+//
+// Canceling this context releases resources associated with it, so code should
+// call cancel as soon as the operations running in this Context complete.
+func WithCancel(parent Context) (ctx Context, cancel CancelFunc) {
+ c := newCancelCtx(parent)
+ propagateCancel(parent, c)
+ return c, func() { c.cancel(true, Canceled) }
+}
+
+// newCancelCtx returns an initialized cancelCtx.
+func newCancelCtx(parent Context) *cancelCtx {
+ return &cancelCtx{
+ Context: parent,
+ done: make(chan struct{}),
+ }
+}
+
+// propagateCancel arranges for child to be canceled when parent is.
+func propagateCancel(parent Context, child canceler) {
+ if parent.Done() == nil {
+ return // parent is never canceled
+ }
+ if p, ok := parentCancelCtx(parent); ok {
+ p.mu.Lock()
+ if p.err != nil {
+ // parent has already been canceled
+ child.cancel(false, p.err)
+ } else {
+ if p.children == nil {
+ p.children = make(map[canceler]bool)
+ }
+ p.children[child] = true
+ }
+ p.mu.Unlock()
+ } else {
+ go func() {
+ select {
+ case <-parent.Done():
+ child.cancel(false, parent.Err())
+ case <-child.Done():
+ }
+ }()
+ }
+}
+
+// parentCancelCtx follows a chain of parent references until it finds a
+// *cancelCtx. This function understands how each of the concrete types in this
+// package represents its parent.
+func parentCancelCtx(parent Context) (*cancelCtx, bool) {
+ for {
+ switch c := parent.(type) {
+ case *cancelCtx:
+ return c, true
+ case *timerCtx:
+ return c.cancelCtx, true
+ case *valueCtx:
+ parent = c.Context
+ default:
+ return nil, false
+ }
+ }
+}
+
+// removeChild removes a context from its parent.
+func removeChild(parent Context, child canceler) {
+ p, ok := parentCancelCtx(parent)
+ if !ok {
+ return
+ }
+ p.mu.Lock()
+ if p.children != nil {
+ delete(p.children, child)
+ }
+ p.mu.Unlock()
+}
+
+// A canceler is a context type that can be canceled directly. The
+// implementations are *cancelCtx and *timerCtx.
+type canceler interface {
+ cancel(removeFromParent bool, err error)
+ Done() <-chan struct{}
+}
+
+// A cancelCtx can be canceled. When canceled, it also cancels any children
+// that implement canceler.
+type cancelCtx struct {
+ Context
+
+ done chan struct{} // closed by the first cancel call.
+
+ mu sync.Mutex
+ children map[canceler]bool // set to nil by the first cancel call
+ err error // set to non-nil by the first cancel call
+}
+
+func (c *cancelCtx) Done() <-chan struct{} {
+ return c.done
+}
+
+func (c *cancelCtx) Err() error {
+ c.mu.Lock()
+ defer c.mu.Unlock()
+ return c.err
+}
+
+func (c *cancelCtx) String() string {
+ return fmt.Sprintf("%v.WithCancel", c.Context)
+}
+
+// cancel closes c.done, cancels each of c's children, and, if
+// removeFromParent is true, removes c from its parent's children.
+func (c *cancelCtx) cancel(removeFromParent bool, err error) {
+ if err == nil {
+ panic("context: internal error: missing cancel error")
+ }
+ c.mu.Lock()
+ if c.err != nil {
+ c.mu.Unlock()
+ return // already canceled
+ }
+ c.err = err
+ close(c.done)
+ for child := range c.children {
+ // NOTE: acquiring the child's lock while holding parent's lock.
+ child.cancel(false, err)
+ }
+ c.children = nil
+ c.mu.Unlock()
+
+ if removeFromParent {
+ removeChild(c.Context, c)
+ }
+}
+
+// WithDeadline returns a copy of the parent context with the deadline adjusted
+// to be no later than d. If the parent's deadline is already earlier than d,
+// WithDeadline(parent, d) is semantically equivalent to parent. The returned
+// context's Done channel is closed when the deadline expires, when the returned
+// cancel function is called, or when the parent context's Done channel is
+// closed, whichever happens first.
+//
+// Canceling this context releases resources associated with it, so code should
+// call cancel as soon as the operations running in this Context complete.
+func WithDeadline(parent Context, deadline time.Time) (Context, CancelFunc) {
+ if cur, ok := parent.Deadline(); ok && cur.Before(deadline) {
+ // The current deadline is already sooner than the new one.
+ return WithCancel(parent)
+ }
+ c := &timerCtx{
+ cancelCtx: newCancelCtx(parent),
+ deadline: deadline,
+ }
+ propagateCancel(parent, c)
+ d := deadline.Sub(time.Now())
+ if d <= 0 {
+ c.cancel(true, DeadlineExceeded) // deadline has already passed
+ return c, func() { c.cancel(true, Canceled) }
+ }
+ c.mu.Lock()
+ defer c.mu.Unlock()
+ if c.err == nil {
+ c.timer = time.AfterFunc(d, func() {
+ c.cancel(true, DeadlineExceeded)
+ })
+ }
+ return c, func() { c.cancel(true, Canceled) }
+}
+
+// A timerCtx carries a timer and a deadline. It embeds a cancelCtx to
+// implement Done and Err. It implements cancel by stopping its timer then
+// delegating to cancelCtx.cancel.
+type timerCtx struct {
+ *cancelCtx
+ timer *time.Timer // Under cancelCtx.mu.
+
+ deadline time.Time
+}
+
+func (c *timerCtx) Deadline() (deadline time.Time, ok bool) {
+ return c.deadline, true
+}
+
+func (c *timerCtx) String() string {
+ return fmt.Sprintf("%v.WithDeadline(%s [%s])", c.cancelCtx.Context, c.deadline, c.deadline.Sub(time.Now()))
+}
+
+func (c *timerCtx) cancel(removeFromParent bool, err error) {
+ c.cancelCtx.cancel(false, err)
+ if removeFromParent {
+ // Remove this timerCtx from its parent cancelCtx's children.
+ removeChild(c.cancelCtx.Context, c)
+ }
+ c.mu.Lock()
+ if c.timer != nil {
+ c.timer.Stop()
+ c.timer = nil
+ }
+ c.mu.Unlock()
+}
+
+// WithTimeout returns WithDeadline(parent, time.Now().Add(timeout)).
+//
+// Canceling this context releases resources associated with it, so code should
+// call cancel as soon as the operations running in this Context complete:
+//
+// func slowOperationWithTimeout(ctx context.Context) (Result, error) {
+// ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond)
+// defer cancel() // releases resources if slowOperation completes before timeout elapses
+// return slowOperation(ctx)
+// }
+func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) {
+ return WithDeadline(parent, time.Now().Add(timeout))
+}
+
+// WithValue returns a copy of parent in which the value associated with key is
+// val.
+//
+// Use context Values only for request-scoped data that transits processes and
+// APIs, not for passing optional parameters to functions.
+func WithValue(parent Context, key interface{}, val interface{}) Context {
+ return &valueCtx{parent, key, val}
+}
+
+// A valueCtx carries a key-value pair. It implements Value for that key and
+// delegates all other calls to the embedded Context.
+type valueCtx struct {
+ Context
+ key, val interface{}
+}
+
+func (c *valueCtx) String() string {
+ return fmt.Sprintf("%v.WithValue(%#v, %#v)", c.Context, c.key, c.val)
+}
+
+func (c *valueCtx) Value(key interface{}) interface{} {
+ if c.key == key {
+ return c.val
+ }
+ return c.Context.Value(key)
+}
diff --git a/vendor/golang.org/x/net/context/pre_go19.go b/vendor/golang.org/x/net/context/pre_go19.go
new file mode 100644
index 0000000..b105f80
--- /dev/null
+++ b/vendor/golang.org/x/net/context/pre_go19.go
@@ -0,0 +1,109 @@
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !go1.9
+
+package context
+
+import "time"
+
+// A Context carries a deadline, a cancelation signal, and other values across
+// API boundaries.
+//
+// Context's methods may be called by multiple goroutines simultaneously.
+type Context interface {
+ // Deadline returns the time when work done on behalf of this context
+ // should be canceled. Deadline returns ok==false when no deadline is
+ // set. Successive calls to Deadline return the same results.
+ Deadline() (deadline time.Time, ok bool)
+
+ // Done returns a channel that's closed when work done on behalf of this
+ // context should be canceled. Done may return nil if this context can
+ // never be canceled. Successive calls to Done return the same value.
+ //
+ // WithCancel arranges for Done to be closed when cancel is called;
+ // WithDeadline arranges for Done to be closed when the deadline
+ // expires; WithTimeout arranges for Done to be closed when the timeout
+ // elapses.
+ //
+ // Done is provided for use in select statements:
+ //
+ // // Stream generates values with DoSomething and sends them to out
+ // // until DoSomething returns an error or ctx.Done is closed.
+ // func Stream(ctx context.Context, out chan<- Value) error {
+ // for {
+ // v, err := DoSomething(ctx)
+ // if err != nil {
+ // return err
+ // }
+ // select {
+ // case <-ctx.Done():
+ // return ctx.Err()
+ // case out <- v:
+ // }
+ // }
+ // }
+ //
+ // See http://blog.golang.org/pipelines for more examples of how to use
+ // a Done channel for cancelation.
+ Done() <-chan struct{}
+
+ // Err returns a non-nil error value after Done is closed. Err returns
+ // Canceled if the context was canceled or DeadlineExceeded if the
+ // context's deadline passed. No other values for Err are defined.
+ // After Done is closed, successive calls to Err return the same value.
+ Err() error
+
+ // Value returns the value associated with this context for key, or nil
+ // if no value is associated with key. Successive calls to Value with
+ // the same key returns the same result.
+ //
+ // Use context values only for request-scoped data that transits
+ // processes and API boundaries, not for passing optional parameters to
+ // functions.
+ //
+ // A key identifies a specific value in a Context. Functions that wish
+ // to store values in Context typically allocate a key in a global
+ // variable then use that key as the argument to context.WithValue and
+ // Context.Value. A key can be any type that supports equality;
+ // packages should define keys as an unexported type to avoid
+ // collisions.
+ //
+ // Packages that define a Context key should provide type-safe accessors
+ // for the values stores using that key:
+ //
+ // // Package user defines a User type that's stored in Contexts.
+ // package user
+ //
+ // import "golang.org/x/net/context"
+ //
+ // // User is the type of value stored in the Contexts.
+ // type User struct {...}
+ //
+ // // key is an unexported type for keys defined in this package.
+ // // This prevents collisions with keys defined in other packages.
+ // type key int
+ //
+ // // userKey is the key for user.User values in Contexts. It is
+ // // unexported; clients use user.NewContext and user.FromContext
+ // // instead of using this key directly.
+ // var userKey key = 0
+ //
+ // // NewContext returns a new Context that carries value u.
+ // func NewContext(ctx context.Context, u *User) context.Context {
+ // return context.WithValue(ctx, userKey, u)
+ // }
+ //
+ // // FromContext returns the User value stored in ctx, if any.
+ // func FromContext(ctx context.Context) (*User, bool) {
+ // u, ok := ctx.Value(userKey).(*User)
+ // return u, ok
+ // }
+ Value(key interface{}) interface{}
+}
+
+// A CancelFunc tells an operation to abandon its work.
+// A CancelFunc does not wait for the work to stop.
+// After the first call, subsequent calls to a CancelFunc do nothing.
+type CancelFunc func()
diff --git a/vendor/golang.org/x/text/LICENSE b/vendor/golang.org/x/text/LICENSE
new file mode 100644
index 0000000..6a66aea
--- /dev/null
+++ b/vendor/golang.org/x/text/LICENSE
@@ -0,0 +1,27 @@
+Copyright (c) 2009 The Go Authors. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/vendor/golang.org/x/text/PATENTS b/vendor/golang.org/x/text/PATENTS
new file mode 100644
index 0000000..7330990
--- /dev/null
+++ b/vendor/golang.org/x/text/PATENTS
@@ -0,0 +1,22 @@
+Additional IP Rights Grant (Patents)
+
+"This implementation" means the copyrightable works distributed by
+Google as part of the Go project.
+
+Google hereby grants to You a perpetual, worldwide, non-exclusive,
+no-charge, royalty-free, irrevocable (except as stated in this section)
+patent license to make, have made, use, offer to sell, sell, import,
+transfer and otherwise run, modify and propagate the contents of this
+implementation of Go, where such license applies only to those patent
+claims, both currently owned or controlled by Google and acquired in
+the future, licensable by Google that are necessarily infringed by this
+implementation of Go. This grant does not include claims that would be
+infringed only as a consequence of further modification of this
+implementation. If you or your agent or exclusive licensee institute or
+order or agree to the institution of patent litigation against any
+entity (including a cross-claim or counterclaim in a lawsuit) alleging
+that this implementation of Go or any code incorporated within this
+implementation of Go constitutes direct or contributory patent
+infringement, or inducement of patent infringement, then any patent
+rights granted to you under this License for this implementation of Go
+shall terminate as of the date such litigation is filed.
diff --git a/vendor/golang.org/x/text/feature/plural/common.go b/vendor/golang.org/x/text/feature/plural/common.go
new file mode 100644
index 0000000..fdcb373
--- /dev/null
+++ b/vendor/golang.org/x/text/feature/plural/common.go
@@ -0,0 +1,70 @@
+// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
+
+package plural
+
+// Form defines a plural form.
+//
+// Not all languages support all forms. Also, the meaning of each form varies
+// per language. It is important to note that the name of a form does not
+// necessarily correspond one-to-one with the set of numbers. For instance,
+// for Croation, One matches not only 1, but also 11, 21, etc.
+//
+// Each language must at least support the form "other".
+type Form byte
+
+const (
+ Other Form = iota
+ Zero
+ One
+ Two
+ Few
+ Many
+)
+
+var countMap = map[string]Form{
+ "other": Other,
+ "zero": Zero,
+ "one": One,
+ "two": Two,
+ "few": Few,
+ "many": Many,
+}
+
+type pluralCheck struct {
+ // category:
+ // 3..7: opID
+ // 0..2: category
+ cat byte
+ setID byte
+}
+
+// opID identifies the type of operand in the plural rule, being i, n or f.
+// (v, w, and t are treated as filters in our implementation.)
+type opID byte
+
+const (
+ opMod opID = 0x1 // is '%' used?
+ opNotEqual opID = 0x2 // using "!=" to compare
+ opI opID = 0 << 2 // integers after taking the absolute value
+ opN opID = 1 << 2 // full number (must be integer)
+ opF opID = 2 << 2 // fraction
+ opV opID = 3 << 2 // number of visible digits
+ opW opID = 4 << 2 // number of visible digits without trailing zeros
+ opBretonM opID = 5 << 2 // hard-wired rule for Breton
+ opItalian800 opID = 6 << 2 // hard-wired rule for Italian
+ opAzerbaijan00s opID = 7 << 2 // hard-wired rule for Azerbaijan
+)
+const (
+ // Use this plural form to indicate the next rule needs to match as well.
+ // The last condition in the list will have the correct plural form.
+ andNext = 0x7
+ formMask = 0x7
+
+ opShift = 3
+
+ // numN indicates the maximum integer, or maximum mod value, for which we
+ // have inclusion masks.
+ numN = 100
+ // The common denominator of the modulo that is taken.
+ maxMod = 100
+)
diff --git a/vendor/golang.org/x/text/feature/plural/message.go b/vendor/golang.org/x/text/feature/plural/message.go
new file mode 100644
index 0000000..56d518c
--- /dev/null
+++ b/vendor/golang.org/x/text/feature/plural/message.go
@@ -0,0 +1,244 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package plural
+
+import (
+ "fmt"
+ "io"
+ "reflect"
+ "strconv"
+
+ "golang.org/x/text/internal/catmsg"
+ "golang.org/x/text/internal/number"
+ "golang.org/x/text/language"
+ "golang.org/x/text/message/catalog"
+)
+
+// TODO: consider deleting this interface. Maybe VisibleDigits is always
+// sufficient and practical.
+
+// Interface is used for types that can determine their own plural form.
+type Interface interface {
+ // PluralForm reports the plural form for the given language of the
+ // underlying value. It also returns the integer value. If the integer value
+ // is larger than fits in n, PluralForm may return a value modulo
+ // 10,000,000.
+ PluralForm(t language.Tag, scale int) (f Form, n int)
+}
+
+// Selectf returns the first case for which its selector is a match for the
+// arg-th substitution argument to a formatting call, formatting it as indicated
+// by format.
+//
+// The cases argument are pairs of selectors and messages. Selectors are of type
+// string or Form. Messages are of type string or catalog.Message. A selector
+// matches an argument if:
+// - it is "other" or Other
+// - it matches the plural form of the argument: "zero", "one", "two", "few",
+// or "many", or the equivalent Form
+// - it is of the form "=x" where x is an integer that matches the value of
+// the argument.
+// - it is of the form " kindDefault {
+ e.EncodeUint(uint64(m.scale))
+ }
+
+ forms := validForms(cardinal, e.Language())
+
+ for i := 0; i < len(m.cases); {
+ if err := compileSelector(e, forms, m.cases[i]); err != nil {
+ return err
+ }
+ if i++; i >= len(m.cases) {
+ return fmt.Errorf("plural: no message defined for selector %v", m.cases[i-1])
+ }
+ var msg catalog.Message
+ switch x := m.cases[i].(type) {
+ case string:
+ msg = catalog.String(x)
+ case catalog.Message:
+ msg = x
+ default:
+ return fmt.Errorf("plural: message of type %T; must be string or catalog.Message", x)
+ }
+ if err := e.EncodeMessage(msg); err != nil {
+ return err
+ }
+ i++
+ }
+ return nil
+}
+
+func compileSelector(e *catmsg.Encoder, valid []Form, selector interface{}) error {
+ form := Other
+ switch x := selector.(type) {
+ case string:
+ if x == "" {
+ return fmt.Errorf("plural: empty selector")
+ }
+ if c := x[0]; c == '=' || c == '<' {
+ val, err := strconv.ParseUint(x[1:], 10, 16)
+ if err != nil {
+ return fmt.Errorf("plural: invalid number in selector %q: %v", selector, err)
+ }
+ e.EncodeUint(uint64(c))
+ e.EncodeUint(val)
+ return nil
+ }
+ var ok bool
+ form, ok = countMap[x]
+ if !ok {
+ return fmt.Errorf("plural: invalid plural form %q", selector)
+ }
+ case Form:
+ form = x
+ default:
+ return fmt.Errorf("plural: selector of type %T; want string or Form", selector)
+ }
+
+ ok := false
+ for _, f := range valid {
+ if f == form {
+ ok = true
+ break
+ }
+ }
+ if !ok {
+ return fmt.Errorf("plural: form %q not supported for language %q", selector, e.Language())
+ }
+ e.EncodeUint(uint64(form))
+ return nil
+}
+
+func execute(d *catmsg.Decoder) bool {
+ lang := d.Language()
+ argN := int(d.DecodeUint())
+ kind := int(d.DecodeUint())
+ scale := -1 // default
+ if kind > kindDefault {
+ scale = int(d.DecodeUint())
+ }
+ form := Other
+ n := -1
+ if arg := d.Arg(argN); arg == nil {
+ // Default to Other.
+ } else if x, ok := arg.(number.VisibleDigits); ok {
+ d := x.Digits(nil, lang, scale)
+ form, n = cardinal.matchDisplayDigits(lang, &d)
+ } else if x, ok := arg.(Interface); ok {
+ // This covers lists and formatters from the number package.
+ form, n = x.PluralForm(lang, scale)
+ } else {
+ var f number.Formatter
+ switch kind {
+ case kindScale:
+ f.InitDecimal(lang)
+ f.SetScale(scale)
+ case kindScientific:
+ f.InitScientific(lang)
+ f.SetScale(scale)
+ case kindPrecision:
+ f.InitDecimal(lang)
+ f.SetPrecision(scale)
+ case kindDefault:
+ // sensible default
+ f.InitDecimal(lang)
+ if k := reflect.TypeOf(arg).Kind(); reflect.Int <= k && k <= reflect.Uintptr {
+ f.SetScale(0)
+ } else {
+ f.SetScale(2)
+ }
+ }
+ var dec number.Decimal // TODO: buffer in Printer
+ dec.Convert(f.RoundingContext, arg)
+ v := number.FormatDigits(&dec, f.RoundingContext)
+ if !v.NaN && !v.Inf {
+ form, n = cardinal.matchDisplayDigits(d.Language(), &v)
+ }
+ }
+ for !d.Done() {
+ f := d.DecodeUint()
+ if (f == '=' && n == int(d.DecodeUint())) ||
+ (f == '<' && 0 <= n && n < int(d.DecodeUint())) ||
+ form == Form(f) ||
+ Other == Form(f) {
+ return d.ExecuteMessage()
+ }
+ d.SkipMessage()
+ }
+ return false
+}
diff --git a/vendor/golang.org/x/text/feature/plural/plural.go b/vendor/golang.org/x/text/feature/plural/plural.go
new file mode 100644
index 0000000..e9f2d42
--- /dev/null
+++ b/vendor/golang.org/x/text/feature/plural/plural.go
@@ -0,0 +1,262 @@
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:generate go run gen.go gen_common.go
+
+// Package plural provides utilities for handling linguistic plurals in text.
+//
+// The definitions in this package are based on the plural rule handling defined
+// in CLDR. See
+// https://unicode.org/reports/tr35/tr35-numbers.html#Language_Plural_Rules for
+// details.
+package plural
+
+import (
+ "golang.org/x/text/internal/language/compact"
+ "golang.org/x/text/internal/number"
+ "golang.org/x/text/language"
+)
+
+// Rules defines the plural rules for all languages for a certain plural type.
+//
+// This package is UNDER CONSTRUCTION and its API may change.
+type Rules struct {
+ rules []pluralCheck
+ index []byte
+ langToIndex []byte
+ inclusionMasks []uint64
+}
+
+var (
+ // Cardinal defines the plural rules for numbers indicating quantities.
+ Cardinal *Rules = cardinal
+
+ // Ordinal defines the plural rules for numbers indicating position
+ // (first, second, etc.).
+ Ordinal *Rules = ordinal
+
+ ordinal = &Rules{
+ ordinalRules,
+ ordinalIndex,
+ ordinalLangToIndex,
+ ordinalInclusionMasks[:],
+ }
+
+ cardinal = &Rules{
+ cardinalRules,
+ cardinalIndex,
+ cardinalLangToIndex,
+ cardinalInclusionMasks[:],
+ }
+)
+
+// getIntApprox converts the digits in slice digits[start:end] to an integer
+// according to the following rules:
+// - Let i be asInt(digits[start:end]), where out-of-range digits are assumed
+// to be zero.
+// - Result n is big if i / 10^nMod > 1.
+// - Otherwise the result is i % 10^nMod.
+//
+// For example, if digits is {1, 2, 3} and start:end is 0:5, then the result
+// for various values of nMod is:
+// - when nMod == 2, n == big
+// - when nMod == 3, n == big
+// - when nMod == 4, n == big
+// - when nMod == 5, n == 12300
+// - when nMod == 6, n == 12300
+// - when nMod == 7, n == 12300
+func getIntApprox(digits []byte, start, end, nMod, big int) (n int) {
+ // Leading 0 digits just result in 0.
+ p := start
+ if p < 0 {
+ p = 0
+ }
+ // Range only over the part for which we have digits.
+ mid := end
+ if mid >= len(digits) {
+ mid = len(digits)
+ }
+ // Check digits more significant that nMod.
+ if q := end - nMod; q > 0 {
+ if q > mid {
+ q = mid
+ }
+ for ; p < q; p++ {
+ if digits[p] != 0 {
+ return big
+ }
+ }
+ }
+ for ; p < mid; p++ {
+ n = 10*n + int(digits[p])
+ }
+ // Multiply for trailing zeros.
+ for ; p < end; p++ {
+ n *= 10
+ }
+ return n
+}
+
+// MatchDigits computes the plural form for the given language and the given
+// decimal floating point digits. The digits are stored in big-endian order and
+// are of value byte(0) - byte(9). The floating point position is indicated by
+// exp and the number of visible decimals is scale. All leading and trailing
+// zeros may be omitted from digits.
+//
+// The following table contains examples of possible arguments to represent
+// the given numbers.
+//
+// decimal digits exp scale
+// 123 []byte{1, 2, 3} 3 0
+// 123.4 []byte{1, 2, 3, 4} 3 1
+// 123.40 []byte{1, 2, 3, 4} 3 2
+// 100000 []byte{1} 6 0
+// 100000.00 []byte{1} 6 3
+func (p *Rules) MatchDigits(t language.Tag, digits []byte, exp, scale int) Form {
+ index := tagToID(t)
+
+ // Differentiate up to including mod 1000000 for the integer part.
+ n := getIntApprox(digits, 0, exp, 6, 1000000)
+
+ // Differentiate up to including mod 100 for the fractional part.
+ f := getIntApprox(digits, exp, exp+scale, 2, 100)
+
+ return matchPlural(p, index, n, f, scale)
+}
+
+func (p *Rules) matchDisplayDigits(t language.Tag, d *number.Digits) (Form, int) {
+ n := getIntApprox(d.Digits, 0, int(d.Exp), 6, 1000000)
+ return p.MatchDigits(t, d.Digits, int(d.Exp), d.NumFracDigits()), n
+}
+
+func validForms(p *Rules, t language.Tag) (forms []Form) {
+ offset := p.langToIndex[tagToID(t)]
+ rules := p.rules[p.index[offset]:p.index[offset+1]]
+
+ forms = append(forms, Other)
+ last := Other
+ for _, r := range rules {
+ if cat := Form(r.cat & formMask); cat != andNext && last != cat {
+ forms = append(forms, cat)
+ last = cat
+ }
+ }
+ return forms
+}
+
+func (p *Rules) matchComponents(t language.Tag, n, f, scale int) Form {
+ return matchPlural(p, tagToID(t), n, f, scale)
+}
+
+// MatchPlural returns the plural form for the given language and plural
+// operands (as defined in
+// https://unicode.org/reports/tr35/tr35-numbers.html#Language_Plural_Rules):
+//
+// where
+// n absolute value of the source number (integer and decimals)
+// input
+// i integer digits of n.
+// v number of visible fraction digits in n, with trailing zeros.
+// w number of visible fraction digits in n, without trailing zeros.
+// f visible fractional digits in n, with trailing zeros (f = t * 10^(v-w))
+// t visible fractional digits in n, without trailing zeros.
+//
+// If any of the operand values is too large to fit in an int, it is okay to
+// pass the value modulo 10,000,000.
+func (p *Rules) MatchPlural(lang language.Tag, i, v, w, f, t int) Form {
+ return matchPlural(p, tagToID(lang), i, f, v)
+}
+
+func matchPlural(p *Rules, index compact.ID, n, f, v int) Form {
+ nMask := p.inclusionMasks[n%maxMod]
+ // Compute the fMask inline in the rules below, as it is relatively rare.
+ // fMask := p.inclusionMasks[f%maxMod]
+ vMask := p.inclusionMasks[v%maxMod]
+
+ // Do the matching
+ offset := p.langToIndex[index]
+ rules := p.rules[p.index[offset]:p.index[offset+1]]
+ for i := 0; i < len(rules); i++ {
+ rule := rules[i]
+ setBit := uint64(1 << rule.setID)
+ var skip bool
+ switch op := opID(rule.cat >> opShift); op {
+ case opI: // i = x
+ skip = n >= numN || nMask&setBit == 0
+
+ case opI | opNotEqual: // i != x
+ skip = n < numN && nMask&setBit != 0
+
+ case opI | opMod: // i % m = x
+ skip = nMask&setBit == 0
+
+ case opI | opMod | opNotEqual: // i % m != x
+ skip = nMask&setBit != 0
+
+ case opN: // n = x
+ skip = f != 0 || n >= numN || nMask&setBit == 0
+
+ case opN | opNotEqual: // n != x
+ skip = f == 0 && n < numN && nMask&setBit != 0
+
+ case opN | opMod: // n % m = x
+ skip = f != 0 || nMask&setBit == 0
+
+ case opN | opMod | opNotEqual: // n % m != x
+ skip = f == 0 && nMask&setBit != 0
+
+ case opF: // f = x
+ skip = f >= numN || p.inclusionMasks[f%maxMod]&setBit == 0
+
+ case opF | opNotEqual: // f != x
+ skip = f < numN && p.inclusionMasks[f%maxMod]&setBit != 0
+
+ case opF | opMod: // f % m = x
+ skip = p.inclusionMasks[f%maxMod]&setBit == 0
+
+ case opF | opMod | opNotEqual: // f % m != x
+ skip = p.inclusionMasks[f%maxMod]&setBit != 0
+
+ case opV: // v = x
+ skip = v < numN && vMask&setBit == 0
+
+ case opV | opNotEqual: // v != x
+ skip = v < numN && vMask&setBit != 0
+
+ case opW: // w == 0
+ skip = f != 0
+
+ case opW | opNotEqual: // w != 0
+ skip = f == 0
+
+ // Hard-wired rules that cannot be handled by our algorithm.
+
+ case opBretonM:
+ skip = f != 0 || n == 0 || n%1000000 != 0
+
+ case opAzerbaijan00s:
+ // 100,200,300,400,500,600,700,800,900
+ skip = n == 0 || n >= 1000 || n%100 != 0
+
+ case opItalian800:
+ skip = (f != 0 || n >= numN || nMask&setBit == 0) && n != 800
+ }
+ if skip {
+ // advance over AND entries.
+ for ; i < len(rules) && rules[i].cat&formMask == andNext; i++ {
+ }
+ continue
+ }
+ // return if we have a final entry.
+ if cat := rule.cat & formMask; cat != andNext {
+ return Form(cat)
+ }
+ }
+ return Other
+}
+
+func tagToID(t language.Tag) compact.ID {
+ id, _ := compact.RegionalID(compact.Tag(t))
+ return id
+}
diff --git a/vendor/golang.org/x/text/feature/plural/tables.go b/vendor/golang.org/x/text/feature/plural/tables.go
new file mode 100644
index 0000000..59ae9f2
--- /dev/null
+++ b/vendor/golang.org/x/text/feature/plural/tables.go
@@ -0,0 +1,552 @@
+// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
+
+package plural
+
+// CLDRVersion is the CLDR version from which the tables in this package are derived.
+const CLDRVersion = "32"
+
+var ordinalRules = []pluralCheck{ // 64 elements
+ 0: {cat: 0x2f, setID: 0x4},
+ 1: {cat: 0x3a, setID: 0x5},
+ 2: {cat: 0x22, setID: 0x1},
+ 3: {cat: 0x22, setID: 0x6},
+ 4: {cat: 0x22, setID: 0x7},
+ 5: {cat: 0x2f, setID: 0x8},
+ 6: {cat: 0x3c, setID: 0x9},
+ 7: {cat: 0x2f, setID: 0xa},
+ 8: {cat: 0x3c, setID: 0xb},
+ 9: {cat: 0x2c, setID: 0xc},
+ 10: {cat: 0x24, setID: 0xd},
+ 11: {cat: 0x2d, setID: 0xe},
+ 12: {cat: 0x2d, setID: 0xf},
+ 13: {cat: 0x2f, setID: 0x10},
+ 14: {cat: 0x35, setID: 0x3},
+ 15: {cat: 0xc5, setID: 0x11},
+ 16: {cat: 0x2, setID: 0x1},
+ 17: {cat: 0x5, setID: 0x3},
+ 18: {cat: 0xd, setID: 0x12},
+ 19: {cat: 0x22, setID: 0x1},
+ 20: {cat: 0x2f, setID: 0x13},
+ 21: {cat: 0x3d, setID: 0x14},
+ 22: {cat: 0x2f, setID: 0x15},
+ 23: {cat: 0x3a, setID: 0x16},
+ 24: {cat: 0x2f, setID: 0x17},
+ 25: {cat: 0x3b, setID: 0x18},
+ 26: {cat: 0x2f, setID: 0xa},
+ 27: {cat: 0x3c, setID: 0xb},
+ 28: {cat: 0x22, setID: 0x1},
+ 29: {cat: 0x23, setID: 0x19},
+ 30: {cat: 0x24, setID: 0x1a},
+ 31: {cat: 0x22, setID: 0x1b},
+ 32: {cat: 0x23, setID: 0x2},
+ 33: {cat: 0x24, setID: 0x1a},
+ 34: {cat: 0xf, setID: 0x15},
+ 35: {cat: 0x1a, setID: 0x16},
+ 36: {cat: 0xf, setID: 0x17},
+ 37: {cat: 0x1b, setID: 0x18},
+ 38: {cat: 0xf, setID: 0x1c},
+ 39: {cat: 0x1d, setID: 0x1d},
+ 40: {cat: 0xa, setID: 0x1e},
+ 41: {cat: 0xa, setID: 0x1f},
+ 42: {cat: 0xc, setID: 0x20},
+ 43: {cat: 0xe4, setID: 0x0},
+ 44: {cat: 0x5, setID: 0x3},
+ 45: {cat: 0xd, setID: 0xe},
+ 46: {cat: 0xd, setID: 0x21},
+ 47: {cat: 0x22, setID: 0x1},
+ 48: {cat: 0x23, setID: 0x19},
+ 49: {cat: 0x24, setID: 0x1a},
+ 50: {cat: 0x25, setID: 0x22},
+ 51: {cat: 0x22, setID: 0x23},
+ 52: {cat: 0x23, setID: 0x19},
+ 53: {cat: 0x24, setID: 0x1a},
+ 54: {cat: 0x25, setID: 0x22},
+ 55: {cat: 0x22, setID: 0x24},
+ 56: {cat: 0x23, setID: 0x19},
+ 57: {cat: 0x24, setID: 0x1a},
+ 58: {cat: 0x25, setID: 0x22},
+ 59: {cat: 0x21, setID: 0x25},
+ 60: {cat: 0x22, setID: 0x1},
+ 61: {cat: 0x23, setID: 0x2},
+ 62: {cat: 0x24, setID: 0x26},
+ 63: {cat: 0x25, setID: 0x27},
+} // Size: 152 bytes
+
+var ordinalIndex = []uint8{ // 22 elements
+ 0x00, 0x00, 0x02, 0x03, 0x04, 0x05, 0x07, 0x09,
+ 0x0b, 0x0f, 0x10, 0x13, 0x16, 0x1c, 0x1f, 0x22,
+ 0x28, 0x2f, 0x33, 0x37, 0x3b, 0x40,
+} // Size: 46 bytes
+
+var ordinalLangToIndex = []uint8{ // 775 elements
+ // Entry 0 - 3F
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10,
+ 0x10, 0x10, 0x10, 0x00, 0x00, 0x05, 0x05, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Entry 40 - 7F
+ 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e,
+ 0x0e, 0x0e, 0x0e, 0x0e, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x14, 0x14, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Entry 80 - BF
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x0c,
+ 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
+ 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
+ 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
+ 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
+ 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
+ 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
+ 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
+ // Entry C0 - FF
+ 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
+ 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
+ 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
+ 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
+ 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
+ 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Entry 100 - 13F
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
+ 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ // Entry 140 - 17F
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11,
+ 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03,
+ 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Entry 180 - 1BF
+ 0x00, 0x00, 0x00, 0x00, 0x09, 0x09, 0x09, 0x09,
+ 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x0a, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Entry 1C0 - 1FF
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00,
+ 0x00, 0x00, 0x02, 0x0d, 0x0d, 0x02, 0x02, 0x02,
+ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Entry 200 - 23F
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x13, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Entry 240 - 27F
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Entry 280 - 2BF
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x0b, 0x0b, 0x0b, 0x0b, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x07, 0x07, 0x02, 0x00, 0x00, 0x00, 0x00,
+ // Entry 2C0 - 2FF
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Entry 300 - 33F
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x0c,
+} // Size: 799 bytes
+
+var ordinalInclusionMasks = []uint64{ // 100 elements
+ // Entry 0 - 1F
+ 0x0000002000010009, 0x00000018482000d3, 0x0000000042840195, 0x000000410a040581,
+ 0x00000041040c0081, 0x0000009840040041, 0x0000008400045001, 0x0000003850040001,
+ 0x0000003850060001, 0x0000003800049001, 0x0000000800052001, 0x0000000040660031,
+ 0x0000000041840331, 0x0000000100040f01, 0x00000001001c0001, 0x0000000040040001,
+ 0x0000000000045001, 0x0000000070040001, 0x0000000070040001, 0x0000000000049001,
+ 0x0000000080050001, 0x0000000040200011, 0x0000000040800111, 0x0000000100000501,
+ 0x0000000100080001, 0x0000000040000001, 0x0000000000005001, 0x0000000050000001,
+ 0x0000000050000001, 0x0000000000009001, 0x0000000000010001, 0x0000000040200011,
+ // Entry 20 - 3F
+ 0x0000000040800111, 0x0000000100000501, 0x0000000100080001, 0x0000000040000001,
+ 0x0000000000005001, 0x0000000050000001, 0x0000000050000001, 0x0000000000009001,
+ 0x0000000200050001, 0x0000000040200011, 0x0000000040800111, 0x0000000100000501,
+ 0x0000000100080001, 0x0000000040000001, 0x0000000000005001, 0x0000000050000001,
+ 0x0000000050000001, 0x0000000000009001, 0x0000000080010001, 0x0000000040200011,
+ 0x0000000040800111, 0x0000000100000501, 0x0000000100080001, 0x0000000040000001,
+ 0x0000000000005001, 0x0000000050000001, 0x0000000050000001, 0x0000000000009001,
+ 0x0000000200050001, 0x0000000040200011, 0x0000000040800111, 0x0000000100000501,
+ // Entry 40 - 5F
+ 0x0000000100080001, 0x0000000040000001, 0x0000000000005001, 0x0000000050000001,
+ 0x0000000050000001, 0x0000000000009001, 0x0000000080010001, 0x0000000040200011,
+ 0x0000000040800111, 0x0000000100000501, 0x0000000100080001, 0x0000000040000001,
+ 0x0000000000005001, 0x0000000050000001, 0x0000000050000001, 0x0000000000009001,
+ 0x0000000080070001, 0x0000000040200011, 0x0000000040800111, 0x0000000100000501,
+ 0x0000000100080001, 0x0000000040000001, 0x0000000000005001, 0x0000000050000001,
+ 0x0000000050000001, 0x0000000000009001, 0x0000000200010001, 0x0000000040200011,
+ 0x0000000040800111, 0x0000000100000501, 0x0000000100080001, 0x0000000040000001,
+ // Entry 60 - 7F
+ 0x0000000000005001, 0x0000000050000001, 0x0000000050000001, 0x0000000000009001,
+} // Size: 824 bytes
+
+// Slots used for ordinal: 40 of 0xFF rules; 16 of 0xFF indexes; 40 of 64 sets
+
+var cardinalRules = []pluralCheck{ // 166 elements
+ 0: {cat: 0x2, setID: 0x3},
+ 1: {cat: 0x22, setID: 0x1},
+ 2: {cat: 0x2, setID: 0x4},
+ 3: {cat: 0x2, setID: 0x4},
+ 4: {cat: 0x7, setID: 0x1},
+ 5: {cat: 0x62, setID: 0x3},
+ 6: {cat: 0x22, setID: 0x4},
+ 7: {cat: 0x7, setID: 0x3},
+ 8: {cat: 0x42, setID: 0x1},
+ 9: {cat: 0x22, setID: 0x4},
+ 10: {cat: 0x22, setID: 0x4},
+ 11: {cat: 0x22, setID: 0x5},
+ 12: {cat: 0x22, setID: 0x1},
+ 13: {cat: 0x22, setID: 0x1},
+ 14: {cat: 0x7, setID: 0x4},
+ 15: {cat: 0x92, setID: 0x3},
+ 16: {cat: 0xf, setID: 0x6},
+ 17: {cat: 0x1f, setID: 0x7},
+ 18: {cat: 0x82, setID: 0x3},
+ 19: {cat: 0x92, setID: 0x3},
+ 20: {cat: 0xf, setID: 0x6},
+ 21: {cat: 0x62, setID: 0x3},
+ 22: {cat: 0x4a, setID: 0x6},
+ 23: {cat: 0x7, setID: 0x8},
+ 24: {cat: 0x62, setID: 0x3},
+ 25: {cat: 0x1f, setID: 0x9},
+ 26: {cat: 0x62, setID: 0x3},
+ 27: {cat: 0x5f, setID: 0x9},
+ 28: {cat: 0x72, setID: 0x3},
+ 29: {cat: 0x29, setID: 0xa},
+ 30: {cat: 0x29, setID: 0xb},
+ 31: {cat: 0x4f, setID: 0xb},
+ 32: {cat: 0x61, setID: 0x2},
+ 33: {cat: 0x2f, setID: 0x6},
+ 34: {cat: 0x3a, setID: 0x7},
+ 35: {cat: 0x4f, setID: 0x6},
+ 36: {cat: 0x5f, setID: 0x7},
+ 37: {cat: 0x62, setID: 0x2},
+ 38: {cat: 0x4f, setID: 0x6},
+ 39: {cat: 0x72, setID: 0x2},
+ 40: {cat: 0x21, setID: 0x3},
+ 41: {cat: 0x7, setID: 0x4},
+ 42: {cat: 0x32, setID: 0x3},
+ 43: {cat: 0x21, setID: 0x3},
+ 44: {cat: 0x22, setID: 0x1},
+ 45: {cat: 0x22, setID: 0x1},
+ 46: {cat: 0x23, setID: 0x2},
+ 47: {cat: 0x2, setID: 0x3},
+ 48: {cat: 0x22, setID: 0x1},
+ 49: {cat: 0x24, setID: 0xc},
+ 50: {cat: 0x7, setID: 0x1},
+ 51: {cat: 0x62, setID: 0x3},
+ 52: {cat: 0x74, setID: 0x3},
+ 53: {cat: 0x24, setID: 0x3},
+ 54: {cat: 0x2f, setID: 0xd},
+ 55: {cat: 0x34, setID: 0x1},
+ 56: {cat: 0xf, setID: 0x6},
+ 57: {cat: 0x1f, setID: 0x7},
+ 58: {cat: 0x62, setID: 0x3},
+ 59: {cat: 0x4f, setID: 0x6},
+ 60: {cat: 0x5a, setID: 0x7},
+ 61: {cat: 0xf, setID: 0xe},
+ 62: {cat: 0x1f, setID: 0xf},
+ 63: {cat: 0x64, setID: 0x3},
+ 64: {cat: 0x4f, setID: 0xe},
+ 65: {cat: 0x5c, setID: 0xf},
+ 66: {cat: 0x22, setID: 0x10},
+ 67: {cat: 0x23, setID: 0x11},
+ 68: {cat: 0x24, setID: 0x12},
+ 69: {cat: 0xf, setID: 0x1},
+ 70: {cat: 0x62, setID: 0x3},
+ 71: {cat: 0xf, setID: 0x2},
+ 72: {cat: 0x63, setID: 0x3},
+ 73: {cat: 0xf, setID: 0x13},
+ 74: {cat: 0x64, setID: 0x3},
+ 75: {cat: 0x74, setID: 0x3},
+ 76: {cat: 0xf, setID: 0x1},
+ 77: {cat: 0x62, setID: 0x3},
+ 78: {cat: 0x4a, setID: 0x1},
+ 79: {cat: 0xf, setID: 0x2},
+ 80: {cat: 0x63, setID: 0x3},
+ 81: {cat: 0x4b, setID: 0x2},
+ 82: {cat: 0xf, setID: 0x13},
+ 83: {cat: 0x64, setID: 0x3},
+ 84: {cat: 0x4c, setID: 0x13},
+ 85: {cat: 0x7, setID: 0x1},
+ 86: {cat: 0x62, setID: 0x3},
+ 87: {cat: 0x7, setID: 0x2},
+ 88: {cat: 0x63, setID: 0x3},
+ 89: {cat: 0x2f, setID: 0xa},
+ 90: {cat: 0x37, setID: 0x14},
+ 91: {cat: 0x65, setID: 0x3},
+ 92: {cat: 0x7, setID: 0x1},
+ 93: {cat: 0x62, setID: 0x3},
+ 94: {cat: 0x7, setID: 0x15},
+ 95: {cat: 0x64, setID: 0x3},
+ 96: {cat: 0x75, setID: 0x3},
+ 97: {cat: 0x7, setID: 0x1},
+ 98: {cat: 0x62, setID: 0x3},
+ 99: {cat: 0xf, setID: 0xe},
+ 100: {cat: 0x1f, setID: 0xf},
+ 101: {cat: 0x64, setID: 0x3},
+ 102: {cat: 0xf, setID: 0x16},
+ 103: {cat: 0x17, setID: 0x1},
+ 104: {cat: 0x65, setID: 0x3},
+ 105: {cat: 0xf, setID: 0x17},
+ 106: {cat: 0x65, setID: 0x3},
+ 107: {cat: 0xf, setID: 0xf},
+ 108: {cat: 0x65, setID: 0x3},
+ 109: {cat: 0x2f, setID: 0x6},
+ 110: {cat: 0x3a, setID: 0x7},
+ 111: {cat: 0x2f, setID: 0xe},
+ 112: {cat: 0x3c, setID: 0xf},
+ 113: {cat: 0x2d, setID: 0xa},
+ 114: {cat: 0x2d, setID: 0x17},
+ 115: {cat: 0x2d, setID: 0x18},
+ 116: {cat: 0x2f, setID: 0x6},
+ 117: {cat: 0x3a, setID: 0xb},
+ 118: {cat: 0x2f, setID: 0x19},
+ 119: {cat: 0x3c, setID: 0xb},
+ 120: {cat: 0x55, setID: 0x3},
+ 121: {cat: 0x22, setID: 0x1},
+ 122: {cat: 0x24, setID: 0x3},
+ 123: {cat: 0x2c, setID: 0xc},
+ 124: {cat: 0x2d, setID: 0xb},
+ 125: {cat: 0xf, setID: 0x6},
+ 126: {cat: 0x1f, setID: 0x7},
+ 127: {cat: 0x62, setID: 0x3},
+ 128: {cat: 0xf, setID: 0xe},
+ 129: {cat: 0x1f, setID: 0xf},
+ 130: {cat: 0x64, setID: 0x3},
+ 131: {cat: 0xf, setID: 0xa},
+ 132: {cat: 0x65, setID: 0x3},
+ 133: {cat: 0xf, setID: 0x17},
+ 134: {cat: 0x65, setID: 0x3},
+ 135: {cat: 0xf, setID: 0x18},
+ 136: {cat: 0x65, setID: 0x3},
+ 137: {cat: 0x2f, setID: 0x6},
+ 138: {cat: 0x3a, setID: 0x1a},
+ 139: {cat: 0x2f, setID: 0x1b},
+ 140: {cat: 0x3b, setID: 0x1c},
+ 141: {cat: 0x2f, setID: 0x1d},
+ 142: {cat: 0x3c, setID: 0x1e},
+ 143: {cat: 0x37, setID: 0x3},
+ 144: {cat: 0xa5, setID: 0x0},
+ 145: {cat: 0x22, setID: 0x1},
+ 146: {cat: 0x23, setID: 0x2},
+ 147: {cat: 0x24, setID: 0x1f},
+ 148: {cat: 0x25, setID: 0x20},
+ 149: {cat: 0xf, setID: 0x6},
+ 150: {cat: 0x62, setID: 0x3},
+ 151: {cat: 0xf, setID: 0x1b},
+ 152: {cat: 0x63, setID: 0x3},
+ 153: {cat: 0xf, setID: 0x21},
+ 154: {cat: 0x64, setID: 0x3},
+ 155: {cat: 0x75, setID: 0x3},
+ 156: {cat: 0x21, setID: 0x3},
+ 157: {cat: 0x22, setID: 0x1},
+ 158: {cat: 0x23, setID: 0x2},
+ 159: {cat: 0x2c, setID: 0x22},
+ 160: {cat: 0x2d, setID: 0x5},
+ 161: {cat: 0x21, setID: 0x3},
+ 162: {cat: 0x22, setID: 0x1},
+ 163: {cat: 0x23, setID: 0x2},
+ 164: {cat: 0x24, setID: 0x23},
+ 165: {cat: 0x25, setID: 0x24},
+} // Size: 356 bytes
+
+var cardinalIndex = []uint8{ // 36 elements
+ 0x00, 0x00, 0x02, 0x03, 0x04, 0x06, 0x09, 0x0a,
+ 0x0c, 0x0d, 0x10, 0x14, 0x17, 0x1d, 0x28, 0x2b,
+ 0x2d, 0x2f, 0x32, 0x38, 0x42, 0x45, 0x4c, 0x55,
+ 0x5c, 0x61, 0x6d, 0x74, 0x79, 0x7d, 0x89, 0x91,
+ 0x95, 0x9c, 0xa1, 0xa6,
+} // Size: 60 bytes
+
+var cardinalLangToIndex = []uint8{ // 775 elements
+ // Entry 0 - 3F
+ 0x00, 0x08, 0x08, 0x08, 0x00, 0x00, 0x06, 0x06,
+ 0x01, 0x01, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21,
+ 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21,
+ 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21,
+ 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21,
+ 0x01, 0x01, 0x08, 0x08, 0x04, 0x04, 0x08, 0x08,
+ 0x08, 0x08, 0x08, 0x00, 0x00, 0x1a, 0x1a, 0x08,
+ 0x08, 0x08, 0x08, 0x08, 0x08, 0x06, 0x00, 0x00,
+ // Entry 40 - 7F
+ 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x1e, 0x1e,
+ 0x08, 0x08, 0x13, 0x13, 0x13, 0x13, 0x13, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x08,
+ 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
+ 0x18, 0x18, 0x00, 0x00, 0x22, 0x22, 0x09, 0x09,
+ 0x09, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x00, 0x00, 0x16, 0x16, 0x00,
+ 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Entry 80 - BF
+ 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ // Entry C0 - FF
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x08,
+ 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
+ 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
+ // Entry 100 - 13F
+ 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
+ 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x04, 0x04,
+ 0x08, 0x08, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x04, 0x04, 0x0c, 0x0c,
+ 0x08, 0x08, 0x08, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ // Entry 140 - 17F
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x08, 0x08, 0x04, 0x04, 0x1f, 0x1f,
+ 0x14, 0x14, 0x04, 0x04, 0x08, 0x08, 0x08, 0x08,
+ 0x01, 0x01, 0x06, 0x00, 0x00, 0x20, 0x20, 0x08,
+ 0x08, 0x08, 0x08, 0x08, 0x08, 0x17, 0x17, 0x01,
+ 0x01, 0x13, 0x13, 0x13, 0x16, 0x16, 0x08, 0x08,
+ 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Entry 180 - 1BF
+ 0x00, 0x04, 0x0a, 0x0a, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x10, 0x17, 0x00, 0x00, 0x00, 0x08, 0x08,
+ 0x04, 0x08, 0x08, 0x00, 0x00, 0x08, 0x08, 0x02,
+ 0x02, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08,
+ 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x01,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08,
+ 0x08, 0x08, 0x00, 0x00, 0x0f, 0x0f, 0x08, 0x10,
+ // Entry 1C0 - 1FF
+ 0x10, 0x08, 0x08, 0x0e, 0x0e, 0x08, 0x08, 0x08,
+ 0x08, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, 0x1b, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x0d, 0x08,
+ 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06,
+ 0x00, 0x00, 0x08, 0x08, 0x0b, 0x0b, 0x08, 0x08,
+ 0x08, 0x08, 0x12, 0x01, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x1c, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Entry 200 - 23F
+ 0x00, 0x08, 0x10, 0x10, 0x08, 0x08, 0x08, 0x08,
+ 0x08, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00,
+ 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x08,
+ 0x06, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08,
+ 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x06, 0x06,
+ 0x06, 0x06, 0x06, 0x08, 0x19, 0x19, 0x0d, 0x0d,
+ 0x08, 0x08, 0x03, 0x04, 0x03, 0x04, 0x04, 0x04,
+ // Entry 240 - 27F
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00,
+ 0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x12,
+ 0x12, 0x12, 0x08, 0x08, 0x1d, 0x1d, 0x1d, 0x1d,
+ 0x1d, 0x1d, 0x1d, 0x00, 0x00, 0x08, 0x08, 0x00,
+ 0x00, 0x08, 0x08, 0x00, 0x00, 0x08, 0x08, 0x08,
+ 0x10, 0x10, 0x10, 0x10, 0x08, 0x08, 0x00, 0x00,
+ 0x00, 0x00, 0x13, 0x11, 0x11, 0x11, 0x11, 0x11,
+ 0x05, 0x05, 0x18, 0x18, 0x15, 0x15, 0x10, 0x10,
+ // Entry 280 - 2BF
+ 0x10, 0x10, 0x10, 0x10, 0x08, 0x08, 0x08, 0x08,
+ 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x13,
+ 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13,
+ 0x13, 0x13, 0x08, 0x08, 0x08, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x08, 0x08,
+ 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
+ 0x08, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x06,
+ 0x08, 0x08, 0x08, 0x0c, 0x08, 0x00, 0x00, 0x08,
+ // Entry 2C0 - 2FF
+ 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x07,
+ 0x07, 0x08, 0x08, 0x1d, 0x1d, 0x04, 0x04, 0x04,
+ 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08,
+ 0x08, 0x08, 0x08, 0x06, 0x08, 0x08, 0x00, 0x00,
+ 0x08, 0x08, 0x08, 0x00, 0x00, 0x04, 0x04, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Entry 300 - 33F
+ 0x00, 0x00, 0x00, 0x01, 0x01, 0x04, 0x04,
+} // Size: 799 bytes
+
+var cardinalInclusionMasks = []uint64{ // 100 elements
+ // Entry 0 - 1F
+ 0x0000000200500419, 0x0000000000512153, 0x000000000a327105, 0x0000000ca23c7101,
+ 0x00000004a23c7201, 0x0000000482943001, 0x0000001482943201, 0x0000000502943001,
+ 0x0000000502943001, 0x0000000522943201, 0x0000000540543401, 0x00000000454128e1,
+ 0x000000005b02e821, 0x000000006304e821, 0x000000006304ea21, 0x0000000042842821,
+ 0x0000000042842a21, 0x0000000042842821, 0x0000000042842821, 0x0000000062842a21,
+ 0x0000000200400421, 0x0000000000400061, 0x000000000a004021, 0x0000000022004021,
+ 0x0000000022004221, 0x0000000002800021, 0x0000000002800221, 0x0000000002800021,
+ 0x0000000002800021, 0x0000000022800221, 0x0000000000400421, 0x0000000000400061,
+ // Entry 20 - 3F
+ 0x000000000a004021, 0x0000000022004021, 0x0000000022004221, 0x0000000002800021,
+ 0x0000000002800221, 0x0000000002800021, 0x0000000002800021, 0x0000000022800221,
+ 0x0000000200400421, 0x0000000000400061, 0x000000000a004021, 0x0000000022004021,
+ 0x0000000022004221, 0x0000000002800021, 0x0000000002800221, 0x0000000002800021,
+ 0x0000000002800021, 0x0000000022800221, 0x0000000000400421, 0x0000000000400061,
+ 0x000000000a004021, 0x0000000022004021, 0x0000000022004221, 0x0000000002800021,
+ 0x0000000002800221, 0x0000000002800021, 0x0000000002800021, 0x0000000022800221,
+ 0x0000000200400421, 0x0000000000400061, 0x000000000a004021, 0x0000000022004021,
+ // Entry 40 - 5F
+ 0x0000000022004221, 0x0000000002800021, 0x0000000002800221, 0x0000000002800021,
+ 0x0000000002800021, 0x0000000022800221, 0x0000000040400421, 0x0000000044400061,
+ 0x000000005a004021, 0x0000000062004021, 0x0000000062004221, 0x0000000042800021,
+ 0x0000000042800221, 0x0000000042800021, 0x0000000042800021, 0x0000000062800221,
+ 0x0000000200400421, 0x0000000000400061, 0x000000000a004021, 0x0000000022004021,
+ 0x0000000022004221, 0x0000000002800021, 0x0000000002800221, 0x0000000002800021,
+ 0x0000000002800021, 0x0000000022800221, 0x0000000040400421, 0x0000000044400061,
+ 0x000000005a004021, 0x0000000062004021, 0x0000000062004221, 0x0000000042800021,
+ // Entry 60 - 7F
+ 0x0000000042800221, 0x0000000042800021, 0x0000000042800021, 0x0000000062800221,
+} // Size: 824 bytes
+
+// Slots used for cardinal: A6 of 0xFF rules; 24 of 0xFF indexes; 37 of 64 sets
+
+// Total table size 3860 bytes (3KiB); checksum: 4E56F7B1
diff --git a/vendor/golang.org/x/text/internal/catmsg/catmsg.go b/vendor/golang.org/x/text/internal/catmsg/catmsg.go
new file mode 100644
index 0000000..1b257a7
--- /dev/null
+++ b/vendor/golang.org/x/text/internal/catmsg/catmsg.go
@@ -0,0 +1,417 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package catmsg contains support types for package x/text/message/catalog.
+//
+// This package contains the low-level implementations of Message used by the
+// catalog package and provides primitives for other packages to implement their
+// own. For instance, the plural package provides functionality for selecting
+// translation strings based on the plural category of substitution arguments.
+//
+// # Encoding and Decoding
+//
+// Catalogs store Messages encoded as a single string. Compiling a message into
+// a string both results in compacter representation and speeds up evaluation.
+//
+// A Message must implement a Compile method to convert its arbitrary
+// representation to a string. The Compile method takes an Encoder which
+// facilitates serializing the message. Encoders also provide more context of
+// the messages's creation (such as for which language the message is intended),
+// which may not be known at the time of the creation of the message.
+//
+// Each message type must also have an accompanying decoder registered to decode
+// the message. This decoder takes a Decoder argument which provides the
+// counterparts for the decoding.
+//
+// # Renderers
+//
+// A Decoder must be initialized with a Renderer implementation. These
+// implementations must be provided by packages that use Catalogs, typically
+// formatting packages such as x/text/message. A typical user will not need to
+// worry about this type; it is only relevant to packages that do string
+// formatting and want to use the catalog package to handle localized strings.
+//
+// A package that uses catalogs for selecting strings receives selection results
+// as sequence of substrings passed to the Renderer. The following snippet shows
+// how to express the above example using the message package.
+//
+// message.Set(language.English, "You are %d minute(s) late.",
+// catalog.Var("minutes", plural.Select(1, "one", "minute")),
+// catalog.String("You are %[1]d ${minutes} late."))
+//
+// p := message.NewPrinter(language.English)
+// p.Printf("You are %d minute(s) late.", 5) // always 5 minutes late.
+//
+// To evaluate the Printf, package message wraps the arguments in a Renderer
+// that is passed to the catalog for message decoding. The call sequence that
+// results from evaluating the above message, assuming the person is rather
+// tardy, is:
+//
+// Render("You are %[1]d ")
+// Arg(1)
+// Render("minutes")
+// Render(" late.")
+//
+// The calls to Arg is caused by the plural.Select execution, which evaluates
+// the argument to determine whether the singular or plural message form should
+// be selected. The calls to Render reports the partial results to the message
+// package for further evaluation.
+package catmsg
+
+import (
+ "errors"
+ "fmt"
+ "strconv"
+ "strings"
+ "sync"
+
+ "golang.org/x/text/language"
+)
+
+// A Handle refers to a registered message type.
+type Handle int
+
+// A Handler decodes and evaluates data compiled by a Message and sends the
+// result to the Decoder. The output may depend on the value of the substitution
+// arguments, accessible by the Decoder's Arg method. The Handler returns false
+// if there is no translation for the given substitution arguments.
+type Handler func(d *Decoder) bool
+
+// Register records the existence of a message type and returns a Handle that
+// can be used in the Encoder's EncodeMessageType method to create such
+// messages. The prefix of the name should be the package path followed by
+// an optional disambiguating string.
+// Register will panic if a handle for the same name was already registered.
+func Register(name string, handler Handler) Handle {
+ mutex.Lock()
+ defer mutex.Unlock()
+
+ if _, ok := names[name]; ok {
+ panic(fmt.Errorf("catmsg: handler for %q already exists", name))
+ }
+ h := Handle(len(handlers))
+ names[name] = h
+ handlers = append(handlers, handler)
+ return h
+}
+
+// These handlers require fixed positions in the handlers slice.
+const (
+ msgVars Handle = iota
+ msgFirst
+ msgRaw
+ msgString
+ msgAffix
+ // Leave some arbitrary room for future expansion: 20 should suffice.
+ numInternal = 20
+)
+
+const prefix = "golang.org/x/text/internal/catmsg."
+
+var (
+ // TODO: find a more stable way to link handles to message types.
+ mutex sync.Mutex
+ names = map[string]Handle{
+ prefix + "Vars": msgVars,
+ prefix + "First": msgFirst,
+ prefix + "Raw": msgRaw,
+ prefix + "String": msgString,
+ prefix + "Affix": msgAffix,
+ }
+ handlers = make([]Handler, numInternal)
+)
+
+func init() {
+ // This handler is a message type wrapper that initializes a decoder
+ // with a variable block. This message type, if present, is always at the
+ // start of an encoded message.
+ handlers[msgVars] = func(d *Decoder) bool {
+ blockSize := int(d.DecodeUint())
+ d.vars = d.data[:blockSize]
+ d.data = d.data[blockSize:]
+ return d.executeMessage()
+ }
+
+ // First takes the first message in a sequence that results in a match for
+ // the given substitution arguments.
+ handlers[msgFirst] = func(d *Decoder) bool {
+ for !d.Done() {
+ if d.ExecuteMessage() {
+ return true
+ }
+ }
+ return false
+ }
+
+ handlers[msgRaw] = func(d *Decoder) bool {
+ d.Render(d.data)
+ return true
+ }
+
+ // A String message alternates between a string constant and a variable
+ // substitution.
+ handlers[msgString] = func(d *Decoder) bool {
+ for !d.Done() {
+ if str := d.DecodeString(); str != "" {
+ d.Render(str)
+ }
+ if d.Done() {
+ break
+ }
+ d.ExecuteSubstitution()
+ }
+ return true
+ }
+
+ handlers[msgAffix] = func(d *Decoder) bool {
+ // TODO: use an alternative method for common cases.
+ prefix := d.DecodeString()
+ suffix := d.DecodeString()
+ if prefix != "" {
+ d.Render(prefix)
+ }
+ ret := d.ExecuteMessage()
+ if suffix != "" {
+ d.Render(suffix)
+ }
+ return ret
+ }
+}
+
+var (
+ // ErrIncomplete indicates a compiled message does not define translations
+ // for all possible argument values. If this message is returned, evaluating
+ // a message may result in the ErrNoMatch error.
+ ErrIncomplete = errors.New("catmsg: incomplete message; may not give result for all inputs")
+
+ // ErrNoMatch indicates no translation message matched the given input
+ // parameters when evaluating a message.
+ ErrNoMatch = errors.New("catmsg: no translation for inputs")
+)
+
+// A Message holds a collection of translations for the same phrase that may
+// vary based on the values of substitution arguments.
+type Message interface {
+ // Compile encodes the format string(s) of the message as a string for later
+ // evaluation.
+ //
+ // The first call Compile makes on the encoder must be EncodeMessageType.
+ // The handle passed to this call may either be a handle returned by
+ // Register to encode a single custom message, or HandleFirst followed by
+ // a sequence of calls to EncodeMessage.
+ //
+ // Compile must return ErrIncomplete if it is possible for evaluation to
+ // not match any translation for a given set of formatting parameters.
+ // For example, selecting a translation based on plural form may not yield
+ // a match if the form "Other" is not one of the selectors.
+ //
+ // Compile may return any other application-specific error. For backwards
+ // compatibility with package like fmt, which often do not do sanity
+ // checking of format strings ahead of time, Compile should still make an
+ // effort to have some sensible fallback in case of an error.
+ Compile(e *Encoder) error
+}
+
+// Compile converts a Message to a data string that can be stored in a Catalog.
+// The resulting string can subsequently be decoded by passing to the Execute
+// method of a Decoder.
+func Compile(tag language.Tag, macros Dictionary, m Message) (data string, err error) {
+ // TODO: pass macros so they can be used for validation.
+ v := &Encoder{inBody: true} // encoder for variables
+ v.root = v
+ e := &Encoder{root: v, parent: v, tag: tag} // encoder for messages
+ err = m.Compile(e)
+ // This package serves te message package, which in turn is meant to be a
+ // drop-in replacement for fmt. With the fmt package, format strings are
+ // evaluated lazily and errors are handled by substituting strings in the
+ // result, rather then returning an error. Dealing with multiple languages
+ // makes it more important to check errors ahead of time. We chose to be
+ // consistent and compatible and allow graceful degradation in case of
+ // errors.
+ buf := e.buf[stripPrefix(e.buf):]
+ if len(v.buf) > 0 {
+ // Prepend variable block.
+ b := make([]byte, 1+maxVarintBytes+len(v.buf)+len(buf))
+ b[0] = byte(msgVars)
+ b = b[:1+encodeUint(b[1:], uint64(len(v.buf)))]
+ b = append(b, v.buf...)
+ b = append(b, buf...)
+ buf = b
+ }
+ if err == nil {
+ err = v.err
+ }
+ return string(buf), err
+}
+
+// FirstOf is a message type that prints the first message in the sequence that
+// resolves to a match for the given substitution arguments.
+type FirstOf []Message
+
+// Compile implements Message.
+func (s FirstOf) Compile(e *Encoder) error {
+ e.EncodeMessageType(msgFirst)
+ err := ErrIncomplete
+ for i, m := range s {
+ if err == nil {
+ return fmt.Errorf("catalog: message argument %d is complete and blocks subsequent messages", i-1)
+ }
+ err = e.EncodeMessage(m)
+ }
+ return err
+}
+
+// Var defines a message that can be substituted for a placeholder of the same
+// name. If an expression does not result in a string after evaluation, Name is
+// used as the substitution. For example:
+//
+// Var{
+// Name: "minutes",
+// Message: plural.Select(1, "one", "minute"),
+// }
+//
+// will resolve to minute for singular and minutes for plural forms.
+type Var struct {
+ Name string
+ Message Message
+}
+
+var errIsVar = errors.New("catmsg: variable used as message")
+
+// Compile implements Message.
+//
+// Note that this method merely registers a variable; it does not create an
+// encoded message.
+func (v *Var) Compile(e *Encoder) error {
+ if err := e.addVar(v.Name, v.Message); err != nil {
+ return err
+ }
+ // Using a Var by itself is an error. If it is in a sequence followed by
+ // other messages referring to it, this error will be ignored.
+ return errIsVar
+}
+
+// Raw is a message consisting of a single format string that is passed as is
+// to the Renderer.
+//
+// Note that a Renderer may still do its own variable substitution.
+type Raw string
+
+// Compile implements Message.
+func (r Raw) Compile(e *Encoder) (err error) {
+ e.EncodeMessageType(msgRaw)
+ // Special case: raw strings don't have a size encoding and so don't use
+ // EncodeString.
+ e.buf = append(e.buf, r...)
+ return nil
+}
+
+// String is a message consisting of a single format string which contains
+// placeholders that may be substituted with variables.
+//
+// Variable substitutions are marked with placeholders and a variable name of
+// the form ${name}. Any other substitutions such as Go templates or
+// printf-style substitutions are left to be done by the Renderer.
+//
+// When evaluation a string interpolation, a Renderer will receive separate
+// calls for each placeholder and interstitial string. For example, for the
+// message: "%[1]v ${invites} %[2]v to ${their} party." The sequence of calls
+// is:
+//
+// d.Render("%[1]v ")
+// d.Arg(1)
+// d.Render(resultOfInvites)
+// d.Render(" %[2]v to ")
+// d.Arg(2)
+// d.Render(resultOfTheir)
+// d.Render(" party.")
+//
+// where the messages for "invites" and "their" both use a plural.Select
+// referring to the first argument.
+//
+// Strings may also invoke macros. Macros are essentially variables that can be
+// reused. Macros may, for instance, be used to make selections between
+// different conjugations of a verb. See the catalog package description for an
+// overview of macros.
+type String string
+
+// Compile implements Message. It parses the placeholder formats and returns
+// any error.
+func (s String) Compile(e *Encoder) (err error) {
+ msg := string(s)
+ const subStart = "${"
+ hasHeader := false
+ p := 0
+ b := []byte{}
+ for {
+ i := strings.Index(msg[p:], subStart)
+ if i == -1 {
+ break
+ }
+ b = append(b, msg[p:p+i]...)
+ p += i + len(subStart)
+ if i = strings.IndexByte(msg[p:], '}'); i == -1 {
+ b = append(b, "$!(MISSINGBRACE)"...)
+ err = fmt.Errorf("catmsg: missing '}'")
+ p = len(msg)
+ break
+ }
+ name := strings.TrimSpace(msg[p : p+i])
+ if q := strings.IndexByte(name, '('); q == -1 {
+ if !hasHeader {
+ hasHeader = true
+ e.EncodeMessageType(msgString)
+ }
+ e.EncodeString(string(b))
+ e.EncodeSubstitution(name)
+ b = b[:0]
+ } else if j := strings.IndexByte(name[q:], ')'); j == -1 {
+ // TODO: what should the error be?
+ b = append(b, "$!(MISSINGPAREN)"...)
+ err = fmt.Errorf("catmsg: missing ')'")
+ } else if x, sErr := strconv.ParseUint(strings.TrimSpace(name[q+1:q+j]), 10, 32); sErr != nil {
+ // TODO: handle more than one argument
+ b = append(b, "$!(BADNUM)"...)
+ err = fmt.Errorf("catmsg: invalid number %q", strings.TrimSpace(name[q+1:q+j]))
+ } else {
+ if !hasHeader {
+ hasHeader = true
+ e.EncodeMessageType(msgString)
+ }
+ e.EncodeString(string(b))
+ e.EncodeSubstitution(name[:q], int(x))
+ b = b[:0]
+ }
+ p += i + 1
+ }
+ b = append(b, msg[p:]...)
+ if !hasHeader {
+ // Simplify string to a raw string.
+ Raw(string(b)).Compile(e)
+ } else if len(b) > 0 {
+ e.EncodeString(string(b))
+ }
+ return err
+}
+
+// Affix is a message that adds a prefix and suffix to another message.
+// This is mostly used add back whitespace to a translation that was stripped
+// before sending it out.
+type Affix struct {
+ Message Message
+ Prefix string
+ Suffix string
+}
+
+// Compile implements Message.
+func (a Affix) Compile(e *Encoder) (err error) {
+ // TODO: consider adding a special message type that just adds a single
+ // return. This is probably common enough to handle the majority of cases.
+ // Get some stats first, though.
+ e.EncodeMessageType(msgAffix)
+ e.EncodeString(a.Prefix)
+ e.EncodeString(a.Suffix)
+ e.EncodeMessage(a.Message)
+ return nil
+}
diff --git a/vendor/golang.org/x/text/internal/catmsg/codec.go b/vendor/golang.org/x/text/internal/catmsg/codec.go
new file mode 100644
index 0000000..49c9fc9
--- /dev/null
+++ b/vendor/golang.org/x/text/internal/catmsg/codec.go
@@ -0,0 +1,407 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package catmsg
+
+import (
+ "errors"
+ "fmt"
+
+ "golang.org/x/text/language"
+)
+
+// A Renderer renders a Message.
+type Renderer interface {
+ // Render renders the given string. The given string may be interpreted as a
+ // format string, such as the one used by the fmt package or a template.
+ Render(s string)
+
+ // Arg returns the i-th argument passed to format a message. This method
+ // should return nil if there is no such argument. Messages need access to
+ // arguments to allow selecting a message based on linguistic features of
+ // those arguments.
+ Arg(i int) interface{}
+}
+
+// A Dictionary specifies a source of messages, including variables or macros.
+type Dictionary interface {
+ // Lookup returns the message for the given key. It returns false for ok if
+ // such a message could not be found.
+ Lookup(key string) (data string, ok bool)
+
+ // TODO: consider returning an interface, instead of a string. This will
+ // allow implementations to do their own message type decoding.
+}
+
+// An Encoder serializes a Message to a string.
+type Encoder struct {
+ // The root encoder is used for storing encoded variables.
+ root *Encoder
+ // The parent encoder provides the surrounding scopes for resolving variable
+ // names.
+ parent *Encoder
+
+ tag language.Tag
+
+ // buf holds the encoded message so far. After a message completes encoding,
+ // the contents of buf, prefixed by the encoded length, are flushed to the
+ // parent buffer.
+ buf []byte
+
+ // vars is the lookup table of variables in the current scope.
+ vars []keyVal
+
+ err error
+ inBody bool // if false next call must be EncodeMessageType
+}
+
+type keyVal struct {
+ key string
+ offset int
+}
+
+// Language reports the language for which the encoded message will be stored
+// in the Catalog.
+func (e *Encoder) Language() language.Tag { return e.tag }
+
+func (e *Encoder) setError(err error) {
+ if e.root.err == nil {
+ e.root.err = err
+ }
+}
+
+// EncodeUint encodes x.
+func (e *Encoder) EncodeUint(x uint64) {
+ e.checkInBody()
+ var buf [maxVarintBytes]byte
+ n := encodeUint(buf[:], x)
+ e.buf = append(e.buf, buf[:n]...)
+}
+
+// EncodeString encodes s.
+func (e *Encoder) EncodeString(s string) {
+ e.checkInBody()
+ e.EncodeUint(uint64(len(s)))
+ e.buf = append(e.buf, s...)
+}
+
+// EncodeMessageType marks the current message to be of type h.
+//
+// It must be the first call of a Message's Compile method.
+func (e *Encoder) EncodeMessageType(h Handle) {
+ if e.inBody {
+ panic("catmsg: EncodeMessageType not the first method called")
+ }
+ e.inBody = true
+ e.EncodeUint(uint64(h))
+}
+
+// EncodeMessage serializes the given message inline at the current position.
+func (e *Encoder) EncodeMessage(m Message) error {
+ e = &Encoder{root: e.root, parent: e, tag: e.tag}
+ err := m.Compile(e)
+ if _, ok := m.(*Var); !ok {
+ e.flushTo(e.parent)
+ }
+ return err
+}
+
+func (e *Encoder) checkInBody() {
+ if !e.inBody {
+ panic("catmsg: expected prior call to EncodeMessageType")
+ }
+}
+
+// stripPrefix indicates the number of prefix bytes that must be stripped to
+// turn a single-element sequence into a message that is just this single member
+// without its size prefix. If the message can be stripped, b[1:n] contains the
+// size prefix.
+func stripPrefix(b []byte) (n int) {
+ if len(b) > 0 && Handle(b[0]) == msgFirst {
+ x, n, _ := decodeUint(b[1:])
+ if 1+n+int(x) == len(b) {
+ return 1 + n
+ }
+ }
+ return 0
+}
+
+func (e *Encoder) flushTo(dst *Encoder) {
+ data := e.buf
+ p := stripPrefix(data)
+ if p > 0 {
+ data = data[1:]
+ } else {
+ // Prefix the size.
+ dst.EncodeUint(uint64(len(data)))
+ }
+ dst.buf = append(dst.buf, data...)
+}
+
+func (e *Encoder) addVar(key string, m Message) error {
+ for _, v := range e.parent.vars {
+ if v.key == key {
+ err := fmt.Errorf("catmsg: duplicate variable %q", key)
+ e.setError(err)
+ return err
+ }
+ }
+ scope := e.parent
+ // If a variable message is Incomplete, and does not evaluate to a message
+ // during execution, we fall back to the variable name. We encode this by
+ // appending the variable name if the message reports it's incomplete.
+
+ err := m.Compile(e)
+ if err != ErrIncomplete {
+ e.setError(err)
+ }
+ switch {
+ case len(e.buf) == 1 && Handle(e.buf[0]) == msgFirst: // empty sequence
+ e.buf = e.buf[:0]
+ e.inBody = false
+ fallthrough
+ case len(e.buf) == 0:
+ // Empty message.
+ if err := String(key).Compile(e); err != nil {
+ e.setError(err)
+ }
+ case err == ErrIncomplete:
+ if Handle(e.buf[0]) != msgFirst {
+ seq := &Encoder{root: e.root, parent: e}
+ seq.EncodeMessageType(msgFirst)
+ e.flushTo(seq)
+ e = seq
+ }
+ // e contains a sequence; append the fallback string.
+ e.EncodeMessage(String(key))
+ }
+
+ // Flush result to variable heap.
+ offset := len(e.root.buf)
+ e.flushTo(e.root)
+ e.buf = e.buf[:0]
+
+ // Record variable offset in current scope.
+ scope.vars = append(scope.vars, keyVal{key: key, offset: offset})
+ return err
+}
+
+const (
+ substituteVar = iota
+ substituteMacro
+ substituteError
+)
+
+// EncodeSubstitution inserts a resolved reference to a variable or macro.
+//
+// This call must be matched with a call to ExecuteSubstitution at decoding
+// time.
+func (e *Encoder) EncodeSubstitution(name string, arguments ...int) {
+ if arity := len(arguments); arity > 0 {
+ // TODO: also resolve macros.
+ e.EncodeUint(substituteMacro)
+ e.EncodeString(name)
+ for _, a := range arguments {
+ e.EncodeUint(uint64(a))
+ }
+ return
+ }
+ for scope := e; scope != nil; scope = scope.parent {
+ for _, v := range scope.vars {
+ if v.key != name {
+ continue
+ }
+ e.EncodeUint(substituteVar) // TODO: support arity > 0
+ e.EncodeUint(uint64(v.offset))
+ return
+ }
+ }
+ // TODO: refer to dictionary-wide scoped variables.
+ e.EncodeUint(substituteError)
+ e.EncodeString(name)
+ e.setError(fmt.Errorf("catmsg: unknown var %q", name))
+}
+
+// A Decoder deserializes and evaluates messages that are encoded by an encoder.
+type Decoder struct {
+ tag language.Tag
+ dst Renderer
+ macros Dictionary
+
+ err error
+ vars string
+ data string
+
+ macroArg int // TODO: allow more than one argument
+}
+
+// NewDecoder returns a new Decoder.
+//
+// Decoders are designed to be reused for multiple invocations of Execute.
+// Only one goroutine may call Execute concurrently.
+func NewDecoder(tag language.Tag, r Renderer, macros Dictionary) *Decoder {
+ return &Decoder{
+ tag: tag,
+ dst: r,
+ macros: macros,
+ }
+}
+
+func (d *Decoder) setError(err error) {
+ if d.err == nil {
+ d.err = err
+ }
+}
+
+// Language returns the language in which the message is being rendered.
+//
+// The destination language may be a child language of the language used for
+// encoding. For instance, a decoding language of "pt-PT"" is consistent with an
+// encoding language of "pt".
+func (d *Decoder) Language() language.Tag { return d.tag }
+
+// Done reports whether there are more bytes to process in this message.
+func (d *Decoder) Done() bool { return len(d.data) == 0 }
+
+// Render implements Renderer.
+func (d *Decoder) Render(s string) { d.dst.Render(s) }
+
+// Arg implements Renderer.
+//
+// During evaluation of macros, the argument positions may be mapped to
+// arguments that differ from the original call.
+func (d *Decoder) Arg(i int) interface{} {
+ if d.macroArg != 0 {
+ if i != 1 {
+ panic("catmsg: only macros with single argument supported")
+ }
+ i = d.macroArg
+ }
+ return d.dst.Arg(i)
+}
+
+// DecodeUint decodes a number that was encoded with EncodeUint and advances the
+// position.
+func (d *Decoder) DecodeUint() uint64 {
+ x, n, err := decodeUintString(d.data)
+ d.data = d.data[n:]
+ if err != nil {
+ d.setError(err)
+ }
+ return x
+}
+
+// DecodeString decodes a string that was encoded with EncodeString and advances
+// the position.
+func (d *Decoder) DecodeString() string {
+ size := d.DecodeUint()
+ s := d.data[:size]
+ d.data = d.data[size:]
+ return s
+}
+
+// SkipMessage skips the message at the current location and advances the
+// position.
+func (d *Decoder) SkipMessage() {
+ n := int(d.DecodeUint())
+ d.data = d.data[n:]
+}
+
+// Execute decodes and evaluates msg.
+//
+// Only one goroutine may call execute.
+func (d *Decoder) Execute(msg string) error {
+ d.err = nil
+ if !d.execute(msg) {
+ return ErrNoMatch
+ }
+ return d.err
+}
+
+func (d *Decoder) execute(msg string) bool {
+ saved := d.data
+ d.data = msg
+ ok := d.executeMessage()
+ d.data = saved
+ return ok
+}
+
+// executeMessageFromData is like execute, but also decodes a leading message
+// size and clips the given string accordingly.
+//
+// It reports the number of bytes consumed and whether a message was selected.
+func (d *Decoder) executeMessageFromData(s string) (n int, ok bool) {
+ saved := d.data
+ d.data = s
+ size := int(d.DecodeUint())
+ n = len(s) - len(d.data)
+ // Sanitize the setting. This allows skipping a size argument for
+ // RawString and method Done.
+ d.data = d.data[:size]
+ ok = d.executeMessage()
+ n += size - len(d.data)
+ d.data = saved
+ return n, ok
+}
+
+var errUnknownHandler = errors.New("catmsg: string contains unsupported handler")
+
+// executeMessage reads the handle id, initializes the decoder and executes the
+// message. It is assumed that all of d.data[d.p:] is the single message.
+func (d *Decoder) executeMessage() bool {
+ if d.Done() {
+ // We interpret no data as a valid empty message.
+ return true
+ }
+ handle := d.DecodeUint()
+
+ var fn Handler
+ mutex.Lock()
+ if int(handle) < len(handlers) {
+ fn = handlers[handle]
+ }
+ mutex.Unlock()
+ if fn == nil {
+ d.setError(errUnknownHandler)
+ d.execute(fmt.Sprintf("\x02$!(UNKNOWNMSGHANDLER=%#x)", handle))
+ return true
+ }
+ return fn(d)
+}
+
+// ExecuteMessage decodes and executes the message at the current position.
+func (d *Decoder) ExecuteMessage() bool {
+ n, ok := d.executeMessageFromData(d.data)
+ d.data = d.data[n:]
+ return ok
+}
+
+// ExecuteSubstitution executes the message corresponding to the substitution
+// as encoded by EncodeSubstitution.
+func (d *Decoder) ExecuteSubstitution() {
+ switch x := d.DecodeUint(); x {
+ case substituteVar:
+ offset := d.DecodeUint()
+ d.executeMessageFromData(d.vars[offset:])
+ case substituteMacro:
+ name := d.DecodeString()
+ data, ok := d.macros.Lookup(name)
+ old := d.macroArg
+ // TODO: support macros of arity other than 1.
+ d.macroArg = int(d.DecodeUint())
+ switch {
+ case !ok:
+ // TODO: detect this at creation time.
+ d.setError(fmt.Errorf("catmsg: undefined macro %q", name))
+ fallthrough
+ case !d.execute(data):
+ d.dst.Render(name) // fall back to macro name.
+ }
+ d.macroArg = old
+ case substituteError:
+ d.dst.Render(d.DecodeString())
+ default:
+ panic("catmsg: unreachable")
+ }
+}
diff --git a/vendor/golang.org/x/text/internal/catmsg/varint.go b/vendor/golang.org/x/text/internal/catmsg/varint.go
new file mode 100644
index 0000000..a2cee2c
--- /dev/null
+++ b/vendor/golang.org/x/text/internal/catmsg/varint.go
@@ -0,0 +1,62 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package catmsg
+
+// This file implements varint encoding analogous to the one in encoding/binary.
+// We need a string version of this function, so we add that here and then add
+// the rest for consistency.
+
+import "errors"
+
+var (
+ errIllegalVarint = errors.New("catmsg: illegal varint")
+ errVarintTooLarge = errors.New("catmsg: varint too large for uint64")
+)
+
+const maxVarintBytes = 10 // maximum length of a varint
+
+// encodeUint encodes x as a variable-sized integer into buf and returns the
+// number of bytes written. buf must be at least maxVarintBytes long
+func encodeUint(buf []byte, x uint64) (n int) {
+ for ; x > 127; n++ {
+ buf[n] = 0x80 | uint8(x&0x7F)
+ x >>= 7
+ }
+ buf[n] = uint8(x)
+ n++
+ return n
+}
+
+func decodeUintString(s string) (x uint64, size int, err error) {
+ i := 0
+ for shift := uint(0); shift < 64; shift += 7 {
+ if i >= len(s) {
+ return 0, i, errIllegalVarint
+ }
+ b := uint64(s[i])
+ i++
+ x |= (b & 0x7F) << shift
+ if b&0x80 == 0 {
+ return x, i, nil
+ }
+ }
+ return 0, i, errVarintTooLarge
+}
+
+func decodeUint(b []byte) (x uint64, size int, err error) {
+ i := 0
+ for shift := uint(0); shift < 64; shift += 7 {
+ if i >= len(b) {
+ return 0, i, errIllegalVarint
+ }
+ c := uint64(b[i])
+ i++
+ x |= (c & 0x7F) << shift
+ if c&0x80 == 0 {
+ return x, i, nil
+ }
+ }
+ return 0, i, errVarintTooLarge
+}
diff --git a/vendor/golang.org/x/text/internal/format/format.go b/vendor/golang.org/x/text/internal/format/format.go
new file mode 100644
index 0000000..ee1c57a
--- /dev/null
+++ b/vendor/golang.org/x/text/internal/format/format.go
@@ -0,0 +1,41 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package format contains types for defining language-specific formatting of
+// values.
+//
+// This package is internal now, but will eventually be exposed after the API
+// settles.
+package format // import "golang.org/x/text/internal/format"
+
+import (
+ "fmt"
+
+ "golang.org/x/text/language"
+)
+
+// State represents the printer state passed to custom formatters. It provides
+// access to the fmt.State interface and the sentence and language-related
+// context.
+type State interface {
+ fmt.State
+
+ // Language reports the requested language in which to render a message.
+ Language() language.Tag
+
+ // TODO: consider this and removing rune from the Format method in the
+ // Formatter interface.
+ //
+ // Verb returns the format variant to render, analogous to the types used
+ // in fmt. Use 'v' for the default or only variant.
+ // Verb() rune
+
+ // TODO: more info:
+ // - sentence context such as linguistic features passed by the translator.
+}
+
+// Formatter is analogous to fmt.Formatter.
+type Formatter interface {
+ Format(state State, verb rune)
+}
diff --git a/vendor/golang.org/x/text/internal/format/parser.go b/vendor/golang.org/x/text/internal/format/parser.go
new file mode 100644
index 0000000..855aed7
--- /dev/null
+++ b/vendor/golang.org/x/text/internal/format/parser.go
@@ -0,0 +1,358 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package format
+
+import (
+ "reflect"
+ "unicode/utf8"
+)
+
+// A Parser parses a format string. The result from the parse are set in the
+// struct fields.
+type Parser struct {
+ Verb rune
+
+ WidthPresent bool
+ PrecPresent bool
+ Minus bool
+ Plus bool
+ Sharp bool
+ Space bool
+ Zero bool
+
+ // For the formats %+v %#v, we set the plusV/sharpV flags
+ // and clear the plus/sharp flags since %+v and %#v are in effect
+ // different, flagless formats set at the top level.
+ PlusV bool
+ SharpV bool
+
+ HasIndex bool
+
+ Width int
+ Prec int // precision
+
+ // retain arguments across calls.
+ Args []interface{}
+ // retain current argument number across calls
+ ArgNum int
+
+ // reordered records whether the format string used argument reordering.
+ Reordered bool
+ // goodArgNum records whether the most recent reordering directive was valid.
+ goodArgNum bool
+
+ // position info
+ format string
+ startPos int
+ endPos int
+ Status Status
+}
+
+// Reset initializes a parser to scan format strings for the given args.
+func (p *Parser) Reset(args []interface{}) {
+ p.Args = args
+ p.ArgNum = 0
+ p.startPos = 0
+ p.Reordered = false
+}
+
+// Text returns the part of the format string that was parsed by the last call
+// to Scan. It returns the original substitution clause if the current scan
+// parsed a substitution.
+func (p *Parser) Text() string { return p.format[p.startPos:p.endPos] }
+
+// SetFormat sets a new format string to parse. It does not reset the argument
+// count.
+func (p *Parser) SetFormat(format string) {
+ p.format = format
+ p.startPos = 0
+ p.endPos = 0
+}
+
+// Status indicates the result type of a call to Scan.
+type Status int
+
+const (
+ StatusText Status = iota
+ StatusSubstitution
+ StatusBadWidthSubstitution
+ StatusBadPrecSubstitution
+ StatusNoVerb
+ StatusBadArgNum
+ StatusMissingArg
+)
+
+// ClearFlags reset the parser to default behavior.
+func (p *Parser) ClearFlags() {
+ p.WidthPresent = false
+ p.PrecPresent = false
+ p.Minus = false
+ p.Plus = false
+ p.Sharp = false
+ p.Space = false
+ p.Zero = false
+
+ p.PlusV = false
+ p.SharpV = false
+
+ p.HasIndex = false
+}
+
+// Scan scans the next part of the format string and sets the status to
+// indicate whether it scanned a string literal, substitution or error.
+func (p *Parser) Scan() bool {
+ p.Status = StatusText
+ format := p.format
+ end := len(format)
+ if p.endPos >= end {
+ return false
+ }
+ afterIndex := false // previous item in format was an index like [3].
+
+ p.startPos = p.endPos
+ p.goodArgNum = true
+ i := p.startPos
+ for i < end && format[i] != '%' {
+ i++
+ }
+ if i > p.startPos {
+ p.endPos = i
+ return true
+ }
+ // Process one verb
+ i++
+
+ p.Status = StatusSubstitution
+
+ // Do we have flags?
+ p.ClearFlags()
+
+simpleFormat:
+ for ; i < end; i++ {
+ c := p.format[i]
+ switch c {
+ case '#':
+ p.Sharp = true
+ case '0':
+ p.Zero = !p.Minus // Only allow zero padding to the left.
+ case '+':
+ p.Plus = true
+ case '-':
+ p.Minus = true
+ p.Zero = false // Do not pad with zeros to the right.
+ case ' ':
+ p.Space = true
+ default:
+ // Fast path for common case of ascii lower case simple verbs
+ // without precision or width or argument indices.
+ if 'a' <= c && c <= 'z' && p.ArgNum < len(p.Args) {
+ if c == 'v' {
+ // Go syntax
+ p.SharpV = p.Sharp
+ p.Sharp = false
+ // Struct-field syntax
+ p.PlusV = p.Plus
+ p.Plus = false
+ }
+ p.Verb = rune(c)
+ p.ArgNum++
+ p.endPos = i + 1
+ return true
+ }
+ // Format is more complex than simple flags and a verb or is malformed.
+ break simpleFormat
+ }
+ }
+
+ // Do we have an explicit argument index?
+ i, afterIndex = p.updateArgNumber(format, i)
+
+ // Do we have width?
+ if i < end && format[i] == '*' {
+ i++
+ p.Width, p.WidthPresent = p.intFromArg()
+
+ if !p.WidthPresent {
+ p.Status = StatusBadWidthSubstitution
+ }
+
+ // We have a negative width, so take its value and ensure
+ // that the minus flag is set
+ if p.Width < 0 {
+ p.Width = -p.Width
+ p.Minus = true
+ p.Zero = false // Do not pad with zeros to the right.
+ }
+ afterIndex = false
+ } else {
+ p.Width, p.WidthPresent, i = parsenum(format, i, end)
+ if afterIndex && p.WidthPresent { // "%[3]2d"
+ p.goodArgNum = false
+ }
+ }
+
+ // Do we have precision?
+ if i+1 < end && format[i] == '.' {
+ i++
+ if afterIndex { // "%[3].2d"
+ p.goodArgNum = false
+ }
+ i, afterIndex = p.updateArgNumber(format, i)
+ if i < end && format[i] == '*' {
+ i++
+ p.Prec, p.PrecPresent = p.intFromArg()
+ // Negative precision arguments don't make sense
+ if p.Prec < 0 {
+ p.Prec = 0
+ p.PrecPresent = false
+ }
+ if !p.PrecPresent {
+ p.Status = StatusBadPrecSubstitution
+ }
+ afterIndex = false
+ } else {
+ p.Prec, p.PrecPresent, i = parsenum(format, i, end)
+ if !p.PrecPresent {
+ p.Prec = 0
+ p.PrecPresent = true
+ }
+ }
+ }
+
+ if !afterIndex {
+ i, afterIndex = p.updateArgNumber(format, i)
+ }
+ p.HasIndex = afterIndex
+
+ if i >= end {
+ p.endPos = i
+ p.Status = StatusNoVerb
+ return true
+ }
+
+ verb, w := utf8.DecodeRuneInString(format[i:])
+ p.endPos = i + w
+ p.Verb = verb
+
+ switch {
+ case verb == '%': // Percent does not absorb operands and ignores f.wid and f.prec.
+ p.startPos = p.endPos - 1
+ p.Status = StatusText
+ case !p.goodArgNum:
+ p.Status = StatusBadArgNum
+ case p.ArgNum >= len(p.Args): // No argument left over to print for the current verb.
+ p.Status = StatusMissingArg
+ p.ArgNum++
+ case verb == 'v':
+ // Go syntax
+ p.SharpV = p.Sharp
+ p.Sharp = false
+ // Struct-field syntax
+ p.PlusV = p.Plus
+ p.Plus = false
+ fallthrough
+ default:
+ p.ArgNum++
+ }
+ return true
+}
+
+// intFromArg gets the ArgNumth element of Args. On return, isInt reports
+// whether the argument has integer type.
+func (p *Parser) intFromArg() (num int, isInt bool) {
+ if p.ArgNum < len(p.Args) {
+ arg := p.Args[p.ArgNum]
+ num, isInt = arg.(int) // Almost always OK.
+ if !isInt {
+ // Work harder.
+ switch v := reflect.ValueOf(arg); v.Kind() {
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ n := v.Int()
+ if int64(int(n)) == n {
+ num = int(n)
+ isInt = true
+ }
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+ n := v.Uint()
+ if int64(n) >= 0 && uint64(int(n)) == n {
+ num = int(n)
+ isInt = true
+ }
+ default:
+ // Already 0, false.
+ }
+ }
+ p.ArgNum++
+ if tooLarge(num) {
+ num = 0
+ isInt = false
+ }
+ }
+ return
+}
+
+// parseArgNumber returns the value of the bracketed number, minus 1
+// (explicit argument numbers are one-indexed but we want zero-indexed).
+// The opening bracket is known to be present at format[0].
+// The returned values are the index, the number of bytes to consume
+// up to the closing paren, if present, and whether the number parsed
+// ok. The bytes to consume will be 1 if no closing paren is present.
+func parseArgNumber(format string) (index int, wid int, ok bool) {
+ // There must be at least 3 bytes: [n].
+ if len(format) < 3 {
+ return 0, 1, false
+ }
+
+ // Find closing bracket.
+ for i := 1; i < len(format); i++ {
+ if format[i] == ']' {
+ width, ok, newi := parsenum(format, 1, i)
+ if !ok || newi != i {
+ return 0, i + 1, false
+ }
+ return width - 1, i + 1, true // arg numbers are one-indexed and skip paren.
+ }
+ }
+ return 0, 1, false
+}
+
+// updateArgNumber returns the next argument to evaluate, which is either the value of the passed-in
+// argNum or the value of the bracketed integer that begins format[i:]. It also returns
+// the new value of i, that is, the index of the next byte of the format to process.
+func (p *Parser) updateArgNumber(format string, i int) (newi int, found bool) {
+ if len(format) <= i || format[i] != '[' {
+ return i, false
+ }
+ p.Reordered = true
+ index, wid, ok := parseArgNumber(format[i:])
+ if ok && 0 <= index && index < len(p.Args) {
+ p.ArgNum = index
+ return i + wid, true
+ }
+ p.goodArgNum = false
+ return i + wid, ok
+}
+
+// tooLarge reports whether the magnitude of the integer is
+// too large to be used as a formatting width or precision.
+func tooLarge(x int) bool {
+ const max int = 1e6
+ return x > max || x < -max
+}
+
+// parsenum converts ASCII to integer. num is 0 (and isnum is false) if no number present.
+func parsenum(s string, start, end int) (num int, isnum bool, newi int) {
+ if start >= end {
+ return 0, false, end
+ }
+ for newi = start; newi < end && '0' <= s[newi] && s[newi] <= '9'; newi++ {
+ if tooLarge(num) {
+ return 0, false, end // Overflow; crazy long number most likely.
+ }
+ num = num*10 + int(s[newi]-'0')
+ isnum = true
+ }
+ return
+}
diff --git a/vendor/golang.org/x/text/internal/internal.go b/vendor/golang.org/x/text/internal/internal.go
new file mode 100644
index 0000000..3cddbbd
--- /dev/null
+++ b/vendor/golang.org/x/text/internal/internal.go
@@ -0,0 +1,49 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package internal contains non-exported functionality that are used by
+// packages in the text repository.
+package internal // import "golang.org/x/text/internal"
+
+import (
+ "sort"
+
+ "golang.org/x/text/language"
+)
+
+// SortTags sorts tags in place.
+func SortTags(tags []language.Tag) {
+ sort.Sort(sorter(tags))
+}
+
+type sorter []language.Tag
+
+func (s sorter) Len() int {
+ return len(s)
+}
+
+func (s sorter) Swap(i, j int) {
+ s[i], s[j] = s[j], s[i]
+}
+
+func (s sorter) Less(i, j int) bool {
+ return s[i].String() < s[j].String()
+}
+
+// UniqueTags sorts and filters duplicate tags in place and returns a slice with
+// only unique tags.
+func UniqueTags(tags []language.Tag) []language.Tag {
+ if len(tags) <= 1 {
+ return tags
+ }
+ SortTags(tags)
+ k := 0
+ for i := 1; i < len(tags); i++ {
+ if tags[k].String() < tags[i].String() {
+ k++
+ tags[k] = tags[i]
+ }
+ }
+ return tags[:k+1]
+}
diff --git a/vendor/golang.org/x/text/internal/language/common.go b/vendor/golang.org/x/text/internal/language/common.go
new file mode 100644
index 0000000..cdfdb74
--- /dev/null
+++ b/vendor/golang.org/x/text/internal/language/common.go
@@ -0,0 +1,16 @@
+// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
+
+package language
+
+// This file contains code common to the maketables.go and the package code.
+
+// AliasType is the type of an alias in AliasMap.
+type AliasType int8
+
+const (
+ Deprecated AliasType = iota
+ Macro
+ Legacy
+
+ AliasTypeUnknown AliasType = -1
+)
diff --git a/vendor/golang.org/x/text/internal/language/compact.go b/vendor/golang.org/x/text/internal/language/compact.go
new file mode 100644
index 0000000..46a0015
--- /dev/null
+++ b/vendor/golang.org/x/text/internal/language/compact.go
@@ -0,0 +1,29 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package language
+
+// CompactCoreInfo is a compact integer with the three core tags encoded.
+type CompactCoreInfo uint32
+
+// GetCompactCore generates a uint32 value that is guaranteed to be unique for
+// different language, region, and script values.
+func GetCompactCore(t Tag) (cci CompactCoreInfo, ok bool) {
+ if t.LangID > langNoIndexOffset {
+ return 0, false
+ }
+ cci |= CompactCoreInfo(t.LangID) << (8 + 12)
+ cci |= CompactCoreInfo(t.ScriptID) << 12
+ cci |= CompactCoreInfo(t.RegionID)
+ return cci, true
+}
+
+// Tag generates a tag from c.
+func (c CompactCoreInfo) Tag() Tag {
+ return Tag{
+ LangID: Language(c >> 20),
+ RegionID: Region(c & 0x3ff),
+ ScriptID: Script(c>>12) & 0xff,
+ }
+}
diff --git a/vendor/golang.org/x/text/internal/language/compact/compact.go b/vendor/golang.org/x/text/internal/language/compact/compact.go
new file mode 100644
index 0000000..1b36935
--- /dev/null
+++ b/vendor/golang.org/x/text/internal/language/compact/compact.go
@@ -0,0 +1,61 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package compact defines a compact representation of language tags.
+//
+// Common language tags (at least all for which locale information is defined
+// in CLDR) are assigned a unique index. Each Tag is associated with such an
+// ID for selecting language-related resources (such as translations) as well
+// as one for selecting regional defaults (currency, number formatting, etc.)
+//
+// It may want to export this functionality at some point, but at this point
+// this is only available for use within x/text.
+package compact // import "golang.org/x/text/internal/language/compact"
+
+import (
+ "sort"
+ "strings"
+
+ "golang.org/x/text/internal/language"
+)
+
+// ID is an integer identifying a single tag.
+type ID uint16
+
+func getCoreIndex(t language.Tag) (id ID, ok bool) {
+ cci, ok := language.GetCompactCore(t)
+ if !ok {
+ return 0, false
+ }
+ i := sort.Search(len(coreTags), func(i int) bool {
+ return cci <= coreTags[i]
+ })
+ if i == len(coreTags) || coreTags[i] != cci {
+ return 0, false
+ }
+ return ID(i), true
+}
+
+// Parent returns the ID of the parent or the root ID if id is already the root.
+func (id ID) Parent() ID {
+ return parents[id]
+}
+
+// Tag converts id to an internal language Tag.
+func (id ID) Tag() language.Tag {
+ if int(id) >= len(coreTags) {
+ return specialTags[int(id)-len(coreTags)]
+ }
+ return coreTags[id].Tag()
+}
+
+var specialTags []language.Tag
+
+func init() {
+ tags := strings.Split(specialTagsStr, " ")
+ specialTags = make([]language.Tag, len(tags))
+ for i, t := range tags {
+ specialTags[i] = language.MustParse(t)
+ }
+}
diff --git a/vendor/golang.org/x/text/internal/language/compact/language.go b/vendor/golang.org/x/text/internal/language/compact/language.go
new file mode 100644
index 0000000..83816a7
--- /dev/null
+++ b/vendor/golang.org/x/text/internal/language/compact/language.go
@@ -0,0 +1,260 @@
+// Copyright 2013 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:generate go run gen.go gen_index.go -output tables.go
+//go:generate go run gen_parents.go
+
+package compact
+
+// TODO: Remove above NOTE after:
+// - verifying that tables are dropped correctly (most notably matcher tables).
+
+import (
+ "strings"
+
+ "golang.org/x/text/internal/language"
+)
+
+// Tag represents a BCP 47 language tag. It is used to specify an instance of a
+// specific language or locale. All language tag values are guaranteed to be
+// well-formed.
+type Tag struct {
+ // NOTE: exported tags will become part of the public API.
+ language ID
+ locale ID
+ full fullTag // always a language.Tag for now.
+}
+
+const _und = 0
+
+type fullTag interface {
+ IsRoot() bool
+ Parent() language.Tag
+}
+
+// Make a compact Tag from a fully specified internal language Tag.
+func Make(t language.Tag) (tag Tag) {
+ if region := t.TypeForKey("rg"); len(region) == 6 && region[2:] == "zzzz" {
+ if r, err := language.ParseRegion(region[:2]); err == nil {
+ tFull := t
+ t, _ = t.SetTypeForKey("rg", "")
+ // TODO: should we not consider "va" for the language tag?
+ var exact1, exact2 bool
+ tag.language, exact1 = FromTag(t)
+ t.RegionID = r
+ tag.locale, exact2 = FromTag(t)
+ if !exact1 || !exact2 {
+ tag.full = tFull
+ }
+ return tag
+ }
+ }
+ lang, ok := FromTag(t)
+ tag.language = lang
+ tag.locale = lang
+ if !ok {
+ tag.full = t
+ }
+ return tag
+}
+
+// Tag returns an internal language Tag version of this tag.
+func (t Tag) Tag() language.Tag {
+ if t.full != nil {
+ return t.full.(language.Tag)
+ }
+ tag := t.language.Tag()
+ if t.language != t.locale {
+ loc := t.locale.Tag()
+ tag, _ = tag.SetTypeForKey("rg", strings.ToLower(loc.RegionID.String())+"zzzz")
+ }
+ return tag
+}
+
+// IsCompact reports whether this tag is fully defined in terms of ID.
+func (t *Tag) IsCompact() bool {
+ return t.full == nil
+}
+
+// MayHaveVariants reports whether a tag may have variants. If it returns false
+// it is guaranteed the tag does not have variants.
+func (t Tag) MayHaveVariants() bool {
+ return t.full != nil || int(t.language) >= len(coreTags)
+}
+
+// MayHaveExtensions reports whether a tag may have extensions. If it returns
+// false it is guaranteed the tag does not have them.
+func (t Tag) MayHaveExtensions() bool {
+ return t.full != nil ||
+ int(t.language) >= len(coreTags) ||
+ t.language != t.locale
+}
+
+// IsRoot returns true if t is equal to language "und".
+func (t Tag) IsRoot() bool {
+ if t.full != nil {
+ return t.full.IsRoot()
+ }
+ return t.language == _und
+}
+
+// Parent returns the CLDR parent of t. In CLDR, missing fields in data for a
+// specific language are substituted with fields from the parent language.
+// The parent for a language may change for newer versions of CLDR.
+func (t Tag) Parent() Tag {
+ if t.full != nil {
+ return Make(t.full.Parent())
+ }
+ if t.language != t.locale {
+ // Simulate stripping -u-rg-xxxxxx
+ return Tag{language: t.language, locale: t.language}
+ }
+ // TODO: use parent lookup table once cycle from internal package is
+ // removed. Probably by internalizing the table and declaring this fast
+ // enough.
+ // lang := compactID(internal.Parent(uint16(t.language)))
+ lang, _ := FromTag(t.language.Tag().Parent())
+ return Tag{language: lang, locale: lang}
+}
+
+// returns token t and the rest of the string.
+func nextToken(s string) (t, tail string) {
+ p := strings.Index(s[1:], "-")
+ if p == -1 {
+ return s[1:], ""
+ }
+ p++
+ return s[1:p], s[p:]
+}
+
+// LanguageID returns an index, where 0 <= index < NumCompactTags, for tags
+// for which data exists in the text repository.The index will change over time
+// and should not be stored in persistent storage. If t does not match a compact
+// index, exact will be false and the compact index will be returned for the
+// first match after repeatedly taking the Parent of t.
+func LanguageID(t Tag) (id ID, exact bool) {
+ return t.language, t.full == nil
+}
+
+// RegionalID returns the ID for the regional variant of this tag. This index is
+// used to indicate region-specific overrides, such as default currency, default
+// calendar and week data, default time cycle, and default measurement system
+// and unit preferences.
+//
+// For instance, the tag en-GB-u-rg-uszzzz specifies British English with US
+// settings for currency, number formatting, etc. The CompactIndex for this tag
+// will be that for en-GB, while the RegionalID will be the one corresponding to
+// en-US.
+func RegionalID(t Tag) (id ID, exact bool) {
+ return t.locale, t.full == nil
+}
+
+// LanguageTag returns t stripped of regional variant indicators.
+//
+// At the moment this means it is stripped of a regional and variant subtag "rg"
+// and "va" in the "u" extension.
+func (t Tag) LanguageTag() Tag {
+ if t.full == nil {
+ return Tag{language: t.language, locale: t.language}
+ }
+ tt := t.Tag()
+ tt.SetTypeForKey("rg", "")
+ tt.SetTypeForKey("va", "")
+ return Make(tt)
+}
+
+// RegionalTag returns the regional variant of the tag.
+//
+// At the moment this means that the region is set from the regional subtag
+// "rg" in the "u" extension.
+func (t Tag) RegionalTag() Tag {
+ rt := Tag{language: t.locale, locale: t.locale}
+ if t.full == nil {
+ return rt
+ }
+ b := language.Builder{}
+ tag := t.Tag()
+ // tag, _ = tag.SetTypeForKey("rg", "")
+ b.SetTag(t.locale.Tag())
+ if v := tag.Variants(); v != "" {
+ for _, v := range strings.Split(v, "-") {
+ b.AddVariant(v)
+ }
+ }
+ for _, e := range tag.Extensions() {
+ b.AddExt(e)
+ }
+ return t
+}
+
+// FromTag reports closest matching ID for an internal language Tag.
+func FromTag(t language.Tag) (id ID, exact bool) {
+ // TODO: perhaps give more frequent tags a lower index.
+ // TODO: we could make the indexes stable. This will excluded some
+ // possibilities for optimization, so don't do this quite yet.
+ exact = true
+
+ b, s, r := t.Raw()
+ if t.HasString() {
+ if t.IsPrivateUse() {
+ // We have no entries for user-defined tags.
+ return 0, false
+ }
+ hasExtra := false
+ if t.HasVariants() {
+ if t.HasExtensions() {
+ build := language.Builder{}
+ build.SetTag(language.Tag{LangID: b, ScriptID: s, RegionID: r})
+ build.AddVariant(t.Variants())
+ exact = false
+ t = build.Make()
+ }
+ hasExtra = true
+ } else if _, ok := t.Extension('u'); ok {
+ // TODO: va may mean something else. Consider not considering it.
+ // Strip all but the 'va' entry.
+ old := t
+ variant := t.TypeForKey("va")
+ t = language.Tag{LangID: b, ScriptID: s, RegionID: r}
+ if variant != "" {
+ t, _ = t.SetTypeForKey("va", variant)
+ hasExtra = true
+ }
+ exact = old == t
+ } else {
+ exact = false
+ }
+ if hasExtra {
+ // We have some variants.
+ for i, s := range specialTags {
+ if s == t {
+ return ID(i + len(coreTags)), exact
+ }
+ }
+ exact = false
+ }
+ }
+ if x, ok := getCoreIndex(t); ok {
+ return x, exact
+ }
+ exact = false
+ if r != 0 && s == 0 {
+ // Deal with cases where an extra script is inserted for the region.
+ t, _ := t.Maximize()
+ if x, ok := getCoreIndex(t); ok {
+ return x, exact
+ }
+ }
+ for t = t.Parent(); t != root; t = t.Parent() {
+ // No variants specified: just compare core components.
+ // The key has the form lllssrrr, where l, s, and r are nibbles for
+ // respectively the langID, scriptID, and regionID.
+ if x, ok := getCoreIndex(t); ok {
+ return x, exact
+ }
+ }
+ return 0, exact
+}
+
+var root = language.Tag{}
diff --git a/vendor/golang.org/x/text/internal/language/compact/parents.go b/vendor/golang.org/x/text/internal/language/compact/parents.go
new file mode 100644
index 0000000..8d81072
--- /dev/null
+++ b/vendor/golang.org/x/text/internal/language/compact/parents.go
@@ -0,0 +1,120 @@
+// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
+
+package compact
+
+// parents maps a compact index of a tag to the compact index of the parent of
+// this tag.
+var parents = []ID{ // 775 elements
+ // Entry 0 - 3F
+ 0x0000, 0x0000, 0x0001, 0x0001, 0x0000, 0x0004, 0x0000, 0x0006,
+ 0x0000, 0x0008, 0x0000, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a,
+ 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a,
+ 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a,
+ 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x0000,
+ 0x0000, 0x0028, 0x0000, 0x002a, 0x0000, 0x002c, 0x0000, 0x0000,
+ 0x002f, 0x002e, 0x002e, 0x0000, 0x0033, 0x0000, 0x0035, 0x0000,
+ 0x0037, 0x0000, 0x0039, 0x0000, 0x003b, 0x0000, 0x0000, 0x003e,
+ // Entry 40 - 7F
+ 0x0000, 0x0040, 0x0040, 0x0000, 0x0043, 0x0043, 0x0000, 0x0046,
+ 0x0000, 0x0048, 0x0000, 0x0000, 0x004b, 0x004a, 0x004a, 0x0000,
+ 0x004f, 0x004f, 0x004f, 0x004f, 0x0000, 0x0054, 0x0054, 0x0000,
+ 0x0057, 0x0000, 0x0059, 0x0000, 0x005b, 0x0000, 0x005d, 0x005d,
+ 0x0000, 0x0060, 0x0000, 0x0062, 0x0000, 0x0064, 0x0000, 0x0066,
+ 0x0066, 0x0000, 0x0069, 0x0000, 0x006b, 0x006b, 0x006b, 0x006b,
+ 0x006b, 0x006b, 0x006b, 0x0000, 0x0073, 0x0000, 0x0075, 0x0000,
+ 0x0077, 0x0000, 0x0000, 0x007a, 0x0000, 0x007c, 0x0000, 0x007e,
+ // Entry 80 - BF
+ 0x0000, 0x0080, 0x0080, 0x0000, 0x0083, 0x0083, 0x0000, 0x0086,
+ 0x0087, 0x0087, 0x0087, 0x0086, 0x0088, 0x0087, 0x0087, 0x0087,
+ 0x0086, 0x0087, 0x0087, 0x0087, 0x0087, 0x0087, 0x0087, 0x0088,
+ 0x0087, 0x0087, 0x0087, 0x0087, 0x0088, 0x0087, 0x0088, 0x0087,
+ 0x0087, 0x0088, 0x0087, 0x0087, 0x0087, 0x0087, 0x0087, 0x0087,
+ 0x0087, 0x0087, 0x0087, 0x0086, 0x0087, 0x0087, 0x0087, 0x0087,
+ 0x0087, 0x0087, 0x0087, 0x0087, 0x0087, 0x0087, 0x0087, 0x0087,
+ 0x0087, 0x0087, 0x0087, 0x0087, 0x0087, 0x0086, 0x0087, 0x0086,
+ // Entry C0 - FF
+ 0x0087, 0x0087, 0x0087, 0x0087, 0x0087, 0x0087, 0x0087, 0x0087,
+ 0x0088, 0x0087, 0x0087, 0x0087, 0x0087, 0x0087, 0x0087, 0x0087,
+ 0x0086, 0x0087, 0x0087, 0x0087, 0x0087, 0x0087, 0x0088, 0x0087,
+ 0x0087, 0x0088, 0x0087, 0x0087, 0x0087, 0x0087, 0x0087, 0x0087,
+ 0x0087, 0x0087, 0x0087, 0x0087, 0x0087, 0x0086, 0x0086, 0x0087,
+ 0x0087, 0x0086, 0x0087, 0x0087, 0x0087, 0x0087, 0x0087, 0x0000,
+ 0x00ef, 0x0000, 0x00f1, 0x00f2, 0x00f2, 0x00f2, 0x00f2, 0x00f2,
+ 0x00f2, 0x00f2, 0x00f2, 0x00f2, 0x00f1, 0x00f2, 0x00f1, 0x00f1,
+ // Entry 100 - 13F
+ 0x00f2, 0x00f2, 0x00f1, 0x00f2, 0x00f2, 0x00f2, 0x00f2, 0x00f1,
+ 0x00f2, 0x00f2, 0x00f2, 0x00f2, 0x00f2, 0x00f2, 0x0000, 0x010e,
+ 0x0000, 0x0110, 0x0000, 0x0112, 0x0000, 0x0114, 0x0114, 0x0000,
+ 0x0117, 0x0117, 0x0117, 0x0117, 0x0000, 0x011c, 0x0000, 0x011e,
+ 0x0000, 0x0120, 0x0120, 0x0000, 0x0123, 0x0123, 0x0123, 0x0123,
+ 0x0123, 0x0123, 0x0123, 0x0123, 0x0123, 0x0123, 0x0123, 0x0123,
+ 0x0123, 0x0123, 0x0123, 0x0123, 0x0123, 0x0123, 0x0123, 0x0123,
+ 0x0123, 0x0123, 0x0123, 0x0123, 0x0123, 0x0123, 0x0123, 0x0123,
+ // Entry 140 - 17F
+ 0x0123, 0x0123, 0x0123, 0x0123, 0x0123, 0x0123, 0x0123, 0x0123,
+ 0x0123, 0x0123, 0x0123, 0x0123, 0x0123, 0x0123, 0x0123, 0x0123,
+ 0x0123, 0x0123, 0x0000, 0x0152, 0x0000, 0x0154, 0x0000, 0x0156,
+ 0x0000, 0x0158, 0x0000, 0x015a, 0x0000, 0x015c, 0x015c, 0x015c,
+ 0x0000, 0x0160, 0x0000, 0x0000, 0x0163, 0x0000, 0x0165, 0x0000,
+ 0x0167, 0x0167, 0x0167, 0x0000, 0x016b, 0x0000, 0x016d, 0x0000,
+ 0x016f, 0x0000, 0x0171, 0x0171, 0x0000, 0x0174, 0x0000, 0x0176,
+ 0x0000, 0x0178, 0x0000, 0x017a, 0x0000, 0x017c, 0x0000, 0x017e,
+ // Entry 180 - 1BF
+ 0x0000, 0x0000, 0x0000, 0x0182, 0x0000, 0x0184, 0x0184, 0x0184,
+ 0x0184, 0x0000, 0x0000, 0x0000, 0x018b, 0x0000, 0x0000, 0x018e,
+ 0x0000, 0x0000, 0x0191, 0x0000, 0x0000, 0x0000, 0x0195, 0x0000,
+ 0x0197, 0x0000, 0x0000, 0x019a, 0x0000, 0x0000, 0x019d, 0x0000,
+ 0x019f, 0x0000, 0x01a1, 0x0000, 0x01a3, 0x0000, 0x01a5, 0x0000,
+ 0x01a7, 0x0000, 0x01a9, 0x0000, 0x01ab, 0x0000, 0x01ad, 0x0000,
+ 0x01af, 0x0000, 0x01b1, 0x01b1, 0x0000, 0x01b4, 0x0000, 0x01b6,
+ 0x0000, 0x01b8, 0x0000, 0x01ba, 0x0000, 0x01bc, 0x0000, 0x0000,
+ // Entry 1C0 - 1FF
+ 0x01bf, 0x0000, 0x01c1, 0x0000, 0x01c3, 0x0000, 0x01c5, 0x0000,
+ 0x01c7, 0x0000, 0x01c9, 0x0000, 0x01cb, 0x01cb, 0x01cb, 0x01cb,
+ 0x0000, 0x01d0, 0x0000, 0x01d2, 0x01d2, 0x0000, 0x01d5, 0x0000,
+ 0x01d7, 0x0000, 0x01d9, 0x0000, 0x01db, 0x0000, 0x01dd, 0x0000,
+ 0x01df, 0x01df, 0x0000, 0x01e2, 0x0000, 0x01e4, 0x0000, 0x01e6,
+ 0x0000, 0x01e8, 0x0000, 0x01ea, 0x0000, 0x01ec, 0x0000, 0x01ee,
+ 0x0000, 0x01f0, 0x0000, 0x0000, 0x01f3, 0x0000, 0x01f5, 0x01f5,
+ 0x01f5, 0x0000, 0x01f9, 0x0000, 0x01fb, 0x0000, 0x01fd, 0x0000,
+ // Entry 200 - 23F
+ 0x01ff, 0x0000, 0x0000, 0x0202, 0x0000, 0x0204, 0x0204, 0x0000,
+ 0x0207, 0x0000, 0x0209, 0x0209, 0x0000, 0x020c, 0x020c, 0x0000,
+ 0x020f, 0x020f, 0x020f, 0x020f, 0x020f, 0x020f, 0x020f, 0x0000,
+ 0x0217, 0x0000, 0x0219, 0x0000, 0x021b, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0221, 0x0000, 0x0000, 0x0224, 0x0000, 0x0226,
+ 0x0226, 0x0000, 0x0229, 0x0000, 0x022b, 0x022b, 0x0000, 0x0000,
+ 0x022f, 0x022e, 0x022e, 0x0000, 0x0000, 0x0234, 0x0000, 0x0236,
+ 0x0000, 0x0238, 0x0000, 0x0244, 0x023a, 0x0244, 0x0244, 0x0244,
+ // Entry 240 - 27F
+ 0x0244, 0x0244, 0x0244, 0x0244, 0x023a, 0x0244, 0x0244, 0x0000,
+ 0x0247, 0x0247, 0x0247, 0x0000, 0x024b, 0x0000, 0x024d, 0x0000,
+ 0x024f, 0x024f, 0x0000, 0x0252, 0x0000, 0x0254, 0x0254, 0x0254,
+ 0x0254, 0x0254, 0x0254, 0x0000, 0x025b, 0x0000, 0x025d, 0x0000,
+ 0x025f, 0x0000, 0x0261, 0x0000, 0x0263, 0x0000, 0x0265, 0x0000,
+ 0x0000, 0x0268, 0x0268, 0x0268, 0x0000, 0x026c, 0x0000, 0x026e,
+ 0x0000, 0x0270, 0x0000, 0x0000, 0x0000, 0x0274, 0x0273, 0x0273,
+ 0x0000, 0x0278, 0x0000, 0x027a, 0x0000, 0x027c, 0x0000, 0x0000,
+ // Entry 280 - 2BF
+ 0x0000, 0x0000, 0x0281, 0x0000, 0x0000, 0x0284, 0x0000, 0x0286,
+ 0x0286, 0x0286, 0x0286, 0x0000, 0x028b, 0x028b, 0x028b, 0x0000,
+ 0x028f, 0x028f, 0x028f, 0x028f, 0x028f, 0x0000, 0x0295, 0x0295,
+ 0x0295, 0x0295, 0x0000, 0x0000, 0x0000, 0x0000, 0x029d, 0x029d,
+ 0x029d, 0x0000, 0x02a1, 0x02a1, 0x02a1, 0x02a1, 0x0000, 0x0000,
+ 0x02a7, 0x02a7, 0x02a7, 0x02a7, 0x0000, 0x02ac, 0x0000, 0x02ae,
+ 0x02ae, 0x0000, 0x02b1, 0x0000, 0x02b3, 0x0000, 0x02b5, 0x02b5,
+ 0x0000, 0x0000, 0x02b9, 0x0000, 0x0000, 0x0000, 0x02bd, 0x0000,
+ // Entry 2C0 - 2FF
+ 0x02bf, 0x02bf, 0x0000, 0x0000, 0x02c3, 0x0000, 0x02c5, 0x0000,
+ 0x02c7, 0x0000, 0x02c9, 0x0000, 0x02cb, 0x0000, 0x02cd, 0x02cd,
+ 0x0000, 0x0000, 0x02d1, 0x0000, 0x02d3, 0x02d0, 0x02d0, 0x0000,
+ 0x0000, 0x02d8, 0x02d7, 0x02d7, 0x0000, 0x0000, 0x02dd, 0x0000,
+ 0x02df, 0x0000, 0x02e1, 0x0000, 0x0000, 0x02e4, 0x0000, 0x02e6,
+ 0x0000, 0x0000, 0x02e9, 0x0000, 0x02eb, 0x0000, 0x02ed, 0x0000,
+ 0x02ef, 0x02ef, 0x0000, 0x0000, 0x02f3, 0x02f2, 0x02f2, 0x0000,
+ 0x02f7, 0x0000, 0x02f9, 0x02f9, 0x02f9, 0x02f9, 0x02f9, 0x0000,
+ // Entry 300 - 33F
+ 0x02ff, 0x0300, 0x02ff, 0x0000, 0x0303, 0x0051, 0x00e6,
+} // Size: 1574 bytes
+
+// Total table size 1574 bytes (1KiB); checksum: 895AAF0B
diff --git a/vendor/golang.org/x/text/internal/language/compact/tables.go b/vendor/golang.org/x/text/internal/language/compact/tables.go
new file mode 100644
index 0000000..32af9de
--- /dev/null
+++ b/vendor/golang.org/x/text/internal/language/compact/tables.go
@@ -0,0 +1,1015 @@
+// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
+
+package compact
+
+import "golang.org/x/text/internal/language"
+
+// CLDRVersion is the CLDR version from which the tables in this package are derived.
+const CLDRVersion = "32"
+
+// NumCompactTags is the number of common tags. The maximum tag is
+// NumCompactTags-1.
+const NumCompactTags = 775
+const (
+ undIndex ID = 0
+ afIndex ID = 1
+ afNAIndex ID = 2
+ afZAIndex ID = 3
+ agqIndex ID = 4
+ agqCMIndex ID = 5
+ akIndex ID = 6
+ akGHIndex ID = 7
+ amIndex ID = 8
+ amETIndex ID = 9
+ arIndex ID = 10
+ ar001Index ID = 11
+ arAEIndex ID = 12
+ arBHIndex ID = 13
+ arDJIndex ID = 14
+ arDZIndex ID = 15
+ arEGIndex ID = 16
+ arEHIndex ID = 17
+ arERIndex ID = 18
+ arILIndex ID = 19
+ arIQIndex ID = 20
+ arJOIndex ID = 21
+ arKMIndex ID = 22
+ arKWIndex ID = 23
+ arLBIndex ID = 24
+ arLYIndex ID = 25
+ arMAIndex ID = 26
+ arMRIndex ID = 27
+ arOMIndex ID = 28
+ arPSIndex ID = 29
+ arQAIndex ID = 30
+ arSAIndex ID = 31
+ arSDIndex ID = 32
+ arSOIndex ID = 33
+ arSSIndex ID = 34
+ arSYIndex ID = 35
+ arTDIndex ID = 36
+ arTNIndex ID = 37
+ arYEIndex ID = 38
+ arsIndex ID = 39
+ asIndex ID = 40
+ asINIndex ID = 41
+ asaIndex ID = 42
+ asaTZIndex ID = 43
+ astIndex ID = 44
+ astESIndex ID = 45
+ azIndex ID = 46
+ azCyrlIndex ID = 47
+ azCyrlAZIndex ID = 48
+ azLatnIndex ID = 49
+ azLatnAZIndex ID = 50
+ basIndex ID = 51
+ basCMIndex ID = 52
+ beIndex ID = 53
+ beBYIndex ID = 54
+ bemIndex ID = 55
+ bemZMIndex ID = 56
+ bezIndex ID = 57
+ bezTZIndex ID = 58
+ bgIndex ID = 59
+ bgBGIndex ID = 60
+ bhIndex ID = 61
+ bmIndex ID = 62
+ bmMLIndex ID = 63
+ bnIndex ID = 64
+ bnBDIndex ID = 65
+ bnINIndex ID = 66
+ boIndex ID = 67
+ boCNIndex ID = 68
+ boINIndex ID = 69
+ brIndex ID = 70
+ brFRIndex ID = 71
+ brxIndex ID = 72
+ brxINIndex ID = 73
+ bsIndex ID = 74
+ bsCyrlIndex ID = 75
+ bsCyrlBAIndex ID = 76
+ bsLatnIndex ID = 77
+ bsLatnBAIndex ID = 78
+ caIndex ID = 79
+ caADIndex ID = 80
+ caESIndex ID = 81
+ caFRIndex ID = 82
+ caITIndex ID = 83
+ ccpIndex ID = 84
+ ccpBDIndex ID = 85
+ ccpINIndex ID = 86
+ ceIndex ID = 87
+ ceRUIndex ID = 88
+ cggIndex ID = 89
+ cggUGIndex ID = 90
+ chrIndex ID = 91
+ chrUSIndex ID = 92
+ ckbIndex ID = 93
+ ckbIQIndex ID = 94
+ ckbIRIndex ID = 95
+ csIndex ID = 96
+ csCZIndex ID = 97
+ cuIndex ID = 98
+ cuRUIndex ID = 99
+ cyIndex ID = 100
+ cyGBIndex ID = 101
+ daIndex ID = 102
+ daDKIndex ID = 103
+ daGLIndex ID = 104
+ davIndex ID = 105
+ davKEIndex ID = 106
+ deIndex ID = 107
+ deATIndex ID = 108
+ deBEIndex ID = 109
+ deCHIndex ID = 110
+ deDEIndex ID = 111
+ deITIndex ID = 112
+ deLIIndex ID = 113
+ deLUIndex ID = 114
+ djeIndex ID = 115
+ djeNEIndex ID = 116
+ dsbIndex ID = 117
+ dsbDEIndex ID = 118
+ duaIndex ID = 119
+ duaCMIndex ID = 120
+ dvIndex ID = 121
+ dyoIndex ID = 122
+ dyoSNIndex ID = 123
+ dzIndex ID = 124
+ dzBTIndex ID = 125
+ ebuIndex ID = 126
+ ebuKEIndex ID = 127
+ eeIndex ID = 128
+ eeGHIndex ID = 129
+ eeTGIndex ID = 130
+ elIndex ID = 131
+ elCYIndex ID = 132
+ elGRIndex ID = 133
+ enIndex ID = 134
+ en001Index ID = 135
+ en150Index ID = 136
+ enAGIndex ID = 137
+ enAIIndex ID = 138
+ enASIndex ID = 139
+ enATIndex ID = 140
+ enAUIndex ID = 141
+ enBBIndex ID = 142
+ enBEIndex ID = 143
+ enBIIndex ID = 144
+ enBMIndex ID = 145
+ enBSIndex ID = 146
+ enBWIndex ID = 147
+ enBZIndex ID = 148
+ enCAIndex ID = 149
+ enCCIndex ID = 150
+ enCHIndex ID = 151
+ enCKIndex ID = 152
+ enCMIndex ID = 153
+ enCXIndex ID = 154
+ enCYIndex ID = 155
+ enDEIndex ID = 156
+ enDGIndex ID = 157
+ enDKIndex ID = 158
+ enDMIndex ID = 159
+ enERIndex ID = 160
+ enFIIndex ID = 161
+ enFJIndex ID = 162
+ enFKIndex ID = 163
+ enFMIndex ID = 164
+ enGBIndex ID = 165
+ enGDIndex ID = 166
+ enGGIndex ID = 167
+ enGHIndex ID = 168
+ enGIIndex ID = 169
+ enGMIndex ID = 170
+ enGUIndex ID = 171
+ enGYIndex ID = 172
+ enHKIndex ID = 173
+ enIEIndex ID = 174
+ enILIndex ID = 175
+ enIMIndex ID = 176
+ enINIndex ID = 177
+ enIOIndex ID = 178
+ enJEIndex ID = 179
+ enJMIndex ID = 180
+ enKEIndex ID = 181
+ enKIIndex ID = 182
+ enKNIndex ID = 183
+ enKYIndex ID = 184
+ enLCIndex ID = 185
+ enLRIndex ID = 186
+ enLSIndex ID = 187
+ enMGIndex ID = 188
+ enMHIndex ID = 189
+ enMOIndex ID = 190
+ enMPIndex ID = 191
+ enMSIndex ID = 192
+ enMTIndex ID = 193
+ enMUIndex ID = 194
+ enMWIndex ID = 195
+ enMYIndex ID = 196
+ enNAIndex ID = 197
+ enNFIndex ID = 198
+ enNGIndex ID = 199
+ enNLIndex ID = 200
+ enNRIndex ID = 201
+ enNUIndex ID = 202
+ enNZIndex ID = 203
+ enPGIndex ID = 204
+ enPHIndex ID = 205
+ enPKIndex ID = 206
+ enPNIndex ID = 207
+ enPRIndex ID = 208
+ enPWIndex ID = 209
+ enRWIndex ID = 210
+ enSBIndex ID = 211
+ enSCIndex ID = 212
+ enSDIndex ID = 213
+ enSEIndex ID = 214
+ enSGIndex ID = 215
+ enSHIndex ID = 216
+ enSIIndex ID = 217
+ enSLIndex ID = 218
+ enSSIndex ID = 219
+ enSXIndex ID = 220
+ enSZIndex ID = 221
+ enTCIndex ID = 222
+ enTKIndex ID = 223
+ enTOIndex ID = 224
+ enTTIndex ID = 225
+ enTVIndex ID = 226
+ enTZIndex ID = 227
+ enUGIndex ID = 228
+ enUMIndex ID = 229
+ enUSIndex ID = 230
+ enVCIndex ID = 231
+ enVGIndex ID = 232
+ enVIIndex ID = 233
+ enVUIndex ID = 234
+ enWSIndex ID = 235
+ enZAIndex ID = 236
+ enZMIndex ID = 237
+ enZWIndex ID = 238
+ eoIndex ID = 239
+ eo001Index ID = 240
+ esIndex ID = 241
+ es419Index ID = 242
+ esARIndex ID = 243
+ esBOIndex ID = 244
+ esBRIndex ID = 245
+ esBZIndex ID = 246
+ esCLIndex ID = 247
+ esCOIndex ID = 248
+ esCRIndex ID = 249
+ esCUIndex ID = 250
+ esDOIndex ID = 251
+ esEAIndex ID = 252
+ esECIndex ID = 253
+ esESIndex ID = 254
+ esGQIndex ID = 255
+ esGTIndex ID = 256
+ esHNIndex ID = 257
+ esICIndex ID = 258
+ esMXIndex ID = 259
+ esNIIndex ID = 260
+ esPAIndex ID = 261
+ esPEIndex ID = 262
+ esPHIndex ID = 263
+ esPRIndex ID = 264
+ esPYIndex ID = 265
+ esSVIndex ID = 266
+ esUSIndex ID = 267
+ esUYIndex ID = 268
+ esVEIndex ID = 269
+ etIndex ID = 270
+ etEEIndex ID = 271
+ euIndex ID = 272
+ euESIndex ID = 273
+ ewoIndex ID = 274
+ ewoCMIndex ID = 275
+ faIndex ID = 276
+ faAFIndex ID = 277
+ faIRIndex ID = 278
+ ffIndex ID = 279
+ ffCMIndex ID = 280
+ ffGNIndex ID = 281
+ ffMRIndex ID = 282
+ ffSNIndex ID = 283
+ fiIndex ID = 284
+ fiFIIndex ID = 285
+ filIndex ID = 286
+ filPHIndex ID = 287
+ foIndex ID = 288
+ foDKIndex ID = 289
+ foFOIndex ID = 290
+ frIndex ID = 291
+ frBEIndex ID = 292
+ frBFIndex ID = 293
+ frBIIndex ID = 294
+ frBJIndex ID = 295
+ frBLIndex ID = 296
+ frCAIndex ID = 297
+ frCDIndex ID = 298
+ frCFIndex ID = 299
+ frCGIndex ID = 300
+ frCHIndex ID = 301
+ frCIIndex ID = 302
+ frCMIndex ID = 303
+ frDJIndex ID = 304
+ frDZIndex ID = 305
+ frFRIndex ID = 306
+ frGAIndex ID = 307
+ frGFIndex ID = 308
+ frGNIndex ID = 309
+ frGPIndex ID = 310
+ frGQIndex ID = 311
+ frHTIndex ID = 312
+ frKMIndex ID = 313
+ frLUIndex ID = 314
+ frMAIndex ID = 315
+ frMCIndex ID = 316
+ frMFIndex ID = 317
+ frMGIndex ID = 318
+ frMLIndex ID = 319
+ frMQIndex ID = 320
+ frMRIndex ID = 321
+ frMUIndex ID = 322
+ frNCIndex ID = 323
+ frNEIndex ID = 324
+ frPFIndex ID = 325
+ frPMIndex ID = 326
+ frREIndex ID = 327
+ frRWIndex ID = 328
+ frSCIndex ID = 329
+ frSNIndex ID = 330
+ frSYIndex ID = 331
+ frTDIndex ID = 332
+ frTGIndex ID = 333
+ frTNIndex ID = 334
+ frVUIndex ID = 335
+ frWFIndex ID = 336
+ frYTIndex ID = 337
+ furIndex ID = 338
+ furITIndex ID = 339
+ fyIndex ID = 340
+ fyNLIndex ID = 341
+ gaIndex ID = 342
+ gaIEIndex ID = 343
+ gdIndex ID = 344
+ gdGBIndex ID = 345
+ glIndex ID = 346
+ glESIndex ID = 347
+ gswIndex ID = 348
+ gswCHIndex ID = 349
+ gswFRIndex ID = 350
+ gswLIIndex ID = 351
+ guIndex ID = 352
+ guINIndex ID = 353
+ guwIndex ID = 354
+ guzIndex ID = 355
+ guzKEIndex ID = 356
+ gvIndex ID = 357
+ gvIMIndex ID = 358
+ haIndex ID = 359
+ haGHIndex ID = 360
+ haNEIndex ID = 361
+ haNGIndex ID = 362
+ hawIndex ID = 363
+ hawUSIndex ID = 364
+ heIndex ID = 365
+ heILIndex ID = 366
+ hiIndex ID = 367
+ hiINIndex ID = 368
+ hrIndex ID = 369
+ hrBAIndex ID = 370
+ hrHRIndex ID = 371
+ hsbIndex ID = 372
+ hsbDEIndex ID = 373
+ huIndex ID = 374
+ huHUIndex ID = 375
+ hyIndex ID = 376
+ hyAMIndex ID = 377
+ idIndex ID = 378
+ idIDIndex ID = 379
+ igIndex ID = 380
+ igNGIndex ID = 381
+ iiIndex ID = 382
+ iiCNIndex ID = 383
+ inIndex ID = 384
+ ioIndex ID = 385
+ isIndex ID = 386
+ isISIndex ID = 387
+ itIndex ID = 388
+ itCHIndex ID = 389
+ itITIndex ID = 390
+ itSMIndex ID = 391
+ itVAIndex ID = 392
+ iuIndex ID = 393
+ iwIndex ID = 394
+ jaIndex ID = 395
+ jaJPIndex ID = 396
+ jboIndex ID = 397
+ jgoIndex ID = 398
+ jgoCMIndex ID = 399
+ jiIndex ID = 400
+ jmcIndex ID = 401
+ jmcTZIndex ID = 402
+ jvIndex ID = 403
+ jwIndex ID = 404
+ kaIndex ID = 405
+ kaGEIndex ID = 406
+ kabIndex ID = 407
+ kabDZIndex ID = 408
+ kajIndex ID = 409
+ kamIndex ID = 410
+ kamKEIndex ID = 411
+ kcgIndex ID = 412
+ kdeIndex ID = 413
+ kdeTZIndex ID = 414
+ keaIndex ID = 415
+ keaCVIndex ID = 416
+ khqIndex ID = 417
+ khqMLIndex ID = 418
+ kiIndex ID = 419
+ kiKEIndex ID = 420
+ kkIndex ID = 421
+ kkKZIndex ID = 422
+ kkjIndex ID = 423
+ kkjCMIndex ID = 424
+ klIndex ID = 425
+ klGLIndex ID = 426
+ klnIndex ID = 427
+ klnKEIndex ID = 428
+ kmIndex ID = 429
+ kmKHIndex ID = 430
+ knIndex ID = 431
+ knINIndex ID = 432
+ koIndex ID = 433
+ koKPIndex ID = 434
+ koKRIndex ID = 435
+ kokIndex ID = 436
+ kokINIndex ID = 437
+ ksIndex ID = 438
+ ksINIndex ID = 439
+ ksbIndex ID = 440
+ ksbTZIndex ID = 441
+ ksfIndex ID = 442
+ ksfCMIndex ID = 443
+ kshIndex ID = 444
+ kshDEIndex ID = 445
+ kuIndex ID = 446
+ kwIndex ID = 447
+ kwGBIndex ID = 448
+ kyIndex ID = 449
+ kyKGIndex ID = 450
+ lagIndex ID = 451
+ lagTZIndex ID = 452
+ lbIndex ID = 453
+ lbLUIndex ID = 454
+ lgIndex ID = 455
+ lgUGIndex ID = 456
+ lktIndex ID = 457
+ lktUSIndex ID = 458
+ lnIndex ID = 459
+ lnAOIndex ID = 460
+ lnCDIndex ID = 461
+ lnCFIndex ID = 462
+ lnCGIndex ID = 463
+ loIndex ID = 464
+ loLAIndex ID = 465
+ lrcIndex ID = 466
+ lrcIQIndex ID = 467
+ lrcIRIndex ID = 468
+ ltIndex ID = 469
+ ltLTIndex ID = 470
+ luIndex ID = 471
+ luCDIndex ID = 472
+ luoIndex ID = 473
+ luoKEIndex ID = 474
+ luyIndex ID = 475
+ luyKEIndex ID = 476
+ lvIndex ID = 477
+ lvLVIndex ID = 478
+ masIndex ID = 479
+ masKEIndex ID = 480
+ masTZIndex ID = 481
+ merIndex ID = 482
+ merKEIndex ID = 483
+ mfeIndex ID = 484
+ mfeMUIndex ID = 485
+ mgIndex ID = 486
+ mgMGIndex ID = 487
+ mghIndex ID = 488
+ mghMZIndex ID = 489
+ mgoIndex ID = 490
+ mgoCMIndex ID = 491
+ mkIndex ID = 492
+ mkMKIndex ID = 493
+ mlIndex ID = 494
+ mlINIndex ID = 495
+ mnIndex ID = 496
+ mnMNIndex ID = 497
+ moIndex ID = 498
+ mrIndex ID = 499
+ mrINIndex ID = 500
+ msIndex ID = 501
+ msBNIndex ID = 502
+ msMYIndex ID = 503
+ msSGIndex ID = 504
+ mtIndex ID = 505
+ mtMTIndex ID = 506
+ muaIndex ID = 507
+ muaCMIndex ID = 508
+ myIndex ID = 509
+ myMMIndex ID = 510
+ mznIndex ID = 511
+ mznIRIndex ID = 512
+ nahIndex ID = 513
+ naqIndex ID = 514
+ naqNAIndex ID = 515
+ nbIndex ID = 516
+ nbNOIndex ID = 517
+ nbSJIndex ID = 518
+ ndIndex ID = 519
+ ndZWIndex ID = 520
+ ndsIndex ID = 521
+ ndsDEIndex ID = 522
+ ndsNLIndex ID = 523
+ neIndex ID = 524
+ neINIndex ID = 525
+ neNPIndex ID = 526
+ nlIndex ID = 527
+ nlAWIndex ID = 528
+ nlBEIndex ID = 529
+ nlBQIndex ID = 530
+ nlCWIndex ID = 531
+ nlNLIndex ID = 532
+ nlSRIndex ID = 533
+ nlSXIndex ID = 534
+ nmgIndex ID = 535
+ nmgCMIndex ID = 536
+ nnIndex ID = 537
+ nnNOIndex ID = 538
+ nnhIndex ID = 539
+ nnhCMIndex ID = 540
+ noIndex ID = 541
+ nqoIndex ID = 542
+ nrIndex ID = 543
+ nsoIndex ID = 544
+ nusIndex ID = 545
+ nusSSIndex ID = 546
+ nyIndex ID = 547
+ nynIndex ID = 548
+ nynUGIndex ID = 549
+ omIndex ID = 550
+ omETIndex ID = 551
+ omKEIndex ID = 552
+ orIndex ID = 553
+ orINIndex ID = 554
+ osIndex ID = 555
+ osGEIndex ID = 556
+ osRUIndex ID = 557
+ paIndex ID = 558
+ paArabIndex ID = 559
+ paArabPKIndex ID = 560
+ paGuruIndex ID = 561
+ paGuruINIndex ID = 562
+ papIndex ID = 563
+ plIndex ID = 564
+ plPLIndex ID = 565
+ prgIndex ID = 566
+ prg001Index ID = 567
+ psIndex ID = 568
+ psAFIndex ID = 569
+ ptIndex ID = 570
+ ptAOIndex ID = 571
+ ptBRIndex ID = 572
+ ptCHIndex ID = 573
+ ptCVIndex ID = 574
+ ptGQIndex ID = 575
+ ptGWIndex ID = 576
+ ptLUIndex ID = 577
+ ptMOIndex ID = 578
+ ptMZIndex ID = 579
+ ptPTIndex ID = 580
+ ptSTIndex ID = 581
+ ptTLIndex ID = 582
+ quIndex ID = 583
+ quBOIndex ID = 584
+ quECIndex ID = 585
+ quPEIndex ID = 586
+ rmIndex ID = 587
+ rmCHIndex ID = 588
+ rnIndex ID = 589
+ rnBIIndex ID = 590
+ roIndex ID = 591
+ roMDIndex ID = 592
+ roROIndex ID = 593
+ rofIndex ID = 594
+ rofTZIndex ID = 595
+ ruIndex ID = 596
+ ruBYIndex ID = 597
+ ruKGIndex ID = 598
+ ruKZIndex ID = 599
+ ruMDIndex ID = 600
+ ruRUIndex ID = 601
+ ruUAIndex ID = 602
+ rwIndex ID = 603
+ rwRWIndex ID = 604
+ rwkIndex ID = 605
+ rwkTZIndex ID = 606
+ sahIndex ID = 607
+ sahRUIndex ID = 608
+ saqIndex ID = 609
+ saqKEIndex ID = 610
+ sbpIndex ID = 611
+ sbpTZIndex ID = 612
+ sdIndex ID = 613
+ sdPKIndex ID = 614
+ sdhIndex ID = 615
+ seIndex ID = 616
+ seFIIndex ID = 617
+ seNOIndex ID = 618
+ seSEIndex ID = 619
+ sehIndex ID = 620
+ sehMZIndex ID = 621
+ sesIndex ID = 622
+ sesMLIndex ID = 623
+ sgIndex ID = 624
+ sgCFIndex ID = 625
+ shIndex ID = 626
+ shiIndex ID = 627
+ shiLatnIndex ID = 628
+ shiLatnMAIndex ID = 629
+ shiTfngIndex ID = 630
+ shiTfngMAIndex ID = 631
+ siIndex ID = 632
+ siLKIndex ID = 633
+ skIndex ID = 634
+ skSKIndex ID = 635
+ slIndex ID = 636
+ slSIIndex ID = 637
+ smaIndex ID = 638
+ smiIndex ID = 639
+ smjIndex ID = 640
+ smnIndex ID = 641
+ smnFIIndex ID = 642
+ smsIndex ID = 643
+ snIndex ID = 644
+ snZWIndex ID = 645
+ soIndex ID = 646
+ soDJIndex ID = 647
+ soETIndex ID = 648
+ soKEIndex ID = 649
+ soSOIndex ID = 650
+ sqIndex ID = 651
+ sqALIndex ID = 652
+ sqMKIndex ID = 653
+ sqXKIndex ID = 654
+ srIndex ID = 655
+ srCyrlIndex ID = 656
+ srCyrlBAIndex ID = 657
+ srCyrlMEIndex ID = 658
+ srCyrlRSIndex ID = 659
+ srCyrlXKIndex ID = 660
+ srLatnIndex ID = 661
+ srLatnBAIndex ID = 662
+ srLatnMEIndex ID = 663
+ srLatnRSIndex ID = 664
+ srLatnXKIndex ID = 665
+ ssIndex ID = 666
+ ssyIndex ID = 667
+ stIndex ID = 668
+ svIndex ID = 669
+ svAXIndex ID = 670
+ svFIIndex ID = 671
+ svSEIndex ID = 672
+ swIndex ID = 673
+ swCDIndex ID = 674
+ swKEIndex ID = 675
+ swTZIndex ID = 676
+ swUGIndex ID = 677
+ syrIndex ID = 678
+ taIndex ID = 679
+ taINIndex ID = 680
+ taLKIndex ID = 681
+ taMYIndex ID = 682
+ taSGIndex ID = 683
+ teIndex ID = 684
+ teINIndex ID = 685
+ teoIndex ID = 686
+ teoKEIndex ID = 687
+ teoUGIndex ID = 688
+ tgIndex ID = 689
+ tgTJIndex ID = 690
+ thIndex ID = 691
+ thTHIndex ID = 692
+ tiIndex ID = 693
+ tiERIndex ID = 694
+ tiETIndex ID = 695
+ tigIndex ID = 696
+ tkIndex ID = 697
+ tkTMIndex ID = 698
+ tlIndex ID = 699
+ tnIndex ID = 700
+ toIndex ID = 701
+ toTOIndex ID = 702
+ trIndex ID = 703
+ trCYIndex ID = 704
+ trTRIndex ID = 705
+ tsIndex ID = 706
+ ttIndex ID = 707
+ ttRUIndex ID = 708
+ twqIndex ID = 709
+ twqNEIndex ID = 710
+ tzmIndex ID = 711
+ tzmMAIndex ID = 712
+ ugIndex ID = 713
+ ugCNIndex ID = 714
+ ukIndex ID = 715
+ ukUAIndex ID = 716
+ urIndex ID = 717
+ urINIndex ID = 718
+ urPKIndex ID = 719
+ uzIndex ID = 720
+ uzArabIndex ID = 721
+ uzArabAFIndex ID = 722
+ uzCyrlIndex ID = 723
+ uzCyrlUZIndex ID = 724
+ uzLatnIndex ID = 725
+ uzLatnUZIndex ID = 726
+ vaiIndex ID = 727
+ vaiLatnIndex ID = 728
+ vaiLatnLRIndex ID = 729
+ vaiVaiiIndex ID = 730
+ vaiVaiiLRIndex ID = 731
+ veIndex ID = 732
+ viIndex ID = 733
+ viVNIndex ID = 734
+ voIndex ID = 735
+ vo001Index ID = 736
+ vunIndex ID = 737
+ vunTZIndex ID = 738
+ waIndex ID = 739
+ waeIndex ID = 740
+ waeCHIndex ID = 741
+ woIndex ID = 742
+ woSNIndex ID = 743
+ xhIndex ID = 744
+ xogIndex ID = 745
+ xogUGIndex ID = 746
+ yavIndex ID = 747
+ yavCMIndex ID = 748
+ yiIndex ID = 749
+ yi001Index ID = 750
+ yoIndex ID = 751
+ yoBJIndex ID = 752
+ yoNGIndex ID = 753
+ yueIndex ID = 754
+ yueHansIndex ID = 755
+ yueHansCNIndex ID = 756
+ yueHantIndex ID = 757
+ yueHantHKIndex ID = 758
+ zghIndex ID = 759
+ zghMAIndex ID = 760
+ zhIndex ID = 761
+ zhHansIndex ID = 762
+ zhHansCNIndex ID = 763
+ zhHansHKIndex ID = 764
+ zhHansMOIndex ID = 765
+ zhHansSGIndex ID = 766
+ zhHantIndex ID = 767
+ zhHantHKIndex ID = 768
+ zhHantMOIndex ID = 769
+ zhHantTWIndex ID = 770
+ zuIndex ID = 771
+ zuZAIndex ID = 772
+ caESvalenciaIndex ID = 773
+ enUSuvaposixIndex ID = 774
+)
+
+var coreTags = []language.CompactCoreInfo{ // 773 elements
+ // Entry 0 - 1F
+ 0x00000000, 0x01600000, 0x016000d2, 0x01600161,
+ 0x01c00000, 0x01c00052, 0x02100000, 0x02100080,
+ 0x02700000, 0x0270006f, 0x03a00000, 0x03a00001,
+ 0x03a00023, 0x03a00039, 0x03a00062, 0x03a00067,
+ 0x03a0006b, 0x03a0006c, 0x03a0006d, 0x03a00097,
+ 0x03a0009b, 0x03a000a1, 0x03a000a8, 0x03a000ac,
+ 0x03a000b0, 0x03a000b9, 0x03a000ba, 0x03a000c9,
+ 0x03a000e1, 0x03a000ed, 0x03a000f3, 0x03a00108,
+ // Entry 20 - 3F
+ 0x03a0010b, 0x03a00115, 0x03a00117, 0x03a0011c,
+ 0x03a00120, 0x03a00128, 0x03a0015e, 0x04000000,
+ 0x04300000, 0x04300099, 0x04400000, 0x0440012f,
+ 0x04800000, 0x0480006e, 0x05800000, 0x05820000,
+ 0x05820032, 0x0585a000, 0x0585a032, 0x05e00000,
+ 0x05e00052, 0x07100000, 0x07100047, 0x07500000,
+ 0x07500162, 0x07900000, 0x0790012f, 0x07e00000,
+ 0x07e00038, 0x08200000, 0x0a000000, 0x0a0000c3,
+ // Entry 40 - 5F
+ 0x0a500000, 0x0a500035, 0x0a500099, 0x0a900000,
+ 0x0a900053, 0x0a900099, 0x0b200000, 0x0b200078,
+ 0x0b500000, 0x0b500099, 0x0b700000, 0x0b720000,
+ 0x0b720033, 0x0b75a000, 0x0b75a033, 0x0d700000,
+ 0x0d700022, 0x0d70006e, 0x0d700078, 0x0d70009e,
+ 0x0db00000, 0x0db00035, 0x0db00099, 0x0dc00000,
+ 0x0dc00106, 0x0df00000, 0x0df00131, 0x0e500000,
+ 0x0e500135, 0x0e900000, 0x0e90009b, 0x0e90009c,
+ // Entry 60 - 7F
+ 0x0fa00000, 0x0fa0005e, 0x0fe00000, 0x0fe00106,
+ 0x10000000, 0x1000007b, 0x10100000, 0x10100063,
+ 0x10100082, 0x10800000, 0x108000a4, 0x10d00000,
+ 0x10d0002e, 0x10d00036, 0x10d0004e, 0x10d00060,
+ 0x10d0009e, 0x10d000b2, 0x10d000b7, 0x11700000,
+ 0x117000d4, 0x11f00000, 0x11f00060, 0x12400000,
+ 0x12400052, 0x12800000, 0x12b00000, 0x12b00114,
+ 0x12d00000, 0x12d00043, 0x12f00000, 0x12f000a4,
+ // Entry 80 - 9F
+ 0x13000000, 0x13000080, 0x13000122, 0x13600000,
+ 0x1360005d, 0x13600087, 0x13900000, 0x13900001,
+ 0x1390001a, 0x13900025, 0x13900026, 0x1390002d,
+ 0x1390002e, 0x1390002f, 0x13900034, 0x13900036,
+ 0x1390003a, 0x1390003d, 0x13900042, 0x13900046,
+ 0x13900048, 0x13900049, 0x1390004a, 0x1390004e,
+ 0x13900050, 0x13900052, 0x1390005c, 0x1390005d,
+ 0x13900060, 0x13900061, 0x13900063, 0x13900064,
+ // Entry A0 - BF
+ 0x1390006d, 0x13900072, 0x13900073, 0x13900074,
+ 0x13900075, 0x1390007b, 0x1390007c, 0x1390007f,
+ 0x13900080, 0x13900081, 0x13900083, 0x1390008a,
+ 0x1390008c, 0x1390008d, 0x13900096, 0x13900097,
+ 0x13900098, 0x13900099, 0x1390009a, 0x1390009f,
+ 0x139000a0, 0x139000a4, 0x139000a7, 0x139000a9,
+ 0x139000ad, 0x139000b1, 0x139000b4, 0x139000b5,
+ 0x139000bf, 0x139000c0, 0x139000c6, 0x139000c7,
+ // Entry C0 - DF
+ 0x139000ca, 0x139000cb, 0x139000cc, 0x139000ce,
+ 0x139000d0, 0x139000d2, 0x139000d5, 0x139000d6,
+ 0x139000d9, 0x139000dd, 0x139000df, 0x139000e0,
+ 0x139000e6, 0x139000e7, 0x139000e8, 0x139000eb,
+ 0x139000ec, 0x139000f0, 0x13900107, 0x13900109,
+ 0x1390010a, 0x1390010b, 0x1390010c, 0x1390010d,
+ 0x1390010e, 0x1390010f, 0x13900112, 0x13900117,
+ 0x1390011b, 0x1390011d, 0x1390011f, 0x13900125,
+ // Entry E0 - FF
+ 0x13900129, 0x1390012c, 0x1390012d, 0x1390012f,
+ 0x13900131, 0x13900133, 0x13900135, 0x13900139,
+ 0x1390013c, 0x1390013d, 0x1390013f, 0x13900142,
+ 0x13900161, 0x13900162, 0x13900164, 0x13c00000,
+ 0x13c00001, 0x13e00000, 0x13e0001f, 0x13e0002c,
+ 0x13e0003f, 0x13e00041, 0x13e00048, 0x13e00051,
+ 0x13e00054, 0x13e00056, 0x13e00059, 0x13e00065,
+ 0x13e00068, 0x13e00069, 0x13e0006e, 0x13e00086,
+ // Entry 100 - 11F
+ 0x13e00089, 0x13e0008f, 0x13e00094, 0x13e000cf,
+ 0x13e000d8, 0x13e000e2, 0x13e000e4, 0x13e000e7,
+ 0x13e000ec, 0x13e000f1, 0x13e0011a, 0x13e00135,
+ 0x13e00136, 0x13e0013b, 0x14000000, 0x1400006a,
+ 0x14500000, 0x1450006e, 0x14600000, 0x14600052,
+ 0x14800000, 0x14800024, 0x1480009c, 0x14e00000,
+ 0x14e00052, 0x14e00084, 0x14e000c9, 0x14e00114,
+ 0x15100000, 0x15100072, 0x15300000, 0x153000e7,
+ // Entry 120 - 13F
+ 0x15800000, 0x15800063, 0x15800076, 0x15e00000,
+ 0x15e00036, 0x15e00037, 0x15e0003a, 0x15e0003b,
+ 0x15e0003c, 0x15e00049, 0x15e0004b, 0x15e0004c,
+ 0x15e0004d, 0x15e0004e, 0x15e0004f, 0x15e00052,
+ 0x15e00062, 0x15e00067, 0x15e00078, 0x15e0007a,
+ 0x15e0007e, 0x15e00084, 0x15e00085, 0x15e00086,
+ 0x15e00091, 0x15e000a8, 0x15e000b7, 0x15e000ba,
+ 0x15e000bb, 0x15e000be, 0x15e000bf, 0x15e000c3,
+ // Entry 140 - 15F
+ 0x15e000c8, 0x15e000c9, 0x15e000cc, 0x15e000d3,
+ 0x15e000d4, 0x15e000e5, 0x15e000ea, 0x15e00102,
+ 0x15e00107, 0x15e0010a, 0x15e00114, 0x15e0011c,
+ 0x15e00120, 0x15e00122, 0x15e00128, 0x15e0013f,
+ 0x15e00140, 0x15e0015f, 0x16900000, 0x1690009e,
+ 0x16d00000, 0x16d000d9, 0x16e00000, 0x16e00096,
+ 0x17e00000, 0x17e0007b, 0x19000000, 0x1900006e,
+ 0x1a300000, 0x1a30004e, 0x1a300078, 0x1a3000b2,
+ // Entry 160 - 17F
+ 0x1a400000, 0x1a400099, 0x1a900000, 0x1ab00000,
+ 0x1ab000a4, 0x1ac00000, 0x1ac00098, 0x1b400000,
+ 0x1b400080, 0x1b4000d4, 0x1b4000d6, 0x1b800000,
+ 0x1b800135, 0x1bc00000, 0x1bc00097, 0x1be00000,
+ 0x1be00099, 0x1d100000, 0x1d100033, 0x1d100090,
+ 0x1d200000, 0x1d200060, 0x1d500000, 0x1d500092,
+ 0x1d700000, 0x1d700028, 0x1e100000, 0x1e100095,
+ 0x1e700000, 0x1e7000d6, 0x1ea00000, 0x1ea00053,
+ // Entry 180 - 19F
+ 0x1f300000, 0x1f500000, 0x1f800000, 0x1f80009d,
+ 0x1f900000, 0x1f90004e, 0x1f90009e, 0x1f900113,
+ 0x1f900138, 0x1fa00000, 0x1fb00000, 0x20000000,
+ 0x200000a2, 0x20300000, 0x20700000, 0x20700052,
+ 0x20800000, 0x20a00000, 0x20a0012f, 0x20e00000,
+ 0x20f00000, 0x21000000, 0x2100007d, 0x21200000,
+ 0x21200067, 0x21600000, 0x21700000, 0x217000a4,
+ 0x21f00000, 0x22300000, 0x2230012f, 0x22700000,
+ // Entry 1A0 - 1BF
+ 0x2270005a, 0x23400000, 0x234000c3, 0x23900000,
+ 0x239000a4, 0x24200000, 0x242000ae, 0x24400000,
+ 0x24400052, 0x24500000, 0x24500082, 0x24600000,
+ 0x246000a4, 0x24a00000, 0x24a000a6, 0x25100000,
+ 0x25100099, 0x25400000, 0x254000aa, 0x254000ab,
+ 0x25600000, 0x25600099, 0x26a00000, 0x26a00099,
+ 0x26b00000, 0x26b0012f, 0x26d00000, 0x26d00052,
+ 0x26e00000, 0x26e00060, 0x27400000, 0x28100000,
+ // Entry 1C0 - 1DF
+ 0x2810007b, 0x28a00000, 0x28a000a5, 0x29100000,
+ 0x2910012f, 0x29500000, 0x295000b7, 0x2a300000,
+ 0x2a300131, 0x2af00000, 0x2af00135, 0x2b500000,
+ 0x2b50002a, 0x2b50004b, 0x2b50004c, 0x2b50004d,
+ 0x2b800000, 0x2b8000af, 0x2bf00000, 0x2bf0009b,
+ 0x2bf0009c, 0x2c000000, 0x2c0000b6, 0x2c200000,
+ 0x2c20004b, 0x2c400000, 0x2c4000a4, 0x2c500000,
+ 0x2c5000a4, 0x2c700000, 0x2c7000b8, 0x2d100000,
+ // Entry 1E0 - 1FF
+ 0x2d1000a4, 0x2d10012f, 0x2e900000, 0x2e9000a4,
+ 0x2ed00000, 0x2ed000cc, 0x2f100000, 0x2f1000bf,
+ 0x2f200000, 0x2f2000d1, 0x2f400000, 0x2f400052,
+ 0x2ff00000, 0x2ff000c2, 0x30400000, 0x30400099,
+ 0x30b00000, 0x30b000c5, 0x31000000, 0x31b00000,
+ 0x31b00099, 0x31f00000, 0x31f0003e, 0x31f000d0,
+ 0x31f0010d, 0x32000000, 0x320000cb, 0x32500000,
+ 0x32500052, 0x33100000, 0x331000c4, 0x33a00000,
+ // Entry 200 - 21F
+ 0x33a0009c, 0x34100000, 0x34500000, 0x345000d2,
+ 0x34700000, 0x347000da, 0x34700110, 0x34e00000,
+ 0x34e00164, 0x35000000, 0x35000060, 0x350000d9,
+ 0x35100000, 0x35100099, 0x351000db, 0x36700000,
+ 0x36700030, 0x36700036, 0x36700040, 0x3670005b,
+ 0x367000d9, 0x36700116, 0x3670011b, 0x36800000,
+ 0x36800052, 0x36a00000, 0x36a000da, 0x36c00000,
+ 0x36c00052, 0x36f00000, 0x37500000, 0x37600000,
+ // Entry 220 - 23F
+ 0x37a00000, 0x38000000, 0x38000117, 0x38700000,
+ 0x38900000, 0x38900131, 0x39000000, 0x3900006f,
+ 0x390000a4, 0x39500000, 0x39500099, 0x39800000,
+ 0x3980007d, 0x39800106, 0x39d00000, 0x39d05000,
+ 0x39d050e8, 0x39d36000, 0x39d36099, 0x3a100000,
+ 0x3b300000, 0x3b3000e9, 0x3bd00000, 0x3bd00001,
+ 0x3be00000, 0x3be00024, 0x3c000000, 0x3c00002a,
+ 0x3c000041, 0x3c00004e, 0x3c00005a, 0x3c000086,
+ // Entry 240 - 25F
+ 0x3c00008b, 0x3c0000b7, 0x3c0000c6, 0x3c0000d1,
+ 0x3c0000ee, 0x3c000118, 0x3c000126, 0x3c400000,
+ 0x3c40003f, 0x3c400069, 0x3c4000e4, 0x3d400000,
+ 0x3d40004e, 0x3d900000, 0x3d90003a, 0x3dc00000,
+ 0x3dc000bc, 0x3dc00104, 0x3de00000, 0x3de0012f,
+ 0x3e200000, 0x3e200047, 0x3e2000a5, 0x3e2000ae,
+ 0x3e2000bc, 0x3e200106, 0x3e200130, 0x3e500000,
+ 0x3e500107, 0x3e600000, 0x3e60012f, 0x3eb00000,
+ // Entry 260 - 27F
+ 0x3eb00106, 0x3ec00000, 0x3ec000a4, 0x3f300000,
+ 0x3f30012f, 0x3fa00000, 0x3fa000e8, 0x3fc00000,
+ 0x3fd00000, 0x3fd00072, 0x3fd000da, 0x3fd0010c,
+ 0x3ff00000, 0x3ff000d1, 0x40100000, 0x401000c3,
+ 0x40200000, 0x4020004c, 0x40700000, 0x40800000,
+ 0x4085a000, 0x4085a0ba, 0x408e8000, 0x408e80ba,
+ 0x40c00000, 0x40c000b3, 0x41200000, 0x41200111,
+ 0x41600000, 0x4160010f, 0x41c00000, 0x41d00000,
+ // Entry 280 - 29F
+ 0x41e00000, 0x41f00000, 0x41f00072, 0x42200000,
+ 0x42300000, 0x42300164, 0x42900000, 0x42900062,
+ 0x4290006f, 0x429000a4, 0x42900115, 0x43100000,
+ 0x43100027, 0x431000c2, 0x4310014d, 0x43200000,
+ 0x43220000, 0x43220033, 0x432200bd, 0x43220105,
+ 0x4322014d, 0x4325a000, 0x4325a033, 0x4325a0bd,
+ 0x4325a105, 0x4325a14d, 0x43700000, 0x43a00000,
+ 0x43b00000, 0x44400000, 0x44400031, 0x44400072,
+ // Entry 2A0 - 2BF
+ 0x4440010c, 0x44500000, 0x4450004b, 0x445000a4,
+ 0x4450012f, 0x44500131, 0x44e00000, 0x45000000,
+ 0x45000099, 0x450000b3, 0x450000d0, 0x4500010d,
+ 0x46100000, 0x46100099, 0x46400000, 0x464000a4,
+ 0x46400131, 0x46700000, 0x46700124, 0x46b00000,
+ 0x46b00123, 0x46f00000, 0x46f0006d, 0x46f0006f,
+ 0x47100000, 0x47600000, 0x47600127, 0x47a00000,
+ 0x48000000, 0x48200000, 0x48200129, 0x48a00000,
+ // Entry 2C0 - 2DF
+ 0x48a0005d, 0x48a0012b, 0x48e00000, 0x49400000,
+ 0x49400106, 0x4a400000, 0x4a4000d4, 0x4a900000,
+ 0x4a9000ba, 0x4ac00000, 0x4ac00053, 0x4ae00000,
+ 0x4ae00130, 0x4b400000, 0x4b400099, 0x4b4000e8,
+ 0x4bc00000, 0x4bc05000, 0x4bc05024, 0x4bc20000,
+ 0x4bc20137, 0x4bc5a000, 0x4bc5a137, 0x4be00000,
+ 0x4be5a000, 0x4be5a0b4, 0x4bef1000, 0x4bef10b4,
+ 0x4c000000, 0x4c300000, 0x4c30013e, 0x4c900000,
+ // Entry 2E0 - 2FF
+ 0x4c900001, 0x4cc00000, 0x4cc0012f, 0x4ce00000,
+ 0x4cf00000, 0x4cf0004e, 0x4e500000, 0x4e500114,
+ 0x4f200000, 0x4fb00000, 0x4fb00131, 0x50900000,
+ 0x50900052, 0x51200000, 0x51200001, 0x51800000,
+ 0x5180003b, 0x518000d6, 0x51f00000, 0x51f3b000,
+ 0x51f3b053, 0x51f3c000, 0x51f3c08d, 0x52800000,
+ 0x528000ba, 0x52900000, 0x5293b000, 0x5293b053,
+ 0x5293b08d, 0x5293b0c6, 0x5293b10d, 0x5293c000,
+ // Entry 300 - 31F
+ 0x5293c08d, 0x5293c0c6, 0x5293c12e, 0x52f00000,
+ 0x52f00161,
+} // Size: 3116 bytes
+
+const specialTagsStr string = "ca-ES-valencia en-US-u-va-posix"
+
+// Total table size 3147 bytes (3KiB); checksum: 6772C83C
diff --git a/vendor/golang.org/x/text/internal/language/compact/tags.go b/vendor/golang.org/x/text/internal/language/compact/tags.go
new file mode 100644
index 0000000..ca135d2
--- /dev/null
+++ b/vendor/golang.org/x/text/internal/language/compact/tags.go
@@ -0,0 +1,91 @@
+// Copyright 2013 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package compact
+
+var (
+ und = Tag{}
+
+ Und Tag = Tag{}
+
+ Afrikaans Tag = Tag{language: afIndex, locale: afIndex}
+ Amharic Tag = Tag{language: amIndex, locale: amIndex}
+ Arabic Tag = Tag{language: arIndex, locale: arIndex}
+ ModernStandardArabic Tag = Tag{language: ar001Index, locale: ar001Index}
+ Azerbaijani Tag = Tag{language: azIndex, locale: azIndex}
+ Bulgarian Tag = Tag{language: bgIndex, locale: bgIndex}
+ Bengali Tag = Tag{language: bnIndex, locale: bnIndex}
+ Catalan Tag = Tag{language: caIndex, locale: caIndex}
+ Czech Tag = Tag{language: csIndex, locale: csIndex}
+ Danish Tag = Tag{language: daIndex, locale: daIndex}
+ German Tag = Tag{language: deIndex, locale: deIndex}
+ Greek Tag = Tag{language: elIndex, locale: elIndex}
+ English Tag = Tag{language: enIndex, locale: enIndex}
+ AmericanEnglish Tag = Tag{language: enUSIndex, locale: enUSIndex}
+ BritishEnglish Tag = Tag{language: enGBIndex, locale: enGBIndex}
+ Spanish Tag = Tag{language: esIndex, locale: esIndex}
+ EuropeanSpanish Tag = Tag{language: esESIndex, locale: esESIndex}
+ LatinAmericanSpanish Tag = Tag{language: es419Index, locale: es419Index}
+ Estonian Tag = Tag{language: etIndex, locale: etIndex}
+ Persian Tag = Tag{language: faIndex, locale: faIndex}
+ Finnish Tag = Tag{language: fiIndex, locale: fiIndex}
+ Filipino Tag = Tag{language: filIndex, locale: filIndex}
+ French Tag = Tag{language: frIndex, locale: frIndex}
+ CanadianFrench Tag = Tag{language: frCAIndex, locale: frCAIndex}
+ Gujarati Tag = Tag{language: guIndex, locale: guIndex}
+ Hebrew Tag = Tag{language: heIndex, locale: heIndex}
+ Hindi Tag = Tag{language: hiIndex, locale: hiIndex}
+ Croatian Tag = Tag{language: hrIndex, locale: hrIndex}
+ Hungarian Tag = Tag{language: huIndex, locale: huIndex}
+ Armenian Tag = Tag{language: hyIndex, locale: hyIndex}
+ Indonesian Tag = Tag{language: idIndex, locale: idIndex}
+ Icelandic Tag = Tag{language: isIndex, locale: isIndex}
+ Italian Tag = Tag{language: itIndex, locale: itIndex}
+ Japanese Tag = Tag{language: jaIndex, locale: jaIndex}
+ Georgian Tag = Tag{language: kaIndex, locale: kaIndex}
+ Kazakh Tag = Tag{language: kkIndex, locale: kkIndex}
+ Khmer Tag = Tag{language: kmIndex, locale: kmIndex}
+ Kannada Tag = Tag{language: knIndex, locale: knIndex}
+ Korean Tag = Tag{language: koIndex, locale: koIndex}
+ Kirghiz Tag = Tag{language: kyIndex, locale: kyIndex}
+ Lao Tag = Tag{language: loIndex, locale: loIndex}
+ Lithuanian Tag = Tag{language: ltIndex, locale: ltIndex}
+ Latvian Tag = Tag{language: lvIndex, locale: lvIndex}
+ Macedonian Tag = Tag{language: mkIndex, locale: mkIndex}
+ Malayalam Tag = Tag{language: mlIndex, locale: mlIndex}
+ Mongolian Tag = Tag{language: mnIndex, locale: mnIndex}
+ Marathi Tag = Tag{language: mrIndex, locale: mrIndex}
+ Malay Tag = Tag{language: msIndex, locale: msIndex}
+ Burmese Tag = Tag{language: myIndex, locale: myIndex}
+ Nepali Tag = Tag{language: neIndex, locale: neIndex}
+ Dutch Tag = Tag{language: nlIndex, locale: nlIndex}
+ Norwegian Tag = Tag{language: noIndex, locale: noIndex}
+ Punjabi Tag = Tag{language: paIndex, locale: paIndex}
+ Polish Tag = Tag{language: plIndex, locale: plIndex}
+ Portuguese Tag = Tag{language: ptIndex, locale: ptIndex}
+ BrazilianPortuguese Tag = Tag{language: ptBRIndex, locale: ptBRIndex}
+ EuropeanPortuguese Tag = Tag{language: ptPTIndex, locale: ptPTIndex}
+ Romanian Tag = Tag{language: roIndex, locale: roIndex}
+ Russian Tag = Tag{language: ruIndex, locale: ruIndex}
+ Sinhala Tag = Tag{language: siIndex, locale: siIndex}
+ Slovak Tag = Tag{language: skIndex, locale: skIndex}
+ Slovenian Tag = Tag{language: slIndex, locale: slIndex}
+ Albanian Tag = Tag{language: sqIndex, locale: sqIndex}
+ Serbian Tag = Tag{language: srIndex, locale: srIndex}
+ SerbianLatin Tag = Tag{language: srLatnIndex, locale: srLatnIndex}
+ Swedish Tag = Tag{language: svIndex, locale: svIndex}
+ Swahili Tag = Tag{language: swIndex, locale: swIndex}
+ Tamil Tag = Tag{language: taIndex, locale: taIndex}
+ Telugu Tag = Tag{language: teIndex, locale: teIndex}
+ Thai Tag = Tag{language: thIndex, locale: thIndex}
+ Turkish Tag = Tag{language: trIndex, locale: trIndex}
+ Ukrainian Tag = Tag{language: ukIndex, locale: ukIndex}
+ Urdu Tag = Tag{language: urIndex, locale: urIndex}
+ Uzbek Tag = Tag{language: uzIndex, locale: uzIndex}
+ Vietnamese Tag = Tag{language: viIndex, locale: viIndex}
+ Chinese Tag = Tag{language: zhIndex, locale: zhIndex}
+ SimplifiedChinese Tag = Tag{language: zhHansIndex, locale: zhHansIndex}
+ TraditionalChinese Tag = Tag{language: zhHantIndex, locale: zhHantIndex}
+ Zulu Tag = Tag{language: zuIndex, locale: zuIndex}
+)
diff --git a/vendor/golang.org/x/text/internal/language/compose.go b/vendor/golang.org/x/text/internal/language/compose.go
new file mode 100644
index 0000000..4ae78e0
--- /dev/null
+++ b/vendor/golang.org/x/text/internal/language/compose.go
@@ -0,0 +1,167 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package language
+
+import (
+ "sort"
+ "strings"
+)
+
+// A Builder allows constructing a Tag from individual components.
+// Its main user is Compose in the top-level language package.
+type Builder struct {
+ Tag Tag
+
+ private string // the x extension
+ variants []string
+ extensions []string
+}
+
+// Make returns a new Tag from the current settings.
+func (b *Builder) Make() Tag {
+ t := b.Tag
+
+ if len(b.extensions) > 0 || len(b.variants) > 0 {
+ sort.Sort(sortVariants(b.variants))
+ sort.Strings(b.extensions)
+
+ if b.private != "" {
+ b.extensions = append(b.extensions, b.private)
+ }
+ n := maxCoreSize + tokenLen(b.variants...) + tokenLen(b.extensions...)
+ buf := make([]byte, n)
+ p := t.genCoreBytes(buf)
+ t.pVariant = byte(p)
+ p += appendTokens(buf[p:], b.variants...)
+ t.pExt = uint16(p)
+ p += appendTokens(buf[p:], b.extensions...)
+ t.str = string(buf[:p])
+ // We may not always need to remake the string, but when or when not
+ // to do so is rather tricky.
+ scan := makeScanner(buf[:p])
+ t, _ = parse(&scan, "")
+ return t
+
+ } else if b.private != "" {
+ t.str = b.private
+ t.RemakeString()
+ }
+ return t
+}
+
+// SetTag copies all the settings from a given Tag. Any previously set values
+// are discarded.
+func (b *Builder) SetTag(t Tag) {
+ b.Tag.LangID = t.LangID
+ b.Tag.RegionID = t.RegionID
+ b.Tag.ScriptID = t.ScriptID
+ // TODO: optimize
+ b.variants = b.variants[:0]
+ if variants := t.Variants(); variants != "" {
+ for _, vr := range strings.Split(variants[1:], "-") {
+ b.variants = append(b.variants, vr)
+ }
+ }
+ b.extensions, b.private = b.extensions[:0], ""
+ for _, e := range t.Extensions() {
+ b.AddExt(e)
+ }
+}
+
+// AddExt adds extension e to the tag. e must be a valid extension as returned
+// by Tag.Extension. If the extension already exists, it will be discarded,
+// except for a -u extension, where non-existing key-type pairs will added.
+func (b *Builder) AddExt(e string) {
+ if e[0] == 'x' {
+ if b.private == "" {
+ b.private = e
+ }
+ return
+ }
+ for i, s := range b.extensions {
+ if s[0] == e[0] {
+ if e[0] == 'u' {
+ b.extensions[i] += e[1:]
+ }
+ return
+ }
+ }
+ b.extensions = append(b.extensions, e)
+}
+
+// SetExt sets the extension e to the tag. e must be a valid extension as
+// returned by Tag.Extension. If the extension already exists, it will be
+// overwritten, except for a -u extension, where the individual key-type pairs
+// will be set.
+func (b *Builder) SetExt(e string) {
+ if e[0] == 'x' {
+ b.private = e
+ return
+ }
+ for i, s := range b.extensions {
+ if s[0] == e[0] {
+ if e[0] == 'u' {
+ b.extensions[i] = e + s[1:]
+ } else {
+ b.extensions[i] = e
+ }
+ return
+ }
+ }
+ b.extensions = append(b.extensions, e)
+}
+
+// AddVariant adds any number of variants.
+func (b *Builder) AddVariant(v ...string) {
+ for _, v := range v {
+ if v != "" {
+ b.variants = append(b.variants, v)
+ }
+ }
+}
+
+// ClearVariants removes any variants previously added, including those
+// copied from a Tag in SetTag.
+func (b *Builder) ClearVariants() {
+ b.variants = b.variants[:0]
+}
+
+// ClearExtensions removes any extensions previously added, including those
+// copied from a Tag in SetTag.
+func (b *Builder) ClearExtensions() {
+ b.private = ""
+ b.extensions = b.extensions[:0]
+}
+
+func tokenLen(token ...string) (n int) {
+ for _, t := range token {
+ n += len(t) + 1
+ }
+ return
+}
+
+func appendTokens(b []byte, token ...string) int {
+ p := 0
+ for _, t := range token {
+ b[p] = '-'
+ copy(b[p+1:], t)
+ p += 1 + len(t)
+ }
+ return p
+}
+
+type sortVariants []string
+
+func (s sortVariants) Len() int {
+ return len(s)
+}
+
+func (s sortVariants) Swap(i, j int) {
+ s[j], s[i] = s[i], s[j]
+}
+
+func (s sortVariants) Less(i, j int) bool {
+ return variantIndex[s[i]] < variantIndex[s[j]]
+}
diff --git a/vendor/golang.org/x/text/internal/language/coverage.go b/vendor/golang.org/x/text/internal/language/coverage.go
new file mode 100644
index 0000000..9b20b88
--- /dev/null
+++ b/vendor/golang.org/x/text/internal/language/coverage.go
@@ -0,0 +1,28 @@
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package language
+
+// BaseLanguages returns the list of all supported base languages. It generates
+// the list by traversing the internal structures.
+func BaseLanguages() []Language {
+ base := make([]Language, 0, NumLanguages)
+ for i := 0; i < langNoIndexOffset; i++ {
+ // We included "und" already for the value 0.
+ if i != nonCanonicalUnd {
+ base = append(base, Language(i))
+ }
+ }
+ i := langNoIndexOffset
+ for _, v := range langNoIndex {
+ for k := 0; k < 8; k++ {
+ if v&1 == 1 {
+ base = append(base, Language(i))
+ }
+ v >>= 1
+ i++
+ }
+ }
+ return base
+}
diff --git a/vendor/golang.org/x/text/internal/language/language.go b/vendor/golang.org/x/text/internal/language/language.go
new file mode 100644
index 0000000..6105bc7
--- /dev/null
+++ b/vendor/golang.org/x/text/internal/language/language.go
@@ -0,0 +1,627 @@
+// Copyright 2013 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:generate go run gen.go gen_common.go -output tables.go
+
+package language // import "golang.org/x/text/internal/language"
+
+// TODO: Remove above NOTE after:
+// - verifying that tables are dropped correctly (most notably matcher tables).
+
+import (
+ "errors"
+ "fmt"
+ "strings"
+)
+
+const (
+ // maxCoreSize is the maximum size of a BCP 47 tag without variants and
+ // extensions. Equals max lang (3) + script (4) + max reg (3) + 2 dashes.
+ maxCoreSize = 12
+
+ // max99thPercentileSize is a somewhat arbitrary buffer size that presumably
+ // is large enough to hold at least 99% of the BCP 47 tags.
+ max99thPercentileSize = 32
+
+ // maxSimpleUExtensionSize is the maximum size of a -u extension with one
+ // key-type pair. Equals len("-u-") + key (2) + dash + max value (8).
+ maxSimpleUExtensionSize = 14
+)
+
+// Tag represents a BCP 47 language tag. It is used to specify an instance of a
+// specific language or locale. All language tag values are guaranteed to be
+// well-formed. The zero value of Tag is Und.
+type Tag struct {
+ // TODO: the following fields have the form TagTypeID. This name is chosen
+ // to allow refactoring the public package without conflicting with its
+ // Base, Script, and Region methods. Once the transition is fully completed
+ // the ID can be stripped from the name.
+
+ LangID Language
+ RegionID Region
+ // TODO: we will soon run out of positions for ScriptID. Idea: instead of
+ // storing lang, region, and ScriptID codes, store only the compact index and
+ // have a lookup table from this code to its expansion. This greatly speeds
+ // up table lookup, speed up common variant cases.
+ // This will also immediately free up 3 extra bytes. Also, the pVariant
+ // field can now be moved to the lookup table, as the compact index uniquely
+ // determines the offset of a possible variant.
+ ScriptID Script
+ pVariant byte // offset in str, includes preceding '-'
+ pExt uint16 // offset of first extension, includes preceding '-'
+
+ // str is the string representation of the Tag. It will only be used if the
+ // tag has variants or extensions.
+ str string
+}
+
+// Make is a convenience wrapper for Parse that omits the error.
+// In case of an error, a sensible default is returned.
+func Make(s string) Tag {
+ t, _ := Parse(s)
+ return t
+}
+
+// Raw returns the raw base language, script and region, without making an
+// attempt to infer their values.
+// TODO: consider removing
+func (t Tag) Raw() (b Language, s Script, r Region) {
+ return t.LangID, t.ScriptID, t.RegionID
+}
+
+// equalTags compares language, script and region subtags only.
+func (t Tag) equalTags(a Tag) bool {
+ return t.LangID == a.LangID && t.ScriptID == a.ScriptID && t.RegionID == a.RegionID
+}
+
+// IsRoot returns true if t is equal to language "und".
+func (t Tag) IsRoot() bool {
+ if int(t.pVariant) < len(t.str) {
+ return false
+ }
+ return t.equalTags(Und)
+}
+
+// IsPrivateUse reports whether the Tag consists solely of an IsPrivateUse use
+// tag.
+func (t Tag) IsPrivateUse() bool {
+ return t.str != "" && t.pVariant == 0
+}
+
+// RemakeString is used to update t.str in case lang, script or region changed.
+// It is assumed that pExt and pVariant still point to the start of the
+// respective parts.
+func (t *Tag) RemakeString() {
+ if t.str == "" {
+ return
+ }
+ extra := t.str[t.pVariant:]
+ if t.pVariant > 0 {
+ extra = extra[1:]
+ }
+ if t.equalTags(Und) && strings.HasPrefix(extra, "x-") {
+ t.str = extra
+ t.pVariant = 0
+ t.pExt = 0
+ return
+ }
+ var buf [max99thPercentileSize]byte // avoid extra memory allocation in most cases.
+ b := buf[:t.genCoreBytes(buf[:])]
+ if extra != "" {
+ diff := len(b) - int(t.pVariant)
+ b = append(b, '-')
+ b = append(b, extra...)
+ t.pVariant = uint8(int(t.pVariant) + diff)
+ t.pExt = uint16(int(t.pExt) + diff)
+ } else {
+ t.pVariant = uint8(len(b))
+ t.pExt = uint16(len(b))
+ }
+ t.str = string(b)
+}
+
+// genCoreBytes writes a string for the base languages, script and region tags
+// to the given buffer and returns the number of bytes written. It will never
+// write more than maxCoreSize bytes.
+func (t *Tag) genCoreBytes(buf []byte) int {
+ n := t.LangID.StringToBuf(buf[:])
+ if t.ScriptID != 0 {
+ n += copy(buf[n:], "-")
+ n += copy(buf[n:], t.ScriptID.String())
+ }
+ if t.RegionID != 0 {
+ n += copy(buf[n:], "-")
+ n += copy(buf[n:], t.RegionID.String())
+ }
+ return n
+}
+
+// String returns the canonical string representation of the language tag.
+func (t Tag) String() string {
+ if t.str != "" {
+ return t.str
+ }
+ if t.ScriptID == 0 && t.RegionID == 0 {
+ return t.LangID.String()
+ }
+ buf := [maxCoreSize]byte{}
+ return string(buf[:t.genCoreBytes(buf[:])])
+}
+
+// MarshalText implements encoding.TextMarshaler.
+func (t Tag) MarshalText() (text []byte, err error) {
+ if t.str != "" {
+ text = append(text, t.str...)
+ } else if t.ScriptID == 0 && t.RegionID == 0 {
+ text = append(text, t.LangID.String()...)
+ } else {
+ buf := [maxCoreSize]byte{}
+ text = buf[:t.genCoreBytes(buf[:])]
+ }
+ return text, nil
+}
+
+// UnmarshalText implements encoding.TextUnmarshaler.
+func (t *Tag) UnmarshalText(text []byte) error {
+ tag, err := Parse(string(text))
+ *t = tag
+ return err
+}
+
+// Variants returns the part of the tag holding all variants or the empty string
+// if there are no variants defined.
+func (t Tag) Variants() string {
+ if t.pVariant == 0 {
+ return ""
+ }
+ return t.str[t.pVariant:t.pExt]
+}
+
+// VariantOrPrivateUseTags returns variants or private use tags.
+func (t Tag) VariantOrPrivateUseTags() string {
+ if t.pExt > 0 {
+ return t.str[t.pVariant:t.pExt]
+ }
+ return t.str[t.pVariant:]
+}
+
+// HasString reports whether this tag defines more than just the raw
+// components.
+func (t Tag) HasString() bool {
+ return t.str != ""
+}
+
+// Parent returns the CLDR parent of t. In CLDR, missing fields in data for a
+// specific language are substituted with fields from the parent language.
+// The parent for a language may change for newer versions of CLDR.
+func (t Tag) Parent() Tag {
+ if t.str != "" {
+ // Strip the variants and extensions.
+ b, s, r := t.Raw()
+ t = Tag{LangID: b, ScriptID: s, RegionID: r}
+ if t.RegionID == 0 && t.ScriptID != 0 && t.LangID != 0 {
+ base, _ := addTags(Tag{LangID: t.LangID})
+ if base.ScriptID == t.ScriptID {
+ return Tag{LangID: t.LangID}
+ }
+ }
+ return t
+ }
+ if t.LangID != 0 {
+ if t.RegionID != 0 {
+ maxScript := t.ScriptID
+ if maxScript == 0 {
+ max, _ := addTags(t)
+ maxScript = max.ScriptID
+ }
+
+ for i := range parents {
+ if Language(parents[i].lang) == t.LangID && Script(parents[i].maxScript) == maxScript {
+ for _, r := range parents[i].fromRegion {
+ if Region(r) == t.RegionID {
+ return Tag{
+ LangID: t.LangID,
+ ScriptID: Script(parents[i].script),
+ RegionID: Region(parents[i].toRegion),
+ }
+ }
+ }
+ }
+ }
+
+ // Strip the script if it is the default one.
+ base, _ := addTags(Tag{LangID: t.LangID})
+ if base.ScriptID != maxScript {
+ return Tag{LangID: t.LangID, ScriptID: maxScript}
+ }
+ return Tag{LangID: t.LangID}
+ } else if t.ScriptID != 0 {
+ // The parent for an base-script pair with a non-default script is
+ // "und" instead of the base language.
+ base, _ := addTags(Tag{LangID: t.LangID})
+ if base.ScriptID != t.ScriptID {
+ return Und
+ }
+ return Tag{LangID: t.LangID}
+ }
+ }
+ return Und
+}
+
+// ParseExtension parses s as an extension and returns it on success.
+func ParseExtension(s string) (ext string, err error) {
+ defer func() {
+ if recover() != nil {
+ ext = ""
+ err = ErrSyntax
+ }
+ }()
+
+ scan := makeScannerString(s)
+ var end int
+ if n := len(scan.token); n != 1 {
+ return "", ErrSyntax
+ }
+ scan.toLower(0, len(scan.b))
+ end = parseExtension(&scan)
+ if end != len(s) {
+ return "", ErrSyntax
+ }
+ return string(scan.b), nil
+}
+
+// HasVariants reports whether t has variants.
+func (t Tag) HasVariants() bool {
+ return uint16(t.pVariant) < t.pExt
+}
+
+// HasExtensions reports whether t has extensions.
+func (t Tag) HasExtensions() bool {
+ return int(t.pExt) < len(t.str)
+}
+
+// Extension returns the extension of type x for tag t. It will return
+// false for ok if t does not have the requested extension. The returned
+// extension will be invalid in this case.
+func (t Tag) Extension(x byte) (ext string, ok bool) {
+ for i := int(t.pExt); i < len(t.str)-1; {
+ var ext string
+ i, ext = getExtension(t.str, i)
+ if ext[0] == x {
+ return ext, true
+ }
+ }
+ return "", false
+}
+
+// Extensions returns all extensions of t.
+func (t Tag) Extensions() []string {
+ e := []string{}
+ for i := int(t.pExt); i < len(t.str)-1; {
+ var ext string
+ i, ext = getExtension(t.str, i)
+ e = append(e, ext)
+ }
+ return e
+}
+
+// TypeForKey returns the type associated with the given key, where key and type
+// are of the allowed values defined for the Unicode locale extension ('u') in
+// https://www.unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers.
+// TypeForKey will traverse the inheritance chain to get the correct value.
+//
+// If there are multiple types associated with a key, only the first will be
+// returned. If there is no type associated with a key, it returns the empty
+// string.
+func (t Tag) TypeForKey(key string) string {
+ if _, start, end, _ := t.findTypeForKey(key); end != start {
+ s := t.str[start:end]
+ if p := strings.IndexByte(s, '-'); p >= 0 {
+ s = s[:p]
+ }
+ return s
+ }
+ return ""
+}
+
+var (
+ errPrivateUse = errors.New("cannot set a key on a private use tag")
+ errInvalidArguments = errors.New("invalid key or type")
+)
+
+// SetTypeForKey returns a new Tag with the key set to type, where key and type
+// are of the allowed values defined for the Unicode locale extension ('u') in
+// https://www.unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers.
+// An empty value removes an existing pair with the same key.
+func (t Tag) SetTypeForKey(key, value string) (Tag, error) {
+ if t.IsPrivateUse() {
+ return t, errPrivateUse
+ }
+ if len(key) != 2 {
+ return t, errInvalidArguments
+ }
+
+ // Remove the setting if value is "".
+ if value == "" {
+ start, sep, end, _ := t.findTypeForKey(key)
+ if start != sep {
+ // Remove a possible empty extension.
+ switch {
+ case t.str[start-2] != '-': // has previous elements.
+ case end == len(t.str), // end of string
+ end+2 < len(t.str) && t.str[end+2] == '-': // end of extension
+ start -= 2
+ }
+ if start == int(t.pVariant) && end == len(t.str) {
+ t.str = ""
+ t.pVariant, t.pExt = 0, 0
+ } else {
+ t.str = fmt.Sprintf("%s%s", t.str[:start], t.str[end:])
+ }
+ }
+ return t, nil
+ }
+
+ if len(value) < 3 || len(value) > 8 {
+ return t, errInvalidArguments
+ }
+
+ var (
+ buf [maxCoreSize + maxSimpleUExtensionSize]byte
+ uStart int // start of the -u extension.
+ )
+
+ // Generate the tag string if needed.
+ if t.str == "" {
+ uStart = t.genCoreBytes(buf[:])
+ buf[uStart] = '-'
+ uStart++
+ }
+
+ // Create new key-type pair and parse it to verify.
+ b := buf[uStart:]
+ copy(b, "u-")
+ copy(b[2:], key)
+ b[4] = '-'
+ b = b[:5+copy(b[5:], value)]
+ scan := makeScanner(b)
+ if parseExtensions(&scan); scan.err != nil {
+ return t, scan.err
+ }
+
+ // Assemble the replacement string.
+ if t.str == "" {
+ t.pVariant, t.pExt = byte(uStart-1), uint16(uStart-1)
+ t.str = string(buf[:uStart+len(b)])
+ } else {
+ s := t.str
+ start, sep, end, hasExt := t.findTypeForKey(key)
+ if start == sep {
+ if hasExt {
+ b = b[2:]
+ }
+ t.str = fmt.Sprintf("%s-%s%s", s[:sep], b, s[end:])
+ } else {
+ t.str = fmt.Sprintf("%s-%s%s", s[:start+3], value, s[end:])
+ }
+ }
+ return t, nil
+}
+
+// findKeyAndType returns the start and end position for the type corresponding
+// to key or the point at which to insert the key-value pair if the type
+// wasn't found. The hasExt return value reports whether an -u extension was present.
+// Note: the extensions are typically very small and are likely to contain
+// only one key-type pair.
+func (t Tag) findTypeForKey(key string) (start, sep, end int, hasExt bool) {
+ p := int(t.pExt)
+ if len(key) != 2 || p == len(t.str) || p == 0 {
+ return p, p, p, false
+ }
+ s := t.str
+
+ // Find the correct extension.
+ for p++; s[p] != 'u'; p++ {
+ if s[p] > 'u' {
+ p--
+ return p, p, p, false
+ }
+ if p = nextExtension(s, p); p == len(s) {
+ return len(s), len(s), len(s), false
+ }
+ }
+ // Proceed to the hyphen following the extension name.
+ p++
+
+ // curKey is the key currently being processed.
+ curKey := ""
+
+ // Iterate over keys until we get the end of a section.
+ for {
+ end = p
+ for p++; p < len(s) && s[p] != '-'; p++ {
+ }
+ n := p - end - 1
+ if n <= 2 && curKey == key {
+ if sep < end {
+ sep++
+ }
+ return start, sep, end, true
+ }
+ switch n {
+ case 0, // invalid string
+ 1: // next extension
+ return end, end, end, true
+ case 2:
+ // next key
+ curKey = s[end+1 : p]
+ if curKey > key {
+ return end, end, end, true
+ }
+ start = end
+ sep = p
+ }
+ }
+}
+
+// ParseBase parses a 2- or 3-letter ISO 639 code.
+// It returns a ValueError if s is a well-formed but unknown language identifier
+// or another error if another error occurred.
+func ParseBase(s string) (l Language, err error) {
+ defer func() {
+ if recover() != nil {
+ l = 0
+ err = ErrSyntax
+ }
+ }()
+
+ if n := len(s); n < 2 || 3 < n {
+ return 0, ErrSyntax
+ }
+ var buf [3]byte
+ return getLangID(buf[:copy(buf[:], s)])
+}
+
+// ParseScript parses a 4-letter ISO 15924 code.
+// It returns a ValueError if s is a well-formed but unknown script identifier
+// or another error if another error occurred.
+func ParseScript(s string) (scr Script, err error) {
+ defer func() {
+ if recover() != nil {
+ scr = 0
+ err = ErrSyntax
+ }
+ }()
+
+ if len(s) != 4 {
+ return 0, ErrSyntax
+ }
+ var buf [4]byte
+ return getScriptID(script, buf[:copy(buf[:], s)])
+}
+
+// EncodeM49 returns the Region for the given UN M.49 code.
+// It returns an error if r is not a valid code.
+func EncodeM49(r int) (Region, error) {
+ return getRegionM49(r)
+}
+
+// ParseRegion parses a 2- or 3-letter ISO 3166-1 or a UN M.49 code.
+// It returns a ValueError if s is a well-formed but unknown region identifier
+// or another error if another error occurred.
+func ParseRegion(s string) (r Region, err error) {
+ defer func() {
+ if recover() != nil {
+ r = 0
+ err = ErrSyntax
+ }
+ }()
+
+ if n := len(s); n < 2 || 3 < n {
+ return 0, ErrSyntax
+ }
+ var buf [3]byte
+ return getRegionID(buf[:copy(buf[:], s)])
+}
+
+// IsCountry returns whether this region is a country or autonomous area. This
+// includes non-standard definitions from CLDR.
+func (r Region) IsCountry() bool {
+ if r == 0 || r.IsGroup() || r.IsPrivateUse() && r != _XK {
+ return false
+ }
+ return true
+}
+
+// IsGroup returns whether this region defines a collection of regions. This
+// includes non-standard definitions from CLDR.
+func (r Region) IsGroup() bool {
+ if r == 0 {
+ return false
+ }
+ return int(regionInclusion[r]) < len(regionContainment)
+}
+
+// Contains returns whether Region c is contained by Region r. It returns true
+// if c == r.
+func (r Region) Contains(c Region) bool {
+ if r == c {
+ return true
+ }
+ g := regionInclusion[r]
+ if g >= nRegionGroups {
+ return false
+ }
+ m := regionContainment[g]
+
+ d := regionInclusion[c]
+ b := regionInclusionBits[d]
+
+ // A contained country may belong to multiple disjoint groups. Matching any
+ // of these indicates containment. If the contained region is a group, it
+ // must strictly be a subset.
+ if d >= nRegionGroups {
+ return b&m != 0
+ }
+ return b&^m == 0
+}
+
+var errNoTLD = errors.New("language: region is not a valid ccTLD")
+
+// TLD returns the country code top-level domain (ccTLD). UK is returned for GB.
+// In all other cases it returns either the region itself or an error.
+//
+// This method may return an error for a region for which there exists a
+// canonical form with a ccTLD. To get that ccTLD canonicalize r first. The
+// region will already be canonicalized it was obtained from a Tag that was
+// obtained using any of the default methods.
+func (r Region) TLD() (Region, error) {
+ // See http://en.wikipedia.org/wiki/Country_code_top-level_domain for the
+ // difference between ISO 3166-1 and IANA ccTLD.
+ if r == _GB {
+ r = _UK
+ }
+ if (r.typ() & ccTLD) == 0 {
+ return 0, errNoTLD
+ }
+ return r, nil
+}
+
+// Canonicalize returns the region or a possible replacement if the region is
+// deprecated. It will not return a replacement for deprecated regions that
+// are split into multiple regions.
+func (r Region) Canonicalize() Region {
+ if cr := normRegion(r); cr != 0 {
+ return cr
+ }
+ return r
+}
+
+// Variant represents a registered variant of a language as defined by BCP 47.
+type Variant struct {
+ ID uint8
+ str string
+}
+
+// ParseVariant parses and returns a Variant. An error is returned if s is not
+// a valid variant.
+func ParseVariant(s string) (v Variant, err error) {
+ defer func() {
+ if recover() != nil {
+ v = Variant{}
+ err = ErrSyntax
+ }
+ }()
+
+ s = strings.ToLower(s)
+ if id, ok := variantIndex[s]; ok {
+ return Variant{id, s}, nil
+ }
+ return Variant{}, NewValueError([]byte(s))
+}
+
+// String returns the string representation of the variant.
+func (v Variant) String() string {
+ return v.str
+}
diff --git a/vendor/golang.org/x/text/internal/language/lookup.go b/vendor/golang.org/x/text/internal/language/lookup.go
new file mode 100644
index 0000000..231b4fb
--- /dev/null
+++ b/vendor/golang.org/x/text/internal/language/lookup.go
@@ -0,0 +1,412 @@
+// Copyright 2013 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package language
+
+import (
+ "bytes"
+ "fmt"
+ "sort"
+ "strconv"
+
+ "golang.org/x/text/internal/tag"
+)
+
+// findIndex tries to find the given tag in idx and returns a standardized error
+// if it could not be found.
+func findIndex(idx tag.Index, key []byte, form string) (index int, err error) {
+ if !tag.FixCase(form, key) {
+ return 0, ErrSyntax
+ }
+ i := idx.Index(key)
+ if i == -1 {
+ return 0, NewValueError(key)
+ }
+ return i, nil
+}
+
+func searchUint(imap []uint16, key uint16) int {
+ return sort.Search(len(imap), func(i int) bool {
+ return imap[i] >= key
+ })
+}
+
+type Language uint16
+
+// getLangID returns the langID of s if s is a canonical subtag
+// or langUnknown if s is not a canonical subtag.
+func getLangID(s []byte) (Language, error) {
+ if len(s) == 2 {
+ return getLangISO2(s)
+ }
+ return getLangISO3(s)
+}
+
+// TODO language normalization as well as the AliasMaps could be moved to the
+// higher level package, but it is a bit tricky to separate the generation.
+
+func (id Language) Canonicalize() (Language, AliasType) {
+ return normLang(id)
+}
+
+// normLang returns the mapped langID of id according to mapping m.
+func normLang(id Language) (Language, AliasType) {
+ k := sort.Search(len(AliasMap), func(i int) bool {
+ return AliasMap[i].From >= uint16(id)
+ })
+ if k < len(AliasMap) && AliasMap[k].From == uint16(id) {
+ return Language(AliasMap[k].To), AliasTypes[k]
+ }
+ return id, AliasTypeUnknown
+}
+
+// getLangISO2 returns the langID for the given 2-letter ISO language code
+// or unknownLang if this does not exist.
+func getLangISO2(s []byte) (Language, error) {
+ if !tag.FixCase("zz", s) {
+ return 0, ErrSyntax
+ }
+ if i := lang.Index(s); i != -1 && lang.Elem(i)[3] != 0 {
+ return Language(i), nil
+ }
+ return 0, NewValueError(s)
+}
+
+const base = 'z' - 'a' + 1
+
+func strToInt(s []byte) uint {
+ v := uint(0)
+ for i := 0; i < len(s); i++ {
+ v *= base
+ v += uint(s[i] - 'a')
+ }
+ return v
+}
+
+// converts the given integer to the original ASCII string passed to strToInt.
+// len(s) must match the number of characters obtained.
+func intToStr(v uint, s []byte) {
+ for i := len(s) - 1; i >= 0; i-- {
+ s[i] = byte(v%base) + 'a'
+ v /= base
+ }
+}
+
+// getLangISO3 returns the langID for the given 3-letter ISO language code
+// or unknownLang if this does not exist.
+func getLangISO3(s []byte) (Language, error) {
+ if tag.FixCase("und", s) {
+ // first try to match canonical 3-letter entries
+ for i := lang.Index(s[:2]); i != -1; i = lang.Next(s[:2], i) {
+ if e := lang.Elem(i); e[3] == 0 && e[2] == s[2] {
+ // We treat "und" as special and always translate it to "unspecified".
+ // Note that ZZ and Zzzz are private use and are not treated as
+ // unspecified by default.
+ id := Language(i)
+ if id == nonCanonicalUnd {
+ return 0, nil
+ }
+ return id, nil
+ }
+ }
+ if i := altLangISO3.Index(s); i != -1 {
+ return Language(altLangIndex[altLangISO3.Elem(i)[3]]), nil
+ }
+ n := strToInt(s)
+ if langNoIndex[n/8]&(1<<(n%8)) != 0 {
+ return Language(n) + langNoIndexOffset, nil
+ }
+ // Check for non-canonical uses of ISO3.
+ for i := lang.Index(s[:1]); i != -1; i = lang.Next(s[:1], i) {
+ if e := lang.Elem(i); e[2] == s[1] && e[3] == s[2] {
+ return Language(i), nil
+ }
+ }
+ return 0, NewValueError(s)
+ }
+ return 0, ErrSyntax
+}
+
+// StringToBuf writes the string to b and returns the number of bytes
+// written. cap(b) must be >= 3.
+func (id Language) StringToBuf(b []byte) int {
+ if id >= langNoIndexOffset {
+ intToStr(uint(id)-langNoIndexOffset, b[:3])
+ return 3
+ } else if id == 0 {
+ return copy(b, "und")
+ }
+ l := lang[id<<2:]
+ if l[3] == 0 {
+ return copy(b, l[:3])
+ }
+ return copy(b, l[:2])
+}
+
+// String returns the BCP 47 representation of the langID.
+// Use b as variable name, instead of id, to ensure the variable
+// used is consistent with that of Base in which this type is embedded.
+func (b Language) String() string {
+ if b == 0 {
+ return "und"
+ } else if b >= langNoIndexOffset {
+ b -= langNoIndexOffset
+ buf := [3]byte{}
+ intToStr(uint(b), buf[:])
+ return string(buf[:])
+ }
+ l := lang.Elem(int(b))
+ if l[3] == 0 {
+ return l[:3]
+ }
+ return l[:2]
+}
+
+// ISO3 returns the ISO 639-3 language code.
+func (b Language) ISO3() string {
+ if b == 0 || b >= langNoIndexOffset {
+ return b.String()
+ }
+ l := lang.Elem(int(b))
+ if l[3] == 0 {
+ return l[:3]
+ } else if l[2] == 0 {
+ return altLangISO3.Elem(int(l[3]))[:3]
+ }
+ // This allocation will only happen for 3-letter ISO codes
+ // that are non-canonical BCP 47 language identifiers.
+ return l[0:1] + l[2:4]
+}
+
+// IsPrivateUse reports whether this language code is reserved for private use.
+func (b Language) IsPrivateUse() bool {
+ return langPrivateStart <= b && b <= langPrivateEnd
+}
+
+// SuppressScript returns the script marked as SuppressScript in the IANA
+// language tag repository, or 0 if there is no such script.
+func (b Language) SuppressScript() Script {
+ if b < langNoIndexOffset {
+ return Script(suppressScript[b])
+ }
+ return 0
+}
+
+type Region uint16
+
+// getRegionID returns the region id for s if s is a valid 2-letter region code
+// or unknownRegion.
+func getRegionID(s []byte) (Region, error) {
+ if len(s) == 3 {
+ if isAlpha(s[0]) {
+ return getRegionISO3(s)
+ }
+ if i, err := strconv.ParseUint(string(s), 10, 10); err == nil {
+ return getRegionM49(int(i))
+ }
+ }
+ return getRegionISO2(s)
+}
+
+// getRegionISO2 returns the regionID for the given 2-letter ISO country code
+// or unknownRegion if this does not exist.
+func getRegionISO2(s []byte) (Region, error) {
+ i, err := findIndex(regionISO, s, "ZZ")
+ if err != nil {
+ return 0, err
+ }
+ return Region(i) + isoRegionOffset, nil
+}
+
+// getRegionISO3 returns the regionID for the given 3-letter ISO country code
+// or unknownRegion if this does not exist.
+func getRegionISO3(s []byte) (Region, error) {
+ if tag.FixCase("ZZZ", s) {
+ for i := regionISO.Index(s[:1]); i != -1; i = regionISO.Next(s[:1], i) {
+ if e := regionISO.Elem(i); e[2] == s[1] && e[3] == s[2] {
+ return Region(i) + isoRegionOffset, nil
+ }
+ }
+ for i := 0; i < len(altRegionISO3); i += 3 {
+ if tag.Compare(altRegionISO3[i:i+3], s) == 0 {
+ return Region(altRegionIDs[i/3]), nil
+ }
+ }
+ return 0, NewValueError(s)
+ }
+ return 0, ErrSyntax
+}
+
+func getRegionM49(n int) (Region, error) {
+ if 0 < n && n <= 999 {
+ const (
+ searchBits = 7
+ regionBits = 9
+ regionMask = 1<> searchBits
+ buf := fromM49[m49Index[idx]:m49Index[idx+1]]
+ val := uint16(n) << regionBits // we rely on bits shifting out
+ i := sort.Search(len(buf), func(i int) bool {
+ return buf[i] >= val
+ })
+ if r := fromM49[int(m49Index[idx])+i]; r&^regionMask == val {
+ return Region(r & regionMask), nil
+ }
+ }
+ var e ValueError
+ fmt.Fprint(bytes.NewBuffer([]byte(e.v[:])), n)
+ return 0, e
+}
+
+// normRegion returns a region if r is deprecated or 0 otherwise.
+// TODO: consider supporting BYS (-> BLR), CSK (-> 200 or CZ), PHI (-> PHL) and AFI (-> DJ).
+// TODO: consider mapping split up regions to new most populous one (like CLDR).
+func normRegion(r Region) Region {
+ m := regionOldMap
+ k := sort.Search(len(m), func(i int) bool {
+ return m[i].From >= uint16(r)
+ })
+ if k < len(m) && m[k].From == uint16(r) {
+ return Region(m[k].To)
+ }
+ return 0
+}
+
+const (
+ iso3166UserAssigned = 1 << iota
+ ccTLD
+ bcp47Region
+)
+
+func (r Region) typ() byte {
+ return regionTypes[r]
+}
+
+// String returns the BCP 47 representation for the region.
+// It returns "ZZ" for an unspecified region.
+func (r Region) String() string {
+ if r < isoRegionOffset {
+ if r == 0 {
+ return "ZZ"
+ }
+ return fmt.Sprintf("%03d", r.M49())
+ }
+ r -= isoRegionOffset
+ return regionISO.Elem(int(r))[:2]
+}
+
+// ISO3 returns the 3-letter ISO code of r.
+// Note that not all regions have a 3-letter ISO code.
+// In such cases this method returns "ZZZ".
+func (r Region) ISO3() string {
+ if r < isoRegionOffset {
+ return "ZZZ"
+ }
+ r -= isoRegionOffset
+ reg := regionISO.Elem(int(r))
+ switch reg[2] {
+ case 0:
+ return altRegionISO3[reg[3]:][:3]
+ case ' ':
+ return "ZZZ"
+ }
+ return reg[0:1] + reg[2:4]
+}
+
+// M49 returns the UN M.49 encoding of r, or 0 if this encoding
+// is not defined for r.
+func (r Region) M49() int {
+ return int(m49[r])
+}
+
+// IsPrivateUse reports whether r has the ISO 3166 User-assigned status. This
+// may include private-use tags that are assigned by CLDR and used in this
+// implementation. So IsPrivateUse and IsCountry can be simultaneously true.
+func (r Region) IsPrivateUse() bool {
+ return r.typ()&iso3166UserAssigned != 0
+}
+
+type Script uint16
+
+// getScriptID returns the script id for string s. It assumes that s
+// is of the format [A-Z][a-z]{3}.
+func getScriptID(idx tag.Index, s []byte) (Script, error) {
+ i, err := findIndex(idx, s, "Zzzz")
+ return Script(i), err
+}
+
+// String returns the script code in title case.
+// It returns "Zzzz" for an unspecified script.
+func (s Script) String() string {
+ if s == 0 {
+ return "Zzzz"
+ }
+ return script.Elem(int(s))
+}
+
+// IsPrivateUse reports whether this script code is reserved for private use.
+func (s Script) IsPrivateUse() bool {
+ return _Qaaa <= s && s <= _Qabx
+}
+
+const (
+ maxAltTaglen = len("en-US-POSIX")
+ maxLen = maxAltTaglen
+)
+
+var (
+ // grandfatheredMap holds a mapping from legacy and grandfathered tags to
+ // their base language or index to more elaborate tag.
+ grandfatheredMap = map[[maxLen]byte]int16{
+ [maxLen]byte{'a', 'r', 't', '-', 'l', 'o', 'j', 'b', 'a', 'n'}: _jbo, // art-lojban
+ [maxLen]byte{'i', '-', 'a', 'm', 'i'}: _ami, // i-ami
+ [maxLen]byte{'i', '-', 'b', 'n', 'n'}: _bnn, // i-bnn
+ [maxLen]byte{'i', '-', 'h', 'a', 'k'}: _hak, // i-hak
+ [maxLen]byte{'i', '-', 'k', 'l', 'i', 'n', 'g', 'o', 'n'}: _tlh, // i-klingon
+ [maxLen]byte{'i', '-', 'l', 'u', 'x'}: _lb, // i-lux
+ [maxLen]byte{'i', '-', 'n', 'a', 'v', 'a', 'j', 'o'}: _nv, // i-navajo
+ [maxLen]byte{'i', '-', 'p', 'w', 'n'}: _pwn, // i-pwn
+ [maxLen]byte{'i', '-', 't', 'a', 'o'}: _tao, // i-tao
+ [maxLen]byte{'i', '-', 't', 'a', 'y'}: _tay, // i-tay
+ [maxLen]byte{'i', '-', 't', 's', 'u'}: _tsu, // i-tsu
+ [maxLen]byte{'n', 'o', '-', 'b', 'o', 'k'}: _nb, // no-bok
+ [maxLen]byte{'n', 'o', '-', 'n', 'y', 'n'}: _nn, // no-nyn
+ [maxLen]byte{'s', 'g', 'n', '-', 'b', 'e', '-', 'f', 'r'}: _sfb, // sgn-BE-FR
+ [maxLen]byte{'s', 'g', 'n', '-', 'b', 'e', '-', 'n', 'l'}: _vgt, // sgn-BE-NL
+ [maxLen]byte{'s', 'g', 'n', '-', 'c', 'h', '-', 'd', 'e'}: _sgg, // sgn-CH-DE
+ [maxLen]byte{'z', 'h', '-', 'g', 'u', 'o', 'y', 'u'}: _cmn, // zh-guoyu
+ [maxLen]byte{'z', 'h', '-', 'h', 'a', 'k', 'k', 'a'}: _hak, // zh-hakka
+ [maxLen]byte{'z', 'h', '-', 'm', 'i', 'n', '-', 'n', 'a', 'n'}: _nan, // zh-min-nan
+ [maxLen]byte{'z', 'h', '-', 'x', 'i', 'a', 'n', 'g'}: _hsn, // zh-xiang
+
+ // Grandfathered tags with no modern replacement will be converted as
+ // follows:
+ [maxLen]byte{'c', 'e', 'l', '-', 'g', 'a', 'u', 'l', 'i', 's', 'h'}: -1, // cel-gaulish
+ [maxLen]byte{'e', 'n', '-', 'g', 'b', '-', 'o', 'e', 'd'}: -2, // en-GB-oed
+ [maxLen]byte{'i', '-', 'd', 'e', 'f', 'a', 'u', 'l', 't'}: -3, // i-default
+ [maxLen]byte{'i', '-', 'e', 'n', 'o', 'c', 'h', 'i', 'a', 'n'}: -4, // i-enochian
+ [maxLen]byte{'i', '-', 'm', 'i', 'n', 'g', 'o'}: -5, // i-mingo
+ [maxLen]byte{'z', 'h', '-', 'm', 'i', 'n'}: -6, // zh-min
+
+ // CLDR-specific tag.
+ [maxLen]byte{'r', 'o', 'o', 't'}: 0, // root
+ [maxLen]byte{'e', 'n', '-', 'u', 's', '-', 'p', 'o', 's', 'i', 'x'}: -7, // en_US_POSIX"
+ }
+
+ altTagIndex = [...]uint8{0, 17, 31, 45, 61, 74, 86, 102}
+
+ altTags = "xtg-x-cel-gaulishen-GB-oxendicten-x-i-defaultund-x-i-enochiansee-x-i-mingonan-x-zh-minen-US-u-va-posix"
+)
+
+func grandfathered(s [maxAltTaglen]byte) (t Tag, ok bool) {
+ if v, ok := grandfatheredMap[s]; ok {
+ if v < 0 {
+ return Make(altTags[altTagIndex[-v-1]:altTagIndex[-v]]), true
+ }
+ t.LangID = Language(v)
+ return t, true
+ }
+ return t, false
+}
diff --git a/vendor/golang.org/x/text/internal/language/match.go b/vendor/golang.org/x/text/internal/language/match.go
new file mode 100644
index 0000000..75a2dbc
--- /dev/null
+++ b/vendor/golang.org/x/text/internal/language/match.go
@@ -0,0 +1,226 @@
+// Copyright 2013 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package language
+
+import "errors"
+
+type scriptRegionFlags uint8
+
+const (
+ isList = 1 << iota
+ scriptInFrom
+ regionInFrom
+)
+
+func (t *Tag) setUndefinedLang(id Language) {
+ if t.LangID == 0 {
+ t.LangID = id
+ }
+}
+
+func (t *Tag) setUndefinedScript(id Script) {
+ if t.ScriptID == 0 {
+ t.ScriptID = id
+ }
+}
+
+func (t *Tag) setUndefinedRegion(id Region) {
+ if t.RegionID == 0 || t.RegionID.Contains(id) {
+ t.RegionID = id
+ }
+}
+
+// ErrMissingLikelyTagsData indicates no information was available
+// to compute likely values of missing tags.
+var ErrMissingLikelyTagsData = errors.New("missing likely tags data")
+
+// addLikelySubtags sets subtags to their most likely value, given the locale.
+// In most cases this means setting fields for unknown values, but in some
+// cases it may alter a value. It returns an ErrMissingLikelyTagsData error
+// if the given locale cannot be expanded.
+func (t Tag) addLikelySubtags() (Tag, error) {
+ id, err := addTags(t)
+ if err != nil {
+ return t, err
+ } else if id.equalTags(t) {
+ return t, nil
+ }
+ id.RemakeString()
+ return id, nil
+}
+
+// specializeRegion attempts to specialize a group region.
+func specializeRegion(t *Tag) bool {
+ if i := regionInclusion[t.RegionID]; i < nRegionGroups {
+ x := likelyRegionGroup[i]
+ if Language(x.lang) == t.LangID && Script(x.script) == t.ScriptID {
+ t.RegionID = Region(x.region)
+ }
+ return true
+ }
+ return false
+}
+
+// Maximize returns a new tag with missing tags filled in.
+func (t Tag) Maximize() (Tag, error) {
+ return addTags(t)
+}
+
+func addTags(t Tag) (Tag, error) {
+ // We leave private use identifiers alone.
+ if t.IsPrivateUse() {
+ return t, nil
+ }
+ if t.ScriptID != 0 && t.RegionID != 0 {
+ if t.LangID != 0 {
+ // already fully specified
+ specializeRegion(&t)
+ return t, nil
+ }
+ // Search matches for und-script-region. Note that for these cases
+ // region will never be a group so there is no need to check for this.
+ list := likelyRegion[t.RegionID : t.RegionID+1]
+ if x := list[0]; x.flags&isList != 0 {
+ list = likelyRegionList[x.lang : x.lang+uint16(x.script)]
+ }
+ for _, x := range list {
+ // Deviating from the spec. See match_test.go for details.
+ if Script(x.script) == t.ScriptID {
+ t.setUndefinedLang(Language(x.lang))
+ return t, nil
+ }
+ }
+ }
+ if t.LangID != 0 {
+ // Search matches for lang-script and lang-region, where lang != und.
+ if t.LangID < langNoIndexOffset {
+ x := likelyLang[t.LangID]
+ if x.flags&isList != 0 {
+ list := likelyLangList[x.region : x.region+uint16(x.script)]
+ if t.ScriptID != 0 {
+ for _, x := range list {
+ if Script(x.script) == t.ScriptID && x.flags&scriptInFrom != 0 {
+ t.setUndefinedRegion(Region(x.region))
+ return t, nil
+ }
+ }
+ } else if t.RegionID != 0 {
+ count := 0
+ goodScript := true
+ tt := t
+ for _, x := range list {
+ // We visit all entries for which the script was not
+ // defined, including the ones where the region was not
+ // defined. This allows for proper disambiguation within
+ // regions.
+ if x.flags&scriptInFrom == 0 && t.RegionID.Contains(Region(x.region)) {
+ tt.RegionID = Region(x.region)
+ tt.setUndefinedScript(Script(x.script))
+ goodScript = goodScript && tt.ScriptID == Script(x.script)
+ count++
+ }
+ }
+ if count == 1 {
+ return tt, nil
+ }
+ // Even if we fail to find a unique Region, we might have
+ // an unambiguous script.
+ if goodScript {
+ t.ScriptID = tt.ScriptID
+ }
+ }
+ }
+ }
+ } else {
+ // Search matches for und-script.
+ if t.ScriptID != 0 {
+ x := likelyScript[t.ScriptID]
+ if x.region != 0 {
+ t.setUndefinedRegion(Region(x.region))
+ t.setUndefinedLang(Language(x.lang))
+ return t, nil
+ }
+ }
+ // Search matches for und-region. If und-script-region exists, it would
+ // have been found earlier.
+ if t.RegionID != 0 {
+ if i := regionInclusion[t.RegionID]; i < nRegionGroups {
+ x := likelyRegionGroup[i]
+ if x.region != 0 {
+ t.setUndefinedLang(Language(x.lang))
+ t.setUndefinedScript(Script(x.script))
+ t.RegionID = Region(x.region)
+ }
+ } else {
+ x := likelyRegion[t.RegionID]
+ if x.flags&isList != 0 {
+ x = likelyRegionList[x.lang]
+ }
+ if x.script != 0 && x.flags != scriptInFrom {
+ t.setUndefinedLang(Language(x.lang))
+ t.setUndefinedScript(Script(x.script))
+ return t, nil
+ }
+ }
+ }
+ }
+
+ // Search matches for lang.
+ if t.LangID < langNoIndexOffset {
+ x := likelyLang[t.LangID]
+ if x.flags&isList != 0 {
+ x = likelyLangList[x.region]
+ }
+ if x.region != 0 {
+ t.setUndefinedScript(Script(x.script))
+ t.setUndefinedRegion(Region(x.region))
+ }
+ specializeRegion(&t)
+ if t.LangID == 0 {
+ t.LangID = _en // default language
+ }
+ return t, nil
+ }
+ return t, ErrMissingLikelyTagsData
+}
+
+func (t *Tag) setTagsFrom(id Tag) {
+ t.LangID = id.LangID
+ t.ScriptID = id.ScriptID
+ t.RegionID = id.RegionID
+}
+
+// minimize removes the region or script subtags from t such that
+// t.addLikelySubtags() == t.minimize().addLikelySubtags().
+func (t Tag) minimize() (Tag, error) {
+ t, err := minimizeTags(t)
+ if err != nil {
+ return t, err
+ }
+ t.RemakeString()
+ return t, nil
+}
+
+// minimizeTags mimics the behavior of the ICU 51 C implementation.
+func minimizeTags(t Tag) (Tag, error) {
+ if t.equalTags(Und) {
+ return t, nil
+ }
+ max, err := addTags(t)
+ if err != nil {
+ return t, err
+ }
+ for _, id := range [...]Tag{
+ {LangID: t.LangID},
+ {LangID: t.LangID, RegionID: t.RegionID},
+ {LangID: t.LangID, ScriptID: t.ScriptID},
+ } {
+ if x, err := addTags(id); err == nil && max.equalTags(x) {
+ t.setTagsFrom(id)
+ break
+ }
+ }
+ return t, nil
+}
diff --git a/vendor/golang.org/x/text/internal/language/parse.go b/vendor/golang.org/x/text/internal/language/parse.go
new file mode 100644
index 0000000..aad1e0a
--- /dev/null
+++ b/vendor/golang.org/x/text/internal/language/parse.go
@@ -0,0 +1,608 @@
+// Copyright 2013 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package language
+
+import (
+ "bytes"
+ "errors"
+ "fmt"
+ "sort"
+
+ "golang.org/x/text/internal/tag"
+)
+
+// isAlpha returns true if the byte is not a digit.
+// b must be an ASCII letter or digit.
+func isAlpha(b byte) bool {
+ return b > '9'
+}
+
+// isAlphaNum returns true if the string contains only ASCII letters or digits.
+func isAlphaNum(s []byte) bool {
+ for _, c := range s {
+ if !('a' <= c && c <= 'z' || 'A' <= c && c <= 'Z' || '0' <= c && c <= '9') {
+ return false
+ }
+ }
+ return true
+}
+
+// ErrSyntax is returned by any of the parsing functions when the
+// input is not well-formed, according to BCP 47.
+// TODO: return the position at which the syntax error occurred?
+var ErrSyntax = errors.New("language: tag is not well-formed")
+
+// ErrDuplicateKey is returned when a tag contains the same key twice with
+// different values in the -u section.
+var ErrDuplicateKey = errors.New("language: different values for same key in -u extension")
+
+// ValueError is returned by any of the parsing functions when the
+// input is well-formed but the respective subtag is not recognized
+// as a valid value.
+type ValueError struct {
+ v [8]byte
+}
+
+// NewValueError creates a new ValueError.
+func NewValueError(tag []byte) ValueError {
+ var e ValueError
+ copy(e.v[:], tag)
+ return e
+}
+
+func (e ValueError) tag() []byte {
+ n := bytes.IndexByte(e.v[:], 0)
+ if n == -1 {
+ n = 8
+ }
+ return e.v[:n]
+}
+
+// Error implements the error interface.
+func (e ValueError) Error() string {
+ return fmt.Sprintf("language: subtag %q is well-formed but unknown", e.tag())
+}
+
+// Subtag returns the subtag for which the error occurred.
+func (e ValueError) Subtag() string {
+ return string(e.tag())
+}
+
+// scanner is used to scan BCP 47 tokens, which are separated by _ or -.
+type scanner struct {
+ b []byte
+ bytes [max99thPercentileSize]byte
+ token []byte
+ start int // start position of the current token
+ end int // end position of the current token
+ next int // next point for scan
+ err error
+ done bool
+}
+
+func makeScannerString(s string) scanner {
+ scan := scanner{}
+ if len(s) <= len(scan.bytes) {
+ scan.b = scan.bytes[:copy(scan.bytes[:], s)]
+ } else {
+ scan.b = []byte(s)
+ }
+ scan.init()
+ return scan
+}
+
+// makeScanner returns a scanner using b as the input buffer.
+// b is not copied and may be modified by the scanner routines.
+func makeScanner(b []byte) scanner {
+ scan := scanner{b: b}
+ scan.init()
+ return scan
+}
+
+func (s *scanner) init() {
+ for i, c := range s.b {
+ if c == '_' {
+ s.b[i] = '-'
+ }
+ }
+ s.scan()
+}
+
+// restToLower converts the string between start and end to lower case.
+func (s *scanner) toLower(start, end int) {
+ for i := start; i < end; i++ {
+ c := s.b[i]
+ if 'A' <= c && c <= 'Z' {
+ s.b[i] += 'a' - 'A'
+ }
+ }
+}
+
+func (s *scanner) setError(e error) {
+ if s.err == nil || (e == ErrSyntax && s.err != ErrSyntax) {
+ s.err = e
+ }
+}
+
+// resizeRange shrinks or grows the array at position oldStart such that
+// a new string of size newSize can fit between oldStart and oldEnd.
+// Sets the scan point to after the resized range.
+func (s *scanner) resizeRange(oldStart, oldEnd, newSize int) {
+ s.start = oldStart
+ if end := oldStart + newSize; end != oldEnd {
+ diff := end - oldEnd
+ var b []byte
+ if n := len(s.b) + diff; n > cap(s.b) {
+ b = make([]byte, n)
+ copy(b, s.b[:oldStart])
+ } else {
+ b = s.b[:n]
+ }
+ copy(b[end:], s.b[oldEnd:])
+ s.b = b
+ s.next = end + (s.next - s.end)
+ s.end = end
+ }
+}
+
+// replace replaces the current token with repl.
+func (s *scanner) replace(repl string) {
+ s.resizeRange(s.start, s.end, len(repl))
+ copy(s.b[s.start:], repl)
+}
+
+// gobble removes the current token from the input.
+// Caller must call scan after calling gobble.
+func (s *scanner) gobble(e error) {
+ s.setError(e)
+ if s.start == 0 {
+ s.b = s.b[:+copy(s.b, s.b[s.next:])]
+ s.end = 0
+ } else {
+ s.b = s.b[:s.start-1+copy(s.b[s.start-1:], s.b[s.end:])]
+ s.end = s.start - 1
+ }
+ s.next = s.start
+}
+
+// deleteRange removes the given range from s.b before the current token.
+func (s *scanner) deleteRange(start, end int) {
+ s.b = s.b[:start+copy(s.b[start:], s.b[end:])]
+ diff := end - start
+ s.next -= diff
+ s.start -= diff
+ s.end -= diff
+}
+
+// scan parses the next token of a BCP 47 string. Tokens that are larger
+// than 8 characters or include non-alphanumeric characters result in an error
+// and are gobbled and removed from the output.
+// It returns the end position of the last token consumed.
+func (s *scanner) scan() (end int) {
+ end = s.end
+ s.token = nil
+ for s.start = s.next; s.next < len(s.b); {
+ i := bytes.IndexByte(s.b[s.next:], '-')
+ if i == -1 {
+ s.end = len(s.b)
+ s.next = len(s.b)
+ i = s.end - s.start
+ } else {
+ s.end = s.next + i
+ s.next = s.end + 1
+ }
+ token := s.b[s.start:s.end]
+ if i < 1 || i > 8 || !isAlphaNum(token) {
+ s.gobble(ErrSyntax)
+ continue
+ }
+ s.token = token
+ return end
+ }
+ if n := len(s.b); n > 0 && s.b[n-1] == '-' {
+ s.setError(ErrSyntax)
+ s.b = s.b[:len(s.b)-1]
+ }
+ s.done = true
+ return end
+}
+
+// acceptMinSize parses multiple tokens of the given size or greater.
+// It returns the end position of the last token consumed.
+func (s *scanner) acceptMinSize(min int) (end int) {
+ end = s.end
+ s.scan()
+ for ; len(s.token) >= min; s.scan() {
+ end = s.end
+ }
+ return end
+}
+
+// Parse parses the given BCP 47 string and returns a valid Tag. If parsing
+// failed it returns an error and any part of the tag that could be parsed.
+// If parsing succeeded but an unknown value was found, it returns
+// ValueError. The Tag returned in this case is just stripped of the unknown
+// value. All other values are preserved. It accepts tags in the BCP 47 format
+// and extensions to this standard defined in
+// https://www.unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers.
+func Parse(s string) (t Tag, err error) {
+ // TODO: consider supporting old-style locale key-value pairs.
+ if s == "" {
+ return Und, ErrSyntax
+ }
+ defer func() {
+ if recover() != nil {
+ t = Und
+ err = ErrSyntax
+ return
+ }
+ }()
+ if len(s) <= maxAltTaglen {
+ b := [maxAltTaglen]byte{}
+ for i, c := range s {
+ // Generating invalid UTF-8 is okay as it won't match.
+ if 'A' <= c && c <= 'Z' {
+ c += 'a' - 'A'
+ } else if c == '_' {
+ c = '-'
+ }
+ b[i] = byte(c)
+ }
+ if t, ok := grandfathered(b); ok {
+ return t, nil
+ }
+ }
+ scan := makeScannerString(s)
+ return parse(&scan, s)
+}
+
+func parse(scan *scanner, s string) (t Tag, err error) {
+ t = Und
+ var end int
+ if n := len(scan.token); n <= 1 {
+ scan.toLower(0, len(scan.b))
+ if n == 0 || scan.token[0] != 'x' {
+ return t, ErrSyntax
+ }
+ end = parseExtensions(scan)
+ } else if n >= 4 {
+ return Und, ErrSyntax
+ } else { // the usual case
+ t, end = parseTag(scan, true)
+ if n := len(scan.token); n == 1 {
+ t.pExt = uint16(end)
+ end = parseExtensions(scan)
+ } else if end < len(scan.b) {
+ scan.setError(ErrSyntax)
+ scan.b = scan.b[:end]
+ }
+ }
+ if int(t.pVariant) < len(scan.b) {
+ if end < len(s) {
+ s = s[:end]
+ }
+ if len(s) > 0 && tag.Compare(s, scan.b) == 0 {
+ t.str = s
+ } else {
+ t.str = string(scan.b)
+ }
+ } else {
+ t.pVariant, t.pExt = 0, 0
+ }
+ return t, scan.err
+}
+
+// parseTag parses language, script, region and variants.
+// It returns a Tag and the end position in the input that was parsed.
+// If doNorm is true, then - will be normalized to .
+func parseTag(scan *scanner, doNorm bool) (t Tag, end int) {
+ var e error
+ // TODO: set an error if an unknown lang, script or region is encountered.
+ t.LangID, e = getLangID(scan.token)
+ scan.setError(e)
+ scan.replace(t.LangID.String())
+ langStart := scan.start
+ end = scan.scan()
+ for len(scan.token) == 3 && isAlpha(scan.token[0]) {
+ // From http://tools.ietf.org/html/bcp47, - tags are equivalent
+ // to a tag of the form .
+ if doNorm {
+ lang, e := getLangID(scan.token)
+ if lang != 0 {
+ t.LangID = lang
+ langStr := lang.String()
+ copy(scan.b[langStart:], langStr)
+ scan.b[langStart+len(langStr)] = '-'
+ scan.start = langStart + len(langStr) + 1
+ }
+ scan.gobble(e)
+ }
+ end = scan.scan()
+ }
+ if len(scan.token) == 4 && isAlpha(scan.token[0]) {
+ t.ScriptID, e = getScriptID(script, scan.token)
+ if t.ScriptID == 0 {
+ scan.gobble(e)
+ }
+ end = scan.scan()
+ }
+ if n := len(scan.token); n >= 2 && n <= 3 {
+ t.RegionID, e = getRegionID(scan.token)
+ if t.RegionID == 0 {
+ scan.gobble(e)
+ } else {
+ scan.replace(t.RegionID.String())
+ }
+ end = scan.scan()
+ }
+ scan.toLower(scan.start, len(scan.b))
+ t.pVariant = byte(end)
+ end = parseVariants(scan, end, t)
+ t.pExt = uint16(end)
+ return t, end
+}
+
+var separator = []byte{'-'}
+
+// parseVariants scans tokens as long as each token is a valid variant string.
+// Duplicate variants are removed.
+func parseVariants(scan *scanner, end int, t Tag) int {
+ start := scan.start
+ varIDBuf := [4]uint8{}
+ variantBuf := [4][]byte{}
+ varID := varIDBuf[:0]
+ variant := variantBuf[:0]
+ last := -1
+ needSort := false
+ for ; len(scan.token) >= 4; scan.scan() {
+ // TODO: measure the impact of needing this conversion and redesign
+ // the data structure if there is an issue.
+ v, ok := variantIndex[string(scan.token)]
+ if !ok {
+ // unknown variant
+ // TODO: allow user-defined variants?
+ scan.gobble(NewValueError(scan.token))
+ continue
+ }
+ varID = append(varID, v)
+ variant = append(variant, scan.token)
+ if !needSort {
+ if last < int(v) {
+ last = int(v)
+ } else {
+ needSort = true
+ // There is no legal combinations of more than 7 variants
+ // (and this is by no means a useful sequence).
+ const maxVariants = 8
+ if len(varID) > maxVariants {
+ break
+ }
+ }
+ }
+ end = scan.end
+ }
+ if needSort {
+ sort.Sort(variantsSort{varID, variant})
+ k, l := 0, -1
+ for i, v := range varID {
+ w := int(v)
+ if l == w {
+ // Remove duplicates.
+ continue
+ }
+ varID[k] = varID[i]
+ variant[k] = variant[i]
+ k++
+ l = w
+ }
+ if str := bytes.Join(variant[:k], separator); len(str) == 0 {
+ end = start - 1
+ } else {
+ scan.resizeRange(start, end, len(str))
+ copy(scan.b[scan.start:], str)
+ end = scan.end
+ }
+ }
+ return end
+}
+
+type variantsSort struct {
+ i []uint8
+ v [][]byte
+}
+
+func (s variantsSort) Len() int {
+ return len(s.i)
+}
+
+func (s variantsSort) Swap(i, j int) {
+ s.i[i], s.i[j] = s.i[j], s.i[i]
+ s.v[i], s.v[j] = s.v[j], s.v[i]
+}
+
+func (s variantsSort) Less(i, j int) bool {
+ return s.i[i] < s.i[j]
+}
+
+type bytesSort struct {
+ b [][]byte
+ n int // first n bytes to compare
+}
+
+func (b bytesSort) Len() int {
+ return len(b.b)
+}
+
+func (b bytesSort) Swap(i, j int) {
+ b.b[i], b.b[j] = b.b[j], b.b[i]
+}
+
+func (b bytesSort) Less(i, j int) bool {
+ for k := 0; k < b.n; k++ {
+ if b.b[i][k] == b.b[j][k] {
+ continue
+ }
+ return b.b[i][k] < b.b[j][k]
+ }
+ return false
+}
+
+// parseExtensions parses and normalizes the extensions in the buffer.
+// It returns the last position of scan.b that is part of any extension.
+// It also trims scan.b to remove excess parts accordingly.
+func parseExtensions(scan *scanner) int {
+ start := scan.start
+ exts := [][]byte{}
+ private := []byte{}
+ end := scan.end
+ for len(scan.token) == 1 {
+ extStart := scan.start
+ ext := scan.token[0]
+ end = parseExtension(scan)
+ extension := scan.b[extStart:end]
+ if len(extension) < 3 || (ext != 'x' && len(extension) < 4) {
+ scan.setError(ErrSyntax)
+ end = extStart
+ continue
+ } else if start == extStart && (ext == 'x' || scan.start == len(scan.b)) {
+ scan.b = scan.b[:end]
+ return end
+ } else if ext == 'x' {
+ private = extension
+ break
+ }
+ exts = append(exts, extension)
+ }
+ sort.Sort(bytesSort{exts, 1})
+ if len(private) > 0 {
+ exts = append(exts, private)
+ }
+ scan.b = scan.b[:start]
+ if len(exts) > 0 {
+ scan.b = append(scan.b, bytes.Join(exts, separator)...)
+ } else if start > 0 {
+ // Strip trailing '-'.
+ scan.b = scan.b[:start-1]
+ }
+ return end
+}
+
+// parseExtension parses a single extension and returns the position of
+// the extension end.
+func parseExtension(scan *scanner) int {
+ start, end := scan.start, scan.end
+ switch scan.token[0] {
+ case 'u': // https://www.ietf.org/rfc/rfc6067.txt
+ attrStart := end
+ scan.scan()
+ for last := []byte{}; len(scan.token) > 2; scan.scan() {
+ if bytes.Compare(scan.token, last) != -1 {
+ // Attributes are unsorted. Start over from scratch.
+ p := attrStart + 1
+ scan.next = p
+ attrs := [][]byte{}
+ for scan.scan(); len(scan.token) > 2; scan.scan() {
+ attrs = append(attrs, scan.token)
+ end = scan.end
+ }
+ sort.Sort(bytesSort{attrs, 3})
+ copy(scan.b[p:], bytes.Join(attrs, separator))
+ break
+ }
+ last = scan.token
+ end = scan.end
+ }
+ // Scan key-type sequences. A key is of length 2 and may be followed
+ // by 0 or more "type" subtags from 3 to the maximum of 8 letters.
+ var last, key []byte
+ for attrEnd := end; len(scan.token) == 2; last = key {
+ key = scan.token
+ end = scan.end
+ for scan.scan(); end < scan.end && len(scan.token) > 2; scan.scan() {
+ end = scan.end
+ }
+ // TODO: check key value validity
+ if bytes.Compare(key, last) != 1 || scan.err != nil {
+ // We have an invalid key or the keys are not sorted.
+ // Start scanning keys from scratch and reorder.
+ p := attrEnd + 1
+ scan.next = p
+ keys := [][]byte{}
+ for scan.scan(); len(scan.token) == 2; {
+ keyStart := scan.start
+ end = scan.end
+ for scan.scan(); end < scan.end && len(scan.token) > 2; scan.scan() {
+ end = scan.end
+ }
+ keys = append(keys, scan.b[keyStart:end])
+ }
+ sort.Stable(bytesSort{keys, 2})
+ if n := len(keys); n > 0 {
+ k := 0
+ for i := 1; i < n; i++ {
+ if !bytes.Equal(keys[k][:2], keys[i][:2]) {
+ k++
+ keys[k] = keys[i]
+ } else if !bytes.Equal(keys[k], keys[i]) {
+ scan.setError(ErrDuplicateKey)
+ }
+ }
+ keys = keys[:k+1]
+ }
+ reordered := bytes.Join(keys, separator)
+ if e := p + len(reordered); e < end {
+ scan.deleteRange(e, end)
+ end = e
+ }
+ copy(scan.b[p:], reordered)
+ break
+ }
+ }
+ case 't': // https://www.ietf.org/rfc/rfc6497.txt
+ scan.scan()
+ if n := len(scan.token); n >= 2 && n <= 3 && isAlpha(scan.token[1]) {
+ _, end = parseTag(scan, false)
+ scan.toLower(start, end)
+ }
+ for len(scan.token) == 2 && !isAlpha(scan.token[1]) {
+ end = scan.acceptMinSize(3)
+ }
+ case 'x':
+ end = scan.acceptMinSize(1)
+ default:
+ end = scan.acceptMinSize(2)
+ }
+ return end
+}
+
+// getExtension returns the name, body and end position of the extension.
+func getExtension(s string, p int) (end int, ext string) {
+ if s[p] == '-' {
+ p++
+ }
+ if s[p] == 'x' {
+ return len(s), s[p:]
+ }
+ end = nextExtension(s, p)
+ return end, s[p:end]
+}
+
+// nextExtension finds the next extension within the string, searching
+// for the -- pattern from position p.
+// In the fast majority of cases, language tags will have at most
+// one extension and extensions tend to be small.
+func nextExtension(s string, p int) int {
+ for n := len(s) - 3; p < n; {
+ if s[p] == '-' {
+ if s[p+2] == '-' {
+ return p
+ }
+ p += 3
+ } else {
+ p++
+ }
+ }
+ return len(s)
+}
diff --git a/vendor/golang.org/x/text/internal/language/tables.go b/vendor/golang.org/x/text/internal/language/tables.go
new file mode 100644
index 0000000..fb6b583
--- /dev/null
+++ b/vendor/golang.org/x/text/internal/language/tables.go
@@ -0,0 +1,3472 @@
+// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
+
+package language
+
+import "golang.org/x/text/internal/tag"
+
+// CLDRVersion is the CLDR version from which the tables in this package are derived.
+const CLDRVersion = "32"
+
+const NumLanguages = 8752
+
+const NumScripts = 258
+
+const NumRegions = 357
+
+type FromTo struct {
+ From uint16
+ To uint16
+}
+
+const nonCanonicalUnd = 1201
+const (
+ _af = 22
+ _am = 39
+ _ar = 58
+ _az = 88
+ _bg = 126
+ _bn = 165
+ _ca = 215
+ _cs = 250
+ _da = 257
+ _de = 269
+ _el = 310
+ _en = 313
+ _es = 318
+ _et = 320
+ _fa = 328
+ _fi = 337
+ _fil = 339
+ _fr = 350
+ _gu = 420
+ _he = 444
+ _hi = 446
+ _hr = 465
+ _hu = 469
+ _hy = 471
+ _id = 481
+ _is = 504
+ _it = 505
+ _ja = 512
+ _ka = 528
+ _kk = 578
+ _km = 586
+ _kn = 593
+ _ko = 596
+ _ky = 650
+ _lo = 696
+ _lt = 704
+ _lv = 711
+ _mk = 767
+ _ml = 772
+ _mn = 779
+ _mo = 784
+ _mr = 795
+ _ms = 799
+ _mul = 806
+ _my = 817
+ _nb = 839
+ _ne = 849
+ _nl = 871
+ _no = 879
+ _pa = 925
+ _pl = 947
+ _pt = 960
+ _ro = 988
+ _ru = 994
+ _sh = 1031
+ _si = 1036
+ _sk = 1042
+ _sl = 1046
+ _sq = 1073
+ _sr = 1074
+ _sv = 1092
+ _sw = 1093
+ _ta = 1104
+ _te = 1121
+ _th = 1131
+ _tl = 1146
+ _tn = 1152
+ _tr = 1162
+ _uk = 1198
+ _ur = 1204
+ _uz = 1212
+ _vi = 1219
+ _zh = 1321
+ _zu = 1327
+ _jbo = 515
+ _ami = 1650
+ _bnn = 2357
+ _hak = 438
+ _tlh = 14467
+ _lb = 661
+ _nv = 899
+ _pwn = 12055
+ _tao = 14188
+ _tay = 14198
+ _tsu = 14662
+ _nn = 874
+ _sfb = 13629
+ _vgt = 15701
+ _sgg = 13660
+ _cmn = 3007
+ _nan = 835
+ _hsn = 467
+)
+
+const langPrivateStart = 0x2f72
+
+const langPrivateEnd = 0x3179
+
+// lang holds an alphabetically sorted list of ISO-639 language identifiers.
+// All entries are 4 bytes. The index of the identifier (divided by 4) is the language tag.
+// For 2-byte language identifiers, the two successive bytes have the following meaning:
+// - if the first letter of the 2- and 3-letter ISO codes are the same:
+// the second and third letter of the 3-letter ISO code.
+// - otherwise: a 0 and a by 2 bits right-shifted index into altLangISO3.
+//
+// For 3-byte language identifiers the 4th byte is 0.
+const lang tag.Index = "" + // Size: 5324 bytes
+ "---\x00aaaraai\x00aak\x00aau\x00abbkabi\x00abq\x00abr\x00abt\x00aby\x00a" +
+ "cd\x00ace\x00ach\x00ada\x00ade\x00adj\x00ady\x00adz\x00aeveaeb\x00aey" +
+ "\x00affragc\x00agd\x00agg\x00agm\x00ago\x00agq\x00aha\x00ahl\x00aho\x00a" +
+ "jg\x00akkaakk\x00ala\x00ali\x00aln\x00alt\x00ammhamm\x00amn\x00amo\x00am" +
+ "p\x00anrganc\x00ank\x00ann\x00any\x00aoj\x00aom\x00aoz\x00apc\x00apd\x00" +
+ "ape\x00apr\x00aps\x00apz\x00arraarc\x00arh\x00arn\x00aro\x00arq\x00ars" +
+ "\x00ary\x00arz\x00assmasa\x00ase\x00asg\x00aso\x00ast\x00ata\x00atg\x00a" +
+ "tj\x00auy\x00avvaavl\x00avn\x00avt\x00avu\x00awa\x00awb\x00awo\x00awx" +
+ "\x00ayymayb\x00azzebaakbal\x00ban\x00bap\x00bar\x00bas\x00bav\x00bax\x00" +
+ "bba\x00bbb\x00bbc\x00bbd\x00bbj\x00bbp\x00bbr\x00bcf\x00bch\x00bci\x00bc" +
+ "m\x00bcn\x00bco\x00bcq\x00bcu\x00bdd\x00beelbef\x00beh\x00bej\x00bem\x00" +
+ "bet\x00bew\x00bex\x00bez\x00bfd\x00bfq\x00bft\x00bfy\x00bgulbgc\x00bgn" +
+ "\x00bgx\x00bhihbhb\x00bhg\x00bhi\x00bhk\x00bhl\x00bho\x00bhy\x00biisbib" +
+ "\x00big\x00bik\x00bim\x00bin\x00bio\x00biq\x00bjh\x00bji\x00bjj\x00bjn" +
+ "\x00bjo\x00bjr\x00bjt\x00bjz\x00bkc\x00bkm\x00bkq\x00bku\x00bkv\x00blt" +
+ "\x00bmambmh\x00bmk\x00bmq\x00bmu\x00bnenbng\x00bnm\x00bnp\x00boodboj\x00" +
+ "bom\x00bon\x00bpy\x00bqc\x00bqi\x00bqp\x00bqv\x00brrebra\x00brh\x00brx" +
+ "\x00brz\x00bsosbsj\x00bsq\x00bss\x00bst\x00bto\x00btt\x00btv\x00bua\x00b" +
+ "uc\x00bud\x00bug\x00buk\x00bum\x00buo\x00bus\x00buu\x00bvb\x00bwd\x00bwr" +
+ "\x00bxh\x00bye\x00byn\x00byr\x00bys\x00byv\x00byx\x00bza\x00bze\x00bzf" +
+ "\x00bzh\x00bzw\x00caatcan\x00cbj\x00cch\x00ccp\x00ceheceb\x00cfa\x00cgg" +
+ "\x00chhachk\x00chm\x00cho\x00chp\x00chr\x00cja\x00cjm\x00cjv\x00ckb\x00c" +
+ "kl\x00cko\x00cky\x00cla\x00cme\x00cmg\x00cooscop\x00cps\x00crrecrh\x00cr" +
+ "j\x00crk\x00crl\x00crm\x00crs\x00csescsb\x00csw\x00ctd\x00cuhucvhvcyymda" +
+ "andad\x00daf\x00dag\x00dah\x00dak\x00dar\x00dav\x00dbd\x00dbq\x00dcc\x00" +
+ "ddn\x00deeuded\x00den\x00dga\x00dgh\x00dgi\x00dgl\x00dgr\x00dgz\x00dia" +
+ "\x00dje\x00dnj\x00dob\x00doi\x00dop\x00dow\x00dri\x00drs\x00dsb\x00dtm" +
+ "\x00dtp\x00dts\x00dty\x00dua\x00duc\x00dud\x00dug\x00dvivdva\x00dww\x00d" +
+ "yo\x00dyu\x00dzzodzg\x00ebu\x00eeweefi\x00egl\x00egy\x00eka\x00eky\x00el" +
+ "llema\x00emi\x00enngenn\x00enq\x00eopoeri\x00es\x00\x05esu\x00etstetr" +
+ "\x00ett\x00etu\x00etx\x00euusewo\x00ext\x00faasfaa\x00fab\x00fag\x00fai" +
+ "\x00fan\x00ffulffi\x00ffm\x00fiinfia\x00fil\x00fit\x00fjijflr\x00fmp\x00" +
+ "foaofod\x00fon\x00for\x00fpe\x00fqs\x00frrafrc\x00frp\x00frr\x00frs\x00f" +
+ "ub\x00fud\x00fue\x00fuf\x00fuh\x00fuq\x00fur\x00fuv\x00fuy\x00fvr\x00fyr" +
+ "ygalegaa\x00gaf\x00gag\x00gah\x00gaj\x00gam\x00gan\x00gaw\x00gay\x00gba" +
+ "\x00gbf\x00gbm\x00gby\x00gbz\x00gcr\x00gdlagde\x00gdn\x00gdr\x00geb\x00g" +
+ "ej\x00gel\x00gez\x00gfk\x00ggn\x00ghs\x00gil\x00gim\x00gjk\x00gjn\x00gju" +
+ "\x00gkn\x00gkp\x00gllgglk\x00gmm\x00gmv\x00gnrngnd\x00gng\x00god\x00gof" +
+ "\x00goi\x00gom\x00gon\x00gor\x00gos\x00got\x00grb\x00grc\x00grt\x00grw" +
+ "\x00gsw\x00guujgub\x00guc\x00gud\x00gur\x00guw\x00gux\x00guz\x00gvlvgvf" +
+ "\x00gvr\x00gvs\x00gwc\x00gwi\x00gwt\x00gyi\x00haauhag\x00hak\x00ham\x00h" +
+ "aw\x00haz\x00hbb\x00hdy\x00heebhhy\x00hiinhia\x00hif\x00hig\x00hih\x00hi" +
+ "l\x00hla\x00hlu\x00hmd\x00hmt\x00hnd\x00hne\x00hnj\x00hnn\x00hno\x00homo" +
+ "hoc\x00hoj\x00hot\x00hrrvhsb\x00hsn\x00htathuunhui\x00hyyehzerianaian" +
+ "\x00iar\x00iba\x00ibb\x00iby\x00ica\x00ich\x00idndidd\x00idi\x00idu\x00i" +
+ "eleife\x00igboigb\x00ige\x00iiiiijj\x00ikpkikk\x00ikt\x00ikw\x00ikx\x00i" +
+ "lo\x00imo\x00inndinh\x00iodoiou\x00iri\x00isslittaiukuiw\x00\x03iwm\x00i" +
+ "ws\x00izh\x00izi\x00japnjab\x00jam\x00jbo\x00jbu\x00jen\x00jgk\x00jgo" +
+ "\x00ji\x00\x06jib\x00jmc\x00jml\x00jra\x00jut\x00jvavjwavkaatkaa\x00kab" +
+ "\x00kac\x00kad\x00kai\x00kaj\x00kam\x00kao\x00kbd\x00kbm\x00kbp\x00kbq" +
+ "\x00kbx\x00kby\x00kcg\x00kck\x00kcl\x00kct\x00kde\x00kdh\x00kdl\x00kdt" +
+ "\x00kea\x00ken\x00kez\x00kfo\x00kfr\x00kfy\x00kgonkge\x00kgf\x00kgp\x00k" +
+ "ha\x00khb\x00khn\x00khq\x00khs\x00kht\x00khw\x00khz\x00kiikkij\x00kiu" +
+ "\x00kiw\x00kjuakjd\x00kjg\x00kjs\x00kjy\x00kkazkkc\x00kkj\x00klalkln\x00" +
+ "klq\x00klt\x00klx\x00kmhmkmb\x00kmh\x00kmo\x00kms\x00kmu\x00kmw\x00knank" +
+ "nf\x00knp\x00koorkoi\x00kok\x00kol\x00kos\x00koz\x00kpe\x00kpf\x00kpo" +
+ "\x00kpr\x00kpx\x00kqb\x00kqf\x00kqs\x00kqy\x00kraukrc\x00kri\x00krj\x00k" +
+ "rl\x00krs\x00kru\x00ksasksb\x00ksd\x00ksf\x00ksh\x00ksj\x00ksr\x00ktb" +
+ "\x00ktm\x00kto\x00kuurkub\x00kud\x00kue\x00kuj\x00kum\x00kun\x00kup\x00k" +
+ "us\x00kvomkvg\x00kvr\x00kvx\x00kw\x00\x01kwj\x00kwo\x00kxa\x00kxc\x00kxm" +
+ "\x00kxp\x00kxw\x00kxz\x00kyirkye\x00kyx\x00kzr\x00laatlab\x00lad\x00lag" +
+ "\x00lah\x00laj\x00las\x00lbtzlbe\x00lbu\x00lbw\x00lcm\x00lcp\x00ldb\x00l" +
+ "ed\x00lee\x00lem\x00lep\x00leq\x00leu\x00lez\x00lguglgg\x00liimlia\x00li" +
+ "d\x00lif\x00lig\x00lih\x00lij\x00lis\x00ljp\x00lki\x00lkt\x00lle\x00lln" +
+ "\x00lmn\x00lmo\x00lmp\x00lninlns\x00lnu\x00loaoloj\x00lok\x00lol\x00lor" +
+ "\x00los\x00loz\x00lrc\x00ltitltg\x00luublua\x00luo\x00luy\x00luz\x00lvav" +
+ "lwl\x00lzh\x00lzz\x00mad\x00maf\x00mag\x00mai\x00mak\x00man\x00mas\x00ma" +
+ "w\x00maz\x00mbh\x00mbo\x00mbq\x00mbu\x00mbw\x00mci\x00mcp\x00mcq\x00mcr" +
+ "\x00mcu\x00mda\x00mde\x00mdf\x00mdh\x00mdj\x00mdr\x00mdx\x00med\x00mee" +
+ "\x00mek\x00men\x00mer\x00met\x00meu\x00mfa\x00mfe\x00mfn\x00mfo\x00mfq" +
+ "\x00mglgmgh\x00mgl\x00mgo\x00mgp\x00mgy\x00mhahmhi\x00mhl\x00mirimif\x00" +
+ "min\x00mis\x00miw\x00mkkdmki\x00mkl\x00mkp\x00mkw\x00mlalmle\x00mlp\x00m" +
+ "ls\x00mmo\x00mmu\x00mmx\x00mnonmna\x00mnf\x00mni\x00mnw\x00moolmoa\x00mo" +
+ "e\x00moh\x00mos\x00mox\x00mpp\x00mps\x00mpt\x00mpx\x00mql\x00mrarmrd\x00" +
+ "mrj\x00mro\x00mssamtltmtc\x00mtf\x00mti\x00mtr\x00mua\x00mul\x00mur\x00m" +
+ "us\x00mva\x00mvn\x00mvy\x00mwk\x00mwr\x00mwv\x00mxc\x00mxm\x00myyamyk" +
+ "\x00mym\x00myv\x00myw\x00myx\x00myz\x00mzk\x00mzm\x00mzn\x00mzp\x00mzw" +
+ "\x00mzz\x00naaunac\x00naf\x00nah\x00nak\x00nan\x00nap\x00naq\x00nas\x00n" +
+ "bobnca\x00nce\x00ncf\x00nch\x00nco\x00ncu\x00nddendc\x00nds\x00neepneb" +
+ "\x00new\x00nex\x00nfr\x00ngdonga\x00ngb\x00ngl\x00nhb\x00nhe\x00nhw\x00n" +
+ "if\x00nii\x00nij\x00nin\x00niu\x00niy\x00niz\x00njo\x00nkg\x00nko\x00nll" +
+ "dnmg\x00nmz\x00nnnonnf\x00nnh\x00nnk\x00nnm\x00noornod\x00noe\x00non\x00" +
+ "nop\x00nou\x00nqo\x00nrblnrb\x00nsk\x00nsn\x00nso\x00nss\x00ntm\x00ntr" +
+ "\x00nui\x00nup\x00nus\x00nuv\x00nux\x00nvavnwb\x00nxq\x00nxr\x00nyyanym" +
+ "\x00nyn\x00nzi\x00occiogc\x00ojjiokr\x00okv\x00omrmong\x00onn\x00ons\x00" +
+ "opm\x00orrioro\x00oru\x00osssosa\x00ota\x00otk\x00ozm\x00paanpag\x00pal" +
+ "\x00pam\x00pap\x00pau\x00pbi\x00pcd\x00pcm\x00pdc\x00pdt\x00ped\x00peo" +
+ "\x00pex\x00pfl\x00phl\x00phn\x00pilipil\x00pip\x00pka\x00pko\x00plolpla" +
+ "\x00pms\x00png\x00pnn\x00pnt\x00pon\x00ppo\x00pra\x00prd\x00prg\x00psusp" +
+ "ss\x00ptorptp\x00puu\x00pwa\x00quuequc\x00qug\x00rai\x00raj\x00rao\x00rc" +
+ "f\x00rej\x00rel\x00res\x00rgn\x00rhg\x00ria\x00rif\x00rjs\x00rkt\x00rmoh" +
+ "rmf\x00rmo\x00rmt\x00rmu\x00rnunrna\x00rng\x00roonrob\x00rof\x00roo\x00r" +
+ "ro\x00rtm\x00ruusrue\x00rug\x00rw\x00\x04rwk\x00rwo\x00ryu\x00saansaf" +
+ "\x00sah\x00saq\x00sas\x00sat\x00sav\x00saz\x00sba\x00sbe\x00sbp\x00scrds" +
+ "ck\x00scl\x00scn\x00sco\x00scs\x00sdndsdc\x00sdh\x00semesef\x00seh\x00se" +
+ "i\x00ses\x00sgagsga\x00sgs\x00sgw\x00sgz\x00sh\x00\x02shi\x00shk\x00shn" +
+ "\x00shu\x00siinsid\x00sig\x00sil\x00sim\x00sjr\x00sklkskc\x00skr\x00sks" +
+ "\x00sllvsld\x00sli\x00sll\x00sly\x00smmosma\x00smi\x00smj\x00smn\x00smp" +
+ "\x00smq\x00sms\x00snnasnc\x00snk\x00snp\x00snx\x00sny\x00soomsok\x00soq" +
+ "\x00sou\x00soy\x00spd\x00spl\x00sps\x00sqqisrrpsrb\x00srn\x00srr\x00srx" +
+ "\x00ssswssd\x00ssg\x00ssy\x00stotstk\x00stq\x00suunsua\x00sue\x00suk\x00" +
+ "sur\x00sus\x00svweswwaswb\x00swc\x00swg\x00swp\x00swv\x00sxn\x00sxw\x00s" +
+ "yl\x00syr\x00szl\x00taamtaj\x00tal\x00tan\x00taq\x00tbc\x00tbd\x00tbf" +
+ "\x00tbg\x00tbo\x00tbw\x00tbz\x00tci\x00tcy\x00tdd\x00tdg\x00tdh\x00teelt" +
+ "ed\x00tem\x00teo\x00tet\x00tfi\x00tggktgc\x00tgo\x00tgu\x00thhathl\x00th" +
+ "q\x00thr\x00tiirtif\x00tig\x00tik\x00tim\x00tio\x00tiv\x00tkuktkl\x00tkr" +
+ "\x00tkt\x00tlgltlf\x00tlx\x00tly\x00tmh\x00tmy\x00tnsntnh\x00toontof\x00" +
+ "tog\x00toq\x00tpi\x00tpm\x00tpz\x00tqo\x00trurtru\x00trv\x00trw\x00tssot" +
+ "sd\x00tsf\x00tsg\x00tsj\x00tsw\x00ttatttd\x00tte\x00ttj\x00ttr\x00tts" +
+ "\x00ttt\x00tuh\x00tul\x00tum\x00tuq\x00tvd\x00tvl\x00tvu\x00twwitwh\x00t" +
+ "wq\x00txg\x00tyahtya\x00tyv\x00tzm\x00ubu\x00udm\x00ugiguga\x00ukkruli" +
+ "\x00umb\x00und\x00unr\x00unx\x00urrduri\x00urt\x00urw\x00usa\x00utr\x00u" +
+ "vh\x00uvl\x00uzzbvag\x00vai\x00van\x00veenvec\x00vep\x00viievic\x00viv" +
+ "\x00vls\x00vmf\x00vmw\x00voolvot\x00vro\x00vun\x00vut\x00walnwae\x00waj" +
+ "\x00wal\x00wan\x00war\x00wbp\x00wbq\x00wbr\x00wci\x00wer\x00wgi\x00whg" +
+ "\x00wib\x00wiu\x00wiv\x00wja\x00wji\x00wls\x00wmo\x00wnc\x00wni\x00wnu" +
+ "\x00woolwob\x00wos\x00wrs\x00wsk\x00wtm\x00wuu\x00wuv\x00wwa\x00xav\x00x" +
+ "bi\x00xcr\x00xes\x00xhhoxla\x00xlc\x00xld\x00xmf\x00xmn\x00xmr\x00xna" +
+ "\x00xnr\x00xog\x00xon\x00xpr\x00xrb\x00xsa\x00xsi\x00xsm\x00xsr\x00xwe" +
+ "\x00yam\x00yao\x00yap\x00yas\x00yat\x00yav\x00yay\x00yaz\x00yba\x00ybb" +
+ "\x00yby\x00yer\x00ygr\x00ygw\x00yiidyko\x00yle\x00ylg\x00yll\x00yml\x00y" +
+ "ooryon\x00yrb\x00yre\x00yrl\x00yss\x00yua\x00yue\x00yuj\x00yut\x00yuw" +
+ "\x00zahazag\x00zbl\x00zdj\x00zea\x00zgh\x00zhhozhx\x00zia\x00zlm\x00zmi" +
+ "\x00zne\x00zuulzxx\x00zza\x00\xff\xff\xff\xff"
+
+const langNoIndexOffset = 1330
+
+// langNoIndex is a bit vector of all 3-letter language codes that are not used as an index
+// in lookup tables. The language ids for these language codes are derived directly
+// from the letters and are not consecutive.
+// Size: 2197 bytes, 2197 elements
+var langNoIndex = [2197]uint8{
+ // Entry 0 - 3F
+ 0xff, 0xf8, 0xed, 0xfe, 0xeb, 0xd3, 0x3b, 0xd2,
+ 0xfb, 0xbf, 0x7a, 0xfa, 0x37, 0x1d, 0x3c, 0x57,
+ 0x6e, 0x97, 0x73, 0x38, 0xfb, 0xea, 0xbf, 0x70,
+ 0xad, 0x03, 0xff, 0xff, 0xcf, 0x05, 0x84, 0x62,
+ 0xe9, 0xbf, 0xfd, 0xbf, 0xbf, 0xf7, 0xfd, 0x77,
+ 0x0f, 0xff, 0xef, 0x6f, 0xff, 0xfb, 0xdf, 0xe2,
+ 0xc9, 0xf8, 0x7f, 0x7e, 0x4d, 0xbc, 0x0a, 0x6a,
+ 0x7c, 0xea, 0xe3, 0xfa, 0x7a, 0xbf, 0x67, 0xff,
+ // Entry 40 - 7F
+ 0xff, 0xff, 0xff, 0xdf, 0x2a, 0x54, 0x91, 0xc0,
+ 0x5d, 0xe3, 0x97, 0x14, 0x07, 0x20, 0xdd, 0xed,
+ 0x9f, 0x3f, 0xc9, 0x21, 0xf8, 0x3f, 0x94, 0x35,
+ 0x7c, 0x5f, 0xff, 0x5f, 0x8e, 0x6e, 0xdf, 0xff,
+ 0xff, 0xff, 0x55, 0x7c, 0xd3, 0xfd, 0xbf, 0xb5,
+ 0x7b, 0xdf, 0x7f, 0xf7, 0xca, 0xfe, 0xdb, 0xa3,
+ 0xa8, 0xff, 0x1f, 0x67, 0x7d, 0xeb, 0xef, 0xce,
+ 0xff, 0xff, 0x9f, 0xff, 0xb7, 0xef, 0xfe, 0xcf,
+ // Entry 80 - BF
+ 0xdb, 0xff, 0xf3, 0xcd, 0xfb, 0x6f, 0xff, 0xff,
+ 0xbb, 0xee, 0xf7, 0xbd, 0xdb, 0xff, 0x5f, 0xf7,
+ 0xfd, 0xf2, 0xfd, 0xff, 0x5e, 0x2f, 0x3b, 0xba,
+ 0x7e, 0xff, 0xff, 0xfe, 0xf7, 0xff, 0xdd, 0xff,
+ 0xfd, 0xdf, 0xfb, 0xfe, 0x9d, 0xb4, 0xd3, 0xff,
+ 0xef, 0xff, 0xdf, 0xf7, 0x7f, 0xb7, 0xfd, 0xd5,
+ 0xa5, 0x77, 0x40, 0xff, 0x9c, 0xc1, 0x41, 0x2c,
+ 0x08, 0x21, 0x41, 0x00, 0x50, 0x40, 0x00, 0x80,
+ // Entry C0 - FF
+ 0xfb, 0x4a, 0xf2, 0x9f, 0xb4, 0x42, 0x41, 0x96,
+ 0x1b, 0x14, 0x08, 0xf3, 0x2b, 0xe7, 0x17, 0x56,
+ 0x05, 0x7d, 0x0e, 0x1c, 0x37, 0x7b, 0xf3, 0xef,
+ 0x97, 0xff, 0x5d, 0x38, 0x64, 0x08, 0x00, 0x10,
+ 0xbc, 0x85, 0xaf, 0xdf, 0xff, 0xff, 0x7b, 0x35,
+ 0x3e, 0xc7, 0xc7, 0xdf, 0xff, 0x01, 0x81, 0x00,
+ 0xb0, 0x05, 0x80, 0x00, 0x00, 0x00, 0x00, 0x03,
+ 0x40, 0x00, 0x40, 0x92, 0x21, 0x50, 0xb1, 0x5d,
+ // Entry 100 - 13F
+ 0xfd, 0xdc, 0xbe, 0x5e, 0x00, 0x00, 0x02, 0x64,
+ 0x0d, 0x19, 0x41, 0xdf, 0x79, 0x22, 0x00, 0x00,
+ 0x00, 0x5e, 0x64, 0xdc, 0x24, 0xe5, 0xd9, 0xe3,
+ 0xfe, 0xff, 0xfd, 0xcb, 0x9f, 0x14, 0x41, 0x0c,
+ 0x86, 0x00, 0xd1, 0x00, 0xf0, 0xc7, 0x67, 0x5f,
+ 0x56, 0x99, 0x5e, 0xb5, 0x6c, 0xaf, 0x03, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0xc0, 0x37, 0xda, 0x56,
+ 0x90, 0x69, 0x01, 0x2c, 0x96, 0x69, 0x20, 0xfb,
+ // Entry 140 - 17F
+ 0xff, 0x3f, 0x00, 0x00, 0x00, 0x01, 0x0c, 0x16,
+ 0x03, 0x00, 0x00, 0xb0, 0x14, 0x03, 0x50, 0x06,
+ 0x0a, 0x00, 0x01, 0x00, 0x00, 0x10, 0x11, 0x09,
+ 0x00, 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x10,
+ 0x00, 0x00, 0x44, 0x00, 0x00, 0x10, 0x00, 0x04,
+ 0x08, 0x00, 0x00, 0x05, 0x00, 0x80, 0x28, 0x04,
+ 0x00, 0x00, 0x40, 0xd5, 0x2d, 0x00, 0x64, 0x35,
+ 0x24, 0x52, 0xf4, 0xd5, 0xbf, 0x62, 0xc9, 0x03,
+ // Entry 180 - 1BF
+ 0x00, 0x80, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x04, 0x13, 0x39, 0x01, 0xdd, 0x57, 0x98,
+ 0x21, 0x18, 0x81, 0x00, 0x00, 0x01, 0x40, 0x82,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x40, 0x00, 0x44, 0x00, 0x00, 0x80, 0xea,
+ 0xa9, 0x39, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ // Entry 1C0 - 1FF
+ 0x00, 0x03, 0x28, 0x05, 0x00, 0x00, 0x00, 0x00,
+ 0x04, 0x20, 0x04, 0xa6, 0x00, 0x04, 0x00, 0x00,
+ 0x81, 0x50, 0x00, 0x00, 0x00, 0x11, 0x84, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x55,
+ 0x02, 0x10, 0x08, 0x04, 0x00, 0x00, 0x00, 0x40,
+ 0x30, 0x83, 0x01, 0x00, 0x00, 0x00, 0x11, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x1e, 0xcd, 0xbf, 0x7a, 0xbf,
+ // Entry 200 - 23F
+ 0xdf, 0xc3, 0x83, 0x82, 0xc0, 0xfb, 0x57, 0x27,
+ 0xed, 0x55, 0xe7, 0x01, 0x00, 0x20, 0xb2, 0xc5,
+ 0xa4, 0x45, 0x25, 0x9b, 0x02, 0xdf, 0xe1, 0xdf,
+ 0x03, 0x44, 0x08, 0x90, 0x01, 0x04, 0x81, 0xe3,
+ 0x92, 0x54, 0xdb, 0x28, 0xd3, 0x5f, 0xfe, 0x6d,
+ 0x79, 0xed, 0x1c, 0x7d, 0x04, 0x08, 0x00, 0x01,
+ 0x21, 0x12, 0x64, 0x5f, 0xdd, 0x0e, 0x85, 0x4f,
+ 0x40, 0x40, 0x00, 0x04, 0xf1, 0xfd, 0x3d, 0x54,
+ // Entry 240 - 27F
+ 0xe8, 0x03, 0xb4, 0x27, 0x23, 0x0d, 0x00, 0x00,
+ 0x20, 0x7b, 0x78, 0x02, 0x07, 0x84, 0x00, 0xf0,
+ 0xbb, 0x7e, 0x5a, 0x00, 0x18, 0x04, 0x81, 0x00,
+ 0x00, 0x00, 0x80, 0x10, 0x90, 0x1c, 0x01, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x10, 0x40, 0x00, 0x04,
+ 0x08, 0xa0, 0x70, 0xa5, 0x0c, 0x40, 0x00, 0x00,
+ 0x91, 0x24, 0x04, 0x68, 0x00, 0x20, 0x70, 0xff,
+ 0x7b, 0x7f, 0x70, 0x00, 0x05, 0x9b, 0xdd, 0x66,
+ // Entry 280 - 2BF
+ 0x03, 0x00, 0x11, 0x00, 0x00, 0x00, 0x40, 0x05,
+ 0xb5, 0xb6, 0x80, 0x08, 0x04, 0x00, 0x04, 0x51,
+ 0xe2, 0xef, 0xfd, 0x3f, 0x05, 0x09, 0x08, 0x05,
+ 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
+ 0x0c, 0x00, 0x00, 0x00, 0x00, 0x81, 0x00, 0x60,
+ 0xe7, 0x48, 0x00, 0x81, 0x20, 0xc0, 0x05, 0x80,
+ 0x03, 0x00, 0x00, 0x00, 0x8c, 0x50, 0x40, 0x04,
+ 0x84, 0x47, 0x84, 0x40, 0x20, 0x10, 0x00, 0x20,
+ // Entry 2C0 - 2FF
+ 0x02, 0x50, 0x80, 0x11, 0x00, 0x91, 0x6c, 0xe2,
+ 0x50, 0x27, 0x1d, 0x11, 0x29, 0x06, 0x59, 0xe9,
+ 0x33, 0x08, 0x00, 0x20, 0x04, 0x40, 0x10, 0x00,
+ 0x00, 0x00, 0x50, 0x44, 0x92, 0x49, 0xd6, 0x5d,
+ 0xa7, 0x81, 0x47, 0x97, 0xfb, 0x00, 0x10, 0x00,
+ 0x08, 0x00, 0x80, 0x00, 0x40, 0x04, 0x00, 0x01,
+ 0x02, 0x00, 0x01, 0x40, 0x80, 0x00, 0x00, 0x08,
+ 0xd8, 0xeb, 0xf6, 0x39, 0xc4, 0x8d, 0x12, 0x00,
+ // Entry 300 - 33F
+ 0x00, 0x0c, 0x04, 0x01, 0x20, 0x20, 0xdd, 0xa0,
+ 0x01, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00,
+ 0x04, 0x10, 0xd0, 0x9d, 0x95, 0x13, 0x04, 0x80,
+ 0x00, 0x01, 0xd0, 0x16, 0x40, 0x00, 0x10, 0xb0,
+ 0x10, 0x62, 0x4c, 0xd2, 0x02, 0x01, 0x4a, 0x00,
+ 0x46, 0x04, 0x00, 0x08, 0x02, 0x00, 0x20, 0x80,
+ 0x00, 0x80, 0x06, 0x00, 0x08, 0x00, 0x00, 0x00,
+ 0x00, 0xf0, 0xd8, 0x6f, 0x15, 0x02, 0x08, 0x00,
+ // Entry 340 - 37F
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x10, 0x01,
+ 0x00, 0x10, 0x00, 0x00, 0x00, 0xf0, 0x84, 0xe3,
+ 0xdd, 0xbf, 0xf9, 0xf9, 0x3b, 0x7f, 0x7f, 0xdb,
+ 0xfd, 0xfc, 0xfe, 0xdf, 0xff, 0xfd, 0xff, 0xf6,
+ 0xfb, 0xfc, 0xf7, 0x1f, 0xff, 0xb3, 0x6c, 0xff,
+ 0xd9, 0xad, 0xdf, 0xfe, 0xef, 0xba, 0xdf, 0xff,
+ 0xff, 0xff, 0xb7, 0xdd, 0x7d, 0xbf, 0xab, 0x7f,
+ 0xfd, 0xfd, 0xdf, 0x2f, 0x9c, 0xdf, 0xf3, 0x6f,
+ // Entry 380 - 3BF
+ 0xdf, 0xdd, 0xff, 0xfb, 0xee, 0xd2, 0xab, 0x5f,
+ 0xd5, 0xdf, 0x7f, 0xff, 0xeb, 0xff, 0xe4, 0x4d,
+ 0xf9, 0xff, 0xfe, 0xf7, 0xfd, 0xdf, 0xfb, 0xbf,
+ 0xee, 0xdb, 0x6f, 0xef, 0xff, 0x7f, 0xff, 0xff,
+ 0xf7, 0x5f, 0xd3, 0x3b, 0xfd, 0xd9, 0xdf, 0xeb,
+ 0xbc, 0x08, 0x05, 0x24, 0xff, 0x07, 0x70, 0xfe,
+ 0xe6, 0x5e, 0x00, 0x08, 0x00, 0x83, 0x3d, 0x1b,
+ 0x06, 0xe6, 0x72, 0x60, 0xd1, 0x3c, 0x7f, 0x44,
+ // Entry 3C0 - 3FF
+ 0x02, 0x30, 0x9f, 0x7a, 0x16, 0xbd, 0x7f, 0x57,
+ 0xf2, 0xff, 0x31, 0xff, 0xf2, 0x1e, 0x90, 0xf7,
+ 0xf1, 0xf9, 0x45, 0x80, 0x01, 0x02, 0x00, 0x00,
+ 0x40, 0x54, 0x9f, 0x8a, 0xdb, 0xf9, 0x2e, 0x11,
+ 0x86, 0x51, 0xc0, 0xf3, 0xfb, 0x47, 0x40, 0x01,
+ 0x05, 0xd1, 0x50, 0x5c, 0x00, 0x40, 0x00, 0x10,
+ 0x04, 0x02, 0x00, 0x00, 0x0a, 0x00, 0x17, 0xd2,
+ 0xb9, 0xfd, 0xfc, 0xba, 0xfe, 0xef, 0xc7, 0xbe,
+ // Entry 400 - 43F
+ 0x53, 0x6f, 0xdf, 0xe7, 0xdb, 0x65, 0xbb, 0x7f,
+ 0xfa, 0xff, 0x77, 0xf3, 0xef, 0xbf, 0xfd, 0xf7,
+ 0xdf, 0xdf, 0x9b, 0x7f, 0xff, 0xff, 0x7f, 0x6f,
+ 0xf7, 0xfb, 0xeb, 0xdf, 0xbc, 0xff, 0xbf, 0x6b,
+ 0x7b, 0xfb, 0xff, 0xce, 0x76, 0xbd, 0xf7, 0xf7,
+ 0xdf, 0xdc, 0xf7, 0xf7, 0xff, 0xdf, 0xf3, 0xfe,
+ 0xef, 0xff, 0xff, 0xff, 0xb6, 0x7f, 0x7f, 0xde,
+ 0xf7, 0xb9, 0xeb, 0x77, 0xff, 0xfb, 0xbf, 0xdf,
+ // Entry 440 - 47F
+ 0xfd, 0xfe, 0xfb, 0xff, 0xfe, 0xeb, 0x1f, 0x7d,
+ 0x2f, 0xfd, 0xb6, 0xb5, 0xa5, 0xfc, 0xff, 0xfd,
+ 0x7f, 0x4e, 0xbf, 0x8f, 0xae, 0xff, 0xee, 0xdf,
+ 0x7f, 0xf7, 0x73, 0x02, 0x02, 0x04, 0xfc, 0xf7,
+ 0xff, 0xb7, 0xd7, 0xef, 0xfe, 0xcd, 0xf5, 0xce,
+ 0xe2, 0x8e, 0xe7, 0xbf, 0xb7, 0xff, 0x56, 0xfd,
+ 0xcd, 0xff, 0xfb, 0xff, 0xdf, 0xd7, 0xea, 0xff,
+ 0xe5, 0x5f, 0x6d, 0x0f, 0xa7, 0x51, 0x06, 0xc4,
+ // Entry 480 - 4BF
+ 0x93, 0x50, 0x5d, 0xaf, 0xa6, 0xff, 0x99, 0xfb,
+ 0x63, 0x1d, 0x53, 0xff, 0xef, 0xb7, 0x35, 0x20,
+ 0x14, 0x00, 0x55, 0x51, 0x82, 0x65, 0xf5, 0x41,
+ 0xe2, 0xff, 0xfc, 0xdf, 0x02, 0x05, 0xc5, 0x05,
+ 0x00, 0x22, 0x00, 0x74, 0x69, 0x10, 0x08, 0x05,
+ 0x41, 0x00, 0x01, 0x06, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x51, 0x20, 0x05, 0x04, 0x01, 0x00, 0x00,
+ 0x06, 0x01, 0x20, 0x00, 0x18, 0x01, 0x92, 0xf1,
+ // Entry 4C0 - 4FF
+ 0xfd, 0x47, 0x69, 0x06, 0x95, 0x06, 0x57, 0xed,
+ 0xfb, 0x4d, 0x1c, 0x6b, 0x83, 0x04, 0x62, 0x40,
+ 0x00, 0x11, 0x42, 0x00, 0x00, 0x00, 0x54, 0x83,
+ 0xb8, 0x4f, 0x10, 0x8e, 0x89, 0x46, 0xde, 0xf7,
+ 0x13, 0x31, 0x00, 0x20, 0x00, 0x00, 0x00, 0x90,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x10, 0x00,
+ 0x01, 0x00, 0x00, 0xf0, 0x5b, 0xf4, 0xbe, 0x3d,
+ 0xbe, 0xcf, 0xf7, 0xaf, 0x42, 0x04, 0x84, 0x41,
+ // Entry 500 - 53F
+ 0x30, 0xff, 0x79, 0x72, 0x04, 0x00, 0x00, 0x49,
+ 0x2d, 0x14, 0x27, 0x57, 0xed, 0xf1, 0x3f, 0xe7,
+ 0x3f, 0x00, 0x00, 0x02, 0xc6, 0xa0, 0x1e, 0xf8,
+ 0xbb, 0xff, 0xfd, 0xfb, 0xb7, 0xfd, 0xe7, 0xf7,
+ 0xfd, 0xfc, 0xd5, 0xed, 0x47, 0xf4, 0x7e, 0x10,
+ 0x01, 0x01, 0x84, 0x6d, 0xff, 0xf7, 0xdd, 0xf9,
+ 0x5b, 0x05, 0x86, 0xed, 0xf5, 0x77, 0xbd, 0x3c,
+ 0x00, 0x00, 0x00, 0x42, 0x71, 0x42, 0x00, 0x40,
+ // Entry 540 - 57F
+ 0x00, 0x00, 0x01, 0x43, 0x19, 0x00, 0x08, 0x00,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ // Entry 580 - 5BF
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xab, 0xbd, 0xe7, 0x57, 0xee, 0x13, 0x5d,
+ 0x09, 0xc1, 0x40, 0x21, 0xfa, 0x17, 0x01, 0x80,
+ 0x00, 0x00, 0x00, 0x00, 0xf0, 0xce, 0xfb, 0xbf,
+ 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00,
+ 0x00, 0x30, 0x15, 0xa3, 0x10, 0x00, 0x00, 0x00,
+ 0x11, 0x04, 0x16, 0x00, 0x00, 0x02, 0x00, 0x81,
+ 0xa3, 0x01, 0x50, 0x00, 0x00, 0x83, 0x11, 0x40,
+ // Entry 5C0 - 5FF
+ 0x00, 0x00, 0x00, 0xf0, 0xdd, 0x7b, 0x3e, 0x02,
+ 0xaa, 0x10, 0x5d, 0x98, 0x52, 0x00, 0x80, 0x20,
+ 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x02, 0x02,
+ 0x19, 0x00, 0x10, 0x02, 0x10, 0x61, 0x5a, 0x9d,
+ 0x31, 0x00, 0x00, 0x00, 0x01, 0x18, 0x02, 0x20,
+ 0x00, 0x00, 0x01, 0x00, 0x42, 0x00, 0x20, 0x00,
+ 0x00, 0x1f, 0xdf, 0xd2, 0xb9, 0xff, 0xfd, 0x3f,
+ 0x1f, 0x98, 0xcf, 0x9c, 0xff, 0xaf, 0x5f, 0xfe,
+ // Entry 600 - 63F
+ 0x7b, 0x4b, 0x40, 0x10, 0xe1, 0xfd, 0xaf, 0xd9,
+ 0xb7, 0xf6, 0xfb, 0xb3, 0xc7, 0xff, 0x6f, 0xf1,
+ 0x73, 0xb1, 0x7f, 0x9f, 0x7f, 0xbd, 0xfc, 0xb7,
+ 0xee, 0x1c, 0xfa, 0xcb, 0xef, 0xdd, 0xf9, 0xbd,
+ 0x6e, 0xae, 0x55, 0xfd, 0x6e, 0x81, 0x76, 0x9f,
+ 0xd4, 0x77, 0xf5, 0x7d, 0xfb, 0xff, 0xeb, 0xfe,
+ 0xbe, 0x5f, 0x46, 0x5b, 0xe9, 0x5f, 0x50, 0x18,
+ 0x02, 0xfa, 0xf7, 0x9d, 0x15, 0x97, 0x05, 0x0f,
+ // Entry 640 - 67F
+ 0x75, 0xc4, 0x7d, 0x81, 0x92, 0xf5, 0x57, 0x6c,
+ 0xff, 0xe4, 0xef, 0x6f, 0xff, 0xfc, 0xdd, 0xde,
+ 0xfc, 0xfd, 0x76, 0x5f, 0x7a, 0x3f, 0x00, 0x98,
+ 0x02, 0xfb, 0xa3, 0xef, 0xf3, 0xd6, 0xf2, 0xff,
+ 0xb9, 0xda, 0x7d, 0xd0, 0x3e, 0x15, 0x7b, 0xb4,
+ 0xf5, 0x3e, 0xff, 0xff, 0xf1, 0xf7, 0xff, 0xe7,
+ 0x5f, 0xff, 0xff, 0x9e, 0xdb, 0xf6, 0xd7, 0xb9,
+ 0xef, 0x27, 0x80, 0xbb, 0xc5, 0xff, 0xff, 0xe3,
+ // Entry 680 - 6BF
+ 0x97, 0x9d, 0xbf, 0x9f, 0xf7, 0xc7, 0xfd, 0x37,
+ 0xce, 0x7f, 0x04, 0x1d, 0x73, 0x7f, 0xf8, 0xda,
+ 0x5d, 0xce, 0x7d, 0x06, 0xb9, 0xea, 0x79, 0xa0,
+ 0x1a, 0x20, 0x00, 0x30, 0x02, 0x04, 0x24, 0x08,
+ 0x04, 0x00, 0x00, 0x40, 0xd4, 0x02, 0x04, 0x00,
+ 0x00, 0x04, 0x00, 0x04, 0x00, 0x20, 0x01, 0x06,
+ 0x50, 0x00, 0x08, 0x00, 0x00, 0x00, 0x24, 0x00,
+ 0x04, 0x00, 0x10, 0xdc, 0x58, 0xd7, 0x0d, 0x0f,
+ // Entry 6C0 - 6FF
+ 0x14, 0x4d, 0xf1, 0x16, 0x44, 0xd5, 0x42, 0x08,
+ 0x40, 0x00, 0x00, 0x40, 0x00, 0x08, 0x00, 0x00,
+ 0x00, 0xdc, 0xfb, 0xcb, 0x0e, 0x58, 0x48, 0x41,
+ 0x24, 0x20, 0x04, 0x00, 0x30, 0x12, 0x40, 0x00,
+ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x80, 0x10, 0x10, 0xab,
+ 0x6d, 0x93, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x80, 0x80, 0x25, 0x00, 0x00,
+ // Entry 700 - 73F
+ 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00,
+ 0x80, 0x86, 0xc2, 0x00, 0x00, 0x00, 0x00, 0x01,
+ 0xff, 0x18, 0x02, 0x00, 0x02, 0xf0, 0xfd, 0x79,
+ 0x3b, 0x00, 0x25, 0x00, 0x00, 0x00, 0x02, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00,
+ 0x03, 0x00, 0x09, 0x20, 0x00, 0x00, 0x01, 0x00,
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Entry 740 - 77F
+ 0x00, 0x00, 0x00, 0xef, 0xd5, 0xfd, 0xcf, 0x7e,
+ 0xb0, 0x11, 0x00, 0x00, 0x00, 0x92, 0x01, 0x44,
+ 0xcd, 0xf9, 0x5c, 0x00, 0x01, 0x00, 0x30, 0x04,
+ 0x04, 0x55, 0x00, 0x01, 0x04, 0xf4, 0x3f, 0x4a,
+ 0x01, 0x00, 0x00, 0xb0, 0x80, 0x20, 0x55, 0x75,
+ 0x97, 0x7c, 0xdf, 0x31, 0xcc, 0x68, 0xd1, 0x03,
+ 0xd5, 0x57, 0x27, 0x14, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x2c, 0xf7, 0xcb, 0x1f, 0x14, 0x60,
+ // Entry 780 - 7BF
+ 0x03, 0x68, 0x01, 0x10, 0x8b, 0x38, 0x8a, 0x01,
+ 0x00, 0x00, 0x20, 0x00, 0x24, 0x44, 0x00, 0x00,
+ 0x10, 0x03, 0x11, 0x02, 0x01, 0x00, 0x00, 0xf0,
+ 0xf5, 0xff, 0xd5, 0x97, 0xbc, 0x70, 0xd6, 0x78,
+ 0x78, 0x15, 0x50, 0x01, 0xa4, 0x84, 0xa9, 0x41,
+ 0x00, 0x00, 0x00, 0x6b, 0x39, 0x52, 0x74, 0x00,
+ 0xe8, 0x30, 0x90, 0x6a, 0x92, 0x00, 0x00, 0x02,
+ 0xff, 0xef, 0xff, 0x4b, 0x85, 0x53, 0xf4, 0xed,
+ // Entry 7C0 - 7FF
+ 0xdd, 0xbf, 0xf2, 0x5d, 0xc7, 0x0c, 0xd5, 0x42,
+ 0xfc, 0xff, 0xf7, 0x1f, 0x00, 0x80, 0x40, 0x56,
+ 0xcc, 0x16, 0x9e, 0xea, 0x35, 0x7d, 0xef, 0xff,
+ 0xbd, 0xa4, 0xaf, 0x01, 0x44, 0x18, 0x01, 0x4d,
+ 0x4e, 0x4a, 0x08, 0x50, 0x28, 0x30, 0xe0, 0x80,
+ 0x10, 0x20, 0x24, 0x00, 0xff, 0x2f, 0xd3, 0x60,
+ 0xfe, 0x01, 0x02, 0x88, 0x0a, 0x40, 0x16, 0x01,
+ 0x01, 0x15, 0x2b, 0x3c, 0x01, 0x00, 0x00, 0x10,
+ // Entry 800 - 83F
+ 0x90, 0x49, 0x41, 0x02, 0x02, 0x01, 0xe1, 0xbf,
+ 0xbf, 0x03, 0x00, 0x00, 0x10, 0xd4, 0xa3, 0xd1,
+ 0x40, 0x9c, 0x44, 0xdf, 0xf5, 0x8f, 0x66, 0xb3,
+ 0x55, 0x20, 0xd4, 0xc1, 0xd8, 0x30, 0x3d, 0x80,
+ 0x00, 0x00, 0x00, 0x04, 0xd4, 0x11, 0xc5, 0x84,
+ 0x2f, 0x50, 0x00, 0x22, 0x50, 0x6e, 0xbd, 0x93,
+ 0x07, 0x00, 0x20, 0x10, 0x84, 0xb2, 0x45, 0x10,
+ 0x06, 0x44, 0x00, 0x00, 0x12, 0x02, 0x11, 0x00,
+ // Entry 840 - 87F
+ 0xf0, 0xfb, 0xfd, 0x7f, 0x05, 0x00, 0x16, 0x81,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x02,
+ 0x00, 0x00, 0x00, 0x00, 0x03, 0x30, 0x02, 0x28,
+ 0x84, 0x00, 0x21, 0xc0, 0x23, 0x24, 0x00, 0x00,
+ 0x00, 0xcb, 0xe4, 0x3a, 0x46, 0x88, 0x14, 0xf1,
+ 0xef, 0xff, 0x7f, 0x12, 0x01, 0x01, 0x84, 0x50,
+ 0x07, 0xfc, 0xff, 0xff, 0x0f, 0x01, 0x00, 0x40,
+ 0x10, 0x38, 0x01, 0x01, 0x1c, 0x12, 0x40, 0xe1,
+ // Entry 880 - 8BF
+ 0x76, 0x16, 0x08, 0x03, 0x10, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x24,
+ 0x0a, 0x00, 0x80, 0x00, 0x00,
+}
+
+// altLangISO3 holds an alphabetically sorted list of 3-letter language code alternatives
+// to 2-letter language codes that cannot be derived using the method described above.
+// Each 3-letter code is followed by its 1-byte langID.
+const altLangISO3 tag.Index = "---\x00cor\x00hbs\x01heb\x02kin\x03spa\x04yid\x05\xff\xff\xff\xff"
+
+// altLangIndex is used to convert indexes in altLangISO3 to langIDs.
+// Size: 12 bytes, 6 elements
+var altLangIndex = [6]uint16{
+ 0x0281, 0x0407, 0x01fb, 0x03e5, 0x013e, 0x0208,
+}
+
+// AliasMap maps langIDs to their suggested replacements.
+// Size: 716 bytes, 179 elements
+var AliasMap = [179]FromTo{
+ 0: {From: 0x82, To: 0x88},
+ 1: {From: 0x187, To: 0x1ae},
+ 2: {From: 0x1f3, To: 0x1e1},
+ 3: {From: 0x1fb, To: 0x1bc},
+ 4: {From: 0x208, To: 0x512},
+ 5: {From: 0x20f, To: 0x20e},
+ 6: {From: 0x310, To: 0x3dc},
+ 7: {From: 0x347, To: 0x36f},
+ 8: {From: 0x407, To: 0x432},
+ 9: {From: 0x47a, To: 0x153},
+ 10: {From: 0x490, To: 0x451},
+ 11: {From: 0x4a2, To: 0x21},
+ 12: {From: 0x53e, To: 0x544},
+ 13: {From: 0x58f, To: 0x12d},
+ 14: {From: 0x630, To: 0x1eb1},
+ 15: {From: 0x651, To: 0x431},
+ 16: {From: 0x662, To: 0x431},
+ 17: {From: 0x6ed, To: 0x3a},
+ 18: {From: 0x6f8, To: 0x1d7},
+ 19: {From: 0x709, To: 0x3625},
+ 20: {From: 0x73e, To: 0x21a1},
+ 21: {From: 0x7b3, To: 0x56},
+ 22: {From: 0x7b9, To: 0x299b},
+ 23: {From: 0x7c5, To: 0x58},
+ 24: {From: 0x7e6, To: 0x145},
+ 25: {From: 0x80c, To: 0x5a},
+ 26: {From: 0x815, To: 0x8d},
+ 27: {From: 0x87e, To: 0x810},
+ 28: {From: 0x8a8, To: 0x8b7},
+ 29: {From: 0x8c3, To: 0xee3},
+ 30: {From: 0x8fa, To: 0x1dc},
+ 31: {From: 0x9ef, To: 0x331},
+ 32: {From: 0xa36, To: 0x2c5},
+ 33: {From: 0xa3d, To: 0xbf},
+ 34: {From: 0xabe, To: 0x3322},
+ 35: {From: 0xb38, To: 0x529},
+ 36: {From: 0xb75, To: 0x265a},
+ 37: {From: 0xb7e, To: 0xbc3},
+ 38: {From: 0xb9b, To: 0x44e},
+ 39: {From: 0xbbc, To: 0x4229},
+ 40: {From: 0xbbf, To: 0x529},
+ 41: {From: 0xbfe, To: 0x2da7},
+ 42: {From: 0xc2e, To: 0x3181},
+ 43: {From: 0xcb9, To: 0xf3},
+ 44: {From: 0xd08, To: 0xfa},
+ 45: {From: 0xdc8, To: 0x11a},
+ 46: {From: 0xdd7, To: 0x32d},
+ 47: {From: 0xdf8, To: 0xdfb},
+ 48: {From: 0xdfe, To: 0x531},
+ 49: {From: 0xe01, To: 0xdf3},
+ 50: {From: 0xedf, To: 0x205a},
+ 51: {From: 0xee9, To: 0x222e},
+ 52: {From: 0xeee, To: 0x2e9a},
+ 53: {From: 0xf39, To: 0x367},
+ 54: {From: 0x10d0, To: 0x140},
+ 55: {From: 0x1104, To: 0x2d0},
+ 56: {From: 0x11a0, To: 0x1ec},
+ 57: {From: 0x1279, To: 0x21},
+ 58: {From: 0x1424, To: 0x15e},
+ 59: {From: 0x1470, To: 0x14e},
+ 60: {From: 0x151f, To: 0xd9b},
+ 61: {From: 0x1523, To: 0x390},
+ 62: {From: 0x1532, To: 0x19f},
+ 63: {From: 0x1580, To: 0x210},
+ 64: {From: 0x1583, To: 0x10d},
+ 65: {From: 0x15a3, To: 0x3caf},
+ 66: {From: 0x1630, To: 0x222e},
+ 67: {From: 0x166a, To: 0x19b},
+ 68: {From: 0x16c8, To: 0x136},
+ 69: {From: 0x1700, To: 0x29f8},
+ 70: {From: 0x1718, To: 0x194},
+ 71: {From: 0x1727, To: 0xf3f},
+ 72: {From: 0x177a, To: 0x178},
+ 73: {From: 0x1809, To: 0x17b6},
+ 74: {From: 0x1816, To: 0x18f3},
+ 75: {From: 0x188a, To: 0x436},
+ 76: {From: 0x1979, To: 0x1d01},
+ 77: {From: 0x1a74, To: 0x2bb0},
+ 78: {From: 0x1a8a, To: 0x1f8},
+ 79: {From: 0x1b5a, To: 0x1fa},
+ 80: {From: 0x1b86, To: 0x1515},
+ 81: {From: 0x1d64, To: 0x2c9b},
+ 82: {From: 0x2038, To: 0x37b1},
+ 83: {From: 0x203d, To: 0x20dd},
+ 84: {From: 0x205a, To: 0x30b},
+ 85: {From: 0x20e3, To: 0x274},
+ 86: {From: 0x20ee, To: 0x263},
+ 87: {From: 0x20f2, To: 0x22d},
+ 88: {From: 0x20f9, To: 0x256},
+ 89: {From: 0x210f, To: 0x21eb},
+ 90: {From: 0x2135, To: 0x27d},
+ 91: {From: 0x2160, To: 0x913},
+ 92: {From: 0x2199, To: 0x121},
+ 93: {From: 0x21ce, To: 0x1561},
+ 94: {From: 0x21e6, To: 0x504},
+ 95: {From: 0x21f4, To: 0x49f},
+ 96: {From: 0x21fb, To: 0x269},
+ 97: {From: 0x222d, To: 0x121},
+ 98: {From: 0x2237, To: 0x121},
+ 99: {From: 0x2262, To: 0x92a},
+ 100: {From: 0x2316, To: 0x3226},
+ 101: {From: 0x236a, To: 0x2835},
+ 102: {From: 0x2382, To: 0x3365},
+ 103: {From: 0x2472, To: 0x2c7},
+ 104: {From: 0x24e4, To: 0x2ff},
+ 105: {From: 0x24f0, To: 0x2fa},
+ 106: {From: 0x24fa, To: 0x31f},
+ 107: {From: 0x2550, To: 0xb5b},
+ 108: {From: 0x25a9, To: 0xe2},
+ 109: {From: 0x263e, To: 0x2d0},
+ 110: {From: 0x26c9, To: 0x26b4},
+ 111: {From: 0x26f9, To: 0x3c8},
+ 112: {From: 0x2727, To: 0x3caf},
+ 113: {From: 0x2755, To: 0x6a4},
+ 114: {From: 0x2765, To: 0x26b4},
+ 115: {From: 0x2789, To: 0x4358},
+ 116: {From: 0x27c9, To: 0x2001},
+ 117: {From: 0x28ea, To: 0x27b1},
+ 118: {From: 0x28ef, To: 0x2837},
+ 119: {From: 0x2914, To: 0x351},
+ 120: {From: 0x2986, To: 0x2da7},
+ 121: {From: 0x29f0, To: 0x96b},
+ 122: {From: 0x2b1a, To: 0x38d},
+ 123: {From: 0x2bfc, To: 0x395},
+ 124: {From: 0x2c3f, To: 0x3caf},
+ 125: {From: 0x2ce1, To: 0x2201},
+ 126: {From: 0x2cfc, To: 0x3be},
+ 127: {From: 0x2d13, To: 0x597},
+ 128: {From: 0x2d47, To: 0x148},
+ 129: {From: 0x2d48, To: 0x148},
+ 130: {From: 0x2dff, To: 0x2f1},
+ 131: {From: 0x2e08, To: 0x19cc},
+ 132: {From: 0x2e1a, To: 0x2d95},
+ 133: {From: 0x2e21, To: 0x292},
+ 134: {From: 0x2e54, To: 0x7d},
+ 135: {From: 0x2e65, To: 0x2282},
+ 136: {From: 0x2ea0, To: 0x2e9b},
+ 137: {From: 0x2eef, To: 0x2ed7},
+ 138: {From: 0x3193, To: 0x3c4},
+ 139: {From: 0x3366, To: 0x338e},
+ 140: {From: 0x342a, To: 0x3dc},
+ 141: {From: 0x34ee, To: 0x18d0},
+ 142: {From: 0x35c8, To: 0x2c9b},
+ 143: {From: 0x35e6, To: 0x412},
+ 144: {From: 0x3658, To: 0x246},
+ 145: {From: 0x3676, To: 0x3f4},
+ 146: {From: 0x36fd, To: 0x445},
+ 147: {From: 0x37c0, To: 0x121},
+ 148: {From: 0x3816, To: 0x38f2},
+ 149: {From: 0x382a, To: 0x2b48},
+ 150: {From: 0x382b, To: 0x2c9b},
+ 151: {From: 0x382f, To: 0xa9},
+ 152: {From: 0x3832, To: 0x3228},
+ 153: {From: 0x386c, To: 0x39a6},
+ 154: {From: 0x3892, To: 0x3fc0},
+ 155: {From: 0x38a5, To: 0x39d7},
+ 156: {From: 0x38b4, To: 0x1fa4},
+ 157: {From: 0x38b5, To: 0x2e9a},
+ 158: {From: 0x395c, To: 0x47e},
+ 159: {From: 0x3b4e, To: 0xd91},
+ 160: {From: 0x3b78, To: 0x137},
+ 161: {From: 0x3c99, To: 0x4bc},
+ 162: {From: 0x3fbd, To: 0x100},
+ 163: {From: 0x4208, To: 0xa91},
+ 164: {From: 0x42be, To: 0x573},
+ 165: {From: 0x42f9, To: 0x3f60},
+ 166: {From: 0x4378, To: 0x25a},
+ 167: {From: 0x43b8, To: 0xe6c},
+ 168: {From: 0x43cd, To: 0x10f},
+ 169: {From: 0x44af, To: 0x3322},
+ 170: {From: 0x44e3, To: 0x512},
+ 171: {From: 0x45ca, To: 0x2409},
+ 172: {From: 0x45dd, To: 0x26dc},
+ 173: {From: 0x4610, To: 0x48ae},
+ 174: {From: 0x46ae, To: 0x46a0},
+ 175: {From: 0x473e, To: 0x4745},
+ 176: {From: 0x4817, To: 0x3503},
+ 177: {From: 0x4916, To: 0x31f},
+ 178: {From: 0x49a7, To: 0x523},
+}
+
+// Size: 179 bytes, 179 elements
+var AliasTypes = [179]AliasType{
+ // Entry 0 - 3F
+ 1, 0, 0, 0, 0, 0, 0, 1, 2, 2, 0, 1, 0, 0, 1, 2,
+ 1, 1, 2, 0, 0, 1, 0, 1, 2, 1, 1, 0, 0, 0, 0, 2,
+ 1, 1, 0, 2, 0, 0, 1, 0, 1, 0, 0, 1, 2, 1, 1, 1,
+ 1, 0, 0, 0, 0, 2, 1, 1, 1, 1, 2, 1, 0, 1, 1, 2,
+ // Entry 40 - 7F
+ 2, 0, 0, 1, 2, 0, 1, 0, 1, 1, 1, 1, 0, 0, 2, 1,
+ 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0,
+ 0, 0, 0, 1, 0, 0, 0, 1, 2, 2, 2, 0, 1, 1, 0, 1,
+ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0,
+ // Entry 80 - BF
+ 2, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 2, 0, 0, 2,
+ 1, 1, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 1,
+ 0, 1, 2, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1,
+ 0, 1, 1,
+}
+
+const (
+ _Latn = 90
+ _Hani = 57
+ _Hans = 59
+ _Hant = 60
+ _Qaaa = 147
+ _Qaai = 155
+ _Qabx = 196
+ _Zinh = 252
+ _Zyyy = 257
+ _Zzzz = 258
+)
+
+// script is an alphabetically sorted list of ISO 15924 codes. The index
+// of the script in the string, divided by 4, is the internal scriptID.
+const script tag.Index = "" + // Size: 1040 bytes
+ "----AdlmAfakAghbAhomArabAranArmiArmnAvstBaliBamuBassBatkBengBhksBlisBopo" +
+ "BrahBraiBugiBuhdCakmCansCariChamCherChrsCirtCoptCpmnCprtCyrlCyrsDevaDiak" +
+ "DogrDsrtDuplEgydEgyhEgypElbaElymEthiGeokGeorGlagGongGonmGothGranGrekGujr" +
+ "GuruHanbHangHaniHanoHansHantHatrHebrHiraHluwHmngHmnpHrktHungIndsItalJamo" +
+ "JavaJpanJurcKaliKanaKharKhmrKhojKitlKitsKndaKoreKpelKthiLanaLaooLatfLatg" +
+ "LatnLekeLepcLimbLinaLinbLisuLomaLyciLydiMahjMakaMandManiMarcMayaMedfMend" +
+ "MercMeroMlymModiMongMoonMrooMteiMultMymrNandNarbNbatNewaNkdbNkgbNkooNshu" +
+ "OgamOlckOrkhOryaOsgeOsmaOugrPalmPaucPcunPelmPermPhagPhliPhlpPhlvPhnxPiqd" +
+ "PlrdPrtiPsinQaaaQaabQaacQaadQaaeQaafQaagQaahQaaiQaajQaakQaalQaamQaanQaao" +
+ "QaapQaaqQaarQaasQaatQaauQaavQaawQaaxQaayQaazQabaQabbQabcQabdQabeQabfQabg" +
+ "QabhQabiQabjQabkQablQabmQabnQaboQabpQabqQabrQabsQabtQabuQabvQabwQabxRanj" +
+ "RjngRohgRoroRunrSamrSaraSarbSaurSgnwShawShrdShuiSiddSindSinhSogdSogoSora" +
+ "SoyoSundSyloSyrcSyreSyrjSyrnTagbTakrTaleTaluTamlTangTavtTeluTengTfngTglg" +
+ "ThaaThaiTibtTirhTnsaTotoUgarVaiiVispVithWaraWchoWoleXpeoXsuxYeziYiiiZanb" +
+ "ZinhZmthZsyeZsymZxxxZyyyZzzz\xff\xff\xff\xff"
+
+// suppressScript is an index from langID to the dominant script for that language,
+// if it exists. If a script is given, it should be suppressed from the language tag.
+// Size: 1330 bytes, 1330 elements
+var suppressScript = [1330]uint8{
+ // Entry 0 - 3F
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5a, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2c,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Entry 40 - 7F
+ 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5a, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00,
+ // Entry 80 - BF
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5a,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Entry C0 - FF
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5a,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Entry 100 - 13F
+ 0x5a, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5a,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xea, 0x00, 0x00, 0x00, 0x00, 0xec, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00,
+ 0x00, 0x5a, 0x00, 0x00, 0x5a, 0x00, 0x5a, 0x00,
+ // Entry 140 - 17F
+ 0x5a, 0x00, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00,
+ 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x5a, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00,
+ 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5a, 0x00,
+ 0x00, 0x5a, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x5a, 0x5a, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Entry 180 - 1BF
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x5a, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x5a, 0x35, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x22, 0x00,
+ // Entry 1C0 - 1FF
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x5a, 0x5a, 0x00, 0x5a, 0x5a, 0x00, 0x08,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x00,
+ 0x5a, 0x5a, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00,
+ // Entry 200 - 23F
+ 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Entry 240 - 27F
+ 0x00, 0x00, 0x20, 0x00, 0x00, 0x5a, 0x00, 0x00,
+ 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x52, 0x00, 0x00, 0x53, 0x00, 0x22, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Entry 280 - 2BF
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5a, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00,
+ 0x57, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Entry 2C0 - 2FF
+ 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5a,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5a,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
+ // Entry 300 - 33F
+ 0x00, 0x00, 0x00, 0x00, 0x6e, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x5a,
+ 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x75, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5a, 0x00,
+ // Entry 340 - 37F
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5a,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5a, 0x00,
+ 0x5a, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5a,
+ 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x5a,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x5a, 0x00,
+ 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Entry 380 - 3BF
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5a,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x5a, 0x00, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00,
+ // Entry 3C0 - 3FF
+ 0x5a, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00,
+ 0x00, 0x5a, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x20, 0x00, 0x00, 0x5a, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Entry 400 - 43F
+ 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x5a, 0x00,
+ 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5a,
+ 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x00,
+ // Entry 440 - 47F
+ 0x00, 0x00, 0x00, 0x00, 0x5a, 0x5a, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xe3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xe6, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xeb, 0x00, 0x00, 0x00, 0x2c,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5a,
+ 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x5a, 0x00,
+ // Entry 480 - 4BF
+ 0x5a, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x5a, 0x00,
+ 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x5a, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Entry 4C0 - 4FF
+ 0x5a, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Entry 500 - 53F
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5a,
+ 0x00, 0x00,
+}
+
+const (
+ _001 = 1
+ _419 = 31
+ _BR = 65
+ _CA = 73
+ _ES = 110
+ _GB = 123
+ _MD = 188
+ _PT = 238
+ _UK = 306
+ _US = 309
+ _ZZ = 357
+ _XA = 323
+ _XC = 325
+ _XK = 333
+)
+
+// isoRegionOffset needs to be added to the index of regionISO to obtain the regionID
+// for 2-letter ISO codes. (The first isoRegionOffset regionIDs are reserved for
+// the UN.M49 codes used for groups.)
+const isoRegionOffset = 32
+
+// regionTypes defines the status of a region for various standards.
+// Size: 358 bytes, 358 elements
+var regionTypes = [358]uint8{
+ // Entry 0 - 3F
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+ // Entry 40 - 7F
+ 0x06, 0x06, 0x06, 0x06, 0x04, 0x06, 0x06, 0x06,
+ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+ 0x06, 0x06, 0x06, 0x06, 0x06, 0x04, 0x06, 0x04,
+ 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x04,
+ 0x06, 0x04, 0x06, 0x06, 0x06, 0x06, 0x00, 0x06,
+ 0x04, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+ 0x06, 0x04, 0x06, 0x06, 0x06, 0x06, 0x06, 0x00,
+ 0x06, 0x04, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+ // Entry 80 - BF
+ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+ 0x06, 0x06, 0x06, 0x00, 0x04, 0x06, 0x06, 0x06,
+ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+ 0x06, 0x06, 0x06, 0x00, 0x06, 0x06, 0x06, 0x06,
+ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+ // Entry C0 - FF
+ 0x06, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x00,
+ 0x06, 0x06, 0x06, 0x06, 0x00, 0x06, 0x04, 0x06,
+ 0x06, 0x06, 0x06, 0x00, 0x06, 0x06, 0x06, 0x06,
+ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x00,
+ 0x06, 0x06, 0x00, 0x06, 0x05, 0x05, 0x05, 0x05,
+ 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
+ // Entry 100 - 13F
+ 0x05, 0x05, 0x06, 0x00, 0x06, 0x06, 0x06, 0x06,
+ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x04, 0x06,
+ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+ 0x06, 0x06, 0x02, 0x06, 0x04, 0x06, 0x06, 0x06,
+ 0x06, 0x06, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06,
+ // Entry 140 - 17F
+ 0x06, 0x00, 0x06, 0x05, 0x05, 0x05, 0x05, 0x05,
+ 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
+ 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
+ 0x05, 0x05, 0x05, 0x05, 0x05, 0x04, 0x06, 0x06,
+ 0x04, 0x06, 0x06, 0x04, 0x06, 0x05,
+}
+
+// regionISO holds a list of alphabetically sorted 2-letter ISO region codes.
+// Each 2-letter codes is followed by two bytes with the following meaning:
+// - [A-Z}{2}: the first letter of the 2-letter code plus these two
+// letters form the 3-letter ISO code.
+// - 0, n: index into altRegionISO3.
+const regionISO tag.Index = "" + // Size: 1308 bytes
+ "AAAAACSCADNDAEREAFFGAGTGAIIAALLBAMRMANNTAOGOAQTAARRGASSMATUTAUUSAWBWAXLA" +
+ "AZZEBAIHBBRBBDGDBEELBFFABGGRBHHRBIDIBJENBLLMBMMUBNRNBOOLBQESBRRABSHSBTTN" +
+ "BUURBVVTBWWABYLRBZLZCAANCCCKCDODCFAFCGOGCHHECIIVCKOKCLHLCMMRCNHNCOOLCPPT" +
+ "CRRICS\x00\x00CTTECUUBCVPVCWUWCXXRCYYPCZZEDDDRDEEUDGGADJJIDKNKDMMADOOMDY" +
+ "HYDZZAEA ECCUEESTEGGYEHSHERRIESSPETTHEU\x00\x03EZ FIINFJJIFKLKFMSMFORO" +
+ "FQ\x00\x18FRRAFXXXGAABGBBRGDRDGEEOGFUFGGGYGHHAGIIBGLRLGMMBGNINGPLPGQNQGR" +
+ "RCGS\x00\x06GTTMGUUMGWNBGYUYHKKGHMMDHNNDHRRVHTTIHUUNHVVOIC IDDNIERLILSR" +
+ "IMMNINNDIOOTIQRQIRRNISSLITTAJEEYJMAMJOORJPPNJTTNKEENKGGZKHHMKIIRKM\x00" +
+ "\x09KNNAKP\x00\x0cKRORKWWTKY\x00\x0fKZAZLAAOLBBNLCCALIIELKKALRBRLSSOLTTU" +
+ "LUUXLVVALYBYMAARMCCOMDDAMENEMFAFMGDGMHHLMIIDMKKDMLLIMMMRMNNGMOACMPNPMQTQ" +
+ "MRRTMSSRMTLTMUUSMVDVMWWIMXEXMYYSMZOZNAAMNCCLNEERNFFKNGGANHHBNIICNLLDNOOR" +
+ "NPPLNQ\x00\x1eNRRUNTTZNUIUNZZLOMMNPAANPCCIPEERPFYFPGNGPHHLPKAKPLOLPM\x00" +
+ "\x12PNCNPRRIPSSEPTRTPUUSPWLWPYRYPZCZQAATQMMMQNNNQOOOQPPPQQQQQRRRQSSSQTTT" +
+ "QU\x00\x03QVVVQWWWQXXXQYYYQZZZREEURHHOROOURS\x00\x15RUUSRWWASAAUSBLBSCYC" +
+ "SDDNSEWESGGPSHHNSIVNSJJMSKVKSLLESMMRSNENSOOMSRURSSSDSTTPSUUNSVLVSXXMSYYR" +
+ "SZWZTAAATCCATDCDTF\x00\x18TGGOTHHATJJKTKKLTLLSTMKMTNUNTOONTPMPTRURTTTOTV" +
+ "UVTWWNTZZAUAKRUGGAUK UMMIUN USSAUYRYUZZBVAATVCCTVDDRVEENVGGBVIIRVNNMVU" +
+ "UTWFLFWKAKWSSMXAAAXBBBXCCCXDDDXEEEXFFFXGGGXHHHXIIIXJJJXKKKXLLLXMMMXNNNXO" +
+ "OOXPPPXQQQXRRRXSSSXTTTXUUUXVVVXWWWXXXXXYYYXZZZYDMDYEEMYT\x00\x1bYUUGZAAF" +
+ "ZMMBZRARZWWEZZZZ\xff\xff\xff\xff"
+
+// altRegionISO3 holds a list of 3-letter region codes that cannot be
+// mapped to 2-letter codes using the default algorithm. This is a short list.
+const altRegionISO3 string = "SCGQUUSGSCOMPRKCYMSPMSRBATFMYTATN"
+
+// altRegionIDs holds a list of regionIDs the positions of which match those
+// of the 3-letter ISO codes in altRegionISO3.
+// Size: 22 bytes, 11 elements
+var altRegionIDs = [11]uint16{
+ 0x0057, 0x0070, 0x0088, 0x00a8, 0x00aa, 0x00ad, 0x00ea, 0x0105,
+ 0x0121, 0x015f, 0x00dc,
+}
+
+// Size: 80 bytes, 20 elements
+var regionOldMap = [20]FromTo{
+ 0: {From: 0x44, To: 0xc4},
+ 1: {From: 0x58, To: 0xa7},
+ 2: {From: 0x5f, To: 0x60},
+ 3: {From: 0x66, To: 0x3b},
+ 4: {From: 0x79, To: 0x78},
+ 5: {From: 0x93, To: 0x37},
+ 6: {From: 0xa3, To: 0x133},
+ 7: {From: 0xc1, To: 0x133},
+ 8: {From: 0xd7, To: 0x13f},
+ 9: {From: 0xdc, To: 0x2b},
+ 10: {From: 0xef, To: 0x133},
+ 11: {From: 0xf2, To: 0xe2},
+ 12: {From: 0xfc, To: 0x70},
+ 13: {From: 0x103, To: 0x164},
+ 14: {From: 0x12a, To: 0x126},
+ 15: {From: 0x132, To: 0x7b},
+ 16: {From: 0x13a, To: 0x13e},
+ 17: {From: 0x141, To: 0x133},
+ 18: {From: 0x15d, To: 0x15e},
+ 19: {From: 0x163, To: 0x4b},
+}
+
+// m49 maps regionIDs to UN.M49 codes. The first isoRegionOffset entries are
+// codes indicating collections of regions.
+// Size: 716 bytes, 358 elements
+var m49 = [358]int16{
+ // Entry 0 - 3F
+ 0, 1, 2, 3, 5, 9, 11, 13,
+ 14, 15, 17, 18, 19, 21, 29, 30,
+ 34, 35, 39, 53, 54, 57, 61, 142,
+ 143, 145, 150, 151, 154, 155, 202, 419,
+ 958, 0, 20, 784, 4, 28, 660, 8,
+ 51, 530, 24, 10, 32, 16, 40, 36,
+ 533, 248, 31, 70, 52, 50, 56, 854,
+ 100, 48, 108, 204, 652, 60, 96, 68,
+ // Entry 40 - 7F
+ 535, 76, 44, 64, 104, 74, 72, 112,
+ 84, 124, 166, 180, 140, 178, 756, 384,
+ 184, 152, 120, 156, 170, 0, 188, 891,
+ 296, 192, 132, 531, 162, 196, 203, 278,
+ 276, 0, 262, 208, 212, 214, 204, 12,
+ 0, 218, 233, 818, 732, 232, 724, 231,
+ 967, 0, 246, 242, 238, 583, 234, 0,
+ 250, 249, 266, 826, 308, 268, 254, 831,
+ // Entry 80 - BF
+ 288, 292, 304, 270, 324, 312, 226, 300,
+ 239, 320, 316, 624, 328, 344, 334, 340,
+ 191, 332, 348, 854, 0, 360, 372, 376,
+ 833, 356, 86, 368, 364, 352, 380, 832,
+ 388, 400, 392, 581, 404, 417, 116, 296,
+ 174, 659, 408, 410, 414, 136, 398, 418,
+ 422, 662, 438, 144, 430, 426, 440, 442,
+ 428, 434, 504, 492, 498, 499, 663, 450,
+ // Entry C0 - FF
+ 584, 581, 807, 466, 104, 496, 446, 580,
+ 474, 478, 500, 470, 480, 462, 454, 484,
+ 458, 508, 516, 540, 562, 574, 566, 548,
+ 558, 528, 578, 524, 10, 520, 536, 570,
+ 554, 512, 591, 0, 604, 258, 598, 608,
+ 586, 616, 666, 612, 630, 275, 620, 581,
+ 585, 600, 591, 634, 959, 960, 961, 962,
+ 963, 964, 965, 966, 967, 968, 969, 970,
+ // Entry 100 - 13F
+ 971, 972, 638, 716, 642, 688, 643, 646,
+ 682, 90, 690, 729, 752, 702, 654, 705,
+ 744, 703, 694, 674, 686, 706, 740, 728,
+ 678, 810, 222, 534, 760, 748, 0, 796,
+ 148, 260, 768, 764, 762, 772, 626, 795,
+ 788, 776, 626, 792, 780, 798, 158, 834,
+ 804, 800, 826, 581, 0, 840, 858, 860,
+ 336, 670, 704, 862, 92, 850, 704, 548,
+ // Entry 140 - 17F
+ 876, 581, 882, 973, 974, 975, 976, 977,
+ 978, 979, 980, 981, 982, 983, 984, 985,
+ 986, 987, 988, 989, 990, 991, 992, 993,
+ 994, 995, 996, 997, 998, 720, 887, 175,
+ 891, 710, 894, 180, 716, 999,
+}
+
+// m49Index gives indexes into fromM49 based on the three most significant bits
+// of a 10-bit UN.M49 code. To search an UN.M49 code in fromM49, search in
+//
+// fromM49[m49Index[msb39(code)]:m49Index[msb3(code)+1]]
+//
+// for an entry where the first 7 bits match the 7 lsb of the UN.M49 code.
+// The region code is stored in the 9 lsb of the indexed value.
+// Size: 18 bytes, 9 elements
+var m49Index = [9]int16{
+ 0, 59, 108, 143, 181, 220, 259, 291,
+ 333,
+}
+
+// fromM49 contains entries to map UN.M49 codes to regions. See m49Index for details.
+// Size: 666 bytes, 333 elements
+var fromM49 = [333]uint16{
+ // Entry 0 - 3F
+ 0x0201, 0x0402, 0x0603, 0x0824, 0x0a04, 0x1027, 0x1205, 0x142b,
+ 0x1606, 0x1867, 0x1a07, 0x1c08, 0x1e09, 0x202d, 0x220a, 0x240b,
+ 0x260c, 0x2822, 0x2a0d, 0x302a, 0x3825, 0x3a0e, 0x3c0f, 0x3e32,
+ 0x402c, 0x4410, 0x4611, 0x482f, 0x4e12, 0x502e, 0x5842, 0x6039,
+ 0x6435, 0x6628, 0x6834, 0x6a13, 0x6c14, 0x7036, 0x7215, 0x783d,
+ 0x7a16, 0x8043, 0x883f, 0x8c33, 0x9046, 0x9445, 0x9841, 0xa848,
+ 0xac9a, 0xb509, 0xb93c, 0xc03e, 0xc838, 0xd0c4, 0xd83a, 0xe047,
+ 0xe8a6, 0xf052, 0xf849, 0x085a, 0x10ad, 0x184c, 0x1c17, 0x1e18,
+ // Entry 40 - 7F
+ 0x20b3, 0x2219, 0x2920, 0x2c1a, 0x2e1b, 0x3051, 0x341c, 0x361d,
+ 0x3853, 0x3d2e, 0x445c, 0x4c4a, 0x5454, 0x5ca8, 0x5f5f, 0x644d,
+ 0x684b, 0x7050, 0x7856, 0x7e90, 0x8059, 0x885d, 0x941e, 0x965e,
+ 0x983b, 0xa063, 0xa864, 0xac65, 0xb469, 0xbd1a, 0xc486, 0xcc6f,
+ 0xce6f, 0xd06d, 0xd26a, 0xd476, 0xdc74, 0xde88, 0xe473, 0xec72,
+ 0xf031, 0xf279, 0xf478, 0xfc7e, 0x04e5, 0x0921, 0x0c62, 0x147a,
+ 0x187d, 0x1c83, 0x26ed, 0x2860, 0x2c5f, 0x3060, 0x4080, 0x4881,
+ 0x50a7, 0x5887, 0x6082, 0x687c, 0x7085, 0x788a, 0x8089, 0x8884,
+ // Entry 80 - BF
+ 0x908c, 0x9891, 0x9c8e, 0xa138, 0xa88f, 0xb08d, 0xb892, 0xc09d,
+ 0xc899, 0xd095, 0xd89c, 0xe09b, 0xe896, 0xf097, 0xf89e, 0x004f,
+ 0x08a0, 0x10a2, 0x1cae, 0x20a1, 0x28a4, 0x30aa, 0x34ab, 0x3cac,
+ 0x42a5, 0x44af, 0x461f, 0x4cb0, 0x54b5, 0x58b8, 0x5cb4, 0x64b9,
+ 0x6cb2, 0x70b6, 0x74b7, 0x7cc6, 0x84bf, 0x8cce, 0x94d0, 0x9ccd,
+ 0xa4c3, 0xaccb, 0xb4c8, 0xbcc9, 0xc0cc, 0xc8cf, 0xd8bb, 0xe0c5,
+ 0xe4bc, 0xe6bd, 0xe8ca, 0xf0ba, 0xf8d1, 0x00e1, 0x08d2, 0x10dd,
+ 0x18db, 0x20d9, 0x2429, 0x265b, 0x2a30, 0x2d1b, 0x2e40, 0x30de,
+ // Entry C0 - FF
+ 0x38d3, 0x493f, 0x54e0, 0x5cd8, 0x64d4, 0x6cd6, 0x74df, 0x7cd5,
+ 0x84da, 0x88c7, 0x8b33, 0x8e75, 0x90c0, 0x92f0, 0x94e8, 0x9ee2,
+ 0xace6, 0xb0f1, 0xb8e4, 0xc0e7, 0xc8eb, 0xd0e9, 0xd8ee, 0xe08b,
+ 0xe526, 0xecec, 0xf4f3, 0xfd02, 0x0504, 0x0706, 0x0d07, 0x183c,
+ 0x1d0e, 0x26a9, 0x2826, 0x2cb1, 0x2ebe, 0x34ea, 0x3d39, 0x4513,
+ 0x4d18, 0x5508, 0x5d14, 0x6105, 0x650a, 0x6d12, 0x7d0d, 0x7f11,
+ 0x813e, 0x830f, 0x8515, 0x8d61, 0x9964, 0xa15d, 0xa86e, 0xb117,
+ 0xb30b, 0xb86c, 0xc10b, 0xc916, 0xd110, 0xd91d, 0xe10c, 0xe84e,
+ // Entry 100 - 13F
+ 0xf11c, 0xf524, 0xf923, 0x0122, 0x0925, 0x1129, 0x192c, 0x2023,
+ 0x2928, 0x312b, 0x3727, 0x391f, 0x3d2d, 0x4131, 0x4930, 0x4ec2,
+ 0x5519, 0x646b, 0x747b, 0x7e7f, 0x809f, 0x8298, 0x852f, 0x9135,
+ 0xa53d, 0xac37, 0xb536, 0xb937, 0xbd3b, 0xd940, 0xe542, 0xed5e,
+ 0xef5e, 0xf657, 0xfd62, 0x7c20, 0x7ef4, 0x80f5, 0x82f6, 0x84f7,
+ 0x86f8, 0x88f9, 0x8afa, 0x8cfb, 0x8e70, 0x90fd, 0x92fe, 0x94ff,
+ 0x9700, 0x9901, 0x9b43, 0x9d44, 0x9f45, 0xa146, 0xa347, 0xa548,
+ 0xa749, 0xa94a, 0xab4b, 0xad4c, 0xaf4d, 0xb14e, 0xb34f, 0xb550,
+ // Entry 140 - 17F
+ 0xb751, 0xb952, 0xbb53, 0xbd54, 0xbf55, 0xc156, 0xc357, 0xc558,
+ 0xc759, 0xc95a, 0xcb5b, 0xcd5c, 0xcf65,
+}
+
+// Size: 2014 bytes
+var variantIndex = map[string]uint8{
+ "1606nict": 0x0,
+ "1694acad": 0x1,
+ "1901": 0x2,
+ "1959acad": 0x3,
+ "1994": 0x61,
+ "1996": 0x4,
+ "abl1943": 0x5,
+ "akuapem": 0x6,
+ "alalc97": 0x63,
+ "aluku": 0x7,
+ "ao1990": 0x8,
+ "aranes": 0x9,
+ "arevela": 0xa,
+ "arevmda": 0xb,
+ "arkaika": 0xc,
+ "asante": 0xd,
+ "auvern": 0xe,
+ "baku1926": 0xf,
+ "balanka": 0x10,
+ "barla": 0x11,
+ "basiceng": 0x12,
+ "bauddha": 0x13,
+ "biscayan": 0x14,
+ "biske": 0x5c,
+ "bohoric": 0x15,
+ "boont": 0x16,
+ "bornholm": 0x17,
+ "cisaup": 0x18,
+ "colb1945": 0x19,
+ "cornu": 0x1a,
+ "creiss": 0x1b,
+ "dajnko": 0x1c,
+ "ekavsk": 0x1d,
+ "emodeng": 0x1e,
+ "fonipa": 0x64,
+ "fonkirsh": 0x65,
+ "fonnapa": 0x66,
+ "fonupa": 0x67,
+ "fonxsamp": 0x68,
+ "gascon": 0x1f,
+ "grclass": 0x20,
+ "grital": 0x21,
+ "grmistr": 0x22,
+ "hepburn": 0x23,
+ "heploc": 0x62,
+ "hognorsk": 0x24,
+ "hsistemo": 0x25,
+ "ijekavsk": 0x26,
+ "itihasa": 0x27,
+ "ivanchov": 0x28,
+ "jauer": 0x29,
+ "jyutping": 0x2a,
+ "kkcor": 0x2b,
+ "kociewie": 0x2c,
+ "kscor": 0x2d,
+ "laukika": 0x2e,
+ "lemosin": 0x2f,
+ "lengadoc": 0x30,
+ "lipaw": 0x5d,
+ "luna1918": 0x31,
+ "metelko": 0x32,
+ "monoton": 0x33,
+ "ndyuka": 0x34,
+ "nedis": 0x35,
+ "newfound": 0x36,
+ "nicard": 0x37,
+ "njiva": 0x5e,
+ "nulik": 0x38,
+ "osojs": 0x5f,
+ "oxendict": 0x39,
+ "pahawh2": 0x3a,
+ "pahawh3": 0x3b,
+ "pahawh4": 0x3c,
+ "pamaka": 0x3d,
+ "peano": 0x3e,
+ "petr1708": 0x3f,
+ "pinyin": 0x40,
+ "polyton": 0x41,
+ "provenc": 0x42,
+ "puter": 0x43,
+ "rigik": 0x44,
+ "rozaj": 0x45,
+ "rumgr": 0x46,
+ "scotland": 0x47,
+ "scouse": 0x48,
+ "simple": 0x69,
+ "solba": 0x60,
+ "sotav": 0x49,
+ "spanglis": 0x4a,
+ "surmiran": 0x4b,
+ "sursilv": 0x4c,
+ "sutsilv": 0x4d,
+ "tarask": 0x4e,
+ "tongyong": 0x4f,
+ "tunumiit": 0x50,
+ "uccor": 0x51,
+ "ucrcor": 0x52,
+ "ulster": 0x53,
+ "unifon": 0x54,
+ "vaidika": 0x55,
+ "valencia": 0x56,
+ "vallader": 0x57,
+ "vecdruka": 0x58,
+ "vivaraup": 0x59,
+ "wadegile": 0x5a,
+ "xsistemo": 0x5b,
+}
+
+// variantNumSpecialized is the number of specialized variants in variants.
+const variantNumSpecialized = 99
+
+// nRegionGroups is the number of region groups.
+const nRegionGroups = 33
+
+type likelyLangRegion struct {
+ lang uint16
+ region uint16
+}
+
+// likelyScript is a lookup table, indexed by scriptID, for the most likely
+// languages and regions given a script.
+// Size: 1040 bytes, 260 elements
+var likelyScript = [260]likelyLangRegion{
+ 1: {lang: 0x14e, region: 0x84},
+ 3: {lang: 0x2a2, region: 0x106},
+ 4: {lang: 0x1f, region: 0x99},
+ 5: {lang: 0x3a, region: 0x6b},
+ 7: {lang: 0x3b, region: 0x9c},
+ 8: {lang: 0x1d7, region: 0x28},
+ 9: {lang: 0x13, region: 0x9c},
+ 10: {lang: 0x5b, region: 0x95},
+ 11: {lang: 0x60, region: 0x52},
+ 12: {lang: 0xb9, region: 0xb4},
+ 13: {lang: 0x63, region: 0x95},
+ 14: {lang: 0xa5, region: 0x35},
+ 15: {lang: 0x3e9, region: 0x99},
+ 17: {lang: 0x529, region: 0x12e},
+ 18: {lang: 0x3b1, region: 0x99},
+ 19: {lang: 0x15e, region: 0x78},
+ 20: {lang: 0xc2, region: 0x95},
+ 21: {lang: 0x9d, region: 0xe7},
+ 22: {lang: 0xdb, region: 0x35},
+ 23: {lang: 0xf3, region: 0x49},
+ 24: {lang: 0x4f0, region: 0x12b},
+ 25: {lang: 0xe7, region: 0x13e},
+ 26: {lang: 0xe5, region: 0x135},
+ 29: {lang: 0xf1, region: 0x6b},
+ 31: {lang: 0x1a0, region: 0x5d},
+ 32: {lang: 0x3e2, region: 0x106},
+ 34: {lang: 0x1be, region: 0x99},
+ 38: {lang: 0x15e, region: 0x78},
+ 41: {lang: 0x133, region: 0x6b},
+ 42: {lang: 0x431, region: 0x27},
+ 44: {lang: 0x27, region: 0x6f},
+ 46: {lang: 0x210, region: 0x7d},
+ 47: {lang: 0xfe, region: 0x38},
+ 49: {lang: 0x19b, region: 0x99},
+ 50: {lang: 0x19e, region: 0x130},
+ 51: {lang: 0x3e9, region: 0x99},
+ 52: {lang: 0x136, region: 0x87},
+ 53: {lang: 0x1a4, region: 0x99},
+ 54: {lang: 0x39d, region: 0x99},
+ 55: {lang: 0x529, region: 0x12e},
+ 56: {lang: 0x254, region: 0xab},
+ 57: {lang: 0x529, region: 0x53},
+ 58: {lang: 0x1cb, region: 0xe7},
+ 59: {lang: 0x529, region: 0x53},
+ 60: {lang: 0x529, region: 0x12e},
+ 61: {lang: 0x2fd, region: 0x9b},
+ 62: {lang: 0x1bc, region: 0x97},
+ 63: {lang: 0x200, region: 0xa2},
+ 64: {lang: 0x1c5, region: 0x12b},
+ 65: {lang: 0x1ca, region: 0xaf},
+ 68: {lang: 0x1d5, region: 0x92},
+ 70: {lang: 0x142, region: 0x9e},
+ 71: {lang: 0x254, region: 0xab},
+ 72: {lang: 0x20e, region: 0x95},
+ 73: {lang: 0x200, region: 0xa2},
+ 75: {lang: 0x135, region: 0xc4},
+ 76: {lang: 0x200, region: 0xa2},
+ 77: {lang: 0x3bb, region: 0xe8},
+ 78: {lang: 0x24a, region: 0xa6},
+ 79: {lang: 0x3fa, region: 0x99},
+ 82: {lang: 0x251, region: 0x99},
+ 83: {lang: 0x254, region: 0xab},
+ 85: {lang: 0x88, region: 0x99},
+ 86: {lang: 0x370, region: 0x123},
+ 87: {lang: 0x2b8, region: 0xaf},
+ 92: {lang: 0x29f, region: 0x99},
+ 93: {lang: 0x2a8, region: 0x99},
+ 94: {lang: 0x28f, region: 0x87},
+ 95: {lang: 0x1a0, region: 0x87},
+ 96: {lang: 0x2ac, region: 0x53},
+ 98: {lang: 0x4f4, region: 0x12b},
+ 99: {lang: 0x4f5, region: 0x12b},
+ 100: {lang: 0x1be, region: 0x99},
+ 102: {lang: 0x337, region: 0x9c},
+ 103: {lang: 0x4f7, region: 0x53},
+ 104: {lang: 0xa9, region: 0x53},
+ 107: {lang: 0x2e8, region: 0x112},
+ 108: {lang: 0x4f8, region: 0x10b},
+ 109: {lang: 0x4f8, region: 0x10b},
+ 110: {lang: 0x304, region: 0x99},
+ 111: {lang: 0x31b, region: 0x99},
+ 112: {lang: 0x30b, region: 0x53},
+ 114: {lang: 0x31e, region: 0x35},
+ 115: {lang: 0x30e, region: 0x99},
+ 116: {lang: 0x414, region: 0xe8},
+ 117: {lang: 0x331, region: 0xc4},
+ 119: {lang: 0x4f9, region: 0x108},
+ 120: {lang: 0x3b, region: 0xa1},
+ 121: {lang: 0x353, region: 0xdb},
+ 124: {lang: 0x2d0, region: 0x84},
+ 125: {lang: 0x52a, region: 0x53},
+ 126: {lang: 0x403, region: 0x96},
+ 127: {lang: 0x3ee, region: 0x99},
+ 128: {lang: 0x39b, region: 0xc5},
+ 129: {lang: 0x395, region: 0x99},
+ 130: {lang: 0x399, region: 0x135},
+ 131: {lang: 0x429, region: 0x115},
+ 133: {lang: 0x3b, region: 0x11c},
+ 134: {lang: 0xfd, region: 0xc4},
+ 137: {lang: 0x27d, region: 0x106},
+ 138: {lang: 0x2c9, region: 0x53},
+ 139: {lang: 0x39f, region: 0x9c},
+ 140: {lang: 0x39f, region: 0x53},
+ 142: {lang: 0x3ad, region: 0xb0},
+ 144: {lang: 0x1c6, region: 0x53},
+ 145: {lang: 0x4fd, region: 0x9c},
+ 198: {lang: 0x3cb, region: 0x95},
+ 201: {lang: 0x372, region: 0x10c},
+ 202: {lang: 0x420, region: 0x97},
+ 204: {lang: 0x4ff, region: 0x15e},
+ 205: {lang: 0x3f0, region: 0x99},
+ 206: {lang: 0x45, region: 0x135},
+ 207: {lang: 0x139, region: 0x7b},
+ 208: {lang: 0x3e9, region: 0x99},
+ 210: {lang: 0x3e9, region: 0x99},
+ 211: {lang: 0x3fa, region: 0x99},
+ 212: {lang: 0x40c, region: 0xb3},
+ 215: {lang: 0x433, region: 0x99},
+ 216: {lang: 0xef, region: 0xc5},
+ 217: {lang: 0x43e, region: 0x95},
+ 218: {lang: 0x44d, region: 0x35},
+ 219: {lang: 0x44e, region: 0x9b},
+ 223: {lang: 0x45a, region: 0xe7},
+ 224: {lang: 0x11a, region: 0x99},
+ 225: {lang: 0x45e, region: 0x53},
+ 226: {lang: 0x232, region: 0x53},
+ 227: {lang: 0x450, region: 0x99},
+ 228: {lang: 0x4a5, region: 0x53},
+ 229: {lang: 0x9f, region: 0x13e},
+ 230: {lang: 0x461, region: 0x99},
+ 232: {lang: 0x528, region: 0xba},
+ 233: {lang: 0x153, region: 0xe7},
+ 234: {lang: 0x128, region: 0xcd},
+ 235: {lang: 0x46b, region: 0x123},
+ 236: {lang: 0xa9, region: 0x53},
+ 237: {lang: 0x2ce, region: 0x99},
+ 240: {lang: 0x4ad, region: 0x11c},
+ 241: {lang: 0x4be, region: 0xb4},
+ 244: {lang: 0x1ce, region: 0x99},
+ 247: {lang: 0x3a9, region: 0x9c},
+ 248: {lang: 0x22, region: 0x9b},
+ 250: {lang: 0x1ea, region: 0x53},
+ 251: {lang: 0xef, region: 0xc5},
+}
+
+type likelyScriptRegion struct {
+ region uint16
+ script uint16
+ flags uint8
+}
+
+// likelyLang is a lookup table, indexed by langID, for the most likely
+// scripts and regions given incomplete information. If more entries exist for a
+// given language, region and script are the index and size respectively
+// of the list in likelyLangList.
+// Size: 7980 bytes, 1330 elements
+var likelyLang = [1330]likelyScriptRegion{
+ 0: {region: 0x135, script: 0x5a, flags: 0x0},
+ 1: {region: 0x6f, script: 0x5a, flags: 0x0},
+ 2: {region: 0x165, script: 0x5a, flags: 0x0},
+ 3: {region: 0x165, script: 0x5a, flags: 0x0},
+ 4: {region: 0x165, script: 0x5a, flags: 0x0},
+ 5: {region: 0x7d, script: 0x20, flags: 0x0},
+ 6: {region: 0x165, script: 0x5a, flags: 0x0},
+ 7: {region: 0x165, script: 0x20, flags: 0x0},
+ 8: {region: 0x80, script: 0x5a, flags: 0x0},
+ 9: {region: 0x165, script: 0x5a, flags: 0x0},
+ 10: {region: 0x165, script: 0x5a, flags: 0x0},
+ 11: {region: 0x165, script: 0x5a, flags: 0x0},
+ 12: {region: 0x95, script: 0x5a, flags: 0x0},
+ 13: {region: 0x131, script: 0x5a, flags: 0x0},
+ 14: {region: 0x80, script: 0x5a, flags: 0x0},
+ 15: {region: 0x165, script: 0x5a, flags: 0x0},
+ 16: {region: 0x165, script: 0x5a, flags: 0x0},
+ 17: {region: 0x106, script: 0x20, flags: 0x0},
+ 18: {region: 0x165, script: 0x5a, flags: 0x0},
+ 19: {region: 0x9c, script: 0x9, flags: 0x0},
+ 20: {region: 0x128, script: 0x5, flags: 0x0},
+ 21: {region: 0x165, script: 0x5a, flags: 0x0},
+ 22: {region: 0x161, script: 0x5a, flags: 0x0},
+ 23: {region: 0x165, script: 0x5a, flags: 0x0},
+ 24: {region: 0x165, script: 0x5a, flags: 0x0},
+ 25: {region: 0x165, script: 0x5a, flags: 0x0},
+ 26: {region: 0x165, script: 0x5a, flags: 0x0},
+ 27: {region: 0x165, script: 0x5a, flags: 0x0},
+ 28: {region: 0x52, script: 0x5a, flags: 0x0},
+ 29: {region: 0x165, script: 0x5a, flags: 0x0},
+ 30: {region: 0x165, script: 0x5a, flags: 0x0},
+ 31: {region: 0x99, script: 0x4, flags: 0x0},
+ 32: {region: 0x165, script: 0x5a, flags: 0x0},
+ 33: {region: 0x80, script: 0x5a, flags: 0x0},
+ 34: {region: 0x9b, script: 0xf8, flags: 0x0},
+ 35: {region: 0x165, script: 0x5a, flags: 0x0},
+ 36: {region: 0x165, script: 0x5a, flags: 0x0},
+ 37: {region: 0x14d, script: 0x5a, flags: 0x0},
+ 38: {region: 0x106, script: 0x20, flags: 0x0},
+ 39: {region: 0x6f, script: 0x2c, flags: 0x0},
+ 40: {region: 0x165, script: 0x5a, flags: 0x0},
+ 41: {region: 0x165, script: 0x5a, flags: 0x0},
+ 42: {region: 0xd6, script: 0x5a, flags: 0x0},
+ 43: {region: 0x165, script: 0x5a, flags: 0x0},
+ 45: {region: 0x165, script: 0x5a, flags: 0x0},
+ 46: {region: 0x165, script: 0x5a, flags: 0x0},
+ 47: {region: 0x165, script: 0x5a, flags: 0x0},
+ 48: {region: 0x165, script: 0x5a, flags: 0x0},
+ 49: {region: 0x165, script: 0x5a, flags: 0x0},
+ 50: {region: 0x165, script: 0x5a, flags: 0x0},
+ 51: {region: 0x95, script: 0x5a, flags: 0x0},
+ 52: {region: 0x165, script: 0x5, flags: 0x0},
+ 53: {region: 0x122, script: 0x5, flags: 0x0},
+ 54: {region: 0x165, script: 0x5a, flags: 0x0},
+ 55: {region: 0x165, script: 0x5a, flags: 0x0},
+ 56: {region: 0x165, script: 0x5a, flags: 0x0},
+ 57: {region: 0x165, script: 0x5a, flags: 0x0},
+ 58: {region: 0x6b, script: 0x5, flags: 0x0},
+ 59: {region: 0x0, script: 0x3, flags: 0x1},
+ 60: {region: 0x165, script: 0x5a, flags: 0x0},
+ 61: {region: 0x51, script: 0x5a, flags: 0x0},
+ 62: {region: 0x3f, script: 0x5a, flags: 0x0},
+ 63: {region: 0x67, script: 0x5, flags: 0x0},
+ 65: {region: 0xba, script: 0x5, flags: 0x0},
+ 66: {region: 0x6b, script: 0x5, flags: 0x0},
+ 67: {region: 0x99, script: 0xe, flags: 0x0},
+ 68: {region: 0x12f, script: 0x5a, flags: 0x0},
+ 69: {region: 0x135, script: 0xce, flags: 0x0},
+ 70: {region: 0x165, script: 0x5a, flags: 0x0},
+ 71: {region: 0x165, script: 0x5a, flags: 0x0},
+ 72: {region: 0x6e, script: 0x5a, flags: 0x0},
+ 73: {region: 0x165, script: 0x5a, flags: 0x0},
+ 74: {region: 0x165, script: 0x5a, flags: 0x0},
+ 75: {region: 0x49, script: 0x5a, flags: 0x0},
+ 76: {region: 0x165, script: 0x5a, flags: 0x0},
+ 77: {region: 0x106, script: 0x20, flags: 0x0},
+ 78: {region: 0x165, script: 0x5, flags: 0x0},
+ 79: {region: 0x165, script: 0x5a, flags: 0x0},
+ 80: {region: 0x165, script: 0x5a, flags: 0x0},
+ 81: {region: 0x165, script: 0x5a, flags: 0x0},
+ 82: {region: 0x99, script: 0x22, flags: 0x0},
+ 83: {region: 0x165, script: 0x5a, flags: 0x0},
+ 84: {region: 0x165, script: 0x5a, flags: 0x0},
+ 85: {region: 0x165, script: 0x5a, flags: 0x0},
+ 86: {region: 0x3f, script: 0x5a, flags: 0x0},
+ 87: {region: 0x165, script: 0x5a, flags: 0x0},
+ 88: {region: 0x3, script: 0x5, flags: 0x1},
+ 89: {region: 0x106, script: 0x20, flags: 0x0},
+ 90: {region: 0xe8, script: 0x5, flags: 0x0},
+ 91: {region: 0x95, script: 0x5a, flags: 0x0},
+ 92: {region: 0xdb, script: 0x22, flags: 0x0},
+ 93: {region: 0x2e, script: 0x5a, flags: 0x0},
+ 94: {region: 0x52, script: 0x5a, flags: 0x0},
+ 95: {region: 0x165, script: 0x5a, flags: 0x0},
+ 96: {region: 0x52, script: 0xb, flags: 0x0},
+ 97: {region: 0x165, script: 0x5a, flags: 0x0},
+ 98: {region: 0x165, script: 0x5a, flags: 0x0},
+ 99: {region: 0x95, script: 0x5a, flags: 0x0},
+ 100: {region: 0x165, script: 0x5a, flags: 0x0},
+ 101: {region: 0x52, script: 0x5a, flags: 0x0},
+ 102: {region: 0x165, script: 0x5a, flags: 0x0},
+ 103: {region: 0x165, script: 0x5a, flags: 0x0},
+ 104: {region: 0x165, script: 0x5a, flags: 0x0},
+ 105: {region: 0x165, script: 0x5a, flags: 0x0},
+ 106: {region: 0x4f, script: 0x5a, flags: 0x0},
+ 107: {region: 0x165, script: 0x5a, flags: 0x0},
+ 108: {region: 0x165, script: 0x5a, flags: 0x0},
+ 109: {region: 0x165, script: 0x5a, flags: 0x0},
+ 110: {region: 0x165, script: 0x2c, flags: 0x0},
+ 111: {region: 0x165, script: 0x5a, flags: 0x0},
+ 112: {region: 0x165, script: 0x5a, flags: 0x0},
+ 113: {region: 0x47, script: 0x20, flags: 0x0},
+ 114: {region: 0x165, script: 0x5a, flags: 0x0},
+ 115: {region: 0x165, script: 0x5a, flags: 0x0},
+ 116: {region: 0x10b, script: 0x5, flags: 0x0},
+ 117: {region: 0x162, script: 0x5a, flags: 0x0},
+ 118: {region: 0x165, script: 0x5a, flags: 0x0},
+ 119: {region: 0x95, script: 0x5a, flags: 0x0},
+ 120: {region: 0x165, script: 0x5a, flags: 0x0},
+ 121: {region: 0x12f, script: 0x5a, flags: 0x0},
+ 122: {region: 0x52, script: 0x5a, flags: 0x0},
+ 123: {region: 0x99, script: 0xe3, flags: 0x0},
+ 124: {region: 0xe8, script: 0x5, flags: 0x0},
+ 125: {region: 0x99, script: 0x22, flags: 0x0},
+ 126: {region: 0x38, script: 0x20, flags: 0x0},
+ 127: {region: 0x99, script: 0x22, flags: 0x0},
+ 128: {region: 0xe8, script: 0x5, flags: 0x0},
+ 129: {region: 0x12b, script: 0x34, flags: 0x0},
+ 131: {region: 0x99, script: 0x22, flags: 0x0},
+ 132: {region: 0x165, script: 0x5a, flags: 0x0},
+ 133: {region: 0x99, script: 0x22, flags: 0x0},
+ 134: {region: 0xe7, script: 0x5a, flags: 0x0},
+ 135: {region: 0x165, script: 0x5a, flags: 0x0},
+ 136: {region: 0x99, script: 0x22, flags: 0x0},
+ 137: {region: 0x165, script: 0x5a, flags: 0x0},
+ 138: {region: 0x13f, script: 0x5a, flags: 0x0},
+ 139: {region: 0x165, script: 0x5a, flags: 0x0},
+ 140: {region: 0x165, script: 0x5a, flags: 0x0},
+ 141: {region: 0xe7, script: 0x5a, flags: 0x0},
+ 142: {region: 0x165, script: 0x5a, flags: 0x0},
+ 143: {region: 0xd6, script: 0x5a, flags: 0x0},
+ 144: {region: 0x165, script: 0x5a, flags: 0x0},
+ 145: {region: 0x165, script: 0x5a, flags: 0x0},
+ 146: {region: 0x165, script: 0x5a, flags: 0x0},
+ 147: {region: 0x165, script: 0x2c, flags: 0x0},
+ 148: {region: 0x99, script: 0x22, flags: 0x0},
+ 149: {region: 0x95, script: 0x5a, flags: 0x0},
+ 150: {region: 0x165, script: 0x5a, flags: 0x0},
+ 151: {region: 0x165, script: 0x5a, flags: 0x0},
+ 152: {region: 0x114, script: 0x5a, flags: 0x0},
+ 153: {region: 0x165, script: 0x5a, flags: 0x0},
+ 154: {region: 0x165, script: 0x5a, flags: 0x0},
+ 155: {region: 0x52, script: 0x5a, flags: 0x0},
+ 156: {region: 0x165, script: 0x5a, flags: 0x0},
+ 157: {region: 0xe7, script: 0x5a, flags: 0x0},
+ 158: {region: 0x165, script: 0x5a, flags: 0x0},
+ 159: {region: 0x13e, script: 0xe5, flags: 0x0},
+ 160: {region: 0xc3, script: 0x5a, flags: 0x0},
+ 161: {region: 0x165, script: 0x5a, flags: 0x0},
+ 162: {region: 0x165, script: 0x5a, flags: 0x0},
+ 163: {region: 0xc3, script: 0x5a, flags: 0x0},
+ 164: {region: 0x165, script: 0x5a, flags: 0x0},
+ 165: {region: 0x35, script: 0xe, flags: 0x0},
+ 166: {region: 0x165, script: 0x5a, flags: 0x0},
+ 167: {region: 0x165, script: 0x5a, flags: 0x0},
+ 168: {region: 0x165, script: 0x5a, flags: 0x0},
+ 169: {region: 0x53, script: 0xec, flags: 0x0},
+ 170: {region: 0x165, script: 0x5a, flags: 0x0},
+ 171: {region: 0x165, script: 0x5a, flags: 0x0},
+ 172: {region: 0x165, script: 0x5a, flags: 0x0},
+ 173: {region: 0x99, script: 0xe, flags: 0x0},
+ 174: {region: 0x165, script: 0x5a, flags: 0x0},
+ 175: {region: 0x9c, script: 0x5, flags: 0x0},
+ 176: {region: 0x165, script: 0x5a, flags: 0x0},
+ 177: {region: 0x4f, script: 0x5a, flags: 0x0},
+ 178: {region: 0x78, script: 0x5a, flags: 0x0},
+ 179: {region: 0x99, script: 0x22, flags: 0x0},
+ 180: {region: 0xe8, script: 0x5, flags: 0x0},
+ 181: {region: 0x99, script: 0x22, flags: 0x0},
+ 182: {region: 0x165, script: 0x5a, flags: 0x0},
+ 183: {region: 0x33, script: 0x5a, flags: 0x0},
+ 184: {region: 0x165, script: 0x5a, flags: 0x0},
+ 185: {region: 0xb4, script: 0xc, flags: 0x0},
+ 186: {region: 0x52, script: 0x5a, flags: 0x0},
+ 187: {region: 0x165, script: 0x2c, flags: 0x0},
+ 188: {region: 0xe7, script: 0x5a, flags: 0x0},
+ 189: {region: 0x165, script: 0x5a, flags: 0x0},
+ 190: {region: 0xe8, script: 0x22, flags: 0x0},
+ 191: {region: 0x106, script: 0x20, flags: 0x0},
+ 192: {region: 0x15f, script: 0x5a, flags: 0x0},
+ 193: {region: 0x165, script: 0x5a, flags: 0x0},
+ 194: {region: 0x95, script: 0x5a, flags: 0x0},
+ 195: {region: 0x165, script: 0x5a, flags: 0x0},
+ 196: {region: 0x52, script: 0x5a, flags: 0x0},
+ 197: {region: 0x165, script: 0x5a, flags: 0x0},
+ 198: {region: 0x165, script: 0x5a, flags: 0x0},
+ 199: {region: 0x165, script: 0x5a, flags: 0x0},
+ 200: {region: 0x86, script: 0x5a, flags: 0x0},
+ 201: {region: 0x165, script: 0x5a, flags: 0x0},
+ 202: {region: 0x165, script: 0x5a, flags: 0x0},
+ 203: {region: 0x165, script: 0x5a, flags: 0x0},
+ 204: {region: 0x165, script: 0x5a, flags: 0x0},
+ 205: {region: 0x6d, script: 0x2c, flags: 0x0},
+ 206: {region: 0x165, script: 0x5a, flags: 0x0},
+ 207: {region: 0x165, script: 0x5a, flags: 0x0},
+ 208: {region: 0x52, script: 0x5a, flags: 0x0},
+ 209: {region: 0x165, script: 0x5a, flags: 0x0},
+ 210: {region: 0x165, script: 0x5a, flags: 0x0},
+ 211: {region: 0xc3, script: 0x5a, flags: 0x0},
+ 212: {region: 0x165, script: 0x5a, flags: 0x0},
+ 213: {region: 0x165, script: 0x5a, flags: 0x0},
+ 214: {region: 0x165, script: 0x5a, flags: 0x0},
+ 215: {region: 0x6e, script: 0x5a, flags: 0x0},
+ 216: {region: 0x165, script: 0x5a, flags: 0x0},
+ 217: {region: 0x165, script: 0x5a, flags: 0x0},
+ 218: {region: 0xd6, script: 0x5a, flags: 0x0},
+ 219: {region: 0x35, script: 0x16, flags: 0x0},
+ 220: {region: 0x106, script: 0x20, flags: 0x0},
+ 221: {region: 0xe7, script: 0x5a, flags: 0x0},
+ 222: {region: 0x165, script: 0x5a, flags: 0x0},
+ 223: {region: 0x131, script: 0x5a, flags: 0x0},
+ 224: {region: 0x8a, script: 0x5a, flags: 0x0},
+ 225: {region: 0x75, script: 0x5a, flags: 0x0},
+ 226: {region: 0x106, script: 0x20, flags: 0x0},
+ 227: {region: 0x135, script: 0x5a, flags: 0x0},
+ 228: {region: 0x49, script: 0x5a, flags: 0x0},
+ 229: {region: 0x135, script: 0x1a, flags: 0x0},
+ 230: {region: 0xa6, script: 0x5, flags: 0x0},
+ 231: {region: 0x13e, script: 0x19, flags: 0x0},
+ 232: {region: 0x165, script: 0x5a, flags: 0x0},
+ 233: {region: 0x9b, script: 0x5, flags: 0x0},
+ 234: {region: 0x165, script: 0x5a, flags: 0x0},
+ 235: {region: 0x165, script: 0x5a, flags: 0x0},
+ 236: {region: 0x165, script: 0x5a, flags: 0x0},
+ 237: {region: 0x165, script: 0x5a, flags: 0x0},
+ 238: {region: 0x165, script: 0x5a, flags: 0x0},
+ 239: {region: 0xc5, script: 0xd8, flags: 0x0},
+ 240: {region: 0x78, script: 0x5a, flags: 0x0},
+ 241: {region: 0x6b, script: 0x1d, flags: 0x0},
+ 242: {region: 0xe7, script: 0x5a, flags: 0x0},
+ 243: {region: 0x49, script: 0x17, flags: 0x0},
+ 244: {region: 0x130, script: 0x20, flags: 0x0},
+ 245: {region: 0x49, script: 0x17, flags: 0x0},
+ 246: {region: 0x49, script: 0x17, flags: 0x0},
+ 247: {region: 0x49, script: 0x17, flags: 0x0},
+ 248: {region: 0x49, script: 0x17, flags: 0x0},
+ 249: {region: 0x10a, script: 0x5a, flags: 0x0},
+ 250: {region: 0x5e, script: 0x5a, flags: 0x0},
+ 251: {region: 0xe9, script: 0x5a, flags: 0x0},
+ 252: {region: 0x49, script: 0x17, flags: 0x0},
+ 253: {region: 0xc4, script: 0x86, flags: 0x0},
+ 254: {region: 0x8, script: 0x2, flags: 0x1},
+ 255: {region: 0x106, script: 0x20, flags: 0x0},
+ 256: {region: 0x7b, script: 0x5a, flags: 0x0},
+ 257: {region: 0x63, script: 0x5a, flags: 0x0},
+ 258: {region: 0x165, script: 0x5a, flags: 0x0},
+ 259: {region: 0x165, script: 0x5a, flags: 0x0},
+ 260: {region: 0x165, script: 0x5a, flags: 0x0},
+ 261: {region: 0x165, script: 0x5a, flags: 0x0},
+ 262: {region: 0x135, script: 0x5a, flags: 0x0},
+ 263: {region: 0x106, script: 0x20, flags: 0x0},
+ 264: {region: 0xa4, script: 0x5a, flags: 0x0},
+ 265: {region: 0x165, script: 0x5a, flags: 0x0},
+ 266: {region: 0x165, script: 0x5a, flags: 0x0},
+ 267: {region: 0x99, script: 0x5, flags: 0x0},
+ 268: {region: 0x165, script: 0x5a, flags: 0x0},
+ 269: {region: 0x60, script: 0x5a, flags: 0x0},
+ 270: {region: 0x165, script: 0x5a, flags: 0x0},
+ 271: {region: 0x49, script: 0x5a, flags: 0x0},
+ 272: {region: 0x165, script: 0x5a, flags: 0x0},
+ 273: {region: 0x165, script: 0x5a, flags: 0x0},
+ 274: {region: 0x165, script: 0x5a, flags: 0x0},
+ 275: {region: 0x165, script: 0x5, flags: 0x0},
+ 276: {region: 0x49, script: 0x5a, flags: 0x0},
+ 277: {region: 0x165, script: 0x5a, flags: 0x0},
+ 278: {region: 0x165, script: 0x5a, flags: 0x0},
+ 279: {region: 0xd4, script: 0x5a, flags: 0x0},
+ 280: {region: 0x4f, script: 0x5a, flags: 0x0},
+ 281: {region: 0x165, script: 0x5a, flags: 0x0},
+ 282: {region: 0x99, script: 0x5, flags: 0x0},
+ 283: {region: 0x165, script: 0x5a, flags: 0x0},
+ 284: {region: 0x165, script: 0x5a, flags: 0x0},
+ 285: {region: 0x165, script: 0x5a, flags: 0x0},
+ 286: {region: 0x165, script: 0x2c, flags: 0x0},
+ 287: {region: 0x60, script: 0x5a, flags: 0x0},
+ 288: {region: 0xc3, script: 0x5a, flags: 0x0},
+ 289: {region: 0xd0, script: 0x5a, flags: 0x0},
+ 290: {region: 0x165, script: 0x5a, flags: 0x0},
+ 291: {region: 0xdb, script: 0x22, flags: 0x0},
+ 292: {region: 0x52, script: 0x5a, flags: 0x0},
+ 293: {region: 0x165, script: 0x5a, flags: 0x0},
+ 294: {region: 0x165, script: 0x5a, flags: 0x0},
+ 295: {region: 0x165, script: 0x5a, flags: 0x0},
+ 296: {region: 0xcd, script: 0xea, flags: 0x0},
+ 297: {region: 0x165, script: 0x5a, flags: 0x0},
+ 298: {region: 0x165, script: 0x5a, flags: 0x0},
+ 299: {region: 0x114, script: 0x5a, flags: 0x0},
+ 300: {region: 0x37, script: 0x5a, flags: 0x0},
+ 301: {region: 0x43, script: 0xec, flags: 0x0},
+ 302: {region: 0x165, script: 0x5a, flags: 0x0},
+ 303: {region: 0xa4, script: 0x5a, flags: 0x0},
+ 304: {region: 0x80, script: 0x5a, flags: 0x0},
+ 305: {region: 0xd6, script: 0x5a, flags: 0x0},
+ 306: {region: 0x9e, script: 0x5a, flags: 0x0},
+ 307: {region: 0x6b, script: 0x29, flags: 0x0},
+ 308: {region: 0x165, script: 0x5a, flags: 0x0},
+ 309: {region: 0xc4, script: 0x4b, flags: 0x0},
+ 310: {region: 0x87, script: 0x34, flags: 0x0},
+ 311: {region: 0x165, script: 0x5a, flags: 0x0},
+ 312: {region: 0x165, script: 0x5a, flags: 0x0},
+ 313: {region: 0xa, script: 0x2, flags: 0x1},
+ 314: {region: 0x165, script: 0x5a, flags: 0x0},
+ 315: {region: 0x165, script: 0x5a, flags: 0x0},
+ 316: {region: 0x1, script: 0x5a, flags: 0x0},
+ 317: {region: 0x165, script: 0x5a, flags: 0x0},
+ 318: {region: 0x6e, script: 0x5a, flags: 0x0},
+ 319: {region: 0x135, script: 0x5a, flags: 0x0},
+ 320: {region: 0x6a, script: 0x5a, flags: 0x0},
+ 321: {region: 0x165, script: 0x5a, flags: 0x0},
+ 322: {region: 0x9e, script: 0x46, flags: 0x0},
+ 323: {region: 0x165, script: 0x5a, flags: 0x0},
+ 324: {region: 0x165, script: 0x5a, flags: 0x0},
+ 325: {region: 0x6e, script: 0x5a, flags: 0x0},
+ 326: {region: 0x52, script: 0x5a, flags: 0x0},
+ 327: {region: 0x6e, script: 0x5a, flags: 0x0},
+ 328: {region: 0x9c, script: 0x5, flags: 0x0},
+ 329: {region: 0x165, script: 0x5a, flags: 0x0},
+ 330: {region: 0x165, script: 0x5a, flags: 0x0},
+ 331: {region: 0x165, script: 0x5a, flags: 0x0},
+ 332: {region: 0x165, script: 0x5a, flags: 0x0},
+ 333: {region: 0x86, script: 0x5a, flags: 0x0},
+ 334: {region: 0xc, script: 0x2, flags: 0x1},
+ 335: {region: 0x165, script: 0x5a, flags: 0x0},
+ 336: {region: 0xc3, script: 0x5a, flags: 0x0},
+ 337: {region: 0x72, script: 0x5a, flags: 0x0},
+ 338: {region: 0x10b, script: 0x5, flags: 0x0},
+ 339: {region: 0xe7, script: 0x5a, flags: 0x0},
+ 340: {region: 0x10c, script: 0x5a, flags: 0x0},
+ 341: {region: 0x73, script: 0x5a, flags: 0x0},
+ 342: {region: 0x165, script: 0x5a, flags: 0x0},
+ 343: {region: 0x165, script: 0x5a, flags: 0x0},
+ 344: {region: 0x76, script: 0x5a, flags: 0x0},
+ 345: {region: 0x165, script: 0x5a, flags: 0x0},
+ 346: {region: 0x3b, script: 0x5a, flags: 0x0},
+ 347: {region: 0x165, script: 0x5a, flags: 0x0},
+ 348: {region: 0x165, script: 0x5a, flags: 0x0},
+ 349: {region: 0x165, script: 0x5a, flags: 0x0},
+ 350: {region: 0x78, script: 0x5a, flags: 0x0},
+ 351: {region: 0x135, script: 0x5a, flags: 0x0},
+ 352: {region: 0x78, script: 0x5a, flags: 0x0},
+ 353: {region: 0x60, script: 0x5a, flags: 0x0},
+ 354: {region: 0x60, script: 0x5a, flags: 0x0},
+ 355: {region: 0x52, script: 0x5, flags: 0x0},
+ 356: {region: 0x140, script: 0x5a, flags: 0x0},
+ 357: {region: 0x165, script: 0x5a, flags: 0x0},
+ 358: {region: 0x84, script: 0x5a, flags: 0x0},
+ 359: {region: 0x165, script: 0x5a, flags: 0x0},
+ 360: {region: 0xd4, script: 0x5a, flags: 0x0},
+ 361: {region: 0x9e, script: 0x5a, flags: 0x0},
+ 362: {region: 0xd6, script: 0x5a, flags: 0x0},
+ 363: {region: 0x165, script: 0x5a, flags: 0x0},
+ 364: {region: 0x10b, script: 0x5a, flags: 0x0},
+ 365: {region: 0xd9, script: 0x5a, flags: 0x0},
+ 366: {region: 0x96, script: 0x5a, flags: 0x0},
+ 367: {region: 0x80, script: 0x5a, flags: 0x0},
+ 368: {region: 0x165, script: 0x5a, flags: 0x0},
+ 369: {region: 0xbc, script: 0x5a, flags: 0x0},
+ 370: {region: 0x165, script: 0x5a, flags: 0x0},
+ 371: {region: 0x165, script: 0x5a, flags: 0x0},
+ 372: {region: 0x165, script: 0x5a, flags: 0x0},
+ 373: {region: 0x53, script: 0x3b, flags: 0x0},
+ 374: {region: 0x165, script: 0x5a, flags: 0x0},
+ 375: {region: 0x95, script: 0x5a, flags: 0x0},
+ 376: {region: 0x165, script: 0x5a, flags: 0x0},
+ 377: {region: 0x165, script: 0x5a, flags: 0x0},
+ 378: {region: 0x99, script: 0x22, flags: 0x0},
+ 379: {region: 0x165, script: 0x5a, flags: 0x0},
+ 380: {region: 0x9c, script: 0x5, flags: 0x0},
+ 381: {region: 0x7e, script: 0x5a, flags: 0x0},
+ 382: {region: 0x7b, script: 0x5a, flags: 0x0},
+ 383: {region: 0x165, script: 0x5a, flags: 0x0},
+ 384: {region: 0x165, script: 0x5a, flags: 0x0},
+ 385: {region: 0x165, script: 0x5a, flags: 0x0},
+ 386: {region: 0x165, script: 0x5a, flags: 0x0},
+ 387: {region: 0x165, script: 0x5a, flags: 0x0},
+ 388: {region: 0x165, script: 0x5a, flags: 0x0},
+ 389: {region: 0x6f, script: 0x2c, flags: 0x0},
+ 390: {region: 0x165, script: 0x5a, flags: 0x0},
+ 391: {region: 0xdb, script: 0x22, flags: 0x0},
+ 392: {region: 0x165, script: 0x5a, flags: 0x0},
+ 393: {region: 0xa7, script: 0x5a, flags: 0x0},
+ 394: {region: 0x165, script: 0x5a, flags: 0x0},
+ 395: {region: 0xe8, script: 0x5, flags: 0x0},
+ 396: {region: 0x165, script: 0x5a, flags: 0x0},
+ 397: {region: 0xe8, script: 0x5, flags: 0x0},
+ 398: {region: 0x165, script: 0x5a, flags: 0x0},
+ 399: {region: 0x165, script: 0x5a, flags: 0x0},
+ 400: {region: 0x6e, script: 0x5a, flags: 0x0},
+ 401: {region: 0x9c, script: 0x5, flags: 0x0},
+ 402: {region: 0x165, script: 0x5a, flags: 0x0},
+ 403: {region: 0x165, script: 0x2c, flags: 0x0},
+ 404: {region: 0xf1, script: 0x5a, flags: 0x0},
+ 405: {region: 0x165, script: 0x5a, flags: 0x0},
+ 406: {region: 0x165, script: 0x5a, flags: 0x0},
+ 407: {region: 0x165, script: 0x5a, flags: 0x0},
+ 408: {region: 0x165, script: 0x2c, flags: 0x0},
+ 409: {region: 0x165, script: 0x5a, flags: 0x0},
+ 410: {region: 0x99, script: 0x22, flags: 0x0},
+ 411: {region: 0x99, script: 0xe6, flags: 0x0},
+ 412: {region: 0x95, script: 0x5a, flags: 0x0},
+ 413: {region: 0xd9, script: 0x5a, flags: 0x0},
+ 414: {region: 0x130, script: 0x32, flags: 0x0},
+ 415: {region: 0x165, script: 0x5a, flags: 0x0},
+ 416: {region: 0xe, script: 0x2, flags: 0x1},
+ 417: {region: 0x99, script: 0xe, flags: 0x0},
+ 418: {region: 0x165, script: 0x5a, flags: 0x0},
+ 419: {region: 0x4e, script: 0x5a, flags: 0x0},
+ 420: {region: 0x99, script: 0x35, flags: 0x0},
+ 421: {region: 0x41, script: 0x5a, flags: 0x0},
+ 422: {region: 0x54, script: 0x5a, flags: 0x0},
+ 423: {region: 0x165, script: 0x5a, flags: 0x0},
+ 424: {region: 0x80, script: 0x5a, flags: 0x0},
+ 425: {region: 0x165, script: 0x5a, flags: 0x0},
+ 426: {region: 0x165, script: 0x5a, flags: 0x0},
+ 427: {region: 0xa4, script: 0x5a, flags: 0x0},
+ 428: {region: 0x98, script: 0x5a, flags: 0x0},
+ 429: {region: 0x165, script: 0x5a, flags: 0x0},
+ 430: {region: 0xdb, script: 0x22, flags: 0x0},
+ 431: {region: 0x165, script: 0x5a, flags: 0x0},
+ 432: {region: 0x165, script: 0x5, flags: 0x0},
+ 433: {region: 0x49, script: 0x5a, flags: 0x0},
+ 434: {region: 0x165, script: 0x5, flags: 0x0},
+ 435: {region: 0x165, script: 0x5a, flags: 0x0},
+ 436: {region: 0x10, script: 0x3, flags: 0x1},
+ 437: {region: 0x165, script: 0x5a, flags: 0x0},
+ 438: {region: 0x53, script: 0x3b, flags: 0x0},
+ 439: {region: 0x165, script: 0x5a, flags: 0x0},
+ 440: {region: 0x135, script: 0x5a, flags: 0x0},
+ 441: {region: 0x24, script: 0x5, flags: 0x0},
+ 442: {region: 0x165, script: 0x5a, flags: 0x0},
+ 443: {region: 0x165, script: 0x2c, flags: 0x0},
+ 444: {region: 0x97, script: 0x3e, flags: 0x0},
+ 445: {region: 0x165, script: 0x5a, flags: 0x0},
+ 446: {region: 0x99, script: 0x22, flags: 0x0},
+ 447: {region: 0x165, script: 0x5a, flags: 0x0},
+ 448: {region: 0x73, script: 0x5a, flags: 0x0},
+ 449: {region: 0x165, script: 0x5a, flags: 0x0},
+ 450: {region: 0x165, script: 0x5a, flags: 0x0},
+ 451: {region: 0xe7, script: 0x5a, flags: 0x0},
+ 452: {region: 0x165, script: 0x5a, flags: 0x0},
+ 453: {region: 0x12b, script: 0x40, flags: 0x0},
+ 454: {region: 0x53, script: 0x90, flags: 0x0},
+ 455: {region: 0x165, script: 0x5a, flags: 0x0},
+ 456: {region: 0xe8, script: 0x5, flags: 0x0},
+ 457: {region: 0x99, script: 0x22, flags: 0x0},
+ 458: {region: 0xaf, script: 0x41, flags: 0x0},
+ 459: {region: 0xe7, script: 0x5a, flags: 0x0},
+ 460: {region: 0xe8, script: 0x5, flags: 0x0},
+ 461: {region: 0xe6, script: 0x5a, flags: 0x0},
+ 462: {region: 0x99, script: 0x22, flags: 0x0},
+ 463: {region: 0x99, script: 0x22, flags: 0x0},
+ 464: {region: 0x165, script: 0x5a, flags: 0x0},
+ 465: {region: 0x90, script: 0x5a, flags: 0x0},
+ 466: {region: 0x60, script: 0x5a, flags: 0x0},
+ 467: {region: 0x53, script: 0x3b, flags: 0x0},
+ 468: {region: 0x91, script: 0x5a, flags: 0x0},
+ 469: {region: 0x92, script: 0x5a, flags: 0x0},
+ 470: {region: 0x165, script: 0x5a, flags: 0x0},
+ 471: {region: 0x28, script: 0x8, flags: 0x0},
+ 472: {region: 0xd2, script: 0x5a, flags: 0x0},
+ 473: {region: 0x78, script: 0x5a, flags: 0x0},
+ 474: {region: 0x165, script: 0x5a, flags: 0x0},
+ 475: {region: 0x165, script: 0x5a, flags: 0x0},
+ 476: {region: 0xd0, script: 0x5a, flags: 0x0},
+ 477: {region: 0xd6, script: 0x5a, flags: 0x0},
+ 478: {region: 0x165, script: 0x5a, flags: 0x0},
+ 479: {region: 0x165, script: 0x5a, flags: 0x0},
+ 480: {region: 0x165, script: 0x5a, flags: 0x0},
+ 481: {region: 0x95, script: 0x5a, flags: 0x0},
+ 482: {region: 0x165, script: 0x5a, flags: 0x0},
+ 483: {region: 0x165, script: 0x5a, flags: 0x0},
+ 484: {region: 0x165, script: 0x5a, flags: 0x0},
+ 486: {region: 0x122, script: 0x5a, flags: 0x0},
+ 487: {region: 0xd6, script: 0x5a, flags: 0x0},
+ 488: {region: 0x165, script: 0x5a, flags: 0x0},
+ 489: {region: 0x165, script: 0x5a, flags: 0x0},
+ 490: {region: 0x53, script: 0xfa, flags: 0x0},
+ 491: {region: 0x165, script: 0x5a, flags: 0x0},
+ 492: {region: 0x135, script: 0x5a, flags: 0x0},
+ 493: {region: 0x165, script: 0x5a, flags: 0x0},
+ 494: {region: 0x49, script: 0x5a, flags: 0x0},
+ 495: {region: 0x165, script: 0x5a, flags: 0x0},
+ 496: {region: 0x165, script: 0x5a, flags: 0x0},
+ 497: {region: 0xe7, script: 0x5a, flags: 0x0},
+ 498: {region: 0x165, script: 0x5a, flags: 0x0},
+ 499: {region: 0x95, script: 0x5a, flags: 0x0},
+ 500: {region: 0x106, script: 0x20, flags: 0x0},
+ 501: {region: 0x1, script: 0x5a, flags: 0x0},
+ 502: {region: 0x165, script: 0x5a, flags: 0x0},
+ 503: {region: 0x165, script: 0x5a, flags: 0x0},
+ 504: {region: 0x9d, script: 0x5a, flags: 0x0},
+ 505: {region: 0x9e, script: 0x5a, flags: 0x0},
+ 506: {region: 0x49, script: 0x17, flags: 0x0},
+ 507: {region: 0x97, script: 0x3e, flags: 0x0},
+ 508: {region: 0x165, script: 0x5a, flags: 0x0},
+ 509: {region: 0x165, script: 0x5a, flags: 0x0},
+ 510: {region: 0x106, script: 0x5a, flags: 0x0},
+ 511: {region: 0x165, script: 0x5a, flags: 0x0},
+ 512: {region: 0xa2, script: 0x49, flags: 0x0},
+ 513: {region: 0x165, script: 0x5a, flags: 0x0},
+ 514: {region: 0xa0, script: 0x5a, flags: 0x0},
+ 515: {region: 0x1, script: 0x5a, flags: 0x0},
+ 516: {region: 0x165, script: 0x5a, flags: 0x0},
+ 517: {region: 0x165, script: 0x5a, flags: 0x0},
+ 518: {region: 0x165, script: 0x5a, flags: 0x0},
+ 519: {region: 0x52, script: 0x5a, flags: 0x0},
+ 520: {region: 0x130, script: 0x3e, flags: 0x0},
+ 521: {region: 0x165, script: 0x5a, flags: 0x0},
+ 522: {region: 0x12f, script: 0x5a, flags: 0x0},
+ 523: {region: 0xdb, script: 0x22, flags: 0x0},
+ 524: {region: 0x165, script: 0x5a, flags: 0x0},
+ 525: {region: 0x63, script: 0x5a, flags: 0x0},
+ 526: {region: 0x95, script: 0x5a, flags: 0x0},
+ 527: {region: 0x95, script: 0x5a, flags: 0x0},
+ 528: {region: 0x7d, script: 0x2e, flags: 0x0},
+ 529: {region: 0x137, script: 0x20, flags: 0x0},
+ 530: {region: 0x67, script: 0x5a, flags: 0x0},
+ 531: {region: 0xc4, script: 0x5a, flags: 0x0},
+ 532: {region: 0x165, script: 0x5a, flags: 0x0},
+ 533: {region: 0x165, script: 0x5a, flags: 0x0},
+ 534: {region: 0xd6, script: 0x5a, flags: 0x0},
+ 535: {region: 0xa4, script: 0x5a, flags: 0x0},
+ 536: {region: 0xc3, script: 0x5a, flags: 0x0},
+ 537: {region: 0x106, script: 0x20, flags: 0x0},
+ 538: {region: 0x165, script: 0x5a, flags: 0x0},
+ 539: {region: 0x165, script: 0x5a, flags: 0x0},
+ 540: {region: 0x165, script: 0x5a, flags: 0x0},
+ 541: {region: 0x165, script: 0x5a, flags: 0x0},
+ 542: {region: 0xd4, script: 0x5, flags: 0x0},
+ 543: {region: 0xd6, script: 0x5a, flags: 0x0},
+ 544: {region: 0x164, script: 0x5a, flags: 0x0},
+ 545: {region: 0x165, script: 0x5a, flags: 0x0},
+ 546: {region: 0x165, script: 0x5a, flags: 0x0},
+ 547: {region: 0x12f, script: 0x5a, flags: 0x0},
+ 548: {region: 0x122, script: 0x5, flags: 0x0},
+ 549: {region: 0x165, script: 0x5a, flags: 0x0},
+ 550: {region: 0x123, script: 0xeb, flags: 0x0},
+ 551: {region: 0x5a, script: 0x5a, flags: 0x0},
+ 552: {region: 0x52, script: 0x5a, flags: 0x0},
+ 553: {region: 0x165, script: 0x5a, flags: 0x0},
+ 554: {region: 0x4f, script: 0x5a, flags: 0x0},
+ 555: {region: 0x99, script: 0x22, flags: 0x0},
+ 556: {region: 0x99, script: 0x22, flags: 0x0},
+ 557: {region: 0x4b, script: 0x5a, flags: 0x0},
+ 558: {region: 0x95, script: 0x5a, flags: 0x0},
+ 559: {region: 0x165, script: 0x5a, flags: 0x0},
+ 560: {region: 0x41, script: 0x5a, flags: 0x0},
+ 561: {region: 0x99, script: 0x5a, flags: 0x0},
+ 562: {region: 0x53, script: 0xe2, flags: 0x0},
+ 563: {region: 0x99, script: 0x22, flags: 0x0},
+ 564: {region: 0xc3, script: 0x5a, flags: 0x0},
+ 565: {region: 0x165, script: 0x5a, flags: 0x0},
+ 566: {region: 0x99, script: 0x75, flags: 0x0},
+ 567: {region: 0xe8, script: 0x5, flags: 0x0},
+ 568: {region: 0x165, script: 0x5a, flags: 0x0},
+ 569: {region: 0xa4, script: 0x5a, flags: 0x0},
+ 570: {region: 0x165, script: 0x5a, flags: 0x0},
+ 571: {region: 0x12b, script: 0x5a, flags: 0x0},
+ 572: {region: 0x165, script: 0x5a, flags: 0x0},
+ 573: {region: 0xd2, script: 0x5a, flags: 0x0},
+ 574: {region: 0x165, script: 0x5a, flags: 0x0},
+ 575: {region: 0xaf, script: 0x57, flags: 0x0},
+ 576: {region: 0x165, script: 0x5a, flags: 0x0},
+ 577: {region: 0x165, script: 0x5a, flags: 0x0},
+ 578: {region: 0x13, script: 0x6, flags: 0x1},
+ 579: {region: 0x165, script: 0x5a, flags: 0x0},
+ 580: {region: 0x52, script: 0x5a, flags: 0x0},
+ 581: {region: 0x82, script: 0x5a, flags: 0x0},
+ 582: {region: 0xa4, script: 0x5a, flags: 0x0},
+ 583: {region: 0x165, script: 0x5a, flags: 0x0},
+ 584: {region: 0x165, script: 0x5a, flags: 0x0},
+ 585: {region: 0x165, script: 0x5a, flags: 0x0},
+ 586: {region: 0xa6, script: 0x4e, flags: 0x0},
+ 587: {region: 0x2a, script: 0x5a, flags: 0x0},
+ 588: {region: 0x165, script: 0x5a, flags: 0x0},
+ 589: {region: 0x165, script: 0x5a, flags: 0x0},
+ 590: {region: 0x165, script: 0x5a, flags: 0x0},
+ 591: {region: 0x165, script: 0x5a, flags: 0x0},
+ 592: {region: 0x165, script: 0x5a, flags: 0x0},
+ 593: {region: 0x99, script: 0x52, flags: 0x0},
+ 594: {region: 0x8b, script: 0x5a, flags: 0x0},
+ 595: {region: 0x165, script: 0x5a, flags: 0x0},
+ 596: {region: 0xab, script: 0x53, flags: 0x0},
+ 597: {region: 0x106, script: 0x20, flags: 0x0},
+ 598: {region: 0x99, script: 0x22, flags: 0x0},
+ 599: {region: 0x165, script: 0x5a, flags: 0x0},
+ 600: {region: 0x75, script: 0x5a, flags: 0x0},
+ 601: {region: 0x165, script: 0x5a, flags: 0x0},
+ 602: {region: 0xb4, script: 0x5a, flags: 0x0},
+ 603: {region: 0x165, script: 0x5a, flags: 0x0},
+ 604: {region: 0x165, script: 0x5a, flags: 0x0},
+ 605: {region: 0x165, script: 0x5a, flags: 0x0},
+ 606: {region: 0x165, script: 0x5a, flags: 0x0},
+ 607: {region: 0x165, script: 0x5a, flags: 0x0},
+ 608: {region: 0x165, script: 0x5a, flags: 0x0},
+ 609: {region: 0x165, script: 0x5a, flags: 0x0},
+ 610: {region: 0x165, script: 0x2c, flags: 0x0},
+ 611: {region: 0x165, script: 0x5a, flags: 0x0},
+ 612: {region: 0x106, script: 0x20, flags: 0x0},
+ 613: {region: 0x112, script: 0x5a, flags: 0x0},
+ 614: {region: 0xe7, script: 0x5a, flags: 0x0},
+ 615: {region: 0x106, script: 0x5a, flags: 0x0},
+ 616: {region: 0x165, script: 0x5a, flags: 0x0},
+ 617: {region: 0x99, script: 0x22, flags: 0x0},
+ 618: {region: 0x99, script: 0x5, flags: 0x0},
+ 619: {region: 0x12f, script: 0x5a, flags: 0x0},
+ 620: {region: 0x165, script: 0x5a, flags: 0x0},
+ 621: {region: 0x52, script: 0x5a, flags: 0x0},
+ 622: {region: 0x60, script: 0x5a, flags: 0x0},
+ 623: {region: 0x165, script: 0x5a, flags: 0x0},
+ 624: {region: 0x165, script: 0x5a, flags: 0x0},
+ 625: {region: 0x165, script: 0x2c, flags: 0x0},
+ 626: {region: 0x165, script: 0x5a, flags: 0x0},
+ 627: {region: 0x165, script: 0x5a, flags: 0x0},
+ 628: {region: 0x19, script: 0x3, flags: 0x1},
+ 629: {region: 0x165, script: 0x5a, flags: 0x0},
+ 630: {region: 0x165, script: 0x5a, flags: 0x0},
+ 631: {region: 0x165, script: 0x5a, flags: 0x0},
+ 632: {region: 0x165, script: 0x5a, flags: 0x0},
+ 633: {region: 0x106, script: 0x20, flags: 0x0},
+ 634: {region: 0x165, script: 0x5a, flags: 0x0},
+ 635: {region: 0x165, script: 0x5a, flags: 0x0},
+ 636: {region: 0x165, script: 0x5a, flags: 0x0},
+ 637: {region: 0x106, script: 0x20, flags: 0x0},
+ 638: {region: 0x165, script: 0x5a, flags: 0x0},
+ 639: {region: 0x95, script: 0x5a, flags: 0x0},
+ 640: {region: 0xe8, script: 0x5, flags: 0x0},
+ 641: {region: 0x7b, script: 0x5a, flags: 0x0},
+ 642: {region: 0x165, script: 0x5a, flags: 0x0},
+ 643: {region: 0x165, script: 0x5a, flags: 0x0},
+ 644: {region: 0x165, script: 0x5a, flags: 0x0},
+ 645: {region: 0x165, script: 0x2c, flags: 0x0},
+ 646: {region: 0x123, script: 0xeb, flags: 0x0},
+ 647: {region: 0xe8, script: 0x5, flags: 0x0},
+ 648: {region: 0x165, script: 0x5a, flags: 0x0},
+ 649: {region: 0x165, script: 0x5a, flags: 0x0},
+ 650: {region: 0x1c, script: 0x5, flags: 0x1},
+ 651: {region: 0x165, script: 0x5a, flags: 0x0},
+ 652: {region: 0x165, script: 0x5a, flags: 0x0},
+ 653: {region: 0x165, script: 0x5a, flags: 0x0},
+ 654: {region: 0x138, script: 0x5a, flags: 0x0},
+ 655: {region: 0x87, script: 0x5e, flags: 0x0},
+ 656: {region: 0x97, script: 0x3e, flags: 0x0},
+ 657: {region: 0x12f, script: 0x5a, flags: 0x0},
+ 658: {region: 0xe8, script: 0x5, flags: 0x0},
+ 659: {region: 0x131, script: 0x5a, flags: 0x0},
+ 660: {region: 0x165, script: 0x5a, flags: 0x0},
+ 661: {region: 0xb7, script: 0x5a, flags: 0x0},
+ 662: {region: 0x106, script: 0x20, flags: 0x0},
+ 663: {region: 0x165, script: 0x5a, flags: 0x0},
+ 664: {region: 0x95, script: 0x5a, flags: 0x0},
+ 665: {region: 0x165, script: 0x5a, flags: 0x0},
+ 666: {region: 0x53, script: 0xeb, flags: 0x0},
+ 667: {region: 0x165, script: 0x5a, flags: 0x0},
+ 668: {region: 0x165, script: 0x5a, flags: 0x0},
+ 669: {region: 0x165, script: 0x5a, flags: 0x0},
+ 670: {region: 0x165, script: 0x5a, flags: 0x0},
+ 671: {region: 0x99, script: 0x5c, flags: 0x0},
+ 672: {region: 0x165, script: 0x5a, flags: 0x0},
+ 673: {region: 0x165, script: 0x5a, flags: 0x0},
+ 674: {region: 0x106, script: 0x20, flags: 0x0},
+ 675: {region: 0x131, script: 0x5a, flags: 0x0},
+ 676: {region: 0x165, script: 0x5a, flags: 0x0},
+ 677: {region: 0xd9, script: 0x5a, flags: 0x0},
+ 678: {region: 0x165, script: 0x5a, flags: 0x0},
+ 679: {region: 0x165, script: 0x5a, flags: 0x0},
+ 680: {region: 0x21, script: 0x2, flags: 0x1},
+ 681: {region: 0x165, script: 0x5a, flags: 0x0},
+ 682: {region: 0x165, script: 0x5a, flags: 0x0},
+ 683: {region: 0x9e, script: 0x5a, flags: 0x0},
+ 684: {region: 0x53, script: 0x60, flags: 0x0},
+ 685: {region: 0x95, script: 0x5a, flags: 0x0},
+ 686: {region: 0x9c, script: 0x5, flags: 0x0},
+ 687: {region: 0x135, script: 0x5a, flags: 0x0},
+ 688: {region: 0x165, script: 0x5a, flags: 0x0},
+ 689: {region: 0x165, script: 0x5a, flags: 0x0},
+ 690: {region: 0x99, script: 0xe6, flags: 0x0},
+ 691: {region: 0x9e, script: 0x5a, flags: 0x0},
+ 692: {region: 0x165, script: 0x5a, flags: 0x0},
+ 693: {region: 0x4b, script: 0x5a, flags: 0x0},
+ 694: {region: 0x165, script: 0x5a, flags: 0x0},
+ 695: {region: 0x165, script: 0x5a, flags: 0x0},
+ 696: {region: 0xaf, script: 0x57, flags: 0x0},
+ 697: {region: 0x165, script: 0x5a, flags: 0x0},
+ 698: {region: 0x165, script: 0x5a, flags: 0x0},
+ 699: {region: 0x4b, script: 0x5a, flags: 0x0},
+ 700: {region: 0x165, script: 0x5a, flags: 0x0},
+ 701: {region: 0x165, script: 0x5a, flags: 0x0},
+ 702: {region: 0x162, script: 0x5a, flags: 0x0},
+ 703: {region: 0x9c, script: 0x5, flags: 0x0},
+ 704: {region: 0xb6, script: 0x5a, flags: 0x0},
+ 705: {region: 0xb8, script: 0x5a, flags: 0x0},
+ 706: {region: 0x4b, script: 0x5a, flags: 0x0},
+ 707: {region: 0x4b, script: 0x5a, flags: 0x0},
+ 708: {region: 0xa4, script: 0x5a, flags: 0x0},
+ 709: {region: 0xa4, script: 0x5a, flags: 0x0},
+ 710: {region: 0x9c, script: 0x5, flags: 0x0},
+ 711: {region: 0xb8, script: 0x5a, flags: 0x0},
+ 712: {region: 0x123, script: 0xeb, flags: 0x0},
+ 713: {region: 0x53, script: 0x3b, flags: 0x0},
+ 714: {region: 0x12b, script: 0x5a, flags: 0x0},
+ 715: {region: 0x95, script: 0x5a, flags: 0x0},
+ 716: {region: 0x52, script: 0x5a, flags: 0x0},
+ 717: {region: 0x99, script: 0x22, flags: 0x0},
+ 718: {region: 0x99, script: 0x22, flags: 0x0},
+ 719: {region: 0x95, script: 0x5a, flags: 0x0},
+ 720: {region: 0x23, script: 0x3, flags: 0x1},
+ 721: {region: 0xa4, script: 0x5a, flags: 0x0},
+ 722: {region: 0x165, script: 0x5a, flags: 0x0},
+ 723: {region: 0xcf, script: 0x5a, flags: 0x0},
+ 724: {region: 0x165, script: 0x5a, flags: 0x0},
+ 725: {region: 0x165, script: 0x5a, flags: 0x0},
+ 726: {region: 0x165, script: 0x5a, flags: 0x0},
+ 727: {region: 0x165, script: 0x5a, flags: 0x0},
+ 728: {region: 0x165, script: 0x5a, flags: 0x0},
+ 729: {region: 0x165, script: 0x5a, flags: 0x0},
+ 730: {region: 0x165, script: 0x5a, flags: 0x0},
+ 731: {region: 0x165, script: 0x5a, flags: 0x0},
+ 732: {region: 0x165, script: 0x5a, flags: 0x0},
+ 733: {region: 0x165, script: 0x5a, flags: 0x0},
+ 734: {region: 0x165, script: 0x5a, flags: 0x0},
+ 735: {region: 0x165, script: 0x5, flags: 0x0},
+ 736: {region: 0x106, script: 0x20, flags: 0x0},
+ 737: {region: 0xe7, script: 0x5a, flags: 0x0},
+ 738: {region: 0x165, script: 0x5a, flags: 0x0},
+ 739: {region: 0x95, script: 0x5a, flags: 0x0},
+ 740: {region: 0x165, script: 0x2c, flags: 0x0},
+ 741: {region: 0x165, script: 0x5a, flags: 0x0},
+ 742: {region: 0x165, script: 0x5a, flags: 0x0},
+ 743: {region: 0x165, script: 0x5a, flags: 0x0},
+ 744: {region: 0x112, script: 0x5a, flags: 0x0},
+ 745: {region: 0xa4, script: 0x5a, flags: 0x0},
+ 746: {region: 0x165, script: 0x5a, flags: 0x0},
+ 747: {region: 0x165, script: 0x5a, flags: 0x0},
+ 748: {region: 0x123, script: 0x5, flags: 0x0},
+ 749: {region: 0xcc, script: 0x5a, flags: 0x0},
+ 750: {region: 0x165, script: 0x5a, flags: 0x0},
+ 751: {region: 0x165, script: 0x5a, flags: 0x0},
+ 752: {region: 0x165, script: 0x5a, flags: 0x0},
+ 753: {region: 0xbf, script: 0x5a, flags: 0x0},
+ 754: {region: 0xd1, script: 0x5a, flags: 0x0},
+ 755: {region: 0x165, script: 0x5a, flags: 0x0},
+ 756: {region: 0x52, script: 0x5a, flags: 0x0},
+ 757: {region: 0xdb, script: 0x22, flags: 0x0},
+ 758: {region: 0x12f, script: 0x5a, flags: 0x0},
+ 759: {region: 0xc0, script: 0x5a, flags: 0x0},
+ 760: {region: 0x165, script: 0x5a, flags: 0x0},
+ 761: {region: 0x165, script: 0x5a, flags: 0x0},
+ 762: {region: 0xe0, script: 0x5a, flags: 0x0},
+ 763: {region: 0x165, script: 0x5a, flags: 0x0},
+ 764: {region: 0x95, script: 0x5a, flags: 0x0},
+ 765: {region: 0x9b, script: 0x3d, flags: 0x0},
+ 766: {region: 0x165, script: 0x5a, flags: 0x0},
+ 767: {region: 0xc2, script: 0x20, flags: 0x0},
+ 768: {region: 0x165, script: 0x5, flags: 0x0},
+ 769: {region: 0x165, script: 0x5a, flags: 0x0},
+ 770: {region: 0x165, script: 0x5a, flags: 0x0},
+ 771: {region: 0x165, script: 0x5a, flags: 0x0},
+ 772: {region: 0x99, script: 0x6e, flags: 0x0},
+ 773: {region: 0x165, script: 0x5a, flags: 0x0},
+ 774: {region: 0x165, script: 0x5a, flags: 0x0},
+ 775: {region: 0x10b, script: 0x5a, flags: 0x0},
+ 776: {region: 0x165, script: 0x5a, flags: 0x0},
+ 777: {region: 0x165, script: 0x5a, flags: 0x0},
+ 778: {region: 0x165, script: 0x5a, flags: 0x0},
+ 779: {region: 0x26, script: 0x3, flags: 0x1},
+ 780: {region: 0x165, script: 0x5a, flags: 0x0},
+ 781: {region: 0x165, script: 0x5a, flags: 0x0},
+ 782: {region: 0x99, script: 0xe, flags: 0x0},
+ 783: {region: 0xc4, script: 0x75, flags: 0x0},
+ 785: {region: 0x165, script: 0x5a, flags: 0x0},
+ 786: {region: 0x49, script: 0x5a, flags: 0x0},
+ 787: {region: 0x49, script: 0x5a, flags: 0x0},
+ 788: {region: 0x37, script: 0x5a, flags: 0x0},
+ 789: {region: 0x165, script: 0x5a, flags: 0x0},
+ 790: {region: 0x165, script: 0x5a, flags: 0x0},
+ 791: {region: 0x165, script: 0x5a, flags: 0x0},
+ 792: {region: 0x165, script: 0x5a, flags: 0x0},
+ 793: {region: 0x165, script: 0x5a, flags: 0x0},
+ 794: {region: 0x165, script: 0x5a, flags: 0x0},
+ 795: {region: 0x99, script: 0x22, flags: 0x0},
+ 796: {region: 0xdb, script: 0x22, flags: 0x0},
+ 797: {region: 0x106, script: 0x20, flags: 0x0},
+ 798: {region: 0x35, script: 0x72, flags: 0x0},
+ 799: {region: 0x29, script: 0x3, flags: 0x1},
+ 800: {region: 0xcb, script: 0x5a, flags: 0x0},
+ 801: {region: 0x165, script: 0x5a, flags: 0x0},
+ 802: {region: 0x165, script: 0x5a, flags: 0x0},
+ 803: {region: 0x165, script: 0x5a, flags: 0x0},
+ 804: {region: 0x99, script: 0x22, flags: 0x0},
+ 805: {region: 0x52, script: 0x5a, flags: 0x0},
+ 807: {region: 0x165, script: 0x5a, flags: 0x0},
+ 808: {region: 0x135, script: 0x5a, flags: 0x0},
+ 809: {region: 0x165, script: 0x5a, flags: 0x0},
+ 810: {region: 0x165, script: 0x5a, flags: 0x0},
+ 811: {region: 0xe8, script: 0x5, flags: 0x0},
+ 812: {region: 0xc3, script: 0x5a, flags: 0x0},
+ 813: {region: 0x99, script: 0x22, flags: 0x0},
+ 814: {region: 0x95, script: 0x5a, flags: 0x0},
+ 815: {region: 0x164, script: 0x5a, flags: 0x0},
+ 816: {region: 0x165, script: 0x5a, flags: 0x0},
+ 817: {region: 0xc4, script: 0x75, flags: 0x0},
+ 818: {region: 0x165, script: 0x5a, flags: 0x0},
+ 819: {region: 0x165, script: 0x2c, flags: 0x0},
+ 820: {region: 0x106, script: 0x20, flags: 0x0},
+ 821: {region: 0x165, script: 0x5a, flags: 0x0},
+ 822: {region: 0x131, script: 0x5a, flags: 0x0},
+ 823: {region: 0x9c, script: 0x66, flags: 0x0},
+ 824: {region: 0x165, script: 0x5a, flags: 0x0},
+ 825: {region: 0x165, script: 0x5a, flags: 0x0},
+ 826: {region: 0x9c, script: 0x5, flags: 0x0},
+ 827: {region: 0x165, script: 0x5a, flags: 0x0},
+ 828: {region: 0x165, script: 0x5a, flags: 0x0},
+ 829: {region: 0x165, script: 0x5a, flags: 0x0},
+ 830: {region: 0xdd, script: 0x5a, flags: 0x0},
+ 831: {region: 0x165, script: 0x5a, flags: 0x0},
+ 832: {region: 0x165, script: 0x5a, flags: 0x0},
+ 834: {region: 0x165, script: 0x5a, flags: 0x0},
+ 835: {region: 0x53, script: 0x3b, flags: 0x0},
+ 836: {region: 0x9e, script: 0x5a, flags: 0x0},
+ 837: {region: 0xd2, script: 0x5a, flags: 0x0},
+ 838: {region: 0x165, script: 0x5a, flags: 0x0},
+ 839: {region: 0xda, script: 0x5a, flags: 0x0},
+ 840: {region: 0x165, script: 0x5a, flags: 0x0},
+ 841: {region: 0x165, script: 0x5a, flags: 0x0},
+ 842: {region: 0x165, script: 0x5a, flags: 0x0},
+ 843: {region: 0xcf, script: 0x5a, flags: 0x0},
+ 844: {region: 0x165, script: 0x5a, flags: 0x0},
+ 845: {region: 0x165, script: 0x5a, flags: 0x0},
+ 846: {region: 0x164, script: 0x5a, flags: 0x0},
+ 847: {region: 0xd1, script: 0x5a, flags: 0x0},
+ 848: {region: 0x60, script: 0x5a, flags: 0x0},
+ 849: {region: 0xdb, script: 0x22, flags: 0x0},
+ 850: {region: 0x165, script: 0x5a, flags: 0x0},
+ 851: {region: 0xdb, script: 0x22, flags: 0x0},
+ 852: {region: 0x165, script: 0x5a, flags: 0x0},
+ 853: {region: 0x165, script: 0x5a, flags: 0x0},
+ 854: {region: 0xd2, script: 0x5a, flags: 0x0},
+ 855: {region: 0x165, script: 0x5a, flags: 0x0},
+ 856: {region: 0x165, script: 0x5a, flags: 0x0},
+ 857: {region: 0xd1, script: 0x5a, flags: 0x0},
+ 858: {region: 0x165, script: 0x5a, flags: 0x0},
+ 859: {region: 0xcf, script: 0x5a, flags: 0x0},
+ 860: {region: 0xcf, script: 0x5a, flags: 0x0},
+ 861: {region: 0x165, script: 0x5a, flags: 0x0},
+ 862: {region: 0x165, script: 0x5a, flags: 0x0},
+ 863: {region: 0x95, script: 0x5a, flags: 0x0},
+ 864: {region: 0x165, script: 0x5a, flags: 0x0},
+ 865: {region: 0xdf, script: 0x5a, flags: 0x0},
+ 866: {region: 0x165, script: 0x5a, flags: 0x0},
+ 867: {region: 0x165, script: 0x5a, flags: 0x0},
+ 868: {region: 0x99, script: 0x5a, flags: 0x0},
+ 869: {region: 0x165, script: 0x5a, flags: 0x0},
+ 870: {region: 0x165, script: 0x5a, flags: 0x0},
+ 871: {region: 0xd9, script: 0x5a, flags: 0x0},
+ 872: {region: 0x52, script: 0x5a, flags: 0x0},
+ 873: {region: 0x165, script: 0x5a, flags: 0x0},
+ 874: {region: 0xda, script: 0x5a, flags: 0x0},
+ 875: {region: 0x165, script: 0x5a, flags: 0x0},
+ 876: {region: 0x52, script: 0x5a, flags: 0x0},
+ 877: {region: 0x165, script: 0x5a, flags: 0x0},
+ 878: {region: 0x165, script: 0x5a, flags: 0x0},
+ 879: {region: 0xda, script: 0x5a, flags: 0x0},
+ 880: {region: 0x123, script: 0x56, flags: 0x0},
+ 881: {region: 0x99, script: 0x22, flags: 0x0},
+ 882: {region: 0x10c, script: 0xc9, flags: 0x0},
+ 883: {region: 0x165, script: 0x5a, flags: 0x0},
+ 884: {region: 0x165, script: 0x5a, flags: 0x0},
+ 885: {region: 0x84, script: 0x7c, flags: 0x0},
+ 886: {region: 0x161, script: 0x5a, flags: 0x0},
+ 887: {region: 0x165, script: 0x5a, flags: 0x0},
+ 888: {region: 0x49, script: 0x17, flags: 0x0},
+ 889: {region: 0x165, script: 0x5a, flags: 0x0},
+ 890: {region: 0x161, script: 0x5a, flags: 0x0},
+ 891: {region: 0x165, script: 0x5a, flags: 0x0},
+ 892: {region: 0x165, script: 0x5a, flags: 0x0},
+ 893: {region: 0x165, script: 0x5a, flags: 0x0},
+ 894: {region: 0x165, script: 0x5a, flags: 0x0},
+ 895: {region: 0x165, script: 0x5a, flags: 0x0},
+ 896: {region: 0x117, script: 0x5a, flags: 0x0},
+ 897: {region: 0x165, script: 0x5a, flags: 0x0},
+ 898: {region: 0x165, script: 0x5a, flags: 0x0},
+ 899: {region: 0x135, script: 0x5a, flags: 0x0},
+ 900: {region: 0x165, script: 0x5a, flags: 0x0},
+ 901: {region: 0x53, script: 0x5a, flags: 0x0},
+ 902: {region: 0x165, script: 0x5a, flags: 0x0},
+ 903: {region: 0xce, script: 0x5a, flags: 0x0},
+ 904: {region: 0x12f, script: 0x5a, flags: 0x0},
+ 905: {region: 0x131, script: 0x5a, flags: 0x0},
+ 906: {region: 0x80, script: 0x5a, flags: 0x0},
+ 907: {region: 0x78, script: 0x5a, flags: 0x0},
+ 908: {region: 0x165, script: 0x5a, flags: 0x0},
+ 910: {region: 0x165, script: 0x5a, flags: 0x0},
+ 911: {region: 0x165, script: 0x5a, flags: 0x0},
+ 912: {region: 0x6f, script: 0x5a, flags: 0x0},
+ 913: {region: 0x165, script: 0x5a, flags: 0x0},
+ 914: {region: 0x165, script: 0x5a, flags: 0x0},
+ 915: {region: 0x165, script: 0x5a, flags: 0x0},
+ 916: {region: 0x165, script: 0x5a, flags: 0x0},
+ 917: {region: 0x99, script: 0x81, flags: 0x0},
+ 918: {region: 0x165, script: 0x5a, flags: 0x0},
+ 919: {region: 0x165, script: 0x5, flags: 0x0},
+ 920: {region: 0x7d, script: 0x20, flags: 0x0},
+ 921: {region: 0x135, script: 0x82, flags: 0x0},
+ 922: {region: 0x165, script: 0x5, flags: 0x0},
+ 923: {region: 0xc5, script: 0x80, flags: 0x0},
+ 924: {region: 0x165, script: 0x5a, flags: 0x0},
+ 925: {region: 0x2c, script: 0x3, flags: 0x1},
+ 926: {region: 0xe7, script: 0x5a, flags: 0x0},
+ 927: {region: 0x2f, script: 0x2, flags: 0x1},
+ 928: {region: 0xe7, script: 0x5a, flags: 0x0},
+ 929: {region: 0x30, script: 0x5a, flags: 0x0},
+ 930: {region: 0xf0, script: 0x5a, flags: 0x0},
+ 931: {region: 0x165, script: 0x5a, flags: 0x0},
+ 932: {region: 0x78, script: 0x5a, flags: 0x0},
+ 933: {region: 0xd6, script: 0x5a, flags: 0x0},
+ 934: {region: 0x135, script: 0x5a, flags: 0x0},
+ 935: {region: 0x49, script: 0x5a, flags: 0x0},
+ 936: {region: 0x165, script: 0x5a, flags: 0x0},
+ 937: {region: 0x9c, script: 0xf7, flags: 0x0},
+ 938: {region: 0x165, script: 0x5a, flags: 0x0},
+ 939: {region: 0x60, script: 0x5a, flags: 0x0},
+ 940: {region: 0x165, script: 0x5, flags: 0x0},
+ 941: {region: 0xb0, script: 0x8e, flags: 0x0},
+ 943: {region: 0x165, script: 0x5a, flags: 0x0},
+ 944: {region: 0x165, script: 0x5a, flags: 0x0},
+ 945: {region: 0x99, script: 0x12, flags: 0x0},
+ 946: {region: 0xa4, script: 0x5a, flags: 0x0},
+ 947: {region: 0xe9, script: 0x5a, flags: 0x0},
+ 948: {region: 0x165, script: 0x5a, flags: 0x0},
+ 949: {region: 0x9e, script: 0x5a, flags: 0x0},
+ 950: {region: 0x165, script: 0x5a, flags: 0x0},
+ 951: {region: 0x165, script: 0x5a, flags: 0x0},
+ 952: {region: 0x87, script: 0x34, flags: 0x0},
+ 953: {region: 0x75, script: 0x5a, flags: 0x0},
+ 954: {region: 0x165, script: 0x5a, flags: 0x0},
+ 955: {region: 0xe8, script: 0x4d, flags: 0x0},
+ 956: {region: 0x9c, script: 0x5, flags: 0x0},
+ 957: {region: 0x1, script: 0x5a, flags: 0x0},
+ 958: {region: 0x24, script: 0x5, flags: 0x0},
+ 959: {region: 0x165, script: 0x5a, flags: 0x0},
+ 960: {region: 0x41, script: 0x5a, flags: 0x0},
+ 961: {region: 0x165, script: 0x5a, flags: 0x0},
+ 962: {region: 0x7a, script: 0x5a, flags: 0x0},
+ 963: {region: 0x165, script: 0x5a, flags: 0x0},
+ 964: {region: 0xe4, script: 0x5a, flags: 0x0},
+ 965: {region: 0x89, script: 0x5a, flags: 0x0},
+ 966: {region: 0x69, script: 0x5a, flags: 0x0},
+ 967: {region: 0x165, script: 0x5a, flags: 0x0},
+ 968: {region: 0x99, script: 0x22, flags: 0x0},
+ 969: {region: 0x165, script: 0x5a, flags: 0x0},
+ 970: {region: 0x102, script: 0x5a, flags: 0x0},
+ 971: {region: 0x95, script: 0x5a, flags: 0x0},
+ 972: {region: 0x165, script: 0x5a, flags: 0x0},
+ 973: {region: 0x165, script: 0x5a, flags: 0x0},
+ 974: {region: 0x9e, script: 0x5a, flags: 0x0},
+ 975: {region: 0x165, script: 0x5, flags: 0x0},
+ 976: {region: 0x99, script: 0x5a, flags: 0x0},
+ 977: {region: 0x31, script: 0x2, flags: 0x1},
+ 978: {region: 0xdb, script: 0x22, flags: 0x0},
+ 979: {region: 0x35, script: 0xe, flags: 0x0},
+ 980: {region: 0x4e, script: 0x5a, flags: 0x0},
+ 981: {region: 0x72, script: 0x5a, flags: 0x0},
+ 982: {region: 0x4e, script: 0x5a, flags: 0x0},
+ 983: {region: 0x9c, script: 0x5, flags: 0x0},
+ 984: {region: 0x10c, script: 0x5a, flags: 0x0},
+ 985: {region: 0x3a, script: 0x5a, flags: 0x0},
+ 986: {region: 0x165, script: 0x5a, flags: 0x0},
+ 987: {region: 0xd1, script: 0x5a, flags: 0x0},
+ 988: {region: 0x104, script: 0x5a, flags: 0x0},
+ 989: {region: 0x95, script: 0x5a, flags: 0x0},
+ 990: {region: 0x12f, script: 0x5a, flags: 0x0},
+ 991: {region: 0x165, script: 0x5a, flags: 0x0},
+ 992: {region: 0x165, script: 0x5a, flags: 0x0},
+ 993: {region: 0x73, script: 0x5a, flags: 0x0},
+ 994: {region: 0x106, script: 0x20, flags: 0x0},
+ 995: {region: 0x130, script: 0x20, flags: 0x0},
+ 996: {region: 0x109, script: 0x5a, flags: 0x0},
+ 997: {region: 0x107, script: 0x5a, flags: 0x0},
+ 998: {region: 0x12f, script: 0x5a, flags: 0x0},
+ 999: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1000: {region: 0xa2, script: 0x4c, flags: 0x0},
+ 1001: {region: 0x99, script: 0x22, flags: 0x0},
+ 1002: {region: 0x80, script: 0x5a, flags: 0x0},
+ 1003: {region: 0x106, script: 0x20, flags: 0x0},
+ 1004: {region: 0xa4, script: 0x5a, flags: 0x0},
+ 1005: {region: 0x95, script: 0x5a, flags: 0x0},
+ 1006: {region: 0x99, script: 0x5a, flags: 0x0},
+ 1007: {region: 0x114, script: 0x5a, flags: 0x0},
+ 1008: {region: 0x99, script: 0xcd, flags: 0x0},
+ 1009: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1010: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1011: {region: 0x12f, script: 0x5a, flags: 0x0},
+ 1012: {region: 0x9e, script: 0x5a, flags: 0x0},
+ 1013: {region: 0x99, script: 0x22, flags: 0x0},
+ 1014: {region: 0x165, script: 0x5, flags: 0x0},
+ 1015: {region: 0x9e, script: 0x5a, flags: 0x0},
+ 1016: {region: 0x7b, script: 0x5a, flags: 0x0},
+ 1017: {region: 0x49, script: 0x5a, flags: 0x0},
+ 1018: {region: 0x33, script: 0x4, flags: 0x1},
+ 1019: {region: 0x9e, script: 0x5a, flags: 0x0},
+ 1020: {region: 0x9c, script: 0x5, flags: 0x0},
+ 1021: {region: 0xda, script: 0x5a, flags: 0x0},
+ 1022: {region: 0x4f, script: 0x5a, flags: 0x0},
+ 1023: {region: 0xd1, script: 0x5a, flags: 0x0},
+ 1024: {region: 0xcf, script: 0x5a, flags: 0x0},
+ 1025: {region: 0xc3, script: 0x5a, flags: 0x0},
+ 1026: {region: 0x4c, script: 0x5a, flags: 0x0},
+ 1027: {region: 0x96, script: 0x7e, flags: 0x0},
+ 1028: {region: 0xb6, script: 0x5a, flags: 0x0},
+ 1029: {region: 0x165, script: 0x2c, flags: 0x0},
+ 1030: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1032: {region: 0xba, script: 0xe8, flags: 0x0},
+ 1033: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1034: {region: 0xc4, script: 0x75, flags: 0x0},
+ 1035: {region: 0x165, script: 0x5, flags: 0x0},
+ 1036: {region: 0xb3, script: 0xd4, flags: 0x0},
+ 1037: {region: 0x6f, script: 0x5a, flags: 0x0},
+ 1038: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1039: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1040: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1041: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1042: {region: 0x111, script: 0x5a, flags: 0x0},
+ 1043: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1044: {region: 0xe8, script: 0x5, flags: 0x0},
+ 1045: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1046: {region: 0x10f, script: 0x5a, flags: 0x0},
+ 1047: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1048: {region: 0xe9, script: 0x5a, flags: 0x0},
+ 1049: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1050: {region: 0x95, script: 0x5a, flags: 0x0},
+ 1051: {region: 0x142, script: 0x5a, flags: 0x0},
+ 1052: {region: 0x10c, script: 0x5a, flags: 0x0},
+ 1054: {region: 0x10c, script: 0x5a, flags: 0x0},
+ 1055: {region: 0x72, script: 0x5a, flags: 0x0},
+ 1056: {region: 0x97, script: 0xca, flags: 0x0},
+ 1057: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1058: {region: 0x72, script: 0x5a, flags: 0x0},
+ 1059: {region: 0x164, script: 0x5a, flags: 0x0},
+ 1060: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1061: {region: 0xc3, script: 0x5a, flags: 0x0},
+ 1062: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1063: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1064: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1065: {region: 0x115, script: 0x5a, flags: 0x0},
+ 1066: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1067: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1068: {region: 0x123, script: 0xeb, flags: 0x0},
+ 1069: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1070: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1071: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1072: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1073: {region: 0x27, script: 0x5a, flags: 0x0},
+ 1074: {region: 0x37, script: 0x5, flags: 0x1},
+ 1075: {region: 0x99, script: 0xd7, flags: 0x0},
+ 1076: {region: 0x116, script: 0x5a, flags: 0x0},
+ 1077: {region: 0x114, script: 0x5a, flags: 0x0},
+ 1078: {region: 0x99, script: 0x22, flags: 0x0},
+ 1079: {region: 0x161, script: 0x5a, flags: 0x0},
+ 1080: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1081: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1082: {region: 0x6d, script: 0x5a, flags: 0x0},
+ 1083: {region: 0x161, script: 0x5a, flags: 0x0},
+ 1084: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1085: {region: 0x60, script: 0x5a, flags: 0x0},
+ 1086: {region: 0x95, script: 0x5a, flags: 0x0},
+ 1087: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1088: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1089: {region: 0x12f, script: 0x5a, flags: 0x0},
+ 1090: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1091: {region: 0x84, script: 0x5a, flags: 0x0},
+ 1092: {region: 0x10c, script: 0x5a, flags: 0x0},
+ 1093: {region: 0x12f, script: 0x5a, flags: 0x0},
+ 1094: {region: 0x15f, script: 0x5, flags: 0x0},
+ 1095: {region: 0x4b, script: 0x5a, flags: 0x0},
+ 1096: {region: 0x60, script: 0x5a, flags: 0x0},
+ 1097: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1098: {region: 0x99, script: 0x22, flags: 0x0},
+ 1099: {region: 0x95, script: 0x5a, flags: 0x0},
+ 1100: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1101: {region: 0x35, script: 0xe, flags: 0x0},
+ 1102: {region: 0x9b, script: 0xdb, flags: 0x0},
+ 1103: {region: 0xe9, script: 0x5a, flags: 0x0},
+ 1104: {region: 0x99, script: 0xe3, flags: 0x0},
+ 1105: {region: 0xdb, script: 0x22, flags: 0x0},
+ 1106: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1107: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1108: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1109: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1110: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1111: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1112: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1113: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1114: {region: 0xe7, script: 0x5a, flags: 0x0},
+ 1115: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1116: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1117: {region: 0x99, script: 0x52, flags: 0x0},
+ 1118: {region: 0x53, script: 0xe1, flags: 0x0},
+ 1119: {region: 0xdb, script: 0x22, flags: 0x0},
+ 1120: {region: 0xdb, script: 0x22, flags: 0x0},
+ 1121: {region: 0x99, script: 0xe6, flags: 0x0},
+ 1122: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1123: {region: 0x112, script: 0x5a, flags: 0x0},
+ 1124: {region: 0x131, script: 0x5a, flags: 0x0},
+ 1125: {region: 0x126, script: 0x5a, flags: 0x0},
+ 1126: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1127: {region: 0x3c, script: 0x3, flags: 0x1},
+ 1128: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1129: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1130: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1131: {region: 0x123, script: 0xeb, flags: 0x0},
+ 1132: {region: 0xdb, script: 0x22, flags: 0x0},
+ 1133: {region: 0xdb, script: 0x22, flags: 0x0},
+ 1134: {region: 0xdb, script: 0x22, flags: 0x0},
+ 1135: {region: 0x6f, script: 0x2c, flags: 0x0},
+ 1136: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1137: {region: 0x6d, script: 0x2c, flags: 0x0},
+ 1138: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1139: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1140: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1141: {region: 0xd6, script: 0x5a, flags: 0x0},
+ 1142: {region: 0x127, script: 0x5a, flags: 0x0},
+ 1143: {region: 0x125, script: 0x5a, flags: 0x0},
+ 1144: {region: 0x32, script: 0x5a, flags: 0x0},
+ 1145: {region: 0xdb, script: 0x22, flags: 0x0},
+ 1146: {region: 0xe7, script: 0x5a, flags: 0x0},
+ 1147: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1148: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1149: {region: 0x32, script: 0x5a, flags: 0x0},
+ 1150: {region: 0xd4, script: 0x5a, flags: 0x0},
+ 1151: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1152: {region: 0x161, script: 0x5a, flags: 0x0},
+ 1153: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1154: {region: 0x129, script: 0x5a, flags: 0x0},
+ 1155: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1156: {region: 0xce, script: 0x5a, flags: 0x0},
+ 1157: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1158: {region: 0xe6, script: 0x5a, flags: 0x0},
+ 1159: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1160: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1161: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1162: {region: 0x12b, script: 0x5a, flags: 0x0},
+ 1163: {region: 0x12b, script: 0x5a, flags: 0x0},
+ 1164: {region: 0x12e, script: 0x5a, flags: 0x0},
+ 1165: {region: 0x165, script: 0x5, flags: 0x0},
+ 1166: {region: 0x161, script: 0x5a, flags: 0x0},
+ 1167: {region: 0x87, script: 0x34, flags: 0x0},
+ 1168: {region: 0xdb, script: 0x22, flags: 0x0},
+ 1169: {region: 0xe7, script: 0x5a, flags: 0x0},
+ 1170: {region: 0x43, script: 0xec, flags: 0x0},
+ 1171: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1172: {region: 0x106, script: 0x20, flags: 0x0},
+ 1173: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1174: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1175: {region: 0x131, script: 0x5a, flags: 0x0},
+ 1176: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1177: {region: 0x123, script: 0xeb, flags: 0x0},
+ 1178: {region: 0x32, script: 0x5a, flags: 0x0},
+ 1179: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1180: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1181: {region: 0xce, script: 0x5a, flags: 0x0},
+ 1182: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1183: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1184: {region: 0x12d, script: 0x5a, flags: 0x0},
+ 1185: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1187: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1188: {region: 0xd4, script: 0x5a, flags: 0x0},
+ 1189: {region: 0x53, script: 0xe4, flags: 0x0},
+ 1190: {region: 0xe5, script: 0x5a, flags: 0x0},
+ 1191: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1192: {region: 0x106, script: 0x20, flags: 0x0},
+ 1193: {region: 0xba, script: 0x5a, flags: 0x0},
+ 1194: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1195: {region: 0x106, script: 0x20, flags: 0x0},
+ 1196: {region: 0x3f, script: 0x4, flags: 0x1},
+ 1197: {region: 0x11c, script: 0xf0, flags: 0x0},
+ 1198: {region: 0x130, script: 0x20, flags: 0x0},
+ 1199: {region: 0x75, script: 0x5a, flags: 0x0},
+ 1200: {region: 0x2a, script: 0x5a, flags: 0x0},
+ 1202: {region: 0x43, script: 0x3, flags: 0x1},
+ 1203: {region: 0x99, script: 0xe, flags: 0x0},
+ 1204: {region: 0xe8, script: 0x5, flags: 0x0},
+ 1205: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1206: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1207: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1208: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1209: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1210: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1211: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1212: {region: 0x46, script: 0x4, flags: 0x1},
+ 1213: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1214: {region: 0xb4, script: 0xf1, flags: 0x0},
+ 1215: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1216: {region: 0x161, script: 0x5a, flags: 0x0},
+ 1217: {region: 0x9e, script: 0x5a, flags: 0x0},
+ 1218: {region: 0x106, script: 0x5a, flags: 0x0},
+ 1219: {region: 0x13e, script: 0x5a, flags: 0x0},
+ 1220: {region: 0x11b, script: 0x5a, flags: 0x0},
+ 1221: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1222: {region: 0x36, script: 0x5a, flags: 0x0},
+ 1223: {region: 0x60, script: 0x5a, flags: 0x0},
+ 1224: {region: 0xd1, script: 0x5a, flags: 0x0},
+ 1225: {region: 0x1, script: 0x5a, flags: 0x0},
+ 1226: {region: 0x106, script: 0x5a, flags: 0x0},
+ 1227: {region: 0x6a, script: 0x5a, flags: 0x0},
+ 1228: {region: 0x12f, script: 0x5a, flags: 0x0},
+ 1229: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1230: {region: 0x36, script: 0x5a, flags: 0x0},
+ 1231: {region: 0x4e, script: 0x5a, flags: 0x0},
+ 1232: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1233: {region: 0x6f, script: 0x2c, flags: 0x0},
+ 1234: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1235: {region: 0xe7, script: 0x5a, flags: 0x0},
+ 1236: {region: 0x2f, script: 0x5a, flags: 0x0},
+ 1237: {region: 0x99, script: 0xe6, flags: 0x0},
+ 1238: {region: 0x99, script: 0x22, flags: 0x0},
+ 1239: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1240: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1241: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1242: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1243: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1244: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1245: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1246: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1247: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1248: {region: 0x140, script: 0x5a, flags: 0x0},
+ 1249: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1250: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1251: {region: 0xa8, script: 0x5, flags: 0x0},
+ 1252: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1253: {region: 0x114, script: 0x5a, flags: 0x0},
+ 1254: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1255: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1256: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1257: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1258: {region: 0x99, script: 0x22, flags: 0x0},
+ 1259: {region: 0x53, script: 0x3b, flags: 0x0},
+ 1260: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1261: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1262: {region: 0x41, script: 0x5a, flags: 0x0},
+ 1263: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1264: {region: 0x12b, script: 0x18, flags: 0x0},
+ 1265: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1266: {region: 0x161, script: 0x5a, flags: 0x0},
+ 1267: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1268: {region: 0x12b, script: 0x62, flags: 0x0},
+ 1269: {region: 0x12b, script: 0x63, flags: 0x0},
+ 1270: {region: 0x7d, script: 0x2e, flags: 0x0},
+ 1271: {region: 0x53, script: 0x67, flags: 0x0},
+ 1272: {region: 0x10b, script: 0x6c, flags: 0x0},
+ 1273: {region: 0x108, script: 0x77, flags: 0x0},
+ 1274: {region: 0x99, script: 0x22, flags: 0x0},
+ 1275: {region: 0x131, script: 0x5a, flags: 0x0},
+ 1276: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1277: {region: 0x9c, script: 0x91, flags: 0x0},
+ 1278: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1279: {region: 0x15e, script: 0xcc, flags: 0x0},
+ 1280: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1281: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1282: {region: 0xdb, script: 0x22, flags: 0x0},
+ 1283: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1284: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1285: {region: 0xd1, script: 0x5a, flags: 0x0},
+ 1286: {region: 0x75, script: 0x5a, flags: 0x0},
+ 1287: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1288: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1289: {region: 0x52, script: 0x5a, flags: 0x0},
+ 1290: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1291: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1292: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1293: {region: 0x52, script: 0x5a, flags: 0x0},
+ 1294: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1295: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1296: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1297: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1298: {region: 0x1, script: 0x3e, flags: 0x0},
+ 1299: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1300: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1301: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1302: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1303: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1304: {region: 0xd6, script: 0x5a, flags: 0x0},
+ 1305: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1306: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1307: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1308: {region: 0x41, script: 0x5a, flags: 0x0},
+ 1309: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1310: {region: 0xcf, script: 0x5a, flags: 0x0},
+ 1311: {region: 0x4a, script: 0x3, flags: 0x1},
+ 1312: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1313: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1314: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1315: {region: 0x53, script: 0x5a, flags: 0x0},
+ 1316: {region: 0x10b, script: 0x5a, flags: 0x0},
+ 1318: {region: 0xa8, script: 0x5, flags: 0x0},
+ 1319: {region: 0xd9, script: 0x5a, flags: 0x0},
+ 1320: {region: 0xba, script: 0xe8, flags: 0x0},
+ 1321: {region: 0x4d, script: 0x14, flags: 0x1},
+ 1322: {region: 0x53, script: 0x7d, flags: 0x0},
+ 1323: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1324: {region: 0x122, script: 0x5a, flags: 0x0},
+ 1325: {region: 0xd0, script: 0x5a, flags: 0x0},
+ 1326: {region: 0x165, script: 0x5a, flags: 0x0},
+ 1327: {region: 0x161, script: 0x5a, flags: 0x0},
+ 1329: {region: 0x12b, script: 0x5a, flags: 0x0},
+}
+
+// likelyLangList holds lists info associated with likelyLang.
+// Size: 582 bytes, 97 elements
+var likelyLangList = [97]likelyScriptRegion{
+ 0: {region: 0x9c, script: 0x7, flags: 0x0},
+ 1: {region: 0xa1, script: 0x78, flags: 0x2},
+ 2: {region: 0x11c, script: 0x85, flags: 0x2},
+ 3: {region: 0x32, script: 0x5a, flags: 0x0},
+ 4: {region: 0x9b, script: 0x5, flags: 0x4},
+ 5: {region: 0x9c, script: 0x5, flags: 0x4},
+ 6: {region: 0x106, script: 0x20, flags: 0x4},
+ 7: {region: 0x9c, script: 0x5, flags: 0x2},
+ 8: {region: 0x106, script: 0x20, flags: 0x0},
+ 9: {region: 0x38, script: 0x2f, flags: 0x2},
+ 10: {region: 0x135, script: 0x5a, flags: 0x0},
+ 11: {region: 0x7b, script: 0xcf, flags: 0x2},
+ 12: {region: 0x114, script: 0x5a, flags: 0x0},
+ 13: {region: 0x84, script: 0x1, flags: 0x2},
+ 14: {region: 0x5d, script: 0x1f, flags: 0x0},
+ 15: {region: 0x87, script: 0x5f, flags: 0x2},
+ 16: {region: 0xd6, script: 0x5a, flags: 0x0},
+ 17: {region: 0x52, script: 0x5, flags: 0x4},
+ 18: {region: 0x10b, script: 0x5, flags: 0x4},
+ 19: {region: 0xae, script: 0x20, flags: 0x0},
+ 20: {region: 0x24, script: 0x5, flags: 0x4},
+ 21: {region: 0x53, script: 0x5, flags: 0x4},
+ 22: {region: 0x9c, script: 0x5, flags: 0x4},
+ 23: {region: 0xc5, script: 0x5, flags: 0x4},
+ 24: {region: 0x53, script: 0x5, flags: 0x2},
+ 25: {region: 0x12b, script: 0x5a, flags: 0x0},
+ 26: {region: 0xb0, script: 0x5, flags: 0x4},
+ 27: {region: 0x9b, script: 0x5, flags: 0x2},
+ 28: {region: 0xa5, script: 0x20, flags: 0x0},
+ 29: {region: 0x53, script: 0x5, flags: 0x4},
+ 30: {region: 0x12b, script: 0x5a, flags: 0x4},
+ 31: {region: 0x53, script: 0x5, flags: 0x2},
+ 32: {region: 0x12b, script: 0x5a, flags: 0x2},
+ 33: {region: 0xdb, script: 0x22, flags: 0x0},
+ 34: {region: 0x99, script: 0x5d, flags: 0x2},
+ 35: {region: 0x83, script: 0x5a, flags: 0x0},
+ 36: {region: 0x84, script: 0x7c, flags: 0x4},
+ 37: {region: 0x84, script: 0x7c, flags: 0x2},
+ 38: {region: 0xc5, script: 0x20, flags: 0x0},
+ 39: {region: 0x53, script: 0x70, flags: 0x4},
+ 40: {region: 0x53, script: 0x70, flags: 0x2},
+ 41: {region: 0xd0, script: 0x5a, flags: 0x0},
+ 42: {region: 0x4a, script: 0x5, flags: 0x4},
+ 43: {region: 0x95, script: 0x5, flags: 0x4},
+ 44: {region: 0x99, script: 0x36, flags: 0x0},
+ 45: {region: 0xe8, script: 0x5, flags: 0x4},
+ 46: {region: 0xe8, script: 0x5, flags: 0x2},
+ 47: {region: 0x9c, script: 0x8b, flags: 0x0},
+ 48: {region: 0x53, script: 0x8c, flags: 0x2},
+ 49: {region: 0xba, script: 0xe8, flags: 0x0},
+ 50: {region: 0xd9, script: 0x5a, flags: 0x4},
+ 51: {region: 0xe8, script: 0x5, flags: 0x0},
+ 52: {region: 0x99, script: 0x22, flags: 0x2},
+ 53: {region: 0x99, script: 0x4f, flags: 0x2},
+ 54: {region: 0x99, script: 0xd3, flags: 0x2},
+ 55: {region: 0x105, script: 0x20, flags: 0x0},
+ 56: {region: 0xbd, script: 0x5a, flags: 0x4},
+ 57: {region: 0x104, script: 0x5a, flags: 0x4},
+ 58: {region: 0x106, script: 0x5a, flags: 0x4},
+ 59: {region: 0x12b, script: 0x5a, flags: 0x4},
+ 60: {region: 0x124, script: 0x20, flags: 0x0},
+ 61: {region: 0xe8, script: 0x5, flags: 0x4},
+ 62: {region: 0xe8, script: 0x5, flags: 0x2},
+ 63: {region: 0x53, script: 0x5, flags: 0x0},
+ 64: {region: 0xae, script: 0x20, flags: 0x4},
+ 65: {region: 0xc5, script: 0x20, flags: 0x4},
+ 66: {region: 0xae, script: 0x20, flags: 0x2},
+ 67: {region: 0x99, script: 0xe, flags: 0x0},
+ 68: {region: 0xdb, script: 0x22, flags: 0x4},
+ 69: {region: 0xdb, script: 0x22, flags: 0x2},
+ 70: {region: 0x137, script: 0x5a, flags: 0x0},
+ 71: {region: 0x24, script: 0x5, flags: 0x4},
+ 72: {region: 0x53, script: 0x20, flags: 0x4},
+ 73: {region: 0x24, script: 0x5, flags: 0x2},
+ 74: {region: 0x8d, script: 0x3c, flags: 0x0},
+ 75: {region: 0x53, script: 0x3b, flags: 0x4},
+ 76: {region: 0x53, script: 0x3b, flags: 0x2},
+ 77: {region: 0x53, script: 0x3b, flags: 0x0},
+ 78: {region: 0x2f, script: 0x3c, flags: 0x4},
+ 79: {region: 0x3e, script: 0x3c, flags: 0x4},
+ 80: {region: 0x7b, script: 0x3c, flags: 0x4},
+ 81: {region: 0x7e, script: 0x3c, flags: 0x4},
+ 82: {region: 0x8d, script: 0x3c, flags: 0x4},
+ 83: {region: 0x95, script: 0x3c, flags: 0x4},
+ 84: {region: 0xc6, script: 0x3c, flags: 0x4},
+ 85: {region: 0xd0, script: 0x3c, flags: 0x4},
+ 86: {region: 0xe2, script: 0x3c, flags: 0x4},
+ 87: {region: 0xe5, script: 0x3c, flags: 0x4},
+ 88: {region: 0xe7, script: 0x3c, flags: 0x4},
+ 89: {region: 0x116, script: 0x3c, flags: 0x4},
+ 90: {region: 0x123, script: 0x3c, flags: 0x4},
+ 91: {region: 0x12e, script: 0x3c, flags: 0x4},
+ 92: {region: 0x135, script: 0x3c, flags: 0x4},
+ 93: {region: 0x13e, script: 0x3c, flags: 0x4},
+ 94: {region: 0x12e, script: 0x11, flags: 0x2},
+ 95: {region: 0x12e, script: 0x37, flags: 0x2},
+ 96: {region: 0x12e, script: 0x3c, flags: 0x2},
+}
+
+type likelyLangScript struct {
+ lang uint16
+ script uint16
+ flags uint8
+}
+
+// likelyRegion is a lookup table, indexed by regionID, for the most likely
+// languages and scripts given incomplete information. If more entries exist
+// for a given regionID, lang and script are the index and size respectively
+// of the list in likelyRegionList.
+// TODO: exclude containers and user-definable regions from the list.
+// Size: 2148 bytes, 358 elements
+var likelyRegion = [358]likelyLangScript{
+ 34: {lang: 0xd7, script: 0x5a, flags: 0x0},
+ 35: {lang: 0x3a, script: 0x5, flags: 0x0},
+ 36: {lang: 0x0, script: 0x2, flags: 0x1},
+ 39: {lang: 0x2, script: 0x2, flags: 0x1},
+ 40: {lang: 0x4, script: 0x2, flags: 0x1},
+ 42: {lang: 0x3c0, script: 0x5a, flags: 0x0},
+ 43: {lang: 0x0, script: 0x5a, flags: 0x0},
+ 44: {lang: 0x13e, script: 0x5a, flags: 0x0},
+ 45: {lang: 0x41b, script: 0x5a, flags: 0x0},
+ 46: {lang: 0x10d, script: 0x5a, flags: 0x0},
+ 48: {lang: 0x367, script: 0x5a, flags: 0x0},
+ 49: {lang: 0x444, script: 0x5a, flags: 0x0},
+ 50: {lang: 0x58, script: 0x5a, flags: 0x0},
+ 51: {lang: 0x6, script: 0x2, flags: 0x1},
+ 53: {lang: 0xa5, script: 0xe, flags: 0x0},
+ 54: {lang: 0x367, script: 0x5a, flags: 0x0},
+ 55: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 56: {lang: 0x7e, script: 0x20, flags: 0x0},
+ 57: {lang: 0x3a, script: 0x5, flags: 0x0},
+ 58: {lang: 0x3d9, script: 0x5a, flags: 0x0},
+ 59: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 60: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 62: {lang: 0x31f, script: 0x5a, flags: 0x0},
+ 63: {lang: 0x13e, script: 0x5a, flags: 0x0},
+ 64: {lang: 0x3a1, script: 0x5a, flags: 0x0},
+ 65: {lang: 0x3c0, script: 0x5a, flags: 0x0},
+ 67: {lang: 0x8, script: 0x2, flags: 0x1},
+ 69: {lang: 0x0, script: 0x5a, flags: 0x0},
+ 71: {lang: 0x71, script: 0x20, flags: 0x0},
+ 73: {lang: 0x512, script: 0x3e, flags: 0x2},
+ 74: {lang: 0x31f, script: 0x5, flags: 0x2},
+ 75: {lang: 0x445, script: 0x5a, flags: 0x0},
+ 76: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 77: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 78: {lang: 0x10d, script: 0x5a, flags: 0x0},
+ 79: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 81: {lang: 0x13e, script: 0x5a, flags: 0x0},
+ 82: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 83: {lang: 0xa, script: 0x4, flags: 0x1},
+ 84: {lang: 0x13e, script: 0x5a, flags: 0x0},
+ 85: {lang: 0x0, script: 0x5a, flags: 0x0},
+ 86: {lang: 0x13e, script: 0x5a, flags: 0x0},
+ 89: {lang: 0x13e, script: 0x5a, flags: 0x0},
+ 90: {lang: 0x3c0, script: 0x5a, flags: 0x0},
+ 91: {lang: 0x3a1, script: 0x5a, flags: 0x0},
+ 93: {lang: 0xe, script: 0x2, flags: 0x1},
+ 94: {lang: 0xfa, script: 0x5a, flags: 0x0},
+ 96: {lang: 0x10d, script: 0x5a, flags: 0x0},
+ 98: {lang: 0x1, script: 0x5a, flags: 0x0},
+ 99: {lang: 0x101, script: 0x5a, flags: 0x0},
+ 101: {lang: 0x13e, script: 0x5a, flags: 0x0},
+ 103: {lang: 0x10, script: 0x2, flags: 0x1},
+ 104: {lang: 0x13e, script: 0x5a, flags: 0x0},
+ 105: {lang: 0x13e, script: 0x5a, flags: 0x0},
+ 106: {lang: 0x140, script: 0x5a, flags: 0x0},
+ 107: {lang: 0x3a, script: 0x5, flags: 0x0},
+ 108: {lang: 0x3a, script: 0x5, flags: 0x0},
+ 109: {lang: 0x46f, script: 0x2c, flags: 0x0},
+ 110: {lang: 0x13e, script: 0x5a, flags: 0x0},
+ 111: {lang: 0x12, script: 0x2, flags: 0x1},
+ 113: {lang: 0x10d, script: 0x5a, flags: 0x0},
+ 114: {lang: 0x151, script: 0x5a, flags: 0x0},
+ 115: {lang: 0x1c0, script: 0x22, flags: 0x2},
+ 118: {lang: 0x158, script: 0x5a, flags: 0x0},
+ 120: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 122: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 123: {lang: 0x14, script: 0x2, flags: 0x1},
+ 125: {lang: 0x16, script: 0x3, flags: 0x1},
+ 126: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 128: {lang: 0x21, script: 0x5a, flags: 0x0},
+ 130: {lang: 0x245, script: 0x5a, flags: 0x0},
+ 132: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 133: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 134: {lang: 0x13e, script: 0x5a, flags: 0x0},
+ 135: {lang: 0x19, script: 0x2, flags: 0x1},
+ 136: {lang: 0x0, script: 0x5a, flags: 0x0},
+ 137: {lang: 0x13e, script: 0x5a, flags: 0x0},
+ 139: {lang: 0x3c0, script: 0x5a, flags: 0x0},
+ 141: {lang: 0x529, script: 0x3c, flags: 0x0},
+ 142: {lang: 0x0, script: 0x5a, flags: 0x0},
+ 143: {lang: 0x13e, script: 0x5a, flags: 0x0},
+ 144: {lang: 0x1d1, script: 0x5a, flags: 0x0},
+ 145: {lang: 0x1d4, script: 0x5a, flags: 0x0},
+ 146: {lang: 0x1d5, script: 0x5a, flags: 0x0},
+ 148: {lang: 0x13e, script: 0x5a, flags: 0x0},
+ 149: {lang: 0x1b, script: 0x2, flags: 0x1},
+ 151: {lang: 0x1bc, script: 0x3e, flags: 0x0},
+ 153: {lang: 0x1d, script: 0x3, flags: 0x1},
+ 155: {lang: 0x3a, script: 0x5, flags: 0x0},
+ 156: {lang: 0x20, script: 0x2, flags: 0x1},
+ 157: {lang: 0x1f8, script: 0x5a, flags: 0x0},
+ 158: {lang: 0x1f9, script: 0x5a, flags: 0x0},
+ 161: {lang: 0x3a, script: 0x5, flags: 0x0},
+ 162: {lang: 0x200, script: 0x49, flags: 0x0},
+ 164: {lang: 0x445, script: 0x5a, flags: 0x0},
+ 165: {lang: 0x28a, script: 0x20, flags: 0x0},
+ 166: {lang: 0x22, script: 0x3, flags: 0x1},
+ 168: {lang: 0x25, script: 0x2, flags: 0x1},
+ 170: {lang: 0x254, script: 0x53, flags: 0x0},
+ 171: {lang: 0x254, script: 0x53, flags: 0x0},
+ 172: {lang: 0x3a, script: 0x5, flags: 0x0},
+ 174: {lang: 0x3e2, script: 0x20, flags: 0x0},
+ 175: {lang: 0x27, script: 0x2, flags: 0x1},
+ 176: {lang: 0x3a, script: 0x5, flags: 0x0},
+ 178: {lang: 0x10d, script: 0x5a, flags: 0x0},
+ 179: {lang: 0x40c, script: 0xd4, flags: 0x0},
+ 181: {lang: 0x43b, script: 0x5a, flags: 0x0},
+ 182: {lang: 0x2c0, script: 0x5a, flags: 0x0},
+ 183: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 184: {lang: 0x2c7, script: 0x5a, flags: 0x0},
+ 185: {lang: 0x3a, script: 0x5, flags: 0x0},
+ 186: {lang: 0x29, script: 0x2, flags: 0x1},
+ 187: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 188: {lang: 0x2b, script: 0x2, flags: 0x1},
+ 189: {lang: 0x432, script: 0x5a, flags: 0x0},
+ 190: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 191: {lang: 0x2f1, script: 0x5a, flags: 0x0},
+ 194: {lang: 0x2d, script: 0x2, flags: 0x1},
+ 195: {lang: 0xa0, script: 0x5a, flags: 0x0},
+ 196: {lang: 0x2f, script: 0x2, flags: 0x1},
+ 197: {lang: 0x31, script: 0x2, flags: 0x1},
+ 198: {lang: 0x33, script: 0x2, flags: 0x1},
+ 200: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 201: {lang: 0x35, script: 0x2, flags: 0x1},
+ 203: {lang: 0x320, script: 0x5a, flags: 0x0},
+ 204: {lang: 0x37, script: 0x3, flags: 0x1},
+ 205: {lang: 0x128, script: 0xea, flags: 0x0},
+ 207: {lang: 0x13e, script: 0x5a, flags: 0x0},
+ 208: {lang: 0x31f, script: 0x5a, flags: 0x0},
+ 209: {lang: 0x3c0, script: 0x5a, flags: 0x0},
+ 210: {lang: 0x16, script: 0x5a, flags: 0x0},
+ 211: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 212: {lang: 0x1b4, script: 0x5a, flags: 0x0},
+ 214: {lang: 0x1b4, script: 0x5, flags: 0x2},
+ 216: {lang: 0x13e, script: 0x5a, flags: 0x0},
+ 217: {lang: 0x367, script: 0x5a, flags: 0x0},
+ 218: {lang: 0x347, script: 0x5a, flags: 0x0},
+ 219: {lang: 0x351, script: 0x22, flags: 0x0},
+ 225: {lang: 0x3a, script: 0x5, flags: 0x0},
+ 226: {lang: 0x13e, script: 0x5a, flags: 0x0},
+ 228: {lang: 0x13e, script: 0x5a, flags: 0x0},
+ 229: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 230: {lang: 0x486, script: 0x5a, flags: 0x0},
+ 231: {lang: 0x153, script: 0x5a, flags: 0x0},
+ 232: {lang: 0x3a, script: 0x3, flags: 0x1},
+ 233: {lang: 0x3b3, script: 0x5a, flags: 0x0},
+ 234: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 236: {lang: 0x13e, script: 0x5a, flags: 0x0},
+ 237: {lang: 0x3a, script: 0x5, flags: 0x0},
+ 238: {lang: 0x3c0, script: 0x5a, flags: 0x0},
+ 240: {lang: 0x3a2, script: 0x5a, flags: 0x0},
+ 241: {lang: 0x194, script: 0x5a, flags: 0x0},
+ 243: {lang: 0x3a, script: 0x5, flags: 0x0},
+ 258: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 260: {lang: 0x3d, script: 0x2, flags: 0x1},
+ 261: {lang: 0x432, script: 0x20, flags: 0x0},
+ 262: {lang: 0x3f, script: 0x2, flags: 0x1},
+ 263: {lang: 0x3e5, script: 0x5a, flags: 0x0},
+ 264: {lang: 0x3a, script: 0x5, flags: 0x0},
+ 266: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 267: {lang: 0x3a, script: 0x5, flags: 0x0},
+ 268: {lang: 0x41, script: 0x2, flags: 0x1},
+ 271: {lang: 0x416, script: 0x5a, flags: 0x0},
+ 272: {lang: 0x347, script: 0x5a, flags: 0x0},
+ 273: {lang: 0x43, script: 0x2, flags: 0x1},
+ 275: {lang: 0x1f9, script: 0x5a, flags: 0x0},
+ 276: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 277: {lang: 0x429, script: 0x5a, flags: 0x0},
+ 278: {lang: 0x367, script: 0x5a, flags: 0x0},
+ 280: {lang: 0x3c0, script: 0x5a, flags: 0x0},
+ 282: {lang: 0x13e, script: 0x5a, flags: 0x0},
+ 284: {lang: 0x45, script: 0x2, flags: 0x1},
+ 288: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 289: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 290: {lang: 0x47, script: 0x2, flags: 0x1},
+ 291: {lang: 0x49, script: 0x3, flags: 0x1},
+ 292: {lang: 0x4c, script: 0x2, flags: 0x1},
+ 293: {lang: 0x477, script: 0x5a, flags: 0x0},
+ 294: {lang: 0x3c0, script: 0x5a, flags: 0x0},
+ 295: {lang: 0x476, script: 0x5a, flags: 0x0},
+ 296: {lang: 0x4e, script: 0x2, flags: 0x1},
+ 297: {lang: 0x482, script: 0x5a, flags: 0x0},
+ 299: {lang: 0x50, script: 0x4, flags: 0x1},
+ 301: {lang: 0x4a0, script: 0x5a, flags: 0x0},
+ 302: {lang: 0x54, script: 0x2, flags: 0x1},
+ 303: {lang: 0x445, script: 0x5a, flags: 0x0},
+ 304: {lang: 0x56, script: 0x3, flags: 0x1},
+ 305: {lang: 0x445, script: 0x5a, flags: 0x0},
+ 309: {lang: 0x512, script: 0x3e, flags: 0x2},
+ 310: {lang: 0x13e, script: 0x5a, flags: 0x0},
+ 311: {lang: 0x4bc, script: 0x5a, flags: 0x0},
+ 312: {lang: 0x1f9, script: 0x5a, flags: 0x0},
+ 315: {lang: 0x13e, script: 0x5a, flags: 0x0},
+ 318: {lang: 0x4c3, script: 0x5a, flags: 0x0},
+ 319: {lang: 0x8a, script: 0x5a, flags: 0x0},
+ 320: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 322: {lang: 0x41b, script: 0x5a, flags: 0x0},
+ 333: {lang: 0x59, script: 0x2, flags: 0x1},
+ 350: {lang: 0x3a, script: 0x5, flags: 0x0},
+ 351: {lang: 0x5b, script: 0x2, flags: 0x1},
+ 356: {lang: 0x423, script: 0x5a, flags: 0x0},
+}
+
+// likelyRegionList holds lists info associated with likelyRegion.
+// Size: 558 bytes, 93 elements
+var likelyRegionList = [93]likelyLangScript{
+ 0: {lang: 0x148, script: 0x5, flags: 0x0},
+ 1: {lang: 0x476, script: 0x5a, flags: 0x0},
+ 2: {lang: 0x431, script: 0x5a, flags: 0x0},
+ 3: {lang: 0x2ff, script: 0x20, flags: 0x0},
+ 4: {lang: 0x1d7, script: 0x8, flags: 0x0},
+ 5: {lang: 0x274, script: 0x5a, flags: 0x0},
+ 6: {lang: 0xb7, script: 0x5a, flags: 0x0},
+ 7: {lang: 0x432, script: 0x20, flags: 0x0},
+ 8: {lang: 0x12d, script: 0xec, flags: 0x0},
+ 9: {lang: 0x351, script: 0x22, flags: 0x0},
+ 10: {lang: 0x529, script: 0x3b, flags: 0x0},
+ 11: {lang: 0x4ac, script: 0x5, flags: 0x0},
+ 12: {lang: 0x523, script: 0x5a, flags: 0x0},
+ 13: {lang: 0x29a, script: 0xeb, flags: 0x0},
+ 14: {lang: 0x136, script: 0x34, flags: 0x0},
+ 15: {lang: 0x48a, script: 0x5a, flags: 0x0},
+ 16: {lang: 0x3a, script: 0x5, flags: 0x0},
+ 17: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 18: {lang: 0x27, script: 0x2c, flags: 0x0},
+ 19: {lang: 0x139, script: 0x5a, flags: 0x0},
+ 20: {lang: 0x26a, script: 0x5, flags: 0x2},
+ 21: {lang: 0x512, script: 0x3e, flags: 0x2},
+ 22: {lang: 0x210, script: 0x2e, flags: 0x0},
+ 23: {lang: 0x5, script: 0x20, flags: 0x0},
+ 24: {lang: 0x274, script: 0x5a, flags: 0x0},
+ 25: {lang: 0x136, script: 0x34, flags: 0x0},
+ 26: {lang: 0x2ff, script: 0x20, flags: 0x0},
+ 27: {lang: 0x1e1, script: 0x5a, flags: 0x0},
+ 28: {lang: 0x31f, script: 0x5, flags: 0x0},
+ 29: {lang: 0x1be, script: 0x22, flags: 0x0},
+ 30: {lang: 0x4b4, script: 0x5, flags: 0x0},
+ 31: {lang: 0x236, script: 0x75, flags: 0x0},
+ 32: {lang: 0x148, script: 0x5, flags: 0x0},
+ 33: {lang: 0x476, script: 0x5a, flags: 0x0},
+ 34: {lang: 0x24a, script: 0x4e, flags: 0x0},
+ 35: {lang: 0xe6, script: 0x5, flags: 0x0},
+ 36: {lang: 0x226, script: 0xeb, flags: 0x0},
+ 37: {lang: 0x3a, script: 0x5, flags: 0x0},
+ 38: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 39: {lang: 0x2b8, script: 0x57, flags: 0x0},
+ 40: {lang: 0x226, script: 0xeb, flags: 0x0},
+ 41: {lang: 0x3a, script: 0x5, flags: 0x0},
+ 42: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 43: {lang: 0x3dc, script: 0x5a, flags: 0x0},
+ 44: {lang: 0x4ae, script: 0x20, flags: 0x0},
+ 45: {lang: 0x2ff, script: 0x20, flags: 0x0},
+ 46: {lang: 0x431, script: 0x5a, flags: 0x0},
+ 47: {lang: 0x331, script: 0x75, flags: 0x0},
+ 48: {lang: 0x213, script: 0x5a, flags: 0x0},
+ 49: {lang: 0x30b, script: 0x20, flags: 0x0},
+ 50: {lang: 0x242, script: 0x5, flags: 0x0},
+ 51: {lang: 0x529, script: 0x3c, flags: 0x0},
+ 52: {lang: 0x3c0, script: 0x5a, flags: 0x0},
+ 53: {lang: 0x3a, script: 0x5, flags: 0x0},
+ 54: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 55: {lang: 0x2ed, script: 0x5a, flags: 0x0},
+ 56: {lang: 0x4b4, script: 0x5, flags: 0x0},
+ 57: {lang: 0x88, script: 0x22, flags: 0x0},
+ 58: {lang: 0x4b4, script: 0x5, flags: 0x0},
+ 59: {lang: 0x4b4, script: 0x5, flags: 0x0},
+ 60: {lang: 0xbe, script: 0x22, flags: 0x0},
+ 61: {lang: 0x3dc, script: 0x5a, flags: 0x0},
+ 62: {lang: 0x7e, script: 0x20, flags: 0x0},
+ 63: {lang: 0x3e2, script: 0x20, flags: 0x0},
+ 64: {lang: 0x267, script: 0x5a, flags: 0x0},
+ 65: {lang: 0x444, script: 0x5a, flags: 0x0},
+ 66: {lang: 0x512, script: 0x3e, flags: 0x0},
+ 67: {lang: 0x412, script: 0x5a, flags: 0x0},
+ 68: {lang: 0x4ae, script: 0x20, flags: 0x0},
+ 69: {lang: 0x3a, script: 0x5, flags: 0x0},
+ 70: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 71: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 72: {lang: 0x35, script: 0x5, flags: 0x0},
+ 73: {lang: 0x46b, script: 0xeb, flags: 0x0},
+ 74: {lang: 0x2ec, script: 0x5, flags: 0x0},
+ 75: {lang: 0x30f, script: 0x75, flags: 0x0},
+ 76: {lang: 0x467, script: 0x20, flags: 0x0},
+ 77: {lang: 0x148, script: 0x5, flags: 0x0},
+ 78: {lang: 0x3a, script: 0x5, flags: 0x0},
+ 79: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 80: {lang: 0x48a, script: 0x5a, flags: 0x0},
+ 81: {lang: 0x58, script: 0x5, flags: 0x0},
+ 82: {lang: 0x219, script: 0x20, flags: 0x0},
+ 83: {lang: 0x81, script: 0x34, flags: 0x0},
+ 84: {lang: 0x529, script: 0x3c, flags: 0x0},
+ 85: {lang: 0x48c, script: 0x5a, flags: 0x0},
+ 86: {lang: 0x4ae, script: 0x20, flags: 0x0},
+ 87: {lang: 0x512, script: 0x3e, flags: 0x0},
+ 88: {lang: 0x3b3, script: 0x5a, flags: 0x0},
+ 89: {lang: 0x431, script: 0x5a, flags: 0x0},
+ 90: {lang: 0x432, script: 0x20, flags: 0x0},
+ 91: {lang: 0x15e, script: 0x5a, flags: 0x0},
+ 92: {lang: 0x446, script: 0x5, flags: 0x0},
+}
+
+type likelyTag struct {
+ lang uint16
+ region uint16
+ script uint16
+}
+
+// Size: 198 bytes, 33 elements
+var likelyRegionGroup = [33]likelyTag{
+ 1: {lang: 0x139, region: 0xd6, script: 0x5a},
+ 2: {lang: 0x139, region: 0x135, script: 0x5a},
+ 3: {lang: 0x3c0, region: 0x41, script: 0x5a},
+ 4: {lang: 0x139, region: 0x2f, script: 0x5a},
+ 5: {lang: 0x139, region: 0xd6, script: 0x5a},
+ 6: {lang: 0x13e, region: 0xcf, script: 0x5a},
+ 7: {lang: 0x445, region: 0x12f, script: 0x5a},
+ 8: {lang: 0x3a, region: 0x6b, script: 0x5},
+ 9: {lang: 0x445, region: 0x4b, script: 0x5a},
+ 10: {lang: 0x139, region: 0x161, script: 0x5a},
+ 11: {lang: 0x139, region: 0x135, script: 0x5a},
+ 12: {lang: 0x139, region: 0x135, script: 0x5a},
+ 13: {lang: 0x13e, region: 0x59, script: 0x5a},
+ 14: {lang: 0x529, region: 0x53, script: 0x3b},
+ 15: {lang: 0x1be, region: 0x99, script: 0x22},
+ 16: {lang: 0x1e1, region: 0x95, script: 0x5a},
+ 17: {lang: 0x1f9, region: 0x9e, script: 0x5a},
+ 18: {lang: 0x139, region: 0x2f, script: 0x5a},
+ 19: {lang: 0x139, region: 0xe6, script: 0x5a},
+ 20: {lang: 0x139, region: 0x8a, script: 0x5a},
+ 21: {lang: 0x41b, region: 0x142, script: 0x5a},
+ 22: {lang: 0x529, region: 0x53, script: 0x3b},
+ 23: {lang: 0x4bc, region: 0x137, script: 0x5a},
+ 24: {lang: 0x3a, region: 0x108, script: 0x5},
+ 25: {lang: 0x3e2, region: 0x106, script: 0x20},
+ 26: {lang: 0x3e2, region: 0x106, script: 0x20},
+ 27: {lang: 0x139, region: 0x7b, script: 0x5a},
+ 28: {lang: 0x10d, region: 0x60, script: 0x5a},
+ 29: {lang: 0x139, region: 0xd6, script: 0x5a},
+ 30: {lang: 0x13e, region: 0x1f, script: 0x5a},
+ 31: {lang: 0x139, region: 0x9a, script: 0x5a},
+ 32: {lang: 0x139, region: 0x7b, script: 0x5a},
+}
+
+// Size: 264 bytes, 33 elements
+var regionContainment = [33]uint64{
+ // Entry 0 - 1F
+ 0x00000001ffffffff, 0x00000000200007a2, 0x0000000000003044, 0x0000000000000008,
+ 0x00000000803c0010, 0x0000000000000020, 0x0000000000000040, 0x0000000000000080,
+ 0x0000000000000100, 0x0000000000000200, 0x0000000000000400, 0x000000004000384c,
+ 0x0000000000001000, 0x0000000000002000, 0x0000000000004000, 0x0000000000008000,
+ 0x0000000000010000, 0x0000000000020000, 0x0000000000040000, 0x0000000000080000,
+ 0x0000000000100000, 0x0000000000200000, 0x0000000001c1c000, 0x0000000000800000,
+ 0x0000000001000000, 0x000000001e020000, 0x0000000004000000, 0x0000000008000000,
+ 0x0000000010000000, 0x00000000200006a0, 0x0000000040002048, 0x0000000080000000,
+ // Entry 20 - 3F
+ 0x0000000100000000,
+}
+
+// regionInclusion maps region identifiers to sets of regions in regionInclusionBits,
+// where each set holds all groupings that are directly connected in a region
+// containment graph.
+// Size: 358 bytes, 358 elements
+var regionInclusion = [358]uint8{
+ // Entry 0 - 3F
+ 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
+ 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
+ 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
+ 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e,
+ 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x26, 0x23,
+ 0x24, 0x26, 0x27, 0x22, 0x28, 0x29, 0x2a, 0x2b,
+ 0x26, 0x2c, 0x24, 0x23, 0x26, 0x25, 0x2a, 0x2d,
+ 0x2e, 0x24, 0x2f, 0x2d, 0x26, 0x30, 0x31, 0x28,
+ // Entry 40 - 7F
+ 0x26, 0x28, 0x26, 0x25, 0x31, 0x22, 0x32, 0x33,
+ 0x34, 0x30, 0x22, 0x27, 0x27, 0x27, 0x35, 0x2d,
+ 0x29, 0x28, 0x27, 0x36, 0x28, 0x22, 0x34, 0x23,
+ 0x21, 0x26, 0x2d, 0x26, 0x22, 0x37, 0x2e, 0x35,
+ 0x2a, 0x22, 0x2f, 0x38, 0x26, 0x26, 0x21, 0x39,
+ 0x39, 0x28, 0x38, 0x39, 0x39, 0x2f, 0x3a, 0x2f,
+ 0x20, 0x21, 0x38, 0x3b, 0x28, 0x3c, 0x2c, 0x21,
+ 0x2a, 0x35, 0x27, 0x38, 0x26, 0x24, 0x28, 0x2c,
+ // Entry 80 - BF
+ 0x2d, 0x23, 0x30, 0x2d, 0x2d, 0x26, 0x27, 0x3a,
+ 0x22, 0x34, 0x3c, 0x2d, 0x28, 0x36, 0x22, 0x34,
+ 0x3a, 0x26, 0x2e, 0x21, 0x39, 0x31, 0x38, 0x24,
+ 0x2c, 0x25, 0x22, 0x24, 0x25, 0x2c, 0x3a, 0x2c,
+ 0x26, 0x24, 0x36, 0x21, 0x2f, 0x3d, 0x31, 0x3c,
+ 0x2f, 0x26, 0x36, 0x36, 0x24, 0x26, 0x3d, 0x31,
+ 0x24, 0x26, 0x35, 0x25, 0x2d, 0x32, 0x38, 0x2a,
+ 0x38, 0x39, 0x39, 0x35, 0x33, 0x23, 0x26, 0x2f,
+ // Entry C0 - FF
+ 0x3c, 0x21, 0x23, 0x2d, 0x31, 0x36, 0x36, 0x3c,
+ 0x26, 0x2d, 0x26, 0x3a, 0x2f, 0x25, 0x2f, 0x34,
+ 0x31, 0x2f, 0x32, 0x3b, 0x2d, 0x2b, 0x2d, 0x21,
+ 0x34, 0x2a, 0x2c, 0x25, 0x21, 0x3c, 0x24, 0x29,
+ 0x2b, 0x24, 0x34, 0x21, 0x28, 0x29, 0x3b, 0x31,
+ 0x25, 0x2e, 0x30, 0x29, 0x26, 0x24, 0x3a, 0x21,
+ 0x3c, 0x28, 0x21, 0x24, 0x21, 0x21, 0x1f, 0x21,
+ 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21,
+ // Entry 100 - 13F
+ 0x21, 0x21, 0x2f, 0x21, 0x2e, 0x23, 0x33, 0x2f,
+ 0x24, 0x3b, 0x2f, 0x39, 0x38, 0x31, 0x2d, 0x3a,
+ 0x2c, 0x2e, 0x2d, 0x23, 0x2d, 0x2f, 0x28, 0x2f,
+ 0x27, 0x33, 0x34, 0x26, 0x24, 0x32, 0x22, 0x26,
+ 0x27, 0x22, 0x2d, 0x31, 0x3d, 0x29, 0x31, 0x3d,
+ 0x39, 0x29, 0x31, 0x24, 0x26, 0x29, 0x36, 0x2f,
+ 0x33, 0x2f, 0x21, 0x22, 0x21, 0x30, 0x28, 0x3d,
+ 0x23, 0x26, 0x21, 0x28, 0x26, 0x26, 0x31, 0x3b,
+ // Entry 140 - 17F
+ 0x29, 0x21, 0x29, 0x21, 0x21, 0x21, 0x21, 0x21,
+ 0x21, 0x21, 0x21, 0x21, 0x21, 0x23, 0x21, 0x21,
+ 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21,
+ 0x21, 0x21, 0x21, 0x21, 0x21, 0x24, 0x24, 0x2f,
+ 0x23, 0x32, 0x2f, 0x27, 0x2f, 0x21,
+}
+
+// regionInclusionBits is an array of bit vectors where every vector represents
+// a set of region groupings. These sets are used to compute the distance
+// between two regions for the purpose of language matching.
+// Size: 584 bytes, 73 elements
+var regionInclusionBits = [73]uint64{
+ // Entry 0 - 1F
+ 0x0000000102400813, 0x00000000200007a3, 0x0000000000003844, 0x0000000040000808,
+ 0x00000000803c0011, 0x0000000020000022, 0x0000000040000844, 0x0000000020000082,
+ 0x0000000000000102, 0x0000000020000202, 0x0000000020000402, 0x000000004000384d,
+ 0x0000000000001804, 0x0000000040002804, 0x0000000000404000, 0x0000000000408000,
+ 0x0000000000410000, 0x0000000002020000, 0x0000000000040010, 0x0000000000080010,
+ 0x0000000000100010, 0x0000000000200010, 0x0000000001c1c001, 0x0000000000c00000,
+ 0x0000000001400000, 0x000000001e020001, 0x0000000006000000, 0x000000000a000000,
+ 0x0000000012000000, 0x00000000200006a2, 0x0000000040002848, 0x0000000080000010,
+ // Entry 20 - 3F
+ 0x0000000100000001, 0x0000000000000001, 0x0000000080000000, 0x0000000000020000,
+ 0x0000000001000000, 0x0000000000008000, 0x0000000000002000, 0x0000000000000200,
+ 0x0000000000000008, 0x0000000000200000, 0x0000000110000000, 0x0000000000040000,
+ 0x0000000008000000, 0x0000000000000020, 0x0000000104000000, 0x0000000000000080,
+ 0x0000000000001000, 0x0000000000010000, 0x0000000000000400, 0x0000000004000000,
+ 0x0000000000000040, 0x0000000010000000, 0x0000000000004000, 0x0000000101000000,
+ 0x0000000108000000, 0x0000000000000100, 0x0000000100020000, 0x0000000000080000,
+ 0x0000000000100000, 0x0000000000800000, 0x00000001ffffffff, 0x0000000122400fb3,
+ // Entry 40 - 5F
+ 0x00000001827c0813, 0x000000014240385f, 0x0000000103c1c813, 0x000000011e420813,
+ 0x0000000112000001, 0x0000000106000001, 0x0000000101400001, 0x000000010a000001,
+ 0x0000000102020001,
+}
+
+// regionInclusionNext marks, for each entry in regionInclusionBits, the set of
+// all groups that are reachable from the groups set in the respective entry.
+// Size: 73 bytes, 73 elements
+var regionInclusionNext = [73]uint8{
+ // Entry 0 - 3F
+ 0x3e, 0x3f, 0x0b, 0x0b, 0x40, 0x01, 0x0b, 0x01,
+ 0x01, 0x01, 0x01, 0x41, 0x0b, 0x0b, 0x16, 0x16,
+ 0x16, 0x19, 0x04, 0x04, 0x04, 0x04, 0x42, 0x16,
+ 0x16, 0x43, 0x19, 0x19, 0x19, 0x01, 0x0b, 0x04,
+ 0x00, 0x00, 0x1f, 0x11, 0x18, 0x0f, 0x0d, 0x09,
+ 0x03, 0x15, 0x44, 0x12, 0x1b, 0x05, 0x45, 0x07,
+ 0x0c, 0x10, 0x0a, 0x1a, 0x06, 0x1c, 0x0e, 0x46,
+ 0x47, 0x08, 0x48, 0x13, 0x14, 0x17, 0x3e, 0x3e,
+ // Entry 40 - 7F
+ 0x3e, 0x3e, 0x3e, 0x3e, 0x43, 0x43, 0x42, 0x43,
+ 0x43,
+}
+
+type parentRel struct {
+ lang uint16
+ script uint16
+ maxScript uint16
+ toRegion uint16
+ fromRegion []uint16
+}
+
+// Size: 414 bytes, 5 elements
+var parents = [5]parentRel{
+ 0: {lang: 0x139, script: 0x0, maxScript: 0x5a, toRegion: 0x1, fromRegion: []uint16{0x1a, 0x25, 0x26, 0x2f, 0x34, 0x36, 0x3d, 0x42, 0x46, 0x48, 0x49, 0x4a, 0x50, 0x52, 0x5c, 0x5d, 0x61, 0x64, 0x6d, 0x73, 0x74, 0x75, 0x7b, 0x7c, 0x7f, 0x80, 0x81, 0x83, 0x8c, 0x8d, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9f, 0xa0, 0xa4, 0xa7, 0xa9, 0xad, 0xb1, 0xb4, 0xb5, 0xbf, 0xc6, 0xca, 0xcb, 0xcc, 0xce, 0xd0, 0xd2, 0xd5, 0xd6, 0xdd, 0xdf, 0xe0, 0xe6, 0xe7, 0xe8, 0xeb, 0xf0, 0x107, 0x109, 0x10a, 0x10b, 0x10d, 0x10e, 0x112, 0x117, 0x11b, 0x11d, 0x11f, 0x125, 0x129, 0x12c, 0x12d, 0x12f, 0x131, 0x139, 0x13c, 0x13f, 0x142, 0x161, 0x162, 0x164}},
+ 1: {lang: 0x139, script: 0x0, maxScript: 0x5a, toRegion: 0x1a, fromRegion: []uint16{0x2e, 0x4e, 0x60, 0x63, 0x72, 0xd9, 0x10c, 0x10f}},
+ 2: {lang: 0x13e, script: 0x0, maxScript: 0x5a, toRegion: 0x1f, fromRegion: []uint16{0x2c, 0x3f, 0x41, 0x48, 0x51, 0x54, 0x56, 0x59, 0x65, 0x69, 0x89, 0x8f, 0xcf, 0xd8, 0xe2, 0xe4, 0xec, 0xf1, 0x11a, 0x135, 0x136, 0x13b}},
+ 3: {lang: 0x3c0, script: 0x0, maxScript: 0x5a, toRegion: 0xee, fromRegion: []uint16{0x2a, 0x4e, 0x5a, 0x86, 0x8b, 0xb7, 0xc6, 0xd1, 0x118, 0x126}},
+ 4: {lang: 0x529, script: 0x3c, maxScript: 0x3c, toRegion: 0x8d, fromRegion: []uint16{0xc6}},
+}
+
+// Total table size 30244 bytes (29KiB); checksum: B6B15F30
diff --git a/vendor/golang.org/x/text/internal/language/tags.go b/vendor/golang.org/x/text/internal/language/tags.go
new file mode 100644
index 0000000..e7afd31
--- /dev/null
+++ b/vendor/golang.org/x/text/internal/language/tags.go
@@ -0,0 +1,48 @@
+// Copyright 2013 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package language
+
+// MustParse is like Parse, but panics if the given BCP 47 tag cannot be parsed.
+// It simplifies safe initialization of Tag values.
+func MustParse(s string) Tag {
+ t, err := Parse(s)
+ if err != nil {
+ panic(err)
+ }
+ return t
+}
+
+// MustParseBase is like ParseBase, but panics if the given base cannot be parsed.
+// It simplifies safe initialization of Base values.
+func MustParseBase(s string) Language {
+ b, err := ParseBase(s)
+ if err != nil {
+ panic(err)
+ }
+ return b
+}
+
+// MustParseScript is like ParseScript, but panics if the given script cannot be
+// parsed. It simplifies safe initialization of Script values.
+func MustParseScript(s string) Script {
+ scr, err := ParseScript(s)
+ if err != nil {
+ panic(err)
+ }
+ return scr
+}
+
+// MustParseRegion is like ParseRegion, but panics if the given region cannot be
+// parsed. It simplifies safe initialization of Region values.
+func MustParseRegion(s string) Region {
+ r, err := ParseRegion(s)
+ if err != nil {
+ panic(err)
+ }
+ return r
+}
+
+// Und is the root language.
+var Und Tag
diff --git a/vendor/golang.org/x/text/internal/match.go b/vendor/golang.org/x/text/internal/match.go
new file mode 100644
index 0000000..1cc004a
--- /dev/null
+++ b/vendor/golang.org/x/text/internal/match.go
@@ -0,0 +1,67 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package internal
+
+// This file contains matchers that implement CLDR inheritance.
+//
+// See https://unicode.org/reports/tr35/#Locale_Inheritance.
+//
+// Some of the inheritance described in this document is already handled by
+// the cldr package.
+
+import (
+ "golang.org/x/text/language"
+)
+
+// TODO: consider if (some of the) matching algorithm needs to be public after
+// getting some feel about what is generic and what is specific.
+
+// NewInheritanceMatcher returns a matcher that matches based on the inheritance
+// chain.
+//
+// The matcher uses canonicalization and the parent relationship to find a
+// match. The resulting match will always be either Und or a language with the
+// same language and script as the requested language. It will not match
+// languages for which there is understood to be mutual or one-directional
+// intelligibility.
+//
+// A Match will indicate an Exact match if the language matches after
+// canonicalization and High if the matched tag is a parent.
+func NewInheritanceMatcher(t []language.Tag) *InheritanceMatcher {
+ tags := &InheritanceMatcher{make(map[language.Tag]int)}
+ for i, tag := range t {
+ ct, err := language.All.Canonicalize(tag)
+ if err != nil {
+ ct = tag
+ }
+ tags.index[ct] = i
+ }
+ return tags
+}
+
+type InheritanceMatcher struct {
+ index map[language.Tag]int
+}
+
+func (m InheritanceMatcher) Match(want ...language.Tag) (language.Tag, int, language.Confidence) {
+ for _, t := range want {
+ ct, err := language.All.Canonicalize(t)
+ if err != nil {
+ ct = t
+ }
+ conf := language.Exact
+ for {
+ if index, ok := m.index[ct]; ok {
+ return ct, index, conf
+ }
+ if ct == language.Und {
+ break
+ }
+ ct = ct.Parent()
+ conf = language.High
+ }
+ }
+ return language.Und, 0, language.No
+}
diff --git a/vendor/golang.org/x/text/internal/number/common.go b/vendor/golang.org/x/text/internal/number/common.go
new file mode 100644
index 0000000..a6e9c8e
--- /dev/null
+++ b/vendor/golang.org/x/text/internal/number/common.go
@@ -0,0 +1,55 @@
+// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
+
+package number
+
+import (
+ "unicode/utf8"
+
+ "golang.org/x/text/internal/language/compact"
+)
+
+// A system identifies a CLDR numbering system.
+type system byte
+
+type systemData struct {
+ id system
+ digitSize byte // number of UTF-8 bytes per digit
+ zero [utf8.UTFMax]byte // UTF-8 sequence of zero digit.
+}
+
+// A SymbolType identifies a symbol of a specific kind.
+type SymbolType int
+
+const (
+ SymDecimal SymbolType = iota
+ SymGroup
+ SymList
+ SymPercentSign
+ SymPlusSign
+ SymMinusSign
+ SymExponential
+ SymSuperscriptingExponent
+ SymPerMille
+ SymInfinity
+ SymNan
+ SymTimeSeparator
+
+ NumSymbolTypes
+)
+
+const hasNonLatnMask = 0x8000
+
+// symOffset is an offset into altSymData if the bit indicated by hasNonLatnMask
+// is not 0 (with this bit masked out), and an offset into symIndex otherwise.
+//
+// TODO: this type can be a byte again if we use an indirection into altsymData
+// and introduce an alt -> offset slice (the length of this will be number of
+// alternatives plus 1). This also allows getting rid of the compactTag field
+// in altSymData. In total this will save about 1K.
+type symOffset uint16
+
+type altSymData struct {
+ compactTag compact.ID
+ symIndex symOffset
+ system system
+}
diff --git a/vendor/golang.org/x/text/internal/number/decimal.go b/vendor/golang.org/x/text/internal/number/decimal.go
new file mode 100644
index 0000000..37e0c4b
--- /dev/null
+++ b/vendor/golang.org/x/text/internal/number/decimal.go
@@ -0,0 +1,500 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:generate stringer -type RoundingMode
+
+package number
+
+import (
+ "math"
+ "strconv"
+)
+
+// RoundingMode determines how a number is rounded to the desired precision.
+type RoundingMode byte
+
+const (
+ ToNearestEven RoundingMode = iota // towards the nearest integer, or towards an even number if equidistant.
+ ToNearestZero // towards the nearest integer, or towards zero if equidistant.
+ ToNearestAway // towards the nearest integer, or away from zero if equidistant.
+ ToPositiveInf // towards infinity
+ ToNegativeInf // towards negative infinity
+ ToZero // towards zero
+ AwayFromZero // away from zero
+ numModes
+)
+
+const maxIntDigits = 20
+
+// A Decimal represents a floating point number in decimal format.
+// Digits represents a number [0, 1.0), and the absolute value represented by
+// Decimal is Digits * 10^Exp. Leading and trailing zeros may be omitted and Exp
+// may point outside a valid position in Digits.
+//
+// Examples:
+//
+// Number Decimal
+// 12345 Digits: [1, 2, 3, 4, 5], Exp: 5
+// 12.345 Digits: [1, 2, 3, 4, 5], Exp: 2
+// 12000 Digits: [1, 2], Exp: 5
+// 12000.00 Digits: [1, 2], Exp: 5
+// 0.00123 Digits: [1, 2, 3], Exp: -2
+// 0 Digits: [], Exp: 0
+type Decimal struct {
+ digits
+
+ buf [maxIntDigits]byte
+}
+
+type digits struct {
+ Digits []byte // mantissa digits, big-endian
+ Exp int32 // exponent
+ Neg bool
+ Inf bool // Takes precedence over Digits and Exp.
+ NaN bool // Takes precedence over Inf.
+}
+
+// Digits represents a floating point number represented in digits of the
+// base in which a number is to be displayed. It is similar to Decimal, but
+// keeps track of trailing fraction zeros and the comma placement for
+// engineering notation. Digits must have at least one digit.
+//
+// Examples:
+//
+// Number Decimal
+// decimal
+// 12345 Digits: [1, 2, 3, 4, 5], Exp: 5 End: 5
+// 12.345 Digits: [1, 2, 3, 4, 5], Exp: 2 End: 5
+// 12000 Digits: [1, 2], Exp: 5 End: 5
+// 12000.00 Digits: [1, 2], Exp: 5 End: 7
+// 0.00123 Digits: [1, 2, 3], Exp: -2 End: 3
+// 0 Digits: [], Exp: 0 End: 1
+// scientific (actual exp is Exp - Comma)
+// 0e0 Digits: [0], Exp: 1, End: 1, Comma: 1
+// .0e0 Digits: [0], Exp: 0, End: 1, Comma: 0
+// 0.0e0 Digits: [0], Exp: 1, End: 2, Comma: 1
+// 1.23e4 Digits: [1, 2, 3], Exp: 5, End: 3, Comma: 1
+// .123e5 Digits: [1, 2, 3], Exp: 5, End: 3, Comma: 0
+// engineering
+// 12.3e3 Digits: [1, 2, 3], Exp: 5, End: 3, Comma: 2
+type Digits struct {
+ digits
+ // End indicates the end position of the number.
+ End int32 // For decimals Exp <= End. For scientific len(Digits) <= End.
+ // Comma is used for the comma position for scientific (always 0 or 1) and
+ // engineering notation (always 0, 1, 2, or 3).
+ Comma uint8
+ // IsScientific indicates whether this number is to be rendered as a
+ // scientific number.
+ IsScientific bool
+}
+
+func (d *Digits) NumFracDigits() int {
+ if d.Exp >= d.End {
+ return 0
+ }
+ return int(d.End - d.Exp)
+}
+
+// normalize returns a new Decimal with leading and trailing zeros removed.
+func (d *Decimal) normalize() (n Decimal) {
+ n = *d
+ b := n.Digits
+ // Strip leading zeros. Resulting number of digits is significant digits.
+ for len(b) > 0 && b[0] == 0 {
+ b = b[1:]
+ n.Exp--
+ }
+ // Strip trailing zeros
+ for len(b) > 0 && b[len(b)-1] == 0 {
+ b = b[:len(b)-1]
+ }
+ if len(b) == 0 {
+ n.Exp = 0
+ }
+ n.Digits = b
+ return n
+}
+
+func (d *Decimal) clear() {
+ b := d.Digits
+ if b == nil {
+ b = d.buf[:0]
+ }
+ *d = Decimal{}
+ d.Digits = b[:0]
+}
+
+func (x *Decimal) String() string {
+ if x.NaN {
+ return "NaN"
+ }
+ var buf []byte
+ if x.Neg {
+ buf = append(buf, '-')
+ }
+ if x.Inf {
+ buf = append(buf, "Inf"...)
+ return string(buf)
+ }
+ switch {
+ case len(x.Digits) == 0:
+ buf = append(buf, '0')
+ case x.Exp <= 0:
+ // 0.00ddd
+ buf = append(buf, "0."...)
+ buf = appendZeros(buf, -int(x.Exp))
+ buf = appendDigits(buf, x.Digits)
+
+ case /* 0 < */ int(x.Exp) < len(x.Digits):
+ // dd.ddd
+ buf = appendDigits(buf, x.Digits[:x.Exp])
+ buf = append(buf, '.')
+ buf = appendDigits(buf, x.Digits[x.Exp:])
+
+ default: // len(x.Digits) <= x.Exp
+ // ddd00
+ buf = appendDigits(buf, x.Digits)
+ buf = appendZeros(buf, int(x.Exp)-len(x.Digits))
+ }
+ return string(buf)
+}
+
+func appendDigits(buf []byte, digits []byte) []byte {
+ for _, c := range digits {
+ buf = append(buf, c+'0')
+ }
+ return buf
+}
+
+// appendZeros appends n 0 digits to buf and returns buf.
+func appendZeros(buf []byte, n int) []byte {
+ for ; n > 0; n-- {
+ buf = append(buf, '0')
+ }
+ return buf
+}
+
+func (d *digits) round(mode RoundingMode, n int) {
+ if n >= len(d.Digits) {
+ return
+ }
+ // Make rounding decision: The result mantissa is truncated ("rounded down")
+ // by default. Decide if we need to increment, or "round up", the (unsigned)
+ // mantissa.
+ inc := false
+ switch mode {
+ case ToNegativeInf:
+ inc = d.Neg
+ case ToPositiveInf:
+ inc = !d.Neg
+ case ToZero:
+ // nothing to do
+ case AwayFromZero:
+ inc = true
+ case ToNearestEven:
+ inc = d.Digits[n] > 5 || d.Digits[n] == 5 &&
+ (len(d.Digits) > n+1 || n == 0 || d.Digits[n-1]&1 != 0)
+ case ToNearestAway:
+ inc = d.Digits[n] >= 5
+ case ToNearestZero:
+ inc = d.Digits[n] > 5 || d.Digits[n] == 5 && len(d.Digits) > n+1
+ default:
+ panic("unreachable")
+ }
+ if inc {
+ d.roundUp(n)
+ } else {
+ d.roundDown(n)
+ }
+}
+
+// roundFloat rounds a floating point number.
+func (r RoundingMode) roundFloat(x float64) float64 {
+ // Make rounding decision: The result mantissa is truncated ("rounded down")
+ // by default. Decide if we need to increment, or "round up", the (unsigned)
+ // mantissa.
+ abs := x
+ if x < 0 {
+ abs = -x
+ }
+ i, f := math.Modf(abs)
+ if f == 0.0 {
+ return x
+ }
+ inc := false
+ switch r {
+ case ToNegativeInf:
+ inc = x < 0
+ case ToPositiveInf:
+ inc = x >= 0
+ case ToZero:
+ // nothing to do
+ case AwayFromZero:
+ inc = true
+ case ToNearestEven:
+ // TODO: check overflow
+ inc = f > 0.5 || f == 0.5 && int64(i)&1 != 0
+ case ToNearestAway:
+ inc = f >= 0.5
+ case ToNearestZero:
+ inc = f > 0.5
+ default:
+ panic("unreachable")
+ }
+ if inc {
+ i += 1
+ }
+ if abs != x {
+ i = -i
+ }
+ return i
+}
+
+func (x *digits) roundUp(n int) {
+ if n < 0 || n >= len(x.Digits) {
+ return // nothing to do
+ }
+ // find first digit < 9
+ for n > 0 && x.Digits[n-1] >= 9 {
+ n--
+ }
+
+ if n == 0 {
+ // all digits are 9s => round up to 1 and update exponent
+ x.Digits[0] = 1 // ok since len(x.Digits) > n
+ x.Digits = x.Digits[:1]
+ x.Exp++
+ return
+ }
+ x.Digits[n-1]++
+ x.Digits = x.Digits[:n]
+ // x already trimmed
+}
+
+func (x *digits) roundDown(n int) {
+ if n < 0 || n >= len(x.Digits) {
+ return // nothing to do
+ }
+ x.Digits = x.Digits[:n]
+ trim(x)
+}
+
+// trim cuts off any trailing zeros from x's mantissa;
+// they are meaningless for the value of x.
+func trim(x *digits) {
+ i := len(x.Digits)
+ for i > 0 && x.Digits[i-1] == 0 {
+ i--
+ }
+ x.Digits = x.Digits[:i]
+ if i == 0 {
+ x.Exp = 0
+ }
+}
+
+// A Converter converts a number into decimals according to the given rounding
+// criteria.
+type Converter interface {
+ Convert(d *Decimal, r RoundingContext)
+}
+
+const (
+ signed = true
+ unsigned = false
+)
+
+// Convert converts the given number to the decimal representation using the
+// supplied RoundingContext.
+func (d *Decimal) Convert(r RoundingContext, number interface{}) {
+ switch f := number.(type) {
+ case Converter:
+ d.clear()
+ f.Convert(d, r)
+ case float32:
+ d.ConvertFloat(r, float64(f), 32)
+ case float64:
+ d.ConvertFloat(r, f, 64)
+ case int:
+ d.ConvertInt(r, signed, uint64(f))
+ case int8:
+ d.ConvertInt(r, signed, uint64(f))
+ case int16:
+ d.ConvertInt(r, signed, uint64(f))
+ case int32:
+ d.ConvertInt(r, signed, uint64(f))
+ case int64:
+ d.ConvertInt(r, signed, uint64(f))
+ case uint:
+ d.ConvertInt(r, unsigned, uint64(f))
+ case uint8:
+ d.ConvertInt(r, unsigned, uint64(f))
+ case uint16:
+ d.ConvertInt(r, unsigned, uint64(f))
+ case uint32:
+ d.ConvertInt(r, unsigned, uint64(f))
+ case uint64:
+ d.ConvertInt(r, unsigned, f)
+
+ default:
+ d.NaN = true
+ // TODO:
+ // case string: if produced by strconv, allows for easy arbitrary pos.
+ // case reflect.Value:
+ // case big.Float
+ // case big.Int
+ // case big.Rat?
+ // catch underlyings using reflect or will this already be done by the
+ // message package?
+ }
+}
+
+// ConvertInt converts an integer to decimals.
+func (d *Decimal) ConvertInt(r RoundingContext, signed bool, x uint64) {
+ if r.Increment > 0 {
+ // TODO: if uint64 is too large, fall back to float64
+ if signed {
+ d.ConvertFloat(r, float64(int64(x)), 64)
+ } else {
+ d.ConvertFloat(r, float64(x), 64)
+ }
+ return
+ }
+ d.clear()
+ if signed && int64(x) < 0 {
+ x = uint64(-int64(x))
+ d.Neg = true
+ }
+ d.fillIntDigits(x)
+ d.Exp = int32(len(d.Digits))
+}
+
+// ConvertFloat converts a floating point number to decimals.
+func (d *Decimal) ConvertFloat(r RoundingContext, x float64, size int) {
+ d.clear()
+ if math.IsNaN(x) {
+ d.NaN = true
+ return
+ }
+ // Simple case: decimal notation
+ if r.Increment > 0 {
+ scale := int(r.IncrementScale)
+ mult := 1.0
+ if scale >= len(scales) {
+ mult = math.Pow(10, float64(scale))
+ } else {
+ mult = scales[scale]
+ }
+ // We multiply x instead of dividing inc as it gives less rounding
+ // issues.
+ x *= mult
+ x /= float64(r.Increment)
+ x = r.Mode.roundFloat(x)
+ x *= float64(r.Increment)
+ x /= mult
+ }
+
+ abs := x
+ if x < 0 {
+ d.Neg = true
+ abs = -x
+ }
+ if math.IsInf(abs, 1) {
+ d.Inf = true
+ return
+ }
+
+ // By default we get the exact decimal representation.
+ verb := byte('g')
+ prec := -1
+ // As the strconv API does not return the rounding accuracy, we can only
+ // round using ToNearestEven.
+ if r.Mode == ToNearestEven {
+ if n := r.RoundSignificantDigits(); n >= 0 {
+ prec = n
+ } else if n = r.RoundFractionDigits(); n >= 0 {
+ prec = n
+ verb = 'f'
+ }
+ } else {
+ // TODO: At this point strconv's rounding is imprecise to the point that
+ // it is not useable for this purpose.
+ // See https://github.com/golang/go/issues/21714
+ // If rounding is requested, we ask for a large number of digits and
+ // round from there to simulate rounding only once.
+ // Ideally we would have strconv export an AppendDigits that would take
+ // a rounding mode and/or return an accuracy. Something like this would
+ // work:
+ // AppendDigits(dst []byte, x float64, base, size, prec int) (digits []byte, exp, accuracy int)
+ hasPrec := r.RoundSignificantDigits() >= 0
+ hasScale := r.RoundFractionDigits() >= 0
+ if hasPrec || hasScale {
+ // prec is the number of mantissa bits plus some extra for safety.
+ // We need at least the number of mantissa bits as decimals to
+ // accurately represent the floating point without rounding, as each
+ // bit requires one more decimal to represent: 0.5, 0.25, 0.125, ...
+ prec = 60
+ }
+ }
+
+ b := strconv.AppendFloat(d.Digits[:0], abs, verb, prec, size)
+ i := 0
+ k := 0
+ beforeDot := 1
+ for i < len(b) {
+ if c := b[i]; '0' <= c && c <= '9' {
+ b[k] = c - '0'
+ k++
+ d.Exp += int32(beforeDot)
+ } else if c == '.' {
+ beforeDot = 0
+ d.Exp = int32(k)
+ } else {
+ break
+ }
+ i++
+ }
+ d.Digits = b[:k]
+ if i != len(b) {
+ i += len("e")
+ pSign := i
+ exp := 0
+ for i++; i < len(b); i++ {
+ exp *= 10
+ exp += int(b[i] - '0')
+ }
+ if b[pSign] == '-' {
+ exp = -exp
+ }
+ d.Exp = int32(exp) + 1
+ }
+}
+
+func (d *Decimal) fillIntDigits(x uint64) {
+ if cap(d.Digits) < maxIntDigits {
+ d.Digits = d.buf[:]
+ } else {
+ d.Digits = d.buf[:maxIntDigits]
+ }
+ i := 0
+ for ; x > 0; x /= 10 {
+ d.Digits[i] = byte(x % 10)
+ i++
+ }
+ d.Digits = d.Digits[:i]
+ for p := 0; p < i; p++ {
+ i--
+ d.Digits[p], d.Digits[i] = d.Digits[i], d.Digits[p]
+ }
+}
+
+var scales [70]float64
+
+func init() {
+ x := 1.0
+ for i := range scales {
+ scales[i] = x
+ x *= 10
+ }
+}
diff --git a/vendor/golang.org/x/text/internal/number/format.go b/vendor/golang.org/x/text/internal/number/format.go
new file mode 100644
index 0000000..cd94c5d
--- /dev/null
+++ b/vendor/golang.org/x/text/internal/number/format.go
@@ -0,0 +1,535 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package number
+
+import (
+ "strconv"
+ "unicode/utf8"
+
+ "golang.org/x/text/language"
+)
+
+// TODO:
+// - grouping of fractions
+// - allow user-defined superscript notation (such as 4)
+// - same for non-breaking spaces, like
+
+// A VisibleDigits computes digits, comma placement and trailing zeros as they
+// will be shown to the user.
+type VisibleDigits interface {
+ Digits(buf []byte, t language.Tag, scale int) Digits
+ // TODO: Do we also need to add the verb or pass a format.State?
+}
+
+// Formatting proceeds along the following lines:
+// 0) Compose rounding information from format and context.
+// 1) Convert a number into a Decimal.
+// 2) Sanitize Decimal by adding trailing zeros, removing leading digits, and
+// (non-increment) rounding. The Decimal that results from this is suitable
+// for determining the plural form.
+// 3) Render the Decimal in the localized form.
+
+// Formatter contains all the information needed to render a number.
+type Formatter struct {
+ Pattern
+ Info
+}
+
+func (f *Formatter) init(t language.Tag, index []uint8) {
+ f.Info = InfoFromTag(t)
+ f.Pattern = formats[index[tagToID(t)]]
+}
+
+// InitPattern initializes a Formatter for the given Pattern.
+func (f *Formatter) InitPattern(t language.Tag, pat *Pattern) {
+ f.Info = InfoFromTag(t)
+ f.Pattern = *pat
+}
+
+// InitDecimal initializes a Formatter using the default Pattern for the given
+// language.
+func (f *Formatter) InitDecimal(t language.Tag) {
+ f.init(t, tagToDecimal)
+}
+
+// InitScientific initializes a Formatter using the default Pattern for the
+// given language.
+func (f *Formatter) InitScientific(t language.Tag) {
+ f.init(t, tagToScientific)
+ f.Pattern.MinFractionDigits = 0
+ f.Pattern.MaxFractionDigits = -1
+}
+
+// InitEngineering initializes a Formatter using the default Pattern for the
+// given language.
+func (f *Formatter) InitEngineering(t language.Tag) {
+ f.init(t, tagToScientific)
+ f.Pattern.MinFractionDigits = 0
+ f.Pattern.MaxFractionDigits = -1
+ f.Pattern.MaxIntegerDigits = 3
+ f.Pattern.MinIntegerDigits = 1
+}
+
+// InitPercent initializes a Formatter using the default Pattern for the given
+// language.
+func (f *Formatter) InitPercent(t language.Tag) {
+ f.init(t, tagToPercent)
+}
+
+// InitPerMille initializes a Formatter using the default Pattern for the given
+// language.
+func (f *Formatter) InitPerMille(t language.Tag) {
+ f.init(t, tagToPercent)
+ f.Pattern.DigitShift = 3
+}
+
+func (f *Formatter) Append(dst []byte, x interface{}) []byte {
+ var d Decimal
+ r := f.RoundingContext
+ d.Convert(r, x)
+ return f.Render(dst, FormatDigits(&d, r))
+}
+
+func FormatDigits(d *Decimal, r RoundingContext) Digits {
+ if r.isScientific() {
+ return scientificVisibleDigits(r, d)
+ }
+ return decimalVisibleDigits(r, d)
+}
+
+func (f *Formatter) Format(dst []byte, d *Decimal) []byte {
+ return f.Render(dst, FormatDigits(d, f.RoundingContext))
+}
+
+func (f *Formatter) Render(dst []byte, d Digits) []byte {
+ var result []byte
+ var postPrefix, preSuffix int
+ if d.IsScientific {
+ result, postPrefix, preSuffix = appendScientific(dst, f, &d)
+ } else {
+ result, postPrefix, preSuffix = appendDecimal(dst, f, &d)
+ }
+ if f.PadRune == 0 {
+ return result
+ }
+ width := int(f.FormatWidth)
+ if count := utf8.RuneCount(result); count < width {
+ insertPos := 0
+ switch f.Flags & PadMask {
+ case PadAfterPrefix:
+ insertPos = postPrefix
+ case PadBeforeSuffix:
+ insertPos = preSuffix
+ case PadAfterSuffix:
+ insertPos = len(result)
+ }
+ num := width - count
+ pad := [utf8.UTFMax]byte{' '}
+ sz := 1
+ if r := f.PadRune; r != 0 {
+ sz = utf8.EncodeRune(pad[:], r)
+ }
+ extra := sz * num
+ if n := len(result) + extra; n < cap(result) {
+ result = result[:n]
+ copy(result[insertPos+extra:], result[insertPos:])
+ } else {
+ buf := make([]byte, n)
+ copy(buf, result[:insertPos])
+ copy(buf[insertPos+extra:], result[insertPos:])
+ result = buf
+ }
+ for ; num > 0; num-- {
+ insertPos += copy(result[insertPos:], pad[:sz])
+ }
+ }
+ return result
+}
+
+// decimalVisibleDigits converts d according to the RoundingContext. Note that
+// the exponent may change as a result of this operation.
+func decimalVisibleDigits(r RoundingContext, d *Decimal) Digits {
+ if d.NaN || d.Inf {
+ return Digits{digits: digits{Neg: d.Neg, NaN: d.NaN, Inf: d.Inf}}
+ }
+ n := Digits{digits: d.normalize().digits}
+
+ exp := n.Exp
+ exp += int32(r.DigitShift)
+
+ // Cap integer digits. Remove *most-significant* digits.
+ if r.MaxIntegerDigits > 0 {
+ if p := int(exp) - int(r.MaxIntegerDigits); p > 0 {
+ if p > len(n.Digits) {
+ p = len(n.Digits)
+ }
+ if n.Digits = n.Digits[p:]; len(n.Digits) == 0 {
+ exp = 0
+ } else {
+ exp -= int32(p)
+ }
+ // Strip leading zeros.
+ for len(n.Digits) > 0 && n.Digits[0] == 0 {
+ n.Digits = n.Digits[1:]
+ exp--
+ }
+ }
+ }
+
+ // Rounding if not already done by Convert.
+ p := len(n.Digits)
+ if maxSig := int(r.MaxSignificantDigits); maxSig > 0 {
+ p = maxSig
+ }
+ if maxFrac := int(r.MaxFractionDigits); maxFrac >= 0 {
+ if cap := int(exp) + maxFrac; cap < p {
+ p = int(exp) + maxFrac
+ }
+ if p < 0 {
+ p = 0
+ }
+ }
+ n.round(r.Mode, p)
+
+ // set End (trailing zeros)
+ n.End = int32(len(n.Digits))
+ if n.End == 0 {
+ exp = 0
+ if r.MinFractionDigits > 0 {
+ n.End = int32(r.MinFractionDigits)
+ }
+ if p := int32(r.MinSignificantDigits) - 1; p > n.End {
+ n.End = p
+ }
+ } else {
+ if end := exp + int32(r.MinFractionDigits); end > n.End {
+ n.End = end
+ }
+ if n.End < int32(r.MinSignificantDigits) {
+ n.End = int32(r.MinSignificantDigits)
+ }
+ }
+ n.Exp = exp
+ return n
+}
+
+// appendDecimal appends a formatted number to dst. It returns two possible
+// insertion points for padding.
+func appendDecimal(dst []byte, f *Formatter, n *Digits) (b []byte, postPre, preSuf int) {
+ if dst, ok := f.renderSpecial(dst, n); ok {
+ return dst, 0, len(dst)
+ }
+ digits := n.Digits
+ exp := n.Exp
+
+ // Split in integer and fraction part.
+ var intDigits, fracDigits []byte
+ numInt := 0
+ numFrac := int(n.End - n.Exp)
+ if exp > 0 {
+ numInt = int(exp)
+ if int(exp) >= len(digits) { // ddddd | ddddd00
+ intDigits = digits
+ } else { // ddd.dd
+ intDigits = digits[:exp]
+ fracDigits = digits[exp:]
+ }
+ } else {
+ fracDigits = digits
+ }
+
+ neg := n.Neg
+ affix, suffix := f.getAffixes(neg)
+ dst = appendAffix(dst, f, affix, neg)
+ savedLen := len(dst)
+
+ minInt := int(f.MinIntegerDigits)
+ if minInt == 0 && f.MinSignificantDigits > 0 {
+ minInt = 1
+ }
+ // add leading zeros
+ for i := minInt; i > numInt; i-- {
+ dst = f.AppendDigit(dst, 0)
+ if f.needsSep(i) {
+ dst = append(dst, f.Symbol(SymGroup)...)
+ }
+ }
+ i := 0
+ for ; i < len(intDigits); i++ {
+ dst = f.AppendDigit(dst, intDigits[i])
+ if f.needsSep(numInt - i) {
+ dst = append(dst, f.Symbol(SymGroup)...)
+ }
+ }
+ for ; i < numInt; i++ {
+ dst = f.AppendDigit(dst, 0)
+ if f.needsSep(numInt - i) {
+ dst = append(dst, f.Symbol(SymGroup)...)
+ }
+ }
+
+ if numFrac > 0 || f.Flags&AlwaysDecimalSeparator != 0 {
+ dst = append(dst, f.Symbol(SymDecimal)...)
+ }
+ // Add trailing zeros
+ i = 0
+ for n := -int(n.Exp); i < n; i++ {
+ dst = f.AppendDigit(dst, 0)
+ }
+ for _, d := range fracDigits {
+ i++
+ dst = f.AppendDigit(dst, d)
+ }
+ for ; i < numFrac; i++ {
+ dst = f.AppendDigit(dst, 0)
+ }
+ return appendAffix(dst, f, suffix, neg), savedLen, len(dst)
+}
+
+func scientificVisibleDigits(r RoundingContext, d *Decimal) Digits {
+ if d.NaN || d.Inf {
+ return Digits{digits: digits{Neg: d.Neg, NaN: d.NaN, Inf: d.Inf}}
+ }
+ n := Digits{digits: d.normalize().digits, IsScientific: true}
+
+ // Normalize to have at least one digit. This simplifies engineering
+ // notation.
+ if len(n.Digits) == 0 {
+ n.Digits = append(n.Digits, 0)
+ n.Exp = 1
+ }
+
+ // Significant digits are transformed by the parser for scientific notation
+ // and do not need to be handled here.
+ maxInt, numInt := int(r.MaxIntegerDigits), int(r.MinIntegerDigits)
+ if numInt == 0 {
+ numInt = 1
+ }
+
+ // If a maximum number of integers is specified, the minimum must be 1
+ // and the exponent is grouped by this number (e.g. for engineering)
+ if maxInt > numInt {
+ // Correct the exponent to reflect a single integer digit.
+ numInt = 1
+ // engineering
+ // 0.01234 ([12345]e-1) -> 1.2345e-2 12.345e-3
+ // 12345 ([12345]e+5) -> 1.2345e4 12.345e3
+ d := int(n.Exp-1) % maxInt
+ if d < 0 {
+ d += maxInt
+ }
+ numInt += d
+ }
+
+ p := len(n.Digits)
+ if maxSig := int(r.MaxSignificantDigits); maxSig > 0 {
+ p = maxSig
+ }
+ if maxFrac := int(r.MaxFractionDigits); maxFrac >= 0 && numInt+maxFrac < p {
+ p = numInt + maxFrac
+ }
+ n.round(r.Mode, p)
+
+ n.Comma = uint8(numInt)
+ n.End = int32(len(n.Digits))
+ if minSig := int32(r.MinFractionDigits) + int32(numInt); n.End < minSig {
+ n.End = minSig
+ }
+ return n
+}
+
+// appendScientific appends a formatted number to dst. It returns two possible
+// insertion points for padding.
+func appendScientific(dst []byte, f *Formatter, n *Digits) (b []byte, postPre, preSuf int) {
+ if dst, ok := f.renderSpecial(dst, n); ok {
+ return dst, 0, 0
+ }
+ digits := n.Digits
+ numInt := int(n.Comma)
+ numFrac := int(n.End) - int(n.Comma)
+
+ var intDigits, fracDigits []byte
+ if numInt <= len(digits) {
+ intDigits = digits[:numInt]
+ fracDigits = digits[numInt:]
+ } else {
+ intDigits = digits
+ }
+ neg := n.Neg
+ affix, suffix := f.getAffixes(neg)
+ dst = appendAffix(dst, f, affix, neg)
+ savedLen := len(dst)
+
+ i := 0
+ for ; i < len(intDigits); i++ {
+ dst = f.AppendDigit(dst, intDigits[i])
+ if f.needsSep(numInt - i) {
+ dst = append(dst, f.Symbol(SymGroup)...)
+ }
+ }
+ for ; i < numInt; i++ {
+ dst = f.AppendDigit(dst, 0)
+ if f.needsSep(numInt - i) {
+ dst = append(dst, f.Symbol(SymGroup)...)
+ }
+ }
+
+ if numFrac > 0 || f.Flags&AlwaysDecimalSeparator != 0 {
+ dst = append(dst, f.Symbol(SymDecimal)...)
+ }
+ i = 0
+ for ; i < len(fracDigits); i++ {
+ dst = f.AppendDigit(dst, fracDigits[i])
+ }
+ for ; i < numFrac; i++ {
+ dst = f.AppendDigit(dst, 0)
+ }
+
+ // exp
+ buf := [12]byte{}
+ // TODO: use exponential if superscripting is not available (no Latin
+ // numbers or no tags) and use exponential in all other cases.
+ exp := n.Exp - int32(n.Comma)
+ exponential := f.Symbol(SymExponential)
+ if exponential == "E" {
+ dst = append(dst, "\u202f"...) // NARROW NO-BREAK SPACE
+ dst = append(dst, f.Symbol(SymSuperscriptingExponent)...)
+ dst = append(dst, "\u202f"...) // NARROW NO-BREAK SPACE
+ dst = f.AppendDigit(dst, 1)
+ dst = f.AppendDigit(dst, 0)
+ switch {
+ case exp < 0:
+ dst = append(dst, superMinus...)
+ exp = -exp
+ case f.Flags&AlwaysExpSign != 0:
+ dst = append(dst, superPlus...)
+ }
+ b = strconv.AppendUint(buf[:0], uint64(exp), 10)
+ for i := len(b); i < int(f.MinExponentDigits); i++ {
+ dst = append(dst, superDigits[0]...)
+ }
+ for _, c := range b {
+ dst = append(dst, superDigits[c-'0']...)
+ }
+ } else {
+ dst = append(dst, exponential...)
+ switch {
+ case exp < 0:
+ dst = append(dst, f.Symbol(SymMinusSign)...)
+ exp = -exp
+ case f.Flags&AlwaysExpSign != 0:
+ dst = append(dst, f.Symbol(SymPlusSign)...)
+ }
+ b = strconv.AppendUint(buf[:0], uint64(exp), 10)
+ for i := len(b); i < int(f.MinExponentDigits); i++ {
+ dst = f.AppendDigit(dst, 0)
+ }
+ for _, c := range b {
+ dst = f.AppendDigit(dst, c-'0')
+ }
+ }
+ return appendAffix(dst, f, suffix, neg), savedLen, len(dst)
+}
+
+const (
+ superMinus = "\u207B" // SUPERSCRIPT HYPHEN-MINUS
+ superPlus = "\u207A" // SUPERSCRIPT PLUS SIGN
+)
+
+var (
+ // Note: the digits are not sequential!!!
+ superDigits = []string{
+ "\u2070", // SUPERSCRIPT DIGIT ZERO
+ "\u00B9", // SUPERSCRIPT DIGIT ONE
+ "\u00B2", // SUPERSCRIPT DIGIT TWO
+ "\u00B3", // SUPERSCRIPT DIGIT THREE
+ "\u2074", // SUPERSCRIPT DIGIT FOUR
+ "\u2075", // SUPERSCRIPT DIGIT FIVE
+ "\u2076", // SUPERSCRIPT DIGIT SIX
+ "\u2077", // SUPERSCRIPT DIGIT SEVEN
+ "\u2078", // SUPERSCRIPT DIGIT EIGHT
+ "\u2079", // SUPERSCRIPT DIGIT NINE
+ }
+)
+
+func (f *Formatter) getAffixes(neg bool) (affix, suffix string) {
+ str := f.Affix
+ if str != "" {
+ if f.NegOffset > 0 {
+ if neg {
+ str = str[f.NegOffset:]
+ } else {
+ str = str[:f.NegOffset]
+ }
+ }
+ sufStart := 1 + str[0]
+ affix = str[1:sufStart]
+ suffix = str[sufStart+1:]
+ }
+ // TODO: introduce a NeedNeg sign to indicate if the left pattern already
+ // has a sign marked?
+ if f.NegOffset == 0 && (neg || f.Flags&AlwaysSign != 0) {
+ affix = "-" + affix
+ }
+ return affix, suffix
+}
+
+func (f *Formatter) renderSpecial(dst []byte, d *Digits) (b []byte, ok bool) {
+ if d.NaN {
+ return fmtNaN(dst, f), true
+ }
+ if d.Inf {
+ return fmtInfinite(dst, f, d), true
+ }
+ return dst, false
+}
+
+func fmtNaN(dst []byte, f *Formatter) []byte {
+ return append(dst, f.Symbol(SymNan)...)
+}
+
+func fmtInfinite(dst []byte, f *Formatter, d *Digits) []byte {
+ affix, suffix := f.getAffixes(d.Neg)
+ dst = appendAffix(dst, f, affix, d.Neg)
+ dst = append(dst, f.Symbol(SymInfinity)...)
+ dst = appendAffix(dst, f, suffix, d.Neg)
+ return dst
+}
+
+func appendAffix(dst []byte, f *Formatter, affix string, neg bool) []byte {
+ quoting := false
+ escaping := false
+ for _, r := range affix {
+ switch {
+ case escaping:
+ // escaping occurs both inside and outside of quotes
+ dst = append(dst, string(r)...)
+ escaping = false
+ case r == '\\':
+ escaping = true
+ case r == '\'':
+ quoting = !quoting
+ case quoting:
+ dst = append(dst, string(r)...)
+ case r == '%':
+ if f.DigitShift == 3 {
+ dst = append(dst, f.Symbol(SymPerMille)...)
+ } else {
+ dst = append(dst, f.Symbol(SymPercentSign)...)
+ }
+ case r == '-' || r == '+':
+ if neg {
+ dst = append(dst, f.Symbol(SymMinusSign)...)
+ } else if f.Flags&ElideSign == 0 {
+ dst = append(dst, f.Symbol(SymPlusSign)...)
+ } else {
+ dst = append(dst, ' ')
+ }
+ default:
+ dst = append(dst, string(r)...)
+ }
+ }
+ return dst
+}
diff --git a/vendor/golang.org/x/text/internal/number/number.go b/vendor/golang.org/x/text/internal/number/number.go
new file mode 100644
index 0000000..e1d933c
--- /dev/null
+++ b/vendor/golang.org/x/text/internal/number/number.go
@@ -0,0 +1,152 @@
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:generate go run gen.go gen_common.go
+
+// Package number contains tools and data for formatting numbers.
+package number
+
+import (
+ "unicode/utf8"
+
+ "golang.org/x/text/internal/language/compact"
+ "golang.org/x/text/language"
+)
+
+// Info holds number formatting configuration data.
+type Info struct {
+ system systemData // numbering system information
+ symIndex symOffset // index to symbols
+}
+
+// InfoFromLangID returns a Info for the given compact language identifier and
+// numbering system identifier. If system is the empty string, the default
+// numbering system will be taken for that language.
+func InfoFromLangID(compactIndex compact.ID, numberSystem string) Info {
+ p := langToDefaults[compactIndex]
+ // Lookup the entry for the language.
+ pSymIndex := symOffset(0) // Default: Latin, default symbols
+ system, ok := systemMap[numberSystem]
+ if !ok {
+ // Take the value for the default numbering system. This is by far the
+ // most common case as an alternative numbering system is hardly used.
+ if p&hasNonLatnMask == 0 { // Latn digits.
+ pSymIndex = p
+ } else { // Non-Latn or multiple numbering systems.
+ // Take the first entry from the alternatives list.
+ data := langToAlt[p&^hasNonLatnMask]
+ pSymIndex = data.symIndex
+ system = data.system
+ }
+ } else {
+ langIndex := compactIndex
+ ns := system
+ outerLoop:
+ for ; ; p = langToDefaults[langIndex] {
+ if p&hasNonLatnMask == 0 {
+ if ns == 0 {
+ // The index directly points to the symbol data.
+ pSymIndex = p
+ break
+ }
+ // Move to the parent and retry.
+ langIndex = langIndex.Parent()
+ } else {
+ // The index points to a list of symbol data indexes.
+ for _, e := range langToAlt[p&^hasNonLatnMask:] {
+ if e.compactTag != langIndex {
+ if langIndex == 0 {
+ // The CLDR root defines full symbol information for
+ // all numbering systems (even though mostly by
+ // means of aliases). Fall back to the default entry
+ // for Latn if there is no data for the numbering
+ // system of this language.
+ if ns == 0 {
+ break
+ }
+ // Fall back to Latin and start from the original
+ // language. See
+ // https://unicode.org/reports/tr35/#Locale_Inheritance.
+ ns = numLatn
+ langIndex = compactIndex
+ continue outerLoop
+ }
+ // Fall back to parent.
+ langIndex = langIndex.Parent()
+ } else if e.system == ns {
+ pSymIndex = e.symIndex
+ break outerLoop
+ }
+ }
+ }
+ }
+ }
+ if int(system) >= len(numSysData) { // algorithmic
+ // Will generate ASCII digits in case the user inadvertently calls
+ // WriteDigit or Digit on it.
+ d := numSysData[0]
+ d.id = system
+ return Info{
+ system: d,
+ symIndex: pSymIndex,
+ }
+ }
+ return Info{
+ system: numSysData[system],
+ symIndex: pSymIndex,
+ }
+}
+
+// InfoFromTag returns a Info for the given language tag.
+func InfoFromTag(t language.Tag) Info {
+ return InfoFromLangID(tagToID(t), t.TypeForKey("nu"))
+}
+
+// IsDecimal reports if the numbering system can convert decimal to native
+// symbols one-to-one.
+func (n Info) IsDecimal() bool {
+ return int(n.system.id) < len(numSysData)
+}
+
+// WriteDigit writes the UTF-8 sequence for n corresponding to the given ASCII
+// digit to dst and reports the number of bytes written. dst must be large
+// enough to hold the rune (can be up to utf8.UTFMax bytes).
+func (n Info) WriteDigit(dst []byte, asciiDigit rune) int {
+ copy(dst, n.system.zero[:n.system.digitSize])
+ dst[n.system.digitSize-1] += byte(asciiDigit - '0')
+ return int(n.system.digitSize)
+}
+
+// AppendDigit appends the UTF-8 sequence for n corresponding to the given digit
+// to dst and reports the number of bytes written. dst must be large enough to
+// hold the rune (can be up to utf8.UTFMax bytes).
+func (n Info) AppendDigit(dst []byte, digit byte) []byte {
+ dst = append(dst, n.system.zero[:n.system.digitSize]...)
+ dst[len(dst)-1] += digit
+ return dst
+}
+
+// Digit returns the digit for the numbering system for the corresponding ASCII
+// value. For example, ni.Digit('3') could return '三'. Note that the argument
+// is the rune constant '3', which equals 51, not the integer constant 3.
+func (n Info) Digit(asciiDigit rune) rune {
+ var x [utf8.UTFMax]byte
+ n.WriteDigit(x[:], asciiDigit)
+ r, _ := utf8.DecodeRune(x[:])
+ return r
+}
+
+// Symbol returns the string for the given symbol type.
+func (n Info) Symbol(t SymbolType) string {
+ return symData.Elem(int(symIndex[n.symIndex][t]))
+}
+
+func formatForLang(t language.Tag, index []byte) *Pattern {
+ return &formats[index[tagToID(t)]]
+}
+
+func tagToID(t language.Tag) compact.ID {
+ id, _ := compact.RegionalID(compact.Tag(t))
+ return id
+}
diff --git a/vendor/golang.org/x/text/internal/number/pattern.go b/vendor/golang.org/x/text/internal/number/pattern.go
new file mode 100644
index 0000000..06e5955
--- /dev/null
+++ b/vendor/golang.org/x/text/internal/number/pattern.go
@@ -0,0 +1,485 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package number
+
+import (
+ "errors"
+ "unicode/utf8"
+)
+
+// This file contains a parser for the CLDR number patterns as described in
+// https://unicode.org/reports/tr35/tr35-numbers.html#Number_Format_Patterns.
+//
+// The following BNF is derived from this standard.
+//
+// pattern := subpattern (';' subpattern)?
+// subpattern := affix? number exponent? affix?
+// number := decimal | sigDigits
+// decimal := '#'* '0'* ('.' fraction)? | '#' | '0'
+// fraction := '0'* '#'*
+// sigDigits := '#'* '@' '@'* '#'*
+// exponent := 'E' '+'? '0'* '0'
+// padSpec := '*' \L
+//
+// Notes:
+// - An affix pattern may contain any runes, but runes with special meaning
+// should be escaped.
+// - Sequences of digits, '#', and '@' in decimal and sigDigits may have
+// interstitial commas.
+
+// TODO: replace special characters in affixes (-, +, ¤) with control codes.
+
+// Pattern holds information for formatting numbers. It is designed to hold
+// information from CLDR number patterns.
+//
+// This pattern is precompiled for all patterns for all languages. Even though
+// the number of patterns is not very large, we want to keep this small.
+//
+// This type is only intended for internal use.
+type Pattern struct {
+ RoundingContext
+
+ Affix string // includes prefix and suffix. First byte is prefix length.
+ Offset uint16 // Offset into Affix for prefix and suffix
+ NegOffset uint16 // Offset into Affix for negative prefix and suffix or 0.
+ PadRune rune
+ FormatWidth uint16
+
+ GroupingSize [2]uint8
+ Flags PatternFlag
+}
+
+// A RoundingContext indicates how a number should be converted to digits.
+// It contains all information needed to determine the "visible digits" as
+// required by the pluralization rules.
+type RoundingContext struct {
+ // TODO: unify these two fields so that there is a more unambiguous meaning
+ // of how precision is handled.
+ MaxSignificantDigits int16 // -1 is unlimited
+ MaxFractionDigits int16 // -1 is unlimited
+
+ Increment uint32
+ IncrementScale uint8 // May differ from printed scale.
+
+ Mode RoundingMode
+
+ DigitShift uint8 // Number of decimals to shift. Used for % and ‰.
+
+ // Number of digits.
+ MinIntegerDigits uint8
+
+ MaxIntegerDigits uint8
+ MinFractionDigits uint8
+ MinSignificantDigits uint8
+
+ MinExponentDigits uint8
+}
+
+// RoundSignificantDigits returns the number of significant digits an
+// implementation of Convert may round to or n < 0 if there is no maximum or
+// a maximum is not recommended.
+func (r *RoundingContext) RoundSignificantDigits() (n int) {
+ if r.MaxFractionDigits == 0 && r.MaxSignificantDigits > 0 {
+ return int(r.MaxSignificantDigits)
+ } else if r.isScientific() && r.MaxIntegerDigits == 1 {
+ if r.MaxSignificantDigits == 0 ||
+ int(r.MaxFractionDigits+1) == int(r.MaxSignificantDigits) {
+ // Note: don't add DigitShift: it is only used for decimals.
+ return int(r.MaxFractionDigits) + 1
+ }
+ }
+ return -1
+}
+
+// RoundFractionDigits returns the number of fraction digits an implementation
+// of Convert may round to or n < 0 if there is no maximum or a maximum is not
+// recommended.
+func (r *RoundingContext) RoundFractionDigits() (n int) {
+ if r.MinExponentDigits == 0 &&
+ r.MaxSignificantDigits == 0 &&
+ r.MaxFractionDigits >= 0 {
+ return int(r.MaxFractionDigits) + int(r.DigitShift)
+ }
+ return -1
+}
+
+// SetScale fixes the RoundingContext to a fixed number of fraction digits.
+func (r *RoundingContext) SetScale(scale int) {
+ r.MinFractionDigits = uint8(scale)
+ r.MaxFractionDigits = int16(scale)
+}
+
+func (r *RoundingContext) SetPrecision(prec int) {
+ r.MaxSignificantDigits = int16(prec)
+}
+
+func (r *RoundingContext) isScientific() bool {
+ return r.MinExponentDigits > 0
+}
+
+func (f *Pattern) needsSep(pos int) bool {
+ p := pos - 1
+ size := int(f.GroupingSize[0])
+ if size == 0 || p == 0 {
+ return false
+ }
+ if p == size {
+ return true
+ }
+ if p -= size; p < 0 {
+ return false
+ }
+ // TODO: make second groupingsize the same as first if 0 so that we can
+ // avoid this check.
+ if x := int(f.GroupingSize[1]); x != 0 {
+ size = x
+ }
+ return p%size == 0
+}
+
+// A PatternFlag is a bit mask for the flag field of a Pattern.
+type PatternFlag uint8
+
+const (
+ AlwaysSign PatternFlag = 1 << iota
+ ElideSign // Use space instead of plus sign. AlwaysSign must be true.
+ AlwaysExpSign
+ AlwaysDecimalSeparator
+ ParenthesisForNegative // Common pattern. Saves space.
+
+ PadAfterNumber
+ PadAfterAffix
+
+ PadBeforePrefix = 0 // Default
+ PadAfterPrefix = PadAfterAffix
+ PadBeforeSuffix = PadAfterNumber
+ PadAfterSuffix = PadAfterNumber | PadAfterAffix
+ PadMask = PadAfterNumber | PadAfterAffix
+)
+
+type parser struct {
+ *Pattern
+
+ leadingSharps int
+
+ pos int
+ err error
+ doNotTerminate bool
+ groupingCount uint
+ hasGroup bool
+ buf []byte
+}
+
+func (p *parser) setError(err error) {
+ if p.err == nil {
+ p.err = err
+ }
+}
+
+func (p *parser) updateGrouping() {
+ if p.hasGroup &&
+ 0 < p.groupingCount && p.groupingCount < 255 {
+ p.GroupingSize[1] = p.GroupingSize[0]
+ p.GroupingSize[0] = uint8(p.groupingCount)
+ }
+ p.groupingCount = 0
+ p.hasGroup = true
+}
+
+var (
+ // TODO: more sensible and localizeable error messages.
+ errMultiplePadSpecifiers = errors.New("format: pattern has multiple pad specifiers")
+ errInvalidPadSpecifier = errors.New("format: invalid pad specifier")
+ errInvalidQuote = errors.New("format: invalid quote")
+ errAffixTooLarge = errors.New("format: prefix or suffix exceeds maximum UTF-8 length of 256 bytes")
+ errDuplicatePercentSign = errors.New("format: duplicate percent sign")
+ errDuplicatePermilleSign = errors.New("format: duplicate permille sign")
+ errUnexpectedEnd = errors.New("format: unexpected end of pattern")
+)
+
+// ParsePattern extracts formatting information from a CLDR number pattern.
+//
+// See https://unicode.org/reports/tr35/tr35-numbers.html#Number_Format_Patterns.
+func ParsePattern(s string) (f *Pattern, err error) {
+ p := parser{Pattern: &Pattern{}}
+
+ s = p.parseSubPattern(s)
+
+ if s != "" {
+ // Parse negative sub pattern.
+ if s[0] != ';' {
+ p.setError(errors.New("format: error parsing first sub pattern"))
+ return nil, p.err
+ }
+ neg := parser{Pattern: &Pattern{}} // just for extracting the affixes.
+ s = neg.parseSubPattern(s[len(";"):])
+ p.NegOffset = uint16(len(p.buf))
+ p.buf = append(p.buf, neg.buf...)
+ }
+ if s != "" {
+ p.setError(errors.New("format: spurious characters at end of pattern"))
+ }
+ if p.err != nil {
+ return nil, p.err
+ }
+ if affix := string(p.buf); affix == "\x00\x00" || affix == "\x00\x00\x00\x00" {
+ // No prefix or suffixes.
+ p.NegOffset = 0
+ } else {
+ p.Affix = affix
+ }
+ if p.Increment == 0 {
+ p.IncrementScale = 0
+ }
+ return p.Pattern, nil
+}
+
+func (p *parser) parseSubPattern(s string) string {
+ s = p.parsePad(s, PadBeforePrefix)
+ s = p.parseAffix(s)
+ s = p.parsePad(s, PadAfterPrefix)
+
+ s = p.parse(p.number, s)
+ p.updateGrouping()
+
+ s = p.parsePad(s, PadBeforeSuffix)
+ s = p.parseAffix(s)
+ s = p.parsePad(s, PadAfterSuffix)
+ return s
+}
+
+func (p *parser) parsePad(s string, f PatternFlag) (tail string) {
+ if len(s) >= 2 && s[0] == '*' {
+ r, sz := utf8.DecodeRuneInString(s[1:])
+ if p.PadRune != 0 {
+ p.err = errMultiplePadSpecifiers
+ } else {
+ p.Flags |= f
+ p.PadRune = r
+ }
+ return s[1+sz:]
+ }
+ return s
+}
+
+func (p *parser) parseAffix(s string) string {
+ x := len(p.buf)
+ p.buf = append(p.buf, 0) // placeholder for affix length
+
+ s = p.parse(p.affix, s)
+
+ n := len(p.buf) - x - 1
+ if n > 0xFF {
+ p.setError(errAffixTooLarge)
+ }
+ p.buf[x] = uint8(n)
+ return s
+}
+
+// state implements a state transition. It returns the new state. A state
+// function may set an error on the parser or may simply return on an incorrect
+// token and let the next phase fail.
+type state func(r rune) state
+
+// parse repeatedly applies a state function on the given string until a
+// termination condition is reached.
+func (p *parser) parse(fn state, s string) (tail string) {
+ for i, r := range s {
+ p.doNotTerminate = false
+ if fn = fn(r); fn == nil || p.err != nil {
+ return s[i:]
+ }
+ p.FormatWidth++
+ }
+ if p.doNotTerminate {
+ p.setError(errUnexpectedEnd)
+ }
+ return ""
+}
+
+func (p *parser) affix(r rune) state {
+ switch r {
+ case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+ '#', '@', '.', '*', ',', ';':
+ return nil
+ case '\'':
+ p.FormatWidth--
+ return p.escapeFirst
+ case '%':
+ if p.DigitShift != 0 {
+ p.setError(errDuplicatePercentSign)
+ }
+ p.DigitShift = 2
+ case '\u2030': // ‰ Per mille
+ if p.DigitShift != 0 {
+ p.setError(errDuplicatePermilleSign)
+ }
+ p.DigitShift = 3
+ // TODO: handle currency somehow: ¤, ¤¤, ¤¤¤, ¤¤¤¤
+ }
+ p.buf = append(p.buf, string(r)...)
+ return p.affix
+}
+
+func (p *parser) escapeFirst(r rune) state {
+ switch r {
+ case '\'':
+ p.buf = append(p.buf, "\\'"...)
+ return p.affix
+ default:
+ p.buf = append(p.buf, '\'')
+ p.buf = append(p.buf, string(r)...)
+ }
+ return p.escape
+}
+
+func (p *parser) escape(r rune) state {
+ switch r {
+ case '\'':
+ p.FormatWidth--
+ p.buf = append(p.buf, '\'')
+ return p.affix
+ default:
+ p.buf = append(p.buf, string(r)...)
+ }
+ return p.escape
+}
+
+// number parses a number. The BNF says the integer part should always have
+// a '0', but that does not appear to be the case according to the rest of the
+// documentation. We will allow having only '#' numbers.
+func (p *parser) number(r rune) state {
+ switch r {
+ case '#':
+ p.groupingCount++
+ p.leadingSharps++
+ case '@':
+ p.groupingCount++
+ p.leadingSharps = 0
+ p.MaxFractionDigits = -1
+ return p.sigDigits(r)
+ case ',':
+ if p.leadingSharps == 0 { // no leading commas
+ return nil
+ }
+ p.updateGrouping()
+ case 'E':
+ p.MaxIntegerDigits = uint8(p.leadingSharps)
+ return p.exponent
+ case '.': // allow ".##" etc.
+ p.updateGrouping()
+ return p.fraction
+ case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
+ return p.integer(r)
+ default:
+ return nil
+ }
+ return p.number
+}
+
+func (p *parser) integer(r rune) state {
+ if !('0' <= r && r <= '9') {
+ var next state
+ switch r {
+ case 'E':
+ if p.leadingSharps > 0 {
+ p.MaxIntegerDigits = uint8(p.leadingSharps) + p.MinIntegerDigits
+ }
+ next = p.exponent
+ case '.':
+ next = p.fraction
+ case ',':
+ next = p.integer
+ }
+ p.updateGrouping()
+ return next
+ }
+ p.Increment = p.Increment*10 + uint32(r-'0')
+ p.groupingCount++
+ p.MinIntegerDigits++
+ return p.integer
+}
+
+func (p *parser) sigDigits(r rune) state {
+ switch r {
+ case '@':
+ p.groupingCount++
+ p.MaxSignificantDigits++
+ p.MinSignificantDigits++
+ case '#':
+ return p.sigDigitsFinal(r)
+ case 'E':
+ p.updateGrouping()
+ return p.normalizeSigDigitsWithExponent()
+ default:
+ p.updateGrouping()
+ return nil
+ }
+ return p.sigDigits
+}
+
+func (p *parser) sigDigitsFinal(r rune) state {
+ switch r {
+ case '#':
+ p.groupingCount++
+ p.MaxSignificantDigits++
+ case 'E':
+ p.updateGrouping()
+ return p.normalizeSigDigitsWithExponent()
+ default:
+ p.updateGrouping()
+ return nil
+ }
+ return p.sigDigitsFinal
+}
+
+func (p *parser) normalizeSigDigitsWithExponent() state {
+ p.MinIntegerDigits, p.MaxIntegerDigits = 1, 1
+ p.MinFractionDigits = p.MinSignificantDigits - 1
+ p.MaxFractionDigits = p.MaxSignificantDigits - 1
+ p.MinSignificantDigits, p.MaxSignificantDigits = 0, 0
+ return p.exponent
+}
+
+func (p *parser) fraction(r rune) state {
+ switch r {
+ case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
+ p.Increment = p.Increment*10 + uint32(r-'0')
+ p.IncrementScale++
+ p.MinFractionDigits++
+ p.MaxFractionDigits++
+ case '#':
+ p.MaxFractionDigits++
+ case 'E':
+ if p.leadingSharps > 0 {
+ p.MaxIntegerDigits = uint8(p.leadingSharps) + p.MinIntegerDigits
+ }
+ return p.exponent
+ default:
+ return nil
+ }
+ return p.fraction
+}
+
+func (p *parser) exponent(r rune) state {
+ switch r {
+ case '+':
+ // Set mode and check it wasn't already set.
+ if p.Flags&AlwaysExpSign != 0 || p.MinExponentDigits > 0 {
+ break
+ }
+ p.Flags |= AlwaysExpSign
+ p.doNotTerminate = true
+ return p.exponent
+ case '0':
+ p.MinExponentDigits++
+ return p.exponent
+ }
+ // termination condition
+ if p.MinExponentDigits == 0 {
+ p.setError(errors.New("format: need at least one digit"))
+ }
+ return nil
+}
diff --git a/vendor/golang.org/x/text/internal/number/roundingmode_string.go b/vendor/golang.org/x/text/internal/number/roundingmode_string.go
new file mode 100644
index 0000000..bcc2247
--- /dev/null
+++ b/vendor/golang.org/x/text/internal/number/roundingmode_string.go
@@ -0,0 +1,30 @@
+// Code generated by "stringer -type RoundingMode"; DO NOT EDIT.
+
+package number
+
+import "strconv"
+
+func _() {
+ // An "invalid array index" compiler error signifies that the constant values have changed.
+ // Re-run the stringer command to generate them again.
+ var x [1]struct{}
+ _ = x[ToNearestEven-0]
+ _ = x[ToNearestZero-1]
+ _ = x[ToNearestAway-2]
+ _ = x[ToPositiveInf-3]
+ _ = x[ToNegativeInf-4]
+ _ = x[ToZero-5]
+ _ = x[AwayFromZero-6]
+ _ = x[numModes-7]
+}
+
+const _RoundingMode_name = "ToNearestEvenToNearestZeroToNearestAwayToPositiveInfToNegativeInfToZeroAwayFromZeronumModes"
+
+var _RoundingMode_index = [...]uint8{0, 13, 26, 39, 52, 65, 71, 83, 91}
+
+func (i RoundingMode) String() string {
+ if i >= RoundingMode(len(_RoundingMode_index)-1) {
+ return "RoundingMode(" + strconv.FormatInt(int64(i), 10) + ")"
+ }
+ return _RoundingMode_name[_RoundingMode_index[i]:_RoundingMode_index[i+1]]
+}
diff --git a/vendor/golang.org/x/text/internal/number/tables.go b/vendor/golang.org/x/text/internal/number/tables.go
new file mode 100644
index 0000000..0668a37
--- /dev/null
+++ b/vendor/golang.org/x/text/internal/number/tables.go
@@ -0,0 +1,1219 @@
+// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
+
+package number
+
+import "golang.org/x/text/internal/stringset"
+
+// CLDRVersion is the CLDR version from which the tables in this package are derived.
+const CLDRVersion = "32"
+
+var numSysData = []systemData{ // 59 elements
+ 0: {id: 0x0, digitSize: 0x1, zero: [4]uint8{0x30, 0x0, 0x0, 0x0}},
+ 1: {id: 0x1, digitSize: 0x4, zero: [4]uint8{0xf0, 0x9e, 0xa5, 0x90}},
+ 2: {id: 0x2, digitSize: 0x4, zero: [4]uint8{0xf0, 0x91, 0x9c, 0xb0}},
+ 3: {id: 0x3, digitSize: 0x2, zero: [4]uint8{0xd9, 0xa0, 0x0, 0x0}},
+ 4: {id: 0x4, digitSize: 0x2, zero: [4]uint8{0xdb, 0xb0, 0x0, 0x0}},
+ 5: {id: 0x5, digitSize: 0x3, zero: [4]uint8{0xe1, 0xad, 0x90, 0x0}},
+ 6: {id: 0x6, digitSize: 0x3, zero: [4]uint8{0xe0, 0xa7, 0xa6, 0x0}},
+ 7: {id: 0x7, digitSize: 0x4, zero: [4]uint8{0xf0, 0x91, 0xb1, 0x90}},
+ 8: {id: 0x8, digitSize: 0x4, zero: [4]uint8{0xf0, 0x91, 0x81, 0xa6}},
+ 9: {id: 0x9, digitSize: 0x4, zero: [4]uint8{0xf0, 0x91, 0x84, 0xb6}},
+ 10: {id: 0xa, digitSize: 0x3, zero: [4]uint8{0xea, 0xa9, 0x90, 0x0}},
+ 11: {id: 0xb, digitSize: 0x3, zero: [4]uint8{0xe0, 0xa5, 0xa6, 0x0}},
+ 12: {id: 0xc, digitSize: 0x3, zero: [4]uint8{0xef, 0xbc, 0x90, 0x0}},
+ 13: {id: 0xd, digitSize: 0x4, zero: [4]uint8{0xf0, 0x91, 0xb5, 0x90}},
+ 14: {id: 0xe, digitSize: 0x3, zero: [4]uint8{0xe0, 0xab, 0xa6, 0x0}},
+ 15: {id: 0xf, digitSize: 0x3, zero: [4]uint8{0xe0, 0xa9, 0xa6, 0x0}},
+ 16: {id: 0x10, digitSize: 0x4, zero: [4]uint8{0xf0, 0x96, 0xad, 0x90}},
+ 17: {id: 0x11, digitSize: 0x3, zero: [4]uint8{0xea, 0xa7, 0x90, 0x0}},
+ 18: {id: 0x12, digitSize: 0x3, zero: [4]uint8{0xea, 0xa4, 0x80, 0x0}},
+ 19: {id: 0x13, digitSize: 0x3, zero: [4]uint8{0xe1, 0x9f, 0xa0, 0x0}},
+ 20: {id: 0x14, digitSize: 0x3, zero: [4]uint8{0xe0, 0xb3, 0xa6, 0x0}},
+ 21: {id: 0x15, digitSize: 0x3, zero: [4]uint8{0xe1, 0xaa, 0x80, 0x0}},
+ 22: {id: 0x16, digitSize: 0x3, zero: [4]uint8{0xe1, 0xaa, 0x90, 0x0}},
+ 23: {id: 0x17, digitSize: 0x3, zero: [4]uint8{0xe0, 0xbb, 0x90, 0x0}},
+ 24: {id: 0x18, digitSize: 0x3, zero: [4]uint8{0xe1, 0xb1, 0x80, 0x0}},
+ 25: {id: 0x19, digitSize: 0x3, zero: [4]uint8{0xe1, 0xa5, 0x86, 0x0}},
+ 26: {id: 0x1a, digitSize: 0x4, zero: [4]uint8{0xf0, 0x9d, 0x9f, 0x8e}},
+ 27: {id: 0x1b, digitSize: 0x4, zero: [4]uint8{0xf0, 0x9d, 0x9f, 0x98}},
+ 28: {id: 0x1c, digitSize: 0x4, zero: [4]uint8{0xf0, 0x9d, 0x9f, 0xb6}},
+ 29: {id: 0x1d, digitSize: 0x4, zero: [4]uint8{0xf0, 0x9d, 0x9f, 0xac}},
+ 30: {id: 0x1e, digitSize: 0x4, zero: [4]uint8{0xf0, 0x9d, 0x9f, 0xa2}},
+ 31: {id: 0x1f, digitSize: 0x3, zero: [4]uint8{0xe0, 0xb5, 0xa6, 0x0}},
+ 32: {id: 0x20, digitSize: 0x4, zero: [4]uint8{0xf0, 0x91, 0x99, 0x90}},
+ 33: {id: 0x21, digitSize: 0x3, zero: [4]uint8{0xe1, 0xa0, 0x90, 0x0}},
+ 34: {id: 0x22, digitSize: 0x4, zero: [4]uint8{0xf0, 0x96, 0xa9, 0xa0}},
+ 35: {id: 0x23, digitSize: 0x3, zero: [4]uint8{0xea, 0xaf, 0xb0, 0x0}},
+ 36: {id: 0x24, digitSize: 0x3, zero: [4]uint8{0xe1, 0x81, 0x80, 0x0}},
+ 37: {id: 0x25, digitSize: 0x3, zero: [4]uint8{0xe1, 0x82, 0x90, 0x0}},
+ 38: {id: 0x26, digitSize: 0x3, zero: [4]uint8{0xea, 0xa7, 0xb0, 0x0}},
+ 39: {id: 0x27, digitSize: 0x4, zero: [4]uint8{0xf0, 0x91, 0x91, 0x90}},
+ 40: {id: 0x28, digitSize: 0x2, zero: [4]uint8{0xdf, 0x80, 0x0, 0x0}},
+ 41: {id: 0x29, digitSize: 0x3, zero: [4]uint8{0xe1, 0xb1, 0x90, 0x0}},
+ 42: {id: 0x2a, digitSize: 0x3, zero: [4]uint8{0xe0, 0xad, 0xa6, 0x0}},
+ 43: {id: 0x2b, digitSize: 0x4, zero: [4]uint8{0xf0, 0x90, 0x92, 0xa0}},
+ 44: {id: 0x2c, digitSize: 0x3, zero: [4]uint8{0xea, 0xa3, 0x90, 0x0}},
+ 45: {id: 0x2d, digitSize: 0x4, zero: [4]uint8{0xf0, 0x91, 0x87, 0x90}},
+ 46: {id: 0x2e, digitSize: 0x4, zero: [4]uint8{0xf0, 0x91, 0x8b, 0xb0}},
+ 47: {id: 0x2f, digitSize: 0x3, zero: [4]uint8{0xe0, 0xb7, 0xa6, 0x0}},
+ 48: {id: 0x30, digitSize: 0x4, zero: [4]uint8{0xf0, 0x91, 0x83, 0xb0}},
+ 49: {id: 0x31, digitSize: 0x3, zero: [4]uint8{0xe1, 0xae, 0xb0, 0x0}},
+ 50: {id: 0x32, digitSize: 0x4, zero: [4]uint8{0xf0, 0x91, 0x9b, 0x80}},
+ 51: {id: 0x33, digitSize: 0x3, zero: [4]uint8{0xe1, 0xa7, 0x90, 0x0}},
+ 52: {id: 0x34, digitSize: 0x3, zero: [4]uint8{0xe0, 0xaf, 0xa6, 0x0}},
+ 53: {id: 0x35, digitSize: 0x3, zero: [4]uint8{0xe0, 0xb1, 0xa6, 0x0}},
+ 54: {id: 0x36, digitSize: 0x3, zero: [4]uint8{0xe0, 0xb9, 0x90, 0x0}},
+ 55: {id: 0x37, digitSize: 0x3, zero: [4]uint8{0xe0, 0xbc, 0xa0, 0x0}},
+ 56: {id: 0x38, digitSize: 0x4, zero: [4]uint8{0xf0, 0x91, 0x93, 0x90}},
+ 57: {id: 0x39, digitSize: 0x3, zero: [4]uint8{0xea, 0x98, 0xa0, 0x0}},
+ 58: {id: 0x3a, digitSize: 0x4, zero: [4]uint8{0xf0, 0x91, 0xa3, 0xa0}},
+} // Size: 378 bytes
+
+const (
+ numAdlm = 0x1
+ numAhom = 0x2
+ numArab = 0x3
+ numArabext = 0x4
+ numArmn = 0x3b
+ numArmnlow = 0x3c
+ numBali = 0x5
+ numBeng = 0x6
+ numBhks = 0x7
+ numBrah = 0x8
+ numCakm = 0x9
+ numCham = 0xa
+ numCyrl = 0x3d
+ numDeva = 0xb
+ numEthi = 0x3e
+ numFullwide = 0xc
+ numGeor = 0x3f
+ numGonm = 0xd
+ numGrek = 0x40
+ numGreklow = 0x41
+ numGujr = 0xe
+ numGuru = 0xf
+ numHanidays = 0x42
+ numHanidec = 0x43
+ numHans = 0x44
+ numHansfin = 0x45
+ numHant = 0x46
+ numHantfin = 0x47
+ numHebr = 0x48
+ numHmng = 0x10
+ numJava = 0x11
+ numJpan = 0x49
+ numJpanfin = 0x4a
+ numKali = 0x12
+ numKhmr = 0x13
+ numKnda = 0x14
+ numLana = 0x15
+ numLanatham = 0x16
+ numLaoo = 0x17
+ numLatn = 0x0
+ numLepc = 0x18
+ numLimb = 0x19
+ numMathbold = 0x1a
+ numMathdbl = 0x1b
+ numMathmono = 0x1c
+ numMathsanb = 0x1d
+ numMathsans = 0x1e
+ numMlym = 0x1f
+ numModi = 0x20
+ numMong = 0x21
+ numMroo = 0x22
+ numMtei = 0x23
+ numMymr = 0x24
+ numMymrshan = 0x25
+ numMymrtlng = 0x26
+ numNewa = 0x27
+ numNkoo = 0x28
+ numOlck = 0x29
+ numOrya = 0x2a
+ numOsma = 0x2b
+ numRoman = 0x4b
+ numRomanlow = 0x4c
+ numSaur = 0x2c
+ numShrd = 0x2d
+ numSind = 0x2e
+ numSinh = 0x2f
+ numSora = 0x30
+ numSund = 0x31
+ numTakr = 0x32
+ numTalu = 0x33
+ numTaml = 0x4d
+ numTamldec = 0x34
+ numTelu = 0x35
+ numThai = 0x36
+ numTibt = 0x37
+ numTirh = 0x38
+ numVaii = 0x39
+ numWara = 0x3a
+ numNumberSystems
+)
+
+var systemMap = map[string]system{
+ "adlm": numAdlm,
+ "ahom": numAhom,
+ "arab": numArab,
+ "arabext": numArabext,
+ "armn": numArmn,
+ "armnlow": numArmnlow,
+ "bali": numBali,
+ "beng": numBeng,
+ "bhks": numBhks,
+ "brah": numBrah,
+ "cakm": numCakm,
+ "cham": numCham,
+ "cyrl": numCyrl,
+ "deva": numDeva,
+ "ethi": numEthi,
+ "fullwide": numFullwide,
+ "geor": numGeor,
+ "gonm": numGonm,
+ "grek": numGrek,
+ "greklow": numGreklow,
+ "gujr": numGujr,
+ "guru": numGuru,
+ "hanidays": numHanidays,
+ "hanidec": numHanidec,
+ "hans": numHans,
+ "hansfin": numHansfin,
+ "hant": numHant,
+ "hantfin": numHantfin,
+ "hebr": numHebr,
+ "hmng": numHmng,
+ "java": numJava,
+ "jpan": numJpan,
+ "jpanfin": numJpanfin,
+ "kali": numKali,
+ "khmr": numKhmr,
+ "knda": numKnda,
+ "lana": numLana,
+ "lanatham": numLanatham,
+ "laoo": numLaoo,
+ "latn": numLatn,
+ "lepc": numLepc,
+ "limb": numLimb,
+ "mathbold": numMathbold,
+ "mathdbl": numMathdbl,
+ "mathmono": numMathmono,
+ "mathsanb": numMathsanb,
+ "mathsans": numMathsans,
+ "mlym": numMlym,
+ "modi": numModi,
+ "mong": numMong,
+ "mroo": numMroo,
+ "mtei": numMtei,
+ "mymr": numMymr,
+ "mymrshan": numMymrshan,
+ "mymrtlng": numMymrtlng,
+ "newa": numNewa,
+ "nkoo": numNkoo,
+ "olck": numOlck,
+ "orya": numOrya,
+ "osma": numOsma,
+ "roman": numRoman,
+ "romanlow": numRomanlow,
+ "saur": numSaur,
+ "shrd": numShrd,
+ "sind": numSind,
+ "sinh": numSinh,
+ "sora": numSora,
+ "sund": numSund,
+ "takr": numTakr,
+ "talu": numTalu,
+ "taml": numTaml,
+ "tamldec": numTamldec,
+ "telu": numTelu,
+ "thai": numThai,
+ "tibt": numTibt,
+ "tirh": numTirh,
+ "vaii": numVaii,
+ "wara": numWara,
+}
+
+var symIndex = [][12]uint8{ // 81 elements
+ 0: [12]uint8{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb},
+ 1: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb},
+ 2: [12]uint8{0x0, 0x1, 0x2, 0xd, 0xe, 0xf, 0x6, 0x7, 0x8, 0x9, 0x10, 0xb},
+ 3: [12]uint8{0x1, 0x0, 0x2, 0xd, 0xe, 0xf, 0x6, 0x7, 0x8, 0x9, 0x10, 0xb},
+ 4: [12]uint8{0x0, 0x1, 0x2, 0x11, 0xe, 0xf, 0x6, 0x7, 0x8, 0x9, 0x10, 0xb},
+ 5: [12]uint8{0x1, 0x0, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x12, 0xb},
+ 6: [12]uint8{0x1, 0x0, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb},
+ 7: [12]uint8{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x13, 0xb},
+ 8: [12]uint8{0x0, 0x1, 0x2, 0x3, 0xe, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb},
+ 9: [12]uint8{0x1, 0x0, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0x0},
+ 10: [12]uint8{0x1, 0x0, 0x2, 0x3, 0x4, 0x5, 0x6, 0x14, 0x8, 0x9, 0xa, 0xb},
+ 11: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x6, 0x14, 0x8, 0x9, 0xa, 0xb},
+ 12: [12]uint8{0x0, 0x15, 0x2, 0x3, 0x4, 0x5, 0x6, 0x14, 0x8, 0x9, 0xa, 0xb},
+ 13: [12]uint8{0x0, 0xc, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb},
+ 14: [12]uint8{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x16, 0xb},
+ 15: [12]uint8{0x1, 0x0, 0x2, 0x3, 0x4, 0x5, 0x17, 0x7, 0x8, 0x9, 0xa, 0xb},
+ 16: [12]uint8{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x17, 0x7, 0x8, 0x9, 0xa, 0x0},
+ 17: [12]uint8{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x17, 0x7, 0x8, 0x9, 0xa, 0xb},
+ 18: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0x0},
+ 19: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x18, 0x7, 0x8, 0x9, 0xa, 0xb},
+ 20: [12]uint8{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x19, 0x1a, 0xa, 0xb},
+ 21: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x1b, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb},
+ 22: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x1b, 0x18, 0x7, 0x8, 0x9, 0xa, 0xb},
+ 23: [12]uint8{0x1, 0x0, 0x2, 0x3, 0x4, 0x1b, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb},
+ 24: [12]uint8{0x0, 0x1, 0x2, 0x3, 0xe, 0x1c, 0x6, 0x7, 0x8, 0x9, 0x1d, 0xb},
+ 25: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x1b, 0x6, 0x7, 0x8, 0x9, 0x1e, 0x0},
+ 26: [12]uint8{0x0, 0x15, 0x2, 0x3, 0x4, 0x1b, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb},
+ 27: [12]uint8{0x0, 0x1, 0x2, 0x3, 0xe, 0xf, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb},
+ 28: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x1f, 0xb},
+ 29: [12]uint8{0x0, 0x15, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb},
+ 30: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x20, 0xb},
+ 31: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x21, 0x7, 0x8, 0x9, 0x22, 0xb},
+ 32: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x23, 0xb},
+ 33: [12]uint8{0x1, 0x0, 0x2, 0x3, 0x4, 0x1b, 0x18, 0x14, 0x8, 0x9, 0x24, 0xb},
+ 34: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x1b, 0x18, 0x7, 0x8, 0x9, 0x24, 0xb},
+ 35: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x25, 0xb},
+ 36: [12]uint8{0x1, 0x0, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x26, 0xb},
+ 37: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x27, 0xb},
+ 38: [12]uint8{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x28, 0xb},
+ 39: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x29, 0xb},
+ 40: [12]uint8{0x1, 0x0, 0x2, 0x3, 0xe, 0x1c, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb},
+ 41: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x2a, 0xb},
+ 42: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x2b, 0xb},
+ 43: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x1b, 0x2c, 0x14, 0x8, 0x9, 0x24, 0xb},
+ 44: [12]uint8{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0x0},
+ 45: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x17, 0x7, 0x8, 0x9, 0xa, 0xb},
+ 46: [12]uint8{0x1, 0x0, 0x2, 0x3, 0x4, 0x1b, 0x17, 0x7, 0x8, 0x9, 0xa, 0xb},
+ 47: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x2d, 0x0},
+ 48: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x2e, 0xb},
+ 49: [12]uint8{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x2f, 0xb},
+ 50: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x30, 0x7, 0x8, 0x9, 0xa, 0xb},
+ 51: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x31, 0xb},
+ 52: [12]uint8{0x1, 0xc, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x32, 0xb},
+ 53: [12]uint8{0x1, 0x15, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb},
+ 54: [12]uint8{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x33, 0xb},
+ 55: [12]uint8{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x34, 0xb},
+ 56: [12]uint8{0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x7, 0x3c, 0x9, 0xa, 0xb},
+ 57: [12]uint8{0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x7, 0x3c, 0x9, 0x3d, 0xb},
+ 58: [12]uint8{0x35, 0x36, 0x37, 0x11, 0x3e, 0x3f, 0x3b, 0x7, 0x3c, 0x9, 0xa, 0xb},
+ 59: [12]uint8{0x35, 0x36, 0x37, 0x11, 0x39, 0x3a, 0x3b, 0x7, 0x3c, 0x9, 0xa, 0xb},
+ 60: [12]uint8{0x35, 0x36, 0x37, 0x11, 0x39, 0x40, 0x3b, 0x7, 0x3c, 0x9, 0xa, 0xb},
+ 61: [12]uint8{0x35, 0x36, 0x37, 0x41, 0x3e, 0x3f, 0x3b, 0x7, 0x3c, 0x9, 0xa, 0xb},
+ 62: [12]uint8{0x35, 0x36, 0x37, 0x38, 0x3e, 0x3f, 0x3b, 0x7, 0x3c, 0x9, 0xa, 0xb},
+ 63: [12]uint8{0x35, 0xc, 0x37, 0x38, 0x39, 0x42, 0x3b, 0x7, 0x3c, 0x9, 0xa, 0x0},
+ 64: [12]uint8{0x35, 0xc, 0x37, 0x38, 0x39, 0x42, 0x43, 0x7, 0x44, 0x9, 0x24, 0xb},
+ 65: [12]uint8{0x35, 0x36, 0x37, 0x38, 0x39, 0x5, 0x3b, 0x7, 0x3c, 0x9, 0x33, 0xb},
+ 66: [12]uint8{0x35, 0x36, 0x37, 0x11, 0x45, 0x46, 0x43, 0x7, 0x3c, 0x9, 0xa, 0x35},
+ 67: [12]uint8{0x35, 0x36, 0x37, 0x11, 0xe, 0x1c, 0x43, 0x7, 0x3c, 0x9, 0x1d, 0xb},
+ 68: [12]uint8{0x35, 0x36, 0x37, 0x11, 0xe, 0x1c, 0x43, 0x7, 0x3c, 0x9, 0xa, 0x35},
+ 69: [12]uint8{0x35, 0x36, 0x37, 0x11, 0x45, 0x5, 0x43, 0x7, 0x3c, 0x9, 0xa, 0x35},
+ 70: [12]uint8{0x1, 0xc, 0x37, 0x11, 0x45, 0x47, 0x43, 0x7, 0x3c, 0x9, 0xa, 0x0},
+ 71: [12]uint8{0x35, 0x1, 0x37, 0x11, 0x4, 0x5, 0x43, 0x7, 0x3c, 0x9, 0xa, 0x35},
+ 72: [12]uint8{0x1, 0xc, 0x37, 0x11, 0x45, 0x47, 0x43, 0x7, 0x3c, 0x9, 0x24, 0xb},
+ 73: [12]uint8{0x35, 0x36, 0x2, 0x3, 0x45, 0x46, 0x43, 0x7, 0x8, 0x9, 0xa, 0x35},
+ 74: [12]uint8{0x35, 0x36, 0x37, 0x11, 0x4, 0x5, 0x43, 0x7, 0x3c, 0x9, 0x31, 0x35},
+ 75: [12]uint8{0x35, 0x36, 0x37, 0x11, 0x4, 0x5, 0x43, 0x7, 0x3c, 0x9, 0x32, 0x35},
+ 76: [12]uint8{0x35, 0x36, 0x37, 0x11, 0x48, 0x46, 0x43, 0x7, 0x3c, 0x9, 0x33, 0x35},
+ 77: [12]uint8{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0x49},
+ 78: [12]uint8{0x0, 0x1, 0x4a, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x28, 0xb},
+ 79: [12]uint8{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x4b, 0xb},
+ 80: [12]uint8{0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x4c, 0x4d, 0xb},
+} // Size: 996 bytes
+
+var symData = stringset.Set{
+ Data: "" + // Size: 599 bytes
+ ".,;%+-E׉∞NaN:\u00a0\u200e%\u200e\u200e+\u200e-ليس\u00a0رقمًا٪NDТерхьаш" +
+ "\u00a0дац·’mnne×10^0/00INF−\u200e−ناعددepälukuՈչԹარ\u00a0არის\u00a0რიცხვ" +
+ "იZMdMсан\u00a0емес¤¤¤сан\u00a0эмесບໍ່\u200bແມ່ນ\u200bໂຕ\u200bເລກNSဂဏန်" +
+ "းမဟုတ်သောННне\u00a0числочыыһыла\u00a0буотах·10^epilohosan\u00a0dälTFЕs" +
+ "on\u00a0emasҳақиқий\u00a0сон\u00a0эмас非數值非数值٫٬؛٪\u061c\u061c+\u061c-اس؉ل" +
+ "يس\u00a0رقم\u200f+\u200f-\u200f−٪\u200f\u061c−×۱۰^؉\u200f\u200e+\u200e" +
+ "\u200e-\u200e\u200e−\u200e+\u200e:၊ཨང་མེན་གྲངས་མེདཨང་མད",
+ Index: []uint16{ // 79 elements
+ // Entry 0 - 3F
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0009, 0x000c, 0x000f, 0x0012, 0x0013, 0x0015, 0x001c, 0x0020,
+ 0x0024, 0x0036, 0x0038, 0x003a, 0x0050, 0x0052, 0x0055, 0x0058,
+ 0x0059, 0x005e, 0x0062, 0x0065, 0x0068, 0x006e, 0x0078, 0x0080,
+ 0x0086, 0x00ae, 0x00af, 0x00b2, 0x00c2, 0x00c8, 0x00d8, 0x0105,
+ 0x0107, 0x012e, 0x0132, 0x0142, 0x015e, 0x0163, 0x016a, 0x0173,
+ 0x0175, 0x0177, 0x0180, 0x01a0, 0x01a9, 0x01b2, 0x01b4, 0x01b6,
+ 0x01b8, 0x01bc, 0x01bf, 0x01c2, 0x01c6, 0x01c8, 0x01d6, 0x01da,
+ // Entry 40 - 7F
+ 0x01de, 0x01e4, 0x01e9, 0x01ee, 0x01f5, 0x01fa, 0x0201, 0x0208,
+ 0x0211, 0x0215, 0x0218, 0x021b, 0x0230, 0x0248, 0x0257,
+ },
+} // Size: 797 bytes
+
+// langToDefaults maps a compact language index to the default numbering system
+// and default symbol set
+var langToDefaults = [775]symOffset{
+ // Entry 0 - 3F
+ 0x8000, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x8003, 0x0002, 0x0002, 0x0002, 0x0002, 0x0003,
+ 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
+ 0x0003, 0x0003, 0x0003, 0x0003, 0x0002, 0x0002, 0x0002, 0x0004,
+ 0x0002, 0x0004, 0x0002, 0x0002, 0x0002, 0x0003, 0x0002, 0x0000,
+ 0x8005, 0x0000, 0x0000, 0x0000, 0x8006, 0x0005, 0x0006, 0x0006,
+ 0x0006, 0x0006, 0x0006, 0x0001, 0x0001, 0x0001, 0x0001, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0001, 0x0001, 0x0000, 0x0000, 0x0000,
+ // Entry 40 - 7F
+ 0x8009, 0x0000, 0x0000, 0x800a, 0x0000, 0x0000, 0x800c, 0x0001,
+ 0x0000, 0x0000, 0x0006, 0x0006, 0x0006, 0x0006, 0x0006, 0x0006,
+ 0x0006, 0x0006, 0x0006, 0x0006, 0x800e, 0x0000, 0x0000, 0x0007,
+ 0x0007, 0x0000, 0x0000, 0x0000, 0x0000, 0x800f, 0x0008, 0x0008,
+ 0x8011, 0x0001, 0x0001, 0x0001, 0x803c, 0x0000, 0x0009, 0x0009,
+ 0x0009, 0x0000, 0x0000, 0x000a, 0x000b, 0x000a, 0x000c, 0x000a,
+ 0x000a, 0x000c, 0x000a, 0x000d, 0x000d, 0x000a, 0x000a, 0x0001,
+ 0x0001, 0x0000, 0x0001, 0x0001, 0x803f, 0x0000, 0x0000, 0x0000,
+ // Entry 80 - BF
+ 0x000e, 0x000e, 0x000e, 0x000f, 0x000f, 0x000f, 0x0000, 0x0000,
+ 0x0006, 0x0000, 0x0000, 0x0000, 0x000a, 0x0010, 0x0000, 0x0006,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0011, 0x0000, 0x000a,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x000a, 0x0000, 0x0009, 0x0000,
+ 0x0000, 0x0012, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ // Entry C0 - FF
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0006, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0013, 0x0000,
+ 0x0000, 0x000f, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0000, 0x0000, 0x0015,
+ 0x0015, 0x0006, 0x0000, 0x0006, 0x0006, 0x0000, 0x0000, 0x0006,
+ 0x0006, 0x0001, 0x0000, 0x0000, 0x0006, 0x0006, 0x0006, 0x0006,
+ // Entry 100 - 13F
+ 0x0000, 0x0000, 0x0006, 0x0000, 0x0000, 0x0000, 0x0000, 0x0006,
+ 0x0000, 0x0006, 0x0000, 0x0000, 0x0006, 0x0006, 0x0016, 0x0016,
+ 0x0017, 0x0017, 0x0001, 0x0001, 0x8041, 0x0018, 0x0018, 0x0001,
+ 0x0001, 0x0001, 0x0001, 0x0001, 0x0019, 0x0019, 0x0000, 0x0000,
+ 0x0017, 0x0017, 0x0017, 0x8044, 0x0001, 0x0001, 0x0001, 0x0001,
+ 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
+ 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
+ 0x0001, 0x0001, 0x0006, 0x0006, 0x0001, 0x0001, 0x0001, 0x0001,
+ // Entry 140 - 17F
+ 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
+ 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
+ 0x0001, 0x0001, 0x0006, 0x0006, 0x0006, 0x0006, 0x0000, 0x0000,
+ 0x8047, 0x0000, 0x0006, 0x0006, 0x001a, 0x001a, 0x001a, 0x001a,
+ 0x804a, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x804c, 0x001b, 0x0000,
+ 0x0000, 0x0006, 0x0006, 0x0006, 0x000a, 0x000a, 0x0001, 0x0001,
+ 0x001c, 0x001c, 0x0009, 0x0009, 0x804f, 0x0000, 0x0000, 0x0000,
+ // Entry 180 - 1BF
+ 0x0000, 0x0000, 0x8052, 0x0006, 0x0006, 0x001d, 0x0006, 0x0006,
+ 0x0006, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0006, 0x0006,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x001e, 0x001e, 0x001f,
+ 0x001f, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001,
+ 0x0001, 0x000d, 0x000d, 0x0000, 0x0000, 0x0020, 0x0020, 0x0006,
+ 0x0006, 0x0021, 0x0021, 0x0000, 0x0000, 0x0006, 0x0006, 0x0000,
+ 0x0000, 0x8054, 0x0000, 0x0000, 0x0000, 0x0000, 0x8056, 0x001b,
+ 0x0000, 0x0000, 0x0001, 0x0001, 0x0022, 0x0022, 0x0000, 0x0000,
+ // Entry 1C0 - 1FF
+ 0x0000, 0x0023, 0x0023, 0x0000, 0x0000, 0x0006, 0x0006, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0006, 0x0006, 0x0006, 0x0006, 0x0006,
+ 0x0024, 0x0024, 0x8058, 0x0000, 0x0000, 0x0016, 0x0016, 0x0006,
+ 0x0006, 0x0000, 0x0000, 0x0000, 0x0000, 0x0025, 0x0025, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x000d, 0x000d, 0x0000, 0x0000,
+ 0x0006, 0x0006, 0x0000, 0x0000, 0x0006, 0x0006, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x805a, 0x0000, 0x0000, 0x0006, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0006, 0x0006, 0x805b, 0x0026, 0x805d,
+ // Entry 200 - 23F
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x805e, 0x0015, 0x0015, 0x0000,
+ 0x0000, 0x0006, 0x0006, 0x0006, 0x8061, 0x0000, 0x0000, 0x8062,
+ 0x0006, 0x0006, 0x0006, 0x0006, 0x0006, 0x0006, 0x0006, 0x0001,
+ 0x0001, 0x0015, 0x0015, 0x0006, 0x0006, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0027, 0x0027, 0x0027, 0x8065, 0x8067,
+ 0x001b, 0x0000, 0x0000, 0x0000, 0x0001, 0x0001, 0x0001, 0x0001,
+ 0x8069, 0x0028, 0x0006, 0x0001, 0x0006, 0x0001, 0x0001, 0x0001,
+ // Entry 240 - 27F
+ 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0000,
+ 0x0006, 0x0000, 0x0000, 0x001a, 0x001a, 0x0006, 0x0006, 0x0006,
+ 0x0006, 0x0006, 0x0000, 0x0000, 0x0029, 0x0029, 0x0029, 0x0029,
+ 0x0029, 0x0029, 0x0029, 0x0006, 0x0006, 0x0000, 0x0000, 0x002a,
+ 0x002a, 0x0000, 0x0000, 0x0000, 0x0000, 0x806b, 0x0000, 0x0000,
+ 0x002b, 0x002b, 0x002b, 0x002b, 0x0006, 0x0006, 0x000d, 0x000d,
+ 0x0006, 0x0006, 0x0000, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
+ 0x002c, 0x002c, 0x002d, 0x002d, 0x002e, 0x002e, 0x0000, 0x0000,
+ // Entry 280 - 2BF
+ 0x0000, 0x002f, 0x002f, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0001, 0x0001, 0x0001, 0x0001, 0x0006,
+ 0x0006, 0x0006, 0x0006, 0x0006, 0x0006, 0x0006, 0x0006, 0x0006,
+ 0x0006, 0x0006, 0x0000, 0x0000, 0x0000, 0x806d, 0x0022, 0x0022,
+ 0x0022, 0x0000, 0x0006, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0001, 0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0030, 0x0030, 0x0000, 0x0000, 0x8071, 0x0031, 0x0006,
+ // Entry 2C0 - 2FF
+ 0x0006, 0x0006, 0x0000, 0x0001, 0x0001, 0x000d, 0x000d, 0x0001,
+ 0x0001, 0x0000, 0x0000, 0x0032, 0x0032, 0x8074, 0x8076, 0x001b,
+ 0x8077, 0x8079, 0x0028, 0x807b, 0x0034, 0x0033, 0x0033, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0006, 0x0006, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0035, 0x0035, 0x0006, 0x0006,
+ 0x0000, 0x0000, 0x0000, 0x0001, 0x0001, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0036, 0x0037, 0x0037, 0x0036, 0x0036, 0x0001,
+ 0x0001, 0x807d, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x8080,
+ // Entry 300 - 33F
+ 0x0036, 0x0036, 0x0036, 0x0000, 0x0000, 0x0006, 0x0014,
+} // Size: 1550 bytes
+
+// langToAlt is a list of numbering system and symbol set pairs, sorted and
+// marked by compact language index.
+var langToAlt = []altSymData{ // 131 elements
+ 1: {compactTag: 0x0, symIndex: 0x38, system: 0x3},
+ 2: {compactTag: 0x0, symIndex: 0x42, system: 0x4},
+ 3: {compactTag: 0xa, symIndex: 0x39, system: 0x3},
+ 4: {compactTag: 0xa, symIndex: 0x2, system: 0x0},
+ 5: {compactTag: 0x28, symIndex: 0x0, system: 0x6},
+ 6: {compactTag: 0x2c, symIndex: 0x5, system: 0x0},
+ 7: {compactTag: 0x2c, symIndex: 0x3a, system: 0x3},
+ 8: {compactTag: 0x2c, symIndex: 0x42, system: 0x4},
+ 9: {compactTag: 0x40, symIndex: 0x0, system: 0x6},
+ 10: {compactTag: 0x43, symIndex: 0x0, system: 0x0},
+ 11: {compactTag: 0x43, symIndex: 0x4f, system: 0x37},
+ 12: {compactTag: 0x46, symIndex: 0x1, system: 0x0},
+ 13: {compactTag: 0x46, symIndex: 0x38, system: 0x3},
+ 14: {compactTag: 0x54, symIndex: 0x0, system: 0x9},
+ 15: {compactTag: 0x5d, symIndex: 0x3a, system: 0x3},
+ 16: {compactTag: 0x5d, symIndex: 0x8, system: 0x0},
+ 17: {compactTag: 0x60, symIndex: 0x1, system: 0x0},
+ 18: {compactTag: 0x60, symIndex: 0x38, system: 0x3},
+ 19: {compactTag: 0x60, symIndex: 0x42, system: 0x4},
+ 20: {compactTag: 0x60, symIndex: 0x0, system: 0x5},
+ 21: {compactTag: 0x60, symIndex: 0x0, system: 0x6},
+ 22: {compactTag: 0x60, symIndex: 0x0, system: 0x8},
+ 23: {compactTag: 0x60, symIndex: 0x0, system: 0x9},
+ 24: {compactTag: 0x60, symIndex: 0x0, system: 0xa},
+ 25: {compactTag: 0x60, symIndex: 0x0, system: 0xb},
+ 26: {compactTag: 0x60, symIndex: 0x0, system: 0xc},
+ 27: {compactTag: 0x60, symIndex: 0x0, system: 0xd},
+ 28: {compactTag: 0x60, symIndex: 0x0, system: 0xe},
+ 29: {compactTag: 0x60, symIndex: 0x0, system: 0xf},
+ 30: {compactTag: 0x60, symIndex: 0x0, system: 0x11},
+ 31: {compactTag: 0x60, symIndex: 0x0, system: 0x12},
+ 32: {compactTag: 0x60, symIndex: 0x0, system: 0x13},
+ 33: {compactTag: 0x60, symIndex: 0x0, system: 0x14},
+ 34: {compactTag: 0x60, symIndex: 0x0, system: 0x15},
+ 35: {compactTag: 0x60, symIndex: 0x0, system: 0x16},
+ 36: {compactTag: 0x60, symIndex: 0x0, system: 0x17},
+ 37: {compactTag: 0x60, symIndex: 0x0, system: 0x18},
+ 38: {compactTag: 0x60, symIndex: 0x0, system: 0x19},
+ 39: {compactTag: 0x60, symIndex: 0x0, system: 0x1f},
+ 40: {compactTag: 0x60, symIndex: 0x0, system: 0x21},
+ 41: {compactTag: 0x60, symIndex: 0x0, system: 0x23},
+ 42: {compactTag: 0x60, symIndex: 0x0, system: 0x24},
+ 43: {compactTag: 0x60, symIndex: 0x0, system: 0x25},
+ 44: {compactTag: 0x60, symIndex: 0x0, system: 0x28},
+ 45: {compactTag: 0x60, symIndex: 0x0, system: 0x29},
+ 46: {compactTag: 0x60, symIndex: 0x0, system: 0x2a},
+ 47: {compactTag: 0x60, symIndex: 0x0, system: 0x2b},
+ 48: {compactTag: 0x60, symIndex: 0x0, system: 0x2c},
+ 49: {compactTag: 0x60, symIndex: 0x0, system: 0x2d},
+ 50: {compactTag: 0x60, symIndex: 0x0, system: 0x30},
+ 51: {compactTag: 0x60, symIndex: 0x0, system: 0x31},
+ 52: {compactTag: 0x60, symIndex: 0x0, system: 0x32},
+ 53: {compactTag: 0x60, symIndex: 0x0, system: 0x33},
+ 54: {compactTag: 0x60, symIndex: 0x0, system: 0x34},
+ 55: {compactTag: 0x60, symIndex: 0x0, system: 0x35},
+ 56: {compactTag: 0x60, symIndex: 0x0, system: 0x36},
+ 57: {compactTag: 0x60, symIndex: 0x0, system: 0x37},
+ 58: {compactTag: 0x60, symIndex: 0x0, system: 0x39},
+ 59: {compactTag: 0x60, symIndex: 0x0, system: 0x43},
+ 60: {compactTag: 0x64, symIndex: 0x0, system: 0x0},
+ 61: {compactTag: 0x64, symIndex: 0x38, system: 0x3},
+ 62: {compactTag: 0x64, symIndex: 0x42, system: 0x4},
+ 63: {compactTag: 0x7c, symIndex: 0x50, system: 0x37},
+ 64: {compactTag: 0x7c, symIndex: 0x0, system: 0x0},
+ 65: {compactTag: 0x114, symIndex: 0x43, system: 0x4},
+ 66: {compactTag: 0x114, symIndex: 0x18, system: 0x0},
+ 67: {compactTag: 0x114, symIndex: 0x3b, system: 0x3},
+ 68: {compactTag: 0x123, symIndex: 0x1, system: 0x0},
+ 69: {compactTag: 0x123, symIndex: 0x3c, system: 0x3},
+ 70: {compactTag: 0x123, symIndex: 0x44, system: 0x4},
+ 71: {compactTag: 0x158, symIndex: 0x0, system: 0x0},
+ 72: {compactTag: 0x158, symIndex: 0x3b, system: 0x3},
+ 73: {compactTag: 0x158, symIndex: 0x45, system: 0x4},
+ 74: {compactTag: 0x160, symIndex: 0x0, system: 0x0},
+ 75: {compactTag: 0x160, symIndex: 0x38, system: 0x3},
+ 76: {compactTag: 0x16d, symIndex: 0x1b, system: 0x0},
+ 77: {compactTag: 0x16d, symIndex: 0x0, system: 0x9},
+ 78: {compactTag: 0x16d, symIndex: 0x0, system: 0xa},
+ 79: {compactTag: 0x17c, symIndex: 0x0, system: 0x0},
+ 80: {compactTag: 0x17c, symIndex: 0x3d, system: 0x3},
+ 81: {compactTag: 0x17c, symIndex: 0x42, system: 0x4},
+ 82: {compactTag: 0x182, symIndex: 0x6, system: 0x0},
+ 83: {compactTag: 0x182, symIndex: 0x38, system: 0x3},
+ 84: {compactTag: 0x1b1, symIndex: 0x0, system: 0x0},
+ 85: {compactTag: 0x1b1, symIndex: 0x3e, system: 0x3},
+ 86: {compactTag: 0x1b6, symIndex: 0x42, system: 0x4},
+ 87: {compactTag: 0x1b6, symIndex: 0x1b, system: 0x0},
+ 88: {compactTag: 0x1d2, symIndex: 0x42, system: 0x4},
+ 89: {compactTag: 0x1d2, symIndex: 0x0, system: 0x0},
+ 90: {compactTag: 0x1f3, symIndex: 0x0, system: 0xb},
+ 91: {compactTag: 0x1fd, symIndex: 0x4e, system: 0x24},
+ 92: {compactTag: 0x1fd, symIndex: 0x26, system: 0x0},
+ 93: {compactTag: 0x1ff, symIndex: 0x42, system: 0x4},
+ 94: {compactTag: 0x204, symIndex: 0x15, system: 0x0},
+ 95: {compactTag: 0x204, symIndex: 0x3f, system: 0x3},
+ 96: {compactTag: 0x204, symIndex: 0x46, system: 0x4},
+ 97: {compactTag: 0x20c, symIndex: 0x0, system: 0xb},
+ 98: {compactTag: 0x20f, symIndex: 0x6, system: 0x0},
+ 99: {compactTag: 0x20f, symIndex: 0x38, system: 0x3},
+ 100: {compactTag: 0x20f, symIndex: 0x42, system: 0x4},
+ 101: {compactTag: 0x22e, symIndex: 0x0, system: 0x0},
+ 102: {compactTag: 0x22e, symIndex: 0x47, system: 0x4},
+ 103: {compactTag: 0x22f, symIndex: 0x42, system: 0x4},
+ 104: {compactTag: 0x22f, symIndex: 0x1b, system: 0x0},
+ 105: {compactTag: 0x238, symIndex: 0x42, system: 0x4},
+ 106: {compactTag: 0x238, symIndex: 0x28, system: 0x0},
+ 107: {compactTag: 0x265, symIndex: 0x38, system: 0x3},
+ 108: {compactTag: 0x265, symIndex: 0x0, system: 0x0},
+ 109: {compactTag: 0x29d, symIndex: 0x22, system: 0x0},
+ 110: {compactTag: 0x29d, symIndex: 0x40, system: 0x3},
+ 111: {compactTag: 0x29d, symIndex: 0x48, system: 0x4},
+ 112: {compactTag: 0x29d, symIndex: 0x4d, system: 0xc},
+ 113: {compactTag: 0x2bd, symIndex: 0x31, system: 0x0},
+ 114: {compactTag: 0x2bd, symIndex: 0x3e, system: 0x3},
+ 115: {compactTag: 0x2bd, symIndex: 0x42, system: 0x4},
+ 116: {compactTag: 0x2cd, symIndex: 0x1b, system: 0x0},
+ 117: {compactTag: 0x2cd, symIndex: 0x49, system: 0x4},
+ 118: {compactTag: 0x2ce, symIndex: 0x49, system: 0x4},
+ 119: {compactTag: 0x2d0, symIndex: 0x33, system: 0x0},
+ 120: {compactTag: 0x2d0, symIndex: 0x4a, system: 0x4},
+ 121: {compactTag: 0x2d1, symIndex: 0x42, system: 0x4},
+ 122: {compactTag: 0x2d1, symIndex: 0x28, system: 0x0},
+ 123: {compactTag: 0x2d3, symIndex: 0x34, system: 0x0},
+ 124: {compactTag: 0x2d3, symIndex: 0x4b, system: 0x4},
+ 125: {compactTag: 0x2f9, symIndex: 0x0, system: 0x0},
+ 126: {compactTag: 0x2f9, symIndex: 0x38, system: 0x3},
+ 127: {compactTag: 0x2f9, symIndex: 0x42, system: 0x4},
+ 128: {compactTag: 0x2ff, symIndex: 0x36, system: 0x0},
+ 129: {compactTag: 0x2ff, symIndex: 0x41, system: 0x3},
+ 130: {compactTag: 0x2ff, symIndex: 0x4c, system: 0x4},
+} // Size: 810 bytes
+
+var tagToDecimal = []uint8{ // 775 elements
+ // Entry 0 - 3F
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x05, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ // Entry 40 - 7F
+ 0x05, 0x05, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x05, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x05, 0x05, 0x05, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x05, 0x05, 0x01, 0x01,
+ // Entry 80 - BF
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ // Entry C0 - FF
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ // Entry 100 - 13F
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ // Entry 140 - 17F
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x05, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05,
+ 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ // Entry 180 - 1BF
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x05, 0x05, 0x05, 0x05,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ // Entry 1C0 - 1FF
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x05,
+ 0x01, 0x01, 0x01, 0x05, 0x05, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ // Entry 200 - 23F
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x05, 0x05, 0x01, 0x01, 0x01, 0x05, 0x01,
+ 0x01, 0x05, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ // Entry 240 - 27F
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ // Entry 280 - 2BF
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05,
+ 0x05, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ // Entry 2C0 - 2FF
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ // Entry 300 - 33F
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08,
+} // Size: 799 bytes
+
+var tagToScientific = []uint8{ // 775 elements
+ // Entry 0 - 3F
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ // Entry 40 - 7F
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ // Entry 80 - BF
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ // Entry C0 - FF
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ // Entry 100 - 13F
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ // Entry 140 - 17F
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x0c, 0x0c, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x0c,
+ 0x0c, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ // Entry 180 - 1BF
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ // Entry 1C0 - 1FF
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x0d, 0x0d, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x0c, 0x0c, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ // Entry 200 - 23F
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x0c, 0x02,
+ 0x02, 0x0c, 0x0c, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ // Entry 240 - 27F
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x0d, 0x0d, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ // Entry 280 - 2BF
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ // Entry 2C0 - 2FF
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ // Entry 300 - 33F
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x09,
+} // Size: 799 bytes
+
+var tagToPercent = []uint8{ // 775 elements
+ // Entry 0 - 3F
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x06, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ // Entry 40 - 7F
+ 0x06, 0x06, 0x06, 0x04, 0x04, 0x04, 0x03, 0x03,
+ 0x06, 0x06, 0x03, 0x04, 0x04, 0x03, 0x03, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x06, 0x06, 0x06, 0x03,
+ 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03,
+ 0x03, 0x04, 0x04, 0x03, 0x03, 0x03, 0x04, 0x03,
+ 0x03, 0x04, 0x03, 0x04, 0x04, 0x03, 0x03, 0x03,
+ 0x03, 0x04, 0x04, 0x04, 0x07, 0x07, 0x04, 0x04,
+ // Entry 80 - BF
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x03, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x03, 0x04, 0x03, 0x04,
+ 0x04, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ // Entry C0 - FF
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+ // Entry 100 - 13F
+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04,
+ 0x0b, 0x0b, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x04, 0x04,
+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x03, 0x03,
+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+ // Entry 140 - 17F
+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+ 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+ 0x06, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x06,
+ 0x06, 0x04, 0x04, 0x04, 0x03, 0x03, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ // Entry 180 - 1BF
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x06, 0x06, 0x06, 0x06,
+ 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x04, 0x04,
+ // Entry 1C0 - 1FF
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ // Entry 200 - 23F
+ 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x06, 0x06, 0x04, 0x04, 0x04, 0x06, 0x04,
+ 0x04, 0x06, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ // Entry 240 - 27F
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03,
+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+ 0x03, 0x03, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03,
+ 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04,
+ // Entry 280 - 2BF
+ 0x04, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03,
+ 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x06,
+ 0x06, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x0e,
+ // Entry 2C0 - 2FF
+ 0x0e, 0x0e, 0x04, 0x03, 0x03, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03,
+ 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ // Entry 300 - 33F
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x0a,
+} // Size: 799 bytes
+
+var formats = []Pattern{Pattern{RoundingContext: RoundingContext{MaxSignificantDigits: 0,
+ MaxFractionDigits: 0,
+ Increment: 0x0,
+ IncrementScale: 0x0,
+ Mode: 0x0,
+ DigitShift: 0x0,
+ MinIntegerDigits: 0x0,
+ MaxIntegerDigits: 0x0,
+ MinFractionDigits: 0x0,
+ MinSignificantDigits: 0x0,
+ MinExponentDigits: 0x0},
+ Affix: "",
+ Offset: 0x0,
+ NegOffset: 0x0,
+ PadRune: 0,
+ FormatWidth: 0x0,
+ GroupingSize: [2]uint8{0x0,
+ 0x0},
+ Flags: 0x0},
+ Pattern{RoundingContext: RoundingContext{MaxSignificantDigits: 0,
+ MaxFractionDigits: 3,
+ Increment: 0x0,
+ IncrementScale: 0x0,
+ Mode: 0x0,
+ DigitShift: 0x0,
+ MinIntegerDigits: 0x1,
+ MaxIntegerDigits: 0x0,
+ MinFractionDigits: 0x0,
+ MinSignificantDigits: 0x0,
+ MinExponentDigits: 0x0},
+ Affix: "",
+ Offset: 0x0,
+ NegOffset: 0x0,
+ PadRune: 0,
+ FormatWidth: 0x9,
+ GroupingSize: [2]uint8{0x3,
+ 0x0},
+ Flags: 0x0},
+ Pattern{RoundingContext: RoundingContext{MaxSignificantDigits: 0,
+ MaxFractionDigits: 0,
+ Increment: 0x0,
+ IncrementScale: 0x0,
+ Mode: 0x0,
+ DigitShift: 0x0,
+ MinIntegerDigits: 0x0,
+ MaxIntegerDigits: 0x1,
+ MinFractionDigits: 0x0,
+ MinSignificantDigits: 0x0,
+ MinExponentDigits: 0x1},
+ Affix: "",
+ Offset: 0x0,
+ NegOffset: 0x0,
+ PadRune: 0,
+ FormatWidth: 0x3,
+ GroupingSize: [2]uint8{0x0,
+ 0x0},
+ Flags: 0x0},
+ Pattern{RoundingContext: RoundingContext{MaxSignificantDigits: 0,
+ MaxFractionDigits: 0,
+ Increment: 0x0,
+ IncrementScale: 0x0,
+ Mode: 0x0,
+ DigitShift: 0x2,
+ MinIntegerDigits: 0x1,
+ MaxIntegerDigits: 0x0,
+ MinFractionDigits: 0x0,
+ MinSignificantDigits: 0x0,
+ MinExponentDigits: 0x0},
+ Affix: "\x00\x03\u00a0%",
+ Offset: 0x0,
+ NegOffset: 0x0,
+ PadRune: 0,
+ FormatWidth: 0x7,
+ GroupingSize: [2]uint8{0x3,
+ 0x0},
+ Flags: 0x0},
+ Pattern{RoundingContext: RoundingContext{MaxSignificantDigits: 0,
+ MaxFractionDigits: 0,
+ Increment: 0x0,
+ IncrementScale: 0x0,
+ Mode: 0x0,
+ DigitShift: 0x2,
+ MinIntegerDigits: 0x1,
+ MaxIntegerDigits: 0x0,
+ MinFractionDigits: 0x0,
+ MinSignificantDigits: 0x0,
+ MinExponentDigits: 0x0},
+ Affix: "\x00\x01%",
+ Offset: 0x0,
+ NegOffset: 0x0,
+ PadRune: 0,
+ FormatWidth: 0x6,
+ GroupingSize: [2]uint8{0x3,
+ 0x0},
+ Flags: 0x0},
+ Pattern{RoundingContext: RoundingContext{MaxSignificantDigits: 0,
+ MaxFractionDigits: 3,
+ Increment: 0x0,
+ IncrementScale: 0x0,
+ Mode: 0x0,
+ DigitShift: 0x0,
+ MinIntegerDigits: 0x1,
+ MaxIntegerDigits: 0x0,
+ MinFractionDigits: 0x0,
+ MinSignificantDigits: 0x0,
+ MinExponentDigits: 0x0},
+ Affix: "",
+ Offset: 0x0,
+ NegOffset: 0x0,
+ PadRune: 0,
+ FormatWidth: 0xc,
+ GroupingSize: [2]uint8{0x3,
+ 0x2},
+ Flags: 0x0},
+ Pattern{RoundingContext: RoundingContext{MaxSignificantDigits: 0,
+ MaxFractionDigits: 0,
+ Increment: 0x0,
+ IncrementScale: 0x0,
+ Mode: 0x0,
+ DigitShift: 0x2,
+ MinIntegerDigits: 0x1,
+ MaxIntegerDigits: 0x0,
+ MinFractionDigits: 0x0,
+ MinSignificantDigits: 0x0,
+ MinExponentDigits: 0x0},
+ Affix: "\x00\x01%",
+ Offset: 0x0,
+ NegOffset: 0x0,
+ PadRune: 0,
+ FormatWidth: 0x9,
+ GroupingSize: [2]uint8{0x3,
+ 0x2},
+ Flags: 0x0},
+ Pattern{RoundingContext: RoundingContext{MaxSignificantDigits: 0,
+ MaxFractionDigits: 0,
+ Increment: 0x0,
+ IncrementScale: 0x0,
+ Mode: 0x0,
+ DigitShift: 0x2,
+ MinIntegerDigits: 0x1,
+ MaxIntegerDigits: 0x0,
+ MinFractionDigits: 0x0,
+ MinSignificantDigits: 0x0,
+ MinExponentDigits: 0x0},
+ Affix: "\x00\x03\u00a0%",
+ Offset: 0x0,
+ NegOffset: 0x0,
+ PadRune: 0,
+ FormatWidth: 0xa,
+ GroupingSize: [2]uint8{0x3,
+ 0x2},
+ Flags: 0x0},
+ Pattern{RoundingContext: RoundingContext{MaxSignificantDigits: 0,
+ MaxFractionDigits: 6,
+ Increment: 0x0,
+ IncrementScale: 0x0,
+ Mode: 0x0,
+ DigitShift: 0x0,
+ MinIntegerDigits: 0x1,
+ MaxIntegerDigits: 0x0,
+ MinFractionDigits: 0x0,
+ MinSignificantDigits: 0x0,
+ MinExponentDigits: 0x0},
+ Affix: "",
+ Offset: 0x0,
+ NegOffset: 0x0,
+ PadRune: 0,
+ FormatWidth: 0x8,
+ GroupingSize: [2]uint8{0x0,
+ 0x0},
+ Flags: 0x0},
+ Pattern{RoundingContext: RoundingContext{MaxSignificantDigits: 0,
+ MaxFractionDigits: 6,
+ Increment: 0x0,
+ IncrementScale: 0x0,
+ Mode: 0x0,
+ DigitShift: 0x0,
+ MinIntegerDigits: 0x1,
+ MaxIntegerDigits: 0x0,
+ MinFractionDigits: 0x6,
+ MinSignificantDigits: 0x0,
+ MinExponentDigits: 0x3},
+ Affix: "",
+ Offset: 0x0,
+ NegOffset: 0x0,
+ PadRune: 0,
+ FormatWidth: 0xd,
+ GroupingSize: [2]uint8{0x0,
+ 0x0},
+ Flags: 0x4},
+ Pattern{RoundingContext: RoundingContext{MaxSignificantDigits: 0,
+ MaxFractionDigits: 0,
+ Increment: 0x0,
+ IncrementScale: 0x0,
+ Mode: 0x0,
+ DigitShift: 0x2,
+ MinIntegerDigits: 0x1,
+ MaxIntegerDigits: 0x0,
+ MinFractionDigits: 0x0,
+ MinSignificantDigits: 0x0,
+ MinExponentDigits: 0x0},
+ Affix: "\x00\x01%",
+ Offset: 0x0,
+ NegOffset: 0x0,
+ PadRune: 0,
+ FormatWidth: 0x2,
+ GroupingSize: [2]uint8{0x0,
+ 0x0},
+ Flags: 0x0},
+ Pattern{RoundingContext: RoundingContext{MaxSignificantDigits: 0,
+ MaxFractionDigits: 0,
+ Increment: 0x0,
+ IncrementScale: 0x0,
+ Mode: 0x0,
+ DigitShift: 0x2,
+ MinIntegerDigits: 0x1,
+ MaxIntegerDigits: 0x0,
+ MinFractionDigits: 0x0,
+ MinSignificantDigits: 0x0,
+ MinExponentDigits: 0x0},
+ Affix: "\x03%\u00a0\x00",
+ Offset: 0x0,
+ NegOffset: 0x0,
+ PadRune: 0,
+ FormatWidth: 0x7,
+ GroupingSize: [2]uint8{0x3,
+ 0x0},
+ Flags: 0x0},
+ Pattern{RoundingContext: RoundingContext{MaxSignificantDigits: 0,
+ MaxFractionDigits: 0,
+ Increment: 0x0,
+ IncrementScale: 0x0,
+ Mode: 0x0,
+ DigitShift: 0x0,
+ MinIntegerDigits: 0x0,
+ MaxIntegerDigits: 0x1,
+ MinFractionDigits: 0x0,
+ MinSignificantDigits: 0x0,
+ MinExponentDigits: 0x1},
+ Affix: "\x01[\x01]",
+ Offset: 0x0,
+ NegOffset: 0x0,
+ PadRune: 0,
+ FormatWidth: 0x5,
+ GroupingSize: [2]uint8{0x0,
+ 0x0},
+ Flags: 0x0},
+ Pattern{RoundingContext: RoundingContext{MaxSignificantDigits: 0,
+ MaxFractionDigits: 0,
+ Increment: 0x0,
+ IncrementScale: 0x0,
+ Mode: 0x0,
+ DigitShift: 0x0,
+ MinIntegerDigits: 0x0,
+ MaxIntegerDigits: 0x0,
+ MinFractionDigits: 0x0,
+ MinSignificantDigits: 0x0,
+ MinExponentDigits: 0x0},
+ Affix: "",
+ Offset: 0x0,
+ NegOffset: 0x0,
+ PadRune: 0,
+ FormatWidth: 0x1,
+ GroupingSize: [2]uint8{0x0,
+ 0x0},
+ Flags: 0x0},
+ Pattern{RoundingContext: RoundingContext{MaxSignificantDigits: 0,
+ MaxFractionDigits: 0,
+ Increment: 0x0,
+ IncrementScale: 0x0,
+ Mode: 0x0,
+ DigitShift: 0x2,
+ MinIntegerDigits: 0x1,
+ MaxIntegerDigits: 0x0,
+ MinFractionDigits: 0x0,
+ MinSignificantDigits: 0x0,
+ MinExponentDigits: 0x0},
+ Affix: "\x01%\x00",
+ Offset: 0x0,
+ NegOffset: 0x0,
+ PadRune: 0,
+ FormatWidth: 0x6,
+ GroupingSize: [2]uint8{0x3,
+ 0x0},
+ Flags: 0x0}}
+
+// Total table size 8634 bytes (8KiB); checksum: BE6D4A33
diff --git a/vendor/golang.org/x/text/internal/stringset/set.go b/vendor/golang.org/x/text/internal/stringset/set.go
new file mode 100644
index 0000000..bb2fffb
--- /dev/null
+++ b/vendor/golang.org/x/text/internal/stringset/set.go
@@ -0,0 +1,86 @@
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package stringset provides a way to represent a collection of strings
+// compactly.
+package stringset
+
+import "sort"
+
+// A Set holds a collection of strings that can be looked up by an index number.
+type Set struct {
+ // These fields are exported to allow for code generation.
+
+ Data string
+ Index []uint16
+}
+
+// Elem returns the string with index i. It panics if i is out of range.
+func (s *Set) Elem(i int) string {
+ return s.Data[s.Index[i]:s.Index[i+1]]
+}
+
+// Len returns the number of strings in the set.
+func (s *Set) Len() int {
+ return len(s.Index) - 1
+}
+
+// Search returns the index of the given string or -1 if it is not in the set.
+// The Set must have been created with strings in sorted order.
+func Search(s *Set, str string) int {
+ // TODO: optimize this if it gets used a lot.
+ n := len(s.Index) - 1
+ p := sort.Search(n, func(i int) bool {
+ return s.Elem(i) >= str
+ })
+ if p == n || str != s.Elem(p) {
+ return -1
+ }
+ return p
+}
+
+// A Builder constructs Sets.
+type Builder struct {
+ set Set
+ index map[string]int
+}
+
+// NewBuilder returns a new and initialized Builder.
+func NewBuilder() *Builder {
+ return &Builder{
+ set: Set{
+ Index: []uint16{0},
+ },
+ index: map[string]int{},
+ }
+}
+
+// Set creates the set created so far.
+func (b *Builder) Set() Set {
+ return b.set
+}
+
+// Index returns the index for the given string, which must have been added
+// before.
+func (b *Builder) Index(s string) int {
+ return b.index[s]
+}
+
+// Add adds a string to the index. Strings that are added by a single Add will
+// be stored together, unless they match an existing string.
+func (b *Builder) Add(ss ...string) {
+ // First check if the string already exists.
+ for _, s := range ss {
+ if _, ok := b.index[s]; ok {
+ continue
+ }
+ b.index[s] = len(b.set.Index) - 1
+ b.set.Data += s
+ x := len(b.set.Data)
+ if x > 0xFFFF {
+ panic("Index too > 0xFFFF")
+ }
+ b.set.Index = append(b.set.Index, uint16(x))
+ }
+}
diff --git a/vendor/golang.org/x/text/internal/tag/tag.go b/vendor/golang.org/x/text/internal/tag/tag.go
new file mode 100644
index 0000000..b5d3488
--- /dev/null
+++ b/vendor/golang.org/x/text/internal/tag/tag.go
@@ -0,0 +1,100 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package tag contains functionality handling tags and related data.
+package tag // import "golang.org/x/text/internal/tag"
+
+import "sort"
+
+// An Index converts tags to a compact numeric value.
+//
+// All elements are of size 4. Tags may be up to 4 bytes long. Excess bytes can
+// be used to store additional information about the tag.
+type Index string
+
+// Elem returns the element data at the given index.
+func (s Index) Elem(x int) string {
+ return string(s[x*4 : x*4+4])
+}
+
+// Index reports the index of the given key or -1 if it could not be found.
+// Only the first len(key) bytes from the start of the 4-byte entries will be
+// considered for the search and the first match in Index will be returned.
+func (s Index) Index(key []byte) int {
+ n := len(key)
+ // search the index of the first entry with an equal or higher value than
+ // key in s.
+ index := sort.Search(len(s)/4, func(i int) bool {
+ return cmp(s[i*4:i*4+n], key) != -1
+ })
+ i := index * 4
+ if cmp(s[i:i+len(key)], key) != 0 {
+ return -1
+ }
+ return index
+}
+
+// Next finds the next occurrence of key after index x, which must have been
+// obtained from a call to Index using the same key. It returns x+1 or -1.
+func (s Index) Next(key []byte, x int) int {
+ if x++; x*4 < len(s) && cmp(s[x*4:x*4+len(key)], key) == 0 {
+ return x
+ }
+ return -1
+}
+
+// cmp returns an integer comparing a and b lexicographically.
+func cmp(a Index, b []byte) int {
+ n := len(a)
+ if len(b) < n {
+ n = len(b)
+ }
+ for i, c := range b[:n] {
+ switch {
+ case a[i] > c:
+ return 1
+ case a[i] < c:
+ return -1
+ }
+ }
+ switch {
+ case len(a) < len(b):
+ return -1
+ case len(a) > len(b):
+ return 1
+ }
+ return 0
+}
+
+// Compare returns an integer comparing a and b lexicographically.
+func Compare(a string, b []byte) int {
+ return cmp(Index(a), b)
+}
+
+// FixCase reformats b to the same pattern of cases as form.
+// If returns false if string b is malformed.
+func FixCase(form string, b []byte) bool {
+ if len(form) != len(b) {
+ return false
+ }
+ for i, c := range b {
+ if form[i] <= 'Z' {
+ if c >= 'a' {
+ c -= 'z' - 'Z'
+ }
+ if c < 'A' || 'Z' < c {
+ return false
+ }
+ } else {
+ if c <= 'Z' {
+ c += 'z' - 'Z'
+ }
+ if c < 'a' || 'z' < c {
+ return false
+ }
+ }
+ b[i] = c
+ }
+ return true
+}
diff --git a/vendor/golang.org/x/text/language/coverage.go b/vendor/golang.org/x/text/language/coverage.go
new file mode 100644
index 0000000..a24fd1a
--- /dev/null
+++ b/vendor/golang.org/x/text/language/coverage.go
@@ -0,0 +1,187 @@
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package language
+
+import (
+ "fmt"
+ "sort"
+
+ "golang.org/x/text/internal/language"
+)
+
+// The Coverage interface is used to define the level of coverage of an
+// internationalization service. Note that not all types are supported by all
+// services. As lists may be generated on the fly, it is recommended that users
+// of a Coverage cache the results.
+type Coverage interface {
+ // Tags returns the list of supported tags.
+ Tags() []Tag
+
+ // BaseLanguages returns the list of supported base languages.
+ BaseLanguages() []Base
+
+ // Scripts returns the list of supported scripts.
+ Scripts() []Script
+
+ // Regions returns the list of supported regions.
+ Regions() []Region
+}
+
+var (
+ // Supported defines a Coverage that lists all supported subtags. Tags
+ // always returns nil.
+ Supported Coverage = allSubtags{}
+)
+
+// TODO:
+// - Support Variants, numbering systems.
+// - CLDR coverage levels.
+// - Set of common tags defined in this package.
+
+type allSubtags struct{}
+
+// Regions returns the list of supported regions. As all regions are in a
+// consecutive range, it simply returns a slice of numbers in increasing order.
+// The "undefined" region is not returned.
+func (s allSubtags) Regions() []Region {
+ reg := make([]Region, language.NumRegions)
+ for i := range reg {
+ reg[i] = Region{language.Region(i + 1)}
+ }
+ return reg
+}
+
+// Scripts returns the list of supported scripts. As all scripts are in a
+// consecutive range, it simply returns a slice of numbers in increasing order.
+// The "undefined" script is not returned.
+func (s allSubtags) Scripts() []Script {
+ scr := make([]Script, language.NumScripts)
+ for i := range scr {
+ scr[i] = Script{language.Script(i + 1)}
+ }
+ return scr
+}
+
+// BaseLanguages returns the list of all supported base languages. It generates
+// the list by traversing the internal structures.
+func (s allSubtags) BaseLanguages() []Base {
+ bs := language.BaseLanguages()
+ base := make([]Base, len(bs))
+ for i, b := range bs {
+ base[i] = Base{b}
+ }
+ return base
+}
+
+// Tags always returns nil.
+func (s allSubtags) Tags() []Tag {
+ return nil
+}
+
+// coverage is used by NewCoverage which is used as a convenient way for
+// creating Coverage implementations for partially defined data. Very often a
+// package will only need to define a subset of slices. coverage provides a
+// convenient way to do this. Moreover, packages using NewCoverage, instead of
+// their own implementation, will not break if later new slice types are added.
+type coverage struct {
+ tags func() []Tag
+ bases func() []Base
+ scripts func() []Script
+ regions func() []Region
+}
+
+func (s *coverage) Tags() []Tag {
+ if s.tags == nil {
+ return nil
+ }
+ return s.tags()
+}
+
+// bases implements sort.Interface and is used to sort base languages.
+type bases []Base
+
+func (b bases) Len() int {
+ return len(b)
+}
+
+func (b bases) Swap(i, j int) {
+ b[i], b[j] = b[j], b[i]
+}
+
+func (b bases) Less(i, j int) bool {
+ return b[i].langID < b[j].langID
+}
+
+// BaseLanguages returns the result from calling s.bases if it is specified or
+// otherwise derives the set of supported base languages from tags.
+func (s *coverage) BaseLanguages() []Base {
+ if s.bases == nil {
+ tags := s.Tags()
+ if len(tags) == 0 {
+ return nil
+ }
+ a := make([]Base, len(tags))
+ for i, t := range tags {
+ a[i] = Base{language.Language(t.lang())}
+ }
+ sort.Sort(bases(a))
+ k := 0
+ for i := 1; i < len(a); i++ {
+ if a[k] != a[i] {
+ k++
+ a[k] = a[i]
+ }
+ }
+ return a[:k+1]
+ }
+ return s.bases()
+}
+
+func (s *coverage) Scripts() []Script {
+ if s.scripts == nil {
+ return nil
+ }
+ return s.scripts()
+}
+
+func (s *coverage) Regions() []Region {
+ if s.regions == nil {
+ return nil
+ }
+ return s.regions()
+}
+
+// NewCoverage returns a Coverage for the given lists. It is typically used by
+// packages providing internationalization services to define their level of
+// coverage. A list may be of type []T or func() []T, where T is either Tag,
+// Base, Script or Region. The returned Coverage derives the value for Bases
+// from Tags if no func or slice for []Base is specified. For other unspecified
+// types the returned Coverage will return nil for the respective methods.
+func NewCoverage(list ...interface{}) Coverage {
+ s := &coverage{}
+ for _, x := range list {
+ switch v := x.(type) {
+ case func() []Base:
+ s.bases = v
+ case func() []Script:
+ s.scripts = v
+ case func() []Region:
+ s.regions = v
+ case func() []Tag:
+ s.tags = v
+ case []Base:
+ s.bases = func() []Base { return v }
+ case []Script:
+ s.scripts = func() []Script { return v }
+ case []Region:
+ s.regions = func() []Region { return v }
+ case []Tag:
+ s.tags = func() []Tag { return v }
+ default:
+ panic(fmt.Sprintf("language: unsupported set type %T", v))
+ }
+ }
+ return s
+}
diff --git a/vendor/golang.org/x/text/language/doc.go b/vendor/golang.org/x/text/language/doc.go
new file mode 100644
index 0000000..212b77c
--- /dev/null
+++ b/vendor/golang.org/x/text/language/doc.go
@@ -0,0 +1,98 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package language implements BCP 47 language tags and related functionality.
+//
+// The most important function of package language is to match a list of
+// user-preferred languages to a list of supported languages.
+// It alleviates the developer of dealing with the complexity of this process
+// and provides the user with the best experience
+// (see https://blog.golang.org/matchlang).
+//
+// # Matching preferred against supported languages
+//
+// A Matcher for an application that supports English, Australian English,
+// Danish, and standard Mandarin can be created as follows:
+//
+// var matcher = language.NewMatcher([]language.Tag{
+// language.English, // The first language is used as fallback.
+// language.MustParse("en-AU"),
+// language.Danish,
+// language.Chinese,
+// })
+//
+// This list of supported languages is typically implied by the languages for
+// which there exists translations of the user interface.
+//
+// User-preferred languages usually come as a comma-separated list of BCP 47
+// language tags.
+// The MatchString finds best matches for such strings:
+//
+// handler(w http.ResponseWriter, r *http.Request) {
+// lang, _ := r.Cookie("lang")
+// accept := r.Header.Get("Accept-Language")
+// tag, _ := language.MatchStrings(matcher, lang.String(), accept)
+//
+// // tag should now be used for the initialization of any
+// // locale-specific service.
+// }
+//
+// The Matcher's Match method can be used to match Tags directly.
+//
+// Matchers are aware of the intricacies of equivalence between languages, such
+// as deprecated subtags, legacy tags, macro languages, mutual
+// intelligibility between scripts and languages, and transparently passing
+// BCP 47 user configuration.
+// For instance, it will know that a reader of Bokmål Danish can read Norwegian
+// and will know that Cantonese ("yue") is a good match for "zh-HK".
+//
+// # Using match results
+//
+// To guarantee a consistent user experience to the user it is important to
+// use the same language tag for the selection of any locale-specific services.
+// For example, it is utterly confusing to substitute spelled-out numbers
+// or dates in one language in text of another language.
+// More subtly confusing is using the wrong sorting order or casing
+// algorithm for a certain language.
+//
+// All the packages in x/text that provide locale-specific services
+// (e.g. collate, cases) should be initialized with the tag that was
+// obtained at the start of an interaction with the user.
+//
+// Note that Tag that is returned by Match and MatchString may differ from any
+// of the supported languages, as it may contain carried over settings from
+// the user tags.
+// This may be inconvenient when your application has some additional
+// locale-specific data for your supported languages.
+// Match and MatchString both return the index of the matched supported tag
+// to simplify associating such data with the matched tag.
+//
+// # Canonicalization
+//
+// If one uses the Matcher to compare languages one does not need to
+// worry about canonicalization.
+//
+// The meaning of a Tag varies per application. The language package
+// therefore delays canonicalization and preserves information as much
+// as possible. The Matcher, however, will always take into account that
+// two different tags may represent the same language.
+//
+// By default, only legacy and deprecated tags are converted into their
+// canonical equivalent. All other information is preserved. This approach makes
+// the confidence scores more accurate and allows matchers to distinguish
+// between variants that are otherwise lost.
+//
+// As a consequence, two tags that should be treated as identical according to
+// BCP 47 or CLDR, like "en-Latn" and "en", will be represented differently. The
+// Matcher handles such distinctions, though, and is aware of the
+// equivalence relations. The CanonType type can be used to alter the
+// canonicalization form.
+//
+// # References
+//
+// BCP 47 - Tags for Identifying Languages http://tools.ietf.org/html/bcp47
+package language // import "golang.org/x/text/language"
+
+// TODO: explanation on how to match languages for your own locale-specific
+// service.
diff --git a/vendor/golang.org/x/text/language/language.go b/vendor/golang.org/x/text/language/language.go
new file mode 100644
index 0000000..289b3a3
--- /dev/null
+++ b/vendor/golang.org/x/text/language/language.go
@@ -0,0 +1,605 @@
+// Copyright 2013 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:generate go run gen.go -output tables.go
+
+package language
+
+// TODO: Remove above NOTE after:
+// - verifying that tables are dropped correctly (most notably matcher tables).
+
+import (
+ "strings"
+
+ "golang.org/x/text/internal/language"
+ "golang.org/x/text/internal/language/compact"
+)
+
+// Tag represents a BCP 47 language tag. It is used to specify an instance of a
+// specific language or locale. All language tag values are guaranteed to be
+// well-formed.
+type Tag compact.Tag
+
+func makeTag(t language.Tag) (tag Tag) {
+ return Tag(compact.Make(t))
+}
+
+func (t *Tag) tag() language.Tag {
+ return (*compact.Tag)(t).Tag()
+}
+
+func (t *Tag) isCompact() bool {
+ return (*compact.Tag)(t).IsCompact()
+}
+
+// TODO: improve performance.
+func (t *Tag) lang() language.Language { return t.tag().LangID }
+func (t *Tag) region() language.Region { return t.tag().RegionID }
+func (t *Tag) script() language.Script { return t.tag().ScriptID }
+
+// Make is a convenience wrapper for Parse that omits the error.
+// In case of an error, a sensible default is returned.
+func Make(s string) Tag {
+ return Default.Make(s)
+}
+
+// Make is a convenience wrapper for c.Parse that omits the error.
+// In case of an error, a sensible default is returned.
+func (c CanonType) Make(s string) Tag {
+ t, _ := c.Parse(s)
+ return t
+}
+
+// Raw returns the raw base language, script and region, without making an
+// attempt to infer their values.
+func (t Tag) Raw() (b Base, s Script, r Region) {
+ tt := t.tag()
+ return Base{tt.LangID}, Script{tt.ScriptID}, Region{tt.RegionID}
+}
+
+// IsRoot returns true if t is equal to language "und".
+func (t Tag) IsRoot() bool {
+ return compact.Tag(t).IsRoot()
+}
+
+// CanonType can be used to enable or disable various types of canonicalization.
+type CanonType int
+
+const (
+ // Replace deprecated base languages with their preferred replacements.
+ DeprecatedBase CanonType = 1 << iota
+ // Replace deprecated scripts with their preferred replacements.
+ DeprecatedScript
+ // Replace deprecated regions with their preferred replacements.
+ DeprecatedRegion
+ // Remove redundant scripts.
+ SuppressScript
+ // Normalize legacy encodings. This includes legacy languages defined in
+ // CLDR as well as bibliographic codes defined in ISO-639.
+ Legacy
+ // Map the dominant language of a macro language group to the macro language
+ // subtag. For example cmn -> zh.
+ Macro
+ // The CLDR flag should be used if full compatibility with CLDR is required.
+ // There are a few cases where language.Tag may differ from CLDR. To follow all
+ // of CLDR's suggestions, use All|CLDR.
+ CLDR
+
+ // Raw can be used to Compose or Parse without Canonicalization.
+ Raw CanonType = 0
+
+ // Replace all deprecated tags with their preferred replacements.
+ Deprecated = DeprecatedBase | DeprecatedScript | DeprecatedRegion
+
+ // All canonicalizations recommended by BCP 47.
+ BCP47 = Deprecated | SuppressScript
+
+ // All canonicalizations.
+ All = BCP47 | Legacy | Macro
+
+ // Default is the canonicalization used by Parse, Make and Compose. To
+ // preserve as much information as possible, canonicalizations that remove
+ // potentially valuable information are not included. The Matcher is
+ // designed to recognize similar tags that would be the same if
+ // they were canonicalized using All.
+ Default = Deprecated | Legacy
+
+ canonLang = DeprecatedBase | Legacy | Macro
+
+ // TODO: LikelyScript, LikelyRegion: suppress similar to ICU.
+)
+
+// canonicalize returns the canonicalized equivalent of the tag and
+// whether there was any change.
+func canonicalize(c CanonType, t language.Tag) (language.Tag, bool) {
+ if c == Raw {
+ return t, false
+ }
+ changed := false
+ if c&SuppressScript != 0 {
+ if t.LangID.SuppressScript() == t.ScriptID {
+ t.ScriptID = 0
+ changed = true
+ }
+ }
+ if c&canonLang != 0 {
+ for {
+ if l, aliasType := t.LangID.Canonicalize(); l != t.LangID {
+ switch aliasType {
+ case language.Legacy:
+ if c&Legacy != 0 {
+ if t.LangID == _sh && t.ScriptID == 0 {
+ t.ScriptID = _Latn
+ }
+ t.LangID = l
+ changed = true
+ }
+ case language.Macro:
+ if c&Macro != 0 {
+ // We deviate here from CLDR. The mapping "nb" -> "no"
+ // qualifies as a typical Macro language mapping. However,
+ // for legacy reasons, CLDR maps "no", the macro language
+ // code for Norwegian, to the dominant variant "nb". This
+ // change is currently under consideration for CLDR as well.
+ // See https://unicode.org/cldr/trac/ticket/2698 and also
+ // https://unicode.org/cldr/trac/ticket/1790 for some of the
+ // practical implications. TODO: this check could be removed
+ // if CLDR adopts this change.
+ if c&CLDR == 0 || t.LangID != _nb {
+ changed = true
+ t.LangID = l
+ }
+ }
+ case language.Deprecated:
+ if c&DeprecatedBase != 0 {
+ if t.LangID == _mo && t.RegionID == 0 {
+ t.RegionID = _MD
+ }
+ t.LangID = l
+ changed = true
+ // Other canonicalization types may still apply.
+ continue
+ }
+ }
+ } else if c&Legacy != 0 && t.LangID == _no && c&CLDR != 0 {
+ t.LangID = _nb
+ changed = true
+ }
+ break
+ }
+ }
+ if c&DeprecatedScript != 0 {
+ if t.ScriptID == _Qaai {
+ changed = true
+ t.ScriptID = _Zinh
+ }
+ }
+ if c&DeprecatedRegion != 0 {
+ if r := t.RegionID.Canonicalize(); r != t.RegionID {
+ changed = true
+ t.RegionID = r
+ }
+ }
+ return t, changed
+}
+
+// Canonicalize returns the canonicalized equivalent of the tag.
+func (c CanonType) Canonicalize(t Tag) (Tag, error) {
+ // First try fast path.
+ if t.isCompact() {
+ if _, changed := canonicalize(c, compact.Tag(t).Tag()); !changed {
+ return t, nil
+ }
+ }
+ // It is unlikely that one will canonicalize a tag after matching. So do
+ // a slow but simple approach here.
+ if tag, changed := canonicalize(c, t.tag()); changed {
+ tag.RemakeString()
+ return makeTag(tag), nil
+ }
+ return t, nil
+
+}
+
+// Confidence indicates the level of certainty for a given return value.
+// For example, Serbian may be written in Cyrillic or Latin script.
+// The confidence level indicates whether a value was explicitly specified,
+// whether it is typically the only possible value, or whether there is
+// an ambiguity.
+type Confidence int
+
+const (
+ No Confidence = iota // full confidence that there was no match
+ Low // most likely value picked out of a set of alternatives
+ High // value is generally assumed to be the correct match
+ Exact // exact match or explicitly specified value
+)
+
+var confName = []string{"No", "Low", "High", "Exact"}
+
+func (c Confidence) String() string {
+ return confName[c]
+}
+
+// String returns the canonical string representation of the language tag.
+func (t Tag) String() string {
+ return t.tag().String()
+}
+
+// MarshalText implements encoding.TextMarshaler.
+func (t Tag) MarshalText() (text []byte, err error) {
+ return t.tag().MarshalText()
+}
+
+// UnmarshalText implements encoding.TextUnmarshaler.
+func (t *Tag) UnmarshalText(text []byte) error {
+ var tag language.Tag
+ err := tag.UnmarshalText(text)
+ *t = makeTag(tag)
+ return err
+}
+
+// Base returns the base language of the language tag. If the base language is
+// unspecified, an attempt will be made to infer it from the context.
+// It uses a variant of CLDR's Add Likely Subtags algorithm. This is subject to change.
+func (t Tag) Base() (Base, Confidence) {
+ if b := t.lang(); b != 0 {
+ return Base{b}, Exact
+ }
+ tt := t.tag()
+ c := High
+ if tt.ScriptID == 0 && !tt.RegionID.IsCountry() {
+ c = Low
+ }
+ if tag, err := tt.Maximize(); err == nil && tag.LangID != 0 {
+ return Base{tag.LangID}, c
+ }
+ return Base{0}, No
+}
+
+// Script infers the script for the language tag. If it was not explicitly given, it will infer
+// a most likely candidate.
+// If more than one script is commonly used for a language, the most likely one
+// is returned with a low confidence indication. For example, it returns (Cyrl, Low)
+// for Serbian.
+// If a script cannot be inferred (Zzzz, No) is returned. We do not use Zyyy (undetermined)
+// as one would suspect from the IANA registry for BCP 47. In a Unicode context Zyyy marks
+// common characters (like 1, 2, 3, '.', etc.) and is therefore more like multiple scripts.
+// See https://www.unicode.org/reports/tr24/#Values for more details. Zzzz is also used for
+// unknown value in CLDR. (Zzzz, Exact) is returned if Zzzz was explicitly specified.
+// Note that an inferred script is never guaranteed to be the correct one. Latin is
+// almost exclusively used for Afrikaans, but Arabic has been used for some texts
+// in the past. Also, the script that is commonly used may change over time.
+// It uses a variant of CLDR's Add Likely Subtags algorithm. This is subject to change.
+func (t Tag) Script() (Script, Confidence) {
+ if scr := t.script(); scr != 0 {
+ return Script{scr}, Exact
+ }
+ tt := t.tag()
+ sc, c := language.Script(_Zzzz), No
+ if scr := tt.LangID.SuppressScript(); scr != 0 {
+ // Note: it is not always the case that a language with a suppress
+ // script value is only written in one script (e.g. kk, ms, pa).
+ if tt.RegionID == 0 {
+ return Script{scr}, High
+ }
+ sc, c = scr, High
+ }
+ if tag, err := tt.Maximize(); err == nil {
+ if tag.ScriptID != sc {
+ sc, c = tag.ScriptID, Low
+ }
+ } else {
+ tt, _ = canonicalize(Deprecated|Macro, tt)
+ if tag, err := tt.Maximize(); err == nil && tag.ScriptID != sc {
+ sc, c = tag.ScriptID, Low
+ }
+ }
+ return Script{sc}, c
+}
+
+// Region returns the region for the language tag. If it was not explicitly given, it will
+// infer a most likely candidate from the context.
+// It uses a variant of CLDR's Add Likely Subtags algorithm. This is subject to change.
+func (t Tag) Region() (Region, Confidence) {
+ if r := t.region(); r != 0 {
+ return Region{r}, Exact
+ }
+ tt := t.tag()
+ if tt, err := tt.Maximize(); err == nil {
+ return Region{tt.RegionID}, Low // TODO: differentiate between high and low.
+ }
+ tt, _ = canonicalize(Deprecated|Macro, tt)
+ if tag, err := tt.Maximize(); err == nil {
+ return Region{tag.RegionID}, Low
+ }
+ return Region{_ZZ}, No // TODO: return world instead of undetermined?
+}
+
+// Variants returns the variants specified explicitly for this language tag.
+// or nil if no variant was specified.
+func (t Tag) Variants() []Variant {
+ if !compact.Tag(t).MayHaveVariants() {
+ return nil
+ }
+ v := []Variant{}
+ x, str := "", t.tag().Variants()
+ for str != "" {
+ x, str = nextToken(str)
+ v = append(v, Variant{x})
+ }
+ return v
+}
+
+// Parent returns the CLDR parent of t. In CLDR, missing fields in data for a
+// specific language are substituted with fields from the parent language.
+// The parent for a language may change for newer versions of CLDR.
+//
+// Parent returns a tag for a less specific language that is mutually
+// intelligible or Und if there is no such language. This may not be the same as
+// simply stripping the last BCP 47 subtag. For instance, the parent of "zh-TW"
+// is "zh-Hant", and the parent of "zh-Hant" is "und".
+func (t Tag) Parent() Tag {
+ return Tag(compact.Tag(t).Parent())
+}
+
+// returns token t and the rest of the string.
+func nextToken(s string) (t, tail string) {
+ p := strings.Index(s[1:], "-")
+ if p == -1 {
+ return s[1:], ""
+ }
+ p++
+ return s[1:p], s[p:]
+}
+
+// Extension is a single BCP 47 extension.
+type Extension struct {
+ s string
+}
+
+// String returns the string representation of the extension, including the
+// type tag.
+func (e Extension) String() string {
+ return e.s
+}
+
+// ParseExtension parses s as an extension and returns it on success.
+func ParseExtension(s string) (e Extension, err error) {
+ ext, err := language.ParseExtension(s)
+ return Extension{ext}, err
+}
+
+// Type returns the one-byte extension type of e. It returns 0 for the zero
+// exception.
+func (e Extension) Type() byte {
+ if e.s == "" {
+ return 0
+ }
+ return e.s[0]
+}
+
+// Tokens returns the list of tokens of e.
+func (e Extension) Tokens() []string {
+ return strings.Split(e.s, "-")
+}
+
+// Extension returns the extension of type x for tag t. It will return
+// false for ok if t does not have the requested extension. The returned
+// extension will be invalid in this case.
+func (t Tag) Extension(x byte) (ext Extension, ok bool) {
+ if !compact.Tag(t).MayHaveExtensions() {
+ return Extension{}, false
+ }
+ e, ok := t.tag().Extension(x)
+ return Extension{e}, ok
+}
+
+// Extensions returns all extensions of t.
+func (t Tag) Extensions() []Extension {
+ if !compact.Tag(t).MayHaveExtensions() {
+ return nil
+ }
+ e := []Extension{}
+ for _, ext := range t.tag().Extensions() {
+ e = append(e, Extension{ext})
+ }
+ return e
+}
+
+// TypeForKey returns the type associated with the given key, where key and type
+// are of the allowed values defined for the Unicode locale extension ('u') in
+// https://www.unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers.
+// TypeForKey will traverse the inheritance chain to get the correct value.
+//
+// If there are multiple types associated with a key, only the first will be
+// returned. If there is no type associated with a key, it returns the empty
+// string.
+func (t Tag) TypeForKey(key string) string {
+ if !compact.Tag(t).MayHaveExtensions() {
+ if key != "rg" && key != "va" {
+ return ""
+ }
+ }
+ return t.tag().TypeForKey(key)
+}
+
+// SetTypeForKey returns a new Tag with the key set to type, where key and type
+// are of the allowed values defined for the Unicode locale extension ('u') in
+// https://www.unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers.
+// An empty value removes an existing pair with the same key.
+func (t Tag) SetTypeForKey(key, value string) (Tag, error) {
+ tt, err := t.tag().SetTypeForKey(key, value)
+ return makeTag(tt), err
+}
+
+// NumCompactTags is the number of compact tags. The maximum tag is
+// NumCompactTags-1.
+const NumCompactTags = compact.NumCompactTags
+
+// CompactIndex returns an index, where 0 <= index < NumCompactTags, for tags
+// for which data exists in the text repository.The index will change over time
+// and should not be stored in persistent storage. If t does not match a compact
+// index, exact will be false and the compact index will be returned for the
+// first match after repeatedly taking the Parent of t.
+func CompactIndex(t Tag) (index int, exact bool) {
+ id, exact := compact.LanguageID(compact.Tag(t))
+ return int(id), exact
+}
+
+var root = language.Tag{}
+
+// Base is an ISO 639 language code, used for encoding the base language
+// of a language tag.
+type Base struct {
+ langID language.Language
+}
+
+// ParseBase parses a 2- or 3-letter ISO 639 code.
+// It returns a ValueError if s is a well-formed but unknown language identifier
+// or another error if another error occurred.
+func ParseBase(s string) (Base, error) {
+ l, err := language.ParseBase(s)
+ return Base{l}, err
+}
+
+// String returns the BCP 47 representation of the base language.
+func (b Base) String() string {
+ return b.langID.String()
+}
+
+// ISO3 returns the ISO 639-3 language code.
+func (b Base) ISO3() string {
+ return b.langID.ISO3()
+}
+
+// IsPrivateUse reports whether this language code is reserved for private use.
+func (b Base) IsPrivateUse() bool {
+ return b.langID.IsPrivateUse()
+}
+
+// Script is a 4-letter ISO 15924 code for representing scripts.
+// It is idiomatically represented in title case.
+type Script struct {
+ scriptID language.Script
+}
+
+// ParseScript parses a 4-letter ISO 15924 code.
+// It returns a ValueError if s is a well-formed but unknown script identifier
+// or another error if another error occurred.
+func ParseScript(s string) (Script, error) {
+ sc, err := language.ParseScript(s)
+ return Script{sc}, err
+}
+
+// String returns the script code in title case.
+// It returns "Zzzz" for an unspecified script.
+func (s Script) String() string {
+ return s.scriptID.String()
+}
+
+// IsPrivateUse reports whether this script code is reserved for private use.
+func (s Script) IsPrivateUse() bool {
+ return s.scriptID.IsPrivateUse()
+}
+
+// Region is an ISO 3166-1 or UN M.49 code for representing countries and regions.
+type Region struct {
+ regionID language.Region
+}
+
+// EncodeM49 returns the Region for the given UN M.49 code.
+// It returns an error if r is not a valid code.
+func EncodeM49(r int) (Region, error) {
+ rid, err := language.EncodeM49(r)
+ return Region{rid}, err
+}
+
+// ParseRegion parses a 2- or 3-letter ISO 3166-1 or a UN M.49 code.
+// It returns a ValueError if s is a well-formed but unknown region identifier
+// or another error if another error occurred.
+func ParseRegion(s string) (Region, error) {
+ r, err := language.ParseRegion(s)
+ return Region{r}, err
+}
+
+// String returns the BCP 47 representation for the region.
+// It returns "ZZ" for an unspecified region.
+func (r Region) String() string {
+ return r.regionID.String()
+}
+
+// ISO3 returns the 3-letter ISO code of r.
+// Note that not all regions have a 3-letter ISO code.
+// In such cases this method returns "ZZZ".
+func (r Region) ISO3() string {
+ return r.regionID.ISO3()
+}
+
+// M49 returns the UN M.49 encoding of r, or 0 if this encoding
+// is not defined for r.
+func (r Region) M49() int {
+ return r.regionID.M49()
+}
+
+// IsPrivateUse reports whether r has the ISO 3166 User-assigned status. This
+// may include private-use tags that are assigned by CLDR and used in this
+// implementation. So IsPrivateUse and IsCountry can be simultaneously true.
+func (r Region) IsPrivateUse() bool {
+ return r.regionID.IsPrivateUse()
+}
+
+// IsCountry returns whether this region is a country or autonomous area. This
+// includes non-standard definitions from CLDR.
+func (r Region) IsCountry() bool {
+ return r.regionID.IsCountry()
+}
+
+// IsGroup returns whether this region defines a collection of regions. This
+// includes non-standard definitions from CLDR.
+func (r Region) IsGroup() bool {
+ return r.regionID.IsGroup()
+}
+
+// Contains returns whether Region c is contained by Region r. It returns true
+// if c == r.
+func (r Region) Contains(c Region) bool {
+ return r.regionID.Contains(c.regionID)
+}
+
+// TLD returns the country code top-level domain (ccTLD). UK is returned for GB.
+// In all other cases it returns either the region itself or an error.
+//
+// This method may return an error for a region for which there exists a
+// canonical form with a ccTLD. To get that ccTLD canonicalize r first. The
+// region will already be canonicalized it was obtained from a Tag that was
+// obtained using any of the default methods.
+func (r Region) TLD() (Region, error) {
+ tld, err := r.regionID.TLD()
+ return Region{tld}, err
+}
+
+// Canonicalize returns the region or a possible replacement if the region is
+// deprecated. It will not return a replacement for deprecated regions that
+// are split into multiple regions.
+func (r Region) Canonicalize() Region {
+ return Region{r.regionID.Canonicalize()}
+}
+
+// Variant represents a registered variant of a language as defined by BCP 47.
+type Variant struct {
+ variant string
+}
+
+// ParseVariant parses and returns a Variant. An error is returned if s is not
+// a valid variant.
+func ParseVariant(s string) (Variant, error) {
+ v, err := language.ParseVariant(s)
+ return Variant{v.String()}, err
+}
+
+// String returns the string representation of the variant.
+func (v Variant) String() string {
+ return v.variant
+}
diff --git a/vendor/golang.org/x/text/language/match.go b/vendor/golang.org/x/text/language/match.go
new file mode 100644
index 0000000..ee45f49
--- /dev/null
+++ b/vendor/golang.org/x/text/language/match.go
@@ -0,0 +1,735 @@
+// Copyright 2013 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package language
+
+import (
+ "errors"
+ "strings"
+
+ "golang.org/x/text/internal/language"
+)
+
+// A MatchOption configures a Matcher.
+type MatchOption func(*matcher)
+
+// PreferSameScript will, in the absence of a match, result in the first
+// preferred tag with the same script as a supported tag to match this supported
+// tag. The default is currently true, but this may change in the future.
+func PreferSameScript(preferSame bool) MatchOption {
+ return func(m *matcher) { m.preferSameScript = preferSame }
+}
+
+// TODO(v1.0.0): consider making Matcher a concrete type, instead of interface.
+// There doesn't seem to be too much need for multiple types.
+// Making it a concrete type allows MatchStrings to be a method, which will
+// improve its discoverability.
+
+// MatchStrings parses and matches the given strings until one of them matches
+// the language in the Matcher. A string may be an Accept-Language header as
+// handled by ParseAcceptLanguage. The default language is returned if no
+// other language matched.
+func MatchStrings(m Matcher, lang ...string) (tag Tag, index int) {
+ for _, accept := range lang {
+ desired, _, err := ParseAcceptLanguage(accept)
+ if err != nil {
+ continue
+ }
+ if tag, index, conf := m.Match(desired...); conf != No {
+ return tag, index
+ }
+ }
+ tag, index, _ = m.Match()
+ return
+}
+
+// Matcher is the interface that wraps the Match method.
+//
+// Match returns the best match for any of the given tags, along with
+// a unique index associated with the returned tag and a confidence
+// score.
+type Matcher interface {
+ Match(t ...Tag) (tag Tag, index int, c Confidence)
+}
+
+// Comprehends reports the confidence score for a speaker of a given language
+// to being able to comprehend the written form of an alternative language.
+func Comprehends(speaker, alternative Tag) Confidence {
+ _, _, c := NewMatcher([]Tag{alternative}).Match(speaker)
+ return c
+}
+
+// NewMatcher returns a Matcher that matches an ordered list of preferred tags
+// against a list of supported tags based on written intelligibility, closeness
+// of dialect, equivalence of subtags and various other rules. It is initialized
+// with the list of supported tags. The first element is used as the default
+// value in case no match is found.
+//
+// Its Match method matches the first of the given Tags to reach a certain
+// confidence threshold. The tags passed to Match should therefore be specified
+// in order of preference. Extensions are ignored for matching.
+//
+// The index returned by the Match method corresponds to the index of the
+// matched tag in t, but is augmented with the Unicode extension ('u')of the
+// corresponding preferred tag. This allows user locale options to be passed
+// transparently.
+func NewMatcher(t []Tag, options ...MatchOption) Matcher {
+ return newMatcher(t, options)
+}
+
+func (m *matcher) Match(want ...Tag) (t Tag, index int, c Confidence) {
+ var tt language.Tag
+ match, w, c := m.getBest(want...)
+ if match != nil {
+ tt, index = match.tag, match.index
+ } else {
+ // TODO: this should be an option
+ tt = m.default_.tag
+ if m.preferSameScript {
+ outer:
+ for _, w := range want {
+ script, _ := w.Script()
+ if script.scriptID == 0 {
+ // Don't do anything if there is no script, such as with
+ // private subtags.
+ continue
+ }
+ for i, h := range m.supported {
+ if script.scriptID == h.maxScript {
+ tt, index = h.tag, i
+ break outer
+ }
+ }
+ }
+ }
+ // TODO: select first language tag based on script.
+ }
+ if w.RegionID != tt.RegionID && w.RegionID != 0 {
+ if w.RegionID != 0 && tt.RegionID != 0 && tt.RegionID.Contains(w.RegionID) {
+ tt.RegionID = w.RegionID
+ tt.RemakeString()
+ } else if r := w.RegionID.String(); len(r) == 2 {
+ // TODO: also filter macro and deprecated.
+ tt, _ = tt.SetTypeForKey("rg", strings.ToLower(r)+"zzzz")
+ }
+ }
+ // Copy options from the user-provided tag into the result tag. This is hard
+ // to do after the fact, so we do it here.
+ // TODO: add in alternative variants to -u-va-.
+ // TODO: add preferred region to -u-rg-.
+ if e := w.Extensions(); len(e) > 0 {
+ b := language.Builder{}
+ b.SetTag(tt)
+ for _, e := range e {
+ b.AddExt(e)
+ }
+ tt = b.Make()
+ }
+ return makeTag(tt), index, c
+}
+
+// ErrMissingLikelyTagsData indicates no information was available
+// to compute likely values of missing tags.
+var ErrMissingLikelyTagsData = errors.New("missing likely tags data")
+
+// func (t *Tag) setTagsFrom(id Tag) {
+// t.LangID = id.LangID
+// t.ScriptID = id.ScriptID
+// t.RegionID = id.RegionID
+// }
+
+// Tag Matching
+// CLDR defines an algorithm for finding the best match between two sets of language
+// tags. The basic algorithm defines how to score a possible match and then find
+// the match with the best score
+// (see https://www.unicode.org/reports/tr35/#LanguageMatching).
+// Using scoring has several disadvantages. The scoring obfuscates the importance of
+// the various factors considered, making the algorithm harder to understand. Using
+// scoring also requires the full score to be computed for each pair of tags.
+//
+// We will use a different algorithm which aims to have the following properties:
+// - clarity on the precedence of the various selection factors, and
+// - improved performance by allowing early termination of a comparison.
+//
+// Matching algorithm (overview)
+// Input:
+// - supported: a set of supported tags
+// - default: the default tag to return in case there is no match
+// - desired: list of desired tags, ordered by preference, starting with
+// the most-preferred.
+//
+// Algorithm:
+// 1) Set the best match to the lowest confidence level
+// 2) For each tag in "desired":
+// a) For each tag in "supported":
+// 1) compute the match between the two tags.
+// 2) if the match is better than the previous best match, replace it
+// with the new match. (see next section)
+// b) if the current best match is Exact and pin is true the result will be
+// frozen to the language found thusfar, although better matches may
+// still be found for the same language.
+// 3) If the best match so far is below a certain threshold, return "default".
+//
+// Ranking:
+// We use two phases to determine whether one pair of tags are a better match
+// than another pair of tags. First, we determine a rough confidence level. If the
+// levels are different, the one with the highest confidence wins.
+// Second, if the rough confidence levels are identical, we use a set of tie-breaker
+// rules.
+//
+// The confidence level of matching a pair of tags is determined by finding the
+// lowest confidence level of any matches of the corresponding subtags (the
+// result is deemed as good as its weakest link).
+// We define the following levels:
+// Exact - An exact match of a subtag, before adding likely subtags.
+// MaxExact - An exact match of a subtag, after adding likely subtags.
+// [See Note 2].
+// High - High level of mutual intelligibility between different subtag
+// variants.
+// Low - Low level of mutual intelligibility between different subtag
+// variants.
+// No - No mutual intelligibility.
+//
+// The following levels can occur for each type of subtag:
+// Base: Exact, MaxExact, High, Low, No
+// Script: Exact, MaxExact [see Note 3], Low, No
+// Region: Exact, MaxExact, High
+// Variant: Exact, High
+// Private: Exact, No
+//
+// Any result with a confidence level of Low or higher is deemed a possible match.
+// Once a desired tag matches any of the supported tags with a level of MaxExact
+// or higher, the next desired tag is not considered (see Step 2.b).
+// Note that CLDR provides languageMatching data that defines close equivalence
+// classes for base languages, scripts and regions.
+//
+// Tie-breaking
+// If we get the same confidence level for two matches, we apply a sequence of
+// tie-breaking rules. The first that succeeds defines the result. The rules are
+// applied in the following order.
+// 1) Original language was defined and was identical.
+// 2) Original region was defined and was identical.
+// 3) Distance between two maximized regions was the smallest.
+// 4) Original script was defined and was identical.
+// 5) Distance from want tag to have tag using the parent relation [see Note 5.]
+// If there is still no winner after these rules are applied, the first match
+// found wins.
+//
+// Notes:
+// [2] In practice, as matching of Exact is done in a separate phase from
+// matching the other levels, we reuse the Exact level to mean MaxExact in
+// the second phase. As a consequence, we only need the levels defined by
+// the Confidence type. The MaxExact confidence level is mapped to High in
+// the public API.
+// [3] We do not differentiate between maximized script values that were derived
+// from suppressScript versus most likely tag data. We determined that in
+// ranking the two, one ranks just after the other. Moreover, the two cannot
+// occur concurrently. As a consequence, they are identical for practical
+// purposes.
+// [4] In case of deprecated, macro-equivalents and legacy mappings, we assign
+// the MaxExact level to allow iw vs he to still be a closer match than
+// en-AU vs en-US, for example.
+// [5] In CLDR a locale inherits fields that are unspecified for this locale
+// from its parent. Therefore, if a locale is a parent of another locale,
+// it is a strong measure for closeness, especially when no other tie
+// breaker rule applies. One could also argue it is inconsistent, for
+// example, when pt-AO matches pt (which CLDR equates with pt-BR), even
+// though its parent is pt-PT according to the inheritance rules.
+//
+// Implementation Details:
+// There are several performance considerations worth pointing out. Most notably,
+// we preprocess as much as possible (within reason) at the time of creation of a
+// matcher. This includes:
+// - creating a per-language map, which includes data for the raw base language
+// and its canonicalized variant (if applicable),
+// - expanding entries for the equivalence classes defined in CLDR's
+// languageMatch data.
+// The per-language map ensures that typically only a very small number of tags
+// need to be considered. The pre-expansion of canonicalized subtags and
+// equivalence classes reduces the amount of map lookups that need to be done at
+// runtime.
+
+// matcher keeps a set of supported language tags, indexed by language.
+type matcher struct {
+ default_ *haveTag
+ supported []*haveTag
+ index map[language.Language]*matchHeader
+ passSettings bool
+ preferSameScript bool
+}
+
+// matchHeader has the lists of tags for exact matches and matches based on
+// maximized and canonicalized tags for a given language.
+type matchHeader struct {
+ haveTags []*haveTag
+ original bool
+}
+
+// haveTag holds a supported Tag and its maximized script and region. The maximized
+// or canonicalized language is not stored as it is not needed during matching.
+type haveTag struct {
+ tag language.Tag
+
+ // index of this tag in the original list of supported tags.
+ index int
+
+ // conf is the maximum confidence that can result from matching this haveTag.
+ // When conf < Exact this means it was inserted after applying a CLDR equivalence rule.
+ conf Confidence
+
+ // Maximized region and script.
+ maxRegion language.Region
+ maxScript language.Script
+
+ // altScript may be checked as an alternative match to maxScript. If altScript
+ // matches, the confidence level for this match is Low. Theoretically there
+ // could be multiple alternative scripts. This does not occur in practice.
+ altScript language.Script
+
+ // nextMax is the index of the next haveTag with the same maximized tags.
+ nextMax uint16
+}
+
+func makeHaveTag(tag language.Tag, index int) (haveTag, language.Language) {
+ max := tag
+ if tag.LangID != 0 || tag.RegionID != 0 || tag.ScriptID != 0 {
+ max, _ = canonicalize(All, max)
+ max, _ = max.Maximize()
+ max.RemakeString()
+ }
+ return haveTag{tag, index, Exact, max.RegionID, max.ScriptID, altScript(max.LangID, max.ScriptID), 0}, max.LangID
+}
+
+// altScript returns an alternative script that may match the given script with
+// a low confidence. At the moment, the langMatch data allows for at most one
+// script to map to another and we rely on this to keep the code simple.
+func altScript(l language.Language, s language.Script) language.Script {
+ for _, alt := range matchScript {
+ // TODO: also match cases where language is not the same.
+ if (language.Language(alt.wantLang) == l || language.Language(alt.haveLang) == l) &&
+ language.Script(alt.haveScript) == s {
+ return language.Script(alt.wantScript)
+ }
+ }
+ return 0
+}
+
+// addIfNew adds a haveTag to the list of tags only if it is a unique tag.
+// Tags that have the same maximized values are linked by index.
+func (h *matchHeader) addIfNew(n haveTag, exact bool) {
+ h.original = h.original || exact
+ // Don't add new exact matches.
+ for _, v := range h.haveTags {
+ if equalsRest(v.tag, n.tag) {
+ return
+ }
+ }
+ // Allow duplicate maximized tags, but create a linked list to allow quickly
+ // comparing the equivalents and bail out.
+ for i, v := range h.haveTags {
+ if v.maxScript == n.maxScript &&
+ v.maxRegion == n.maxRegion &&
+ v.tag.VariantOrPrivateUseTags() == n.tag.VariantOrPrivateUseTags() {
+ for h.haveTags[i].nextMax != 0 {
+ i = int(h.haveTags[i].nextMax)
+ }
+ h.haveTags[i].nextMax = uint16(len(h.haveTags))
+ break
+ }
+ }
+ h.haveTags = append(h.haveTags, &n)
+}
+
+// header returns the matchHeader for the given language. It creates one if
+// it doesn't already exist.
+func (m *matcher) header(l language.Language) *matchHeader {
+ if h := m.index[l]; h != nil {
+ return h
+ }
+ h := &matchHeader{}
+ m.index[l] = h
+ return h
+}
+
+func toConf(d uint8) Confidence {
+ if d <= 10 {
+ return High
+ }
+ if d < 30 {
+ return Low
+ }
+ return No
+}
+
+// newMatcher builds an index for the given supported tags and returns it as
+// a matcher. It also expands the index by considering various equivalence classes
+// for a given tag.
+func newMatcher(supported []Tag, options []MatchOption) *matcher {
+ m := &matcher{
+ index: make(map[language.Language]*matchHeader),
+ preferSameScript: true,
+ }
+ for _, o := range options {
+ o(m)
+ }
+ if len(supported) == 0 {
+ m.default_ = &haveTag{}
+ return m
+ }
+ // Add supported languages to the index. Add exact matches first to give
+ // them precedence.
+ for i, tag := range supported {
+ tt := tag.tag()
+ pair, _ := makeHaveTag(tt, i)
+ m.header(tt.LangID).addIfNew(pair, true)
+ m.supported = append(m.supported, &pair)
+ }
+ m.default_ = m.header(supported[0].lang()).haveTags[0]
+ // Keep these in two different loops to support the case that two equivalent
+ // languages are distinguished, such as iw and he.
+ for i, tag := range supported {
+ tt := tag.tag()
+ pair, max := makeHaveTag(tt, i)
+ if max != tt.LangID {
+ m.header(max).addIfNew(pair, true)
+ }
+ }
+
+ // update is used to add indexes in the map for equivalent languages.
+ // update will only add entries to original indexes, thus not computing any
+ // transitive relations.
+ update := func(want, have uint16, conf Confidence) {
+ if hh := m.index[language.Language(have)]; hh != nil {
+ if !hh.original {
+ return
+ }
+ hw := m.header(language.Language(want))
+ for _, ht := range hh.haveTags {
+ v := *ht
+ if conf < v.conf {
+ v.conf = conf
+ }
+ v.nextMax = 0 // this value needs to be recomputed
+ if v.altScript != 0 {
+ v.altScript = altScript(language.Language(want), v.maxScript)
+ }
+ hw.addIfNew(v, conf == Exact && hh.original)
+ }
+ }
+ }
+
+ // Add entries for languages with mutual intelligibility as defined by CLDR's
+ // languageMatch data.
+ for _, ml := range matchLang {
+ update(ml.want, ml.have, toConf(ml.distance))
+ if !ml.oneway {
+ update(ml.have, ml.want, toConf(ml.distance))
+ }
+ }
+
+ // Add entries for possible canonicalizations. This is an optimization to
+ // ensure that only one map lookup needs to be done at runtime per desired tag.
+ // First we match deprecated equivalents. If they are perfect equivalents
+ // (their canonicalization simply substitutes a different language code, but
+ // nothing else), the match confidence is Exact, otherwise it is High.
+ for i, lm := range language.AliasMap {
+ // If deprecated codes match and there is no fiddling with the script or
+ // or region, we consider it an exact match.
+ conf := Exact
+ if language.AliasTypes[i] != language.Macro {
+ if !isExactEquivalent(language.Language(lm.From)) {
+ conf = High
+ }
+ update(lm.To, lm.From, conf)
+ }
+ update(lm.From, lm.To, conf)
+ }
+ return m
+}
+
+// getBest gets the best matching tag in m for any of the given tags, taking into
+// account the order of preference of the given tags.
+func (m *matcher) getBest(want ...Tag) (got *haveTag, orig language.Tag, c Confidence) {
+ best := bestMatch{}
+ for i, ww := range want {
+ w := ww.tag()
+ var max language.Tag
+ // Check for exact match first.
+ h := m.index[w.LangID]
+ if w.LangID != 0 {
+ if h == nil {
+ continue
+ }
+ // Base language is defined.
+ max, _ = canonicalize(Legacy|Deprecated|Macro, w)
+ // A region that is added through canonicalization is stronger than
+ // a maximized region: set it in the original (e.g. mo -> ro-MD).
+ if w.RegionID != max.RegionID {
+ w.RegionID = max.RegionID
+ }
+ // TODO: should we do the same for scripts?
+ // See test case: en, sr, nl ; sh ; sr
+ max, _ = max.Maximize()
+ } else {
+ // Base language is not defined.
+ if h != nil {
+ for i := range h.haveTags {
+ have := h.haveTags[i]
+ if equalsRest(have.tag, w) {
+ return have, w, Exact
+ }
+ }
+ }
+ if w.ScriptID == 0 && w.RegionID == 0 {
+ // We skip all tags matching und for approximate matching, including
+ // private tags.
+ continue
+ }
+ max, _ = w.Maximize()
+ if h = m.index[max.LangID]; h == nil {
+ continue
+ }
+ }
+ pin := true
+ for _, t := range want[i+1:] {
+ if w.LangID == t.lang() {
+ pin = false
+ break
+ }
+ }
+ // Check for match based on maximized tag.
+ for i := range h.haveTags {
+ have := h.haveTags[i]
+ best.update(have, w, max.ScriptID, max.RegionID, pin)
+ if best.conf == Exact {
+ for have.nextMax != 0 {
+ have = h.haveTags[have.nextMax]
+ best.update(have, w, max.ScriptID, max.RegionID, pin)
+ }
+ return best.have, best.want, best.conf
+ }
+ }
+ }
+ if best.conf <= No {
+ if len(want) != 0 {
+ return nil, want[0].tag(), No
+ }
+ return nil, language.Tag{}, No
+ }
+ return best.have, best.want, best.conf
+}
+
+// bestMatch accumulates the best match so far.
+type bestMatch struct {
+ have *haveTag
+ want language.Tag
+ conf Confidence
+ pinnedRegion language.Region
+ pinLanguage bool
+ sameRegionGroup bool
+ // Cached results from applying tie-breaking rules.
+ origLang bool
+ origReg bool
+ paradigmReg bool
+ regGroupDist uint8
+ origScript bool
+}
+
+// update updates the existing best match if the new pair is considered to be a
+// better match. To determine if the given pair is a better match, it first
+// computes the rough confidence level. If this surpasses the current match, it
+// will replace it and update the tie-breaker rule cache. If there is a tie, it
+// proceeds with applying a series of tie-breaker rules. If there is no
+// conclusive winner after applying the tie-breaker rules, it leaves the current
+// match as the preferred match.
+//
+// If pin is true and have and tag are a strong match, it will henceforth only
+// consider matches for this language. This corresponds to the idea that most
+// users have a strong preference for the first defined language. A user can
+// still prefer a second language over a dialect of the preferred language by
+// explicitly specifying dialects, e.g. "en, nl, en-GB". In this case pin should
+// be false.
+func (m *bestMatch) update(have *haveTag, tag language.Tag, maxScript language.Script, maxRegion language.Region, pin bool) {
+ // Bail if the maximum attainable confidence is below that of the current best match.
+ c := have.conf
+ if c < m.conf {
+ return
+ }
+ // Don't change the language once we already have found an exact match.
+ if m.pinLanguage && tag.LangID != m.want.LangID {
+ return
+ }
+ // Pin the region group if we are comparing tags for the same language.
+ if tag.LangID == m.want.LangID && m.sameRegionGroup {
+ _, sameGroup := regionGroupDist(m.pinnedRegion, have.maxRegion, have.maxScript, m.want.LangID)
+ if !sameGroup {
+ return
+ }
+ }
+ if c == Exact && have.maxScript == maxScript {
+ // If there is another language and then another entry of this language,
+ // don't pin anything, otherwise pin the language.
+ m.pinLanguage = pin
+ }
+ if equalsRest(have.tag, tag) {
+ } else if have.maxScript != maxScript {
+ // There is usually very little comprehension between different scripts.
+ // In a few cases there may still be Low comprehension. This possibility
+ // is pre-computed and stored in have.altScript.
+ if Low < m.conf || have.altScript != maxScript {
+ return
+ }
+ c = Low
+ } else if have.maxRegion != maxRegion {
+ if High < c {
+ // There is usually a small difference between languages across regions.
+ c = High
+ }
+ }
+
+ // We store the results of the computations of the tie-breaker rules along
+ // with the best match. There is no need to do the checks once we determine
+ // we have a winner, but we do still need to do the tie-breaker computations.
+ // We use "beaten" to keep track if we still need to do the checks.
+ beaten := false // true if the new pair defeats the current one.
+ if c != m.conf {
+ if c < m.conf {
+ return
+ }
+ beaten = true
+ }
+
+ // Tie-breaker rules:
+ // We prefer if the pre-maximized language was specified and identical.
+ origLang := have.tag.LangID == tag.LangID && tag.LangID != 0
+ if !beaten && m.origLang != origLang {
+ if m.origLang {
+ return
+ }
+ beaten = true
+ }
+
+ // We prefer if the pre-maximized region was specified and identical.
+ origReg := have.tag.RegionID == tag.RegionID && tag.RegionID != 0
+ if !beaten && m.origReg != origReg {
+ if m.origReg {
+ return
+ }
+ beaten = true
+ }
+
+ regGroupDist, sameGroup := regionGroupDist(have.maxRegion, maxRegion, maxScript, tag.LangID)
+ if !beaten && m.regGroupDist != regGroupDist {
+ if regGroupDist > m.regGroupDist {
+ return
+ }
+ beaten = true
+ }
+
+ paradigmReg := isParadigmLocale(tag.LangID, have.maxRegion)
+ if !beaten && m.paradigmReg != paradigmReg {
+ if !paradigmReg {
+ return
+ }
+ beaten = true
+ }
+
+ // Next we prefer if the pre-maximized script was specified and identical.
+ origScript := have.tag.ScriptID == tag.ScriptID && tag.ScriptID != 0
+ if !beaten && m.origScript != origScript {
+ if m.origScript {
+ return
+ }
+ beaten = true
+ }
+
+ // Update m to the newly found best match.
+ if beaten {
+ m.have = have
+ m.want = tag
+ m.conf = c
+ m.pinnedRegion = maxRegion
+ m.sameRegionGroup = sameGroup
+ m.origLang = origLang
+ m.origReg = origReg
+ m.paradigmReg = paradigmReg
+ m.origScript = origScript
+ m.regGroupDist = regGroupDist
+ }
+}
+
+func isParadigmLocale(lang language.Language, r language.Region) bool {
+ for _, e := range paradigmLocales {
+ if language.Language(e[0]) == lang && (r == language.Region(e[1]) || r == language.Region(e[2])) {
+ return true
+ }
+ }
+ return false
+}
+
+// regionGroupDist computes the distance between two regions based on their
+// CLDR grouping.
+func regionGroupDist(a, b language.Region, script language.Script, lang language.Language) (dist uint8, same bool) {
+ const defaultDistance = 4
+
+ aGroup := uint(regionToGroups[a]) << 1
+ bGroup := uint(regionToGroups[b]) << 1
+ for _, ri := range matchRegion {
+ if language.Language(ri.lang) == lang && (ri.script == 0 || language.Script(ri.script) == script) {
+ group := uint(1 << (ri.group &^ 0x80))
+ if 0x80&ri.group == 0 {
+ if aGroup&bGroup&group != 0 { // Both regions are in the group.
+ return ri.distance, ri.distance == defaultDistance
+ }
+ } else {
+ if (aGroup|bGroup)&group == 0 { // Both regions are not in the group.
+ return ri.distance, ri.distance == defaultDistance
+ }
+ }
+ }
+ }
+ return defaultDistance, true
+}
+
+// equalsRest compares everything except the language.
+func equalsRest(a, b language.Tag) bool {
+ // TODO: don't include extensions in this comparison. To do this efficiently,
+ // though, we should handle private tags separately.
+ return a.ScriptID == b.ScriptID && a.RegionID == b.RegionID && a.VariantOrPrivateUseTags() == b.VariantOrPrivateUseTags()
+}
+
+// isExactEquivalent returns true if canonicalizing the language will not alter
+// the script or region of a tag.
+func isExactEquivalent(l language.Language) bool {
+ for _, o := range notEquivalent {
+ if o == l {
+ return false
+ }
+ }
+ return true
+}
+
+var notEquivalent []language.Language
+
+func init() {
+ // Create a list of all languages for which canonicalization may alter the
+ // script or region.
+ for _, lm := range language.AliasMap {
+ tag := language.Tag{LangID: language.Language(lm.From)}
+ if tag, _ = canonicalize(All, tag); tag.ScriptID != 0 || tag.RegionID != 0 {
+ notEquivalent = append(notEquivalent, language.Language(lm.From))
+ }
+ }
+ // Maximize undefined regions of paradigm locales.
+ for i, v := range paradigmLocales {
+ t := language.Tag{LangID: language.Language(v[0])}
+ max, _ := t.Maximize()
+ if v[1] == 0 {
+ paradigmLocales[i][1] = uint16(max.RegionID)
+ }
+ if v[2] == 0 {
+ paradigmLocales[i][2] = uint16(max.RegionID)
+ }
+ }
+}
diff --git a/vendor/golang.org/x/text/language/parse.go b/vendor/golang.org/x/text/language/parse.go
new file mode 100644
index 0000000..4d57222
--- /dev/null
+++ b/vendor/golang.org/x/text/language/parse.go
@@ -0,0 +1,256 @@
+// Copyright 2013 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package language
+
+import (
+ "errors"
+ "sort"
+ "strconv"
+ "strings"
+
+ "golang.org/x/text/internal/language"
+)
+
+// ValueError is returned by any of the parsing functions when the
+// input is well-formed but the respective subtag is not recognized
+// as a valid value.
+type ValueError interface {
+ error
+
+ // Subtag returns the subtag for which the error occurred.
+ Subtag() string
+}
+
+// Parse parses the given BCP 47 string and returns a valid Tag. If parsing
+// failed it returns an error and any part of the tag that could be parsed.
+// If parsing succeeded but an unknown value was found, it returns
+// ValueError. The Tag returned in this case is just stripped of the unknown
+// value. All other values are preserved. It accepts tags in the BCP 47 format
+// and extensions to this standard defined in
+// https://www.unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers.
+// The resulting tag is canonicalized using the default canonicalization type.
+func Parse(s string) (t Tag, err error) {
+ return Default.Parse(s)
+}
+
+// Parse parses the given BCP 47 string and returns a valid Tag. If parsing
+// failed it returns an error and any part of the tag that could be parsed.
+// If parsing succeeded but an unknown value was found, it returns
+// ValueError. The Tag returned in this case is just stripped of the unknown
+// value. All other values are preserved. It accepts tags in the BCP 47 format
+// and extensions to this standard defined in
+// https://www.unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers.
+// The resulting tag is canonicalized using the canonicalization type c.
+func (c CanonType) Parse(s string) (t Tag, err error) {
+ defer func() {
+ if recover() != nil {
+ t = Tag{}
+ err = language.ErrSyntax
+ }
+ }()
+
+ tt, err := language.Parse(s)
+ if err != nil {
+ return makeTag(tt), err
+ }
+ tt, changed := canonicalize(c, tt)
+ if changed {
+ tt.RemakeString()
+ }
+ return makeTag(tt), err
+}
+
+// Compose creates a Tag from individual parts, which may be of type Tag, Base,
+// Script, Region, Variant, []Variant, Extension, []Extension or error. If a
+// Base, Script or Region or slice of type Variant or Extension is passed more
+// than once, the latter will overwrite the former. Variants and Extensions are
+// accumulated, but if two extensions of the same type are passed, the latter
+// will replace the former. For -u extensions, though, the key-type pairs are
+// added, where later values overwrite older ones. A Tag overwrites all former
+// values and typically only makes sense as the first argument. The resulting
+// tag is returned after canonicalizing using the Default CanonType. If one or
+// more errors are encountered, one of the errors is returned.
+func Compose(part ...interface{}) (t Tag, err error) {
+ return Default.Compose(part...)
+}
+
+// Compose creates a Tag from individual parts, which may be of type Tag, Base,
+// Script, Region, Variant, []Variant, Extension, []Extension or error. If a
+// Base, Script or Region or slice of type Variant or Extension is passed more
+// than once, the latter will overwrite the former. Variants and Extensions are
+// accumulated, but if two extensions of the same type are passed, the latter
+// will replace the former. For -u extensions, though, the key-type pairs are
+// added, where later values overwrite older ones. A Tag overwrites all former
+// values and typically only makes sense as the first argument. The resulting
+// tag is returned after canonicalizing using CanonType c. If one or more errors
+// are encountered, one of the errors is returned.
+func (c CanonType) Compose(part ...interface{}) (t Tag, err error) {
+ defer func() {
+ if recover() != nil {
+ t = Tag{}
+ err = language.ErrSyntax
+ }
+ }()
+
+ var b language.Builder
+ if err = update(&b, part...); err != nil {
+ return und, err
+ }
+ b.Tag, _ = canonicalize(c, b.Tag)
+ return makeTag(b.Make()), err
+}
+
+var errInvalidArgument = errors.New("invalid Extension or Variant")
+
+func update(b *language.Builder, part ...interface{}) (err error) {
+ for _, x := range part {
+ switch v := x.(type) {
+ case Tag:
+ b.SetTag(v.tag())
+ case Base:
+ b.Tag.LangID = v.langID
+ case Script:
+ b.Tag.ScriptID = v.scriptID
+ case Region:
+ b.Tag.RegionID = v.regionID
+ case Variant:
+ if v.variant == "" {
+ err = errInvalidArgument
+ break
+ }
+ b.AddVariant(v.variant)
+ case Extension:
+ if v.s == "" {
+ err = errInvalidArgument
+ break
+ }
+ b.SetExt(v.s)
+ case []Variant:
+ b.ClearVariants()
+ for _, v := range v {
+ b.AddVariant(v.variant)
+ }
+ case []Extension:
+ b.ClearExtensions()
+ for _, e := range v {
+ b.SetExt(e.s)
+ }
+ // TODO: support parsing of raw strings based on morphology or just extensions?
+ case error:
+ if v != nil {
+ err = v
+ }
+ }
+ }
+ return
+}
+
+var errInvalidWeight = errors.New("ParseAcceptLanguage: invalid weight")
+var errTagListTooLarge = errors.New("tag list exceeds max length")
+
+// ParseAcceptLanguage parses the contents of an Accept-Language header as
+// defined in http://www.ietf.org/rfc/rfc2616.txt and returns a list of Tags and
+// a list of corresponding quality weights. It is more permissive than RFC 2616
+// and may return non-nil slices even if the input is not valid.
+// The Tags will be sorted by highest weight first and then by first occurrence.
+// Tags with a weight of zero will be dropped. An error will be returned if the
+// input could not be parsed.
+func ParseAcceptLanguage(s string) (tag []Tag, q []float32, err error) {
+ defer func() {
+ if recover() != nil {
+ tag = nil
+ q = nil
+ err = language.ErrSyntax
+ }
+ }()
+
+ if strings.Count(s, "-") > 1000 {
+ return nil, nil, errTagListTooLarge
+ }
+
+ var entry string
+ for s != "" {
+ if entry, s = split(s, ','); entry == "" {
+ continue
+ }
+
+ entry, weight := split(entry, ';')
+
+ // Scan the language.
+ t, err := Parse(entry)
+ if err != nil {
+ id, ok := acceptFallback[entry]
+ if !ok {
+ return nil, nil, err
+ }
+ t = makeTag(language.Tag{LangID: id})
+ }
+
+ // Scan the optional weight.
+ w := 1.0
+ if weight != "" {
+ weight = consume(weight, 'q')
+ weight = consume(weight, '=')
+ // consume returns the empty string when a token could not be
+ // consumed, resulting in an error for ParseFloat.
+ if w, err = strconv.ParseFloat(weight, 32); err != nil {
+ return nil, nil, errInvalidWeight
+ }
+ // Drop tags with a quality weight of 0.
+ if w <= 0 {
+ continue
+ }
+ }
+
+ tag = append(tag, t)
+ q = append(q, float32(w))
+ }
+ sort.Stable(&tagSort{tag, q})
+ return tag, q, nil
+}
+
+// consume removes a leading token c from s and returns the result or the empty
+// string if there is no such token.
+func consume(s string, c byte) string {
+ if s == "" || s[0] != c {
+ return ""
+ }
+ return strings.TrimSpace(s[1:])
+}
+
+func split(s string, c byte) (head, tail string) {
+ if i := strings.IndexByte(s, c); i >= 0 {
+ return strings.TrimSpace(s[:i]), strings.TrimSpace(s[i+1:])
+ }
+ return strings.TrimSpace(s), ""
+}
+
+// Add hack mapping to deal with a small number of cases that occur
+// in Accept-Language (with reasonable frequency).
+var acceptFallback = map[string]language.Language{
+ "english": _en,
+ "deutsch": _de,
+ "italian": _it,
+ "french": _fr,
+ "*": _mul, // defined in the spec to match all languages.
+}
+
+type tagSort struct {
+ tag []Tag
+ q []float32
+}
+
+func (s *tagSort) Len() int {
+ return len(s.q)
+}
+
+func (s *tagSort) Less(i, j int) bool {
+ return s.q[i] > s.q[j]
+}
+
+func (s *tagSort) Swap(i, j int) {
+ s.tag[i], s.tag[j] = s.tag[j], s.tag[i]
+ s.q[i], s.q[j] = s.q[j], s.q[i]
+}
diff --git a/vendor/golang.org/x/text/language/tables.go b/vendor/golang.org/x/text/language/tables.go
new file mode 100644
index 0000000..34a732b
--- /dev/null
+++ b/vendor/golang.org/x/text/language/tables.go
@@ -0,0 +1,298 @@
+// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
+
+package language
+
+// CLDRVersion is the CLDR version from which the tables in this package are derived.
+const CLDRVersion = "32"
+
+const (
+ _de = 269
+ _en = 313
+ _fr = 350
+ _it = 505
+ _mo = 784
+ _no = 879
+ _nb = 839
+ _pt = 960
+ _sh = 1031
+ _mul = 806
+ _und = 0
+)
+const (
+ _001 = 1
+ _419 = 31
+ _BR = 65
+ _CA = 73
+ _ES = 110
+ _GB = 123
+ _MD = 188
+ _PT = 238
+ _UK = 306
+ _US = 309
+ _ZZ = 357
+ _XA = 323
+ _XC = 325
+ _XK = 333
+)
+const (
+ _Latn = 90
+ _Hani = 57
+ _Hans = 59
+ _Hant = 60
+ _Qaaa = 147
+ _Qaai = 155
+ _Qabx = 196
+ _Zinh = 252
+ _Zyyy = 257
+ _Zzzz = 258
+)
+
+var regionToGroups = []uint8{ // 358 elements
+ // Entry 0 - 3F
+ 0x00, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x04,
+ 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x00,
+ 0x00, 0x04, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x00, 0x04,
+ // Entry 40 - 7F
+ 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00,
+ 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x00, 0x08,
+ 0x00, 0x04, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00,
+ // Entry 80 - BF
+ 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00,
+ 0x00, 0x04, 0x01, 0x00, 0x04, 0x02, 0x00, 0x04,
+ 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
+ 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x08, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00,
+ // Entry C0 - FF
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x01,
+ 0x04, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x04,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x04, 0x00, 0x05, 0x00, 0x00, 0x00,
+ 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // Entry 100 - 13F
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
+ 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x00, 0x04,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01, 0x00, 0x05, 0x04, 0x00,
+ 0x00, 0x04, 0x00, 0x04, 0x04, 0x05, 0x00, 0x00,
+ // Entry 140 - 17F
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+} // Size: 382 bytes
+
+var paradigmLocales = [][3]uint16{ // 3 elements
+ 0: [3]uint16{0x139, 0x0, 0x7b},
+ 1: [3]uint16{0x13e, 0x0, 0x1f},
+ 2: [3]uint16{0x3c0, 0x41, 0xee},
+} // Size: 42 bytes
+
+type mutualIntelligibility struct {
+ want uint16
+ have uint16
+ distance uint8
+ oneway bool
+}
+type scriptIntelligibility struct {
+ wantLang uint16
+ haveLang uint16
+ wantScript uint8
+ haveScript uint8
+ distance uint8
+}
+type regionIntelligibility struct {
+ lang uint16
+ script uint8
+ group uint8
+ distance uint8
+}
+
+// matchLang holds pairs of langIDs of base languages that are typically
+// mutually intelligible. Each pair is associated with a confidence and
+// whether the intelligibility goes one or both ways.
+var matchLang = []mutualIntelligibility{ // 113 elements
+ 0: {want: 0x1d1, have: 0xb7, distance: 0x4, oneway: false},
+ 1: {want: 0x407, have: 0xb7, distance: 0x4, oneway: false},
+ 2: {want: 0x407, have: 0x1d1, distance: 0x4, oneway: false},
+ 3: {want: 0x407, have: 0x432, distance: 0x4, oneway: false},
+ 4: {want: 0x43a, have: 0x1, distance: 0x4, oneway: false},
+ 5: {want: 0x1a3, have: 0x10d, distance: 0x4, oneway: true},
+ 6: {want: 0x295, have: 0x10d, distance: 0x4, oneway: true},
+ 7: {want: 0x101, have: 0x36f, distance: 0x8, oneway: false},
+ 8: {want: 0x101, have: 0x347, distance: 0x8, oneway: false},
+ 9: {want: 0x5, have: 0x3e2, distance: 0xa, oneway: true},
+ 10: {want: 0xd, have: 0x139, distance: 0xa, oneway: true},
+ 11: {want: 0x16, have: 0x367, distance: 0xa, oneway: true},
+ 12: {want: 0x21, have: 0x139, distance: 0xa, oneway: true},
+ 13: {want: 0x56, have: 0x13e, distance: 0xa, oneway: true},
+ 14: {want: 0x58, have: 0x3e2, distance: 0xa, oneway: true},
+ 15: {want: 0x71, have: 0x3e2, distance: 0xa, oneway: true},
+ 16: {want: 0x75, have: 0x139, distance: 0xa, oneway: true},
+ 17: {want: 0x82, have: 0x1be, distance: 0xa, oneway: true},
+ 18: {want: 0xa5, have: 0x139, distance: 0xa, oneway: true},
+ 19: {want: 0xb2, have: 0x15e, distance: 0xa, oneway: true},
+ 20: {want: 0xdd, have: 0x153, distance: 0xa, oneway: true},
+ 21: {want: 0xe5, have: 0x139, distance: 0xa, oneway: true},
+ 22: {want: 0xe9, have: 0x3a, distance: 0xa, oneway: true},
+ 23: {want: 0xf0, have: 0x15e, distance: 0xa, oneway: true},
+ 24: {want: 0xf9, have: 0x15e, distance: 0xa, oneway: true},
+ 25: {want: 0x100, have: 0x139, distance: 0xa, oneway: true},
+ 26: {want: 0x130, have: 0x139, distance: 0xa, oneway: true},
+ 27: {want: 0x13c, have: 0x139, distance: 0xa, oneway: true},
+ 28: {want: 0x140, have: 0x151, distance: 0xa, oneway: true},
+ 29: {want: 0x145, have: 0x13e, distance: 0xa, oneway: true},
+ 30: {want: 0x158, have: 0x101, distance: 0xa, oneway: true},
+ 31: {want: 0x16d, have: 0x367, distance: 0xa, oneway: true},
+ 32: {want: 0x16e, have: 0x139, distance: 0xa, oneway: true},
+ 33: {want: 0x16f, have: 0x139, distance: 0xa, oneway: true},
+ 34: {want: 0x17e, have: 0x139, distance: 0xa, oneway: true},
+ 35: {want: 0x190, have: 0x13e, distance: 0xa, oneway: true},
+ 36: {want: 0x194, have: 0x13e, distance: 0xa, oneway: true},
+ 37: {want: 0x1a4, have: 0x1be, distance: 0xa, oneway: true},
+ 38: {want: 0x1b4, have: 0x139, distance: 0xa, oneway: true},
+ 39: {want: 0x1b8, have: 0x139, distance: 0xa, oneway: true},
+ 40: {want: 0x1d4, have: 0x15e, distance: 0xa, oneway: true},
+ 41: {want: 0x1d7, have: 0x3e2, distance: 0xa, oneway: true},
+ 42: {want: 0x1d9, have: 0x139, distance: 0xa, oneway: true},
+ 43: {want: 0x1e7, have: 0x139, distance: 0xa, oneway: true},
+ 44: {want: 0x1f8, have: 0x139, distance: 0xa, oneway: true},
+ 45: {want: 0x20e, have: 0x1e1, distance: 0xa, oneway: true},
+ 46: {want: 0x210, have: 0x139, distance: 0xa, oneway: true},
+ 47: {want: 0x22d, have: 0x15e, distance: 0xa, oneway: true},
+ 48: {want: 0x242, have: 0x3e2, distance: 0xa, oneway: true},
+ 49: {want: 0x24a, have: 0x139, distance: 0xa, oneway: true},
+ 50: {want: 0x251, have: 0x139, distance: 0xa, oneway: true},
+ 51: {want: 0x265, have: 0x139, distance: 0xa, oneway: true},
+ 52: {want: 0x274, have: 0x48a, distance: 0xa, oneway: true},
+ 53: {want: 0x28a, have: 0x3e2, distance: 0xa, oneway: true},
+ 54: {want: 0x28e, have: 0x1f9, distance: 0xa, oneway: true},
+ 55: {want: 0x2a3, have: 0x139, distance: 0xa, oneway: true},
+ 56: {want: 0x2b5, have: 0x15e, distance: 0xa, oneway: true},
+ 57: {want: 0x2b8, have: 0x139, distance: 0xa, oneway: true},
+ 58: {want: 0x2be, have: 0x139, distance: 0xa, oneway: true},
+ 59: {want: 0x2c3, have: 0x15e, distance: 0xa, oneway: true},
+ 60: {want: 0x2ed, have: 0x139, distance: 0xa, oneway: true},
+ 61: {want: 0x2f1, have: 0x15e, distance: 0xa, oneway: true},
+ 62: {want: 0x2fa, have: 0x139, distance: 0xa, oneway: true},
+ 63: {want: 0x2ff, have: 0x7e, distance: 0xa, oneway: true},
+ 64: {want: 0x304, have: 0x139, distance: 0xa, oneway: true},
+ 65: {want: 0x30b, have: 0x3e2, distance: 0xa, oneway: true},
+ 66: {want: 0x31b, have: 0x1be, distance: 0xa, oneway: true},
+ 67: {want: 0x31f, have: 0x1e1, distance: 0xa, oneway: true},
+ 68: {want: 0x320, have: 0x139, distance: 0xa, oneway: true},
+ 69: {want: 0x331, have: 0x139, distance: 0xa, oneway: true},
+ 70: {want: 0x351, have: 0x139, distance: 0xa, oneway: true},
+ 71: {want: 0x36a, have: 0x347, distance: 0xa, oneway: false},
+ 72: {want: 0x36a, have: 0x36f, distance: 0xa, oneway: true},
+ 73: {want: 0x37a, have: 0x139, distance: 0xa, oneway: true},
+ 74: {want: 0x387, have: 0x139, distance: 0xa, oneway: true},
+ 75: {want: 0x389, have: 0x139, distance: 0xa, oneway: true},
+ 76: {want: 0x38b, have: 0x15e, distance: 0xa, oneway: true},
+ 77: {want: 0x390, have: 0x139, distance: 0xa, oneway: true},
+ 78: {want: 0x395, have: 0x139, distance: 0xa, oneway: true},
+ 79: {want: 0x39d, have: 0x139, distance: 0xa, oneway: true},
+ 80: {want: 0x3a5, have: 0x139, distance: 0xa, oneway: true},
+ 81: {want: 0x3be, have: 0x139, distance: 0xa, oneway: true},
+ 82: {want: 0x3c4, have: 0x13e, distance: 0xa, oneway: true},
+ 83: {want: 0x3d4, have: 0x10d, distance: 0xa, oneway: true},
+ 84: {want: 0x3d9, have: 0x139, distance: 0xa, oneway: true},
+ 85: {want: 0x3e5, have: 0x15e, distance: 0xa, oneway: true},
+ 86: {want: 0x3e9, have: 0x1be, distance: 0xa, oneway: true},
+ 87: {want: 0x3fa, have: 0x139, distance: 0xa, oneway: true},
+ 88: {want: 0x40c, have: 0x139, distance: 0xa, oneway: true},
+ 89: {want: 0x423, have: 0x139, distance: 0xa, oneway: true},
+ 90: {want: 0x429, have: 0x139, distance: 0xa, oneway: true},
+ 91: {want: 0x431, have: 0x139, distance: 0xa, oneway: true},
+ 92: {want: 0x43b, have: 0x139, distance: 0xa, oneway: true},
+ 93: {want: 0x43e, have: 0x1e1, distance: 0xa, oneway: true},
+ 94: {want: 0x445, have: 0x139, distance: 0xa, oneway: true},
+ 95: {want: 0x450, have: 0x139, distance: 0xa, oneway: true},
+ 96: {want: 0x461, have: 0x139, distance: 0xa, oneway: true},
+ 97: {want: 0x467, have: 0x3e2, distance: 0xa, oneway: true},
+ 98: {want: 0x46f, have: 0x139, distance: 0xa, oneway: true},
+ 99: {want: 0x476, have: 0x3e2, distance: 0xa, oneway: true},
+ 100: {want: 0x3883, have: 0x139, distance: 0xa, oneway: true},
+ 101: {want: 0x480, have: 0x139, distance: 0xa, oneway: true},
+ 102: {want: 0x482, have: 0x139, distance: 0xa, oneway: true},
+ 103: {want: 0x494, have: 0x3e2, distance: 0xa, oneway: true},
+ 104: {want: 0x49d, have: 0x139, distance: 0xa, oneway: true},
+ 105: {want: 0x4ac, have: 0x529, distance: 0xa, oneway: true},
+ 106: {want: 0x4b4, have: 0x139, distance: 0xa, oneway: true},
+ 107: {want: 0x4bc, have: 0x3e2, distance: 0xa, oneway: true},
+ 108: {want: 0x4e5, have: 0x15e, distance: 0xa, oneway: true},
+ 109: {want: 0x4f2, have: 0x139, distance: 0xa, oneway: true},
+ 110: {want: 0x512, have: 0x139, distance: 0xa, oneway: true},
+ 111: {want: 0x518, have: 0x139, distance: 0xa, oneway: true},
+ 112: {want: 0x52f, have: 0x139, distance: 0xa, oneway: true},
+} // Size: 702 bytes
+
+// matchScript holds pairs of scriptIDs where readers of one script
+// can typically also read the other. Each is associated with a confidence.
+var matchScript = []scriptIntelligibility{ // 26 elements
+ 0: {wantLang: 0x432, haveLang: 0x432, wantScript: 0x5a, haveScript: 0x20, distance: 0x5},
+ 1: {wantLang: 0x432, haveLang: 0x432, wantScript: 0x20, haveScript: 0x5a, distance: 0x5},
+ 2: {wantLang: 0x58, haveLang: 0x3e2, wantScript: 0x5a, haveScript: 0x20, distance: 0xa},
+ 3: {wantLang: 0xa5, haveLang: 0x139, wantScript: 0xe, haveScript: 0x5a, distance: 0xa},
+ 4: {wantLang: 0x1d7, haveLang: 0x3e2, wantScript: 0x8, haveScript: 0x20, distance: 0xa},
+ 5: {wantLang: 0x210, haveLang: 0x139, wantScript: 0x2e, haveScript: 0x5a, distance: 0xa},
+ 6: {wantLang: 0x24a, haveLang: 0x139, wantScript: 0x4e, haveScript: 0x5a, distance: 0xa},
+ 7: {wantLang: 0x251, haveLang: 0x139, wantScript: 0x52, haveScript: 0x5a, distance: 0xa},
+ 8: {wantLang: 0x2b8, haveLang: 0x139, wantScript: 0x57, haveScript: 0x5a, distance: 0xa},
+ 9: {wantLang: 0x304, haveLang: 0x139, wantScript: 0x6e, haveScript: 0x5a, distance: 0xa},
+ 10: {wantLang: 0x331, haveLang: 0x139, wantScript: 0x75, haveScript: 0x5a, distance: 0xa},
+ 11: {wantLang: 0x351, haveLang: 0x139, wantScript: 0x22, haveScript: 0x5a, distance: 0xa},
+ 12: {wantLang: 0x395, haveLang: 0x139, wantScript: 0x81, haveScript: 0x5a, distance: 0xa},
+ 13: {wantLang: 0x39d, haveLang: 0x139, wantScript: 0x36, haveScript: 0x5a, distance: 0xa},
+ 14: {wantLang: 0x3be, haveLang: 0x139, wantScript: 0x5, haveScript: 0x5a, distance: 0xa},
+ 15: {wantLang: 0x3fa, haveLang: 0x139, wantScript: 0x5, haveScript: 0x5a, distance: 0xa},
+ 16: {wantLang: 0x40c, haveLang: 0x139, wantScript: 0xd4, haveScript: 0x5a, distance: 0xa},
+ 17: {wantLang: 0x450, haveLang: 0x139, wantScript: 0xe3, haveScript: 0x5a, distance: 0xa},
+ 18: {wantLang: 0x461, haveLang: 0x139, wantScript: 0xe6, haveScript: 0x5a, distance: 0xa},
+ 19: {wantLang: 0x46f, haveLang: 0x139, wantScript: 0x2c, haveScript: 0x5a, distance: 0xa},
+ 20: {wantLang: 0x476, haveLang: 0x3e2, wantScript: 0x5a, haveScript: 0x20, distance: 0xa},
+ 21: {wantLang: 0x4b4, haveLang: 0x139, wantScript: 0x5, haveScript: 0x5a, distance: 0xa},
+ 22: {wantLang: 0x4bc, haveLang: 0x3e2, wantScript: 0x5a, haveScript: 0x20, distance: 0xa},
+ 23: {wantLang: 0x512, haveLang: 0x139, wantScript: 0x3e, haveScript: 0x5a, distance: 0xa},
+ 24: {wantLang: 0x529, haveLang: 0x529, wantScript: 0x3b, haveScript: 0x3c, distance: 0xf},
+ 25: {wantLang: 0x529, haveLang: 0x529, wantScript: 0x3c, haveScript: 0x3b, distance: 0x13},
+} // Size: 232 bytes
+
+var matchRegion = []regionIntelligibility{ // 15 elements
+ 0: {lang: 0x3a, script: 0x0, group: 0x4, distance: 0x4},
+ 1: {lang: 0x3a, script: 0x0, group: 0x84, distance: 0x4},
+ 2: {lang: 0x139, script: 0x0, group: 0x1, distance: 0x4},
+ 3: {lang: 0x139, script: 0x0, group: 0x81, distance: 0x4},
+ 4: {lang: 0x13e, script: 0x0, group: 0x3, distance: 0x4},
+ 5: {lang: 0x13e, script: 0x0, group: 0x83, distance: 0x4},
+ 6: {lang: 0x3c0, script: 0x0, group: 0x3, distance: 0x4},
+ 7: {lang: 0x3c0, script: 0x0, group: 0x83, distance: 0x4},
+ 8: {lang: 0x529, script: 0x3c, group: 0x2, distance: 0x4},
+ 9: {lang: 0x529, script: 0x3c, group: 0x82, distance: 0x4},
+ 10: {lang: 0x3a, script: 0x0, group: 0x80, distance: 0x5},
+ 11: {lang: 0x139, script: 0x0, group: 0x80, distance: 0x5},
+ 12: {lang: 0x13e, script: 0x0, group: 0x80, distance: 0x5},
+ 13: {lang: 0x3c0, script: 0x0, group: 0x80, distance: 0x5},
+ 14: {lang: 0x529, script: 0x3c, group: 0x80, distance: 0x5},
+} // Size: 114 bytes
+
+// Total table size 1472 bytes (1KiB); checksum: F86C669
diff --git a/vendor/golang.org/x/text/language/tags.go b/vendor/golang.org/x/text/language/tags.go
new file mode 100644
index 0000000..42ea792
--- /dev/null
+++ b/vendor/golang.org/x/text/language/tags.go
@@ -0,0 +1,145 @@
+// Copyright 2013 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package language
+
+import "golang.org/x/text/internal/language/compact"
+
+// TODO: Various sets of commonly use tags and regions.
+
+// MustParse is like Parse, but panics if the given BCP 47 tag cannot be parsed.
+// It simplifies safe initialization of Tag values.
+func MustParse(s string) Tag {
+ t, err := Parse(s)
+ if err != nil {
+ panic(err)
+ }
+ return t
+}
+
+// MustParse is like Parse, but panics if the given BCP 47 tag cannot be parsed.
+// It simplifies safe initialization of Tag values.
+func (c CanonType) MustParse(s string) Tag {
+ t, err := c.Parse(s)
+ if err != nil {
+ panic(err)
+ }
+ return t
+}
+
+// MustParseBase is like ParseBase, but panics if the given base cannot be parsed.
+// It simplifies safe initialization of Base values.
+func MustParseBase(s string) Base {
+ b, err := ParseBase(s)
+ if err != nil {
+ panic(err)
+ }
+ return b
+}
+
+// MustParseScript is like ParseScript, but panics if the given script cannot be
+// parsed. It simplifies safe initialization of Script values.
+func MustParseScript(s string) Script {
+ scr, err := ParseScript(s)
+ if err != nil {
+ panic(err)
+ }
+ return scr
+}
+
+// MustParseRegion is like ParseRegion, but panics if the given region cannot be
+// parsed. It simplifies safe initialization of Region values.
+func MustParseRegion(s string) Region {
+ r, err := ParseRegion(s)
+ if err != nil {
+ panic(err)
+ }
+ return r
+}
+
+var (
+ und = Tag{}
+
+ Und Tag = Tag{}
+
+ Afrikaans Tag = Tag(compact.Afrikaans)
+ Amharic Tag = Tag(compact.Amharic)
+ Arabic Tag = Tag(compact.Arabic)
+ ModernStandardArabic Tag = Tag(compact.ModernStandardArabic)
+ Azerbaijani Tag = Tag(compact.Azerbaijani)
+ Bulgarian Tag = Tag(compact.Bulgarian)
+ Bengali Tag = Tag(compact.Bengali)
+ Catalan Tag = Tag(compact.Catalan)
+ Czech Tag = Tag(compact.Czech)
+ Danish Tag = Tag(compact.Danish)
+ German Tag = Tag(compact.German)
+ Greek Tag = Tag(compact.Greek)
+ English Tag = Tag(compact.English)
+ AmericanEnglish Tag = Tag(compact.AmericanEnglish)
+ BritishEnglish Tag = Tag(compact.BritishEnglish)
+ Spanish Tag = Tag(compact.Spanish)
+ EuropeanSpanish Tag = Tag(compact.EuropeanSpanish)
+ LatinAmericanSpanish Tag = Tag(compact.LatinAmericanSpanish)
+ Estonian Tag = Tag(compact.Estonian)
+ Persian Tag = Tag(compact.Persian)
+ Finnish Tag = Tag(compact.Finnish)
+ Filipino Tag = Tag(compact.Filipino)
+ French Tag = Tag(compact.French)
+ CanadianFrench Tag = Tag(compact.CanadianFrench)
+ Gujarati Tag = Tag(compact.Gujarati)
+ Hebrew Tag = Tag(compact.Hebrew)
+ Hindi Tag = Tag(compact.Hindi)
+ Croatian Tag = Tag(compact.Croatian)
+ Hungarian Tag = Tag(compact.Hungarian)
+ Armenian Tag = Tag(compact.Armenian)
+ Indonesian Tag = Tag(compact.Indonesian)
+ Icelandic Tag = Tag(compact.Icelandic)
+ Italian Tag = Tag(compact.Italian)
+ Japanese Tag = Tag(compact.Japanese)
+ Georgian Tag = Tag(compact.Georgian)
+ Kazakh Tag = Tag(compact.Kazakh)
+ Khmer Tag = Tag(compact.Khmer)
+ Kannada Tag = Tag(compact.Kannada)
+ Korean Tag = Tag(compact.Korean)
+ Kirghiz Tag = Tag(compact.Kirghiz)
+ Lao Tag = Tag(compact.Lao)
+ Lithuanian Tag = Tag(compact.Lithuanian)
+ Latvian Tag = Tag(compact.Latvian)
+ Macedonian Tag = Tag(compact.Macedonian)
+ Malayalam Tag = Tag(compact.Malayalam)
+ Mongolian Tag = Tag(compact.Mongolian)
+ Marathi Tag = Tag(compact.Marathi)
+ Malay Tag = Tag(compact.Malay)
+ Burmese Tag = Tag(compact.Burmese)
+ Nepali Tag = Tag(compact.Nepali)
+ Dutch Tag = Tag(compact.Dutch)
+ Norwegian Tag = Tag(compact.Norwegian)
+ Punjabi Tag = Tag(compact.Punjabi)
+ Polish Tag = Tag(compact.Polish)
+ Portuguese Tag = Tag(compact.Portuguese)
+ BrazilianPortuguese Tag = Tag(compact.BrazilianPortuguese)
+ EuropeanPortuguese Tag = Tag(compact.EuropeanPortuguese)
+ Romanian Tag = Tag(compact.Romanian)
+ Russian Tag = Tag(compact.Russian)
+ Sinhala Tag = Tag(compact.Sinhala)
+ Slovak Tag = Tag(compact.Slovak)
+ Slovenian Tag = Tag(compact.Slovenian)
+ Albanian Tag = Tag(compact.Albanian)
+ Serbian Tag = Tag(compact.Serbian)
+ SerbianLatin Tag = Tag(compact.SerbianLatin)
+ Swedish Tag = Tag(compact.Swedish)
+ Swahili Tag = Tag(compact.Swahili)
+ Tamil Tag = Tag(compact.Tamil)
+ Telugu Tag = Tag(compact.Telugu)
+ Thai Tag = Tag(compact.Thai)
+ Turkish Tag = Tag(compact.Turkish)
+ Ukrainian Tag = Tag(compact.Ukrainian)
+ Urdu Tag = Tag(compact.Urdu)
+ Uzbek Tag = Tag(compact.Uzbek)
+ Vietnamese Tag = Tag(compact.Vietnamese)
+ Chinese Tag = Tag(compact.Chinese)
+ SimplifiedChinese Tag = Tag(compact.SimplifiedChinese)
+ TraditionalChinese Tag = Tag(compact.TraditionalChinese)
+ Zulu Tag = Tag(compact.Zulu)
+)
diff --git a/vendor/golang.org/x/text/message/catalog.go b/vendor/golang.org/x/text/message/catalog.go
new file mode 100644
index 0000000..068271d
--- /dev/null
+++ b/vendor/golang.org/x/text/message/catalog.go
@@ -0,0 +1,36 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package message
+
+// TODO: some types in this file will need to be made public at some time.
+// Documentation and method names will reflect this by using the exported name.
+
+import (
+ "golang.org/x/text/language"
+ "golang.org/x/text/message/catalog"
+)
+
+// MatchLanguage reports the matched tag obtained from language.MatchStrings for
+// the Matcher of the DefaultCatalog.
+func MatchLanguage(preferred ...string) language.Tag {
+ c := DefaultCatalog
+ tag, _ := language.MatchStrings(c.Matcher(), preferred...)
+ return tag
+}
+
+// DefaultCatalog is used by SetString.
+var DefaultCatalog catalog.Catalog = defaultCatalog
+
+var defaultCatalog = catalog.NewBuilder()
+
+// SetString calls SetString on the initial default Catalog.
+func SetString(tag language.Tag, key string, msg string) error {
+ return defaultCatalog.SetString(tag, key, msg)
+}
+
+// Set calls Set on the initial default Catalog.
+func Set(tag language.Tag, key string, msg ...catalog.Message) error {
+ return defaultCatalog.Set(tag, key, msg...)
+}
diff --git a/vendor/golang.org/x/text/message/catalog/catalog.go b/vendor/golang.org/x/text/message/catalog/catalog.go
new file mode 100644
index 0000000..96955d0
--- /dev/null
+++ b/vendor/golang.org/x/text/message/catalog/catalog.go
@@ -0,0 +1,365 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package catalog defines collections of translated format strings.
+//
+// This package mostly defines types for populating catalogs with messages. The
+// catmsg package contains further definitions for creating custom message and
+// dictionary types as well as packages that use Catalogs.
+//
+// Package catalog defines various interfaces: Dictionary, Loader, and Message.
+// A Dictionary maintains a set of translations of format strings for a single
+// language. The Loader interface defines a source of dictionaries. A
+// translation of a format string is represented by a Message.
+//
+// # Catalogs
+//
+// A Catalog defines a programmatic interface for setting message translations.
+// It maintains a set of per-language dictionaries with translations for a set
+// of keys. For message translation to function properly, a translation should
+// be defined for each key for each supported language. A dictionary may be
+// underspecified, though, if there is a parent language that already defines
+// the key. For example, a Dictionary for "en-GB" could leave out entries that
+// are identical to those in a dictionary for "en".
+//
+// # Messages
+//
+// A Message is a format string which varies on the value of substitution
+// variables. For instance, to indicate the number of results one could want "no
+// results" if there are none, "1 result" if there is 1, and "%d results" for
+// any other number. Catalog is agnostic to the kind of format strings that are
+// used: for instance, messages can follow either the printf-style substitution
+// from package fmt or use templates.
+//
+// A Message does not substitute arguments in the format string. This job is
+// reserved for packages that render strings, such as message, that use Catalogs
+// to selected string. This separation of concerns allows Catalog to be used to
+// store any kind of formatting strings.
+//
+// # Selecting messages based on linguistic features of substitution arguments
+//
+// Messages may vary based on any linguistic features of the argument values.
+// The most common one is plural form, but others exist.
+//
+// Selection messages are provided in packages that provide support for a
+// specific linguistic feature. The following snippet uses plural.Selectf:
+//
+// catalog.Set(language.English, "You are %d minute(s) late.",
+// plural.Selectf(1, "",
+// plural.One, "You are 1 minute late.",
+// plural.Other, "You are %d minutes late."))
+//
+// In this example, a message is stored in the Catalog where one of two messages
+// is selected based on the first argument, a number. The first message is
+// selected if the argument is singular (identified by the selector "one") and
+// the second message is selected in all other cases. The selectors are defined
+// by the plural rules defined in CLDR. The selector "other" is special and will
+// always match. Each language always defines one of the linguistic categories
+// to be "other." For English, singular is "one" and plural is "other".
+//
+// Selects can be nested. This allows selecting sentences based on features of
+// multiple arguments or multiple linguistic properties of a single argument.
+//
+// # String interpolation
+//
+// There is often a lot of commonality between the possible variants of a
+// message. For instance, in the example above the word "minute" varies based on
+// the plural catogory of the argument, but the rest of the sentence is
+// identical. Using interpolation the above message can be rewritten as:
+//
+// catalog.Set(language.English, "You are %d minute(s) late.",
+// catalog.Var("minutes",
+// plural.Selectf(1, "", plural.One, "minute", plural.Other, "minutes")),
+// catalog.String("You are %[1]d ${minutes} late."))
+//
+// Var is defined to return the variable name if the message does not yield a
+// match. This allows us to further simplify this snippet to
+//
+// catalog.Set(language.English, "You are %d minute(s) late.",
+// catalog.Var("minutes", plural.Selectf(1, "", plural.One, "minute")),
+// catalog.String("You are %d ${minutes} late."))
+//
+// Overall this is still only a minor improvement, but things can get a lot more
+// unwieldy if more than one linguistic feature is used to determine a message
+// variant. Consider the following example:
+//
+// // argument 1: list of hosts, argument 2: list of guests
+// catalog.Set(language.English, "%[1]v invite(s) %[2]v to their party.",
+// catalog.Var("their",
+// plural.Selectf(1, ""
+// plural.One, gender.Select(1, "female", "her", "other", "his"))),
+// catalog.Var("invites", plural.Selectf(1, "", plural.One, "invite"))
+// catalog.String("%[1]v ${invites} %[2]v to ${their} party.")),
+//
+// Without variable substitution, this would have to be written as
+//
+// // argument 1: list of hosts, argument 2: list of guests
+// catalog.Set(language.English, "%[1]v invite(s) %[2]v to their party.",
+// plural.Selectf(1, "",
+// plural.One, gender.Select(1,
+// "female", "%[1]v invites %[2]v to her party."
+// "other", "%[1]v invites %[2]v to his party."),
+// plural.Other, "%[1]v invites %[2]v to their party."))
+//
+// Not necessarily shorter, but using variables there is less duplication and
+// the messages are more maintenance friendly. Moreover, languages may have up
+// to six plural forms. This makes the use of variables more welcome.
+//
+// Different messages using the same inflections can reuse variables by moving
+// them to macros. Using macros we can rewrite the message as:
+//
+// // argument 1: list of hosts, argument 2: list of guests
+// catalog.SetString(language.English, "%[1]v invite(s) %[2]v to their party.",
+// "%[1]v ${invites(1)} %[2]v to ${their(1)} party.")
+//
+// Where the following macros were defined separately.
+//
+// catalog.SetMacro(language.English, "invites", plural.Selectf(1, "",
+// plural.One, "invite"))
+// catalog.SetMacro(language.English, "their", plural.Selectf(1, "",
+// plural.One, gender.Select(1, "female", "her", "other", "his"))),
+//
+// Placeholders use parentheses and the arguments to invoke a macro.
+//
+// # Looking up messages
+//
+// Message lookup using Catalogs is typically only done by specialized packages
+// and is not something the user should be concerned with. For instance, to
+// express the tardiness of a user using the related message we defined earlier,
+// the user may use the package message like so:
+//
+// p := message.NewPrinter(language.English)
+// p.Printf("You are %d minute(s) late.", 5)
+//
+// Which would print:
+//
+// You are 5 minutes late.
+//
+// This package is UNDER CONSTRUCTION and its API may change.
+package catalog // import "golang.org/x/text/message/catalog"
+
+// TODO:
+// Some way to freeze a catalog.
+// - Locking on each lockup turns out to be about 50% of the total running time
+// for some of the benchmarks in the message package.
+// Consider these:
+// - Sequence type to support sequences in user-defined messages.
+// - Garbage collection: Remove dictionaries that can no longer be reached
+// as other dictionaries have been added that cover all possible keys.
+
+import (
+ "errors"
+ "fmt"
+
+ "golang.org/x/text/internal"
+
+ "golang.org/x/text/internal/catmsg"
+ "golang.org/x/text/language"
+)
+
+// A Catalog allows lookup of translated messages.
+type Catalog interface {
+ // Languages returns all languages for which the Catalog contains variants.
+ Languages() []language.Tag
+
+ // Matcher returns a Matcher for languages from this Catalog.
+ Matcher() language.Matcher
+
+ // A Context is used for evaluating Messages.
+ Context(tag language.Tag, r catmsg.Renderer) *Context
+
+ // This method also makes Catalog a private interface.
+ lookup(tag language.Tag, key string) (data string, ok bool)
+}
+
+// NewFromMap creates a Catalog from the given map. If a Dictionary is
+// underspecified the entry is retrieved from a parent language.
+func NewFromMap(dictionaries map[string]Dictionary, opts ...Option) (Catalog, error) {
+ options := options{}
+ for _, o := range opts {
+ o(&options)
+ }
+ c := &catalog{
+ dicts: map[language.Tag]Dictionary{},
+ }
+ _, hasFallback := dictionaries[options.fallback.String()]
+ if hasFallback {
+ // TODO: Should it be okay to not have a fallback language?
+ // Catalog generators could enforce there is always a fallback.
+ c.langs = append(c.langs, options.fallback)
+ }
+ for lang, dict := range dictionaries {
+ tag, err := language.Parse(lang)
+ if err != nil {
+ return nil, fmt.Errorf("catalog: invalid language tag %q", lang)
+ }
+ if _, ok := c.dicts[tag]; ok {
+ return nil, fmt.Errorf("catalog: duplicate entry for tag %q after normalization", tag)
+ }
+ c.dicts[tag] = dict
+ if !hasFallback || tag != options.fallback {
+ c.langs = append(c.langs, tag)
+ }
+ }
+ if hasFallback {
+ internal.SortTags(c.langs[1:])
+ } else {
+ internal.SortTags(c.langs)
+ }
+ c.matcher = language.NewMatcher(c.langs)
+ return c, nil
+}
+
+// A Dictionary is a source of translations for a single language.
+type Dictionary interface {
+ // Lookup returns a message compiled with catmsg.Compile for the given key.
+ // It returns false for ok if such a message could not be found.
+ Lookup(key string) (data string, ok bool)
+}
+
+type catalog struct {
+ langs []language.Tag
+ dicts map[language.Tag]Dictionary
+ macros store
+ matcher language.Matcher
+}
+
+func (c *catalog) Languages() []language.Tag { return c.langs }
+func (c *catalog) Matcher() language.Matcher { return c.matcher }
+
+func (c *catalog) lookup(tag language.Tag, key string) (data string, ok bool) {
+ for ; ; tag = tag.Parent() {
+ if dict, ok := c.dicts[tag]; ok {
+ if data, ok := dict.Lookup(key); ok {
+ return data, true
+ }
+ }
+ if tag == language.Und {
+ break
+ }
+ }
+ return "", false
+}
+
+// Context returns a Context for formatting messages.
+// Only one Message may be formatted per context at any given time.
+func (c *catalog) Context(tag language.Tag, r catmsg.Renderer) *Context {
+ return &Context{
+ cat: c,
+ tag: tag,
+ dec: catmsg.NewDecoder(tag, r, &dict{&c.macros, tag}),
+ }
+}
+
+// A Builder allows building a Catalog programmatically.
+type Builder struct {
+ options
+ matcher language.Matcher
+
+ index store
+ macros store
+}
+
+type options struct {
+ fallback language.Tag
+}
+
+// An Option configures Catalog behavior.
+type Option func(*options)
+
+// Fallback specifies the default fallback language. The default is Und.
+func Fallback(tag language.Tag) Option {
+ return func(o *options) { o.fallback = tag }
+}
+
+// TODO:
+// // Catalogs specifies one or more sources for a Catalog.
+// // Lookups are in order.
+// // This can be changed inserting a Catalog used for setting, which implements
+// // Loader, used for setting in the chain.
+// func Catalogs(d ...Loader) Option {
+// return nil
+// }
+//
+// func Delims(start, end string) Option {}
+//
+// func Dict(tag language.Tag, d ...Dictionary) Option
+
+// NewBuilder returns an empty mutable Catalog.
+func NewBuilder(opts ...Option) *Builder {
+ c := &Builder{}
+ for _, o := range opts {
+ o(&c.options)
+ }
+ return c
+}
+
+// SetString is shorthand for Set(tag, key, String(msg)).
+func (c *Builder) SetString(tag language.Tag, key string, msg string) error {
+ return c.set(tag, key, &c.index, String(msg))
+}
+
+// Set sets the translation for the given language and key.
+//
+// When evaluation this message, the first Message in the sequence to msgs to
+// evaluate to a string will be the message returned.
+func (c *Builder) Set(tag language.Tag, key string, msg ...Message) error {
+ return c.set(tag, key, &c.index, msg...)
+}
+
+// SetMacro defines a Message that may be substituted in another message.
+// The arguments to a macro Message are passed as arguments in the
+// placeholder the form "${foo(arg1, arg2)}".
+func (c *Builder) SetMacro(tag language.Tag, name string, msg ...Message) error {
+ return c.set(tag, name, &c.macros, msg...)
+}
+
+// ErrNotFound indicates there was no message for the given key.
+var ErrNotFound = errors.New("catalog: message not found")
+
+// String specifies a plain message string. It can be used as fallback if no
+// other strings match or as a simple standalone message.
+//
+// It is an error to pass more than one String in a message sequence.
+func String(name string) Message {
+ return catmsg.String(name)
+}
+
+// Var sets a variable that may be substituted in formatting patterns using
+// named substitution of the form "${name}". The name argument is used as a
+// fallback if the statements do not produce a match. The statement sequence may
+// not contain any Var calls.
+//
+// The name passed to a Var must be unique within message sequence.
+func Var(name string, msg ...Message) Message {
+ return &catmsg.Var{Name: name, Message: firstInSequence(msg)}
+}
+
+// Context returns a Context for formatting messages.
+// Only one Message may be formatted per context at any given time.
+func (b *Builder) Context(tag language.Tag, r catmsg.Renderer) *Context {
+ return &Context{
+ cat: b,
+ tag: tag,
+ dec: catmsg.NewDecoder(tag, r, &dict{&b.macros, tag}),
+ }
+}
+
+// A Context is used for evaluating Messages.
+// Only one Message may be formatted per context at any given time.
+type Context struct {
+ cat Catalog
+ tag language.Tag // TODO: use compact index.
+ dec *catmsg.Decoder
+}
+
+// Execute looks up and executes the message with the given key.
+// It returns ErrNotFound if no message could be found in the index.
+func (c *Context) Execute(key string) error {
+ data, ok := c.cat.lookup(c.tag, key)
+ if !ok {
+ return ErrNotFound
+ }
+ return c.dec.Execute(data)
+}
diff --git a/vendor/golang.org/x/text/message/catalog/dict.go b/vendor/golang.org/x/text/message/catalog/dict.go
new file mode 100644
index 0000000..a0eb818
--- /dev/null
+++ b/vendor/golang.org/x/text/message/catalog/dict.go
@@ -0,0 +1,129 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package catalog
+
+import (
+ "sync"
+
+ "golang.org/x/text/internal"
+ "golang.org/x/text/internal/catmsg"
+ "golang.org/x/text/language"
+)
+
+// TODO:
+// Dictionary returns a Dictionary that returns the first Message, using the
+// given language tag, that matches:
+// 1. the last one registered by one of the Set methods
+// 2. returned by one of the Loaders
+// 3. repeat from 1. using the parent language
+// This approach allows messages to be underspecified.
+// func (c *Catalog) Dictionary(tag language.Tag) (Dictionary, error) {
+// // TODO: verify dictionary exists.
+// return &dict{&c.index, tag}, nil
+// }
+
+type dict struct {
+ s *store
+ tag language.Tag // TODO: make compact tag.
+}
+
+func (d *dict) Lookup(key string) (data string, ok bool) {
+ return d.s.lookup(d.tag, key)
+}
+
+func (b *Builder) lookup(tag language.Tag, key string) (data string, ok bool) {
+ return b.index.lookup(tag, key)
+}
+
+func (c *Builder) set(tag language.Tag, key string, s *store, msg ...Message) error {
+ data, err := catmsg.Compile(tag, &dict{&c.macros, tag}, firstInSequence(msg))
+
+ s.mutex.Lock()
+ defer s.mutex.Unlock()
+
+ m := s.index[tag]
+ if m == nil {
+ m = msgMap{}
+ if s.index == nil {
+ s.index = map[language.Tag]msgMap{}
+ }
+ c.matcher = nil
+ s.index[tag] = m
+ }
+
+ m[key] = data
+ return err
+}
+
+func (c *Builder) Matcher() language.Matcher {
+ c.index.mutex.RLock()
+ m := c.matcher
+ c.index.mutex.RUnlock()
+ if m != nil {
+ return m
+ }
+
+ c.index.mutex.Lock()
+ if c.matcher == nil {
+ c.matcher = language.NewMatcher(c.unlockedLanguages())
+ }
+ m = c.matcher
+ c.index.mutex.Unlock()
+ return m
+}
+
+type store struct {
+ mutex sync.RWMutex
+ index map[language.Tag]msgMap
+}
+
+type msgMap map[string]string
+
+func (s *store) lookup(tag language.Tag, key string) (data string, ok bool) {
+ s.mutex.RLock()
+ defer s.mutex.RUnlock()
+
+ for ; ; tag = tag.Parent() {
+ if msgs, ok := s.index[tag]; ok {
+ if msg, ok := msgs[key]; ok {
+ return msg, true
+ }
+ }
+ if tag == language.Und {
+ break
+ }
+ }
+ return "", false
+}
+
+// Languages returns all languages for which the Catalog contains variants.
+func (b *Builder) Languages() []language.Tag {
+ s := &b.index
+ s.mutex.RLock()
+ defer s.mutex.RUnlock()
+
+ return b.unlockedLanguages()
+}
+
+func (b *Builder) unlockedLanguages() []language.Tag {
+ s := &b.index
+ if len(s.index) == 0 {
+ return nil
+ }
+ tags := make([]language.Tag, 0, len(s.index))
+ _, hasFallback := s.index[b.options.fallback]
+ offset := 0
+ if hasFallback {
+ tags = append(tags, b.options.fallback)
+ offset = 1
+ }
+ for t := range s.index {
+ if t != b.options.fallback {
+ tags = append(tags, t)
+ }
+ }
+ internal.SortTags(tags[offset:])
+ return tags
+}
diff --git a/vendor/golang.org/x/text/message/catalog/go19.go b/vendor/golang.org/x/text/message/catalog/go19.go
new file mode 100644
index 0000000..4e5e87f
--- /dev/null
+++ b/vendor/golang.org/x/text/message/catalog/go19.go
@@ -0,0 +1,16 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build go1.9
+// +build go1.9
+
+package catalog
+
+import "golang.org/x/text/internal/catmsg"
+
+// A Message holds a collection of translations for the same phrase that may
+// vary based on the values of substitution arguments.
+type Message = catmsg.Message
+
+type firstInSequence = catmsg.FirstOf
diff --git a/vendor/golang.org/x/text/message/catalog/gopre19.go b/vendor/golang.org/x/text/message/catalog/gopre19.go
new file mode 100644
index 0000000..9e14685
--- /dev/null
+++ b/vendor/golang.org/x/text/message/catalog/gopre19.go
@@ -0,0 +1,24 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build !go1.9
+// +build !go1.9
+
+package catalog
+
+import "golang.org/x/text/internal/catmsg"
+
+// A Message holds a collection of translations for the same phrase that may
+// vary based on the values of substitution arguments.
+type Message interface {
+ catmsg.Message
+}
+
+func firstInSequence(m []Message) catmsg.Message {
+ a := []catmsg.Message{}
+ for _, m := range m {
+ a = append(a, m)
+ }
+ return catmsg.FirstOf(a)
+}
diff --git a/vendor/golang.org/x/text/message/doc.go b/vendor/golang.org/x/text/message/doc.go
new file mode 100644
index 0000000..4bf7bdc
--- /dev/null
+++ b/vendor/golang.org/x/text/message/doc.go
@@ -0,0 +1,99 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package message implements formatted I/O for localized strings with functions
+// analogous to the fmt's print functions. It is a drop-in replacement for fmt.
+//
+// # Localized Formatting
+//
+// A format string can be localized by replacing any of the print functions of
+// fmt with an equivalent call to a Printer.
+//
+// p := message.NewPrinter(message.MatchLanguage("en"))
+// p.Println(123456.78) // Prints 123,456.78
+//
+// p.Printf("%d ducks in a row", 4331) // Prints 4,331 ducks in a row
+//
+// p := message.NewPrinter(message.MatchLanguage("nl"))
+// p.Printf("Hoogte: %.1f meter", 1244.9) // Prints Hoogte: 1,244.9 meter
+//
+// p := message.NewPrinter(message.MatchLanguage("bn"))
+// p.Println(123456.78) // Prints ১,২৩,৪৫৬.৭৮
+//
+// Printer currently supports numbers and specialized types for which packages
+// exist in x/text. Other builtin types such as time.Time and slices are
+// planned.
+//
+// Format strings largely have the same meaning as with fmt with the following
+// notable exceptions:
+// - flag # always resorts to fmt for printing
+// - verb 'f', 'e', 'g', 'd' use localized formatting unless the '#' flag is
+// specified.
+// - verb 'm' inserts a translation of a string argument.
+//
+// See package fmt for more options.
+//
+// # Translation
+//
+// The format strings that are passed to Printf, Sprintf, Fprintf, or Errorf
+// are used as keys to look up translations for the specified languages.
+// More on how these need to be specified below.
+//
+// One can use arbitrary keys to distinguish between otherwise ambiguous
+// strings:
+//
+// p := message.NewPrinter(language.English)
+// p.Printf("archive(noun)") // Prints "archive"
+// p.Printf("archive(verb)") // Prints "archive"
+//
+// p := message.NewPrinter(language.German)
+// p.Printf("archive(noun)") // Prints "Archiv"
+// p.Printf("archive(verb)") // Prints "archivieren"
+//
+// To retain the fallback functionality, use Key:
+//
+// p.Printf(message.Key("archive(noun)", "archive"))
+// p.Printf(message.Key("archive(verb)", "archive"))
+//
+// # Translation Pipeline
+//
+// Format strings that contain text need to be translated to support different
+// locales. The first step is to extract strings that need to be translated.
+//
+// 1. Install gotext
+//
+// go get -u golang.org/x/text/cmd/gotext
+// gotext -help
+//
+// 2. Mark strings in your source to be translated by using message.Printer,
+// instead of the functions of the fmt package.
+//
+// 3. Extract the strings from your source
+//
+// gotext extract
+//
+// The output will be written to the textdata directory.
+//
+// 4. Send the files for translation
+//
+// It is planned to support multiple formats, but for now one will have to
+// rewrite the JSON output to the desired format.
+//
+// 5. Inject translations into program
+//
+// 6. Repeat from 2
+//
+// Right now this has to be done programmatically with calls to Set or
+// SetString. These functions as well as the methods defined in
+// see also package golang.org/x/text/message/catalog can be used to implement
+// either dynamic or static loading of messages.
+//
+// # Plural and Gender Forms
+//
+// Translated messages can vary based on the plural and gender forms of
+// substitution values. In general, it is up to the translators to provide
+// alternative translations for such forms. See the packages in
+// golang.org/x/text/feature and golang.org/x/text/message/catalog for more
+// information.
+package message
diff --git a/vendor/golang.org/x/text/message/format.go b/vendor/golang.org/x/text/message/format.go
new file mode 100644
index 0000000..a47d17d
--- /dev/null
+++ b/vendor/golang.org/x/text/message/format.go
@@ -0,0 +1,510 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package message
+
+import (
+ "bytes"
+ "strconv"
+ "unicode/utf8"
+
+ "golang.org/x/text/internal/format"
+)
+
+const (
+ ldigits = "0123456789abcdefx"
+ udigits = "0123456789ABCDEFX"
+)
+
+const (
+ signed = true
+ unsigned = false
+)
+
+// A formatInfo is the raw formatter used by Printf etc.
+// It prints into a buffer that must be set up separately.
+type formatInfo struct {
+ buf *bytes.Buffer
+
+ format.Parser
+
+ // intbuf is large enough to store %b of an int64 with a sign and
+ // avoids padding at the end of the struct on 32 bit architectures.
+ intbuf [68]byte
+}
+
+func (f *formatInfo) init(buf *bytes.Buffer) {
+ f.ClearFlags()
+ f.buf = buf
+}
+
+// writePadding generates n bytes of padding.
+func (f *formatInfo) writePadding(n int) {
+ if n <= 0 { // No padding bytes needed.
+ return
+ }
+ f.buf.Grow(n)
+ // Decide which byte the padding should be filled with.
+ padByte := byte(' ')
+ if f.Zero {
+ padByte = byte('0')
+ }
+ // Fill padding with padByte.
+ for i := 0; i < n; i++ {
+ f.buf.WriteByte(padByte) // TODO: make more efficient.
+ }
+}
+
+// pad appends b to f.buf, padded on left (!f.minus) or right (f.minus).
+func (f *formatInfo) pad(b []byte) {
+ if !f.WidthPresent || f.Width == 0 {
+ f.buf.Write(b)
+ return
+ }
+ width := f.Width - utf8.RuneCount(b)
+ if !f.Minus {
+ // left padding
+ f.writePadding(width)
+ f.buf.Write(b)
+ } else {
+ // right padding
+ f.buf.Write(b)
+ f.writePadding(width)
+ }
+}
+
+// padString appends s to f.buf, padded on left (!f.minus) or right (f.minus).
+func (f *formatInfo) padString(s string) {
+ if !f.WidthPresent || f.Width == 0 {
+ f.buf.WriteString(s)
+ return
+ }
+ width := f.Width - utf8.RuneCountInString(s)
+ if !f.Minus {
+ // left padding
+ f.writePadding(width)
+ f.buf.WriteString(s)
+ } else {
+ // right padding
+ f.buf.WriteString(s)
+ f.writePadding(width)
+ }
+}
+
+// fmt_boolean formats a boolean.
+func (f *formatInfo) fmt_boolean(v bool) {
+ if v {
+ f.padString("true")
+ } else {
+ f.padString("false")
+ }
+}
+
+// fmt_unicode formats a uint64 as "U+0078" or with f.sharp set as "U+0078 'x'".
+func (f *formatInfo) fmt_unicode(u uint64) {
+ buf := f.intbuf[0:]
+
+ // With default precision set the maximum needed buf length is 18
+ // for formatting -1 with %#U ("U+FFFFFFFFFFFFFFFF") which fits
+ // into the already allocated intbuf with a capacity of 68 bytes.
+ prec := 4
+ if f.PrecPresent && f.Prec > 4 {
+ prec = f.Prec
+ // Compute space needed for "U+" , number, " '", character, "'".
+ width := 2 + prec + 2 + utf8.UTFMax + 1
+ if width > len(buf) {
+ buf = make([]byte, width)
+ }
+ }
+
+ // Format into buf, ending at buf[i]. Formatting numbers is easier right-to-left.
+ i := len(buf)
+
+ // For %#U we want to add a space and a quoted character at the end of the buffer.
+ if f.Sharp && u <= utf8.MaxRune && strconv.IsPrint(rune(u)) {
+ i--
+ buf[i] = '\''
+ i -= utf8.RuneLen(rune(u))
+ utf8.EncodeRune(buf[i:], rune(u))
+ i--
+ buf[i] = '\''
+ i--
+ buf[i] = ' '
+ }
+ // Format the Unicode code point u as a hexadecimal number.
+ for u >= 16 {
+ i--
+ buf[i] = udigits[u&0xF]
+ prec--
+ u >>= 4
+ }
+ i--
+ buf[i] = udigits[u]
+ prec--
+ // Add zeros in front of the number until requested precision is reached.
+ for prec > 0 {
+ i--
+ buf[i] = '0'
+ prec--
+ }
+ // Add a leading "U+".
+ i--
+ buf[i] = '+'
+ i--
+ buf[i] = 'U'
+
+ oldZero := f.Zero
+ f.Zero = false
+ f.pad(buf[i:])
+ f.Zero = oldZero
+}
+
+// fmt_integer formats signed and unsigned integers.
+func (f *formatInfo) fmt_integer(u uint64, base int, isSigned bool, digits string) {
+ negative := isSigned && int64(u) < 0
+ if negative {
+ u = -u
+ }
+
+ buf := f.intbuf[0:]
+ // The already allocated f.intbuf with a capacity of 68 bytes
+ // is large enough for integer formatting when no precision or width is set.
+ if f.WidthPresent || f.PrecPresent {
+ // Account 3 extra bytes for possible addition of a sign and "0x".
+ width := 3 + f.Width + f.Prec // wid and prec are always positive.
+ if width > len(buf) {
+ // We're going to need a bigger boat.
+ buf = make([]byte, width)
+ }
+ }
+
+ // Two ways to ask for extra leading zero digits: %.3d or %03d.
+ // If both are specified the f.zero flag is ignored and
+ // padding with spaces is used instead.
+ prec := 0
+ if f.PrecPresent {
+ prec = f.Prec
+ // Precision of 0 and value of 0 means "print nothing" but padding.
+ if prec == 0 && u == 0 {
+ oldZero := f.Zero
+ f.Zero = false
+ f.writePadding(f.Width)
+ f.Zero = oldZero
+ return
+ }
+ } else if f.Zero && f.WidthPresent {
+ prec = f.Width
+ if negative || f.Plus || f.Space {
+ prec-- // leave room for sign
+ }
+ }
+
+ // Because printing is easier right-to-left: format u into buf, ending at buf[i].
+ // We could make things marginally faster by splitting the 32-bit case out
+ // into a separate block but it's not worth the duplication, so u has 64 bits.
+ i := len(buf)
+ // Use constants for the division and modulo for more efficient code.
+ // Switch cases ordered by popularity.
+ switch base {
+ case 10:
+ for u >= 10 {
+ i--
+ next := u / 10
+ buf[i] = byte('0' + u - next*10)
+ u = next
+ }
+ case 16:
+ for u >= 16 {
+ i--
+ buf[i] = digits[u&0xF]
+ u >>= 4
+ }
+ case 8:
+ for u >= 8 {
+ i--
+ buf[i] = byte('0' + u&7)
+ u >>= 3
+ }
+ case 2:
+ for u >= 2 {
+ i--
+ buf[i] = byte('0' + u&1)
+ u >>= 1
+ }
+ default:
+ panic("fmt: unknown base; can't happen")
+ }
+ i--
+ buf[i] = digits[u]
+ for i > 0 && prec > len(buf)-i {
+ i--
+ buf[i] = '0'
+ }
+
+ // Various prefixes: 0x, -, etc.
+ if f.Sharp {
+ switch base {
+ case 8:
+ if buf[i] != '0' {
+ i--
+ buf[i] = '0'
+ }
+ case 16:
+ // Add a leading 0x or 0X.
+ i--
+ buf[i] = digits[16]
+ i--
+ buf[i] = '0'
+ }
+ }
+
+ if negative {
+ i--
+ buf[i] = '-'
+ } else if f.Plus {
+ i--
+ buf[i] = '+'
+ } else if f.Space {
+ i--
+ buf[i] = ' '
+ }
+
+ // Left padding with zeros has already been handled like precision earlier
+ // or the f.zero flag is ignored due to an explicitly set precision.
+ oldZero := f.Zero
+ f.Zero = false
+ f.pad(buf[i:])
+ f.Zero = oldZero
+}
+
+// truncate truncates the string to the specified precision, if present.
+func (f *formatInfo) truncate(s string) string {
+ if f.PrecPresent {
+ n := f.Prec
+ for i := range s {
+ n--
+ if n < 0 {
+ return s[:i]
+ }
+ }
+ }
+ return s
+}
+
+// fmt_s formats a string.
+func (f *formatInfo) fmt_s(s string) {
+ s = f.truncate(s)
+ f.padString(s)
+}
+
+// fmt_sbx formats a string or byte slice as a hexadecimal encoding of its bytes.
+func (f *formatInfo) fmt_sbx(s string, b []byte, digits string) {
+ length := len(b)
+ if b == nil {
+ // No byte slice present. Assume string s should be encoded.
+ length = len(s)
+ }
+ // Set length to not process more bytes than the precision demands.
+ if f.PrecPresent && f.Prec < length {
+ length = f.Prec
+ }
+ // Compute width of the encoding taking into account the f.sharp and f.space flag.
+ width := 2 * length
+ if width > 0 {
+ if f.Space {
+ // Each element encoded by two hexadecimals will get a leading 0x or 0X.
+ if f.Sharp {
+ width *= 2
+ }
+ // Elements will be separated by a space.
+ width += length - 1
+ } else if f.Sharp {
+ // Only a leading 0x or 0X will be added for the whole string.
+ width += 2
+ }
+ } else { // The byte slice or string that should be encoded is empty.
+ if f.WidthPresent {
+ f.writePadding(f.Width)
+ }
+ return
+ }
+ // Handle padding to the left.
+ if f.WidthPresent && f.Width > width && !f.Minus {
+ f.writePadding(f.Width - width)
+ }
+ // Write the encoding directly into the output buffer.
+ buf := f.buf
+ if f.Sharp {
+ // Add leading 0x or 0X.
+ buf.WriteByte('0')
+ buf.WriteByte(digits[16])
+ }
+ var c byte
+ for i := 0; i < length; i++ {
+ if f.Space && i > 0 {
+ // Separate elements with a space.
+ buf.WriteByte(' ')
+ if f.Sharp {
+ // Add leading 0x or 0X for each element.
+ buf.WriteByte('0')
+ buf.WriteByte(digits[16])
+ }
+ }
+ if b != nil {
+ c = b[i] // Take a byte from the input byte slice.
+ } else {
+ c = s[i] // Take a byte from the input string.
+ }
+ // Encode each byte as two hexadecimal digits.
+ buf.WriteByte(digits[c>>4])
+ buf.WriteByte(digits[c&0xF])
+ }
+ // Handle padding to the right.
+ if f.WidthPresent && f.Width > width && f.Minus {
+ f.writePadding(f.Width - width)
+ }
+}
+
+// fmt_sx formats a string as a hexadecimal encoding of its bytes.
+func (f *formatInfo) fmt_sx(s, digits string) {
+ f.fmt_sbx(s, nil, digits)
+}
+
+// fmt_bx formats a byte slice as a hexadecimal encoding of its bytes.
+func (f *formatInfo) fmt_bx(b []byte, digits string) {
+ f.fmt_sbx("", b, digits)
+}
+
+// fmt_q formats a string as a double-quoted, escaped Go string constant.
+// If f.sharp is set a raw (backquoted) string may be returned instead
+// if the string does not contain any control characters other than tab.
+func (f *formatInfo) fmt_q(s string) {
+ s = f.truncate(s)
+ if f.Sharp && strconv.CanBackquote(s) {
+ f.padString("`" + s + "`")
+ return
+ }
+ buf := f.intbuf[:0]
+ if f.Plus {
+ f.pad(strconv.AppendQuoteToASCII(buf, s))
+ } else {
+ f.pad(strconv.AppendQuote(buf, s))
+ }
+}
+
+// fmt_c formats an integer as a Unicode character.
+// If the character is not valid Unicode, it will print '\ufffd'.
+func (f *formatInfo) fmt_c(c uint64) {
+ r := rune(c)
+ if c > utf8.MaxRune {
+ r = utf8.RuneError
+ }
+ buf := f.intbuf[:0]
+ w := utf8.EncodeRune(buf[:utf8.UTFMax], r)
+ f.pad(buf[:w])
+}
+
+// fmt_qc formats an integer as a single-quoted, escaped Go character constant.
+// If the character is not valid Unicode, it will print '\ufffd'.
+func (f *formatInfo) fmt_qc(c uint64) {
+ r := rune(c)
+ if c > utf8.MaxRune {
+ r = utf8.RuneError
+ }
+ buf := f.intbuf[:0]
+ if f.Plus {
+ f.pad(strconv.AppendQuoteRuneToASCII(buf, r))
+ } else {
+ f.pad(strconv.AppendQuoteRune(buf, r))
+ }
+}
+
+// fmt_float formats a float64. It assumes that verb is a valid format specifier
+// for strconv.AppendFloat and therefore fits into a byte.
+func (f *formatInfo) fmt_float(v float64, size int, verb rune, prec int) {
+ // Explicit precision in format specifier overrules default precision.
+ if f.PrecPresent {
+ prec = f.Prec
+ }
+ // Format number, reserving space for leading + sign if needed.
+ num := strconv.AppendFloat(f.intbuf[:1], v, byte(verb), prec, size)
+ if num[1] == '-' || num[1] == '+' {
+ num = num[1:]
+ } else {
+ num[0] = '+'
+ }
+ // f.space means to add a leading space instead of a "+" sign unless
+ // the sign is explicitly asked for by f.plus.
+ if f.Space && num[0] == '+' && !f.Plus {
+ num[0] = ' '
+ }
+ // Special handling for infinities and NaN,
+ // which don't look like a number so shouldn't be padded with zeros.
+ if num[1] == 'I' || num[1] == 'N' {
+ oldZero := f.Zero
+ f.Zero = false
+ // Remove sign before NaN if not asked for.
+ if num[1] == 'N' && !f.Space && !f.Plus {
+ num = num[1:]
+ }
+ f.pad(num)
+ f.Zero = oldZero
+ return
+ }
+ // The sharp flag forces printing a decimal point for non-binary formats
+ // and retains trailing zeros, which we may need to restore.
+ if f.Sharp && verb != 'b' {
+ digits := 0
+ switch verb {
+ case 'v', 'g', 'G':
+ digits = prec
+ // If no precision is set explicitly use a precision of 6.
+ if digits == -1 {
+ digits = 6
+ }
+ }
+
+ // Buffer pre-allocated with enough room for
+ // exponent notations of the form "e+123".
+ var tailBuf [5]byte
+ tail := tailBuf[:0]
+
+ hasDecimalPoint := false
+ // Starting from i = 1 to skip sign at num[0].
+ for i := 1; i < len(num); i++ {
+ switch num[i] {
+ case '.':
+ hasDecimalPoint = true
+ case 'e', 'E':
+ tail = append(tail, num[i:]...)
+ num = num[:i]
+ default:
+ digits--
+ }
+ }
+ if !hasDecimalPoint {
+ num = append(num, '.')
+ }
+ for digits > 0 {
+ num = append(num, '0')
+ digits--
+ }
+ num = append(num, tail...)
+ }
+ // We want a sign if asked for and if the sign is not positive.
+ if f.Plus || num[0] != '+' {
+ // If we're zero padding to the left we want the sign before the leading zeros.
+ // Achieve this by writing the sign out and then padding the unsigned number.
+ if f.Zero && f.WidthPresent && f.Width > len(num) {
+ f.buf.WriteByte(num[0])
+ f.writePadding(f.Width - len(num))
+ f.buf.Write(num[1:])
+ return
+ }
+ f.pad(num)
+ return
+ }
+ // No sign to show and the number is positive; just print the unsigned number.
+ f.pad(num[1:])
+}
diff --git a/vendor/golang.org/x/text/message/message.go b/vendor/golang.org/x/text/message/message.go
new file mode 100644
index 0000000..48d7663
--- /dev/null
+++ b/vendor/golang.org/x/text/message/message.go
@@ -0,0 +1,193 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package message // import "golang.org/x/text/message"
+
+import (
+ "io"
+ "os"
+
+ // Include features to facilitate generated catalogs.
+ _ "golang.org/x/text/feature/plural"
+
+ "golang.org/x/text/internal/number"
+ "golang.org/x/text/language"
+ "golang.org/x/text/message/catalog"
+)
+
+// A Printer implements language-specific formatted I/O analogous to the fmt
+// package.
+type Printer struct {
+ // the language
+ tag language.Tag
+
+ toDecimal number.Formatter
+ toScientific number.Formatter
+
+ cat catalog.Catalog
+}
+
+type options struct {
+ cat catalog.Catalog
+ // TODO:
+ // - allow %s to print integers in written form (tables are likely too large
+ // to enable this by default).
+ // - list behavior
+ //
+}
+
+// An Option defines an option of a Printer.
+type Option func(o *options)
+
+// Catalog defines the catalog to be used.
+func Catalog(c catalog.Catalog) Option {
+ return func(o *options) { o.cat = c }
+}
+
+// NewPrinter returns a Printer that formats messages tailored to language t.
+func NewPrinter(t language.Tag, opts ...Option) *Printer {
+ options := &options{
+ cat: DefaultCatalog,
+ }
+ for _, o := range opts {
+ o(options)
+ }
+ p := &Printer{
+ tag: t,
+ cat: options.cat,
+ }
+ p.toDecimal.InitDecimal(t)
+ p.toScientific.InitScientific(t)
+ return p
+}
+
+// Sprint is like fmt.Sprint, but using language-specific formatting.
+func (p *Printer) Sprint(a ...interface{}) string {
+ pp := newPrinter(p)
+ pp.doPrint(a)
+ s := pp.String()
+ pp.free()
+ return s
+}
+
+// Fprint is like fmt.Fprint, but using language-specific formatting.
+func (p *Printer) Fprint(w io.Writer, a ...interface{}) (n int, err error) {
+ pp := newPrinter(p)
+ pp.doPrint(a)
+ n64, err := io.Copy(w, &pp.Buffer)
+ pp.free()
+ return int(n64), err
+}
+
+// Print is like fmt.Print, but using language-specific formatting.
+func (p *Printer) Print(a ...interface{}) (n int, err error) {
+ return p.Fprint(os.Stdout, a...)
+}
+
+// Sprintln is like fmt.Sprintln, but using language-specific formatting.
+func (p *Printer) Sprintln(a ...interface{}) string {
+ pp := newPrinter(p)
+ pp.doPrintln(a)
+ s := pp.String()
+ pp.free()
+ return s
+}
+
+// Fprintln is like fmt.Fprintln, but using language-specific formatting.
+func (p *Printer) Fprintln(w io.Writer, a ...interface{}) (n int, err error) {
+ pp := newPrinter(p)
+ pp.doPrintln(a)
+ n64, err := io.Copy(w, &pp.Buffer)
+ pp.free()
+ return int(n64), err
+}
+
+// Println is like fmt.Println, but using language-specific formatting.
+func (p *Printer) Println(a ...interface{}) (n int, err error) {
+ return p.Fprintln(os.Stdout, a...)
+}
+
+// Sprintf is like fmt.Sprintf, but using language-specific formatting.
+func (p *Printer) Sprintf(key Reference, a ...interface{}) string {
+ pp := newPrinter(p)
+ lookupAndFormat(pp, key, a)
+ s := pp.String()
+ pp.free()
+ return s
+}
+
+// Fprintf is like fmt.Fprintf, but using language-specific formatting.
+func (p *Printer) Fprintf(w io.Writer, key Reference, a ...interface{}) (n int, err error) {
+ pp := newPrinter(p)
+ lookupAndFormat(pp, key, a)
+ n, err = w.Write(pp.Bytes())
+ pp.free()
+ return n, err
+
+}
+
+// Printf is like fmt.Printf, but using language-specific formatting.
+func (p *Printer) Printf(key Reference, a ...interface{}) (n int, err error) {
+ pp := newPrinter(p)
+ lookupAndFormat(pp, key, a)
+ n, err = os.Stdout.Write(pp.Bytes())
+ pp.free()
+ return n, err
+}
+
+func lookupAndFormat(p *printer, r Reference, a []interface{}) {
+ p.fmt.Reset(a)
+ var id, msg string
+ switch v := r.(type) {
+ case string:
+ id, msg = v, v
+ case key:
+ id, msg = v.id, v.fallback
+ default:
+ panic("key argument is not a Reference")
+ }
+
+ if p.catContext.Execute(id) == catalog.ErrNotFound {
+ if p.catContext.Execute(msg) == catalog.ErrNotFound {
+ p.Render(msg)
+ return
+ }
+ }
+}
+
+type rawPrinter struct {
+ p *printer
+}
+
+func (p rawPrinter) Render(msg string) { p.p.WriteString(msg) }
+func (p rawPrinter) Arg(i int) interface{} { return nil }
+
+// Arg implements catmsg.Renderer.
+func (p *printer) Arg(i int) interface{} { // TODO, also return "ok" bool
+ i--
+ if uint(i) < uint(len(p.fmt.Args)) {
+ return p.fmt.Args[i]
+ }
+ return nil
+}
+
+// Render implements catmsg.Renderer.
+func (p *printer) Render(msg string) {
+ p.doPrintf(msg)
+}
+
+// A Reference is a string or a message reference.
+type Reference interface {
+ // TODO: also allow []string
+}
+
+// Key creates a message Reference for a message where the given id is used for
+// message lookup and the fallback is returned when no matches are found.
+func Key(id string, fallback string) Reference {
+ return key{id, fallback}
+}
+
+type key struct {
+ id, fallback string
+}
diff --git a/vendor/golang.org/x/text/message/print.go b/vendor/golang.org/x/text/message/print.go
new file mode 100644
index 0000000..da304cc
--- /dev/null
+++ b/vendor/golang.org/x/text/message/print.go
@@ -0,0 +1,984 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package message
+
+import (
+ "bytes"
+ "fmt" // TODO: consider copying interfaces from package fmt to avoid dependency.
+ "math"
+ "reflect"
+ "sync"
+ "unicode/utf8"
+
+ "golang.org/x/text/internal/format"
+ "golang.org/x/text/internal/number"
+ "golang.org/x/text/language"
+ "golang.org/x/text/message/catalog"
+)
+
+// Strings for use with buffer.WriteString.
+// This is less overhead than using buffer.Write with byte arrays.
+const (
+ commaSpaceString = ", "
+ nilAngleString = ""
+ nilParenString = "(nil)"
+ nilString = "nil"
+ mapString = "map["
+ percentBangString = "%!"
+ missingString = "(MISSING)"
+ badIndexString = "(BADINDEX)"
+ panicString = "(PANIC="
+ extraString = "%!(EXTRA "
+ badWidthString = "%!(BADWIDTH)"
+ badPrecString = "%!(BADPREC)"
+ noVerbString = "%!(NOVERB)"
+
+ invReflectString = ""
+)
+
+var printerPool = sync.Pool{
+ New: func() interface{} { return new(printer) },
+}
+
+// newPrinter allocates a new printer struct or grabs a cached one.
+func newPrinter(pp *Printer) *printer {
+ p := printerPool.Get().(*printer)
+ p.Printer = *pp
+ // TODO: cache most of the following call.
+ p.catContext = pp.cat.Context(pp.tag, p)
+
+ p.panicking = false
+ p.erroring = false
+ p.fmt.init(&p.Buffer)
+ return p
+}
+
+// free saves used printer structs in printerFree; avoids an allocation per invocation.
+func (p *printer) free() {
+ p.Buffer.Reset()
+ p.arg = nil
+ p.value = reflect.Value{}
+ printerPool.Put(p)
+}
+
+// printer is used to store a printer's state.
+// It implements "golang.org/x/text/internal/format".State.
+type printer struct {
+ Printer
+
+ // the context for looking up message translations
+ catContext *catalog.Context
+
+ // buffer for accumulating output.
+ bytes.Buffer
+
+ // arg holds the current item, as an interface{}.
+ arg interface{}
+ // value is used instead of arg for reflect values.
+ value reflect.Value
+
+ // fmt is used to format basic items such as integers or strings.
+ fmt formatInfo
+
+ // panicking is set by catchPanic to avoid infinite panic, recover, panic, ... recursion.
+ panicking bool
+ // erroring is set when printing an error string to guard against calling handleMethods.
+ erroring bool
+}
+
+// Language implements "golang.org/x/text/internal/format".State.
+func (p *printer) Language() language.Tag { return p.tag }
+
+func (p *printer) Width() (wid int, ok bool) { return p.fmt.Width, p.fmt.WidthPresent }
+
+func (p *printer) Precision() (prec int, ok bool) { return p.fmt.Prec, p.fmt.PrecPresent }
+
+func (p *printer) Flag(b int) bool {
+ switch b {
+ case '-':
+ return p.fmt.Minus
+ case '+':
+ return p.fmt.Plus || p.fmt.PlusV
+ case '#':
+ return p.fmt.Sharp || p.fmt.SharpV
+ case ' ':
+ return p.fmt.Space
+ case '0':
+ return p.fmt.Zero
+ }
+ return false
+}
+
+// getField gets the i'th field of the struct value.
+// If the field is itself is an interface, return a value for
+// the thing inside the interface, not the interface itself.
+func getField(v reflect.Value, i int) reflect.Value {
+ val := v.Field(i)
+ if val.Kind() == reflect.Interface && !val.IsNil() {
+ val = val.Elem()
+ }
+ return val
+}
+
+func (p *printer) unknownType(v reflect.Value) {
+ if !v.IsValid() {
+ p.WriteString(nilAngleString)
+ return
+ }
+ p.WriteByte('?')
+ p.WriteString(v.Type().String())
+ p.WriteByte('?')
+}
+
+func (p *printer) badVerb(verb rune) {
+ p.erroring = true
+ p.WriteString(percentBangString)
+ p.WriteRune(verb)
+ p.WriteByte('(')
+ switch {
+ case p.arg != nil:
+ p.WriteString(reflect.TypeOf(p.arg).String())
+ p.WriteByte('=')
+ p.printArg(p.arg, 'v')
+ case p.value.IsValid():
+ p.WriteString(p.value.Type().String())
+ p.WriteByte('=')
+ p.printValue(p.value, 'v', 0)
+ default:
+ p.WriteString(nilAngleString)
+ }
+ p.WriteByte(')')
+ p.erroring = false
+}
+
+func (p *printer) fmtBool(v bool, verb rune) {
+ switch verb {
+ case 't', 'v':
+ p.fmt.fmt_boolean(v)
+ default:
+ p.badVerb(verb)
+ }
+}
+
+// fmt0x64 formats a uint64 in hexadecimal and prefixes it with 0x or
+// not, as requested, by temporarily setting the sharp flag.
+func (p *printer) fmt0x64(v uint64, leading0x bool) {
+ sharp := p.fmt.Sharp
+ p.fmt.Sharp = leading0x
+ p.fmt.fmt_integer(v, 16, unsigned, ldigits)
+ p.fmt.Sharp = sharp
+}
+
+// fmtInteger formats a signed or unsigned integer.
+func (p *printer) fmtInteger(v uint64, isSigned bool, verb rune) {
+ switch verb {
+ case 'v':
+ if p.fmt.SharpV && !isSigned {
+ p.fmt0x64(v, true)
+ return
+ }
+ fallthrough
+ case 'd':
+ if p.fmt.Sharp || p.fmt.SharpV {
+ p.fmt.fmt_integer(v, 10, isSigned, ldigits)
+ } else {
+ p.fmtDecimalInt(v, isSigned)
+ }
+ case 'b':
+ p.fmt.fmt_integer(v, 2, isSigned, ldigits)
+ case 'o':
+ p.fmt.fmt_integer(v, 8, isSigned, ldigits)
+ case 'x':
+ p.fmt.fmt_integer(v, 16, isSigned, ldigits)
+ case 'X':
+ p.fmt.fmt_integer(v, 16, isSigned, udigits)
+ case 'c':
+ p.fmt.fmt_c(v)
+ case 'q':
+ if v <= utf8.MaxRune {
+ p.fmt.fmt_qc(v)
+ } else {
+ p.badVerb(verb)
+ }
+ case 'U':
+ p.fmt.fmt_unicode(v)
+ default:
+ p.badVerb(verb)
+ }
+}
+
+// fmtFloat formats a float. The default precision for each verb
+// is specified as last argument in the call to fmt_float.
+func (p *printer) fmtFloat(v float64, size int, verb rune) {
+ switch verb {
+ case 'b':
+ p.fmt.fmt_float(v, size, verb, -1)
+ case 'v':
+ verb = 'g'
+ fallthrough
+ case 'g', 'G':
+ if p.fmt.Sharp || p.fmt.SharpV {
+ p.fmt.fmt_float(v, size, verb, -1)
+ } else {
+ p.fmtVariableFloat(v, size)
+ }
+ case 'e', 'E':
+ if p.fmt.Sharp || p.fmt.SharpV {
+ p.fmt.fmt_float(v, size, verb, 6)
+ } else {
+ p.fmtScientific(v, size, 6)
+ }
+ case 'f', 'F':
+ if p.fmt.Sharp || p.fmt.SharpV {
+ p.fmt.fmt_float(v, size, verb, 6)
+ } else {
+ p.fmtDecimalFloat(v, size, 6)
+ }
+ default:
+ p.badVerb(verb)
+ }
+}
+
+func (p *printer) setFlags(f *number.Formatter) {
+ f.Flags &^= number.ElideSign
+ if p.fmt.Plus || p.fmt.Space {
+ f.Flags |= number.AlwaysSign
+ if !p.fmt.Plus {
+ f.Flags |= number.ElideSign
+ }
+ } else {
+ f.Flags &^= number.AlwaysSign
+ }
+}
+
+func (p *printer) updatePadding(f *number.Formatter) {
+ f.Flags &^= number.PadMask
+ if p.fmt.Minus {
+ f.Flags |= number.PadAfterSuffix
+ } else {
+ f.Flags |= number.PadBeforePrefix
+ }
+ f.PadRune = ' '
+ f.FormatWidth = uint16(p.fmt.Width)
+}
+
+func (p *printer) initDecimal(minFrac, maxFrac int) {
+ f := &p.toDecimal
+ f.MinIntegerDigits = 1
+ f.MaxIntegerDigits = 0
+ f.MinFractionDigits = uint8(minFrac)
+ f.MaxFractionDigits = int16(maxFrac)
+ p.setFlags(f)
+ f.PadRune = 0
+ if p.fmt.WidthPresent {
+ if p.fmt.Zero {
+ wid := p.fmt.Width
+ // Use significant integers for this.
+ // TODO: this is not the same as width, but so be it.
+ if f.MinFractionDigits > 0 {
+ wid -= 1 + int(f.MinFractionDigits)
+ }
+ if p.fmt.Plus || p.fmt.Space {
+ wid--
+ }
+ if wid > 0 && wid > int(f.MinIntegerDigits) {
+ f.MinIntegerDigits = uint8(wid)
+ }
+ }
+ p.updatePadding(f)
+ }
+}
+
+func (p *printer) initScientific(minFrac, maxFrac int) {
+ f := &p.toScientific
+ if maxFrac < 0 {
+ f.SetPrecision(maxFrac)
+ } else {
+ f.SetPrecision(maxFrac + 1)
+ f.MinFractionDigits = uint8(minFrac)
+ f.MaxFractionDigits = int16(maxFrac)
+ }
+ f.MinExponentDigits = 2
+ p.setFlags(f)
+ f.PadRune = 0
+ if p.fmt.WidthPresent {
+ f.Flags &^= number.PadMask
+ if p.fmt.Zero {
+ f.PadRune = f.Digit(0)
+ f.Flags |= number.PadAfterPrefix
+ } else {
+ f.PadRune = ' '
+ f.Flags |= number.PadBeforePrefix
+ }
+ p.updatePadding(f)
+ }
+}
+
+func (p *printer) fmtDecimalInt(v uint64, isSigned bool) {
+ var d number.Decimal
+
+ f := &p.toDecimal
+ if p.fmt.PrecPresent {
+ p.setFlags(f)
+ f.MinIntegerDigits = uint8(p.fmt.Prec)
+ f.MaxIntegerDigits = 0
+ f.MinFractionDigits = 0
+ f.MaxFractionDigits = 0
+ if p.fmt.WidthPresent {
+ p.updatePadding(f)
+ }
+ } else {
+ p.initDecimal(0, 0)
+ }
+ d.ConvertInt(p.toDecimal.RoundingContext, isSigned, v)
+
+ out := p.toDecimal.Format([]byte(nil), &d)
+ p.Buffer.Write(out)
+}
+
+func (p *printer) fmtDecimalFloat(v float64, size, prec int) {
+ var d number.Decimal
+ if p.fmt.PrecPresent {
+ prec = p.fmt.Prec
+ }
+ p.initDecimal(prec, prec)
+ d.ConvertFloat(p.toDecimal.RoundingContext, v, size)
+
+ out := p.toDecimal.Format([]byte(nil), &d)
+ p.Buffer.Write(out)
+}
+
+func (p *printer) fmtVariableFloat(v float64, size int) {
+ prec := -1
+ if p.fmt.PrecPresent {
+ prec = p.fmt.Prec
+ }
+ var d number.Decimal
+ p.initScientific(0, prec)
+ d.ConvertFloat(p.toScientific.RoundingContext, v, size)
+
+ // Copy logic of 'g' formatting from strconv. It is simplified a bit as
+ // we don't have to mind having prec > len(d.Digits).
+ shortest := prec < 0
+ ePrec := prec
+ if shortest {
+ prec = len(d.Digits)
+ ePrec = 6
+ } else if prec == 0 {
+ prec = 1
+ ePrec = 1
+ }
+ exp := int(d.Exp) - 1
+ if exp < -4 || exp >= ePrec {
+ p.initScientific(0, prec)
+
+ out := p.toScientific.Format([]byte(nil), &d)
+ p.Buffer.Write(out)
+ } else {
+ if prec > int(d.Exp) {
+ prec = len(d.Digits)
+ }
+ if prec -= int(d.Exp); prec < 0 {
+ prec = 0
+ }
+ p.initDecimal(0, prec)
+
+ out := p.toDecimal.Format([]byte(nil), &d)
+ p.Buffer.Write(out)
+ }
+}
+
+func (p *printer) fmtScientific(v float64, size, prec int) {
+ var d number.Decimal
+ if p.fmt.PrecPresent {
+ prec = p.fmt.Prec
+ }
+ p.initScientific(prec, prec)
+ rc := p.toScientific.RoundingContext
+ d.ConvertFloat(rc, v, size)
+
+ out := p.toScientific.Format([]byte(nil), &d)
+ p.Buffer.Write(out)
+
+}
+
+// fmtComplex formats a complex number v with
+// r = real(v) and j = imag(v) as (r+ji) using
+// fmtFloat for r and j formatting.
+func (p *printer) fmtComplex(v complex128, size int, verb rune) {
+ // Make sure any unsupported verbs are found before the
+ // calls to fmtFloat to not generate an incorrect error string.
+ switch verb {
+ case 'v', 'b', 'g', 'G', 'f', 'F', 'e', 'E':
+ p.WriteByte('(')
+ p.fmtFloat(real(v), size/2, verb)
+ // Imaginary part always has a sign.
+ if math.IsNaN(imag(v)) {
+ // By CLDR's rules, NaNs do not use patterns or signs. As this code
+ // relies on AlwaysSign working for imaginary parts, we need to
+ // manually handle NaNs.
+ f := &p.toScientific
+ p.setFlags(f)
+ p.updatePadding(f)
+ p.setFlags(f)
+ nan := f.Symbol(number.SymNan)
+ extra := 0
+ if w, ok := p.Width(); ok {
+ extra = w - utf8.RuneCountInString(nan) - 1
+ }
+ if f.Flags&number.PadAfterNumber == 0 {
+ for ; extra > 0; extra-- {
+ p.WriteRune(f.PadRune)
+ }
+ }
+ p.WriteString(f.Symbol(number.SymPlusSign))
+ p.WriteString(nan)
+ for ; extra > 0; extra-- {
+ p.WriteRune(f.PadRune)
+ }
+ p.WriteString("i)")
+ return
+ }
+ oldPlus := p.fmt.Plus
+ p.fmt.Plus = true
+ p.fmtFloat(imag(v), size/2, verb)
+ p.WriteString("i)") // TODO: use symbol?
+ p.fmt.Plus = oldPlus
+ default:
+ p.badVerb(verb)
+ }
+}
+
+func (p *printer) fmtString(v string, verb rune) {
+ switch verb {
+ case 'v':
+ if p.fmt.SharpV {
+ p.fmt.fmt_q(v)
+ } else {
+ p.fmt.fmt_s(v)
+ }
+ case 's':
+ p.fmt.fmt_s(v)
+ case 'x':
+ p.fmt.fmt_sx(v, ldigits)
+ case 'X':
+ p.fmt.fmt_sx(v, udigits)
+ case 'q':
+ p.fmt.fmt_q(v)
+ case 'm':
+ ctx := p.cat.Context(p.tag, rawPrinter{p})
+ if ctx.Execute(v) == catalog.ErrNotFound {
+ p.WriteString(v)
+ }
+ default:
+ p.badVerb(verb)
+ }
+}
+
+func (p *printer) fmtBytes(v []byte, verb rune, typeString string) {
+ switch verb {
+ case 'v', 'd':
+ if p.fmt.SharpV {
+ p.WriteString(typeString)
+ if v == nil {
+ p.WriteString(nilParenString)
+ return
+ }
+ p.WriteByte('{')
+ for i, c := range v {
+ if i > 0 {
+ p.WriteString(commaSpaceString)
+ }
+ p.fmt0x64(uint64(c), true)
+ }
+ p.WriteByte('}')
+ } else {
+ p.WriteByte('[')
+ for i, c := range v {
+ if i > 0 {
+ p.WriteByte(' ')
+ }
+ p.fmt.fmt_integer(uint64(c), 10, unsigned, ldigits)
+ }
+ p.WriteByte(']')
+ }
+ case 's':
+ p.fmt.fmt_s(string(v))
+ case 'x':
+ p.fmt.fmt_bx(v, ldigits)
+ case 'X':
+ p.fmt.fmt_bx(v, udigits)
+ case 'q':
+ p.fmt.fmt_q(string(v))
+ default:
+ p.printValue(reflect.ValueOf(v), verb, 0)
+ }
+}
+
+func (p *printer) fmtPointer(value reflect.Value, verb rune) {
+ var u uintptr
+ switch value.Kind() {
+ case reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr, reflect.Slice, reflect.UnsafePointer:
+ u = value.Pointer()
+ default:
+ p.badVerb(verb)
+ return
+ }
+
+ switch verb {
+ case 'v':
+ if p.fmt.SharpV {
+ p.WriteByte('(')
+ p.WriteString(value.Type().String())
+ p.WriteString(")(")
+ if u == 0 {
+ p.WriteString(nilString)
+ } else {
+ p.fmt0x64(uint64(u), true)
+ }
+ p.WriteByte(')')
+ } else {
+ if u == 0 {
+ p.fmt.padString(nilAngleString)
+ } else {
+ p.fmt0x64(uint64(u), !p.fmt.Sharp)
+ }
+ }
+ case 'p':
+ p.fmt0x64(uint64(u), !p.fmt.Sharp)
+ case 'b', 'o', 'd', 'x', 'X':
+ if verb == 'd' {
+ p.fmt.Sharp = true // Print as standard go. TODO: does this make sense?
+ }
+ p.fmtInteger(uint64(u), unsigned, verb)
+ default:
+ p.badVerb(verb)
+ }
+}
+
+func (p *printer) catchPanic(arg interface{}, verb rune) {
+ if err := recover(); err != nil {
+ // If it's a nil pointer, just say "". The likeliest causes are a
+ // Stringer that fails to guard against nil or a nil pointer for a
+ // value receiver, and in either case, "" is a nice result.
+ if v := reflect.ValueOf(arg); v.Kind() == reflect.Ptr && v.IsNil() {
+ p.WriteString(nilAngleString)
+ return
+ }
+ // Otherwise print a concise panic message. Most of the time the panic
+ // value will print itself nicely.
+ if p.panicking {
+ // Nested panics; the recursion in printArg cannot succeed.
+ panic(err)
+ }
+
+ oldFlags := p.fmt.Parser
+ // For this output we want default behavior.
+ p.fmt.ClearFlags()
+
+ p.WriteString(percentBangString)
+ p.WriteRune(verb)
+ p.WriteString(panicString)
+ p.panicking = true
+ p.printArg(err, 'v')
+ p.panicking = false
+ p.WriteByte(')')
+
+ p.fmt.Parser = oldFlags
+ }
+}
+
+func (p *printer) handleMethods(verb rune) (handled bool) {
+ if p.erroring {
+ return
+ }
+ // Is it a Formatter?
+ if formatter, ok := p.arg.(format.Formatter); ok {
+ handled = true
+ defer p.catchPanic(p.arg, verb)
+ formatter.Format(p, verb)
+ return
+ }
+ if formatter, ok := p.arg.(fmt.Formatter); ok {
+ handled = true
+ defer p.catchPanic(p.arg, verb)
+ formatter.Format(p, verb)
+ return
+ }
+
+ // If we're doing Go syntax and the argument knows how to supply it, take care of it now.
+ if p.fmt.SharpV {
+ if stringer, ok := p.arg.(fmt.GoStringer); ok {
+ handled = true
+ defer p.catchPanic(p.arg, verb)
+ // Print the result of GoString unadorned.
+ p.fmt.fmt_s(stringer.GoString())
+ return
+ }
+ } else {
+ // If a string is acceptable according to the format, see if
+ // the value satisfies one of the string-valued interfaces.
+ // Println etc. set verb to %v, which is "stringable".
+ switch verb {
+ case 'v', 's', 'x', 'X', 'q':
+ // Is it an error or Stringer?
+ // The duplication in the bodies is necessary:
+ // setting handled and deferring catchPanic
+ // must happen before calling the method.
+ switch v := p.arg.(type) {
+ case error:
+ handled = true
+ defer p.catchPanic(p.arg, verb)
+ p.fmtString(v.Error(), verb)
+ return
+
+ case fmt.Stringer:
+ handled = true
+ defer p.catchPanic(p.arg, verb)
+ p.fmtString(v.String(), verb)
+ return
+ }
+ }
+ }
+ return false
+}
+
+func (p *printer) printArg(arg interface{}, verb rune) {
+ p.arg = arg
+ p.value = reflect.Value{}
+
+ if arg == nil {
+ switch verb {
+ case 'T', 'v':
+ p.fmt.padString(nilAngleString)
+ default:
+ p.badVerb(verb)
+ }
+ return
+ }
+
+ // Special processing considerations.
+ // %T (the value's type) and %p (its address) are special; we always do them first.
+ switch verb {
+ case 'T':
+ p.fmt.fmt_s(reflect.TypeOf(arg).String())
+ return
+ case 'p':
+ p.fmtPointer(reflect.ValueOf(arg), 'p')
+ return
+ }
+
+ // Some types can be done without reflection.
+ switch f := arg.(type) {
+ case bool:
+ p.fmtBool(f, verb)
+ case float32:
+ p.fmtFloat(float64(f), 32, verb)
+ case float64:
+ p.fmtFloat(f, 64, verb)
+ case complex64:
+ p.fmtComplex(complex128(f), 64, verb)
+ case complex128:
+ p.fmtComplex(f, 128, verb)
+ case int:
+ p.fmtInteger(uint64(f), signed, verb)
+ case int8:
+ p.fmtInteger(uint64(f), signed, verb)
+ case int16:
+ p.fmtInteger(uint64(f), signed, verb)
+ case int32:
+ p.fmtInteger(uint64(f), signed, verb)
+ case int64:
+ p.fmtInteger(uint64(f), signed, verb)
+ case uint:
+ p.fmtInteger(uint64(f), unsigned, verb)
+ case uint8:
+ p.fmtInteger(uint64(f), unsigned, verb)
+ case uint16:
+ p.fmtInteger(uint64(f), unsigned, verb)
+ case uint32:
+ p.fmtInteger(uint64(f), unsigned, verb)
+ case uint64:
+ p.fmtInteger(f, unsigned, verb)
+ case uintptr:
+ p.fmtInteger(uint64(f), unsigned, verb)
+ case string:
+ p.fmtString(f, verb)
+ case []byte:
+ p.fmtBytes(f, verb, "[]byte")
+ case reflect.Value:
+ // Handle extractable values with special methods
+ // since printValue does not handle them at depth 0.
+ if f.IsValid() && f.CanInterface() {
+ p.arg = f.Interface()
+ if p.handleMethods(verb) {
+ return
+ }
+ }
+ p.printValue(f, verb, 0)
+ default:
+ // If the type is not simple, it might have methods.
+ if !p.handleMethods(verb) {
+ // Need to use reflection, since the type had no
+ // interface methods that could be used for formatting.
+ p.printValue(reflect.ValueOf(f), verb, 0)
+ }
+ }
+}
+
+// printValue is similar to printArg but starts with a reflect value, not an interface{} value.
+// It does not handle 'p' and 'T' verbs because these should have been already handled by printArg.
+func (p *printer) printValue(value reflect.Value, verb rune, depth int) {
+ // Handle values with special methods if not already handled by printArg (depth == 0).
+ if depth > 0 && value.IsValid() && value.CanInterface() {
+ p.arg = value.Interface()
+ if p.handleMethods(verb) {
+ return
+ }
+ }
+ p.arg = nil
+ p.value = value
+
+ switch f := value; value.Kind() {
+ case reflect.Invalid:
+ if depth == 0 {
+ p.WriteString(invReflectString)
+ } else {
+ switch verb {
+ case 'v':
+ p.WriteString(nilAngleString)
+ default:
+ p.badVerb(verb)
+ }
+ }
+ case reflect.Bool:
+ p.fmtBool(f.Bool(), verb)
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ p.fmtInteger(uint64(f.Int()), signed, verb)
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+ p.fmtInteger(f.Uint(), unsigned, verb)
+ case reflect.Float32:
+ p.fmtFloat(f.Float(), 32, verb)
+ case reflect.Float64:
+ p.fmtFloat(f.Float(), 64, verb)
+ case reflect.Complex64:
+ p.fmtComplex(f.Complex(), 64, verb)
+ case reflect.Complex128:
+ p.fmtComplex(f.Complex(), 128, verb)
+ case reflect.String:
+ p.fmtString(f.String(), verb)
+ case reflect.Map:
+ if p.fmt.SharpV {
+ p.WriteString(f.Type().String())
+ if f.IsNil() {
+ p.WriteString(nilParenString)
+ return
+ }
+ p.WriteByte('{')
+ } else {
+ p.WriteString(mapString)
+ }
+ keys := f.MapKeys()
+ for i, key := range keys {
+ if i > 0 {
+ if p.fmt.SharpV {
+ p.WriteString(commaSpaceString)
+ } else {
+ p.WriteByte(' ')
+ }
+ }
+ p.printValue(key, verb, depth+1)
+ p.WriteByte(':')
+ p.printValue(f.MapIndex(key), verb, depth+1)
+ }
+ if p.fmt.SharpV {
+ p.WriteByte('}')
+ } else {
+ p.WriteByte(']')
+ }
+ case reflect.Struct:
+ if p.fmt.SharpV {
+ p.WriteString(f.Type().String())
+ }
+ p.WriteByte('{')
+ for i := 0; i < f.NumField(); i++ {
+ if i > 0 {
+ if p.fmt.SharpV {
+ p.WriteString(commaSpaceString)
+ } else {
+ p.WriteByte(' ')
+ }
+ }
+ if p.fmt.PlusV || p.fmt.SharpV {
+ if name := f.Type().Field(i).Name; name != "" {
+ p.WriteString(name)
+ p.WriteByte(':')
+ }
+ }
+ p.printValue(getField(f, i), verb, depth+1)
+ }
+ p.WriteByte('}')
+ case reflect.Interface:
+ value := f.Elem()
+ if !value.IsValid() {
+ if p.fmt.SharpV {
+ p.WriteString(f.Type().String())
+ p.WriteString(nilParenString)
+ } else {
+ p.WriteString(nilAngleString)
+ }
+ } else {
+ p.printValue(value, verb, depth+1)
+ }
+ case reflect.Array, reflect.Slice:
+ switch verb {
+ case 's', 'q', 'x', 'X':
+ // Handle byte and uint8 slices and arrays special for the above verbs.
+ t := f.Type()
+ if t.Elem().Kind() == reflect.Uint8 {
+ var bytes []byte
+ if f.Kind() == reflect.Slice {
+ bytes = f.Bytes()
+ } else if f.CanAddr() {
+ bytes = f.Slice(0, f.Len()).Bytes()
+ } else {
+ // We have an array, but we cannot Slice() a non-addressable array,
+ // so we build a slice by hand. This is a rare case but it would be nice
+ // if reflection could help a little more.
+ bytes = make([]byte, f.Len())
+ for i := range bytes {
+ bytes[i] = byte(f.Index(i).Uint())
+ }
+ }
+ p.fmtBytes(bytes, verb, t.String())
+ return
+ }
+ }
+ if p.fmt.SharpV {
+ p.WriteString(f.Type().String())
+ if f.Kind() == reflect.Slice && f.IsNil() {
+ p.WriteString(nilParenString)
+ return
+ }
+ p.WriteByte('{')
+ for i := 0; i < f.Len(); i++ {
+ if i > 0 {
+ p.WriteString(commaSpaceString)
+ }
+ p.printValue(f.Index(i), verb, depth+1)
+ }
+ p.WriteByte('}')
+ } else {
+ p.WriteByte('[')
+ for i := 0; i < f.Len(); i++ {
+ if i > 0 {
+ p.WriteByte(' ')
+ }
+ p.printValue(f.Index(i), verb, depth+1)
+ }
+ p.WriteByte(']')
+ }
+ case reflect.Ptr:
+ // pointer to array or slice or struct? ok at top level
+ // but not embedded (avoid loops)
+ if depth == 0 && f.Pointer() != 0 {
+ switch a := f.Elem(); a.Kind() {
+ case reflect.Array, reflect.Slice, reflect.Struct, reflect.Map:
+ p.WriteByte('&')
+ p.printValue(a, verb, depth+1)
+ return
+ }
+ }
+ fallthrough
+ case reflect.Chan, reflect.Func, reflect.UnsafePointer:
+ p.fmtPointer(f, verb)
+ default:
+ p.unknownType(f)
+ }
+}
+
+func (p *printer) badArgNum(verb rune) {
+ p.WriteString(percentBangString)
+ p.WriteRune(verb)
+ p.WriteString(badIndexString)
+}
+
+func (p *printer) missingArg(verb rune) {
+ p.WriteString(percentBangString)
+ p.WriteRune(verb)
+ p.WriteString(missingString)
+}
+
+func (p *printer) doPrintf(fmt string) {
+ for p.fmt.Parser.SetFormat(fmt); p.fmt.Scan(); {
+ switch p.fmt.Status {
+ case format.StatusText:
+ p.WriteString(p.fmt.Text())
+ case format.StatusSubstitution:
+ p.printArg(p.Arg(p.fmt.ArgNum), p.fmt.Verb)
+ case format.StatusBadWidthSubstitution:
+ p.WriteString(badWidthString)
+ p.printArg(p.Arg(p.fmt.ArgNum), p.fmt.Verb)
+ case format.StatusBadPrecSubstitution:
+ p.WriteString(badPrecString)
+ p.printArg(p.Arg(p.fmt.ArgNum), p.fmt.Verb)
+ case format.StatusNoVerb:
+ p.WriteString(noVerbString)
+ case format.StatusBadArgNum:
+ p.badArgNum(p.fmt.Verb)
+ case format.StatusMissingArg:
+ p.missingArg(p.fmt.Verb)
+ default:
+ panic("unreachable")
+ }
+ }
+
+ // Check for extra arguments, but only if there was at least one ordered
+ // argument. Note that this behavior is necessarily different from fmt:
+ // different variants of messages may opt to drop some or all of the
+ // arguments.
+ if !p.fmt.Reordered && p.fmt.ArgNum < len(p.fmt.Args) && p.fmt.ArgNum != 0 {
+ p.fmt.ClearFlags()
+ p.WriteString(extraString)
+ for i, arg := range p.fmt.Args[p.fmt.ArgNum:] {
+ if i > 0 {
+ p.WriteString(commaSpaceString)
+ }
+ if arg == nil {
+ p.WriteString(nilAngleString)
+ } else {
+ p.WriteString(reflect.TypeOf(arg).String())
+ p.WriteString("=")
+ p.printArg(arg, 'v')
+ }
+ }
+ p.WriteByte(')')
+ }
+}
+
+func (p *printer) doPrint(a []interface{}) {
+ prevString := false
+ for argNum, arg := range a {
+ isString := arg != nil && reflect.TypeOf(arg).Kind() == reflect.String
+ // Add a space between two non-string arguments.
+ if argNum > 0 && !isString && !prevString {
+ p.WriteByte(' ')
+ }
+ p.printArg(arg, 'v')
+ prevString = isString
+ }
+}
+
+// doPrintln is like doPrint but always adds a space between arguments
+// and a newline after the last argument.
+func (p *printer) doPrintln(a []interface{}) {
+ for argNum, arg := range a {
+ if argNum > 0 {
+ p.WriteByte(' ')
+ }
+ p.printArg(arg, 'v')
+ }
+ p.WriteByte('\n')
+}
diff --git a/vendor/golang.org/x/text/number/doc.go b/vendor/golang.org/x/text/number/doc.go
new file mode 100644
index 0000000..8766230
--- /dev/null
+++ b/vendor/golang.org/x/text/number/doc.go
@@ -0,0 +1,27 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package number formats numbers according to the customs of different locales.
+//
+// The number formats of this package allow for greater formatting flexibility
+// than passing values to message.Printf calls as is. It currently supports the
+// builtin Go types and anything that implements the Convert interface
+// (currently internal).
+//
+// p := message.NewPrinter(language.English)
+//
+// p.Printf("%v bottles of beer on the wall.", number.Decimal(1234))
+// // Prints: 1,234 bottles of beer on the wall.
+//
+// p.Printf("%v of gophers lose too much fur", number.Percent(0.12))
+// // Prints: 12% of gophers lose too much fur.
+//
+// p := message.NewPrinter(language.Dutch)
+//
+// p.Printf("There are %v bikes per household.", number.Decimal(1.2))
+// // Prints: Er zijn 1,2 fietsen per huishouden.
+//
+// The width and scale specified in the formatting directives override the
+// configuration of the formatter.
+package number
diff --git a/vendor/golang.org/x/text/number/format.go b/vendor/golang.org/x/text/number/format.go
new file mode 100644
index 0000000..f2bdfdc
--- /dev/null
+++ b/vendor/golang.org/x/text/number/format.go
@@ -0,0 +1,122 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package number
+
+import (
+ "fmt"
+ "strings"
+
+ "golang.org/x/text/feature/plural"
+ "golang.org/x/text/internal/format"
+ "golang.org/x/text/internal/number"
+ "golang.org/x/text/language"
+)
+
+// A FormatFunc formats a number.
+type FormatFunc func(x interface{}, opts ...Option) Formatter
+
+// NewFormat creates a FormatFunc based on another FormatFunc and new options.
+// Use NewFormat to cash the creation of formatters.
+func NewFormat(format FormatFunc, opts ...Option) FormatFunc {
+ o := *format(nil).options
+ n := len(o.options)
+ o.options = append(o.options[:n:n], opts...)
+ return func(x interface{}, opts ...Option) Formatter {
+ return newFormatter(&o, opts, x)
+ }
+}
+
+type options struct {
+ verbs string
+ initFunc initFunc
+ options []Option
+ pluralFunc func(t language.Tag, scale int) (f plural.Form, n int)
+}
+
+type optionFlag uint16
+
+const (
+ hasScale optionFlag = 1 << iota
+ hasPrecision
+ noSeparator
+ exact
+)
+
+type initFunc func(f *number.Formatter, t language.Tag)
+
+func newFormatter(o *options, opts []Option, value interface{}) Formatter {
+ if len(opts) > 0 {
+ n := *o
+ n.options = opts
+ o = &n
+ }
+ return Formatter{o, value}
+}
+
+func newOptions(verbs string, f initFunc) *options {
+ return &options{verbs: verbs, initFunc: f}
+}
+
+type Formatter struct {
+ *options
+ value interface{}
+}
+
+// Format implements format.Formatter. It is for internal use only for now.
+func (f Formatter) Format(state format.State, verb rune) {
+ // TODO: consider implementing fmt.Formatter instead and using the following
+ // piece of code. This allows numbers to be rendered mostly as expected
+ // when using fmt. But it may get weird with the spellout options and we
+ // may need more of format.State over time.
+ // lang := language.Und
+ // if s, ok := state.(format.State); ok {
+ // lang = s.Language()
+ // }
+
+ lang := state.Language()
+ if !strings.Contains(f.verbs, string(verb)) {
+ fmt.Fprintf(state, "%%!%s(%T=%v)", string(verb), f.value, f.value)
+ return
+ }
+ var p number.Formatter
+ f.initFunc(&p, lang)
+ for _, o := range f.options.options {
+ o(lang, &p)
+ }
+ if w, ok := state.Width(); ok {
+ p.FormatWidth = uint16(w)
+ }
+ if prec, ok := state.Precision(); ok {
+ switch verb {
+ case 'd':
+ p.SetScale(0)
+ case 'f':
+ p.SetScale(prec)
+ case 'e':
+ p.SetPrecision(prec + 1)
+ case 'g':
+ p.SetPrecision(prec)
+ }
+ }
+ var d number.Decimal
+ d.Convert(p.RoundingContext, f.value)
+ state.Write(p.Format(nil, &d))
+}
+
+// Digits returns information about which logical digits will be presented to
+// the user. This information is relevant, for instance, to determine plural
+// forms.
+func (f Formatter) Digits(buf []byte, tag language.Tag, scale int) number.Digits {
+ var p number.Formatter
+ f.initFunc(&p, tag)
+ if scale >= 0 {
+ // TODO: this only works well for decimal numbers, which is generally
+ // fine.
+ p.SetScale(scale)
+ }
+ var d number.Decimal
+ d.Convert(p.RoundingContext, f.value)
+ return number.FormatDigits(&d, p.RoundingContext)
+}
diff --git a/vendor/golang.org/x/text/number/number.go b/vendor/golang.org/x/text/number/number.go
new file mode 100644
index 0000000..f5ca93b
--- /dev/null
+++ b/vendor/golang.org/x/text/number/number.go
@@ -0,0 +1,77 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package number
+
+// TODO:
+// p.Printf("The gauge was at %v.", number.Spell(number.Percent(23)))
+// // Prints: The gauge was at twenty-three percent.
+//
+// p.Printf("From here to %v!", number.Spell(math.Inf()))
+// // Prints: From here to infinity!
+//
+
+import (
+ "golang.org/x/text/internal/number"
+)
+
+const (
+ decimalVerbs = "vfgd"
+ scientificVerbs = "veg"
+)
+
+// Decimal formats a number as a floating point decimal.
+func Decimal(x interface{}, opts ...Option) Formatter {
+ return newFormatter(decimalOptions, opts, x)
+}
+
+var decimalOptions = newOptions(decimalVerbs, (*number.Formatter).InitDecimal)
+
+// Scientific formats a number in scientific format.
+func Scientific(x interface{}, opts ...Option) Formatter {
+ return newFormatter(scientificOptions, opts, x)
+}
+
+var scientificOptions = newOptions(scientificVerbs, (*number.Formatter).InitScientific)
+
+// Engineering formats a number using engineering notation, which is like
+// scientific notation, but with the exponent normalized to multiples of 3.
+func Engineering(x interface{}, opts ...Option) Formatter {
+ return newFormatter(engineeringOptions, opts, x)
+}
+
+var engineeringOptions = newOptions(scientificVerbs, (*number.Formatter).InitEngineering)
+
+// Percent formats a number as a percentage. A value of 1.0 means 100%.
+func Percent(x interface{}, opts ...Option) Formatter {
+ return newFormatter(percentOptions, opts, x)
+}
+
+var percentOptions = newOptions(decimalVerbs, (*number.Formatter).InitPercent)
+
+// PerMille formats a number as a per mille indication. A value of 1.0 means
+// 1000‰.
+func PerMille(x interface{}, opts ...Option) Formatter {
+ return newFormatter(perMilleOptions, opts, x)
+}
+
+var perMilleOptions = newOptions(decimalVerbs, (*number.Formatter).InitPerMille)
+
+// TODO:
+// - Shortest: akin to verb 'g' of 'G'
+//
+// TODO: RBNF forms:
+// - Compact: 1M 3.5T
+// - CompactBinary: 1Mi 3.5Ti
+// - Long: 1 million
+// - Ordinal:
+// - Roman: MCMIIXX
+// - RomanSmall: mcmiixx
+// - Text: numbers as it typically appears in running text, allowing
+// language-specific choices for when to use numbers and when to use words.
+// - Spell?: spelled-out number. Maybe just allow as an option?
+
+// NOTE: both spelled-out numbers and ordinals, to render correctly, need
+// detailed linguistic information from the translated string into which they
+// are substituted. We will need to implement that first.
diff --git a/vendor/golang.org/x/text/number/option.go b/vendor/golang.org/x/text/number/option.go
new file mode 100644
index 0000000..de96f8e
--- /dev/null
+++ b/vendor/golang.org/x/text/number/option.go
@@ -0,0 +1,177 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package number
+
+import (
+ "fmt"
+
+ "golang.org/x/text/internal/number"
+ "golang.org/x/text/language"
+)
+
+// An Option configures a Formatter.
+type Option option
+
+type option func(tag language.Tag, f *number.Formatter)
+
+// TODO: SpellOut requires support of the ICU RBNF format.
+// func SpellOut() Option
+
+// NoSeparator causes a number to be displayed without grouping separators.
+func NoSeparator() Option {
+ return func(t language.Tag, f *number.Formatter) {
+ f.GroupingSize = [2]uint8{}
+ }
+}
+
+// MaxIntegerDigits limits the number of integer digits, eliminating the
+// most significant digits.
+func MaxIntegerDigits(max int) Option {
+ return func(t language.Tag, f *number.Formatter) {
+ if max >= 1<<8 {
+ max = (1 << 8) - 1
+ }
+ f.MaxIntegerDigits = uint8(max)
+ }
+}
+
+// MinIntegerDigits specifies the minimum number of integer digits, adding
+// leading zeros when needed.
+func MinIntegerDigits(min int) Option {
+ return func(t language.Tag, f *number.Formatter) {
+ if min >= 1<<8 {
+ min = (1 << 8) - 1
+ }
+ f.MinIntegerDigits = uint8(min)
+ }
+}
+
+// MaxFractionDigits specifies the maximum number of fractional digits.
+func MaxFractionDigits(max int) Option {
+ return func(t language.Tag, f *number.Formatter) {
+ if max >= 1<<15 {
+ max = (1 << 15) - 1
+ }
+ f.MaxFractionDigits = int16(max)
+ }
+}
+
+// MinFractionDigits specifies the minimum number of fractional digits.
+func MinFractionDigits(min int) Option {
+ return func(t language.Tag, f *number.Formatter) {
+ if min >= 1<<8 {
+ min = (1 << 8) - 1
+ }
+ f.MinFractionDigits = uint8(min)
+ }
+}
+
+// Precision sets the maximum number of significant digits. A negative value
+// means exact.
+func Precision(prec int) Option {
+ return func(t language.Tag, f *number.Formatter) {
+ f.SetPrecision(prec)
+ }
+}
+
+// Scale simultaneously sets MinFractionDigits and MaxFractionDigits to the
+// given value.
+func Scale(decimals int) Option {
+ return func(t language.Tag, f *number.Formatter) {
+ f.SetScale(decimals)
+ }
+}
+
+// IncrementString sets the incremental value to which numbers should be
+// rounded. For instance: Increment("0.05") will cause 1.44 to round to 1.45.
+// IncrementString also sets scale to the scale of the increment.
+func IncrementString(decimal string) Option {
+ increment := 0
+ scale := 0
+ d := decimal
+ p := 0
+ for ; p < len(d) && '0' <= d[p] && d[p] <= '9'; p++ {
+ increment *= 10
+ increment += int(d[p]) - '0'
+ }
+ if p < len(d) && d[p] == '.' {
+ for p++; p < len(d) && '0' <= d[p] && d[p] <= '9'; p++ {
+ increment *= 10
+ increment += int(d[p]) - '0'
+ scale++
+ }
+ }
+ if p < len(d) {
+ increment = 0
+ scale = 0
+ }
+ return func(t language.Tag, f *number.Formatter) {
+ f.Increment = uint32(increment)
+ f.IncrementScale = uint8(scale)
+ f.SetScale(scale)
+ }
+}
+
+func noop(language.Tag, *number.Formatter) {}
+
+// PatternOverrides allows users to specify alternative patterns for specific
+// languages. The Pattern will be overridden for all languages in a subgroup as
+// well. The function will panic for invalid input. It is best to create this
+// option at startup time.
+// PatternOverrides must be the first Option passed to a formatter.
+func PatternOverrides(patterns map[string]string) Option {
+ // TODO: make it so that it does not have to be the first option.
+ // TODO: use -x-nochild to indicate it does not override child tags.
+ m := map[language.Tag]*number.Pattern{}
+ for k, v := range patterns {
+ tag := language.MustParse(k)
+ p, err := number.ParsePattern(v)
+ if err != nil {
+ panic(fmt.Errorf("number: PatternOverrides: %v", err))
+ }
+ m[tag] = p
+ }
+ return func(t language.Tag, f *number.Formatter) {
+ // TODO: Use language grouping relation instead of parent relation.
+ // TODO: Should parent implement the grouping relation?
+ for lang := t; ; lang = t.Parent() {
+ if p, ok := m[lang]; ok {
+ f.Pattern = *p
+ break
+ }
+ if lang == language.Und {
+ break
+ }
+ }
+ }
+}
+
+// FormatWidth sets the total format width.
+func FormatWidth(n int) Option {
+ if n <= 0 {
+ return noop
+ }
+ return func(t language.Tag, f *number.Formatter) {
+ f.FormatWidth = uint16(n)
+ if f.PadRune == 0 {
+ f.PadRune = ' '
+ }
+ }
+}
+
+// Pad sets the rune to be used for filling up to the format width.
+func Pad(r rune) Option {
+ return func(t language.Tag, f *number.Formatter) {
+ f.PadRune = r
+ }
+}
+
+// TODO:
+// - FormatPosition (using type aliasing?)
+// - Multiplier: find a better way to represent and figure out what to do
+// with clashes with percent/permille.
+// - NumberingSystem(nu string): not accessable in number.Info now. Also, should
+// this be keyed by language or generic?
+// - SymbolOverrides(symbols map[string]map[number.SymbolType]string) Option
diff --git a/vendor/gopkg.in/cenkalti/backoff.v1/.gitignore b/vendor/gopkg.in/cenkalti/backoff.v1/.gitignore
new file mode 100644
index 0000000..0026861
--- /dev/null
+++ b/vendor/gopkg.in/cenkalti/backoff.v1/.gitignore
@@ -0,0 +1,22 @@
+# Compiled Object files, Static and Dynamic libs (Shared Objects)
+*.o
+*.a
+*.so
+
+# Folders
+_obj
+_test
+
+# Architecture specific extensions/prefixes
+*.[568vq]
+[568vq].out
+
+*.cgo1.go
+*.cgo2.c
+_cgo_defun.c
+_cgo_gotypes.go
+_cgo_export.*
+
+_testmain.go
+
+*.exe
diff --git a/vendor/gopkg.in/cenkalti/backoff.v1/.travis.yml b/vendor/gopkg.in/cenkalti/backoff.v1/.travis.yml
new file mode 100644
index 0000000..1040404
--- /dev/null
+++ b/vendor/gopkg.in/cenkalti/backoff.v1/.travis.yml
@@ -0,0 +1,9 @@
+language: go
+go:
+ - 1.3.3
+ - tip
+before_install:
+ - go get github.com/mattn/goveralls
+ - go get golang.org/x/tools/cmd/cover
+script:
+ - $HOME/gopath/bin/goveralls -service=travis-ci
diff --git a/vendor/gopkg.in/cenkalti/backoff.v1/LICENSE b/vendor/gopkg.in/cenkalti/backoff.v1/LICENSE
new file mode 100644
index 0000000..89b8179
--- /dev/null
+++ b/vendor/gopkg.in/cenkalti/backoff.v1/LICENSE
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) 2014 Cenk Altı
+
+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/vendor/gopkg.in/cenkalti/backoff.v1/README.md b/vendor/gopkg.in/cenkalti/backoff.v1/README.md
new file mode 100644
index 0000000..13b347f
--- /dev/null
+++ b/vendor/gopkg.in/cenkalti/backoff.v1/README.md
@@ -0,0 +1,30 @@
+# Exponential Backoff [![GoDoc][godoc image]][godoc] [![Build Status][travis image]][travis] [![Coverage Status][coveralls image]][coveralls]
+
+This is a Go port of the exponential backoff algorithm from [Google's HTTP Client Library for Java][google-http-java-client].
+
+[Exponential backoff][exponential backoff wiki]
+is an algorithm that uses feedback to multiplicatively decrease the rate of some process,
+in order to gradually find an acceptable rate.
+The retries exponentially increase and stop increasing when a certain threshold is met.
+
+## Usage
+
+See https://godoc.org/github.com/cenkalti/backoff#pkg-examples
+
+## Contributing
+
+* I would like to keep this library as small as possible.
+* Please don't send a PR without opening an issue and discussing it first.
+* If proposed change is not a common use case, I will probably not accept it.
+
+[godoc]: https://godoc.org/github.com/cenkalti/backoff
+[godoc image]: https://godoc.org/github.com/cenkalti/backoff?status.png
+[travis]: https://travis-ci.org/cenkalti/backoff
+[travis image]: https://travis-ci.org/cenkalti/backoff.png?branch=master
+[coveralls]: https://coveralls.io/github/cenkalti/backoff?branch=master
+[coveralls image]: https://coveralls.io/repos/github/cenkalti/backoff/badge.svg?branch=master
+
+[google-http-java-client]: https://github.com/google/google-http-java-client
+[exponential backoff wiki]: http://en.wikipedia.org/wiki/Exponential_backoff
+
+[advanced example]: https://godoc.org/github.com/cenkalti/backoff#example_
diff --git a/vendor/gopkg.in/cenkalti/backoff.v1/backoff.go b/vendor/gopkg.in/cenkalti/backoff.v1/backoff.go
new file mode 100644
index 0000000..2102c5f
--- /dev/null
+++ b/vendor/gopkg.in/cenkalti/backoff.v1/backoff.go
@@ -0,0 +1,66 @@
+// Package backoff implements backoff algorithms for retrying operations.
+//
+// Use Retry function for retrying operations that may fail.
+// If Retry does not meet your needs,
+// copy/paste the function into your project and modify as you wish.
+//
+// There is also Ticker type similar to time.Ticker.
+// You can use it if you need to work with channels.
+//
+// See Examples section below for usage examples.
+package backoff
+
+import "time"
+
+// BackOff is a backoff policy for retrying an operation.
+type BackOff interface {
+ // NextBackOff returns the duration to wait before retrying the operation,
+ // or backoff.Stop to indicate that no more retries should be made.
+ //
+ // Example usage:
+ //
+ // duration := backoff.NextBackOff();
+ // if (duration == backoff.Stop) {
+ // // Do not retry operation.
+ // } else {
+ // // Sleep for duration and retry operation.
+ // }
+ //
+ NextBackOff() time.Duration
+
+ // Reset to initial state.
+ Reset()
+}
+
+// Stop indicates that no more retries should be made for use in NextBackOff().
+const Stop time.Duration = -1
+
+// ZeroBackOff is a fixed backoff policy whose backoff time is always zero,
+// meaning that the operation is retried immediately without waiting, indefinitely.
+type ZeroBackOff struct{}
+
+func (b *ZeroBackOff) Reset() {}
+
+func (b *ZeroBackOff) NextBackOff() time.Duration { return 0 }
+
+// StopBackOff is a fixed backoff policy that always returns backoff.Stop for
+// NextBackOff(), meaning that the operation should never be retried.
+type StopBackOff struct{}
+
+func (b *StopBackOff) Reset() {}
+
+func (b *StopBackOff) NextBackOff() time.Duration { return Stop }
+
+// ConstantBackOff is a backoff policy that always returns the same backoff delay.
+// This is in contrast to an exponential backoff policy,
+// which returns a delay that grows longer as you call NextBackOff() over and over again.
+type ConstantBackOff struct {
+ Interval time.Duration
+}
+
+func (b *ConstantBackOff) Reset() {}
+func (b *ConstantBackOff) NextBackOff() time.Duration { return b.Interval }
+
+func NewConstantBackOff(d time.Duration) *ConstantBackOff {
+ return &ConstantBackOff{Interval: d}
+}
diff --git a/vendor/gopkg.in/cenkalti/backoff.v1/context.go b/vendor/gopkg.in/cenkalti/backoff.v1/context.go
new file mode 100644
index 0000000..5d15709
--- /dev/null
+++ b/vendor/gopkg.in/cenkalti/backoff.v1/context.go
@@ -0,0 +1,60 @@
+package backoff
+
+import (
+ "time"
+
+ "golang.org/x/net/context"
+)
+
+// BackOffContext is a backoff policy that stops retrying after the context
+// is canceled.
+type BackOffContext interface {
+ BackOff
+ Context() context.Context
+}
+
+type backOffContext struct {
+ BackOff
+ ctx context.Context
+}
+
+// WithContext returns a BackOffContext with context ctx
+//
+// ctx must not be nil
+func WithContext(b BackOff, ctx context.Context) BackOffContext {
+ if ctx == nil {
+ panic("nil context")
+ }
+
+ if b, ok := b.(*backOffContext); ok {
+ return &backOffContext{
+ BackOff: b.BackOff,
+ ctx: ctx,
+ }
+ }
+
+ return &backOffContext{
+ BackOff: b,
+ ctx: ctx,
+ }
+}
+
+func ensureContext(b BackOff) BackOffContext {
+ if cb, ok := b.(BackOffContext); ok {
+ return cb
+ }
+ return WithContext(b, context.Background())
+}
+
+func (b *backOffContext) Context() context.Context {
+ return b.ctx
+}
+
+func (b *backOffContext) NextBackOff() time.Duration {
+ select {
+ case <-b.Context().Done():
+ return Stop
+ default:
+ return b.BackOff.NextBackOff()
+ }
+}
diff --git a/vendor/gopkg.in/cenkalti/backoff.v1/exponential.go b/vendor/gopkg.in/cenkalti/backoff.v1/exponential.go
new file mode 100644
index 0000000..9a6addf
--- /dev/null
+++ b/vendor/gopkg.in/cenkalti/backoff.v1/exponential.go
@@ -0,0 +1,156 @@
+package backoff
+
+import (
+ "math/rand"
+ "time"
+)
+
+/*
+ExponentialBackOff is a backoff implementation that increases the backoff
+period for each retry attempt using a randomization function that grows exponentially.
+
+NextBackOff() is calculated using the following formula:
+
+ randomized interval =
+ RetryInterval * (random value in range [1 - RandomizationFactor, 1 + RandomizationFactor])
+
+In other words NextBackOff() will range between the randomization factor
+percentage below and above the retry interval.
+
+For example, given the following parameters:
+
+ RetryInterval = 2
+ RandomizationFactor = 0.5
+ Multiplier = 2
+
+the actual backoff period used in the next retry attempt will range between 1 and 3 seconds,
+multiplied by the exponential, that is, between 2 and 6 seconds.
+
+Note: MaxInterval caps the RetryInterval and not the randomized interval.
+
+If the time elapsed since an ExponentialBackOff instance is created goes past the
+MaxElapsedTime, then the method NextBackOff() starts returning backoff.Stop.
+
+The elapsed time can be reset by calling Reset().
+
+Example: Given the following default arguments, for 10 tries the sequence will be,
+and assuming we go over the MaxElapsedTime on the 10th try:
+
+ Request # RetryInterval (seconds) Randomized Interval (seconds)
+
+ 1 0.5 [0.25, 0.75]
+ 2 0.75 [0.375, 1.125]
+ 3 1.125 [0.562, 1.687]
+ 4 1.687 [0.8435, 2.53]
+ 5 2.53 [1.265, 3.795]
+ 6 3.795 [1.897, 5.692]
+ 7 5.692 [2.846, 8.538]
+ 8 8.538 [4.269, 12.807]
+ 9 12.807 [6.403, 19.210]
+ 10 19.210 backoff.Stop
+
+Note: Implementation is not thread-safe.
+*/
+type ExponentialBackOff struct {
+ InitialInterval time.Duration
+ RandomizationFactor float64
+ Multiplier float64
+ MaxInterval time.Duration
+ // After MaxElapsedTime the ExponentialBackOff stops.
+ // It never stops if MaxElapsedTime == 0.
+ MaxElapsedTime time.Duration
+ Clock Clock
+
+ currentInterval time.Duration
+ startTime time.Time
+ random *rand.Rand
+}
+
+// Clock is an interface that returns current time for BackOff.
+type Clock interface {
+ Now() time.Time
+}
+
+// Default values for ExponentialBackOff.
+const (
+ DefaultInitialInterval = 500 * time.Millisecond
+ DefaultRandomizationFactor = 0.5
+ DefaultMultiplier = 1.5
+ DefaultMaxInterval = 60 * time.Second
+ DefaultMaxElapsedTime = 15 * time.Minute
+)
+
+// NewExponentialBackOff creates an instance of ExponentialBackOff using default values.
+func NewExponentialBackOff() *ExponentialBackOff {
+ b := &ExponentialBackOff{
+ InitialInterval: DefaultInitialInterval,
+ RandomizationFactor: DefaultRandomizationFactor,
+ Multiplier: DefaultMultiplier,
+ MaxInterval: DefaultMaxInterval,
+ MaxElapsedTime: DefaultMaxElapsedTime,
+ Clock: SystemClock,
+ random: rand.New(rand.NewSource(time.Now().UnixNano())),
+ }
+ b.Reset()
+ return b
+}
+
+type systemClock struct{}
+
+func (t systemClock) Now() time.Time {
+ return time.Now()
+}
+
+// SystemClock implements Clock interface that uses time.Now().
+var SystemClock = systemClock{}
+
+// Reset the interval back to the initial retry interval and restarts the timer.
+func (b *ExponentialBackOff) Reset() {
+ b.currentInterval = b.InitialInterval
+ b.startTime = b.Clock.Now()
+}
+
+// NextBackOff calculates the next backoff interval using the formula:
+// Randomized interval = RetryInterval +/- (RandomizationFactor * RetryInterval)
+func (b *ExponentialBackOff) NextBackOff() time.Duration {
+ // Make sure we have not gone over the maximum elapsed time.
+ if b.MaxElapsedTime != 0 && b.GetElapsedTime() > b.MaxElapsedTime {
+ return Stop
+ }
+ defer b.incrementCurrentInterval()
+ if b.random == nil {
+ b.random = rand.New(rand.NewSource(time.Now().UnixNano()))
+ }
+ return getRandomValueFromInterval(b.RandomizationFactor, b.random.Float64(), b.currentInterval)
+}
+
+// GetElapsedTime returns the elapsed time since an ExponentialBackOff instance
+// is created and is reset when Reset() is called.
+//
+// The elapsed time is computed using time.Now().UnixNano().
+func (b *ExponentialBackOff) GetElapsedTime() time.Duration {
+ return b.Clock.Now().Sub(b.startTime)
+}
+
+// Increments the current interval by multiplying it with the multiplier.
+func (b *ExponentialBackOff) incrementCurrentInterval() {
+ // Check for overflow, if overflow is detected set the current interval to the max interval.
+ if float64(b.currentInterval) >= float64(b.MaxInterval)/b.Multiplier {
+ b.currentInterval = b.MaxInterval
+ } else {
+ b.currentInterval = time.Duration(float64(b.currentInterval) * b.Multiplier)
+ }
+}
+
+// Returns a random value from the following interval:
+// [randomizationFactor * currentInterval, randomizationFactor * currentInterval].
+func getRandomValueFromInterval(randomizationFactor, random float64, currentInterval time.Duration) time.Duration {
+ var delta = randomizationFactor * float64(currentInterval)
+ var minInterval = float64(currentInterval) - delta
+ var maxInterval = float64(currentInterval) + delta
+
+ // Get a random value from the range [minInterval, maxInterval].
+ // The formula used below has a +1 because if the minInterval is 1 and the maxInterval is 3 then
+ // we want a 33% chance for selecting either 1, 2 or 3.
+ return time.Duration(minInterval + (random * (maxInterval - minInterval + 1)))
+}
diff --git a/vendor/gopkg.in/cenkalti/backoff.v1/retry.go b/vendor/gopkg.in/cenkalti/backoff.v1/retry.go
new file mode 100644
index 0000000..5dbd825
--- /dev/null
+++ b/vendor/gopkg.in/cenkalti/backoff.v1/retry.go
@@ -0,0 +1,78 @@
+package backoff
+
+import "time"
+
+// An Operation is executing by Retry() or RetryNotify().
+// The operation will be retried using a backoff policy if it returns an error.
+type Operation func() error
+
+// Notify is a notify-on-error function. It receives an operation error and
+// backoff delay if the operation failed (with an error).
+//
+// NOTE that if the backoff policy stated to stop retrying,
+// the notify function isn't called.
+type Notify func(error, time.Duration)
+
+// Retry the operation o until it does not return error or BackOff stops.
+// o is guaranteed to be run at least once.
+// It is the caller's responsibility to reset b after Retry returns.
+//
+// If o returns a *PermanentError, the operation is not retried, and the
+// wrapped error is returned.
+//
+// Retry sleeps the goroutine for the duration returned by BackOff after a
+// failed operation returns.
+func Retry(o Operation, b BackOff) error { return RetryNotify(o, b, nil) }
+
+// RetryNotify calls notify function with the error and wait duration
+// for each failed attempt before sleep.
+func RetryNotify(operation Operation, b BackOff, notify Notify) error {
+ var err error
+ var next time.Duration
+
+ cb := ensureContext(b)
+
+ b.Reset()
+ for {
+ if err = operation(); err == nil {
+ return nil
+ }
+
+ if permanent, ok := err.(*PermanentError); ok {
+ return permanent.Err
+ }
+
+ if next = b.NextBackOff(); next == Stop {
+ return err
+ }
+
+ if notify != nil {
+ notify(err, next)
+ }
+
+ t := time.NewTimer(next)
+
+ select {
+ case <-cb.Context().Done():
+ t.Stop()
+ return err
+ case <-t.C:
+ }
+ }
+}
+
+// PermanentError signals that the operation should not be retried.
+type PermanentError struct {
+ Err error
+}
+
+func (e *PermanentError) Error() string {
+ return e.Err.Error()
+}
+
+// Permanent wraps the given err in a *PermanentError.
+func Permanent(err error) *PermanentError {
+ return &PermanentError{
+ Err: err,
+ }
+}
diff --git a/vendor/gopkg.in/cenkalti/backoff.v1/ticker.go b/vendor/gopkg.in/cenkalti/backoff.v1/ticker.go
new file mode 100644
index 0000000..49a9971
--- /dev/null
+++ b/vendor/gopkg.in/cenkalti/backoff.v1/ticker.go
@@ -0,0 +1,81 @@
+package backoff
+
+import (
+ "runtime"
+ "sync"
+ "time"
+)
+
+// Ticker holds a channel that delivers `ticks' of a clock at times reported by a BackOff.
+//
+// Ticks will continue to arrive when the previous operation is still running,
+// so operations that take a while to fail could run in quick succession.
+type Ticker struct {
+ C <-chan time.Time
+ c chan time.Time
+ b BackOffContext
+ stop chan struct{}
+ stopOnce sync.Once
+}
+
+// NewTicker returns a new Ticker containing a channel that will send the time at times
+// specified by the BackOff argument. Ticker is guaranteed to tick at least once.
+// The channel is closed when Stop method is called or BackOff stops.
+func NewTicker(b BackOff) *Ticker {
+ c := make(chan time.Time)
+ t := &Ticker{
+ C: c,
+ c: c,
+ b: ensureContext(b),
+ stop: make(chan struct{}),
+ }
+ go t.run()
+ runtime.SetFinalizer(t, (*Ticker).Stop)
+ return t
+}
+
+// Stop turns off a ticker. After Stop, no more ticks will be sent.
+func (t *Ticker) Stop() {
+ t.stopOnce.Do(func() { close(t.stop) })
+}
+
+func (t *Ticker) run() {
+ c := t.c
+ defer close(c)
+ t.b.Reset()
+
+ // Ticker is guaranteed to tick at least once.
+ afterC := t.send(time.Now())
+
+ for {
+ if afterC == nil {
+ return
+ }
+
+ select {
+ case tick := <-afterC:
+ afterC = t.send(tick)
+ case <-t.stop:
+ t.c = nil // Prevent future ticks from being sent to the channel.
+ return
+ case <-t.b.Context().Done():
+ return
+ }
+ }
+}
+
+func (t *Ticker) send(tick time.Time) <-chan time.Time {
+ select {
+ case t.c <- tick:
+ case <-t.stop:
+ return nil
+ }
+
+ next := t.b.NextBackOff()
+ if next == Stop {
+ t.Stop()
+ return nil
+ }
+
+ return time.After(next)
+}
diff --git a/vendor/gopkg.in/cenkalti/backoff.v1/tries.go b/vendor/gopkg.in/cenkalti/backoff.v1/tries.go
new file mode 100644
index 0000000..d2da730
--- /dev/null
+++ b/vendor/gopkg.in/cenkalti/backoff.v1/tries.go
@@ -0,0 +1,35 @@
+package backoff
+
+import "time"
+
+/*
+WithMaxTries creates a wrapper around another BackOff, which will
+return Stop if NextBackOff() has been called too many times since
+the last time Reset() was called
+
+Note: Implementation is not thread-safe.
+*/
+func WithMaxTries(b BackOff, max uint64) BackOff {
+ return &backOffTries{delegate: b, maxTries: max}
+}
+
+type backOffTries struct {
+ delegate BackOff
+ maxTries uint64
+ numTries uint64
+}
+
+func (b *backOffTries) NextBackOff() time.Duration {
+ if b.maxTries > 0 {
+ if b.maxTries <= b.numTries {
+ return Stop
+ }
+ b.numTries++
+ }
+ return b.delegate.NextBackOff()
+}
+
+func (b *backOffTries) Reset() {
+ b.numTries = 0
+ b.delegate.Reset()
+}
diff --git a/vendor/gopkg.in/sourcemap.v1/.travis.yml b/vendor/gopkg.in/sourcemap.v1/.travis.yml
new file mode 100644
index 0000000..229abef
--- /dev/null
+++ b/vendor/gopkg.in/sourcemap.v1/.travis.yml
@@ -0,0 +1,16 @@
+sudo: false
+language: go
+
+go:
+ - 1.6
+ - 1.7
+ - tip
+
+matrix:
+ allow_failures:
+ - go: tip
+
+install:
+ - mkdir -p $HOME/gopath/src/gopkg.in
+ - mv $HOME/gopath/src/github.com/go-sourcemap/sourcemap $HOME/gopath/src/gopkg.in/sourcemap.v1
+ - cd $HOME/gopath/src/gopkg.in/sourcemap.v1
diff --git a/vendor/gopkg.in/sourcemap.v1/LICENSE b/vendor/gopkg.in/sourcemap.v1/LICENSE
new file mode 100644
index 0000000..405d20f
--- /dev/null
+++ b/vendor/gopkg.in/sourcemap.v1/LICENSE
@@ -0,0 +1,25 @@
+Copyright (c) 2016 The github.com/go-sourcemap/sourcemap Contributors.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/vendor/gopkg.in/sourcemap.v1/Makefile b/vendor/gopkg.in/sourcemap.v1/Makefile
new file mode 100644
index 0000000..161c4fd
--- /dev/null
+++ b/vendor/gopkg.in/sourcemap.v1/Makefile
@@ -0,0 +1,4 @@
+all:
+ go test ./...
+ go test ./... -short -race
+ go vet
diff --git a/vendor/gopkg.in/sourcemap.v1/README.md b/vendor/gopkg.in/sourcemap.v1/README.md
new file mode 100644
index 0000000..fb319d2
--- /dev/null
+++ b/vendor/gopkg.in/sourcemap.v1/README.md
@@ -0,0 +1,35 @@
+# Source Maps consumer for Golang [![Build Status](https://travis-ci.org/go-sourcemap/sourcemap.svg?branch=v1)](https://travis-ci.org/go-sourcemap/sourcemap)
+
+## Installation
+
+Install:
+
+ go get gopkg.in/sourcemap.v1
+
+## Quickstart
+
+```go
+func ExampleParse() {
+ mapURL := "http://code.jquery.com/jquery-2.0.3.min.map"
+ resp, err := http.Get(mapURL)
+ if err != nil {
+ panic(err)
+ }
+ defer resp.Body.Close()
+
+ b, err := ioutil.ReadAll(resp.Body)
+ if err != nil {
+ panic(err)
+ }
+
+ smap, err := sourcemap.Parse(mapURL, b)
+ if err != nil {
+ panic(err)
+ }
+
+ line, column := 5, 6789
+ file, fn, line, col, ok := smap.Source(line, column)
+ fmt.Println(file, fn, line, col, ok)
+ // Output: http://code.jquery.com/jquery-2.0.3.js apply 4360 27 true
+}
+```
diff --git a/vendor/gopkg.in/sourcemap.v1/base64vlq/base64_vlq.go b/vendor/gopkg.in/sourcemap.v1/base64vlq/base64_vlq.go
new file mode 100644
index 0000000..16cbfb5
--- /dev/null
+++ b/vendor/gopkg.in/sourcemap.v1/base64vlq/base64_vlq.go
@@ -0,0 +1,92 @@
+package base64vlq
+
+import (
+ "io"
+)
+
+const encodeStd = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
+
+const (
+ vlqBaseShift = 5
+ vlqBase = 1 << vlqBaseShift
+ vlqBaseMask = vlqBase - 1
+ vlqSignBit = 1
+ vlqContinuationBit = vlqBase
+)
+
+var decodeMap [256]byte
+
+func init() {
+ for i := 0; i < len(encodeStd); i++ {
+ decodeMap[encodeStd[i]] = byte(i)
+ }
+}
+
+func toVLQSigned(n int) int {
+ if n < 0 {
+ return -n<<1 + 1
+ }
+ return n << 1
+}
+
+func fromVLQSigned(n int) int {
+ isNeg := n&vlqSignBit != 0
+ n >>= 1
+ if isNeg {
+ return -n
+ }
+ return n
+}
+
+type Encoder struct {
+ w io.ByteWriter
+}
+
+func NewEncoder(w io.ByteWriter) *Encoder {
+ return &Encoder{
+ w: w,
+ }
+}
+
+func (enc Encoder) Encode(n int) error {
+ n = toVLQSigned(n)
+ for digit := vlqContinuationBit; digit&vlqContinuationBit != 0; {
+ digit = n & vlqBaseMask
+ n >>= vlqBaseShift
+ if n > 0 {
+ digit |= vlqContinuationBit
+ }
+
+ err := enc.w.WriteByte(encodeStd[digit])
+ if err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+type Decoder struct {
+ r io.ByteReader
+}
+
+func NewDecoder(r io.ByteReader) *Decoder {
+ return &Decoder{
+ r: r,
+ }
+}
+
+func (dec Decoder) Decode() (n int, err error) {
+ shift := uint(0)
+ for continuation := true; continuation; {
+ c, err := dec.r.ReadByte()
+ if err != nil {
+ return 0, err
+ }
+
+ c = decodeMap[c]
+ continuation = c&vlqContinuationBit != 0
+ n += int(c&vlqBaseMask) << shift
+ shift += vlqBaseShift
+ }
+ return fromVLQSigned(n), nil
+}
diff --git a/vendor/gopkg.in/sourcemap.v1/consumer.go b/vendor/gopkg.in/sourcemap.v1/consumer.go
new file mode 100644
index 0000000..3bed06a
--- /dev/null
+++ b/vendor/gopkg.in/sourcemap.v1/consumer.go
@@ -0,0 +1,134 @@
+package sourcemap
+
+import (
+ "encoding/json"
+ "fmt"
+ "net/url"
+ "path"
+ "sort"
+ "strconv"
+)
+
+type Consumer struct {
+ sourceRootURL *url.URL
+ smap *sourceMap
+ mappings []mapping
+}
+
+func Parse(mapURL string, b []byte) (*Consumer, error) {
+ smap := new(sourceMap)
+ err := json.Unmarshal(b, smap)
+ if err != nil {
+ return nil, err
+ }
+
+ if smap.Version != 3 {
+ return nil, fmt.Errorf(
+ "sourcemap: got version=%d, but only 3rd version is supported",
+ smap.Version,
+ )
+ }
+
+ var sourceRootURL *url.URL
+ if smap.SourceRoot != "" {
+ u, err := url.Parse(smap.SourceRoot)
+ if err != nil {
+ return nil, err
+ }
+ if u.IsAbs() {
+ sourceRootURL = u
+ }
+ } else if mapURL != "" {
+ u, err := url.Parse(mapURL)
+ if err != nil {
+ return nil, err
+ }
+ if u.IsAbs() {
+ u.Path = path.Dir(u.Path)
+ sourceRootURL = u
+ }
+ }
+
+ mappings, err := parseMappings(smap.Mappings)
+ if err != nil {
+ return nil, err
+ }
+ // Free memory.
+ smap.Mappings = ""
+
+ return &Consumer{
+ sourceRootURL: sourceRootURL,
+ smap: smap,
+ mappings: mappings,
+ }, nil
+}
+
+func (c *Consumer) File() string {
+ return c.smap.File
+}
+
+func (c *Consumer) Source(genLine, genCol int) (source, name string, line, col int, ok bool) {
+ i := sort.Search(len(c.mappings), func(i int) bool {
+ m := &c.mappings[i]
+ if m.genLine == genLine {
+ return m.genCol >= genCol
+ }
+ return m.genLine >= genLine
+ })
+
+ // Mapping not found.
+ if i == len(c.mappings) {
+ return
+ }
+
+ match := &c.mappings[i]
+
+ // Fuzzy match.
+ if match.genLine > genLine || match.genCol > genCol {
+ if i == 0 {
+ return
+ }
+ match = &c.mappings[i-1]
+ }
+
+ if match.sourcesInd >= 0 {
+ source = c.absSource(c.smap.Sources[match.sourcesInd])
+ }
+ if match.namesInd >= 0 {
+ v := c.smap.Names[match.namesInd]
+ switch v := v.(type) {
+ case string:
+ name = v
+ case float64:
+ name = strconv.FormatFloat(v, 'f', -1, 64)
+ default:
+ name = fmt.Sprint(v)
+ }
+ }
+ line = match.sourceLine
+ col = match.sourceCol
+ ok = true
+ return
+}
+
+func (c *Consumer) absSource(source string) string {
+ if path.IsAbs(source) {
+ return source
+ }
+
+ if u, err := url.Parse(source); err == nil && u.IsAbs() {
+ return source
+ }
+
+ if c.sourceRootURL != nil {
+ u := *c.sourceRootURL
+ u.Path = path.Join(c.sourceRootURL.Path, source)
+ return u.String()
+ }
+
+ if c.smap.SourceRoot != "" {
+ return path.Join(c.smap.SourceRoot, source)
+ }
+
+ return source
+}
diff --git a/vendor/gopkg.in/sourcemap.v1/sourcemap.go b/vendor/gopkg.in/sourcemap.v1/sourcemap.go
new file mode 100644
index 0000000..0e9af1a
--- /dev/null
+++ b/vendor/gopkg.in/sourcemap.v1/sourcemap.go
@@ -0,0 +1,157 @@
+package sourcemap // import "gopkg.in/sourcemap.v1"
+
+import (
+ "io"
+ "strings"
+
+ "gopkg.in/sourcemap.v1/base64vlq"
+)
+
+type fn func(m *mappings) (fn, error)
+
+type sourceMap struct {
+ Version int `json:"version"`
+ File string `json:"file"`
+ SourceRoot string `json:"sourceRoot"`
+ Sources []string `json:"sources"`
+ Names []interface{} `json:"names"`
+ Mappings string `json:"mappings"`
+}
+
+type mapping struct {
+ genLine int
+ genCol int
+ sourcesInd int
+ sourceLine int
+ sourceCol int
+ namesInd int
+}
+
+type mappings struct {
+ rd *strings.Reader
+ dec *base64vlq.Decoder
+
+ hasName bool
+ value mapping
+
+ values []mapping
+}
+
+func parseMappings(s string) ([]mapping, error) {
+ rd := strings.NewReader(s)
+ m := &mappings{
+ rd: rd,
+ dec: base64vlq.NewDecoder(rd),
+ }
+ m.value.genLine = 1
+ m.value.sourceLine = 1
+
+ err := m.parse()
+ if err != nil {
+ return nil, err
+ }
+ return m.values, nil
+}
+
+func (m *mappings) parse() error {
+ next := parseGenCol
+ for {
+ c, err := m.rd.ReadByte()
+ if err == io.EOF {
+ m.pushValue()
+ return nil
+ }
+ if err != nil {
+ return err
+ }
+
+ switch c {
+ case ',':
+ m.pushValue()
+ next = parseGenCol
+ case ';':
+ m.pushValue()
+
+ m.value.genLine++
+ m.value.genCol = 0
+
+ next = parseGenCol
+ default:
+ err := m.rd.UnreadByte()
+ if err != nil {
+ return err
+ }
+
+ next, err = next(m)
+ if err != nil {
+ return err
+ }
+ }
+ }
+}
+
+func parseGenCol(m *mappings) (fn, error) {
+ n, err := m.dec.Decode()
+ if err != nil {
+ return nil, err
+ }
+ m.value.genCol += n
+ return parseSourcesInd, nil
+}
+
+func parseSourcesInd(m *mappings) (fn, error) {
+ n, err := m.dec.Decode()
+ if err != nil {
+ return nil, err
+ }
+ m.value.sourcesInd += n
+ return parseSourceLine, nil
+}
+
+func parseSourceLine(m *mappings) (fn, error) {
+ n, err := m.dec.Decode()
+ if err != nil {
+ return nil, err
+ }
+ m.value.sourceLine += n
+ return parseSourceCol, nil
+}
+
+func parseSourceCol(m *mappings) (fn, error) {
+ n, err := m.dec.Decode()
+ if err != nil {
+ return nil, err
+ }
+ m.value.sourceCol += n
+ return parseNamesInd, nil
+}
+
+func parseNamesInd(m *mappings) (fn, error) {
+ n, err := m.dec.Decode()
+ if err != nil {
+ return nil, err
+ }
+ m.hasName = true
+ m.value.namesInd += n
+ return parseGenCol, nil
+}
+
+func (m *mappings) pushValue() {
+ if m.value.sourceLine == 1 && m.value.sourceCol == 0 {
+ return
+ }
+
+ if m.hasName {
+ m.values = append(m.values, m.value)
+ m.hasName = false
+ } else {
+ m.values = append(m.values, mapping{
+ genLine: m.value.genLine,
+ genCol: m.value.genCol,
+ sourcesInd: m.value.sourcesInd,
+ sourceLine: m.value.sourceLine,
+ sourceCol: m.value.sourceCol,
+ namesInd: -1,
+ })
+ }
+}
diff --git a/vendor/modules.txt b/vendor/modules.txt
new file mode 100644
index 0000000..bb75a42
--- /dev/null
+++ b/vendor/modules.txt
@@ -0,0 +1,48 @@
+# github.com/juju/go4 v0.0.0-20160222163258-40d72ab9641a
+## explicit
+# github.com/juju/persistent-cookiejar v1.0.0
+## explicit
+# github.com/r3labs/sse/v2 v2.10.0
+## explicit; go 1.13
+github.com/r3labs/sse/v2
+# github.com/robertkrimen/otto v0.2.1
+## explicit; go 1.18
+github.com/robertkrimen/otto
+github.com/robertkrimen/otto/ast
+github.com/robertkrimen/otto/dbg
+github.com/robertkrimen/otto/file
+github.com/robertkrimen/otto/parser
+github.com/robertkrimen/otto/registry
+github.com/robertkrimen/otto/token
+# github.com/tylertravisty/go-utils v0.0.0-20230524204414-6893ae548909
+## explicit; go 1.16
+github.com/tylertravisty/go-utils/random
+# golang.org/x/net v0.0.0-20191116160921-f9c825593386
+## explicit; go 1.11
+golang.org/x/net/context
+# golang.org/x/text v0.4.0
+## explicit; go 1.17
+golang.org/x/text/feature/plural
+golang.org/x/text/internal
+golang.org/x/text/internal/catmsg
+golang.org/x/text/internal/format
+golang.org/x/text/internal/language
+golang.org/x/text/internal/language/compact
+golang.org/x/text/internal/number
+golang.org/x/text/internal/stringset
+golang.org/x/text/internal/tag
+golang.org/x/text/language
+golang.org/x/text/message
+golang.org/x/text/message/catalog
+golang.org/x/text/number
+# gopkg.in/cenkalti/backoff.v1 v1.1.0
+## explicit
+gopkg.in/cenkalti/backoff.v1
+# gopkg.in/errgo.v1 v1.0.1
+## explicit
+# gopkg.in/retry.v1 v1.0.3
+## explicit; go 1.12
+# gopkg.in/sourcemap.v1 v1.0.5
+## explicit
+gopkg.in/sourcemap.v1
+gopkg.in/sourcemap.v1/base64vlq