mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 07:22:24 -05:00
[chore]: Bump modernc.org/sqlite from 1.28.0 to 1.29.2 (#2718)
This commit is contained in:
parent
ea0efb8094
commit
adb4cdcf6c
356 changed files with 2619858 additions and 1869411 deletions
23
vendor/github.com/hashicorp/golang-lru/v2/.gitignore
generated
vendored
Normal file
23
vendor/github.com/hashicorp/golang-lru/v2/.gitignore
generated
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# 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
|
||||
*.test
|
||||
46
vendor/github.com/hashicorp/golang-lru/v2/.golangci.yml
generated
vendored
Normal file
46
vendor/github.com/hashicorp/golang-lru/v2/.golangci.yml
generated
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
# Copyright (c) HashiCorp, Inc.
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
linters:
|
||||
fast: false
|
||||
disable-all: true
|
||||
enable:
|
||||
- revive
|
||||
- megacheck
|
||||
- govet
|
||||
- unconvert
|
||||
- gas
|
||||
- gocyclo
|
||||
- dupl
|
||||
- misspell
|
||||
- unparam
|
||||
- unused
|
||||
- typecheck
|
||||
- ineffassign
|
||||
# - stylecheck
|
||||
- exportloopref
|
||||
- gocritic
|
||||
- nakedret
|
||||
- gosimple
|
||||
- prealloc
|
||||
|
||||
# golangci-lint configuration file
|
||||
linters-settings:
|
||||
revive:
|
||||
ignore-generated-header: true
|
||||
severity: warning
|
||||
rules:
|
||||
- name: package-comments
|
||||
severity: warning
|
||||
disabled: true
|
||||
- name: exported
|
||||
severity: warning
|
||||
disabled: false
|
||||
arguments: ["checkPrivateReceivers", "disableStutteringCheck"]
|
||||
|
||||
issues:
|
||||
exclude-use-default: false
|
||||
exclude-rules:
|
||||
- path: _test\.go
|
||||
linters:
|
||||
- dupl
|
||||
267
vendor/github.com/hashicorp/golang-lru/v2/2q.go
generated
vendored
Normal file
267
vendor/github.com/hashicorp/golang-lru/v2/2q.go
generated
vendored
Normal file
|
|
@ -0,0 +1,267 @@
|
|||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
package lru
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"sync"
|
||||
|
||||
"github.com/hashicorp/golang-lru/v2/simplelru"
|
||||
)
|
||||
|
||||
const (
|
||||
// Default2QRecentRatio is the ratio of the 2Q cache dedicated
|
||||
// to recently added entries that have only been accessed once.
|
||||
Default2QRecentRatio = 0.25
|
||||
|
||||
// Default2QGhostEntries is the default ratio of ghost
|
||||
// entries kept to track entries recently evicted
|
||||
Default2QGhostEntries = 0.50
|
||||
)
|
||||
|
||||
// TwoQueueCache is a thread-safe fixed size 2Q cache.
|
||||
// 2Q is an enhancement over the standard LRU cache
|
||||
// in that it tracks both frequently and recently used
|
||||
// entries separately. This avoids a burst in access to new
|
||||
// entries from evicting frequently used entries. It adds some
|
||||
// additional tracking overhead to the standard LRU cache, and is
|
||||
// computationally about 2x the cost, and adds some metadata over
|
||||
// head. The ARCCache is similar, but does not require setting any
|
||||
// parameters.
|
||||
type TwoQueueCache[K comparable, V any] struct {
|
||||
size int
|
||||
recentSize int
|
||||
recentRatio float64
|
||||
ghostRatio float64
|
||||
|
||||
recent simplelru.LRUCache[K, V]
|
||||
frequent simplelru.LRUCache[K, V]
|
||||
recentEvict simplelru.LRUCache[K, struct{}]
|
||||
lock sync.RWMutex
|
||||
}
|
||||
|
||||
// New2Q creates a new TwoQueueCache using the default
|
||||
// values for the parameters.
|
||||
func New2Q[K comparable, V any](size int) (*TwoQueueCache[K, V], error) {
|
||||
return New2QParams[K, V](size, Default2QRecentRatio, Default2QGhostEntries)
|
||||
}
|
||||
|
||||
// New2QParams creates a new TwoQueueCache using the provided
|
||||
// parameter values.
|
||||
func New2QParams[K comparable, V any](size int, recentRatio, ghostRatio float64) (*TwoQueueCache[K, V], error) {
|
||||
if size <= 0 {
|
||||
return nil, errors.New("invalid size")
|
||||
}
|
||||
if recentRatio < 0.0 || recentRatio > 1.0 {
|
||||
return nil, errors.New("invalid recent ratio")
|
||||
}
|
||||
if ghostRatio < 0.0 || ghostRatio > 1.0 {
|
||||
return nil, errors.New("invalid ghost ratio")
|
||||
}
|
||||
|
||||
// Determine the sub-sizes
|
||||
recentSize := int(float64(size) * recentRatio)
|
||||
evictSize := int(float64(size) * ghostRatio)
|
||||
|
||||
// Allocate the LRUs
|
||||
recent, err := simplelru.NewLRU[K, V](size, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
frequent, err := simplelru.NewLRU[K, V](size, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
recentEvict, err := simplelru.NewLRU[K, struct{}](evictSize, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Initialize the cache
|
||||
c := &TwoQueueCache[K, V]{
|
||||
size: size,
|
||||
recentSize: recentSize,
|
||||
recentRatio: recentRatio,
|
||||
ghostRatio: ghostRatio,
|
||||
recent: recent,
|
||||
frequent: frequent,
|
||||
recentEvict: recentEvict,
|
||||
}
|
||||
return c, nil
|
||||
}
|
||||
|
||||
// Get looks up a key's value from the cache.
|
||||
func (c *TwoQueueCache[K, V]) Get(key K) (value V, ok bool) {
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
|
||||
// Check if this is a frequent value
|
||||
if val, ok := c.frequent.Get(key); ok {
|
||||
return val, ok
|
||||
}
|
||||
|
||||
// If the value is contained in recent, then we
|
||||
// promote it to frequent
|
||||
if val, ok := c.recent.Peek(key); ok {
|
||||
c.recent.Remove(key)
|
||||
c.frequent.Add(key, val)
|
||||
return val, ok
|
||||
}
|
||||
|
||||
// No hit
|
||||
return
|
||||
}
|
||||
|
||||
// Add adds a value to the cache.
|
||||
func (c *TwoQueueCache[K, V]) Add(key K, value V) {
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
|
||||
// Check if the value is frequently used already,
|
||||
// and just update the value
|
||||
if c.frequent.Contains(key) {
|
||||
c.frequent.Add(key, value)
|
||||
return
|
||||
}
|
||||
|
||||
// Check if the value is recently used, and promote
|
||||
// the value into the frequent list
|
||||
if c.recent.Contains(key) {
|
||||
c.recent.Remove(key)
|
||||
c.frequent.Add(key, value)
|
||||
return
|
||||
}
|
||||
|
||||
// If the value was recently evicted, add it to the
|
||||
// frequently used list
|
||||
if c.recentEvict.Contains(key) {
|
||||
c.ensureSpace(true)
|
||||
c.recentEvict.Remove(key)
|
||||
c.frequent.Add(key, value)
|
||||
return
|
||||
}
|
||||
|
||||
// Add to the recently seen list
|
||||
c.ensureSpace(false)
|
||||
c.recent.Add(key, value)
|
||||
}
|
||||
|
||||
// ensureSpace is used to ensure we have space in the cache
|
||||
func (c *TwoQueueCache[K, V]) ensureSpace(recentEvict bool) {
|
||||
// If we have space, nothing to do
|
||||
recentLen := c.recent.Len()
|
||||
freqLen := c.frequent.Len()
|
||||
if recentLen+freqLen < c.size {
|
||||
return
|
||||
}
|
||||
|
||||
// If the recent buffer is larger than
|
||||
// the target, evict from there
|
||||
if recentLen > 0 && (recentLen > c.recentSize || (recentLen == c.recentSize && !recentEvict)) {
|
||||
k, _, _ := c.recent.RemoveOldest()
|
||||
c.recentEvict.Add(k, struct{}{})
|
||||
return
|
||||
}
|
||||
|
||||
// Remove from the frequent list otherwise
|
||||
c.frequent.RemoveOldest()
|
||||
}
|
||||
|
||||
// Len returns the number of items in the cache.
|
||||
func (c *TwoQueueCache[K, V]) Len() int {
|
||||
c.lock.RLock()
|
||||
defer c.lock.RUnlock()
|
||||
return c.recent.Len() + c.frequent.Len()
|
||||
}
|
||||
|
||||
// Resize changes the cache size.
|
||||
func (c *TwoQueueCache[K, V]) Resize(size int) (evicted int) {
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
|
||||
// Recalculate the sub-sizes
|
||||
recentSize := int(float64(size) * c.recentRatio)
|
||||
evictSize := int(float64(size) * c.ghostRatio)
|
||||
c.size = size
|
||||
c.recentSize = recentSize
|
||||
|
||||
// ensureSpace
|
||||
diff := c.recent.Len() + c.frequent.Len() - size
|
||||
if diff < 0 {
|
||||
diff = 0
|
||||
}
|
||||
for i := 0; i < diff; i++ {
|
||||
c.ensureSpace(true)
|
||||
}
|
||||
|
||||
// Reallocate the LRUs
|
||||
c.recent.Resize(size)
|
||||
c.frequent.Resize(size)
|
||||
c.recentEvict.Resize(evictSize)
|
||||
|
||||
return diff
|
||||
}
|
||||
|
||||
// Keys returns a slice of the keys in the cache.
|
||||
// The frequently used keys are first in the returned slice.
|
||||
func (c *TwoQueueCache[K, V]) Keys() []K {
|
||||
c.lock.RLock()
|
||||
defer c.lock.RUnlock()
|
||||
k1 := c.frequent.Keys()
|
||||
k2 := c.recent.Keys()
|
||||
return append(k1, k2...)
|
||||
}
|
||||
|
||||
// Values returns a slice of the values in the cache.
|
||||
// The frequently used values are first in the returned slice.
|
||||
func (c *TwoQueueCache[K, V]) Values() []V {
|
||||
c.lock.RLock()
|
||||
defer c.lock.RUnlock()
|
||||
v1 := c.frequent.Values()
|
||||
v2 := c.recent.Values()
|
||||
return append(v1, v2...)
|
||||
}
|
||||
|
||||
// Remove removes the provided key from the cache.
|
||||
func (c *TwoQueueCache[K, V]) Remove(key K) {
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
if c.frequent.Remove(key) {
|
||||
return
|
||||
}
|
||||
if c.recent.Remove(key) {
|
||||
return
|
||||
}
|
||||
if c.recentEvict.Remove(key) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Purge is used to completely clear the cache.
|
||||
func (c *TwoQueueCache[K, V]) Purge() {
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
c.recent.Purge()
|
||||
c.frequent.Purge()
|
||||
c.recentEvict.Purge()
|
||||
}
|
||||
|
||||
// Contains is used to check if the cache contains a key
|
||||
// without updating recency or frequency.
|
||||
func (c *TwoQueueCache[K, V]) Contains(key K) bool {
|
||||
c.lock.RLock()
|
||||
defer c.lock.RUnlock()
|
||||
return c.frequent.Contains(key) || c.recent.Contains(key)
|
||||
}
|
||||
|
||||
// Peek is used to inspect the cache value of a key
|
||||
// without updating recency or frequency.
|
||||
func (c *TwoQueueCache[K, V]) Peek(key K) (value V, ok bool) {
|
||||
c.lock.RLock()
|
||||
defer c.lock.RUnlock()
|
||||
if val, ok := c.frequent.Peek(key); ok {
|
||||
return val, ok
|
||||
}
|
||||
return c.recent.Peek(key)
|
||||
}
|
||||
364
vendor/github.com/hashicorp/golang-lru/v2/LICENSE
generated
vendored
Normal file
364
vendor/github.com/hashicorp/golang-lru/v2/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,364 @@
|
|||
Copyright (c) 2014 HashiCorp, Inc.
|
||||
|
||||
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.
|
||||
79
vendor/github.com/hashicorp/golang-lru/v2/README.md
generated
vendored
Normal file
79
vendor/github.com/hashicorp/golang-lru/v2/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
golang-lru
|
||||
==========
|
||||
|
||||
This provides the `lru` package which implements a fixed-size
|
||||
thread safe LRU cache. It is based on the cache in Groupcache.
|
||||
|
||||
Documentation
|
||||
=============
|
||||
|
||||
Full docs are available on [Go Packages](https://pkg.go.dev/github.com/hashicorp/golang-lru/v2)
|
||||
|
||||
LRU cache example
|
||||
=================
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hashicorp/golang-lru/v2"
|
||||
)
|
||||
|
||||
func main() {
|
||||
l, _ := lru.New[int, any](128)
|
||||
for i := 0; i < 256; i++ {
|
||||
l.Add(i, nil)
|
||||
}
|
||||
if l.Len() != 128 {
|
||||
panic(fmt.Sprintf("bad len: %v", l.Len()))
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Expirable LRU cache example
|
||||
===========================
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/golang-lru/v2/expirable"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// make cache with 10ms TTL and 5 max keys
|
||||
cache := expirable.NewLRU[string, string](5, nil, time.Millisecond*10)
|
||||
|
||||
|
||||
// set value under key1.
|
||||
cache.Add("key1", "val1")
|
||||
|
||||
// get value under key1
|
||||
r, ok := cache.Get("key1")
|
||||
|
||||
// check for OK value
|
||||
if ok {
|
||||
fmt.Printf("value before expiration is found: %v, value: %q\n", ok, r)
|
||||
}
|
||||
|
||||
// wait for cache to expire
|
||||
time.Sleep(time.Millisecond * 12)
|
||||
|
||||
// get value under key1 after key expiration
|
||||
r, ok = cache.Get("key1")
|
||||
fmt.Printf("value after expiration is found: %v, value: %q\n", ok, r)
|
||||
|
||||
// set value under key2, would evict old entry because it is already expired.
|
||||
cache.Add("key2", "val2")
|
||||
|
||||
fmt.Printf("Cache len: %d\n", cache.Len())
|
||||
// Output:
|
||||
// value before expiration is found: true, value: "val1"
|
||||
// value after expiration is found: false, value: ""
|
||||
// Cache len: 1
|
||||
}
|
||||
```
|
||||
24
vendor/github.com/hashicorp/golang-lru/v2/doc.go
generated
vendored
Normal file
24
vendor/github.com/hashicorp/golang-lru/v2/doc.go
generated
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
// Package lru provides three different LRU caches of varying sophistication.
|
||||
//
|
||||
// Cache is a simple LRU cache. It is based on the LRU implementation in
|
||||
// groupcache: https://github.com/golang/groupcache/tree/master/lru
|
||||
//
|
||||
// TwoQueueCache tracks frequently used and recently used entries separately.
|
||||
// This avoids a burst of accesses from taking out frequently used entries, at
|
||||
// the cost of about 2x computational overhead and some extra bookkeeping.
|
||||
//
|
||||
// ARCCache is an adaptive replacement cache. It tracks recent evictions as well
|
||||
// as recent usage in both the frequent and recent caches. Its computational
|
||||
// overhead is comparable to TwoQueueCache, but the memory overhead is linear
|
||||
// with the size of the cache.
|
||||
//
|
||||
// ARC has been patented by IBM, so do not use it if that is problematic for
|
||||
// your program. For this reason, it is in a separate go module contained within
|
||||
// this repository.
|
||||
//
|
||||
// All caches in this package take locks while operating, and are therefore
|
||||
// thread-safe for consumers.
|
||||
package lru
|
||||
142
vendor/github.com/hashicorp/golang-lru/v2/internal/list.go
generated
vendored
Normal file
142
vendor/github.com/hashicorp/golang-lru/v2/internal/list.go
generated
vendored
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
// Copyright 2009 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_list file.
|
||||
|
||||
package internal
|
||||
|
||||
import "time"
|
||||
|
||||
// Entry is an LRU Entry
|
||||
type Entry[K comparable, V any] struct {
|
||||
// Next and previous pointers in the doubly-linked list of elements.
|
||||
// To simplify the implementation, internally a list l is implemented
|
||||
// as a ring, such that &l.root is both the next element of the last
|
||||
// list element (l.Back()) and the previous element of the first list
|
||||
// element (l.Front()).
|
||||
next, prev *Entry[K, V]
|
||||
|
||||
// The list to which this element belongs.
|
||||
list *LruList[K, V]
|
||||
|
||||
// The LRU Key of this element.
|
||||
Key K
|
||||
|
||||
// The Value stored with this element.
|
||||
Value V
|
||||
|
||||
// The time this element would be cleaned up, optional
|
||||
ExpiresAt time.Time
|
||||
|
||||
// The expiry bucket item was put in, optional
|
||||
ExpireBucket uint8
|
||||
}
|
||||
|
||||
// PrevEntry returns the previous list element or nil.
|
||||
func (e *Entry[K, V]) PrevEntry() *Entry[K, V] {
|
||||
if p := e.prev; e.list != nil && p != &e.list.root {
|
||||
return p
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// LruList represents a doubly linked list.
|
||||
// The zero Value for LruList is an empty list ready to use.
|
||||
type LruList[K comparable, V any] struct {
|
||||
root Entry[K, V] // sentinel list element, only &root, root.prev, and root.next are used
|
||||
len int // current list Length excluding (this) sentinel element
|
||||
}
|
||||
|
||||
// Init initializes or clears list l.
|
||||
func (l *LruList[K, V]) Init() *LruList[K, V] {
|
||||
l.root.next = &l.root
|
||||
l.root.prev = &l.root
|
||||
l.len = 0
|
||||
return l
|
||||
}
|
||||
|
||||
// NewList returns an initialized list.
|
||||
func NewList[K comparable, V any]() *LruList[K, V] { return new(LruList[K, V]).Init() }
|
||||
|
||||
// Length returns the number of elements of list l.
|
||||
// The complexity is O(1).
|
||||
func (l *LruList[K, V]) Length() int { return l.len }
|
||||
|
||||
// Back returns the last element of list l or nil if the list is empty.
|
||||
func (l *LruList[K, V]) Back() *Entry[K, V] {
|
||||
if l.len == 0 {
|
||||
return nil
|
||||
}
|
||||
return l.root.prev
|
||||
}
|
||||
|
||||
// lazyInit lazily initializes a zero List Value.
|
||||
func (l *LruList[K, V]) lazyInit() {
|
||||
if l.root.next == nil {
|
||||
l.Init()
|
||||
}
|
||||
}
|
||||
|
||||
// insert inserts e after at, increments l.len, and returns e.
|
||||
func (l *LruList[K, V]) insert(e, at *Entry[K, V]) *Entry[K, V] {
|
||||
e.prev = at
|
||||
e.next = at.next
|
||||
e.prev.next = e
|
||||
e.next.prev = e
|
||||
e.list = l
|
||||
l.len++
|
||||
return e
|
||||
}
|
||||
|
||||
// insertValue is a convenience wrapper for insert(&Entry{Value: v, ExpiresAt: ExpiresAt}, at).
|
||||
func (l *LruList[K, V]) insertValue(k K, v V, expiresAt time.Time, at *Entry[K, V]) *Entry[K, V] {
|
||||
return l.insert(&Entry[K, V]{Value: v, Key: k, ExpiresAt: expiresAt}, at)
|
||||
}
|
||||
|
||||
// Remove removes e from its list, decrements l.len
|
||||
func (l *LruList[K, V]) Remove(e *Entry[K, V]) V {
|
||||
e.prev.next = e.next
|
||||
e.next.prev = e.prev
|
||||
e.next = nil // avoid memory leaks
|
||||
e.prev = nil // avoid memory leaks
|
||||
e.list = nil
|
||||
l.len--
|
||||
|
||||
return e.Value
|
||||
}
|
||||
|
||||
// move moves e to next to at.
|
||||
func (l *LruList[K, V]) move(e, at *Entry[K, V]) {
|
||||
if e == at {
|
||||
return
|
||||
}
|
||||
e.prev.next = e.next
|
||||
e.next.prev = e.prev
|
||||
|
||||
e.prev = at
|
||||
e.next = at.next
|
||||
e.prev.next = e
|
||||
e.next.prev = e
|
||||
}
|
||||
|
||||
// PushFront inserts a new element e with value v at the front of list l and returns e.
|
||||
func (l *LruList[K, V]) PushFront(k K, v V) *Entry[K, V] {
|
||||
l.lazyInit()
|
||||
return l.insertValue(k, v, time.Time{}, &l.root)
|
||||
}
|
||||
|
||||
// PushFrontExpirable inserts a new expirable element e with Value v at the front of list l and returns e.
|
||||
func (l *LruList[K, V]) PushFrontExpirable(k K, v V, expiresAt time.Time) *Entry[K, V] {
|
||||
l.lazyInit()
|
||||
return l.insertValue(k, v, expiresAt, &l.root)
|
||||
}
|
||||
|
||||
// MoveToFront moves element e to the front of list l.
|
||||
// If e is not an element of l, the list is not modified.
|
||||
// The element must not be nil.
|
||||
func (l *LruList[K, V]) MoveToFront(e *Entry[K, V]) {
|
||||
if e.list != l || l.root.next == e {
|
||||
return
|
||||
}
|
||||
// see comment in List.Remove about initialization of l
|
||||
l.move(e, &l.root)
|
||||
}
|
||||
250
vendor/github.com/hashicorp/golang-lru/v2/lru.go
generated
vendored
Normal file
250
vendor/github.com/hashicorp/golang-lru/v2/lru.go
generated
vendored
Normal file
|
|
@ -0,0 +1,250 @@
|
|||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
package lru
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/hashicorp/golang-lru/v2/simplelru"
|
||||
)
|
||||
|
||||
const (
|
||||
// DefaultEvictedBufferSize defines the default buffer size to store evicted key/val
|
||||
DefaultEvictedBufferSize = 16
|
||||
)
|
||||
|
||||
// Cache is a thread-safe fixed size LRU cache.
|
||||
type Cache[K comparable, V any] struct {
|
||||
lru *simplelru.LRU[K, V]
|
||||
evictedKeys []K
|
||||
evictedVals []V
|
||||
onEvictedCB func(k K, v V)
|
||||
lock sync.RWMutex
|
||||
}
|
||||
|
||||
// New creates an LRU of the given size.
|
||||
func New[K comparable, V any](size int) (*Cache[K, V], error) {
|
||||
return NewWithEvict[K, V](size, nil)
|
||||
}
|
||||
|
||||
// NewWithEvict constructs a fixed size cache with the given eviction
|
||||
// callback.
|
||||
func NewWithEvict[K comparable, V any](size int, onEvicted func(key K, value V)) (c *Cache[K, V], err error) {
|
||||
// create a cache with default settings
|
||||
c = &Cache[K, V]{
|
||||
onEvictedCB: onEvicted,
|
||||
}
|
||||
if onEvicted != nil {
|
||||
c.initEvictBuffers()
|
||||
onEvicted = c.onEvicted
|
||||
}
|
||||
c.lru, err = simplelru.NewLRU(size, onEvicted)
|
||||
return
|
||||
}
|
||||
|
||||
func (c *Cache[K, V]) initEvictBuffers() {
|
||||
c.evictedKeys = make([]K, 0, DefaultEvictedBufferSize)
|
||||
c.evictedVals = make([]V, 0, DefaultEvictedBufferSize)
|
||||
}
|
||||
|
||||
// onEvicted save evicted key/val and sent in externally registered callback
|
||||
// outside of critical section
|
||||
func (c *Cache[K, V]) onEvicted(k K, v V) {
|
||||
c.evictedKeys = append(c.evictedKeys, k)
|
||||
c.evictedVals = append(c.evictedVals, v)
|
||||
}
|
||||
|
||||
// Purge is used to completely clear the cache.
|
||||
func (c *Cache[K, V]) Purge() {
|
||||
var ks []K
|
||||
var vs []V
|
||||
c.lock.Lock()
|
||||
c.lru.Purge()
|
||||
if c.onEvictedCB != nil && len(c.evictedKeys) > 0 {
|
||||
ks, vs = c.evictedKeys, c.evictedVals
|
||||
c.initEvictBuffers()
|
||||
}
|
||||
c.lock.Unlock()
|
||||
// invoke callback outside of critical section
|
||||
if c.onEvictedCB != nil {
|
||||
for i := 0; i < len(ks); i++ {
|
||||
c.onEvictedCB(ks[i], vs[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add adds a value to the cache. Returns true if an eviction occurred.
|
||||
func (c *Cache[K, V]) Add(key K, value V) (evicted bool) {
|
||||
var k K
|
||||
var v V
|
||||
c.lock.Lock()
|
||||
evicted = c.lru.Add(key, value)
|
||||
if c.onEvictedCB != nil && evicted {
|
||||
k, v = c.evictedKeys[0], c.evictedVals[0]
|
||||
c.evictedKeys, c.evictedVals = c.evictedKeys[:0], c.evictedVals[:0]
|
||||
}
|
||||
c.lock.Unlock()
|
||||
if c.onEvictedCB != nil && evicted {
|
||||
c.onEvictedCB(k, v)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Get looks up a key's value from the cache.
|
||||
func (c *Cache[K, V]) Get(key K) (value V, ok bool) {
|
||||
c.lock.Lock()
|
||||
value, ok = c.lru.Get(key)
|
||||
c.lock.Unlock()
|
||||
return value, ok
|
||||
}
|
||||
|
||||
// Contains checks if a key is in the cache, without updating the
|
||||
// recent-ness or deleting it for being stale.
|
||||
func (c *Cache[K, V]) Contains(key K) bool {
|
||||
c.lock.RLock()
|
||||
containKey := c.lru.Contains(key)
|
||||
c.lock.RUnlock()
|
||||
return containKey
|
||||
}
|
||||
|
||||
// Peek returns the key value (or undefined if not found) without updating
|
||||
// the "recently used"-ness of the key.
|
||||
func (c *Cache[K, V]) Peek(key K) (value V, ok bool) {
|
||||
c.lock.RLock()
|
||||
value, ok = c.lru.Peek(key)
|
||||
c.lock.RUnlock()
|
||||
return value, ok
|
||||
}
|
||||
|
||||
// ContainsOrAdd checks if a key is in the cache without updating the
|
||||
// recent-ness or deleting it for being stale, and if not, adds the value.
|
||||
// Returns whether found and whether an eviction occurred.
|
||||
func (c *Cache[K, V]) ContainsOrAdd(key K, value V) (ok, evicted bool) {
|
||||
var k K
|
||||
var v V
|
||||
c.lock.Lock()
|
||||
if c.lru.Contains(key) {
|
||||
c.lock.Unlock()
|
||||
return true, false
|
||||
}
|
||||
evicted = c.lru.Add(key, value)
|
||||
if c.onEvictedCB != nil && evicted {
|
||||
k, v = c.evictedKeys[0], c.evictedVals[0]
|
||||
c.evictedKeys, c.evictedVals = c.evictedKeys[:0], c.evictedVals[:0]
|
||||
}
|
||||
c.lock.Unlock()
|
||||
if c.onEvictedCB != nil && evicted {
|
||||
c.onEvictedCB(k, v)
|
||||
}
|
||||
return false, evicted
|
||||
}
|
||||
|
||||
// PeekOrAdd checks if a key is in the cache without updating the
|
||||
// recent-ness or deleting it for being stale, and if not, adds the value.
|
||||
// Returns whether found and whether an eviction occurred.
|
||||
func (c *Cache[K, V]) PeekOrAdd(key K, value V) (previous V, ok, evicted bool) {
|
||||
var k K
|
||||
var v V
|
||||
c.lock.Lock()
|
||||
previous, ok = c.lru.Peek(key)
|
||||
if ok {
|
||||
c.lock.Unlock()
|
||||
return previous, true, false
|
||||
}
|
||||
evicted = c.lru.Add(key, value)
|
||||
if c.onEvictedCB != nil && evicted {
|
||||
k, v = c.evictedKeys[0], c.evictedVals[0]
|
||||
c.evictedKeys, c.evictedVals = c.evictedKeys[:0], c.evictedVals[:0]
|
||||
}
|
||||
c.lock.Unlock()
|
||||
if c.onEvictedCB != nil && evicted {
|
||||
c.onEvictedCB(k, v)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Remove removes the provided key from the cache.
|
||||
func (c *Cache[K, V]) Remove(key K) (present bool) {
|
||||
var k K
|
||||
var v V
|
||||
c.lock.Lock()
|
||||
present = c.lru.Remove(key)
|
||||
if c.onEvictedCB != nil && present {
|
||||
k, v = c.evictedKeys[0], c.evictedVals[0]
|
||||
c.evictedKeys, c.evictedVals = c.evictedKeys[:0], c.evictedVals[:0]
|
||||
}
|
||||
c.lock.Unlock()
|
||||
if c.onEvictedCB != nil && present {
|
||||
c.onEvictedCB(k, v)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Resize changes the cache size.
|
||||
func (c *Cache[K, V]) Resize(size int) (evicted int) {
|
||||
var ks []K
|
||||
var vs []V
|
||||
c.lock.Lock()
|
||||
evicted = c.lru.Resize(size)
|
||||
if c.onEvictedCB != nil && evicted > 0 {
|
||||
ks, vs = c.evictedKeys, c.evictedVals
|
||||
c.initEvictBuffers()
|
||||
}
|
||||
c.lock.Unlock()
|
||||
if c.onEvictedCB != nil && evicted > 0 {
|
||||
for i := 0; i < len(ks); i++ {
|
||||
c.onEvictedCB(ks[i], vs[i])
|
||||
}
|
||||
}
|
||||
return evicted
|
||||
}
|
||||
|
||||
// RemoveOldest removes the oldest item from the cache.
|
||||
func (c *Cache[K, V]) RemoveOldest() (key K, value V, ok bool) {
|
||||
var k K
|
||||
var v V
|
||||
c.lock.Lock()
|
||||
key, value, ok = c.lru.RemoveOldest()
|
||||
if c.onEvictedCB != nil && ok {
|
||||
k, v = c.evictedKeys[0], c.evictedVals[0]
|
||||
c.evictedKeys, c.evictedVals = c.evictedKeys[:0], c.evictedVals[:0]
|
||||
}
|
||||
c.lock.Unlock()
|
||||
if c.onEvictedCB != nil && ok {
|
||||
c.onEvictedCB(k, v)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// GetOldest returns the oldest entry
|
||||
func (c *Cache[K, V]) GetOldest() (key K, value V, ok bool) {
|
||||
c.lock.RLock()
|
||||
key, value, ok = c.lru.GetOldest()
|
||||
c.lock.RUnlock()
|
||||
return
|
||||
}
|
||||
|
||||
// Keys returns a slice of the keys in the cache, from oldest to newest.
|
||||
func (c *Cache[K, V]) Keys() []K {
|
||||
c.lock.RLock()
|
||||
keys := c.lru.Keys()
|
||||
c.lock.RUnlock()
|
||||
return keys
|
||||
}
|
||||
|
||||
// Values returns a slice of the values in the cache, from oldest to newest.
|
||||
func (c *Cache[K, V]) Values() []V {
|
||||
c.lock.RLock()
|
||||
values := c.lru.Values()
|
||||
c.lock.RUnlock()
|
||||
return values
|
||||
}
|
||||
|
||||
// Len returns the number of items in the cache.
|
||||
func (c *Cache[K, V]) Len() int {
|
||||
c.lock.RLock()
|
||||
length := c.lru.Len()
|
||||
c.lock.RUnlock()
|
||||
return length
|
||||
}
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
Copyright (c) 2017 The CC Authors. All rights reserved.
|
||||
This license applies to simplelru/list.go
|
||||
|
||||
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
|
||||
|
|
@ -10,7 +12,7 @@ notice, this list of conditions and the following disclaimer.
|
|||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the names of the authors nor the names of the
|
||||
* 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.
|
||||
|
||||
177
vendor/github.com/hashicorp/golang-lru/v2/simplelru/lru.go
generated
vendored
Normal file
177
vendor/github.com/hashicorp/golang-lru/v2/simplelru/lru.go
generated
vendored
Normal file
|
|
@ -0,0 +1,177 @@
|
|||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
package simplelru
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/hashicorp/golang-lru/v2/internal"
|
||||
)
|
||||
|
||||
// EvictCallback is used to get a callback when a cache entry is evicted
|
||||
type EvictCallback[K comparable, V any] func(key K, value V)
|
||||
|
||||
// LRU implements a non-thread safe fixed size LRU cache
|
||||
type LRU[K comparable, V any] struct {
|
||||
size int
|
||||
evictList *internal.LruList[K, V]
|
||||
items map[K]*internal.Entry[K, V]
|
||||
onEvict EvictCallback[K, V]
|
||||
}
|
||||
|
||||
// NewLRU constructs an LRU of the given size
|
||||
func NewLRU[K comparable, V any](size int, onEvict EvictCallback[K, V]) (*LRU[K, V], error) {
|
||||
if size <= 0 {
|
||||
return nil, errors.New("must provide a positive size")
|
||||
}
|
||||
|
||||
c := &LRU[K, V]{
|
||||
size: size,
|
||||
evictList: internal.NewList[K, V](),
|
||||
items: make(map[K]*internal.Entry[K, V]),
|
||||
onEvict: onEvict,
|
||||
}
|
||||
return c, nil
|
||||
}
|
||||
|
||||
// Purge is used to completely clear the cache.
|
||||
func (c *LRU[K, V]) Purge() {
|
||||
for k, v := range c.items {
|
||||
if c.onEvict != nil {
|
||||
c.onEvict(k, v.Value)
|
||||
}
|
||||
delete(c.items, k)
|
||||
}
|
||||
c.evictList.Init()
|
||||
}
|
||||
|
||||
// Add adds a value to the cache. Returns true if an eviction occurred.
|
||||
func (c *LRU[K, V]) Add(key K, value V) (evicted bool) {
|
||||
// Check for existing item
|
||||
if ent, ok := c.items[key]; ok {
|
||||
c.evictList.MoveToFront(ent)
|
||||
ent.Value = value
|
||||
return false
|
||||
}
|
||||
|
||||
// Add new item
|
||||
ent := c.evictList.PushFront(key, value)
|
||||
c.items[key] = ent
|
||||
|
||||
evict := c.evictList.Length() > c.size
|
||||
// Verify size not exceeded
|
||||
if evict {
|
||||
c.removeOldest()
|
||||
}
|
||||
return evict
|
||||
}
|
||||
|
||||
// Get looks up a key's value from the cache.
|
||||
func (c *LRU[K, V]) Get(key K) (value V, ok bool) {
|
||||
if ent, ok := c.items[key]; ok {
|
||||
c.evictList.MoveToFront(ent)
|
||||
return ent.Value, true
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Contains checks if a key is in the cache, without updating the recent-ness
|
||||
// or deleting it for being stale.
|
||||
func (c *LRU[K, V]) Contains(key K) (ok bool) {
|
||||
_, ok = c.items[key]
|
||||
return ok
|
||||
}
|
||||
|
||||
// Peek returns the key value (or undefined if not found) without updating
|
||||
// the "recently used"-ness of the key.
|
||||
func (c *LRU[K, V]) Peek(key K) (value V, ok bool) {
|
||||
var ent *internal.Entry[K, V]
|
||||
if ent, ok = c.items[key]; ok {
|
||||
return ent.Value, true
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Remove removes the provided key from the cache, returning if the
|
||||
// key was contained.
|
||||
func (c *LRU[K, V]) Remove(key K) (present bool) {
|
||||
if ent, ok := c.items[key]; ok {
|
||||
c.removeElement(ent)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// RemoveOldest removes the oldest item from the cache.
|
||||
func (c *LRU[K, V]) RemoveOldest() (key K, value V, ok bool) {
|
||||
if ent := c.evictList.Back(); ent != nil {
|
||||
c.removeElement(ent)
|
||||
return ent.Key, ent.Value, true
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// GetOldest returns the oldest entry
|
||||
func (c *LRU[K, V]) GetOldest() (key K, value V, ok bool) {
|
||||
if ent := c.evictList.Back(); ent != nil {
|
||||
return ent.Key, ent.Value, true
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Keys returns a slice of the keys in the cache, from oldest to newest.
|
||||
func (c *LRU[K, V]) Keys() []K {
|
||||
keys := make([]K, c.evictList.Length())
|
||||
i := 0
|
||||
for ent := c.evictList.Back(); ent != nil; ent = ent.PrevEntry() {
|
||||
keys[i] = ent.Key
|
||||
i++
|
||||
}
|
||||
return keys
|
||||
}
|
||||
|
||||
// Values returns a slice of the values in the cache, from oldest to newest.
|
||||
func (c *LRU[K, V]) Values() []V {
|
||||
values := make([]V, len(c.items))
|
||||
i := 0
|
||||
for ent := c.evictList.Back(); ent != nil; ent = ent.PrevEntry() {
|
||||
values[i] = ent.Value
|
||||
i++
|
||||
}
|
||||
return values
|
||||
}
|
||||
|
||||
// Len returns the number of items in the cache.
|
||||
func (c *LRU[K, V]) Len() int {
|
||||
return c.evictList.Length()
|
||||
}
|
||||
|
||||
// Resize changes the cache size.
|
||||
func (c *LRU[K, V]) Resize(size int) (evicted int) {
|
||||
diff := c.Len() - size
|
||||
if diff < 0 {
|
||||
diff = 0
|
||||
}
|
||||
for i := 0; i < diff; i++ {
|
||||
c.removeOldest()
|
||||
}
|
||||
c.size = size
|
||||
return diff
|
||||
}
|
||||
|
||||
// removeOldest removes the oldest item from the cache.
|
||||
func (c *LRU[K, V]) removeOldest() {
|
||||
if ent := c.evictList.Back(); ent != nil {
|
||||
c.removeElement(ent)
|
||||
}
|
||||
}
|
||||
|
||||
// removeElement is used to remove a given list element from the cache
|
||||
func (c *LRU[K, V]) removeElement(e *internal.Entry[K, V]) {
|
||||
c.evictList.Remove(e)
|
||||
delete(c.items, e.Key)
|
||||
if c.onEvict != nil {
|
||||
c.onEvict(e.Key, e.Value)
|
||||
}
|
||||
}
|
||||
46
vendor/github.com/hashicorp/golang-lru/v2/simplelru/lru_interface.go
generated
vendored
Normal file
46
vendor/github.com/hashicorp/golang-lru/v2/simplelru/lru_interface.go
generated
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
// Package simplelru provides simple LRU implementation based on build-in container/list.
|
||||
package simplelru
|
||||
|
||||
// LRUCache is the interface for simple LRU cache.
|
||||
type LRUCache[K comparable, V any] interface {
|
||||
// Adds a value to the cache, returns true if an eviction occurred and
|
||||
// updates the "recently used"-ness of the key.
|
||||
Add(key K, value V) bool
|
||||
|
||||
// Returns key's value from the cache and
|
||||
// updates the "recently used"-ness of the key. #value, isFound
|
||||
Get(key K) (value V, ok bool)
|
||||
|
||||
// Checks if a key exists in cache without updating the recent-ness.
|
||||
Contains(key K) (ok bool)
|
||||
|
||||
// Returns key's value without updating the "recently used"-ness of the key.
|
||||
Peek(key K) (value V, ok bool)
|
||||
|
||||
// Removes a key from the cache.
|
||||
Remove(key K) bool
|
||||
|
||||
// Removes the oldest entry from cache.
|
||||
RemoveOldest() (K, V, bool)
|
||||
|
||||
// Returns the oldest entry from the cache. #key, value, isFound
|
||||
GetOldest() (K, V, bool)
|
||||
|
||||
// Returns a slice of the keys in the cache, from oldest to newest.
|
||||
Keys() []K
|
||||
|
||||
// Values returns a slice of the values in the cache, from oldest to newest.
|
||||
Values() []V
|
||||
|
||||
// Returns the number of items in the cache.
|
||||
Len() int
|
||||
|
||||
// Clears all cache entries.
|
||||
Purge()
|
||||
|
||||
// Resizes cache, returning number evicted
|
||||
Resize(int) int
|
||||
}
|
||||
19
vendor/github.com/kballard/go-shellquote/LICENSE
generated
vendored
19
vendor/github.com/kballard/go-shellquote/LICENSE
generated
vendored
|
|
@ -1,19 +0,0 @@
|
|||
Copyright (C) 2014 Kevin Ballard
|
||||
|
||||
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.
|
||||
36
vendor/github.com/kballard/go-shellquote/README
generated
vendored
36
vendor/github.com/kballard/go-shellquote/README
generated
vendored
|
|
@ -1,36 +0,0 @@
|
|||
PACKAGE
|
||||
|
||||
package shellquote
|
||||
import "github.com/kballard/go-shellquote"
|
||||
|
||||
Shellquote provides utilities for joining/splitting strings using sh's
|
||||
word-splitting rules.
|
||||
|
||||
VARIABLES
|
||||
|
||||
var (
|
||||
UnterminatedSingleQuoteError = errors.New("Unterminated single-quoted string")
|
||||
UnterminatedDoubleQuoteError = errors.New("Unterminated double-quoted string")
|
||||
UnterminatedEscapeError = errors.New("Unterminated backslash-escape")
|
||||
)
|
||||
|
||||
|
||||
FUNCTIONS
|
||||
|
||||
func Join(args ...string) string
|
||||
Join quotes each argument and joins them with a space. If passed to
|
||||
/bin/sh, the resulting string will be split back into the original
|
||||
arguments.
|
||||
|
||||
func Split(input string) (words []string, err error)
|
||||
Split splits a string according to /bin/sh's word-splitting rules. It
|
||||
supports backslash-escapes, single-quotes, and double-quotes. Notably it
|
||||
does not support the $'' style of quoting. It also doesn't attempt to
|
||||
perform any other sort of expansion, including brace expansion, shell
|
||||
expansion, or pathname expansion.
|
||||
|
||||
If the given input has an unterminated quoted string or ends in a
|
||||
backslash-escape, one of UnterminatedSingleQuoteError,
|
||||
UnterminatedDoubleQuoteError, or UnterminatedEscapeError is returned.
|
||||
|
||||
|
||||
3
vendor/github.com/kballard/go-shellquote/doc.go
generated
vendored
3
vendor/github.com/kballard/go-shellquote/doc.go
generated
vendored
|
|
@ -1,3 +0,0 @@
|
|||
// Shellquote provides utilities for joining/splitting strings using sh's
|
||||
// word-splitting rules.
|
||||
package shellquote
|
||||
102
vendor/github.com/kballard/go-shellquote/quote.go
generated
vendored
102
vendor/github.com/kballard/go-shellquote/quote.go
generated
vendored
|
|
@ -1,102 +0,0 @@
|
|||
package shellquote
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
// Join quotes each argument and joins them with a space.
|
||||
// If passed to /bin/sh, the resulting string will be split back into the
|
||||
// original arguments.
|
||||
func Join(args ...string) string {
|
||||
var buf bytes.Buffer
|
||||
for i, arg := range args {
|
||||
if i != 0 {
|
||||
buf.WriteByte(' ')
|
||||
}
|
||||
quote(arg, &buf)
|
||||
}
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
const (
|
||||
specialChars = "\\'\"`${[|&;<>()*?!"
|
||||
extraSpecialChars = " \t\n"
|
||||
prefixChars = "~"
|
||||
)
|
||||
|
||||
func quote(word string, buf *bytes.Buffer) {
|
||||
// We want to try to produce a "nice" output. As such, we will
|
||||
// backslash-escape most characters, but if we encounter a space, or if we
|
||||
// encounter an extra-special char (which doesn't work with
|
||||
// backslash-escaping) we switch over to quoting the whole word. We do this
|
||||
// with a space because it's typically easier for people to read multi-word
|
||||
// arguments when quoted with a space rather than with ugly backslashes
|
||||
// everywhere.
|
||||
origLen := buf.Len()
|
||||
|
||||
if len(word) == 0 {
|
||||
// oops, no content
|
||||
buf.WriteString("''")
|
||||
return
|
||||
}
|
||||
|
||||
cur, prev := word, word
|
||||
atStart := true
|
||||
for len(cur) > 0 {
|
||||
c, l := utf8.DecodeRuneInString(cur)
|
||||
cur = cur[l:]
|
||||
if strings.ContainsRune(specialChars, c) || (atStart && strings.ContainsRune(prefixChars, c)) {
|
||||
// copy the non-special chars up to this point
|
||||
if len(cur) < len(prev) {
|
||||
buf.WriteString(prev[0 : len(prev)-len(cur)-l])
|
||||
}
|
||||
buf.WriteByte('\\')
|
||||
buf.WriteRune(c)
|
||||
prev = cur
|
||||
} else if strings.ContainsRune(extraSpecialChars, c) {
|
||||
// start over in quote mode
|
||||
buf.Truncate(origLen)
|
||||
goto quote
|
||||
}
|
||||
atStart = false
|
||||
}
|
||||
if len(prev) > 0 {
|
||||
buf.WriteString(prev)
|
||||
}
|
||||
return
|
||||
|
||||
quote:
|
||||
// quote mode
|
||||
// Use single-quotes, but if we find a single-quote in the word, we need
|
||||
// to terminate the string, emit an escaped quote, and start the string up
|
||||
// again
|
||||
inQuote := false
|
||||
for len(word) > 0 {
|
||||
i := strings.IndexRune(word, '\'')
|
||||
if i == -1 {
|
||||
break
|
||||
}
|
||||
if i > 0 {
|
||||
if !inQuote {
|
||||
buf.WriteByte('\'')
|
||||
inQuote = true
|
||||
}
|
||||
buf.WriteString(word[0:i])
|
||||
}
|
||||
word = word[i+1:]
|
||||
if inQuote {
|
||||
buf.WriteByte('\'')
|
||||
inQuote = false
|
||||
}
|
||||
buf.WriteString("\\'")
|
||||
}
|
||||
if len(word) > 0 {
|
||||
if !inQuote {
|
||||
buf.WriteByte('\'')
|
||||
}
|
||||
buf.WriteString(word)
|
||||
buf.WriteByte('\'')
|
||||
}
|
||||
}
|
||||
156
vendor/github.com/kballard/go-shellquote/unquote.go
generated
vendored
156
vendor/github.com/kballard/go-shellquote/unquote.go
generated
vendored
|
|
@ -1,156 +0,0 @@
|
|||
package shellquote
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
var (
|
||||
UnterminatedSingleQuoteError = errors.New("Unterminated single-quoted string")
|
||||
UnterminatedDoubleQuoteError = errors.New("Unterminated double-quoted string")
|
||||
UnterminatedEscapeError = errors.New("Unterminated backslash-escape")
|
||||
)
|
||||
|
||||
var (
|
||||
splitChars = " \n\t"
|
||||
singleChar = '\''
|
||||
doubleChar = '"'
|
||||
escapeChar = '\\'
|
||||
doubleEscapeChars = "$`\"\n\\"
|
||||
)
|
||||
|
||||
// Split splits a string according to /bin/sh's word-splitting rules. It
|
||||
// supports backslash-escapes, single-quotes, and double-quotes. Notably it does
|
||||
// not support the $'' style of quoting. It also doesn't attempt to perform any
|
||||
// other sort of expansion, including brace expansion, shell expansion, or
|
||||
// pathname expansion.
|
||||
//
|
||||
// If the given input has an unterminated quoted string or ends in a
|
||||
// backslash-escape, one of UnterminatedSingleQuoteError,
|
||||
// UnterminatedDoubleQuoteError, or UnterminatedEscapeError is returned.
|
||||
func Split(input string) (words []string, err error) {
|
||||
var buf bytes.Buffer
|
||||
words = make([]string, 0)
|
||||
|
||||
for len(input) > 0 {
|
||||
// skip any splitChars at the start
|
||||
c, l := utf8.DecodeRuneInString(input)
|
||||
if strings.ContainsRune(splitChars, c) {
|
||||
input = input[l:]
|
||||
continue
|
||||
} else if c == escapeChar {
|
||||
// Look ahead for escaped newline so we can skip over it
|
||||
next := input[l:]
|
||||
if len(next) == 0 {
|
||||
err = UnterminatedEscapeError
|
||||
return
|
||||
}
|
||||
c2, l2 := utf8.DecodeRuneInString(next)
|
||||
if c2 == '\n' {
|
||||
input = next[l2:]
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
var word string
|
||||
word, input, err = splitWord(input, &buf)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
words = append(words, word)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func splitWord(input string, buf *bytes.Buffer) (word string, remainder string, err error) {
|
||||
buf.Reset()
|
||||
|
||||
raw:
|
||||
{
|
||||
cur := input
|
||||
for len(cur) > 0 {
|
||||
c, l := utf8.DecodeRuneInString(cur)
|
||||
cur = cur[l:]
|
||||
if c == singleChar {
|
||||
buf.WriteString(input[0 : len(input)-len(cur)-l])
|
||||
input = cur
|
||||
goto single
|
||||
} else if c == doubleChar {
|
||||
buf.WriteString(input[0 : len(input)-len(cur)-l])
|
||||
input = cur
|
||||
goto double
|
||||
} else if c == escapeChar {
|
||||
buf.WriteString(input[0 : len(input)-len(cur)-l])
|
||||
input = cur
|
||||
goto escape
|
||||
} else if strings.ContainsRune(splitChars, c) {
|
||||
buf.WriteString(input[0 : len(input)-len(cur)-l])
|
||||
return buf.String(), cur, nil
|
||||
}
|
||||
}
|
||||
if len(input) > 0 {
|
||||
buf.WriteString(input)
|
||||
input = ""
|
||||
}
|
||||
goto done
|
||||
}
|
||||
|
||||
escape:
|
||||
{
|
||||
if len(input) == 0 {
|
||||
return "", "", UnterminatedEscapeError
|
||||
}
|
||||
c, l := utf8.DecodeRuneInString(input)
|
||||
if c == '\n' {
|
||||
// a backslash-escaped newline is elided from the output entirely
|
||||
} else {
|
||||
buf.WriteString(input[:l])
|
||||
}
|
||||
input = input[l:]
|
||||
}
|
||||
goto raw
|
||||
|
||||
single:
|
||||
{
|
||||
i := strings.IndexRune(input, singleChar)
|
||||
if i == -1 {
|
||||
return "", "", UnterminatedSingleQuoteError
|
||||
}
|
||||
buf.WriteString(input[0:i])
|
||||
input = input[i+1:]
|
||||
goto raw
|
||||
}
|
||||
|
||||
double:
|
||||
{
|
||||
cur := input
|
||||
for len(cur) > 0 {
|
||||
c, l := utf8.DecodeRuneInString(cur)
|
||||
cur = cur[l:]
|
||||
if c == doubleChar {
|
||||
buf.WriteString(input[0 : len(input)-len(cur)-l])
|
||||
input = cur
|
||||
goto raw
|
||||
} else if c == escapeChar {
|
||||
// bash only supports certain escapes in double-quoted strings
|
||||
c2, l2 := utf8.DecodeRuneInString(cur)
|
||||
cur = cur[l2:]
|
||||
if strings.ContainsRune(doubleEscapeChars, c2) {
|
||||
buf.WriteString(input[0 : len(input)-len(cur)-l-l2])
|
||||
if c2 == '\n' {
|
||||
// newline is special, skip the backslash entirely
|
||||
} else {
|
||||
buf.WriteRune(c2)
|
||||
}
|
||||
input = cur
|
||||
}
|
||||
}
|
||||
}
|
||||
return "", "", UnterminatedDoubleQuoteError
|
||||
}
|
||||
|
||||
done:
|
||||
return buf.String(), input, nil
|
||||
}
|
||||
15
vendor/github.com/ncruces/go-strftime/.gitignore
generated
vendored
Normal file
15
vendor/github.com/ncruces/go-strftime/.gitignore
generated
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# Binaries for programs and plugins
|
||||
*.exe
|
||||
*.exe~
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
# Test binary, built with `go test -c`
|
||||
*.test
|
||||
|
||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||
*.out
|
||||
|
||||
# Dependency directories (remove the comment below to include it)
|
||||
# vendor/
|
||||
12
vendor/lukechampine.com/uint128/LICENSE → vendor/github.com/ncruces/go-strftime/LICENSE
generated
vendored
12
vendor/lukechampine.com/uint128/LICENSE → vendor/github.com/ncruces/go-strftime/LICENSE
generated
vendored
|
|
@ -1,6 +1,6 @@
|
|||
The MIT License (MIT)
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 Luke Champine
|
||||
Copyright (c) 2022 Nuno Cruces
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
@ -9,13 +9,13 @@ 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 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.
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
5
vendor/github.com/ncruces/go-strftime/README.md
generated
vendored
Normal file
5
vendor/github.com/ncruces/go-strftime/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# `strftime`/`strptime` compatible time formatting and parsing for Go
|
||||
|
||||
[](https://pkg.go.dev/github.com/ncruces/go-strftime)
|
||||
[](https://goreportcard.com/report/github.com/ncruces/go-strftime)
|
||||
[](https://raw.githack.com/wiki/ncruces/go-strftime/coverage.html)
|
||||
107
vendor/github.com/ncruces/go-strftime/parser.go
generated
vendored
Normal file
107
vendor/github.com/ncruces/go-strftime/parser.go
generated
vendored
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
package strftime
|
||||
|
||||
import "unicode/utf8"
|
||||
|
||||
type parser struct {
|
||||
format func(spec, flag byte) error
|
||||
literal func(byte) error
|
||||
}
|
||||
|
||||
func (p *parser) parse(fmt string) error {
|
||||
const (
|
||||
initial = iota
|
||||
percent
|
||||
flagged
|
||||
modified
|
||||
)
|
||||
|
||||
var flag, modifier byte
|
||||
var err error
|
||||
state := initial
|
||||
start := 0
|
||||
for i, b := range []byte(fmt) {
|
||||
switch state {
|
||||
default:
|
||||
if b == '%' {
|
||||
state = percent
|
||||
start = i
|
||||
continue
|
||||
}
|
||||
err = p.literal(b)
|
||||
|
||||
case percent:
|
||||
if b == '-' || b == ':' {
|
||||
state = flagged
|
||||
flag = b
|
||||
continue
|
||||
}
|
||||
if b == 'E' || b == 'O' {
|
||||
state = modified
|
||||
modifier = b
|
||||
flag = 0
|
||||
continue
|
||||
}
|
||||
err = p.format(b, 0)
|
||||
state = initial
|
||||
|
||||
case flagged:
|
||||
if b == 'E' || b == 'O' {
|
||||
state = modified
|
||||
modifier = b
|
||||
continue
|
||||
}
|
||||
err = p.format(b, flag)
|
||||
state = initial
|
||||
|
||||
case modified:
|
||||
if okModifier(modifier, b) {
|
||||
err = p.format(b, flag)
|
||||
} else {
|
||||
err = p.literals(fmt[start : i+1])
|
||||
}
|
||||
state = initial
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
if err, ok := err.(formatError); ok {
|
||||
err.setDirective(fmt, start, i)
|
||||
return err
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if state != initial {
|
||||
return p.literals(fmt[start:])
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *parser) literals(literal string) error {
|
||||
for _, b := range []byte(literal) {
|
||||
if err := p.literal(b); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type literalErr string
|
||||
|
||||
func (e literalErr) Error() string {
|
||||
return "strftime: unsupported literal: " + string(e)
|
||||
}
|
||||
|
||||
type formatError struct {
|
||||
message string
|
||||
directive string
|
||||
}
|
||||
|
||||
func (e formatError) Error() string {
|
||||
return "strftime: unsupported directive: " + e.directive + " " + e.message
|
||||
}
|
||||
|
||||
func (e *formatError) setDirective(str string, i, j int) {
|
||||
_, n := utf8.DecodeRuneInString(str[j:])
|
||||
e.directive = str[i : j+n]
|
||||
}
|
||||
96
vendor/github.com/ncruces/go-strftime/pkg.go
generated
vendored
Normal file
96
vendor/github.com/ncruces/go-strftime/pkg.go
generated
vendored
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
Package strftime provides strftime/strptime compatible time formatting and parsing.
|
||||
|
||||
The following specifiers are available:
|
||||
|
||||
Date (Year, Month, Day):
|
||||
%Y - Year with century (can be negative, 4 digits at least)
|
||||
-0001, 0000, 1995, 2009, 14292, etc.
|
||||
%C - year / 100 (round down, 20 in 2009)
|
||||
%y - year % 100 (00..99)
|
||||
|
||||
%m - Month of the year, zero-padded (01..12)
|
||||
%-m no-padded (1..12)
|
||||
%B - Full month name (January)
|
||||
%b - Abbreviated month name (Jan)
|
||||
%h - Equivalent to %b
|
||||
|
||||
%d - Day of the month, zero-padded (01..31)
|
||||
%-d no-padded (1..31)
|
||||
%e - Day of the month, blank-padded ( 1..31)
|
||||
|
||||
%j - Day of the year (001..366)
|
||||
%-j no-padded (1..366)
|
||||
|
||||
Time (Hour, Minute, Second, Subsecond):
|
||||
%H - Hour of the day, 24-hour clock, zero-padded (00..23)
|
||||
%-H no-padded (0..23)
|
||||
%k - Hour of the day, 24-hour clock, blank-padded ( 0..23)
|
||||
%I - Hour of the day, 12-hour clock, zero-padded (01..12)
|
||||
%-I no-padded (1..12)
|
||||
%l - Hour of the day, 12-hour clock, blank-padded ( 1..12)
|
||||
%P - Meridian indicator, lowercase (am or pm)
|
||||
%p - Meridian indicator, uppercase (AM or PM)
|
||||
|
||||
%M - Minute of the hour (00..59)
|
||||
%-M no-padded (0..59)
|
||||
|
||||
%S - Second of the minute (00..60)
|
||||
%-S no-padded (0..60)
|
||||
|
||||
%L - Millisecond of the second (000..999)
|
||||
%f - Microsecond of the second (000000..999999)
|
||||
%N - Nanosecond of the second (000000000..999999999)
|
||||
|
||||
Time zone:
|
||||
%z - Time zone as hour and minute offset from UTC (e.g. +0900)
|
||||
%:z - hour and minute offset from UTC with a colon (e.g. +09:00)
|
||||
%Z - Time zone abbreviation (e.g. MST)
|
||||
|
||||
Weekday:
|
||||
%A - Full weekday name (Sunday)
|
||||
%a - Abbreviated weekday name (Sun)
|
||||
%u - Day of the week (Monday is 1, 1..7)
|
||||
%w - Day of the week (Sunday is 0, 0..6)
|
||||
|
||||
ISO 8601 week-based year and week number:
|
||||
Week 1 of YYYY starts with a Monday and includes YYYY-01-04.
|
||||
The days in the year before the first week are in the last week of
|
||||
the previous year.
|
||||
%G - Week-based year
|
||||
%g - Last 2 digits of the week-based year (00..99)
|
||||
%V - Week number of the week-based year (01..53)
|
||||
%-V no-padded (1..53)
|
||||
|
||||
Week number:
|
||||
Week 1 of YYYY starts with a Sunday or Monday (according to %U or %W).
|
||||
The days in the year before the first week are in week 0.
|
||||
%U - Week number of the year. The week starts with Sunday. (00..53)
|
||||
%-U no-padded (0..53)
|
||||
%W - Week number of the year. The week starts with Monday. (00..53)
|
||||
%-W no-padded (0..53)
|
||||
|
||||
Seconds since the Unix Epoch:
|
||||
%s - Number of seconds since 1970-01-01 00:00:00 UTC.
|
||||
%Q - Number of milliseconds since 1970-01-01 00:00:00 UTC.
|
||||
|
||||
Literal string:
|
||||
%n - Newline character (\n)
|
||||
%t - Tab character (\t)
|
||||
%% - Literal % character
|
||||
|
||||
Combination:
|
||||
%c - date and time (%a %b %e %T %Y)
|
||||
%D - Date (%m/%d/%y)
|
||||
%F - ISO 8601 date format (%Y-%m-%d)
|
||||
%v - VMS date (%e-%b-%Y)
|
||||
%x - Same as %D
|
||||
%X - Same as %T
|
||||
%r - 12-hour time (%I:%M:%S %p)
|
||||
%R - 24-hour time (%H:%M)
|
||||
%T - 24-hour time (%H:%M:%S)
|
||||
%+ - date(1) (%a %b %e %H:%M:%S %Z %Y)
|
||||
|
||||
The modifiers ``E'' and ``O'' are ignored.
|
||||
*/
|
||||
package strftime
|
||||
241
vendor/github.com/ncruces/go-strftime/specifiers.go
generated
vendored
Normal file
241
vendor/github.com/ncruces/go-strftime/specifiers.go
generated
vendored
Normal file
|
|
@ -0,0 +1,241 @@
|
|||
package strftime
|
||||
|
||||
import "strings"
|
||||
|
||||
// https://strftime.org/
|
||||
func goLayout(spec, flag byte, parsing bool) string {
|
||||
switch spec {
|
||||
default:
|
||||
return ""
|
||||
|
||||
case 'B':
|
||||
return "January"
|
||||
case 'b', 'h':
|
||||
return "Jan"
|
||||
case 'm':
|
||||
if flag == '-' || parsing {
|
||||
return "1"
|
||||
}
|
||||
return "01"
|
||||
case 'A':
|
||||
return "Monday"
|
||||
case 'a':
|
||||
return "Mon"
|
||||
case 'e':
|
||||
return "_2"
|
||||
case 'd':
|
||||
if flag == '-' || parsing {
|
||||
return "2"
|
||||
}
|
||||
return "02"
|
||||
case 'j':
|
||||
if flag == '-' {
|
||||
if parsing {
|
||||
return "__2"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
return "002"
|
||||
case 'I':
|
||||
if flag == '-' || parsing {
|
||||
return "3"
|
||||
}
|
||||
return "03"
|
||||
case 'H':
|
||||
if flag == '-' && !parsing {
|
||||
return ""
|
||||
}
|
||||
return "15"
|
||||
case 'M':
|
||||
if flag == '-' || parsing {
|
||||
return "4"
|
||||
}
|
||||
return "04"
|
||||
case 'S':
|
||||
if flag == '-' || parsing {
|
||||
return "5"
|
||||
}
|
||||
return "05"
|
||||
case 'y':
|
||||
return "06"
|
||||
case 'Y':
|
||||
return "2006"
|
||||
case 'p':
|
||||
return "PM"
|
||||
case 'P':
|
||||
return "pm"
|
||||
case 'Z':
|
||||
return "MST"
|
||||
case 'z':
|
||||
if flag == ':' {
|
||||
if parsing {
|
||||
return "Z07:00"
|
||||
}
|
||||
return "-07:00"
|
||||
}
|
||||
if parsing {
|
||||
return "Z0700"
|
||||
}
|
||||
return "-0700"
|
||||
|
||||
case '+':
|
||||
if parsing {
|
||||
return "Mon Jan _2 15:4:5 MST 2006"
|
||||
}
|
||||
return "Mon Jan _2 15:04:05 MST 2006"
|
||||
case 'c':
|
||||
if parsing {
|
||||
return "Mon Jan _2 15:4:5 2006"
|
||||
}
|
||||
return "Mon Jan _2 15:04:05 2006"
|
||||
case 'v':
|
||||
return "_2-Jan-2006"
|
||||
case 'F':
|
||||
if parsing {
|
||||
return "2006-1-2"
|
||||
}
|
||||
return "2006-01-02"
|
||||
case 'D', 'x':
|
||||
if parsing {
|
||||
return "1/2/06"
|
||||
}
|
||||
return "01/02/06"
|
||||
case 'r':
|
||||
if parsing {
|
||||
return "3:4:5 PM"
|
||||
}
|
||||
return "03:04:05 PM"
|
||||
case 'T', 'X':
|
||||
if parsing {
|
||||
return "15:4:5"
|
||||
}
|
||||
return "15:04:05"
|
||||
case 'R':
|
||||
if parsing {
|
||||
return "15:4"
|
||||
}
|
||||
return "15:04"
|
||||
|
||||
case '%':
|
||||
return "%"
|
||||
case 't':
|
||||
return "\t"
|
||||
case 'n':
|
||||
return "\n"
|
||||
}
|
||||
}
|
||||
|
||||
// https://nsdateformatter.com/
|
||||
func uts35Pattern(spec, flag byte) string {
|
||||
switch spec {
|
||||
default:
|
||||
return ""
|
||||
|
||||
case 'B':
|
||||
return "MMMM"
|
||||
case 'b', 'h':
|
||||
return "MMM"
|
||||
case 'm':
|
||||
if flag == '-' {
|
||||
return "M"
|
||||
}
|
||||
return "MM"
|
||||
case 'A':
|
||||
return "EEEE"
|
||||
case 'a':
|
||||
return "E"
|
||||
case 'd':
|
||||
if flag == '-' {
|
||||
return "d"
|
||||
}
|
||||
return "dd"
|
||||
case 'j':
|
||||
if flag == '-' {
|
||||
return "D"
|
||||
}
|
||||
return "DDD"
|
||||
case 'I':
|
||||
if flag == '-' {
|
||||
return "h"
|
||||
}
|
||||
return "hh"
|
||||
case 'H':
|
||||
if flag == '-' {
|
||||
return "H"
|
||||
}
|
||||
return "HH"
|
||||
case 'M':
|
||||
if flag == '-' {
|
||||
return "m"
|
||||
}
|
||||
return "mm"
|
||||
case 'S':
|
||||
if flag == '-' {
|
||||
return "s"
|
||||
}
|
||||
return "ss"
|
||||
case 'y':
|
||||
return "yy"
|
||||
case 'Y':
|
||||
return "yyyy"
|
||||
case 'g':
|
||||
return "YY"
|
||||
case 'G':
|
||||
return "YYYY"
|
||||
case 'V':
|
||||
if flag == '-' {
|
||||
return "w"
|
||||
}
|
||||
return "ww"
|
||||
case 'p':
|
||||
return "a"
|
||||
case 'Z':
|
||||
return "zzz"
|
||||
case 'z':
|
||||
if flag == ':' {
|
||||
return "xxx"
|
||||
}
|
||||
return "xx"
|
||||
case 'L':
|
||||
return "SSS"
|
||||
case 'f':
|
||||
return "SSSSSS"
|
||||
case 'N':
|
||||
return "SSSSSSSSS"
|
||||
|
||||
case '+':
|
||||
return "E MMM d HH:mm:ss zzz yyyy"
|
||||
case 'c':
|
||||
return "E MMM d HH:mm:ss yyyy"
|
||||
case 'v':
|
||||
return "d-MMM-yyyy"
|
||||
case 'F':
|
||||
return "yyyy-MM-dd"
|
||||
case 'D', 'x':
|
||||
return "MM/dd/yy"
|
||||
case 'r':
|
||||
return "hh:mm:ss a"
|
||||
case 'T', 'X':
|
||||
return "HH:mm:ss"
|
||||
case 'R':
|
||||
return "HH:mm"
|
||||
|
||||
case '%':
|
||||
return "%"
|
||||
case 't':
|
||||
return "\t"
|
||||
case 'n':
|
||||
return "\n"
|
||||
}
|
||||
}
|
||||
|
||||
// http://man.he.net/man3/strftime
|
||||
func okModifier(mod, spec byte) bool {
|
||||
if mod == 'E' {
|
||||
return strings.Contains("cCxXyY", string(spec))
|
||||
}
|
||||
if mod == 'O' {
|
||||
return strings.Contains("deHImMSuUVwWy", string(spec))
|
||||
}
|
||||
return false
|
||||
}
|
||||
324
vendor/github.com/ncruces/go-strftime/strftime.go
generated
vendored
Normal file
324
vendor/github.com/ncruces/go-strftime/strftime.go
generated
vendored
Normal file
|
|
@ -0,0 +1,324 @@
|
|||
package strftime
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Format returns a textual representation of the time value
|
||||
// formatted according to the strftime format specification.
|
||||
func Format(fmt string, t time.Time) string {
|
||||
buf := buffer(fmt)
|
||||
return string(AppendFormat(buf, fmt, t))
|
||||
}
|
||||
|
||||
// AppendFormat is like Format, but appends the textual representation
|
||||
// to dst and returns the extended buffer.
|
||||
func AppendFormat(dst []byte, fmt string, t time.Time) []byte {
|
||||
var parser parser
|
||||
|
||||
parser.literal = func(b byte) error {
|
||||
dst = append(dst, b)
|
||||
return nil
|
||||
}
|
||||
|
||||
parser.format = func(spec, flag byte) error {
|
||||
switch spec {
|
||||
case 'A':
|
||||
dst = append(dst, t.Weekday().String()...)
|
||||
return nil
|
||||
case 'a':
|
||||
dst = append(dst, t.Weekday().String()[:3]...)
|
||||
return nil
|
||||
case 'B':
|
||||
dst = append(dst, t.Month().String()...)
|
||||
return nil
|
||||
case 'b', 'h':
|
||||
dst = append(dst, t.Month().String()[:3]...)
|
||||
return nil
|
||||
case 'm':
|
||||
dst = appendInt2(dst, int(t.Month()), flag)
|
||||
return nil
|
||||
case 'd':
|
||||
dst = appendInt2(dst, int(t.Day()), flag)
|
||||
return nil
|
||||
case 'e':
|
||||
dst = appendInt2(dst, int(t.Day()), ' ')
|
||||
return nil
|
||||
case 'I':
|
||||
dst = append12Hour(dst, t, flag)
|
||||
return nil
|
||||
case 'l':
|
||||
dst = append12Hour(dst, t, ' ')
|
||||
return nil
|
||||
case 'H':
|
||||
dst = appendInt2(dst, t.Hour(), flag)
|
||||
return nil
|
||||
case 'k':
|
||||
dst = appendInt2(dst, t.Hour(), ' ')
|
||||
return nil
|
||||
case 'M':
|
||||
dst = appendInt2(dst, t.Minute(), flag)
|
||||
return nil
|
||||
case 'S':
|
||||
dst = appendInt2(dst, t.Second(), flag)
|
||||
return nil
|
||||
case 'L':
|
||||
dst = append(dst, t.Format(".000")[1:]...)
|
||||
return nil
|
||||
case 'f':
|
||||
dst = append(dst, t.Format(".000000")[1:]...)
|
||||
return nil
|
||||
case 'N':
|
||||
dst = append(dst, t.Format(".000000000")[1:]...)
|
||||
return nil
|
||||
case 'y':
|
||||
dst = t.AppendFormat(dst, "06")
|
||||
return nil
|
||||
case 'Y':
|
||||
dst = t.AppendFormat(dst, "2006")
|
||||
return nil
|
||||
case 'C':
|
||||
dst = t.AppendFormat(dst, "2006")
|
||||
dst = dst[:len(dst)-2]
|
||||
return nil
|
||||
case 'U':
|
||||
dst = appendWeekNumber(dst, t, flag, true)
|
||||
return nil
|
||||
case 'W':
|
||||
dst = appendWeekNumber(dst, t, flag, false)
|
||||
return nil
|
||||
case 'V':
|
||||
_, w := t.ISOWeek()
|
||||
dst = appendInt2(dst, w, flag)
|
||||
return nil
|
||||
case 'g':
|
||||
y, _ := t.ISOWeek()
|
||||
dst = year(y).AppendFormat(dst, "06")
|
||||
return nil
|
||||
case 'G':
|
||||
y, _ := t.ISOWeek()
|
||||
dst = year(y).AppendFormat(dst, "2006")
|
||||
return nil
|
||||
case 's':
|
||||
dst = strconv.AppendInt(dst, t.Unix(), 10)
|
||||
return nil
|
||||
case 'Q':
|
||||
dst = strconv.AppendInt(dst, t.UnixMilli(), 10)
|
||||
return nil
|
||||
case 'w':
|
||||
w := t.Weekday()
|
||||
dst = appendInt1(dst, int(w))
|
||||
return nil
|
||||
case 'u':
|
||||
if w := t.Weekday(); w == 0 {
|
||||
dst = append(dst, '7')
|
||||
} else {
|
||||
dst = appendInt1(dst, int(w))
|
||||
}
|
||||
return nil
|
||||
case 'j':
|
||||
if flag == '-' {
|
||||
dst = strconv.AppendInt(dst, int64(t.YearDay()), 10)
|
||||
} else {
|
||||
dst = t.AppendFormat(dst, "002")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
if layout := goLayout(spec, flag, false); layout != "" {
|
||||
dst = t.AppendFormat(dst, layout)
|
||||
return nil
|
||||
}
|
||||
|
||||
dst = append(dst, '%')
|
||||
if flag != 0 {
|
||||
dst = append(dst, flag)
|
||||
}
|
||||
dst = append(dst, spec)
|
||||
return nil
|
||||
}
|
||||
|
||||
parser.parse(fmt)
|
||||
return dst
|
||||
}
|
||||
|
||||
// Parse converts a textual representation of time to the time value it represents
|
||||
// according to the strptime format specification.
|
||||
func Parse(fmt, value string) (time.Time, error) {
|
||||
pattern, err := layout(fmt, true)
|
||||
if err != nil {
|
||||
return time.Time{}, err
|
||||
}
|
||||
return time.Parse(pattern, value)
|
||||
}
|
||||
|
||||
// Layout converts a strftime format specification
|
||||
// to a Go time pattern specification.
|
||||
func Layout(fmt string) (string, error) {
|
||||
return layout(fmt, false)
|
||||
}
|
||||
|
||||
func layout(fmt string, parsing bool) (string, error) {
|
||||
dst := buffer(fmt)
|
||||
var parser parser
|
||||
|
||||
parser.literal = func(b byte) error {
|
||||
if '0' <= b && b <= '9' {
|
||||
return literalErr(b)
|
||||
}
|
||||
dst = append(dst, b)
|
||||
if b == 'M' || b == 'T' || b == 'm' || b == 'n' {
|
||||
switch {
|
||||
case bytes.HasSuffix(dst, []byte("Jan")):
|
||||
return literalErr("Jan")
|
||||
case bytes.HasSuffix(dst, []byte("Mon")):
|
||||
return literalErr("Mon")
|
||||
case bytes.HasSuffix(dst, []byte("MST")):
|
||||
return literalErr("MST")
|
||||
case bytes.HasSuffix(dst, []byte("PM")):
|
||||
return literalErr("PM")
|
||||
case bytes.HasSuffix(dst, []byte("pm")):
|
||||
return literalErr("pm")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
parser.format = func(spec, flag byte) error {
|
||||
if layout := goLayout(spec, flag, parsing); layout != "" {
|
||||
dst = append(dst, layout...)
|
||||
return nil
|
||||
}
|
||||
|
||||
switch spec {
|
||||
default:
|
||||
return formatError{}
|
||||
|
||||
case 'L', 'f', 'N':
|
||||
if bytes.HasSuffix(dst, []byte(".")) || bytes.HasSuffix(dst, []byte(",")) {
|
||||
switch spec {
|
||||
default:
|
||||
dst = append(dst, "000"...)
|
||||
case 'f':
|
||||
dst = append(dst, "000000"...)
|
||||
case 'N':
|
||||
dst = append(dst, "000000000"...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return formatError{message: "must follow '.' or ','"}
|
||||
}
|
||||
}
|
||||
|
||||
if err := parser.parse(fmt); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(dst), nil
|
||||
}
|
||||
|
||||
// UTS35 converts a strftime format specification
|
||||
// to a Unicode Technical Standard #35 Date Format Pattern.
|
||||
func UTS35(fmt string) (string, error) {
|
||||
const quote = '\''
|
||||
var quoted bool
|
||||
dst := buffer(fmt)
|
||||
|
||||
var parser parser
|
||||
|
||||
parser.literal = func(b byte) error {
|
||||
if b == quote {
|
||||
dst = append(dst, quote, quote)
|
||||
return nil
|
||||
}
|
||||
if !quoted && ('a' <= b && b <= 'z' || 'A' <= b && b <= 'Z') {
|
||||
dst = append(dst, quote)
|
||||
quoted = true
|
||||
}
|
||||
dst = append(dst, b)
|
||||
return nil
|
||||
}
|
||||
|
||||
parser.format = func(spec, flag byte) error {
|
||||
if quoted {
|
||||
dst = append(dst, quote)
|
||||
quoted = false
|
||||
}
|
||||
if pattern := uts35Pattern(spec, flag); pattern != "" {
|
||||
dst = append(dst, pattern...)
|
||||
return nil
|
||||
}
|
||||
return formatError{}
|
||||
}
|
||||
|
||||
if err := parser.parse(fmt); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if quoted {
|
||||
dst = append(dst, quote)
|
||||
}
|
||||
return string(dst), nil
|
||||
}
|
||||
|
||||
func buffer(format string) (buf []byte) {
|
||||
const bufSize = 64
|
||||
max := len(format) + 10
|
||||
if max < bufSize {
|
||||
var b [bufSize]byte
|
||||
buf = b[:0]
|
||||
} else {
|
||||
buf = make([]byte, 0, max)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func year(y int) time.Time {
|
||||
return time.Date(y, time.January, 1, 0, 0, 0, 0, time.UTC)
|
||||
}
|
||||
|
||||
func appendWeekNumber(dst []byte, t time.Time, flag byte, sunday bool) []byte {
|
||||
offset := int(t.Weekday())
|
||||
if sunday {
|
||||
offset = 6 - offset
|
||||
} else if offset != 0 {
|
||||
offset = 7 - offset
|
||||
}
|
||||
return appendInt2(dst, (t.YearDay()+offset)/7, flag)
|
||||
}
|
||||
|
||||
func append12Hour(dst []byte, t time.Time, flag byte) []byte {
|
||||
h := t.Hour()
|
||||
if h == 0 {
|
||||
h = 12
|
||||
} else if h > 12 {
|
||||
h -= 12
|
||||
}
|
||||
return appendInt2(dst, h, flag)
|
||||
}
|
||||
|
||||
func appendInt1(dst []byte, i int) []byte {
|
||||
return append(dst, byte('0'+i))
|
||||
}
|
||||
|
||||
func appendInt2(dst []byte, i int, flag byte) []byte {
|
||||
if flag == 0 || i >= 10 {
|
||||
return append(dst, smallsString[i*2:i*2+2]...)
|
||||
}
|
||||
if flag == ' ' {
|
||||
dst = append(dst, flag)
|
||||
}
|
||||
return appendInt1(dst, i)
|
||||
}
|
||||
|
||||
const smallsString = "" +
|
||||
"00010203040506070809" +
|
||||
"10111213141516171819" +
|
||||
"20212223242526272829" +
|
||||
"30313233343536373839" +
|
||||
"40414243444546474849" +
|
||||
"50515253545556575859" +
|
||||
"60616263646566676869" +
|
||||
"70717273747576777879" +
|
||||
"80818283848586878889" +
|
||||
"90919293949596979899"
|
||||
46
vendor/lukechampine.com/uint128/README.md
generated
vendored
46
vendor/lukechampine.com/uint128/README.md
generated
vendored
|
|
@ -1,46 +0,0 @@
|
|||
uint128
|
||||
-------
|
||||
|
||||
[](https://godoc.org/github.com/lukechampine/uint128)
|
||||
[](https://goreportcard.com/report/github.com/lukechampine/uint128)
|
||||
|
||||
```
|
||||
go get lukechampine.com/uint128
|
||||
```
|
||||
|
||||
`uint128` provides a high-performance `Uint128` type that supports standard arithmetic
|
||||
operations. Unlike `math/big`, operations on `Uint128` values always produce new values
|
||||
instead of modifying a pointer receiver. A `Uint128` value is therefore immutable, just
|
||||
like `uint64` and friends.
|
||||
|
||||
The name `uint128.Uint128` stutters, so I recommend either using a "dot import"
|
||||
or aliasing `uint128.Uint128` to give it a project-specific name. Embedding the type
|
||||
is not recommended, because methods will still return `uint128.Uint128`; this means that,
|
||||
if you want to extend the type with new methods, your best bet is probably to copy the
|
||||
source code wholesale and rename the identifier. ¯\\\_(ツ)\_/¯
|
||||
|
||||
|
||||
# Benchmarks
|
||||
|
||||
Addition, multiplication, and subtraction are on par with their native 64-bit
|
||||
equivalents. Division is slower: ~20x slower when dividing a `Uint128` by a
|
||||
`uint64`, and ~100x slower when dividing by a `Uint128`. However, division is
|
||||
still faster than with `big.Int` (for the same operands), especially when
|
||||
dividing by a `uint64`.
|
||||
|
||||
```
|
||||
BenchmarkArithmetic/Add-4 2000000000 0.45 ns/op 0 B/op 0 allocs/op
|
||||
BenchmarkArithmetic/Sub-4 2000000000 0.67 ns/op 0 B/op 0 allocs/op
|
||||
BenchmarkArithmetic/Mul-4 2000000000 0.42 ns/op 0 B/op 0 allocs/op
|
||||
BenchmarkArithmetic/Lsh-4 2000000000 1.06 ns/op 0 B/op 0 allocs/op
|
||||
BenchmarkArithmetic/Rsh-4 2000000000 1.06 ns/op 0 B/op 0 allocs/op
|
||||
|
||||
BenchmarkDivision/native_64/64-4 2000000000 0.39 ns/op 0 B/op 0 allocs/op
|
||||
BenchmarkDivision/Div_128/64-4 2000000000 6.28 ns/op 0 B/op 0 allocs/op
|
||||
BenchmarkDivision/Div_128/128-4 30000000 45.2 ns/op 0 B/op 0 allocs/op
|
||||
BenchmarkDivision/big.Int_128/64-4 20000000 98.2 ns/op 8 B/op 1 allocs/op
|
||||
BenchmarkDivision/big.Int_128/128-4 30000000 53.4 ns/op 48 B/op 1 allocs/op
|
||||
|
||||
BenchmarkString/Uint128-4 10000000 173 ns/op 48 B/op 1 allocs/op
|
||||
BenchmarkString/big.Int-4 5000000 350 ns/op 144 B/op 3 allocs/op
|
||||
```
|
||||
440
vendor/lukechampine.com/uint128/uint128.go
generated
vendored
440
vendor/lukechampine.com/uint128/uint128.go
generated
vendored
|
|
@ -1,440 +0,0 @@
|
|||
package uint128 // import "lukechampine.com/uint128"
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"math/big"
|
||||
"math/bits"
|
||||
)
|
||||
|
||||
// Zero is a zero-valued uint128.
|
||||
var Zero Uint128
|
||||
|
||||
// Max is the largest possible uint128 value.
|
||||
var Max = New(math.MaxUint64, math.MaxUint64)
|
||||
|
||||
// A Uint128 is an unsigned 128-bit number.
|
||||
type Uint128 struct {
|
||||
Lo, Hi uint64
|
||||
}
|
||||
|
||||
// IsZero returns true if u == 0.
|
||||
func (u Uint128) IsZero() bool {
|
||||
// NOTE: we do not compare against Zero, because that is a global variable
|
||||
// that could be modified.
|
||||
return u == Uint128{}
|
||||
}
|
||||
|
||||
// Equals returns true if u == v.
|
||||
//
|
||||
// Uint128 values can be compared directly with ==, but use of the Equals method
|
||||
// is preferred for consistency.
|
||||
func (u Uint128) Equals(v Uint128) bool {
|
||||
return u == v
|
||||
}
|
||||
|
||||
// Equals64 returns true if u == v.
|
||||
func (u Uint128) Equals64(v uint64) bool {
|
||||
return u.Lo == v && u.Hi == 0
|
||||
}
|
||||
|
||||
// Cmp compares u and v and returns:
|
||||
//
|
||||
// -1 if u < v
|
||||
// 0 if u == v
|
||||
// +1 if u > v
|
||||
//
|
||||
func (u Uint128) Cmp(v Uint128) int {
|
||||
if u == v {
|
||||
return 0
|
||||
} else if u.Hi < v.Hi || (u.Hi == v.Hi && u.Lo < v.Lo) {
|
||||
return -1
|
||||
} else {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
// Cmp64 compares u and v and returns:
|
||||
//
|
||||
// -1 if u < v
|
||||
// 0 if u == v
|
||||
// +1 if u > v
|
||||
//
|
||||
func (u Uint128) Cmp64(v uint64) int {
|
||||
if u.Hi == 0 && u.Lo == v {
|
||||
return 0
|
||||
} else if u.Hi == 0 && u.Lo < v {
|
||||
return -1
|
||||
} else {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
// And returns u&v.
|
||||
func (u Uint128) And(v Uint128) Uint128 {
|
||||
return Uint128{u.Lo & v.Lo, u.Hi & v.Hi}
|
||||
}
|
||||
|
||||
// And64 returns u&v.
|
||||
func (u Uint128) And64(v uint64) Uint128 {
|
||||
return Uint128{u.Lo & v, u.Hi & 0}
|
||||
}
|
||||
|
||||
// Or returns u|v.
|
||||
func (u Uint128) Or(v Uint128) Uint128 {
|
||||
return Uint128{u.Lo | v.Lo, u.Hi | v.Hi}
|
||||
}
|
||||
|
||||
// Or64 returns u|v.
|
||||
func (u Uint128) Or64(v uint64) Uint128 {
|
||||
return Uint128{u.Lo | v, u.Hi | 0}
|
||||
}
|
||||
|
||||
// Xor returns u^v.
|
||||
func (u Uint128) Xor(v Uint128) Uint128 {
|
||||
return Uint128{u.Lo ^ v.Lo, u.Hi ^ v.Hi}
|
||||
}
|
||||
|
||||
// Xor64 returns u^v.
|
||||
func (u Uint128) Xor64(v uint64) Uint128 {
|
||||
return Uint128{u.Lo ^ v, u.Hi ^ 0}
|
||||
}
|
||||
|
||||
// Add returns u+v.
|
||||
func (u Uint128) Add(v Uint128) Uint128 {
|
||||
lo, carry := bits.Add64(u.Lo, v.Lo, 0)
|
||||
hi, carry := bits.Add64(u.Hi, v.Hi, carry)
|
||||
if carry != 0 {
|
||||
panic("overflow")
|
||||
}
|
||||
return Uint128{lo, hi}
|
||||
}
|
||||
|
||||
// AddWrap returns u+v with wraparound semantics; for example,
|
||||
// Max.AddWrap(From64(1)) == Zero.
|
||||
func (u Uint128) AddWrap(v Uint128) Uint128 {
|
||||
lo, carry := bits.Add64(u.Lo, v.Lo, 0)
|
||||
hi, _ := bits.Add64(u.Hi, v.Hi, carry)
|
||||
return Uint128{lo, hi}
|
||||
}
|
||||
|
||||
// Add64 returns u+v.
|
||||
func (u Uint128) Add64(v uint64) Uint128 {
|
||||
lo, carry := bits.Add64(u.Lo, v, 0)
|
||||
hi, carry := bits.Add64(u.Hi, 0, carry)
|
||||
if carry != 0 {
|
||||
panic("overflow")
|
||||
}
|
||||
return Uint128{lo, hi}
|
||||
}
|
||||
|
||||
// AddWrap64 returns u+v with wraparound semantics; for example,
|
||||
// Max.AddWrap64(1) == Zero.
|
||||
func (u Uint128) AddWrap64(v uint64) Uint128 {
|
||||
lo, carry := bits.Add64(u.Lo, v, 0)
|
||||
hi := u.Hi + carry
|
||||
return Uint128{lo, hi}
|
||||
}
|
||||
|
||||
// Sub returns u-v.
|
||||
func (u Uint128) Sub(v Uint128) Uint128 {
|
||||
lo, borrow := bits.Sub64(u.Lo, v.Lo, 0)
|
||||
hi, borrow := bits.Sub64(u.Hi, v.Hi, borrow)
|
||||
if borrow != 0 {
|
||||
panic("underflow")
|
||||
}
|
||||
return Uint128{lo, hi}
|
||||
}
|
||||
|
||||
// SubWrap returns u-v with wraparound semantics; for example,
|
||||
// Zero.SubWrap(From64(1)) == Max.
|
||||
func (u Uint128) SubWrap(v Uint128) Uint128 {
|
||||
lo, borrow := bits.Sub64(u.Lo, v.Lo, 0)
|
||||
hi, _ := bits.Sub64(u.Hi, v.Hi, borrow)
|
||||
return Uint128{lo, hi}
|
||||
}
|
||||
|
||||
// Sub64 returns u-v.
|
||||
func (u Uint128) Sub64(v uint64) Uint128 {
|
||||
lo, borrow := bits.Sub64(u.Lo, v, 0)
|
||||
hi, borrow := bits.Sub64(u.Hi, 0, borrow)
|
||||
if borrow != 0 {
|
||||
panic("underflow")
|
||||
}
|
||||
return Uint128{lo, hi}
|
||||
}
|
||||
|
||||
// SubWrap64 returns u-v with wraparound semantics; for example,
|
||||
// Zero.SubWrap64(1) == Max.
|
||||
func (u Uint128) SubWrap64(v uint64) Uint128 {
|
||||
lo, borrow := bits.Sub64(u.Lo, v, 0)
|
||||
hi := u.Hi - borrow
|
||||
return Uint128{lo, hi}
|
||||
}
|
||||
|
||||
// Mul returns u*v, panicking on overflow.
|
||||
func (u Uint128) Mul(v Uint128) Uint128 {
|
||||
hi, lo := bits.Mul64(u.Lo, v.Lo)
|
||||
p0, p1 := bits.Mul64(u.Hi, v.Lo)
|
||||
p2, p3 := bits.Mul64(u.Lo, v.Hi)
|
||||
hi, c0 := bits.Add64(hi, p1, 0)
|
||||
hi, c1 := bits.Add64(hi, p3, c0)
|
||||
if (u.Hi != 0 && v.Hi != 0) || p0 != 0 || p2 != 0 || c1 != 0 {
|
||||
panic("overflow")
|
||||
}
|
||||
return Uint128{lo, hi}
|
||||
}
|
||||
|
||||
// MulWrap returns u*v with wraparound semantics; for example,
|
||||
// Max.MulWrap(Max) == 1.
|
||||
func (u Uint128) MulWrap(v Uint128) Uint128 {
|
||||
hi, lo := bits.Mul64(u.Lo, v.Lo)
|
||||
hi += u.Hi*v.Lo + u.Lo*v.Hi
|
||||
return Uint128{lo, hi}
|
||||
}
|
||||
|
||||
// Mul64 returns u*v, panicking on overflow.
|
||||
func (u Uint128) Mul64(v uint64) Uint128 {
|
||||
hi, lo := bits.Mul64(u.Lo, v)
|
||||
p0, p1 := bits.Mul64(u.Hi, v)
|
||||
hi, c0 := bits.Add64(hi, p1, 0)
|
||||
if p0 != 0 || c0 != 0 {
|
||||
panic("overflow")
|
||||
}
|
||||
return Uint128{lo, hi}
|
||||
}
|
||||
|
||||
// MulWrap64 returns u*v with wraparound semantics; for example,
|
||||
// Max.MulWrap64(2) == Max.Sub64(1).
|
||||
func (u Uint128) MulWrap64(v uint64) Uint128 {
|
||||
hi, lo := bits.Mul64(u.Lo, v)
|
||||
hi += u.Hi * v
|
||||
return Uint128{lo, hi}
|
||||
}
|
||||
|
||||
// Div returns u/v.
|
||||
func (u Uint128) Div(v Uint128) Uint128 {
|
||||
q, _ := u.QuoRem(v)
|
||||
return q
|
||||
}
|
||||
|
||||
// Div64 returns u/v.
|
||||
func (u Uint128) Div64(v uint64) Uint128 {
|
||||
q, _ := u.QuoRem64(v)
|
||||
return q
|
||||
}
|
||||
|
||||
// QuoRem returns q = u/v and r = u%v.
|
||||
func (u Uint128) QuoRem(v Uint128) (q, r Uint128) {
|
||||
if v.Hi == 0 {
|
||||
var r64 uint64
|
||||
q, r64 = u.QuoRem64(v.Lo)
|
||||
r = From64(r64)
|
||||
} else {
|
||||
// generate a "trial quotient," guaranteed to be within 1 of the actual
|
||||
// quotient, then adjust.
|
||||
n := uint(bits.LeadingZeros64(v.Hi))
|
||||
v1 := v.Lsh(n)
|
||||
u1 := u.Rsh(1)
|
||||
tq, _ := bits.Div64(u1.Hi, u1.Lo, v1.Hi)
|
||||
tq >>= 63 - n
|
||||
if tq != 0 {
|
||||
tq--
|
||||
}
|
||||
q = From64(tq)
|
||||
// calculate remainder using trial quotient, then adjust if remainder is
|
||||
// greater than divisor
|
||||
r = u.Sub(v.Mul64(tq))
|
||||
if r.Cmp(v) >= 0 {
|
||||
q = q.Add64(1)
|
||||
r = r.Sub(v)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// QuoRem64 returns q = u/v and r = u%v.
|
||||
func (u Uint128) QuoRem64(v uint64) (q Uint128, r uint64) {
|
||||
if u.Hi < v {
|
||||
q.Lo, r = bits.Div64(u.Hi, u.Lo, v)
|
||||
} else {
|
||||
q.Hi, r = bits.Div64(0, u.Hi, v)
|
||||
q.Lo, r = bits.Div64(r, u.Lo, v)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Mod returns r = u%v.
|
||||
func (u Uint128) Mod(v Uint128) (r Uint128) {
|
||||
_, r = u.QuoRem(v)
|
||||
return
|
||||
}
|
||||
|
||||
// Mod64 returns r = u%v.
|
||||
func (u Uint128) Mod64(v uint64) (r uint64) {
|
||||
_, r = u.QuoRem64(v)
|
||||
return
|
||||
}
|
||||
|
||||
// Lsh returns u<<n.
|
||||
func (u Uint128) Lsh(n uint) (s Uint128) {
|
||||
if n > 64 {
|
||||
s.Lo = 0
|
||||
s.Hi = u.Lo << (n - 64)
|
||||
} else {
|
||||
s.Lo = u.Lo << n
|
||||
s.Hi = u.Hi<<n | u.Lo>>(64-n)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Rsh returns u>>n.
|
||||
func (u Uint128) Rsh(n uint) (s Uint128) {
|
||||
if n > 64 {
|
||||
s.Lo = u.Hi >> (n - 64)
|
||||
s.Hi = 0
|
||||
} else {
|
||||
s.Lo = u.Lo>>n | u.Hi<<(64-n)
|
||||
s.Hi = u.Hi >> n
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// LeadingZeros returns the number of leading zero bits in u; the result is 128
|
||||
// for u == 0.
|
||||
func (u Uint128) LeadingZeros() int {
|
||||
if u.Hi > 0 {
|
||||
return bits.LeadingZeros64(u.Hi)
|
||||
}
|
||||
return 64 + bits.LeadingZeros64(u.Lo)
|
||||
}
|
||||
|
||||
// TrailingZeros returns the number of trailing zero bits in u; the result is
|
||||
// 128 for u == 0.
|
||||
func (u Uint128) TrailingZeros() int {
|
||||
if u.Lo > 0 {
|
||||
return bits.TrailingZeros64(u.Lo)
|
||||
}
|
||||
return 64 + bits.TrailingZeros64(u.Hi)
|
||||
}
|
||||
|
||||
// OnesCount returns the number of one bits ("population count") in u.
|
||||
func (u Uint128) OnesCount() int {
|
||||
return bits.OnesCount64(u.Hi) + bits.OnesCount64(u.Lo)
|
||||
}
|
||||
|
||||
// RotateLeft returns the value of u rotated left by (k mod 128) bits.
|
||||
func (u Uint128) RotateLeft(k int) Uint128 {
|
||||
const n = 128
|
||||
s := uint(k) & (n - 1)
|
||||
return u.Lsh(s).Or(u.Rsh(n - s))
|
||||
}
|
||||
|
||||
// RotateRight returns the value of u rotated left by (k mod 128) bits.
|
||||
func (u Uint128) RotateRight(k int) Uint128 {
|
||||
return u.RotateLeft(-k)
|
||||
}
|
||||
|
||||
// Reverse returns the value of u with its bits in reversed order.
|
||||
func (u Uint128) Reverse() Uint128 {
|
||||
return Uint128{bits.Reverse64(u.Hi), bits.Reverse64(u.Lo)}
|
||||
}
|
||||
|
||||
// ReverseBytes returns the value of u with its bytes in reversed order.
|
||||
func (u Uint128) ReverseBytes() Uint128 {
|
||||
return Uint128{bits.ReverseBytes64(u.Hi), bits.ReverseBytes64(u.Lo)}
|
||||
}
|
||||
|
||||
// Len returns the minimum number of bits required to represent u; the result is
|
||||
// 0 for u == 0.
|
||||
func (u Uint128) Len() int {
|
||||
return 128 - u.LeadingZeros()
|
||||
}
|
||||
|
||||
// String returns the base-10 representation of u as a string.
|
||||
func (u Uint128) String() string {
|
||||
if u.IsZero() {
|
||||
return "0"
|
||||
}
|
||||
buf := []byte("0000000000000000000000000000000000000000") // log10(2^128) < 40
|
||||
for i := len(buf); ; i -= 19 {
|
||||
q, r := u.QuoRem64(1e19) // largest power of 10 that fits in a uint64
|
||||
var n int
|
||||
for ; r != 0; r /= 10 {
|
||||
n++
|
||||
buf[i-n] += byte(r % 10)
|
||||
}
|
||||
if q.IsZero() {
|
||||
return string(buf[i-n:])
|
||||
}
|
||||
u = q
|
||||
}
|
||||
}
|
||||
|
||||
// PutBytes stores u in b in little-endian order. It panics if len(b) < 16.
|
||||
func (u Uint128) PutBytes(b []byte) {
|
||||
binary.LittleEndian.PutUint64(b[:8], u.Lo)
|
||||
binary.LittleEndian.PutUint64(b[8:], u.Hi)
|
||||
}
|
||||
|
||||
// Big returns u as a *big.Int.
|
||||
func (u Uint128) Big() *big.Int {
|
||||
i := new(big.Int).SetUint64(u.Hi)
|
||||
i = i.Lsh(i, 64)
|
||||
i = i.Xor(i, new(big.Int).SetUint64(u.Lo))
|
||||
return i
|
||||
}
|
||||
|
||||
// Scan implements fmt.Scanner.
|
||||
func (u *Uint128) Scan(s fmt.ScanState, ch rune) error {
|
||||
i := new(big.Int)
|
||||
if err := i.Scan(s, ch); err != nil {
|
||||
return err
|
||||
} else if i.Sign() < 0 {
|
||||
return errors.New("value cannot be negative")
|
||||
} else if i.BitLen() > 128 {
|
||||
return errors.New("value overflows Uint128")
|
||||
}
|
||||
u.Lo = i.Uint64()
|
||||
u.Hi = i.Rsh(i, 64).Uint64()
|
||||
return nil
|
||||
}
|
||||
|
||||
// New returns the Uint128 value (lo,hi).
|
||||
func New(lo, hi uint64) Uint128 {
|
||||
return Uint128{lo, hi}
|
||||
}
|
||||
|
||||
// From64 converts v to a Uint128 value.
|
||||
func From64(v uint64) Uint128 {
|
||||
return New(v, 0)
|
||||
}
|
||||
|
||||
// FromBytes converts b to a Uint128 value.
|
||||
func FromBytes(b []byte) Uint128 {
|
||||
return New(
|
||||
binary.LittleEndian.Uint64(b[:8]),
|
||||
binary.LittleEndian.Uint64(b[8:]),
|
||||
)
|
||||
}
|
||||
|
||||
// FromBig converts i to a Uint128 value. It panics if i is negative or
|
||||
// overflows 128 bits.
|
||||
func FromBig(i *big.Int) (u Uint128) {
|
||||
if i.Sign() < 0 {
|
||||
panic("value cannot be negative")
|
||||
} else if i.BitLen() > 128 {
|
||||
panic("value overflows Uint128")
|
||||
}
|
||||
u.Lo = i.Uint64()
|
||||
u.Hi = i.Rsh(i, 64).Uint64()
|
||||
return u
|
||||
}
|
||||
|
||||
// FromString parses s as a Uint128 value.
|
||||
func FromString(s string) (u Uint128, err error) {
|
||||
_, err = fmt.Sscan(s, &u)
|
||||
return
|
||||
}
|
||||
19
vendor/modernc.org/cc/v3/AUTHORS
generated
vendored
19
vendor/modernc.org/cc/v3/AUTHORS
generated
vendored
|
|
@ -1,19 +0,0 @@
|
|||
# This file lists authors for copyright purposes. This file is distinct from
|
||||
# the CONTRIBUTORS files. See the latter for an explanation.
|
||||
#
|
||||
# Names should be added to this file as:
|
||||
# Name or Organization <email address>
|
||||
#
|
||||
# The email address is not required for organizations.
|
||||
#
|
||||
# Please keep the list sorted.
|
||||
|
||||
Dan Kortschak <dan.kortschak@adelaide.edu.au>
|
||||
Dan Peterson <danp@danp.net>
|
||||
Denys Smirnov <denis.smirnov.91@gmail.com>
|
||||
Jan Mercl <0xjnml@gmail.com>
|
||||
Maxim Kupriianov <max@kc.vc>
|
||||
Peter Waller <p@pwaller.net>
|
||||
Steffen Butzer <steffen(dot)butzer@outlook.com>
|
||||
Tommi Virtanen <tv@eagain.net>
|
||||
Yasuhiro Matsumoto <mattn.jp@gmail.com>
|
||||
19
vendor/modernc.org/cc/v3/CONTRIBUTORS
generated
vendored
19
vendor/modernc.org/cc/v3/CONTRIBUTORS
generated
vendored
|
|
@ -1,19 +0,0 @@
|
|||
# This file lists people who contributed code to this repository. The AUTHORS
|
||||
# file lists the copyright holders; this file lists people.
|
||||
#
|
||||
# Names should be added to this file like so:
|
||||
# Name <email address>
|
||||
#
|
||||
# Please keep the list sorted.
|
||||
|
||||
Dan Kortschak <dan.kortschak@adelaide.edu.au>
|
||||
Dan Peterson <danp@danp.net>
|
||||
Denys Smirnov <denis.smirnov.91@gmail.com>
|
||||
Jan Mercl <0xjnml@gmail.com>
|
||||
Maxim Kupriianov <max@kc.vc>
|
||||
Peter Waller <p@pwaller.net>
|
||||
Steffen Butzer <steffen(dot)butzer@outlook.com>
|
||||
Tommi Virtanen <tv@eagain.net>
|
||||
Yasuhiro Matsumoto <mattn.jp@gmail.com>
|
||||
Zvi Effron <zeffron@cs.hmc.edu>
|
||||
Lucas Raab <tuftedocelot@fastmail.fm>
|
||||
135
vendor/modernc.org/cc/v3/Makefile
generated
vendored
135
vendor/modernc.org/cc/v3/Makefile
generated
vendored
|
|
@ -1,135 +0,0 @@
|
|||
# Copyright 2019 The CC Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style
|
||||
# license that can be found in the LICENSE file.
|
||||
|
||||
.PHONY: all bench clean cover cpu editor internalError later mem nuke todo edit devbench
|
||||
|
||||
grep=--include=*.go --include=*.l --include=*.y --include=*.yy
|
||||
ngrep='internalError\|TODOOK\|lexer\.go\|ast.go\|trigraphs\.go\|.*_string\.go\|stringer\.go\|testdata\/gcc'
|
||||
testlog=testdata/testlog-$(shell echo $$GOOS)-$(shell echo $$GOARCH)-on-$(shell go env GOOS)-$(shell go env GOARCH)
|
||||
|
||||
all: lexer.go
|
||||
LC_ALL=C make all_log 2>&1 | tee log
|
||||
|
||||
all_log:
|
||||
date
|
||||
go version
|
||||
uname -a
|
||||
./unconvert.sh
|
||||
gofmt -l -s -w *.go
|
||||
GOOS=darwin GOARCH=amd64 go build
|
||||
GOOS=darwin GOARCH=arm64 go build
|
||||
GOOS=linux GOARCH=386 go build
|
||||
GOOS=linux GOARCH=amd64 go build
|
||||
GOOS=linux GOARCH=arm go build
|
||||
GOOS=windows GOARCH=386 go build
|
||||
GOOS=windows GOARCH=amd64 go build
|
||||
go vet | grep -v $(ngrep) || true
|
||||
golint | grep -v $(ngrep) || true
|
||||
misspell *.go
|
||||
staticcheck | grep -v 'lexer\.go' || true
|
||||
pcregrep -nM 'FAIL|false|<nil>|:\n}' ast_test.go || true
|
||||
|
||||
test:
|
||||
go version | tee $(testlog)
|
||||
uname -a | tee -a $(testlog)
|
||||
go test -v -timeout 24h | tee -a $(testlog)
|
||||
grep -ni fail $(testlog) | tee -a $(testlog) || true
|
||||
LC_ALL=C date | tee -a $(testlog)
|
||||
grep -ni --color=always fail $(testlog) || true
|
||||
|
||||
test_linux_amd64:
|
||||
GOOS=linux GOARCH=amd64 make test
|
||||
|
||||
test_linux_386:
|
||||
GOOS=linux GOARCH=386 make test
|
||||
|
||||
test_linux_arm:
|
||||
GOOS=linux GOARCH=arm make test
|
||||
|
||||
test_linux_arm64:
|
||||
GOOS=linux GOARCH=arm64 make test
|
||||
|
||||
test_windows_amd64:
|
||||
go version
|
||||
go test -v -timeout 24h
|
||||
|
||||
test_windows386:
|
||||
go version
|
||||
go test -v -timeout 24h
|
||||
|
||||
build_all_targets:
|
||||
GOOS=darwin GOARCH=amd64 go build -v ./...
|
||||
GOOS=darwin GOARCH=arm64 go build -v ./...
|
||||
GOOS=freebsd GOARCH=386 go build -v ./...
|
||||
GOOS=freebsd GOARCH=amd64 go build -v ./...
|
||||
GOOS=freebsd GOARCH=arm go build -v ./...
|
||||
GOOS=freebsd GOARCH=arm64 go build -v ./...
|
||||
GOOS=linux GOARCH=386 go build -v ./...
|
||||
GOOS=linux GOARCH=amd64 go build -v ./...
|
||||
GOOS=linux GOARCH=arm go build -v ./...
|
||||
GOOS=linux GOARCH=arm64 go build -v ./...
|
||||
GOOS=linux GOARCH=ppc64le go build -v ./...
|
||||
GOOS=linux GOARCH=riscv64 go build -v ./...
|
||||
GOOS=linux GOARCH=s390x go build -v ./...
|
||||
GOOS=netbsd GOARCH=amd64 go build -v ./...
|
||||
GOOS=netbsd GOARCH=arm go build -v ./...
|
||||
GOOS=netbsd GOARCH=386 go build -v ./...
|
||||
GOOS=openbsd GOARCH=amd64 go build -v ./...
|
||||
GOOS=openbsd GOARCH=arm64 go build -v ./...
|
||||
GOOS=openbsd GOARCH=386 go build -v ./...
|
||||
GOOS=windows GOARCH=386 go build -v ./...
|
||||
GOOS=windows GOARCH=amd64 go build -v ./...
|
||||
GOOS=windows GOARCH=arm64 go build -v ./...
|
||||
|
||||
devbench:
|
||||
date 2>&1 | tee log-devbench
|
||||
go test -timeout 24h -dev -run @ -bench . 2>&1 | tee -a log-devbench
|
||||
grep -n 'FAIL\|SKIP' log-devbench || true
|
||||
|
||||
bench:
|
||||
date 2>&1 | tee log-bench
|
||||
go test -timeout 24h -v -run '^[^E]' -bench . 2>&1 | tee -a log-bench
|
||||
grep -n 'FAIL\|SKIP' log-bench || true
|
||||
|
||||
clean:
|
||||
go clean
|
||||
rm -f *~ *.test *.out
|
||||
|
||||
cover:
|
||||
t=$(shell mktemp) ; go test -coverprofile $$t && go tool cover -html $$t && unlink $$t
|
||||
|
||||
cpu: clean
|
||||
go test -run @ -bench . -cpuprofile cpu.out
|
||||
go tool pprof -lines *.test cpu.out
|
||||
|
||||
edit:
|
||||
@touch log
|
||||
@if [ -f "Session.vim" ]; then gvim -S & else gvim -p Makefile *.go & fi
|
||||
|
||||
editor: lexer.go
|
||||
gofmt -l -s -w *.go
|
||||
go test -o /dev/null -c
|
||||
go install 2>&1 | tee log
|
||||
|
||||
ast.go lexer.go stringer.go: lexer.l parser.yy enum.go
|
||||
go generate
|
||||
|
||||
later:
|
||||
@grep -n $(grep) LATER * || true
|
||||
@grep -n $(grep) MAYBE * || true
|
||||
|
||||
mem: clean
|
||||
# go test -v -run ParserCS -csmith 2m -memprofile mem.out -timeout 24h
|
||||
# go test -v -run @ -bench BenchmarkScanner -memprofile mem.out -timeout 24h
|
||||
go test -v -run TestTranslateSQLite -memprofile mem.out -timeout 24h
|
||||
go tool pprof -lines -web -alloc_space *.test mem.out
|
||||
|
||||
nuke: clean
|
||||
go clean -i
|
||||
|
||||
todo:
|
||||
@grep -nr $(grep) ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* * | grep -v $(ngrep) || true
|
||||
@grep -nr $(grep) 'TODO\|panic' * | grep -v $(ngrep) || true
|
||||
@grep -nr $(grep) BUG * | grep -v $(ngrep) || true
|
||||
@grep -nr $(grep) [^[:alpha:]]println * | grep -v $(ngrep) || true
|
||||
11
vendor/modernc.org/cc/v3/README.md
generated
vendored
11
vendor/modernc.org/cc/v3/README.md
generated
vendored
|
|
@ -1,11 +0,0 @@
|
|||
# cc/v3
|
||||
|
||||
Package CC is a C99 compiler front end.
|
||||
|
||||
Most of the functionality is now working.
|
||||
|
||||
Installation
|
||||
|
||||
$ go get -u modernc.org/cc/v3
|
||||
|
||||
Documentation: [godoc.org/modernc.org/cc/v3](http://godoc.org/modernc.org/cc/v3)
|
||||
1026
vendor/modernc.org/cc/v3/abi.go
generated
vendored
1026
vendor/modernc.org/cc/v3/abi.go
generated
vendored
File diff suppressed because it is too large
Load diff
790
vendor/modernc.org/cc/v3/abi_platforms.go
generated
vendored
790
vendor/modernc.org/cc/v3/abi_platforms.go
generated
vendored
|
|
@ -1,790 +0,0 @@
|
|||
package cc
|
||||
|
||||
import "encoding/binary"
|
||||
|
||||
// abiByteOrders contains byte order information for known architectures.
|
||||
var (
|
||||
abiByteOrders = map[string]binary.ByteOrder{
|
||||
"386": binary.LittleEndian,
|
||||
"amd64": binary.LittleEndian,
|
||||
"arm": binary.LittleEndian,
|
||||
"arm64": binary.LittleEndian,
|
||||
"ppc64le": binary.LittleEndian,
|
||||
"riscv64": binary.LittleEndian,
|
||||
"s390x": binary.BigEndian,
|
||||
}
|
||||
|
||||
abiSignedChar = map[[2]string]bool{
|
||||
{"freebsd", "arm"}: false,
|
||||
{"freebsd", "arm64"}: false,
|
||||
{"linux", "arm"}: false,
|
||||
{"linux", "arm64"}: false,
|
||||
{"linux", "ppc64le"}: false,
|
||||
{"linux", "riscv64"}: false,
|
||||
{"linux", "s390x"}: false,
|
||||
{"netbsd", "arm"}: false,
|
||||
|
||||
{"darwin", "amd64"}: true,
|
||||
{"darwin", "arm64"}: true,
|
||||
{"freebsd", "386"}: true,
|
||||
{"freebsd", "amd64"}: true,
|
||||
{"linux", "386"}: true,
|
||||
{"linux", "amd64"}: true,
|
||||
{"netbsd", "386"}: true,
|
||||
{"netbsd", "amd64"}: true,
|
||||
{"openbsd", "386"}: true,
|
||||
{"openbsd", "amd64"}: true,
|
||||
{"openbsd", "arm64"}: true,
|
||||
{"windows", "386"}: true,
|
||||
{"windows", "amd64"}: true,
|
||||
{"windows", "arm64"}: true,
|
||||
}
|
||||
)
|
||||
|
||||
// abiTypes contains size and alignment information for known OS/arch pairs.
|
||||
//
|
||||
// The content is generated by ./cmd/cabi/main.c.
|
||||
var abiTypes = map[[2]string]map[Kind]ABIType{
|
||||
// Linux, generated by GCC 8.3.0
|
||||
{"linux", "amd64"}: {
|
||||
Void: {1, 1, 1},
|
||||
Bool: {1, 1, 1},
|
||||
Char: {1, 1, 1},
|
||||
SChar: {1, 1, 1},
|
||||
UChar: {1, 1, 1},
|
||||
Short: {2, 2, 2},
|
||||
UShort: {2, 2, 2},
|
||||
Enum: {4, 4, 4},
|
||||
Int: {4, 4, 4},
|
||||
UInt: {4, 4, 4},
|
||||
Long: {8, 8, 8},
|
||||
ULong: {8, 8, 8},
|
||||
LongLong: {8, 8, 8},
|
||||
ULongLong: {8, 8, 8},
|
||||
Ptr: {8, 8, 8},
|
||||
Function: {8, 8, 8},
|
||||
Float: {4, 4, 4},
|
||||
Double: {8, 8, 8},
|
||||
LongDouble: {16, 16, 16},
|
||||
Int8: {1, 1, 1},
|
||||
UInt8: {1, 1, 1},
|
||||
Int16: {2, 2, 2},
|
||||
UInt16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
UInt32: {4, 4, 4},
|
||||
Int64: {8, 8, 8},
|
||||
UInt64: {8, 8, 8},
|
||||
Int128: {16, 16, 16},
|
||||
UInt128: {16, 16, 16},
|
||||
Float32: {4, 4, 4},
|
||||
Float32x: {8, 8, 8},
|
||||
Float64: {8, 8, 8},
|
||||
Float64x: {16, 16, 16},
|
||||
Float128: {16, 16, 16},
|
||||
Decimal32: {4, 4, 4},
|
||||
Decimal64: {8, 8, 8},
|
||||
Decimal128: {16, 16, 16},
|
||||
},
|
||||
{"linux", "386"}: {
|
||||
Void: {1, 1, 1},
|
||||
Bool: {1, 1, 1},
|
||||
Char: {1, 1, 1},
|
||||
SChar: {1, 1, 1},
|
||||
UChar: {1, 1, 1},
|
||||
Short: {2, 2, 2},
|
||||
UShort: {2, 2, 2},
|
||||
Enum: {4, 4, 4},
|
||||
Int: {4, 4, 4},
|
||||
UInt: {4, 4, 4},
|
||||
Long: {4, 4, 4},
|
||||
ULong: {4, 4, 4},
|
||||
LongLong: {8, 4, 4},
|
||||
ULongLong: {8, 4, 4},
|
||||
Ptr: {4, 4, 4},
|
||||
Function: {4, 4, 4},
|
||||
Float: {4, 4, 4},
|
||||
Double: {8, 4, 4},
|
||||
LongDouble: {12, 4, 4},
|
||||
Int8: {1, 1, 1},
|
||||
UInt8: {1, 1, 1},
|
||||
Int16: {2, 2, 2},
|
||||
UInt16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
UInt32: {4, 4, 4},
|
||||
Int64: {8, 4, 4},
|
||||
UInt64: {8, 4, 4},
|
||||
Float32: {4, 4, 4},
|
||||
Float32x: {8, 4, 4},
|
||||
Float64: {8, 4, 4},
|
||||
Float64x: {12, 4, 4},
|
||||
Float128: {16, 16, 16},
|
||||
Decimal32: {4, 4, 4},
|
||||
Decimal64: {8, 8, 8},
|
||||
Decimal128: {16, 16, 16},
|
||||
},
|
||||
{"linux", "arm"}: {
|
||||
Void: {1, 1, 1},
|
||||
Bool: {1, 1, 1},
|
||||
Char: {1, 1, 1},
|
||||
SChar: {1, 1, 1},
|
||||
UChar: {1, 1, 1},
|
||||
Short: {2, 2, 2},
|
||||
UShort: {2, 2, 2},
|
||||
Enum: {4, 4, 4},
|
||||
Int: {4, 4, 4},
|
||||
UInt: {4, 4, 4},
|
||||
Long: {4, 4, 4},
|
||||
ULong: {4, 4, 4},
|
||||
LongLong: {8, 8, 8},
|
||||
ULongLong: {8, 8, 8},
|
||||
Ptr: {4, 4, 4},
|
||||
Function: {4, 4, 4},
|
||||
Float: {4, 4, 4},
|
||||
Double: {8, 8, 8},
|
||||
LongDouble: {8, 8, 8},
|
||||
Int8: {1, 1, 1},
|
||||
UInt8: {1, 1, 1},
|
||||
Int16: {2, 2, 2},
|
||||
UInt16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
UInt32: {4, 4, 4},
|
||||
Int64: {8, 8, 8},
|
||||
UInt64: {8, 8, 8},
|
||||
},
|
||||
{"linux", "arm64"}: {
|
||||
Void: {1, 1, 1},
|
||||
Bool: {1, 1, 1},
|
||||
Char: {1, 1, 1},
|
||||
SChar: {1, 1, 1},
|
||||
UChar: {1, 1, 1},
|
||||
Short: {2, 2, 2},
|
||||
UShort: {2, 2, 2},
|
||||
Enum: {4, 4, 4},
|
||||
Int: {4, 4, 4},
|
||||
UInt: {4, 4, 4},
|
||||
Long: {8, 8, 8},
|
||||
ULong: {8, 8, 8},
|
||||
LongLong: {8, 8, 8},
|
||||
ULongLong: {8, 8, 8},
|
||||
Ptr: {8, 8, 8},
|
||||
Function: {8, 8, 8},
|
||||
Float: {4, 4, 4},
|
||||
Double: {8, 8, 8},
|
||||
LongDouble: {16, 16, 16},
|
||||
Int8: {1, 1, 1},
|
||||
UInt8: {1, 1, 1},
|
||||
Int16: {2, 2, 2},
|
||||
UInt16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
UInt32: {4, 4, 4},
|
||||
Int64: {8, 8, 8},
|
||||
UInt64: {8, 8, 8},
|
||||
Int128: {16, 16, 16},
|
||||
UInt128: {16, 16, 16},
|
||||
},
|
||||
// $ x86_64-w64-mingw32-gcc main.c && wine a.exe
|
||||
{"windows", "amd64"}: {
|
||||
Void: {1, 1, 1},
|
||||
Bool: {1, 1, 1},
|
||||
Char: {1, 1, 1},
|
||||
SChar: {1, 1, 1},
|
||||
UChar: {1, 1, 1},
|
||||
Short: {2, 2, 2},
|
||||
UShort: {2, 2, 2},
|
||||
Enum: {4, 4, 4},
|
||||
Int: {4, 4, 4},
|
||||
UInt: {4, 4, 4},
|
||||
Long: {4, 4, 4},
|
||||
ULong: {4, 4, 4},
|
||||
LongLong: {8, 8, 8},
|
||||
ULongLong: {8, 8, 8},
|
||||
Ptr: {8, 8, 8},
|
||||
Function: {8, 8, 8},
|
||||
Float: {4, 4, 4},
|
||||
Double: {8, 8, 8},
|
||||
LongDouble: {16, 16, 16},
|
||||
Int8: {1, 1, 1},
|
||||
UInt8: {1, 1, 1},
|
||||
Int16: {2, 2, 2},
|
||||
UInt16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
UInt32: {4, 4, 4},
|
||||
Int64: {8, 8, 8},
|
||||
UInt64: {8, 8, 8},
|
||||
Int128: {16, 16, 16},
|
||||
UInt128: {16, 16, 16},
|
||||
Float32: {4, 4, 4},
|
||||
Float32x: {8, 8, 8},
|
||||
Float64: {8, 8, 8},
|
||||
Float64x: {16, 16, 16},
|
||||
Float128: {16, 16, 16},
|
||||
Decimal32: {4, 4, 4},
|
||||
Decimal64: {8, 8, 8},
|
||||
Decimal128: {16, 16, 16},
|
||||
},
|
||||
// clang version 14.0.0 (https://github.com/llvm/llvm-project.git 329fda39c507e8740978d10458451dcdb21563be)
|
||||
// Target: aarch64-w64-windows-gnu
|
||||
{"windows", "arm64"}: {
|
||||
Void: {1, 1, 1},
|
||||
Bool: {1, 1, 1},
|
||||
Char: {1, 1, 1},
|
||||
SChar: {1, 1, 1},
|
||||
UChar: {1, 1, 1},
|
||||
Short: {2, 2, 2},
|
||||
UShort: {2, 2, 2},
|
||||
Enum: {4, 4, 4},
|
||||
Int: {4, 4, 4},
|
||||
UInt: {4, 4, 4},
|
||||
Long: {4, 4, 4},
|
||||
ULong: {4, 4, 4},
|
||||
LongLong: {8, 8, 8},
|
||||
ULongLong: {8, 8, 8},
|
||||
Ptr: {8, 8, 8},
|
||||
Function: {8, 8, 8},
|
||||
Float: {4, 4, 4},
|
||||
Double: {8, 8, 8},
|
||||
LongDouble: {8, 8, 8},
|
||||
},
|
||||
// $ i686-w64-mingw32-gcc main.c && wine a.exe
|
||||
{"windows", "386"}: {
|
||||
Void: {1, 1, 1},
|
||||
Bool: {1, 1, 1},
|
||||
Char: {1, 1, 1},
|
||||
SChar: {1, 1, 1},
|
||||
UChar: {1, 1, 1},
|
||||
Short: {2, 2, 2},
|
||||
UShort: {2, 2, 2},
|
||||
Enum: {4, 4, 4},
|
||||
Int: {4, 4, 4},
|
||||
UInt: {4, 4, 4},
|
||||
Long: {4, 4, 4},
|
||||
ULong: {4, 4, 4},
|
||||
LongLong: {8, 8, 8},
|
||||
ULongLong: {8, 8, 8},
|
||||
Ptr: {4, 4, 4},
|
||||
Function: {4, 4, 4},
|
||||
Float: {4, 4, 4},
|
||||
Double: {8, 8, 8},
|
||||
LongDouble: {12, 4, 4},
|
||||
Int8: {1, 1, 1},
|
||||
UInt8: {1, 1, 1},
|
||||
Int16: {2, 2, 2},
|
||||
UInt16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
UInt32: {4, 4, 4},
|
||||
Int64: {8, 8, 8},
|
||||
UInt64: {8, 8, 8},
|
||||
Float32: {4, 4, 4},
|
||||
Float32x: {8, 8, 8},
|
||||
Float64: {8, 8, 8},
|
||||
Float64x: {12, 4, 4},
|
||||
Float128: {16, 16, 16},
|
||||
Decimal32: {4, 4, 4},
|
||||
Decimal64: {8, 8, 8},
|
||||
Decimal128: {16, 16, 16},
|
||||
},
|
||||
{"darwin", "amd64"}: {
|
||||
Void: {1, 1, 1},
|
||||
Bool: {1, 1, 1},
|
||||
Char: {1, 1, 1},
|
||||
SChar: {1, 1, 1},
|
||||
UChar: {1, 1, 1},
|
||||
Short: {2, 2, 2},
|
||||
UShort: {2, 2, 2},
|
||||
Enum: {4, 4, 4},
|
||||
Int: {4, 4, 4},
|
||||
UInt: {4, 4, 4},
|
||||
Long: {8, 8, 8},
|
||||
ULong: {8, 8, 8},
|
||||
LongLong: {8, 8, 8},
|
||||
ULongLong: {8, 8, 8},
|
||||
Ptr: {8, 8, 8},
|
||||
Function: {8, 8, 8},
|
||||
Float: {4, 4, 4},
|
||||
Double: {8, 8, 8},
|
||||
LongDouble: {16, 16, 16},
|
||||
Int8: {1, 1, 1},
|
||||
UInt8: {1, 1, 1},
|
||||
Int16: {2, 2, 2},
|
||||
UInt16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
UInt32: {4, 4, 4},
|
||||
Int64: {8, 8, 8},
|
||||
UInt64: {8, 8, 8},
|
||||
Int128: {16, 16, 16},
|
||||
UInt128: {16, 16, 16},
|
||||
},
|
||||
{"darwin", "arm64"}: {
|
||||
Void: {1, 1, 1},
|
||||
Bool: {1, 1, 1},
|
||||
Char: {1, 1, 1},
|
||||
SChar: {1, 1, 1},
|
||||
UChar: {1, 1, 1},
|
||||
Short: {2, 2, 2},
|
||||
UShort: {2, 2, 2},
|
||||
Enum: {4, 4, 4},
|
||||
Int: {4, 4, 4},
|
||||
UInt: {4, 4, 4},
|
||||
Long: {8, 8, 8},
|
||||
ULong: {8, 8, 8},
|
||||
LongLong: {8, 8, 8},
|
||||
ULongLong: {8, 8, 8},
|
||||
Ptr: {8, 8, 8},
|
||||
Function: {8, 8, 8},
|
||||
Float: {4, 4, 4},
|
||||
Double: {8, 8, 8},
|
||||
LongDouble: {8, 8, 8},
|
||||
Int8: {1, 1, 1},
|
||||
UInt8: {1, 1, 1},
|
||||
Int16: {2, 2, 2},
|
||||
UInt16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
UInt32: {4, 4, 4},
|
||||
Int64: {8, 8, 8},
|
||||
UInt64: {8, 8, 8},
|
||||
Int128: {16, 16, 16},
|
||||
UInt128: {16, 16, 16},
|
||||
},
|
||||
// gcc (SUSE Linux) 7.5.0
|
||||
{"linux", "s390x"}: {
|
||||
Void: {1, 1, 1},
|
||||
Bool: {1, 1, 1},
|
||||
Char: {1, 1, 1},
|
||||
SChar: {1, 1, 1},
|
||||
UChar: {1, 1, 1},
|
||||
Short: {2, 2, 2},
|
||||
UShort: {2, 2, 2},
|
||||
Enum: {4, 4, 4},
|
||||
Int: {4, 4, 4},
|
||||
UInt: {4, 4, 4},
|
||||
Long: {8, 8, 8},
|
||||
ULong: {8, 8, 8},
|
||||
LongLong: {8, 8, 8},
|
||||
ULongLong: {8, 8, 8},
|
||||
Ptr: {8, 8, 8},
|
||||
Function: {8, 8, 8},
|
||||
Float: {4, 4, 4},
|
||||
Double: {8, 8, 8},
|
||||
LongDouble: {16, 8, 8},
|
||||
Int8: {1, 1, 1},
|
||||
UInt8: {1, 1, 1},
|
||||
Int16: {2, 2, 2},
|
||||
UInt16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
UInt32: {4, 4, 4},
|
||||
Int64: {8, 8, 8},
|
||||
UInt64: {8, 8, 8},
|
||||
Int128: {16, 8, 8},
|
||||
UInt128: {16, 8, 8},
|
||||
Float32: {4, 4, 4},
|
||||
Float32x: {8, 8, 8},
|
||||
Float64: {8, 8, 8},
|
||||
Float64x: {16, 8, 8},
|
||||
Float128: {16, 8, 8},
|
||||
Decimal32: {4, 4, 4},
|
||||
Decimal64: {8, 8, 8},
|
||||
Decimal128: {16, 8, 8},
|
||||
},
|
||||
// gcc (FreeBSD Ports Collection) 10.3.0
|
||||
{"freebsd", "amd64"}: {
|
||||
Void: {1, 1, 1},
|
||||
Bool: {1, 1, 1},
|
||||
Char: {1, 1, 1},
|
||||
SChar: {1, 1, 1},
|
||||
UChar: {1, 1, 1},
|
||||
Short: {2, 2, 2},
|
||||
UShort: {2, 2, 2},
|
||||
Enum: {4, 4, 4},
|
||||
Int: {4, 4, 4},
|
||||
UInt: {4, 4, 4},
|
||||
Long: {8, 8, 8},
|
||||
ULong: {8, 8, 8},
|
||||
LongLong: {8, 8, 8},
|
||||
ULongLong: {8, 8, 8},
|
||||
Ptr: {8, 8, 8},
|
||||
Function: {8, 8, 8},
|
||||
Float: {4, 4, 4},
|
||||
Double: {8, 8, 8},
|
||||
LongDouble: {16, 16, 16},
|
||||
Int8: {1, 1, 1},
|
||||
UInt8: {1, 1, 1},
|
||||
Int16: {2, 2, 2},
|
||||
UInt16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
UInt32: {4, 4, 4},
|
||||
Int64: {8, 8, 8},
|
||||
UInt64: {8, 8, 8},
|
||||
Int128: {16, 16, 16},
|
||||
UInt128: {16, 16, 16},
|
||||
},
|
||||
// gcc (FreeBSD Ports Collection) 11.3.0
|
||||
{"freebsd", "arm64"}: {
|
||||
Void: {1, 1, 1},
|
||||
Bool: {1, 1, 1},
|
||||
Char: {1, 1, 1},
|
||||
SChar: {1, 1, 1},
|
||||
UChar: {1, 1, 1},
|
||||
Short: {2, 2, 2},
|
||||
UShort: {2, 2, 2},
|
||||
Enum: {4, 4, 4},
|
||||
Int: {4, 4, 4},
|
||||
UInt: {4, 4, 4},
|
||||
Long: {8, 8, 8},
|
||||
ULong: {8, 8, 8},
|
||||
LongLong: {8, 8, 8},
|
||||
ULongLong: {8, 8, 8},
|
||||
Ptr: {8, 8, 8},
|
||||
Function: {8, 8, 8},
|
||||
Float: {4, 4, 4},
|
||||
Double: {8, 8, 8},
|
||||
LongDouble: {16, 16, 16},
|
||||
Int8: {1, 1, 1},
|
||||
UInt8: {1, 1, 1},
|
||||
Int16: {2, 2, 2},
|
||||
UInt16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
UInt32: {4, 4, 4},
|
||||
Int64: {8, 8, 8},
|
||||
UInt64: {8, 8, 8},
|
||||
Int128: {16, 16, 16},
|
||||
UInt128: {16, 16, 16},
|
||||
},
|
||||
// gcc (FreeBSD Ports Collection) 10.3.0
|
||||
{"freebsd", "386"}: {
|
||||
Void: {1, 1, 1},
|
||||
Bool: {1, 1, 1},
|
||||
Char: {1, 1, 1},
|
||||
SChar: {1, 1, 1},
|
||||
UChar: {1, 1, 1},
|
||||
Short: {2, 2, 2},
|
||||
UShort: {2, 2, 2},
|
||||
Enum: {4, 4, 4},
|
||||
Int: {4, 4, 4},
|
||||
UInt: {4, 4, 4},
|
||||
Long: {4, 4, 4},
|
||||
ULong: {4, 4, 4},
|
||||
LongLong: {8, 4, 4},
|
||||
ULongLong: {8, 4, 4},
|
||||
Ptr: {4, 4, 4},
|
||||
Function: {4, 4, 4},
|
||||
Float: {4, 4, 4},
|
||||
Double: {8, 4, 4},
|
||||
LongDouble: {12, 4, 4},
|
||||
Int8: {1, 1, 1},
|
||||
UInt8: {1, 1, 1},
|
||||
Int16: {2, 2, 2},
|
||||
UInt16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
UInt32: {4, 4, 4},
|
||||
Int64: {8, 4, 4},
|
||||
UInt64: {8, 4, 4},
|
||||
Float32: {4, 4, 4},
|
||||
Float32x: {8, 4, 4},
|
||||
Float64: {8, 4, 4},
|
||||
Float64x: {16, 16, 16},
|
||||
Float128: {16, 16, 16},
|
||||
},
|
||||
// gcc (FreeBSD Ports Collection) 11.3.0
|
||||
{"freebsd", "arm"}: {
|
||||
Void: {1, 1, 1},
|
||||
Bool: {1, 1, 1},
|
||||
Char: {1, 1, 1},
|
||||
SChar: {1, 1, 1},
|
||||
UChar: {1, 1, 1},
|
||||
Short: {2, 2, 2},
|
||||
UShort: {2, 2, 2},
|
||||
Enum: {4, 4, 4},
|
||||
Int: {4, 4, 4},
|
||||
UInt: {4, 4, 4},
|
||||
Long: {4, 4, 4},
|
||||
ULong: {4, 4, 4},
|
||||
LongLong: {8, 8, 8},
|
||||
ULongLong: {8, 8, 8},
|
||||
Ptr: {4, 4, 4},
|
||||
Function: {4, 4, 4},
|
||||
Float: {4, 4, 4},
|
||||
Double: {8, 8, 8},
|
||||
LongDouble: {8, 8, 8},
|
||||
Int8: {1, 1, 1},
|
||||
UInt8: {1, 1, 1},
|
||||
Int16: {2, 2, 2},
|
||||
UInt16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
UInt32: {4, 4, 4},
|
||||
Int64: {8, 8, 8},
|
||||
UInt64: {8, 8, 8},
|
||||
},
|
||||
// gcc (GCC) 8.4.0
|
||||
{"openbsd", "amd64"}: {
|
||||
Void: {1, 1, 1},
|
||||
Bool: {1, 1, 1},
|
||||
Char: {1, 1, 1},
|
||||
SChar: {1, 1, 1},
|
||||
UChar: {1, 1, 1},
|
||||
Short: {2, 2, 2},
|
||||
UShort: {2, 2, 2},
|
||||
Enum: {4, 4, 4},
|
||||
Int: {4, 4, 4},
|
||||
UInt: {4, 4, 4},
|
||||
Long: {8, 8, 8},
|
||||
ULong: {8, 8, 8},
|
||||
LongLong: {8, 8, 8},
|
||||
ULongLong: {8, 8, 8},
|
||||
Ptr: {8, 8, 8},
|
||||
Function: {8, 8, 8},
|
||||
Float: {4, 4, 4},
|
||||
Double: {8, 8, 8},
|
||||
LongDouble: {16, 16, 16},
|
||||
Int8: {1, 1, 1},
|
||||
UInt8: {1, 1, 1},
|
||||
Int16: {2, 2, 2},
|
||||
UInt16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
UInt32: {4, 4, 4},
|
||||
Int64: {8, 8, 8},
|
||||
UInt64: {8, 8, 8},
|
||||
Int128: {16, 16, 16},
|
||||
UInt128: {16, 16, 16},
|
||||
Float32: {4, 4, 4},
|
||||
Float32x: {8, 8, 8},
|
||||
Float64: {8, 8, 8},
|
||||
Float64x: {16, 16, 16},
|
||||
Float128: {16, 16, 16},
|
||||
},
|
||||
// OpenBSD clang version 13.0.0
|
||||
{"openbsd", "arm64"}: {
|
||||
Void: {1, 1, 1},
|
||||
Bool: {1, 1, 1},
|
||||
Char: {1, 1, 1},
|
||||
SChar: {1, 1, 1},
|
||||
UChar: {1, 1, 1},
|
||||
Short: {2, 2, 2},
|
||||
UShort: {2, 2, 2},
|
||||
Enum: {4, 4, 4},
|
||||
Int: {4, 4, 4},
|
||||
UInt: {4, 4, 4},
|
||||
Long: {8, 8, 8},
|
||||
ULong: {8, 8, 8},
|
||||
LongLong: {8, 8, 8},
|
||||
ULongLong: {8, 8, 8},
|
||||
Ptr: {8, 8, 8},
|
||||
Function: {8, 8, 8},
|
||||
Float: {4, 4, 4},
|
||||
Double: {8, 8, 8},
|
||||
LongDouble: {16, 16, 16},
|
||||
Int8: {1, 1, 1},
|
||||
UInt8: {1, 1, 1},
|
||||
Int16: {2, 2, 2},
|
||||
UInt16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
UInt32: {4, 4, 4},
|
||||
Int64: {8, 8, 8},
|
||||
UInt64: {8, 8, 8},
|
||||
Int128: {16, 16, 16},
|
||||
UInt128: {16, 16, 16},
|
||||
},
|
||||
// OpenBSD clang version 13.0.0
|
||||
{"openbsd", "386"}: {
|
||||
Void: {1, 1, 1},
|
||||
Bool: {1, 1, 1},
|
||||
Char: {1, 1, 1},
|
||||
SChar: {1, 1, 1},
|
||||
UChar: {1, 1, 1},
|
||||
Short: {2, 2, 2},
|
||||
UShort: {2, 2, 2},
|
||||
Enum: {4, 4, 4},
|
||||
Int: {4, 4, 4},
|
||||
UInt: {4, 4, 4},
|
||||
Long: {4, 4, 4},
|
||||
ULong: {4, 4, 4},
|
||||
LongLong: {8, 4, 4},
|
||||
ULongLong: {8, 4, 4},
|
||||
Ptr: {4, 4, 4},
|
||||
Function: {4, 4, 4},
|
||||
Float: {4, 4, 4},
|
||||
Double: {8, 4, 4},
|
||||
LongDouble: {12, 4, 4},
|
||||
Int8: {1, 1, 1},
|
||||
UInt8: {1, 1, 1},
|
||||
Int16: {2, 2, 2},
|
||||
UInt16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
UInt32: {4, 4, 4},
|
||||
Int64: {8, 4, 4},
|
||||
UInt64: {8, 4, 4},
|
||||
},
|
||||
// gcc (GCC) 10.3.0
|
||||
{"netbsd", "amd64"}: {
|
||||
Void: {1, 1, 1},
|
||||
Bool: {1, 1, 1},
|
||||
Char: {1, 1, 1},
|
||||
SChar: {1, 1, 1},
|
||||
UChar: {1, 1, 1},
|
||||
Short: {2, 2, 2},
|
||||
UShort: {2, 2, 2},
|
||||
Enum: {4, 4, 4},
|
||||
Int: {4, 4, 4},
|
||||
UInt: {4, 4, 4},
|
||||
Long: {8, 8, 8},
|
||||
ULong: {8, 8, 8},
|
||||
LongLong: {8, 8, 8},
|
||||
ULongLong: {8, 8, 8},
|
||||
Ptr: {8, 8, 8},
|
||||
Function: {8, 8, 8},
|
||||
Float: {4, 4, 4},
|
||||
Double: {8, 8, 8},
|
||||
LongDouble: {16, 16, 16},
|
||||
Int8: {1, 1, 1},
|
||||
UInt8: {1, 1, 1},
|
||||
Int16: {2, 2, 2},
|
||||
UInt16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
UInt32: {4, 4, 4},
|
||||
Int64: {8, 8, 8},
|
||||
UInt64: {8, 8, 8},
|
||||
Int128: {16, 16, 16},
|
||||
UInt128: {16, 16, 16},
|
||||
},
|
||||
// gcc (nb4 20200810) 7.5.0
|
||||
{"netbsd", "arm"}: {
|
||||
Void: {1, 1, 1},
|
||||
Bool: {1, 1, 1},
|
||||
Char: {1, 1, 1},
|
||||
SChar: {1, 1, 1},
|
||||
UChar: {1, 1, 1},
|
||||
Short: {2, 2, 2},
|
||||
UShort: {2, 2, 2},
|
||||
Enum: {4, 4, 4},
|
||||
Int: {4, 4, 4},
|
||||
UInt: {4, 4, 4},
|
||||
Long: {4, 4, 4},
|
||||
ULong: {4, 4, 4},
|
||||
LongLong: {8, 8, 8},
|
||||
ULongLong: {8, 8, 8},
|
||||
Ptr: {4, 4, 4},
|
||||
Function: {4, 4, 4},
|
||||
Float: {4, 4, 4},
|
||||
Double: {8, 8, 8},
|
||||
LongDouble: {8, 8, 8},
|
||||
Int8: {1, 1, 1},
|
||||
UInt8: {1, 1, 1},
|
||||
Int16: {2, 2, 2},
|
||||
UInt16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
UInt32: {4, 4, 4},
|
||||
Int64: {8, 8, 8},
|
||||
UInt64: {8, 8, 8},
|
||||
},
|
||||
// gcc (nb4 20200810) 7.5.0
|
||||
{"netbsd", "386"}: {
|
||||
Void: {1, 1, 1},
|
||||
Bool: {1, 1, 1},
|
||||
Char: {1, 1, 1},
|
||||
SChar: {1, 1, 1},
|
||||
UChar: {1, 1, 1},
|
||||
Short: {2, 2, 2},
|
||||
UShort: {2, 2, 2},
|
||||
Enum: {4, 4, 4},
|
||||
Int: {4, 4, 4},
|
||||
UInt: {4, 4, 4},
|
||||
Long: {4, 4, 4},
|
||||
ULong: {4, 4, 4},
|
||||
LongLong: {8, 4, 4},
|
||||
ULongLong: {8, 4, 4},
|
||||
Ptr: {4, 4, 4},
|
||||
Function: {4, 4, 4},
|
||||
Float: {4, 4, 4},
|
||||
Double: {8, 4, 4},
|
||||
LongDouble: {12, 4, 4},
|
||||
Int8: {1, 1, 1},
|
||||
UInt8: {1, 1, 1},
|
||||
Int16: {2, 2, 2},
|
||||
UInt16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
UInt32: {4, 4, 4},
|
||||
Int64: {8, 4, 4},
|
||||
UInt64: {8, 4, 4},
|
||||
Float32: {4, 4, 4},
|
||||
Float32x: {8, 4, 4},
|
||||
Float64: {8, 4, 4},
|
||||
Float64x: {12, 4, 4},
|
||||
Float128: {16, 16, 16},
|
||||
},
|
||||
// gcc (Ubuntu 11.2.0-7ubuntu2) 11.2.0
|
||||
{"linux", "riscv64"}: {
|
||||
Void: {1, 1, 1},
|
||||
Bool: {1, 1, 1},
|
||||
Char: {1, 1, 1},
|
||||
SChar: {1, 1, 1},
|
||||
UChar: {1, 1, 1},
|
||||
Short: {2, 2, 2},
|
||||
UShort: {2, 2, 2},
|
||||
Enum: {4, 4, 4},
|
||||
Int: {4, 4, 4},
|
||||
UInt: {4, 4, 4},
|
||||
Long: {8, 8, 8},
|
||||
ULong: {8, 8, 8},
|
||||
LongLong: {8, 8, 8},
|
||||
ULongLong: {8, 8, 8},
|
||||
Ptr: {8, 8, 8},
|
||||
Function: {8, 8, 8},
|
||||
Float: {4, 4, 4},
|
||||
Double: {8, 8, 8},
|
||||
LongDouble: {16, 16, 16},
|
||||
Int8: {1, 1, 1},
|
||||
UInt8: {1, 1, 1},
|
||||
Int16: {2, 2, 2},
|
||||
UInt16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
UInt32: {4, 4, 4},
|
||||
Int64: {8, 8, 8},
|
||||
UInt64: {8, 8, 8},
|
||||
Int128: {16, 16, 16},
|
||||
UInt128: {16, 16, 16},
|
||||
Float32: {4, 4, 4},
|
||||
Float32x: {8, 8, 8},
|
||||
Float64: {8, 8, 8},
|
||||
Float64x: {16, 16, 16},
|
||||
Float128: {16, 16, 16},
|
||||
},
|
||||
// gcc (Debian 10.2.1-6) 10.2.1 20210110
|
||||
{"linux", "ppc64le"}: {
|
||||
Void: {1, 1, 1},
|
||||
Bool: {1, 1, 1},
|
||||
Char: {1, 1, 1},
|
||||
SChar: {1, 1, 1},
|
||||
UChar: {1, 1, 1},
|
||||
Short: {2, 2, 2},
|
||||
UShort: {2, 2, 2},
|
||||
Enum: {4, 4, 4},
|
||||
Int: {4, 4, 4},
|
||||
UInt: {4, 4, 4},
|
||||
Long: {8, 8, 8},
|
||||
ULong: {8, 8, 8},
|
||||
LongLong: {8, 8, 8},
|
||||
ULongLong: {8, 8, 8},
|
||||
Ptr: {8, 8, 8},
|
||||
Function: {8, 8, 8},
|
||||
Float: {4, 4, 4},
|
||||
Double: {8, 8, 8},
|
||||
LongDouble: {16, 16, 16},
|
||||
Int8: {1, 1, 1},
|
||||
UInt8: {1, 1, 1},
|
||||
Int16: {2, 2, 2},
|
||||
UInt16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
UInt32: {4, 4, 4},
|
||||
Int64: {8, 8, 8},
|
||||
UInt64: {8, 8, 8},
|
||||
Int128: {16, 16, 16},
|
||||
UInt128: {16, 16, 16},
|
||||
Float32: {4, 4, 4},
|
||||
Float32x: {8, 8, 8},
|
||||
Float64: {8, 8, 8},
|
||||
Float64x: {16, 16, 16},
|
||||
Float128: {16, 16, 16},
|
||||
Decimal32: {4, 4, 4},
|
||||
Decimal64: {8, 8, 8},
|
||||
Decimal128: {16, 16, 16},
|
||||
},
|
||||
}
|
||||
5232
vendor/modernc.org/cc/v3/ast.go
generated
vendored
5232
vendor/modernc.org/cc/v3/ast.go
generated
vendored
File diff suppressed because it is too large
Load diff
1187
vendor/modernc.org/cc/v3/ast2.go
generated
vendored
1187
vendor/modernc.org/cc/v3/ast2.go
generated
vendored
File diff suppressed because it is too large
Load diff
1049
vendor/modernc.org/cc/v3/cc.go
generated
vendored
1049
vendor/modernc.org/cc/v3/cc.go
generated
vendored
File diff suppressed because it is too large
Load diff
5276
vendor/modernc.org/cc/v3/check.go
generated
vendored
5276
vendor/modernc.org/cc/v3/check.go
generated
vendored
File diff suppressed because it is too large
Load diff
3101
vendor/modernc.org/cc/v3/cpp.go
generated
vendored
3101
vendor/modernc.org/cc/v3/cpp.go
generated
vendored
File diff suppressed because it is too large
Load diff
84
vendor/modernc.org/cc/v3/enum.go
generated
vendored
84
vendor/modernc.org/cc/v3/enum.go
generated
vendored
|
|
@ -1,84 +0,0 @@
|
|||
// Copyright 2019 The CC 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 cc // import "modernc.org/cc/v3"
|
||||
|
||||
// Values of Kind
|
||||
const (
|
||||
Invalid Kind = iota
|
||||
|
||||
Array // T[]
|
||||
Bool // _Bool
|
||||
Char // char
|
||||
ComplexChar // complex char
|
||||
ComplexDouble // complex double
|
||||
ComplexFloat // complex float
|
||||
ComplexInt // complex int
|
||||
ComplexLong // complex long
|
||||
ComplexLongDouble // complex long double
|
||||
ComplexLongLong // complex long long
|
||||
ComplexShort // complex short
|
||||
ComplexUInt // complex unsigned
|
||||
ComplexULong // complex unsigned long
|
||||
ComplexULongLong // complex unsigned long long
|
||||
ComplexUShort // complex shor
|
||||
Decimal128 // _Decimal128
|
||||
Decimal32 // _Decimal32
|
||||
Decimal64 // _Decimal64
|
||||
Double // double
|
||||
Enum // enum
|
||||
Float // float
|
||||
Float128 // _Float128
|
||||
Float32 // _Float32
|
||||
Float32x // _Float32x
|
||||
Float64 // _Float64
|
||||
Float64x // _Float64x
|
||||
Function // function
|
||||
Int // int
|
||||
Int8 // __int8
|
||||
Int16 // __int16
|
||||
Int32 // __int32
|
||||
Int64 // __int64
|
||||
Int128 // __int128
|
||||
Long // long
|
||||
LongDouble // long double
|
||||
LongLong // long long
|
||||
Ptr // pointer
|
||||
SChar // signed char
|
||||
Short // short
|
||||
Struct // struct
|
||||
TypedefName // typedefname
|
||||
UChar // unsigned char
|
||||
UInt // unsigned
|
||||
UInt8 // unsigned __int8
|
||||
UInt16 // unsigned __int16
|
||||
UInt32 // unsigned __int32
|
||||
UInt64 // unsigned __int64
|
||||
UInt128 // unsigned __int128
|
||||
ULong // unsigned long
|
||||
ULongLong // unsigned long long
|
||||
UShort // unsigned short
|
||||
Union // union
|
||||
Void // void
|
||||
Vector // vector
|
||||
|
||||
typeofExpr
|
||||
typeofType
|
||||
|
||||
maxKind
|
||||
)
|
||||
|
||||
// Values of Linkage
|
||||
const (
|
||||
None Linkage = iota
|
||||
Internal
|
||||
External
|
||||
)
|
||||
|
||||
// Values of StorageClass
|
||||
const (
|
||||
Static StorageClass = iota
|
||||
Automatic
|
||||
Allocated
|
||||
)
|
||||
156
vendor/modernc.org/cc/v3/filesystem.go
generated
vendored
156
vendor/modernc.org/cc/v3/filesystem.go
generated
vendored
|
|
@ -1,156 +0,0 @@
|
|||
// Copyright 2019 The CC 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 cc
|
||||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Filesystem abstraction used in CC. The underlying value must be comparable (e.g. pointer) to be used in map keys.
|
||||
type Filesystem interface {
|
||||
// Stat is an analog of os.Stat, but also accepts a flag to indicate a system include (<file.h>).
|
||||
Stat(path string, sys bool) (os.FileInfo, error)
|
||||
// Open is an analog of os.Open, but also accepts a flag to indicate a system include (<file.h>).
|
||||
Open(path string, sys bool) (io.ReadCloser, error)
|
||||
}
|
||||
|
||||
// LocalFS returns a local filesystem implementation.
|
||||
func LocalFS() Filesystem {
|
||||
return localFS{}
|
||||
}
|
||||
|
||||
type localFS struct{}
|
||||
|
||||
// Stat implements Filesystem.
|
||||
func (localFS) Stat(path string, sys bool) (os.FileInfo, error) {
|
||||
return os.Stat(path)
|
||||
}
|
||||
|
||||
// Open implements Filesystem.
|
||||
func (localFS) Open(path string, sys bool) (io.ReadCloser, error) {
|
||||
return os.Open(path)
|
||||
}
|
||||
|
||||
// WorkingDir is a filesystem implementation that resolves paths relative to a given directory.
|
||||
// If filesystem is not specified, the local one will be used.
|
||||
func WorkingDir(wd string, fs Filesystem) Filesystem {
|
||||
if fs == nil {
|
||||
fs = LocalFS()
|
||||
}
|
||||
return workDir{fs: fs, wd: wd}
|
||||
}
|
||||
|
||||
type workDir struct {
|
||||
fs Filesystem
|
||||
wd string
|
||||
}
|
||||
|
||||
// Stat implements Filesystem.
|
||||
func (fs workDir) Stat(fname string, sys bool) (os.FileInfo, error) {
|
||||
if !path.IsAbs(fname) {
|
||||
fname = path.Join(fs.wd, fname)
|
||||
}
|
||||
return fs.fs.Stat(fname, sys)
|
||||
}
|
||||
|
||||
// Open implements Filesystem.
|
||||
func (fs workDir) Open(fname string, sys bool) (io.ReadCloser, error) {
|
||||
if !path.IsAbs(fname) {
|
||||
fname = path.Join(fs.wd, fname)
|
||||
}
|
||||
return fs.fs.Open(fname, sys)
|
||||
}
|
||||
|
||||
// Overlay is a filesystem implementation that first check if the file is available in the primary FS
|
||||
// and if not, falls back to a secondary FS.
|
||||
func Overlay(pri, sec Filesystem) Filesystem {
|
||||
return overlayFS{pri: pri, sec: sec}
|
||||
}
|
||||
|
||||
type overlayFS struct {
|
||||
pri, sec Filesystem
|
||||
}
|
||||
|
||||
// Stat implements Filesystem.
|
||||
func (fs overlayFS) Stat(path string, sys bool) (os.FileInfo, error) {
|
||||
st, err := fs.pri.Stat(path, sys)
|
||||
if err == nil || !os.IsNotExist(err) {
|
||||
return st, err
|
||||
}
|
||||
return fs.sec.Stat(path, sys)
|
||||
}
|
||||
|
||||
// Open implements Filesystem.
|
||||
func (fs overlayFS) Open(path string, sys bool) (io.ReadCloser, error) {
|
||||
f, err := fs.pri.Open(path, sys)
|
||||
if err == nil || !os.IsNotExist(err) {
|
||||
return f, err
|
||||
}
|
||||
return fs.sec.Open(path, sys)
|
||||
}
|
||||
|
||||
// StaticFS implements filesystem interface by serving string values form the provided map.
|
||||
func StaticFS(files map[string]string) Filesystem {
|
||||
return &staticFS{m: files, ts: time.Now()}
|
||||
}
|
||||
|
||||
type staticFS struct {
|
||||
ts time.Time
|
||||
m map[string]string
|
||||
}
|
||||
|
||||
// Stat implements Filesystem.
|
||||
func (fs *staticFS) Stat(path string, sys bool) (os.FileInfo, error) {
|
||||
v, ok := fs.m[path]
|
||||
if !ok {
|
||||
return nil, &os.PathError{"stat", path, os.ErrNotExist}
|
||||
}
|
||||
return staticFileInfo{name: path, size: int64(len(v)), mode: 0, mod: fs.ts}, nil
|
||||
}
|
||||
|
||||
// Open implements Filesystem.
|
||||
func (fs *staticFS) Open(path string, sys bool) (io.ReadCloser, error) {
|
||||
v, ok := fs.m[path]
|
||||
if !ok {
|
||||
return nil, &os.PathError{"open", path, os.ErrNotExist}
|
||||
}
|
||||
return ioutil.NopCloser(strings.NewReader(v)), nil
|
||||
}
|
||||
|
||||
type staticFileInfo struct {
|
||||
name string
|
||||
size int64
|
||||
mode os.FileMode
|
||||
mod time.Time
|
||||
}
|
||||
|
||||
func (fi staticFileInfo) Name() string {
|
||||
return fi.name
|
||||
}
|
||||
|
||||
func (fi staticFileInfo) Size() int64 {
|
||||
return fi.size
|
||||
}
|
||||
|
||||
func (fi staticFileInfo) Mode() os.FileMode {
|
||||
return fi.mode
|
||||
}
|
||||
|
||||
func (fi staticFileInfo) ModTime() time.Time {
|
||||
return fi.mod
|
||||
}
|
||||
|
||||
func (fi staticFileInfo) IsDir() bool {
|
||||
return fi.mode.IsDir()
|
||||
}
|
||||
|
||||
func (fi staticFileInfo) Sys() interface{} {
|
||||
return fi
|
||||
}
|
||||
632
vendor/modernc.org/cc/v3/inspect.go
generated
vendored
632
vendor/modernc.org/cc/v3/inspect.go
generated
vendored
|
|
@ -1,632 +0,0 @@
|
|||
// Copyright 2020 The CC 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 cc // import "modernc.org/cc/v3"
|
||||
|
||||
// Inspect inspects AST node trees.
|
||||
//
|
||||
// If n is a non-terminal node, f(n, true) is called first. Next, f is called
|
||||
// recursively for each of n's non-nil non-terminal children nodes, if any, in
|
||||
// alphabetical order. Next, all n's terminal nodes, if any, are visited in
|
||||
// the numeric order of their suffixes (Token, Token2, Token3, ...). Finally,
|
||||
// f(n, false) is invoked.
|
||||
//
|
||||
// If n a terminal node, of type *Token, f(n, <unspecified boolean value> is
|
||||
// called once.
|
||||
//
|
||||
// Inspect stops when any invocation of f returns false.
|
||||
func Inspect(n Node, f func(Node, bool) bool) {
|
||||
see(n, f)
|
||||
}
|
||||
|
||||
func see(n Node, f func(Node, bool) bool) bool {
|
||||
switch x := n.(type) {
|
||||
case *AbstractDeclarator:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.DirectAbstractDeclarator, f) &&
|
||||
see(x.Pointer, f) &&
|
||||
f(x, false)
|
||||
case *AdditiveExpression:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AdditiveExpression, f) &&
|
||||
see(x.MultiplicativeExpression, f) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *AlignmentSpecifier:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.ConstantExpression, f) &&
|
||||
see(x.TypeName, f) &&
|
||||
see(&x.Token, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token3, f) &&
|
||||
f(x, false)
|
||||
case *AndExpression:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AndExpression, f) &&
|
||||
see(x.EqualityExpression, f) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *ArgumentExpressionList:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.ArgumentExpressionList, f) &&
|
||||
see(x.AssignmentExpression, f) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *Asm:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AsmArgList, f) &&
|
||||
see(x.AsmQualifierList, f) &&
|
||||
see(&x.Token, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token3, f) &&
|
||||
see(&x.Token4, f) &&
|
||||
f(x, false)
|
||||
case *AsmArgList:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AsmArgList, f) &&
|
||||
see(x.AsmExpressionList, f) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *AsmExpressionList:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AsmExpressionList, f) &&
|
||||
see(x.AsmIndex, f) &&
|
||||
see(x.AssignmentExpression, f) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *AsmFunctionDefinition:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AsmStatement, f) &&
|
||||
see(x.DeclarationSpecifiers, f) &&
|
||||
see(x.Declarator, f) &&
|
||||
f(x, false)
|
||||
case *AsmIndex:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.Expression, f) &&
|
||||
see(&x.Token, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
f(x, false)
|
||||
case *AsmQualifier:
|
||||
return x == nil || f(x, true) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *AsmQualifierList:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AsmQualifier, f) &&
|
||||
see(x.AsmQualifierList, f) &&
|
||||
f(x, false)
|
||||
case *AsmStatement:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.Asm, f) &&
|
||||
see(x.AttributeSpecifierList, f) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *AssignmentExpression:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AssignmentExpression, f) &&
|
||||
see(x.ConditionalExpression, f) &&
|
||||
see(x.UnaryExpression, f) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *AtomicTypeSpecifier:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.TypeName, f) &&
|
||||
see(&x.Token, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token3, f) &&
|
||||
f(x, false)
|
||||
case *AttributeSpecifier:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AttributeValueList, f) &&
|
||||
see(&x.Token, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token3, f) &&
|
||||
see(&x.Token4, f) &&
|
||||
see(&x.Token5, f) &&
|
||||
f(x, false)
|
||||
case *AttributeSpecifierList:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AttributeSpecifier, f) &&
|
||||
see(x.AttributeSpecifierList, f) &&
|
||||
f(x, false)
|
||||
case *AttributeValue:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.ExpressionList, f) &&
|
||||
see(&x.Token, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token3, f) &&
|
||||
f(x, false)
|
||||
case *AttributeValueList:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AttributeValue, f) &&
|
||||
see(x.AttributeValueList, f) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *BlockItem:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.CompoundStatement, f) &&
|
||||
see(x.Declaration, f) &&
|
||||
see(x.DeclarationSpecifiers, f) &&
|
||||
see(x.Declarator, f) &&
|
||||
see(x.LabelDeclaration, f) &&
|
||||
see(x.PragmaSTDC, f) &&
|
||||
see(x.Statement, f) &&
|
||||
f(x, false)
|
||||
case *BlockItemList:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.BlockItem, f) &&
|
||||
see(x.BlockItemList, f) &&
|
||||
f(x, false)
|
||||
case *CastExpression:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.CastExpression, f) &&
|
||||
see(x.TypeName, f) &&
|
||||
see(x.UnaryExpression, f) &&
|
||||
see(&x.Token, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
f(x, false)
|
||||
case *CompoundStatement:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.BlockItemList, f) &&
|
||||
see(&x.Token, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
f(x, false)
|
||||
case *ConditionalExpression:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.ConditionalExpression, f) &&
|
||||
see(x.Expression, f) &&
|
||||
see(x.LogicalOrExpression, f) &&
|
||||
see(&x.Token, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
f(x, false)
|
||||
case *ConstantExpression:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.ConditionalExpression, f) &&
|
||||
f(x, false)
|
||||
case *Declaration:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.DeclarationSpecifiers, f) &&
|
||||
see(x.InitDeclaratorList, f) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *DeclarationList:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.Declaration, f) &&
|
||||
see(x.DeclarationList, f) &&
|
||||
f(x, false)
|
||||
case *DeclarationSpecifiers:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AlignmentSpecifier, f) &&
|
||||
see(x.AttributeSpecifier, f) &&
|
||||
see(x.DeclarationSpecifiers, f) &&
|
||||
see(x.FunctionSpecifier, f) &&
|
||||
see(x.StorageClassSpecifier, f) &&
|
||||
see(x.TypeQualifier, f) &&
|
||||
see(x.TypeSpecifier, f) &&
|
||||
f(x, false)
|
||||
case *Declarator:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AttributeSpecifierList, f) &&
|
||||
see(x.DirectDeclarator, f) &&
|
||||
see(x.Pointer, f) &&
|
||||
f(x, false)
|
||||
case *Designation:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.DesignatorList, f) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *Designator:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.ConstantExpression, f) &&
|
||||
see(&x.Token, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
f(x, false)
|
||||
case *DesignatorList:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.Designator, f) &&
|
||||
see(x.DesignatorList, f) &&
|
||||
f(x, false)
|
||||
case *DirectAbstractDeclarator:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AbstractDeclarator, f) &&
|
||||
see(x.AssignmentExpression, f) &&
|
||||
see(x.DirectAbstractDeclarator, f) &&
|
||||
see(x.ParameterTypeList, f) &&
|
||||
see(x.TypeQualifiers, f) &&
|
||||
see(&x.Token, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token3, f) &&
|
||||
f(x, false)
|
||||
case *DirectDeclarator:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.Asm, f) &&
|
||||
see(x.AssignmentExpression, f) &&
|
||||
see(x.AttributeSpecifierList, f) &&
|
||||
see(x.Declarator, f) &&
|
||||
see(x.DirectDeclarator, f) &&
|
||||
see(x.IdentifierList, f) &&
|
||||
see(x.ParameterTypeList, f) &&
|
||||
see(x.TypeQualifiers, f) &&
|
||||
see(&x.Token, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token3, f) &&
|
||||
f(x, false)
|
||||
case *EnumSpecifier:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AttributeSpecifierList, f) &&
|
||||
see(x.EnumeratorList, f) &&
|
||||
see(&x.Token, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token3, f) &&
|
||||
see(&x.Token4, f) &&
|
||||
see(&x.Token5, f) &&
|
||||
f(x, false)
|
||||
case *Enumerator:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AttributeSpecifierList, f) &&
|
||||
see(x.ConstantExpression, f) &&
|
||||
see(&x.Token, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
f(x, false)
|
||||
case *EnumeratorList:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.Enumerator, f) &&
|
||||
see(x.EnumeratorList, f) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *EqualityExpression:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.EqualityExpression, f) &&
|
||||
see(x.RelationalExpression, f) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *ExclusiveOrExpression:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AndExpression, f) &&
|
||||
see(x.ExclusiveOrExpression, f) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *Expression:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AssignmentExpression, f) &&
|
||||
see(x.Expression, f) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *ExpressionList:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AssignmentExpression, f) &&
|
||||
see(x.ExpressionList, f) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *ExpressionStatement:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AttributeSpecifierList, f) &&
|
||||
see(x.Expression, f) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *ExternalDeclaration:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AsmFunctionDefinition, f) &&
|
||||
see(x.AsmStatement, f) &&
|
||||
see(x.Declaration, f) &&
|
||||
see(x.FunctionDefinition, f) &&
|
||||
see(x.PragmaSTDC, f) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *FunctionDefinition:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.CompoundStatement, f) &&
|
||||
see(x.DeclarationList, f) &&
|
||||
see(x.DeclarationSpecifiers, f) &&
|
||||
see(x.Declarator, f) &&
|
||||
f(x, false)
|
||||
case *FunctionSpecifier:
|
||||
return x == nil || f(x, true) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *IdentifierList:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.IdentifierList, f) &&
|
||||
see(&x.Token, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
f(x, false)
|
||||
case *InclusiveOrExpression:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.ExclusiveOrExpression, f) &&
|
||||
see(x.InclusiveOrExpression, f) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *InitDeclarator:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AttributeSpecifierList, f) &&
|
||||
see(x.Declarator, f) &&
|
||||
see(x.Initializer, f) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *InitDeclaratorList:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AttributeSpecifierList, f) &&
|
||||
see(x.InitDeclarator, f) &&
|
||||
see(x.InitDeclaratorList, f) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *Initializer:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AssignmentExpression, f) &&
|
||||
see(x.InitializerList, f) &&
|
||||
see(&x.Token, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token3, f) &&
|
||||
f(x, false)
|
||||
case *InitializerList:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.Designation, f) &&
|
||||
see(x.Initializer, f) &&
|
||||
see(x.InitializerList, f) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *IterationStatement:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.Declaration, f) &&
|
||||
see(x.Expression, f) &&
|
||||
see(x.Expression2, f) &&
|
||||
see(x.Expression3, f) &&
|
||||
see(x.Statement, f) &&
|
||||
see(&x.Token, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token3, f) &&
|
||||
see(&x.Token4, f) &&
|
||||
see(&x.Token5, f) &&
|
||||
f(x, false)
|
||||
case *JumpStatement:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.Expression, f) &&
|
||||
see(&x.Token, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token3, f) &&
|
||||
f(x, false)
|
||||
case *LabelDeclaration:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.IdentifierList, f) &&
|
||||
see(&x.Token, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
f(x, false)
|
||||
case *LabeledStatement:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AttributeSpecifierList, f) &&
|
||||
see(x.ConstantExpression, f) &&
|
||||
see(x.ConstantExpression2, f) &&
|
||||
see(x.Statement, f) &&
|
||||
see(&x.Token, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token3, f) &&
|
||||
f(x, false)
|
||||
case *LogicalAndExpression:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.InclusiveOrExpression, f) &&
|
||||
see(x.LogicalAndExpression, f) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *LogicalOrExpression:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.LogicalAndExpression, f) &&
|
||||
see(x.LogicalOrExpression, f) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *MultiplicativeExpression:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.CastExpression, f) &&
|
||||
see(x.MultiplicativeExpression, f) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *ParameterDeclaration:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AbstractDeclarator, f) &&
|
||||
see(x.AttributeSpecifierList, f) &&
|
||||
see(x.DeclarationSpecifiers, f) &&
|
||||
see(x.Declarator, f) &&
|
||||
f(x, false)
|
||||
case *ParameterList:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.ParameterDeclaration, f) &&
|
||||
see(x.ParameterList, f) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *ParameterTypeList:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.ParameterList, f) &&
|
||||
see(&x.Token, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
f(x, false)
|
||||
case *Pointer:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.Pointer, f) &&
|
||||
see(x.TypeQualifiers, f) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *PostfixExpression:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.ArgumentExpressionList, f) &&
|
||||
see(x.Expression, f) &&
|
||||
see(x.InitializerList, f) &&
|
||||
see(x.PostfixExpression, f) &&
|
||||
see(x.PrimaryExpression, f) &&
|
||||
see(x.TypeName, f) &&
|
||||
see(x.TypeName2, f) &&
|
||||
see(&x.Token, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token3, f) &&
|
||||
see(&x.Token4, f) &&
|
||||
see(&x.Token5, f) &&
|
||||
f(x, false)
|
||||
case *PragmaSTDC:
|
||||
return x == nil || f(x, true) &&
|
||||
see(&x.Token, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token3, f) &&
|
||||
see(&x.Token4, f) &&
|
||||
f(x, false)
|
||||
case *PrimaryExpression:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.CompoundStatement, f) &&
|
||||
see(x.Expression, f) &&
|
||||
see(&x.Token, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
f(x, false)
|
||||
case *RelationalExpression:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.RelationalExpression, f) &&
|
||||
see(x.ShiftExpression, f) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *SelectionStatement:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.Expression, f) &&
|
||||
see(x.Statement, f) &&
|
||||
see(x.Statement2, f) &&
|
||||
see(&x.Token, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token3, f) &&
|
||||
see(&x.Token4, f) &&
|
||||
f(x, false)
|
||||
case *ShiftExpression:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AdditiveExpression, f) &&
|
||||
see(x.ShiftExpression, f) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *SpecifierQualifierList:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AlignmentSpecifier, f) &&
|
||||
see(x.AttributeSpecifier, f) &&
|
||||
see(x.SpecifierQualifierList, f) &&
|
||||
see(x.TypeQualifier, f) &&
|
||||
see(x.TypeSpecifier, f) &&
|
||||
f(x, false)
|
||||
case *Statement:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AsmStatement, f) &&
|
||||
see(x.CompoundStatement, f) &&
|
||||
see(x.ExpressionStatement, f) &&
|
||||
see(x.IterationStatement, f) &&
|
||||
see(x.JumpStatement, f) &&
|
||||
see(x.LabeledStatement, f) &&
|
||||
see(x.SelectionStatement, f) &&
|
||||
f(x, false)
|
||||
case *StorageClassSpecifier:
|
||||
return x == nil || f(x, true) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *StructDeclaration:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.SpecifierQualifierList, f) &&
|
||||
see(x.StructDeclaratorList, f) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *StructDeclarationList:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.StructDeclaration, f) &&
|
||||
see(x.StructDeclarationList, f) &&
|
||||
f(x, false)
|
||||
case *StructDeclarator:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AttributeSpecifierList, f) &&
|
||||
see(x.ConstantExpression, f) &&
|
||||
see(x.Declarator, f) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *StructDeclaratorList:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.StructDeclarator, f) &&
|
||||
see(x.StructDeclaratorList, f) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *StructOrUnion:
|
||||
return x == nil || f(x, true) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *StructOrUnionSpecifier:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AttributeSpecifierList, f) &&
|
||||
see(x.StructDeclarationList, f) &&
|
||||
see(x.StructOrUnion, f) &&
|
||||
see(&x.Token, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token3, f) &&
|
||||
f(x, false)
|
||||
case *TranslationUnit:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.ExternalDeclaration, f) &&
|
||||
see(x.TranslationUnit, f) &&
|
||||
f(x, false)
|
||||
case *TypeName:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AbstractDeclarator, f) &&
|
||||
see(x.SpecifierQualifierList, f) &&
|
||||
f(x, false)
|
||||
case *TypeQualifier:
|
||||
return x == nil || f(x, true) &&
|
||||
see(&x.Token, f) &&
|
||||
f(x, false)
|
||||
case *TypeQualifiers:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AttributeSpecifier, f) &&
|
||||
see(x.TypeQualifier, f) &&
|
||||
see(x.TypeQualifiers, f) &&
|
||||
f(x, false)
|
||||
case *TypeSpecifier:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.AtomicTypeSpecifier, f) &&
|
||||
see(x.EnumSpecifier, f) &&
|
||||
see(x.Expression, f) &&
|
||||
see(x.StructOrUnionSpecifier, f) &&
|
||||
see(x.TypeName, f) &&
|
||||
see(&x.Token, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token3, f) &&
|
||||
f(x, false)
|
||||
case *UnaryExpression:
|
||||
return x == nil || f(x, true) &&
|
||||
see(x.CastExpression, f) &&
|
||||
see(x.PostfixExpression, f) &&
|
||||
see(x.TypeName, f) &&
|
||||
see(x.UnaryExpression, f) &&
|
||||
see(&x.Token, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token2, f) &&
|
||||
see(&x.Token3, f) &&
|
||||
f(x, false)
|
||||
case *Token:
|
||||
return f(x, true)
|
||||
default:
|
||||
panic(todo("internal error: %T", x))
|
||||
}
|
||||
}
|
||||
1555
vendor/modernc.org/cc/v3/lexer.go
generated
vendored
1555
vendor/modernc.org/cc/v3/lexer.go
generated
vendored
File diff suppressed because it is too large
Load diff
97
vendor/modernc.org/cc/v3/lexer.l
generated
vendored
97
vendor/modernc.org/cc/v3/lexer.l
generated
vendored
|
|
@ -1,97 +0,0 @@
|
|||
%{
|
||||
// Copyright 2019 The CC Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
%}
|
||||
|
||||
%yyc c
|
||||
%yyn c = s.next()
|
||||
%yym s.mark = len(s.charBuf)
|
||||
|
||||
%{
|
||||
package cc // import "modernc.org/cc/v3"
|
||||
|
||||
func (s *scanner) scan() (r rune) {
|
||||
%}
|
||||
|
||||
c-char [^'\n\x80\\]|{escape-sequence}
|
||||
c-char-sequence {c-char}+
|
||||
character-constant '{c-char-sequence}'
|
||||
comment "/*"([^*\x80]|\*+[^*/\x80])*\*+\/
|
||||
comment-not-terminated "/*"([^*\x80]|\*+[^*/\x80])*(\*+)?\n\x80
|
||||
digit [0-9]
|
||||
escape-sequence {simple-sequence}|{octal-escape-sequence}|{hexadecimal-escape-sequence}|{universal-character-name}
|
||||
hex-quad {hexadecimal-digit}{hexadecimal-digit}{hexadecimal-digit}{hexadecimal-digit}
|
||||
hexadecimal-digit [0-9a-fA-F]
|
||||
hexadecimal-escape-sequence \\x{hexadecimal-digit}+
|
||||
identifier {identifier-nondigit}({identifier-nondigit}|{digit}|"$")*
|
||||
identifier-nondigit {nondigit}|"$"|{universal-character-name}
|
||||
line-comment "//"[^\n\x80]*
|
||||
nondigit [_a-zA-Z\x81]
|
||||
octal-digit [0-7]
|
||||
octal-escape-sequence \\{octal-digit}{octal-digit}?{octal-digit}?
|
||||
pp-number ({digit}|\.{digit})({digit}|{identifier-nondigit}|[eEpP]{sign}|\.)*
|
||||
s-char [^\x22\n\x80\\]|{escape-sequence}
|
||||
s-char-sequence {s-char}+
|
||||
sign [-+]
|
||||
simple-sequence \\['\x22?\\abefnrtv]
|
||||
string-literal \x22{s-char-sequence}?\x22
|
||||
universal-character-name \\u{hex-quad}|\\U{hex-quad}{hex-quad}
|
||||
white-space [ \t\f\v]
|
||||
|
||||
%%
|
||||
c := s.initScan()
|
||||
|
||||
({white-space}|{comment})*{line-comment} |
|
||||
({white-space}|{comment})+{line-comment}?
|
||||
return ' '
|
||||
|
||||
(({white-space}|{comment})*{comment-not-terminated})+
|
||||
return s.unterminatedComment()
|
||||
|
||||
"!=" return NEQ
|
||||
"##" return PPPASTE
|
||||
"%:" return '#'
|
||||
"%:%:" return PPPASTE
|
||||
"%=" return MODASSIGN
|
||||
"%>" return '}'
|
||||
"&&" return ANDAND
|
||||
"&=" return ANDASSIGN
|
||||
"*=" return MULASSIGN
|
||||
"++" return INC
|
||||
"+=" return ADDASSIGN
|
||||
"--" return DEC
|
||||
"-=" return SUBASSIGN
|
||||
"->" return ARROW
|
||||
"..." return DDD
|
||||
"/=" return DIVASSIGN
|
||||
":>" return ']'
|
||||
"<%" return '{'
|
||||
"<:" return '['
|
||||
"<<" return LSH
|
||||
"<<=" return LSHASSIGN
|
||||
"<=" return LEQ
|
||||
"==" return EQ
|
||||
">=" return GEQ
|
||||
">>" return RSH
|
||||
">>=" return RSHASSIGN
|
||||
"^=" return XORASSIGN
|
||||
"|=" return ORASSIGN
|
||||
"||" return OROR
|
||||
|
||||
L{string-literal} return LONGSTRINGLITERAL
|
||||
L{character-constant} return LONGCHARCONST
|
||||
{character-constant} return CHARCONST
|
||||
{identifier} return IDENTIFIER
|
||||
{pp-number} return PPNUMBER
|
||||
{string-literal} return STRINGLITERAL
|
||||
|
||||
\r?\n return '\n'
|
||||
|
||||
%%
|
||||
if c, ok := s.abort(); ok {
|
||||
return rune(c)
|
||||
}
|
||||
|
||||
goto yyAction
|
||||
}
|
||||
1337
vendor/modernc.org/cc/v3/operand.go
generated
vendored
1337
vendor/modernc.org/cc/v3/operand.go
generated
vendored
File diff suppressed because it is too large
Load diff
4311
vendor/modernc.org/cc/v3/parser.go
generated
vendored
4311
vendor/modernc.org/cc/v3/parser.go
generated
vendored
File diff suppressed because it is too large
Load diff
1033
vendor/modernc.org/cc/v3/parser.yy
generated
vendored
1033
vendor/modernc.org/cc/v3/parser.yy
generated
vendored
File diff suppressed because it is too large
Load diff
1266
vendor/modernc.org/cc/v3/scanner.go
generated
vendored
1266
vendor/modernc.org/cc/v3/scanner.go
generated
vendored
File diff suppressed because it is too large
Load diff
99
vendor/modernc.org/cc/v3/stringer.go
generated
vendored
99
vendor/modernc.org/cc/v3/stringer.go
generated
vendored
|
|
@ -1,99 +0,0 @@
|
|||
// Code generated by "stringer -output stringer.go -linecomment -type=Kind,Linkage"; DO NOT EDIT.
|
||||
|
||||
package cc
|
||||
|
||||
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[Invalid-0]
|
||||
_ = x[Array-1]
|
||||
_ = x[Bool-2]
|
||||
_ = x[Char-3]
|
||||
_ = x[ComplexChar-4]
|
||||
_ = x[ComplexDouble-5]
|
||||
_ = x[ComplexFloat-6]
|
||||
_ = x[ComplexInt-7]
|
||||
_ = x[ComplexLong-8]
|
||||
_ = x[ComplexLongDouble-9]
|
||||
_ = x[ComplexLongLong-10]
|
||||
_ = x[ComplexShort-11]
|
||||
_ = x[ComplexUInt-12]
|
||||
_ = x[ComplexULong-13]
|
||||
_ = x[ComplexULongLong-14]
|
||||
_ = x[ComplexUShort-15]
|
||||
_ = x[Decimal128-16]
|
||||
_ = x[Decimal32-17]
|
||||
_ = x[Decimal64-18]
|
||||
_ = x[Double-19]
|
||||
_ = x[Enum-20]
|
||||
_ = x[Float-21]
|
||||
_ = x[Float128-22]
|
||||
_ = x[Float32-23]
|
||||
_ = x[Float32x-24]
|
||||
_ = x[Float64-25]
|
||||
_ = x[Float64x-26]
|
||||
_ = x[Function-27]
|
||||
_ = x[Int-28]
|
||||
_ = x[Int8-29]
|
||||
_ = x[Int16-30]
|
||||
_ = x[Int32-31]
|
||||
_ = x[Int64-32]
|
||||
_ = x[Int128-33]
|
||||
_ = x[Long-34]
|
||||
_ = x[LongDouble-35]
|
||||
_ = x[LongLong-36]
|
||||
_ = x[Ptr-37]
|
||||
_ = x[SChar-38]
|
||||
_ = x[Short-39]
|
||||
_ = x[Struct-40]
|
||||
_ = x[TypedefName-41]
|
||||
_ = x[UChar-42]
|
||||
_ = x[UInt-43]
|
||||
_ = x[UInt8-44]
|
||||
_ = x[UInt16-45]
|
||||
_ = x[UInt32-46]
|
||||
_ = x[UInt64-47]
|
||||
_ = x[UInt128-48]
|
||||
_ = x[ULong-49]
|
||||
_ = x[ULongLong-50]
|
||||
_ = x[UShort-51]
|
||||
_ = x[Union-52]
|
||||
_ = x[Void-53]
|
||||
_ = x[Vector-54]
|
||||
_ = x[typeofExpr-55]
|
||||
_ = x[typeofType-56]
|
||||
_ = x[maxKind-57]
|
||||
}
|
||||
|
||||
const _Kind_name = "InvalidT[]_Boolcharcomplex charcomplex doublecomplex floatcomplex intcomplex longcomplex long doublecomplex long longcomplex shortcomplex unsignedcomplex unsigned longcomplex unsigned long longcomplex shor_Decimal128_Decimal32_Decimal64doubleenumfloat_Float128_Float32_Float32x_Float64_Float64xfunctionint__int8__int16__int32__int64__int128longlong doublelong longpointersigned charshortstructtypedefnameunsigned charunsignedunsigned __int8unsigned __int16unsigned __int32unsigned __int64unsigned __int128unsigned longunsigned long longunsigned shortunionvoidvectortypeofExprtypeofTypemaxKind"
|
||||
|
||||
var _Kind_index = [...]uint16{0, 7, 10, 15, 19, 31, 45, 58, 69, 81, 100, 117, 130, 146, 167, 193, 205, 216, 226, 236, 242, 246, 251, 260, 268, 277, 285, 294, 302, 305, 311, 318, 325, 332, 340, 344, 355, 364, 371, 382, 387, 393, 404, 417, 425, 440, 456, 472, 488, 505, 518, 536, 550, 555, 559, 565, 575, 585, 592}
|
||||
|
||||
func (i Kind) String() string {
|
||||
if i >= Kind(len(_Kind_index)-1) {
|
||||
return "Kind(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||
}
|
||||
return _Kind_name[_Kind_index[i]:_Kind_index[i+1]]
|
||||
}
|
||||
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[None-0]
|
||||
_ = x[Internal-1]
|
||||
_ = x[External-2]
|
||||
}
|
||||
|
||||
const _Linkage_name = "NoneInternalExternal"
|
||||
|
||||
var _Linkage_index = [...]uint8{0, 4, 12, 20}
|
||||
|
||||
func (i Linkage) String() string {
|
||||
if i < 0 || i >= Linkage(len(_Linkage_index)-1) {
|
||||
return "Linkage(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||
}
|
||||
return _Linkage_name[_Linkage_index[i]:_Linkage_index[i+1]]
|
||||
}
|
||||
3266
vendor/modernc.org/cc/v3/type.go
generated
vendored
3266
vendor/modernc.org/cc/v3/type.go
generated
vendored
File diff suppressed because it is too large
Load diff
4
vendor/modernc.org/cc/v3/unconvert.sh
generated
vendored
4
vendor/modernc.org/cc/v3/unconvert.sh
generated
vendored
|
|
@ -1,4 +0,0 @@
|
|||
until unconvert -fastmath . &> /dev/null
|
||||
do
|
||||
unconvert -fastmath -apply . &> /dev/null
|
||||
done
|
||||
27
vendor/modernc.org/ccgo/v3/LICENSE
generated
vendored
27
vendor/modernc.org/ccgo/v3/LICENSE
generated
vendored
|
|
@ -1,27 +0,0 @@
|
|||
Copyright (c) 2017 The CCGO 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 names of the authors nor the names of the
|
||||
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.
|
||||
141
vendor/modernc.org/ccgo/v3/lib/Makefile
generated
vendored
141
vendor/modernc.org/ccgo/v3/lib/Makefile
generated
vendored
|
|
@ -1,141 +0,0 @@
|
|||
# Copyright 2019 The CCGO Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style
|
||||
# license that can be found in the LICENSE file.
|
||||
|
||||
.PHONY: all bench clean cover cpu editor internalError later mem nuke todo edit devbench
|
||||
|
||||
grep=--include=*.go
|
||||
ngrep='TODOOK\|internalError\|testdata'
|
||||
testlog=testdata/testlog-$(shell echo $$GOOS)-$(shell echo $$GOARCH)-on-$(shell go env GOOS)-$(shell go env GOARCH)
|
||||
|
||||
all:
|
||||
LC_ALL=C make all_log 2>&1 | tee log
|
||||
|
||||
all_log:
|
||||
date
|
||||
go version
|
||||
uname -a
|
||||
./unconvert.sh
|
||||
gofmt -l -s -w *.go
|
||||
GOOS=darwin GOARCH=amd64 go build -o /dev/null
|
||||
GOOS=linux GOARCH=386 go build -o /dev/null
|
||||
GOOS=linux GOARCH=amd64 go build -o /dev/null
|
||||
GOOS=linux GOARCH=arm go build -o /dev/null
|
||||
GOOS=windows GOARCH=386 go build -o /dev/null
|
||||
GOOS=windows GOARCH=amd64 go build -o /dev/null
|
||||
go vet 2>&1 | grep -v $(ngrep) || true
|
||||
golint 2>&1 | grep -v $(ngrep) || true
|
||||
make todo
|
||||
misspell *.go
|
||||
staticcheck | grep -v 'lexer\.go' || true
|
||||
maligned || true
|
||||
grep -n 'files.*, ok' log
|
||||
@grep -n --color=never 'FAIL\|PASS' log
|
||||
@grep -n --color=always 'FAIL' log
|
||||
grep -n --color=always 'nil pointer' log
|
||||
grep -c 'exit status 1' log || true
|
||||
grep -c 'exit status 2' log || true
|
||||
LC_ALL=C date 2>&1 | tee -a log
|
||||
|
||||
test:
|
||||
LC_ALL=C make test_log 2>&1 | tee $(testlog)
|
||||
grep -ni --color=always fail $(testlog) || true
|
||||
|
||||
test_log:
|
||||
go version
|
||||
uname -a
|
||||
go test -v -timeout 24h
|
||||
date | tee -a $(testlog)
|
||||
|
||||
test_linux_amd64:
|
||||
GOOS=linux GOARCH=amd64 make test
|
||||
|
||||
test_linux_386:
|
||||
GOOS=linux GOARCH=386 make test
|
||||
|
||||
test_linux_arm:
|
||||
GOOS=linux GOARCH=arm make test
|
||||
|
||||
test_linux_arm64:
|
||||
GOOS=linux GOARCH=arm64 make test
|
||||
|
||||
test_windows_386:
|
||||
go version | tee %TEMP%\testlog-windows-386
|
||||
go test -v -timeout 24h | tee -a %TEMP%\testlog-windows-386
|
||||
date /T | tee -a %TEMP%\testlog-windows-386
|
||||
time /T | tee -a %TEMP%\testlog-windows-386
|
||||
|
||||
test_windows_amd64:
|
||||
go version | tee %TEMP%\testlog-windows-amd64
|
||||
go test -v -timeout 24h | tee -a %TEMP%\testlog-windows-amd64
|
||||
date /T | tee -a %TEMP%\testlog-windows-amd64
|
||||
time /T | tee -a %TEMP%\testlog-windows-amd64
|
||||
|
||||
build_all_targets:
|
||||
GOOS=darwin GOARCH=amd64 go test -c -o /dev/null
|
||||
GOOS=darwin GOARCH=arm64 go test -c -o /dev/null
|
||||
GOOS=freebsd GOARCH=386 go test -c -o /dev/null
|
||||
GOOS=freebsd GOARCH=amd64 go test -c -o /dev/null
|
||||
GOOS=freebsd GOARCH=arm go test -c -o /dev/null
|
||||
GOOS=linux GOARCH=386 go test -c -o /dev/null
|
||||
GOOS=linux GOARCH=amd64 go test -c -o /dev/null
|
||||
GOOS=linux GOARCH=arm go test -c -o /dev/null
|
||||
GOOS=linux GOARCH=arm64 go test -c -o /dev/null
|
||||
GOOS=linux GOARCH=riscv64 go test -c -o /dev/null
|
||||
GOOS=linux GOARCH=s390x go test -c -o /dev/null
|
||||
GOOS=netbsd GOARCH=amd64 go test -c -o /dev/null
|
||||
#TODO GOOS=netbsd GOARCH=arm go test -c -o /dev/null
|
||||
GOOS=openbsd GOARCH=amd64 go test -c -o /dev/null
|
||||
GOOS=openbsd GOARCH=arm64 go test -c -o /dev/null
|
||||
GOOS=windows GOARCH=386 go test -c -o /dev/null
|
||||
GOOS=windows GOARCH=amd64 go test -c -o /dev/null
|
||||
GOOS=windows GOARCH=arm64 go test -c -o /dev/null
|
||||
|
||||
devbench:
|
||||
date 2>&1 | tee log-devbench
|
||||
go test -timeout 24h -dev -run @ -bench . 2>&1 | tee -a log-devbench
|
||||
grep -n 'FAIL\|SKIP' log-devbench || true
|
||||
|
||||
bench:
|
||||
date 2>&1 | tee log-bench
|
||||
go test -timeout 24h -v -run '^[^E]' -bench . 2>&1 | tee -a log-bench
|
||||
grep -n 'FAIL\|SKIP' log-bench || true
|
||||
|
||||
clean:
|
||||
go clean
|
||||
rm -f *~ *.test *.out
|
||||
|
||||
cover:
|
||||
t=$(shell mktemp) ; go test -coverprofile $$t && go tool cover -html $$t && unlink $$t
|
||||
|
||||
cpu: clean
|
||||
go test -run @ -bench . -cpuprofile cpu.out
|
||||
go tool pprof -lines *.test cpu.out
|
||||
|
||||
edit:
|
||||
@touch log
|
||||
@if [ -f "Session.vim" ]; then gvim -S & else gvim -p Makefile *.go & fi
|
||||
|
||||
|
||||
editor:
|
||||
gofmt -l -s -w *.go
|
||||
go build -v -o $(GOPATH)/bin/ccgo3 modernc.org/ccgo/v3
|
||||
go test -c -o /dev/null
|
||||
|
||||
later:
|
||||
@grep -n $(grep) LATER * || true
|
||||
@grep -n $(grep) MAYBE * || true
|
||||
|
||||
mem: clean
|
||||
go test -run Mem -mem -memprofile mem.out -timeout 24h
|
||||
go tool pprof -lines -web -alloc_space *.test mem.out
|
||||
|
||||
nuke: clean
|
||||
go clean -i
|
||||
|
||||
todo:
|
||||
@grep -nr $(grep) ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* * | grep -v $(ngrep) || true
|
||||
@grep -nr $(grep) 'TODO\|panic' * | grep -v $(ngrep) || true
|
||||
@grep -nr $(grep) BUG * | grep -v $(ngrep) || true
|
||||
@grep -nr $(grep) [^[:alpha:]]println * | grep -v $(ngrep) || true
|
||||
@grep -nir $(grep) 'work.*progress' || true
|
||||
2148
vendor/modernc.org/ccgo/v3/lib/ccgo.go
generated
vendored
2148
vendor/modernc.org/ccgo/v3/lib/ccgo.go
generated
vendored
File diff suppressed because it is too large
Load diff
39
vendor/modernc.org/ccgo/v3/lib/cover.go
generated
vendored
39
vendor/modernc.org/ccgo/v3/lib/cover.go
generated
vendored
|
|
@ -1,39 +0,0 @@
|
|||
// Copyright 2020 The CCGO 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 ccgo // import "modernc.org/ccgo/v3/lib"
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
coverMap = map[uintptr]struct{}{}
|
||||
)
|
||||
|
||||
func pc2origin(pc uintptr) string {
|
||||
f := runtime.FuncForPC(pc)
|
||||
var fn, fns string
|
||||
var fl int
|
||||
if f != nil {
|
||||
fn, fl = f.FileLine(pc)
|
||||
fns = f.Name()
|
||||
if x := strings.LastIndex(fns, "."); x > 0 {
|
||||
fns = fns[x+1:]
|
||||
}
|
||||
}
|
||||
return fmt.Sprintf("%s:%d:%s", fn, fl, fns)
|
||||
}
|
||||
|
||||
func coverReport() string {
|
||||
var a []string
|
||||
for pc := range coverMap {
|
||||
a = append(a, pc2origin(pc))
|
||||
}
|
||||
sort.Strings(a)
|
||||
return strings.Join(a, "\n")
|
||||
}
|
||||
91
vendor/modernc.org/ccgo/v3/lib/design-notes.adoc
generated
vendored
91
vendor/modernc.org/ccgo/v3/lib/design-notes.adoc
generated
vendored
|
|
@ -1,91 +0,0 @@
|
|||
= Design Notes
|
||||
|
||||
== Problems:
|
||||
|
||||
Translating C to Go is harder than it looks.
|
||||
|
||||
Jan says: It's impossible in the general case to turn C char* into Go
|
||||
[]byte. It's possible to do it probably often for concrete C code
|
||||
cases - based also on author's C coding style. The first problem this
|
||||
runs into is that Go does not guarantee that the backing array will
|
||||
keep its address stable due to Go movable stacks. C expects the
|
||||
opposite, a pointer never magically modifies itself, so some code will
|
||||
fail.
|
||||
|
||||
INSERT CODE EXAMPLES ILLUSTRATING THE PROBLEM HERE
|
||||
|
||||
== How the parser works
|
||||
|
||||
There are no comment nodes in the C AST. Instead every cc.Token has a
|
||||
Sep field: https://godoc.org/modernc.org/cc/v3#Token
|
||||
|
||||
It captures, when configured to do so, all white space preceding the
|
||||
token, combined, including comments, if any. So we have all white
|
||||
space/comments information for every token in the AST. A final white
|
||||
space/comment, preceding EOF, is available as field TrailingSeperator
|
||||
in the AST: https://godoc.org/modernc.org/cc/v3#AST.
|
||||
|
||||
To get the lexically first white space/comment for any node, use
|
||||
tokenSeparator():
|
||||
https://gitlab.com/cznic/ccgo/-/blob/6551e2544a758fdc265c8fac71fb2587fb3e1042/v3/go.go#L1476
|
||||
|
||||
The same with a default value is comment():
|
||||
https://gitlab.com/cznic/ccgo/-/blob/6551e2544a758fdc265c8fac71fb2587fb3e1042/v3/go.go#L1467
|
||||
|
||||
== Looking forward
|
||||
|
||||
Eric says: In my visualization of how the translator would work, the
|
||||
output of a ccgo translation of a module at any given time is a file
|
||||
of pseudo-Go code in which some sections may be enclosed by a Unicode
|
||||
bracketing character (presently using the guillemot quotes U+ab and
|
||||
U+bb) meaning "this is not Go yet" that intentionally makes the Go
|
||||
compiler barf. This expresses a color on the AST nodes.
|
||||
|
||||
So, for example, if I'm translating hello.c with a ruleset that does not
|
||||
include print -> fmt.Printf, this:
|
||||
|
||||
---------------------------------------------------------
|
||||
#include <stdio>
|
||||
|
||||
/* an example comment */
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
printf("Hello, World")
|
||||
}
|
||||
---------------------------------------------------------
|
||||
|
||||
becomes this without any explicit rules at all:
|
||||
|
||||
---------------------------------------------------------
|
||||
«#include <stdio>»
|
||||
|
||||
/* an example comment */
|
||||
|
||||
func main
|
||||
{
|
||||
«printf(»"Hello, World"!\n"«)»
|
||||
}
|
||||
---------------------------------------------------------
|
||||
|
||||
Then, when the rule print -> fmt.Printf is added, it becomes
|
||||
|
||||
---------------------------------------------------------
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
/* an example comment */
|
||||
|
||||
func main
|
||||
{
|
||||
fmt.Printf("Hello, World"!\n")
|
||||
}
|
||||
---------------------------------------------------------
|
||||
|
||||
because with that rule the AST node corresponding to the printf
|
||||
call can be translated and colored "Go". This implies an import
|
||||
of fmt. We observe that there are no longer C-colored spans
|
||||
and drop the #includes.
|
||||
|
||||
// end
|
||||
43
vendor/modernc.org/ccgo/v3/lib/dmesg.go
generated
vendored
43
vendor/modernc.org/ccgo/v3/lib/dmesg.go
generated
vendored
|
|
@ -1,43 +0,0 @@
|
|||
// Copyright 2021 The CCGO 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 ccgo.dmesg
|
||||
// +build ccgo.dmesg
|
||||
|
||||
package ccgo // import "modernc.org/ccgo/v3/lib"
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const dmesgs = true
|
||||
|
||||
var (
|
||||
pid = fmt.Sprintf("[%v %v] ", os.Getpid(), filepath.Base(os.Args[0]))
|
||||
logf *os.File
|
||||
)
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
if logf, err = os.OpenFile("/tmp/ccgo.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY|os.O_SYNC, 0644); err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func dmesg(s string, args ...interface{}) {
|
||||
if s == "" {
|
||||
s = strings.Repeat("%v ", len(args))
|
||||
}
|
||||
s = fmt.Sprintf(s, args...)
|
||||
s = pid + s
|
||||
switch {
|
||||
case len(s) != 0 && s[len(s)-1] == '\n':
|
||||
fmt.Fprint(logf, s)
|
||||
default:
|
||||
fmt.Fprintln(logf, s)
|
||||
}
|
||||
}
|
||||
110
vendor/modernc.org/ccgo/v3/lib/etc.go
generated
vendored
110
vendor/modernc.org/ccgo/v3/lib/etc.go
generated
vendored
|
|
@ -1,110 +0,0 @@
|
|||
// Copyright 2020 The CCGO 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 ccgo // import "modernc.org/ccgo/v3/lib"
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"math/big"
|
||||
|
||||
"modernc.org/cc/v3"
|
||||
)
|
||||
|
||||
var (
|
||||
reservedNames = map[string]bool{
|
||||
"bool": false, // ccgo can use
|
||||
"break": true, // keyword
|
||||
"case": true, // keyword
|
||||
"chan": true, // keyword
|
||||
"const": true, // keyword
|
||||
"continue": true, // keyword
|
||||
"default": true, // keyword
|
||||
"defer": true, // keyword
|
||||
"else": true, // keyword
|
||||
"fallthrough": true, // keyword
|
||||
"false": false, // ccgo can use
|
||||
"float32": false, // ccgo can use
|
||||
"float64": false, // ccgo can use
|
||||
"for": true, // keyword
|
||||
"func": true, // keyword
|
||||
"go": true, // keyword
|
||||
"goto": true, // keyword
|
||||
"if": true, // keyword
|
||||
"import": true, // keyword
|
||||
"init": false, // special name
|
||||
"int16": false, // ccgo can use
|
||||
"int32": false, // ccgo can use
|
||||
"int64": false, // ccgo can use
|
||||
"int8": false, // ccgo can use
|
||||
"interface": true, // keyword
|
||||
"map": true, // keyword
|
||||
"math": false, // package name
|
||||
"nil": false, // ccgo can use
|
||||
"package": true, // keyword
|
||||
"range": true, // keyword
|
||||
"return": true, // keyword
|
||||
"select": true, // keyword
|
||||
"struct": true, // keyword
|
||||
"switch": true, // keyword
|
||||
"true": false, // ccgo can use
|
||||
"type": true, // keyword
|
||||
"types": false, // package name
|
||||
"uint16": false, // ccgo can use
|
||||
"uint32": false, // ccgo can use
|
||||
"uint64": false, // ccgo can use
|
||||
"uint8": false, // ccgo can use
|
||||
"uintptr": false, // ccgo can use
|
||||
"unsafe": false, // package name
|
||||
"var": true, // keyword
|
||||
}
|
||||
|
||||
reservedIds []cc.StringID
|
||||
|
||||
maxInt32 = big.NewInt(math.MaxInt32)
|
||||
maxInt64 = big.NewInt(math.MaxInt64)
|
||||
maxUint32 = big.NewInt(math.MaxUint32)
|
||||
maxUint64 = big.NewInt(0).SetUint64(math.MaxUint64)
|
||||
minInt32 = big.NewInt(math.MinInt32)
|
||||
minInt64 = big.NewInt(math.MinInt64)
|
||||
)
|
||||
|
||||
func init() {
|
||||
for k := range reservedNames {
|
||||
reservedIds = append(reservedIds, cc.String(k))
|
||||
}
|
||||
}
|
||||
|
||||
type scope map[cc.StringID]int32
|
||||
|
||||
func newScope() scope {
|
||||
s := scope{}
|
||||
for _, k := range reservedIds {
|
||||
s[k] = 0
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
func (s scope) take(t cc.StringID) string {
|
||||
if t == 0 {
|
||||
panic(todo("internal error"))
|
||||
}
|
||||
|
||||
n, ok := s[t]
|
||||
if !ok {
|
||||
s[t] = 0
|
||||
return t.String()
|
||||
}
|
||||
|
||||
for {
|
||||
n++
|
||||
s[t] = n
|
||||
r := fmt.Sprintf("%s%d", t, n)
|
||||
id := cc.String(r)
|
||||
if _, ok := s[id]; !ok {
|
||||
s[id] = 0
|
||||
return r
|
||||
}
|
||||
}
|
||||
}
|
||||
13164
vendor/modernc.org/ccgo/v3/lib/go.go
generated
vendored
13164
vendor/modernc.org/ccgo/v3/lib/go.go
generated
vendored
File diff suppressed because it is too large
Load diff
553
vendor/modernc.org/ccgo/v3/lib/init.go
generated
vendored
553
vendor/modernc.org/ccgo/v3/lib/init.go
generated
vendored
|
|
@ -1,553 +0,0 @@
|
|||
// Copyright 2020 The CCGO 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 ccgo // import "modernc.org/ccgo/v3/lib"
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"modernc.org/cc/v3"
|
||||
)
|
||||
|
||||
func isAggregateTypeOrUnion(t cc.Type) bool {
|
||||
switch t.Kind() {
|
||||
case cc.Struct, cc.Union, cc.Array:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// 6.7.8 Initialization
|
||||
func (p *project) initializer(f *function, n *cc.Initializer, t cc.Type, sc cc.StorageClass, tld *tld) {
|
||||
lm := map[*cc.Initializer][]cc.StringID{}
|
||||
tm := map[*cc.Initializer][]cc.StringID{}
|
||||
s := p.initializerFlatten(n, lm, tm)
|
||||
sort.Slice(s, func(i, j int) bool {
|
||||
a := s[i]
|
||||
b := s[j]
|
||||
if a.Offset < b.Offset {
|
||||
return true
|
||||
}
|
||||
|
||||
if a.Offset > b.Offset {
|
||||
return false
|
||||
}
|
||||
|
||||
if a.Field == nil || b.Field == nil || !a.Field.IsBitField() || !b.Field.IsBitField() {
|
||||
panic(todo("%v: internal error: off %#x, %v: off %#x, t %v", a.Position(), a.Offset, b.Position(), b.Offset, t))
|
||||
}
|
||||
|
||||
return a.Field.BitFieldOffset() < b.Field.BitFieldOffset()
|
||||
})
|
||||
p.initializerInner("", 0, f, s, t, sc, tld, nil, lm, tm)
|
||||
}
|
||||
|
||||
func (p *project) initializerInner(tag string, off uintptr, f *function, s []*cc.Initializer, t cc.Type, sc cc.StorageClass, tld *tld, patchField cc.Field, lm, tm map[*cc.Initializer][]cc.StringID) {
|
||||
// 11: The initializer for a scalar shall be a single expression, optionally
|
||||
// enclosed in braces. The initial value of the object is that of the
|
||||
// expression (after conversion); the same type constraints and conversions as
|
||||
// for simple assignment apply, taking the type of the scalar to be the
|
||||
// unqualified version of its declared type.
|
||||
if t.IsScalarType() && len(s) == 1 {
|
||||
p.w("%s%s", tidyComment("", s[0]), tag)
|
||||
switch {
|
||||
case tld != nil && t.Kind() == cc.Ptr && s[0].AssignmentExpression.Operand.Value() == nil:
|
||||
tld.patches = append(tld.patches, initPatch{t, s[0], patchField})
|
||||
p.w(" 0 ")
|
||||
default:
|
||||
p.assignmentExpression(f, s[0].AssignmentExpression, t, exprValue, 0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 12: The rest of this subclause deals with initializers for objects that have
|
||||
// aggregate or union type.
|
||||
|
||||
k := t.Kind()
|
||||
|
||||
// 13: The initializer for a structure or union object that has automatic
|
||||
// storage duration shall be either an initializer list as described below, or
|
||||
// a single expression that has compatible structure or union type. In the
|
||||
// latter case, the initial value of the object, including unnamed members, is
|
||||
// that of the expression.
|
||||
if sc == cc.Automatic && len(s) == 1 {
|
||||
switch k {
|
||||
case cc.Struct, cc.Union:
|
||||
if compatibleStructOrUnion(t, s[0].AssignmentExpression.Operand.Type()) {
|
||||
p.w("%s%s", tidyComment("", s[0]), tag)
|
||||
p.assignmentExpression(f, s[0].AssignmentExpression, t, exprValue, 0)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if k == cc.Array && len(s) == 1 {
|
||||
et := t.Elem()
|
||||
switch {
|
||||
case isCharType(et):
|
||||
// 14: An array of character type may be initialized by a character string
|
||||
// literal, optionally enclosed in braces. Successive characters of the
|
||||
// character string literal (including the terminating null character if there
|
||||
// is room or if the array is of unknown size) initialize the elements of the
|
||||
// array.
|
||||
if x, ok := s[0].AssignmentExpression.Operand.Value().(cc.StringValue); ok {
|
||||
p.w("%s%s", tidyComment("", s[0]), tag)
|
||||
str := cc.StringID(x).String()
|
||||
slen := uintptr(len(str)) + 1
|
||||
alen := t.Len()
|
||||
switch {
|
||||
case alen < slen-1:
|
||||
p.w("*(*%s)(unsafe.Pointer(%s))", p.typ(s[0], t), p.stringLiteralString(str[:alen]))
|
||||
case alen < slen:
|
||||
p.w("*(*%s)(unsafe.Pointer(%s))", p.typ(s[0], t), p.stringLiteralString(str))
|
||||
default: // alen >= slen
|
||||
p.w("*(*%s)(unsafe.Pointer(%s))", p.typ(s[0], t), p.stringLiteralString(str+strings.Repeat("\x00", int(alen-slen))))
|
||||
}
|
||||
return
|
||||
}
|
||||
case p.isWCharType(et):
|
||||
// 15: An array with element type compatible with wchar_t may be initialized by
|
||||
// a wide string literal, optionally enclosed in braces. Successive wide
|
||||
// characters of the wide string literal (including the terminating null wide
|
||||
// character if there is room or if the array is of unknown size) initialize
|
||||
// the elements of the array.
|
||||
if x, ok := s[0].AssignmentExpression.Operand.Value().(cc.WideStringValue); ok {
|
||||
p.w("%s%s", tidyComment("", s[0]), tag)
|
||||
str := []rune(cc.StringID(x).String())
|
||||
slen := uintptr(len(str)) + 1
|
||||
alen := t.Len()
|
||||
switch {
|
||||
case alen < slen-1:
|
||||
panic(todo("", p.pos(s[0])))
|
||||
case alen < slen:
|
||||
p.w("*(*%s)(unsafe.Pointer(%s))", p.typ(s[0], t), p.wideStringLiteral(x, 0))
|
||||
default: // alen >= slen
|
||||
p.w("*(*%s)(unsafe.Pointer(%s))", p.typ(s[0], t), p.wideStringLiteral(x, int(alen-slen)))
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 16: Otherwise, the initializer for an object that has aggregate or union
|
||||
// type shall be a brace-enclosed list of initializers for the elements or
|
||||
// named members.
|
||||
switch k {
|
||||
case cc.Array:
|
||||
p.initializerArray(tag, off, f, s, t, sc, tld, lm, tm)
|
||||
case cc.Struct:
|
||||
p.initializerStruct(tag, off, f, s, t, sc, tld, lm, tm)
|
||||
case cc.Union:
|
||||
p.initializerUnion(tag, off, f, s, t, sc, tld, lm, tm)
|
||||
default:
|
||||
panic(todo("%v: internal error: %v alias %v %v", s[0].Position(), t, t.Alias(), len(s)))
|
||||
}
|
||||
}
|
||||
|
||||
func (p *project) initializerArray(tag string, off uintptr, f *function, s []*cc.Initializer, t cc.Type, sc cc.StorageClass, tld *tld, lm, tm map[*cc.Initializer][]cc.StringID) {
|
||||
if len(s) == 0 {
|
||||
p.w("%s%s{}", tag, p.typ(nil, t))
|
||||
return
|
||||
}
|
||||
|
||||
et := t.Elem()
|
||||
esz := et.Size()
|
||||
s0 := s[0]
|
||||
p.w("%s%s%s{", initComment(s0, lm), tag, p.typ(s0, t))
|
||||
var a [][]*cc.Initializer
|
||||
for len(s) != 0 {
|
||||
s2, parts, _ := p.initializerArrayElement(off, s, esz)
|
||||
s = s2
|
||||
a = append(a, parts)
|
||||
}
|
||||
mustIndex := uintptr(len(a)) != t.Len()
|
||||
var parts []*cc.Initializer
|
||||
for _, parts = range a {
|
||||
var comma *cc.Token
|
||||
comma = parts[len(parts)-1].TrailingComma()
|
||||
elemOff := (parts[0].Offset - off) / esz * esz
|
||||
tag = ""
|
||||
if mustIndex {
|
||||
tag = fmt.Sprintf("%d:", elemOff/esz)
|
||||
}
|
||||
p.initializerInner(tag, off+elemOff, f, parts, et, sc, tld, nil, lm, tm)
|
||||
p.preCommaSep(comma)
|
||||
p.w(",")
|
||||
}
|
||||
p.w("%s}", initComment(parts[len(parts)-1], tm))
|
||||
}
|
||||
|
||||
func initComment(n *cc.Initializer, m map[*cc.Initializer][]cc.StringID) string {
|
||||
a := m[n]
|
||||
if len(a) == 0 {
|
||||
return ""
|
||||
}
|
||||
|
||||
m[n] = a[1:]
|
||||
return tidyCommentString(a[0].String())
|
||||
}
|
||||
|
||||
func (p *project) initializerArrayElement(off uintptr, s []*cc.Initializer, elemSize uintptr) (r []*cc.Initializer, parts []*cc.Initializer, isZero bool) {
|
||||
r = s
|
||||
isZero = true
|
||||
valueOff := s[0].Offset - off
|
||||
elemOff := valueOff - valueOff%elemSize
|
||||
nextOff := elemOff + elemSize
|
||||
for len(s) != 0 {
|
||||
if v := s[0]; v.Offset-off < nextOff {
|
||||
s = s[1:]
|
||||
parts = append(parts, v)
|
||||
if !v.AssignmentExpression.Operand.IsZero() {
|
||||
isZero = false
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
return r[len(parts):], parts, isZero
|
||||
}
|
||||
|
||||
func (p *project) initializerStruct(tag string, off uintptr, f *function, s []*cc.Initializer, t cc.Type, sc cc.StorageClass, tld *tld, lm, tm map[*cc.Initializer][]cc.StringID) {
|
||||
if len(s) == 0 {
|
||||
p.w("%s%s{}", tag, p.typ(nil, t))
|
||||
return
|
||||
}
|
||||
|
||||
if t.HasFlexibleMember() {
|
||||
p.err(s[0], "flexible array members not supported")
|
||||
return
|
||||
}
|
||||
|
||||
p.w("%s%s%s{", initComment(s[0], lm), tag, p.typ(s[0], t))
|
||||
var parts []*cc.Initializer
|
||||
var isZero bool
|
||||
var fld cc.Field
|
||||
for len(s) != 0 {
|
||||
var comma *cc.Token
|
||||
s, fld, parts, isZero = p.structInitializerParts(off, s, t)
|
||||
if isZero {
|
||||
continue
|
||||
}
|
||||
|
||||
if fld.Type().IsIncomplete() {
|
||||
panic(todo(""))
|
||||
}
|
||||
|
||||
comma = parts[len(parts)-1].TrailingComma()
|
||||
tag = fmt.Sprintf("%s:", p.fieldName2(parts[0], fld))
|
||||
ft := fld.Type()
|
||||
switch {
|
||||
case fld.IsBitField():
|
||||
bft := p.bitFileType(parts[0], fld.BitFieldBlockWidth())
|
||||
off0 := fld.Offset()
|
||||
first := true
|
||||
for _, v := range parts {
|
||||
if v.AssignmentExpression.Operand.IsZero() {
|
||||
continue
|
||||
}
|
||||
|
||||
if !first {
|
||||
p.w("|")
|
||||
}
|
||||
first = false
|
||||
bitFld := v.Field
|
||||
p.w("%s%s", tidyComment("", v.AssignmentExpression), tag)
|
||||
tag = ""
|
||||
p.assignmentExpression(f, v.AssignmentExpression, bft, exprValue, 0)
|
||||
p.w("&%#x", uint64(1)<<uint64(bitFld.BitFieldWidth())-1)
|
||||
if o := bitFld.BitFieldOffset() + 8*int((bitFld.Offset()-off0)); o != 0 {
|
||||
p.w("<<%d", o)
|
||||
}
|
||||
}
|
||||
default:
|
||||
p.initializerInner(tag, off+fld.Offset(), f, parts, ft, sc, tld, fld, lm, tm)
|
||||
}
|
||||
p.preCommaSep(comma)
|
||||
p.w(",")
|
||||
}
|
||||
p.w("%s}", initComment(parts[len(parts)-1], tm))
|
||||
}
|
||||
|
||||
func (p *project) preCommaSep(comma *cc.Token) {
|
||||
if comma == nil {
|
||||
return
|
||||
}
|
||||
|
||||
p.w("%s", strings.TrimSpace(comma.Sep.String()))
|
||||
}
|
||||
|
||||
func (p *project) structInitializerParts(off uintptr, s []*cc.Initializer, t cc.Type) (r []*cc.Initializer, fld cc.Field, parts []*cc.Initializer, isZero bool) {
|
||||
if len(s) == 0 {
|
||||
return nil, nil, nil, true
|
||||
}
|
||||
|
||||
part := s[0]
|
||||
isZero = part.AssignmentExpression.Operand.IsZero()
|
||||
parts = append(parts, part)
|
||||
s = s[1:]
|
||||
fld, _, fNext := p.containingStructField(part, off, t)
|
||||
for len(s) != 0 {
|
||||
part = s[0]
|
||||
vOff := part.Offset
|
||||
if vOff >= fNext {
|
||||
break
|
||||
}
|
||||
|
||||
isZero = isZero && part.AssignmentExpression.Operand.IsZero()
|
||||
parts = append(parts, part)
|
||||
s = s[1:]
|
||||
}
|
||||
return s, fld, parts, isZero
|
||||
}
|
||||
|
||||
func (p *project) containingStructField(part *cc.Initializer, off uintptr, t cc.Type) (f cc.Field, fOff, fNext uintptr) {
|
||||
nf := t.NumField()
|
||||
vOff := part.Offset
|
||||
for i := []int{0}; i[0] < nf; i[0]++ {
|
||||
f = t.FieldByIndex(i)
|
||||
if f.IsBitField() && f.Name() == 0 { // Anonymous bit fields cannot be initialized.
|
||||
continue
|
||||
}
|
||||
|
||||
fOff = off + f.Offset()
|
||||
switch {
|
||||
case f.IsBitField():
|
||||
fNext = fOff + uintptr(f.BitFieldBlockWidth())>>3
|
||||
default:
|
||||
fNext = fOff + f.Type().Size()
|
||||
}
|
||||
if vOff >= fOff && vOff < fNext {
|
||||
return f, fOff, fNext
|
||||
}
|
||||
}
|
||||
|
||||
panic(todo("%v: internal error", p.pos(part)))
|
||||
}
|
||||
|
||||
func (p *project) initializerUnion(tag string, off uintptr, f *function, s []*cc.Initializer, t cc.Type, sc cc.StorageClass, tld *tld, lm, tm map[*cc.Initializer][]cc.StringID) {
|
||||
if len(s) == 0 {
|
||||
p.w("%s%s{}", tag, p.typ(nil, t))
|
||||
return
|
||||
}
|
||||
|
||||
if t.HasFlexibleMember() {
|
||||
p.err(s[0], "flexible array members not supported")
|
||||
return
|
||||
}
|
||||
|
||||
parts, isZero := p.initializerUnionField(off, s, t)
|
||||
if len(parts) == 0 || isZero {
|
||||
p.w("%s%s%s{", initComment(s[0], lm), tag, p.typ(s[0], t))
|
||||
p.w("%s}", initComment(parts[len(parts)-1], tm))
|
||||
return
|
||||
}
|
||||
|
||||
p.w("%sfunc() (r %s) {", tag, p.typ(parts[0], t))
|
||||
for _, part := range parts {
|
||||
var ft cc.Type
|
||||
fld := part.Field
|
||||
if fld != nil && fld.IsBitField() {
|
||||
}
|
||||
|
||||
if ft == nil {
|
||||
ft = part.Type()
|
||||
}
|
||||
if ft.Kind() == cc.Array {
|
||||
et := ft.Elem()
|
||||
switch {
|
||||
case isCharType(et):
|
||||
switch x := part.AssignmentExpression.Operand.Value().(type) {
|
||||
case cc.StringValue:
|
||||
str := cc.StringID(x).String()
|
||||
slen := uintptr(len(str)) + 1
|
||||
alen := ft.Len()
|
||||
switch {
|
||||
case alen < slen-1:
|
||||
p.w("copy(((*[%d]byte)(unsafe.Pointer(uintptr(unsafe.Pointer(&r))+%d)))[:], (*[%d]byte)(unsafe.Pointer(%s))[:])\n", alen, part.Offset-off, alen, p.stringLiteralString(str[:alen]))
|
||||
case alen < slen:
|
||||
p.w("copy(((*[%d]byte)(unsafe.Pointer(uintptr(unsafe.Pointer(&r))+%d)))[:], (*[%d]byte)(unsafe.Pointer(%s))[:])\n", alen, part.Offset-off, alen, p.stringLiteralString(str))
|
||||
default: // alen >= slen
|
||||
p.w("copy(((*[%d]byte)(unsafe.Pointer(uintptr(unsafe.Pointer(&r))+%d)))[:], (*[%d]byte)(unsafe.Pointer(%s))[:])\n", alen, part.Offset-off, alen, p.stringLiteralString(str+strings.Repeat("\x00", int(alen-slen))))
|
||||
}
|
||||
continue
|
||||
default:
|
||||
panic(todo("%v: %v <- %T", p.pos(part), et, x))
|
||||
}
|
||||
case p.isWCharType(et):
|
||||
panic(todo(""))
|
||||
}
|
||||
ft = et
|
||||
}
|
||||
switch {
|
||||
case fld != nil && fld.IsBitField():
|
||||
bft := p.bitFileType(part, fld.BitFieldBlockWidth())
|
||||
p.w("*(*%s)(unsafe.Pointer(uintptr(unsafe.Pointer(&r))+%d)) |= ", p.typ(part, bft), part.Offset-off)
|
||||
p.assignmentExpression(f, part.AssignmentExpression, bft, exprValue, 0)
|
||||
p.w("&%#x", uint64(1)<<uint64(fld.BitFieldWidth())-1)
|
||||
if o := fld.BitFieldOffset(); o != 0 {
|
||||
p.w("<<%d", o)
|
||||
}
|
||||
default:
|
||||
p.w("*(*%s)(unsafe.Pointer(uintptr(unsafe.Pointer(&r))+%d)) = ", p.typ(part, ft), part.Offset-off)
|
||||
p.assignmentExpression(f, part.AssignmentExpression, ft, exprValue, 0)
|
||||
}
|
||||
p.w("\n")
|
||||
}
|
||||
p.w("return r\n")
|
||||
p.w("}()")
|
||||
}
|
||||
|
||||
func (p *project) initializerUnionField(off uintptr, s []*cc.Initializer, t cc.Type) (parts []*cc.Initializer, isZero bool) {
|
||||
isZero = true
|
||||
nextOff := off + t.Size()
|
||||
for len(s) != 0 {
|
||||
if v := s[0]; v.Offset < nextOff {
|
||||
s = s[1:]
|
||||
parts = append(parts, v)
|
||||
isZero = isZero && v.AssignmentExpression.Operand.IsZero()
|
||||
continue
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
return parts, isZero
|
||||
}
|
||||
|
||||
func compatibleStructOrUnion(t1, t2 cc.Type) bool {
|
||||
switch t1.Kind() {
|
||||
case cc.Struct:
|
||||
if t2.Kind() != cc.Struct {
|
||||
return false
|
||||
}
|
||||
case cc.Union:
|
||||
if t2.Kind() != cc.Union {
|
||||
return false
|
||||
}
|
||||
default:
|
||||
return false
|
||||
}
|
||||
|
||||
if tag := t1.Tag(); tag != 0 && t2.Tag() != tag {
|
||||
return false
|
||||
}
|
||||
|
||||
nf := t1.NumField()
|
||||
if t2.NumField() != nf {
|
||||
return false
|
||||
}
|
||||
|
||||
for i := []int{0}; i[0] < nf; i[0]++ {
|
||||
f1 := t1.FieldByIndex(i)
|
||||
f2 := t2.FieldByIndex(i)
|
||||
nm := f1.Name()
|
||||
if f2.Name() != nm {
|
||||
return false
|
||||
}
|
||||
|
||||
ft1 := f1.Type()
|
||||
ft2 := f2.Type()
|
||||
if ft1.Size() != ft2.Size() ||
|
||||
f1.IsBitField() != f2.IsBitField() ||
|
||||
f1.BitFieldOffset() != f2.BitFieldOffset() ||
|
||||
f1.BitFieldWidth() != f2.BitFieldWidth() {
|
||||
return false
|
||||
}
|
||||
|
||||
if !compatibleType(ft1, ft2) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func compatibleType(t1, t2 cc.Type) bool {
|
||||
if t1.Kind() != t2.Kind() {
|
||||
return false
|
||||
}
|
||||
|
||||
switch t1.Kind() {
|
||||
case cc.Array:
|
||||
if t1.Len() != t2.Len() || !compatibleType(t1.Elem(), t2.Elem()) {
|
||||
return false
|
||||
}
|
||||
case cc.Struct, cc.Union:
|
||||
if !compatibleStructOrUnion(t1, t2) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (p *project) bitFileType(n cc.Node, bits int) cc.Type {
|
||||
switch bits {
|
||||
case 8:
|
||||
return p.task.cfg.ABI.Type(cc.UChar)
|
||||
case 16:
|
||||
return p.task.cfg.ABI.Type(cc.UShort)
|
||||
case 32:
|
||||
return p.task.cfg.ABI.Type(cc.UInt)
|
||||
case 64:
|
||||
return p.task.cfg.ABI.Type(cc.ULongLong)
|
||||
default:
|
||||
panic(todo("%v: internal error: %v", n.Position(), bits))
|
||||
}
|
||||
}
|
||||
|
||||
func (p *project) isWCharType(t cc.Type) bool {
|
||||
if t.IsAliasType() {
|
||||
if id := t.AliasDeclarator().Name(); id == idWcharT ||
|
||||
p.task.goos == "windows" && id == idWinWchar {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func isCharType(t cc.Type) bool {
|
||||
switch t.Kind() {
|
||||
case cc.Char, cc.SChar, cc.UChar:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (p *project) initializerFlatten(n *cc.Initializer, lm, tm map[*cc.Initializer][]cc.StringID) (s []*cc.Initializer) {
|
||||
switch n.Case {
|
||||
case cc.InitializerExpr: // AssignmentExpression
|
||||
return append(s, n)
|
||||
case cc.InitializerInitList: // '{' InitializerList ',' '}'
|
||||
first := true
|
||||
for list := n.InitializerList; list != nil; list = list.InitializerList {
|
||||
in := list.Initializer
|
||||
k := in
|
||||
if in.Case != cc.InitializerExpr {
|
||||
k = nil
|
||||
}
|
||||
if first {
|
||||
lm[k] = append(lm[k], append(lm[nil], n.Token.Sep)...)
|
||||
if k != nil {
|
||||
delete(lm, nil)
|
||||
}
|
||||
first = false
|
||||
}
|
||||
if list.InitializerList == nil {
|
||||
tm[k] = append([]cc.StringID{n.Token3.Sep}, append(tm[nil], tm[k]...)...)
|
||||
tm[k] = append(tm[k], append(tm[nil], n.Token3.Sep)...)
|
||||
if k != nil {
|
||||
delete(tm, nil)
|
||||
}
|
||||
}
|
||||
s = append(s, p.initializerFlatten(in, lm, tm)...)
|
||||
}
|
||||
return s
|
||||
default:
|
||||
panic(todo("%v: internal error: %v", n.Position(), n.Case))
|
||||
}
|
||||
}
|
||||
10
vendor/modernc.org/ccgo/v3/lib/mem.go
generated
vendored
10
vendor/modernc.org/ccgo/v3/lib/mem.go
generated
vendored
|
|
@ -1,10 +0,0 @@
|
|||
// Copyright 2020 The CCGO 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 !linux
|
||||
// +build !linux
|
||||
|
||||
package ccgo // import "modernc.org/ccgo/v3/lib"
|
||||
|
||||
var totalRam uint64
|
||||
20
vendor/modernc.org/ccgo/v3/lib/mem_linux.go
generated
vendored
20
vendor/modernc.org/ccgo/v3/lib/mem_linux.go
generated
vendored
|
|
@ -1,20 +0,0 @@
|
|||
// Copyright 2020 The CCGO 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 ccgo // import "modernc.org/ccgo/v3/lib"
|
||||
|
||||
import (
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
var totalRam uint64
|
||||
|
||||
func init() {
|
||||
var si unix.Sysinfo_t
|
||||
if unix.Sysinfo(&si) != nil {
|
||||
return
|
||||
}
|
||||
|
||||
totalRam = uint64(si.Totalram)
|
||||
}
|
||||
12
vendor/modernc.org/ccgo/v3/lib/nodmesg.go
generated
vendored
12
vendor/modernc.org/ccgo/v3/lib/nodmesg.go
generated
vendored
|
|
@ -1,12 +0,0 @@
|
|||
// Copyright 2020 The Libc 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 !ccgo.dmesg
|
||||
// +build !ccgo.dmesg
|
||||
|
||||
package ccgo // import "modernc.org/ccgo/v3/lib"
|
||||
|
||||
const dmesgs = false
|
||||
|
||||
func dmesg(s string, args ...interface{}) {}
|
||||
58
vendor/modernc.org/ccgo/v3/lib/stringer.go
generated
vendored
58
vendor/modernc.org/ccgo/v3/lib/stringer.go
generated
vendored
|
|
@ -1,58 +0,0 @@
|
|||
// Code generated by "stringer -output stringer.go -type=exprMode,opKind"; DO NOT EDIT.
|
||||
|
||||
package ccgo
|
||||
|
||||
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[exprAddrOf-1]
|
||||
_ = x[exprBool-2]
|
||||
_ = x[exprCondInit-3]
|
||||
_ = x[exprCondReturn-4]
|
||||
_ = x[exprDecay-5]
|
||||
_ = x[exprFunc-6]
|
||||
_ = x[exprLValue-7]
|
||||
_ = x[exprPSelect-8]
|
||||
_ = x[exprSelect-9]
|
||||
_ = x[exprValue-10]
|
||||
_ = x[exprVoid-11]
|
||||
_ = x[exprGoPtr-12]
|
||||
}
|
||||
|
||||
const _exprMode_name = "exprAddrOfexprBoolexprCondInitexprCondReturnexprDecayexprFuncexprLValueexprPSelectexprSelectexprValueexprVoidexprGoPtr"
|
||||
|
||||
var _exprMode_index = [...]uint8{0, 10, 18, 30, 44, 53, 61, 71, 82, 92, 101, 109, 118}
|
||||
|
||||
func (i exprMode) String() string {
|
||||
i -= 1
|
||||
if i < 0 || i >= exprMode(len(_exprMode_index)-1) {
|
||||
return "exprMode(" + strconv.FormatInt(int64(i+1), 10) + ")"
|
||||
}
|
||||
return _exprMode_name[_exprMode_index[i]:_exprMode_index[i+1]]
|
||||
}
|
||||
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[opNormal-0]
|
||||
_ = x[opArray-1]
|
||||
_ = x[opArrayParameter-2]
|
||||
_ = x[opFunction-3]
|
||||
_ = x[opUnion-4]
|
||||
_ = x[opBitfield-5]
|
||||
_ = x[opStruct-6]
|
||||
}
|
||||
|
||||
const _opKind_name = "opNormalopArrayopArrayParameteropFunctionopUnionopBitfieldopStruct"
|
||||
|
||||
var _opKind_index = [...]uint8{0, 8, 15, 31, 41, 48, 58, 66}
|
||||
|
||||
func (i opKind) String() string {
|
||||
if i < 0 || i >= opKind(len(_opKind_index)-1) {
|
||||
return "opKind(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||
}
|
||||
return _opKind_name[_opKind_index[i]:_opKind_index[i+1]]
|
||||
}
|
||||
4
vendor/modernc.org/ccgo/v3/lib/unconvert.sh
generated
vendored
4
vendor/modernc.org/ccgo/v3/lib/unconvert.sh
generated
vendored
|
|
@ -1,4 +0,0 @@
|
|||
until unconvert -fastmath . &> /dev/null
|
||||
do
|
||||
unconvert -fastmath -apply . &> /dev/null
|
||||
done
|
||||
458
vendor/modernc.org/ccgo/v3/lib/util.go
generated
vendored
458
vendor/modernc.org/ccgo/v3/lib/util.go
generated
vendored
|
|
@ -1,458 +0,0 @@
|
|||
// Copyright 2020 The CCGO Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// generator.go helpers
|
||||
|
||||
package ccgo // import "modernc.org/ccgo/v3/lib"
|
||||
|
||||
import (
|
||||
"archive/tar"
|
||||
"bufio"
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// CopyFile copies src to dest, preserving permissions and times where/when
|
||||
// possible. If canOverwrite is not nil, it is consulted whether a destination
|
||||
// file can be overwritten. If canOverwrite is nil then destination is
|
||||
// overwritten if permissions allow that, otherwise the function fails.
|
||||
//
|
||||
// Src and dst must be in the slash form.
|
||||
func CopyFile(dst, src string, canOverwrite func(fn string, fi os.FileInfo) bool) (n int64, rerr error) {
|
||||
dst = filepath.FromSlash(dst)
|
||||
dstDir := filepath.Dir(dst)
|
||||
di, err := os.Stat(dstDir)
|
||||
switch {
|
||||
case err != nil:
|
||||
if !os.IsNotExist(err) {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
if err := os.MkdirAll(dstDir, 0770); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
case err == nil:
|
||||
if !di.IsDir() {
|
||||
return 0, fmt.Errorf("cannot create directory, file exists: %s", dst)
|
||||
}
|
||||
}
|
||||
|
||||
src = filepath.FromSlash(src)
|
||||
si, err := os.Stat(src)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
if si.IsDir() {
|
||||
return 0, fmt.Errorf("cannot copy a directory: %s", src)
|
||||
}
|
||||
|
||||
di, err = os.Stat(dst)
|
||||
switch {
|
||||
case err != nil && !os.IsNotExist(err):
|
||||
return 0, err
|
||||
case err == nil:
|
||||
if di.IsDir() {
|
||||
return 0, fmt.Errorf("cannot overwite a directory: %s", dst)
|
||||
}
|
||||
|
||||
if canOverwrite != nil && !canOverwrite(dst, di) {
|
||||
return 0, fmt.Errorf("cannot overwite: %s", dst)
|
||||
}
|
||||
}
|
||||
|
||||
s, err := os.Open(src)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
defer s.Close()
|
||||
r := bufio.NewReader(s)
|
||||
|
||||
d, err := os.Create(dst)
|
||||
|
||||
defer func() {
|
||||
if err := d.Close(); err != nil && rerr == nil {
|
||||
rerr = err
|
||||
return
|
||||
}
|
||||
|
||||
if err := os.Chmod(dst, si.Mode()); err != nil && rerr == nil {
|
||||
rerr = err
|
||||
return
|
||||
}
|
||||
|
||||
if err := os.Chtimes(dst, si.ModTime(), si.ModTime()); err != nil && rerr == nil {
|
||||
rerr = err
|
||||
return
|
||||
}
|
||||
}()
|
||||
|
||||
w := bufio.NewWriter(d)
|
||||
|
||||
defer func() {
|
||||
if err := w.Flush(); err != nil && rerr == nil {
|
||||
rerr = err
|
||||
}
|
||||
}()
|
||||
|
||||
return io.Copy(w, r)
|
||||
}
|
||||
|
||||
// MustCopyFile is like CopyFile but it executes Fatal(stackTrace, err) if it fails.
|
||||
func MustCopyFile(stackTrace bool, dst, src string, canOverwrite func(fn string, fi os.FileInfo) bool) int64 {
|
||||
n, err := CopyFile(dst, src, canOverwrite)
|
||||
if err != nil {
|
||||
Fatal(stackTrace, err)
|
||||
}
|
||||
|
||||
return n
|
||||
}
|
||||
|
||||
// CopyDir recursively copies src to dest, preserving permissions and times
|
||||
// where/when possible. If canOverwrite is not nil, it is consulted whether a
|
||||
// destination file can be overwritten. If canOverwrite is nil then destination
|
||||
// is overwritten if permissions allow that, otherwise the function fails.
|
||||
//
|
||||
// Src and dst must be in the slash form.
|
||||
func CopyDir(dst, src string, canOverwrite func(fn string, fi os.FileInfo) bool) (files int, bytes int64, rerr error) {
|
||||
dst = filepath.FromSlash(dst)
|
||||
src = filepath.FromSlash(src)
|
||||
si, err := os.Stat(src)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
if !si.IsDir() {
|
||||
return 0, 0, fmt.Errorf("cannot copy a file: %s", src)
|
||||
}
|
||||
|
||||
return files, bytes, filepath.Walk(src, func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
rel, err := filepath.Rel(src, path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if info.IsDir() {
|
||||
return os.MkdirAll(filepath.Join(dst, rel), 0770)
|
||||
}
|
||||
|
||||
n, err := CopyFile(filepath.Join(dst, rel), path, canOverwrite)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
files++
|
||||
bytes += n
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// MustCopyDir is like CopyDir, but it executes Fatal(stackTrace, errú if it fails.
|
||||
func MustCopyDir(stackTrace bool, dst, src string, canOverwrite func(fn string, fi os.FileInfo) bool) (files int, bytes int64) {
|
||||
file, bytes, err := CopyDir(dst, src, canOverwrite)
|
||||
if err != nil {
|
||||
Fatal(stackTrace, err)
|
||||
}
|
||||
|
||||
return file, bytes
|
||||
}
|
||||
|
||||
// UntarFile extracts a named tar.gz archive into dst. If canOverwrite is not
|
||||
// nil, it is consulted whether a destination file can be overwritten. If
|
||||
// canOverwrite is nil then destination is overwritten if permissions allow
|
||||
// that, otherwise the function fails.
|
||||
//
|
||||
// Src and dst must be in the slash form.
|
||||
func UntarFile(dst, src string, canOverwrite func(fn string, fi os.FileInfo) bool) error {
|
||||
f, err := os.Open(filepath.FromSlash(src))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer f.Close()
|
||||
|
||||
return Untar(dst, bufio.NewReader(f), canOverwrite)
|
||||
}
|
||||
|
||||
// MustUntarFile is like UntarFile but it executes Fatal(stackTrace, err) if it fails.
|
||||
func MustUntarFile(stackTrace bool, dst, src string, canOverwrite func(fn string, fi os.FileInfo) bool) {
|
||||
if err := UntarFile(dst, src, canOverwrite); err != nil {
|
||||
Fatal(stackTrace, err)
|
||||
}
|
||||
}
|
||||
|
||||
// Untar extracts a tar.gz archive into dst. If canOverwrite is not nil, it is
|
||||
// consulted whether a destination file can be overwritten. If canOverwrite is
|
||||
// nil then destination is overwritten if permissions allow that, otherwise the
|
||||
// function fails.
|
||||
//
|
||||
// Dst must be in the slash form.
|
||||
func Untar(dst string, r io.Reader, canOverwrite func(fn string, fi os.FileInfo) bool) error {
|
||||
dst = filepath.FromSlash(dst)
|
||||
gr, err := gzip.NewReader(r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tr := tar.NewReader(gr)
|
||||
for {
|
||||
hdr, err := tr.Next()
|
||||
if err != nil {
|
||||
if err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
switch hdr.Typeflag {
|
||||
case tar.TypeDir:
|
||||
dir := filepath.Join(dst, hdr.Name)
|
||||
if err = os.MkdirAll(dir, 0770); err != nil {
|
||||
return err
|
||||
}
|
||||
case tar.TypeSymlink, tar.TypeXGlobalHeader:
|
||||
// skip
|
||||
case tar.TypeReg, tar.TypeRegA:
|
||||
dir := filepath.Dir(filepath.Join(dst, hdr.Name))
|
||||
if _, err := os.Stat(dir); err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = os.MkdirAll(dir, 0770); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
fn := filepath.Join(dst, hdr.Name)
|
||||
f, err := os.OpenFile(fn, os.O_CREATE|os.O_WRONLY, os.FileMode(hdr.Mode))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
w := bufio.NewWriter(f)
|
||||
if _, err = io.Copy(w, tr); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := w.Flush(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := f.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := os.Chtimes(fn, hdr.AccessTime, hdr.ModTime); err != nil {
|
||||
return err
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("unexpected tar header typeflag %#02x", hdr.Typeflag)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MustUntar is like Untar but it executes Fatal(stackTrace, err) if it fails.
|
||||
func MustUntar(stackTrace bool, dst string, r io.Reader, canOverwrite func(fn string, fi os.FileInfo) bool) {
|
||||
if err := Untar(dst, r, canOverwrite); err != nil {
|
||||
Fatal(stackTrace, err)
|
||||
}
|
||||
}
|
||||
|
||||
// Fatalf prints a formatted message to os.Stderr and performs os.Exit(1). A
|
||||
// stack trace is added if stackTrace is true.
|
||||
func Fatalf(stackTrace bool, s string, args ...interface{}) {
|
||||
if stackTrace {
|
||||
fmt.Fprintf(os.Stderr, "%s\n", debug.Stack())
|
||||
}
|
||||
fmt.Fprintln(os.Stderr, strings.TrimSpace(fmt.Sprintf(s, args...)))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Fatal prints its argumenst to os.Stderr and performs os.Exit(1). A
|
||||
// stack trace is added if stackTrace is true.
|
||||
func Fatal(stackTrace bool, args ...interface{}) {
|
||||
if stackTrace {
|
||||
fmt.Fprintf(os.Stderr, "%s\n", debug.Stack())
|
||||
}
|
||||
fmt.Fprintln(os.Stderr, strings.TrimSpace(fmt.Sprint(args...)))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Mkdirs will create all paths. Paths must be in slash form.
|
||||
func Mkdirs(paths ...string) error {
|
||||
for _, path := range paths {
|
||||
path = filepath.FromSlash(path)
|
||||
if err := os.MkdirAll(path, 0770); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MustMkdirs is like Mkdir but if executes Fatal(stackTrace, err) if it fails.
|
||||
func MustMkdirs(stackTrace bool, paths ...string) {
|
||||
if err := Mkdirs(paths...); err != nil {
|
||||
Fatal(stackTrace, err)
|
||||
}
|
||||
}
|
||||
|
||||
// InDir executes f in dir. Dir must be in slash form.
|
||||
func InDir(dir string, f func() error) (err error) {
|
||||
var cwd string
|
||||
if cwd, err = os.Getwd(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err2 := os.Chdir(cwd); err2 != nil {
|
||||
err = err2
|
||||
}
|
||||
}()
|
||||
|
||||
if err = os.Chdir(filepath.FromSlash(dir)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return f()
|
||||
}
|
||||
|
||||
// MustInDir is like InDir but it executes Fatal(stackTrace, err) if it fails.
|
||||
func MustInDir(stackTrace bool, dir string, f func() error) {
|
||||
if err := InDir(dir, f); err != nil {
|
||||
Fatal(stackTrace, err)
|
||||
}
|
||||
}
|
||||
|
||||
type echoWriter struct {
|
||||
w bytes.Buffer
|
||||
}
|
||||
|
||||
func (w *echoWriter) Write(b []byte) (int, error) {
|
||||
os.Stdout.Write(b)
|
||||
return w.w.Write(b)
|
||||
}
|
||||
|
||||
// Shell echoes and executes cmd with args and returns the combined output if the command.
|
||||
func Shell(cmd string, args ...string) ([]byte, error) {
|
||||
cmd, err := exec.LookPath(cmd)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
wd, err := AbsCwd()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
fmt.Printf("execute %s %q in %s\n", cmd, args, wd)
|
||||
var b echoWriter
|
||||
c := exec.Command(cmd, args...)
|
||||
c.Stdout = &b
|
||||
c.Stderr = &b
|
||||
err = c.Run()
|
||||
return b.w.Bytes(), err
|
||||
}
|
||||
|
||||
// MustShell is like Shell but it executes Fatal(stackTrace, err) if it fails.
|
||||
func MustShell(stackTrace bool, cmd string, args ...string) []byte {
|
||||
b, err := Shell(cmd, args...)
|
||||
if err != nil {
|
||||
Fatalf(stackTrace, "%v %s\noutput: %s\nerr: %s", cmd, args, b, err)
|
||||
}
|
||||
|
||||
return b
|
||||
}
|
||||
|
||||
// Compile executes Shell with cmd set to "ccgo".
|
||||
func Compile(args ...string) ([]byte, error) { return Shell("ccgo", args...) }
|
||||
|
||||
// MustCompile is like Compile but if executes Fatal(stackTrace, err) if it fails.
|
||||
func MustCompile(stackTrace bool, args ...string) []byte {
|
||||
return MustShell(stackTrace, "ccgo", args...)
|
||||
}
|
||||
|
||||
// Run is like Compile, but executes in-process.
|
||||
func Run(args ...string) ([]byte, error) {
|
||||
var b bytes.Buffer
|
||||
t := NewTask(append([]string{"ccgo"}, args...), &b, &b)
|
||||
err := t.Main()
|
||||
return b.Bytes(), err
|
||||
}
|
||||
|
||||
// MustRun is like Run but if executes Fatal(stackTrace, err) if it fails.
|
||||
func MustRun(stackTrace bool, args ...string) []byte {
|
||||
var b bytes.Buffer
|
||||
args = append([]string{"ccgo"}, args...)
|
||||
t := NewTask(args, &b, &b)
|
||||
if err := t.Main(); err != nil {
|
||||
Fatalf(stackTrace, "%v\noutput: %s\nerr: %s", args, b.Bytes(), err)
|
||||
}
|
||||
|
||||
return b.Bytes()
|
||||
}
|
||||
|
||||
// AbsCwd returns the absolute working directory.
|
||||
func AbsCwd() (string, error) {
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if wd, err = filepath.Abs(wd); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return wd, nil
|
||||
}
|
||||
|
||||
// MustAbsCwd is like AbsCwd but executes Fatal(stackTrace, err) if it fails.
|
||||
func MustAbsCwd(stackTrace bool) string {
|
||||
s, err := AbsCwd()
|
||||
if err != nil {
|
||||
Fatal(stackTrace, err)
|
||||
}
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
// Env returns the value of environmental variable key of dflt otherwise.
|
||||
func Env(key, dflt string) string {
|
||||
if s := os.Getenv(key); s != "" {
|
||||
return s
|
||||
}
|
||||
|
||||
return dflt
|
||||
}
|
||||
|
||||
// MustTempDir is like ioutil.TempDir but executes Fatal(stackTrace, err) if it
|
||||
// fails. The returned path is absolute.
|
||||
func MustTempDir(stackTrace bool, dir, name string) string {
|
||||
s, err := ioutil.TempDir(dir, name)
|
||||
if err != nil {
|
||||
Fatal(stackTrace, err)
|
||||
}
|
||||
|
||||
if s, err = filepath.Abs(s); err != nil {
|
||||
Fatal(stackTrace, err)
|
||||
}
|
||||
|
||||
return s
|
||||
}
|
||||
0
vendor/modernc.org/cc/v3/GO-LICENSE → vendor/modernc.org/gc/v3/GO-LICENSE
generated
vendored
0
vendor/modernc.org/cc/v3/GO-LICENSE → vendor/modernc.org/gc/v3/GO-LICENSE
generated
vendored
69
vendor/modernc.org/gc/v3/LICENSE
generated
vendored
Normal file
69
vendor/modernc.org/gc/v3/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
-------------------------------------------------------------------------------
|
||||
Copyright (c) 2016 The GC 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 names of the authors nor the names of the
|
||||
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.
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Code in this repository contains or may contain
|
||||
|
||||
- copied original code from
|
||||
- code based on original code from
|
||||
- code inspired by original code in
|
||||
|
||||
"The Go Programming Language" project at https://go.googlesource.com/go/.
|
||||
|
||||
Copy of the license of the original code follows below
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
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.
|
||||
-------------------------------------------------------------------------------
|
||||
113
vendor/modernc.org/gc/v3/Makefile
generated
vendored
Normal file
113
vendor/modernc.org/gc/v3/Makefile
generated
vendored
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
.PHONY: all clean edit editor test test2 back report report2 parser2 benchmarks benchmarks2 mem memgo race nreport build_all_targets
|
||||
|
||||
all:
|
||||
|
||||
build_all_targets:
|
||||
GOOS=darwin GOARCH=amd64 go test -c -o /dev/null
|
||||
GOOS=darwin GOARCH=arm64 go test -c -o /dev/null
|
||||
GOOS=freebsd GOARCH=386 go test -c -o /dev/null
|
||||
GOOS=freebsd GOARCH=amd64 go test -c -o /dev/null
|
||||
GOOS=freebsd GOARCH=arm go test -c -o /dev/null
|
||||
GOOS=freebsd GOARCH=arm64 go test -c -o /dev/null
|
||||
GOOS=illumos GOARCH=amd64 go test -c -o /dev/null
|
||||
GOOS=linux GOARCH=386 go test -c -o /dev/null
|
||||
GOOS=linux GOARCH=amd64 go test -c -o /dev/null
|
||||
GOOS=linux GOARCH=arm go test -c -o /dev/null
|
||||
GOOS=linux GOARCH=arm64 go test -c -o /dev/null
|
||||
GOOS=linux GOARCH=ppc64le go test -c -o /dev/null
|
||||
GOOS=linux GOARCH=riscv64 go test -c -o /dev/null
|
||||
GOOS=linux GOARCH=s390x go test -c -o /dev/null
|
||||
GOOS=netbsd GOARCH=386 go test -c -o /dev/null
|
||||
GOOS=netbsd GOARCH=amd64 go test -c -o /dev/null
|
||||
GOOS=netbsd GOARCH=arm go test -c -o /dev/null
|
||||
GOOS=openbsd GOARCH=386 go test -c -o /dev/null
|
||||
GOOS=openbsd GOARCH=amd64 go test -c -o /dev/null
|
||||
GOOS=openbsd GOARCH=arm64 go test -c -o /dev/null
|
||||
GOOS=windows GOARCH=386 go test -c -o /dev/null
|
||||
GOOS=windows GOARCH=amd64 go test -c -o /dev/null
|
||||
GOOS=windows GOARCH=arm64 go test -c -o /dev/null
|
||||
|
||||
clean:
|
||||
rm -f cpu.test mem.test *.out
|
||||
go clean
|
||||
|
||||
edit:
|
||||
@touch log
|
||||
@if [ -f "Session.vim" ]; then gvim -S & else gvim -p Makefile all_test.go gc.go & fi
|
||||
|
||||
editor:
|
||||
gofmt -l -s -w *.go
|
||||
go test -c -o /dev/null 2>&1 | tee log-editor
|
||||
|
||||
race:
|
||||
go test -v -failfast -heap -race 2>&1 | tee log-test
|
||||
@git diff testdata/ || true
|
||||
@git status
|
||||
@grep TOTAL log-test || true
|
||||
grep 'FAIL\|TODO' log-test || true
|
||||
|
||||
test:
|
||||
go test -v -failfast -trctodo -exterr -heap 2>&1 | tee log-test
|
||||
@git diff testdata/ || true
|
||||
@git status
|
||||
@grep TOTAL log-test || true
|
||||
grep 'FAIL\|TODO' log-test || true
|
||||
|
||||
test2:
|
||||
go test -v -failfast -trctodo -exterr -src $$HOME/src 2>&1 | tee log-test2
|
||||
@git diff testdata/ || true
|
||||
@git status
|
||||
@grep TOTAL log-test2 || true
|
||||
grep 'FAIL\|TODO' log-test2 || true
|
||||
|
||||
parser2:
|
||||
go test -v -failfast -run TestParser -src $$HOME/src 2>&1 | tee log-parser2
|
||||
@git diff testdata/ || true
|
||||
@git status
|
||||
@grep TOTAL log-parser2 || true
|
||||
grep 'FAIL\|TODO' log-parser2 || true
|
||||
|
||||
back:
|
||||
go test -v -failfast -noback 2>&1 | tee log-back
|
||||
@git diff testdata/ || true
|
||||
@git status
|
||||
@grep TOTAL log-back || true
|
||||
grep 'FAIL\|TODO' log-back || true
|
||||
|
||||
nreport:
|
||||
touch log-nreport
|
||||
cp log-nreport log-nreport0
|
||||
go test -v -failfast -run TestParser -heap -nreport 2>&1 | tee log-nreport
|
||||
@git diff testdata/ || true
|
||||
@git status
|
||||
@grep TOTAL log-report || true
|
||||
grep 'FAIL\|TODO' log-report || true
|
||||
|
||||
report:
|
||||
go test -v -failfast -run TestParser -report 2>&1 | tee log-report
|
||||
@git diff testdata/ || true
|
||||
@git status
|
||||
@grep TOTAL log-report || true
|
||||
grep 'FAIL\|TODO' log-report || true
|
||||
|
||||
report2:
|
||||
go test -v -failfast -run TestParser -src $$HOME/src -report 2>&1 | tee log-report2
|
||||
@git diff testdata/ || true
|
||||
@git status
|
||||
@grep TOTAL log-report2 || true
|
||||
grep 'FAIL\|TODO' log-report2 || true
|
||||
|
||||
|
||||
benchmarks:
|
||||
go test -v -run @ -bench . 2>&1 | tee log-benchmarks
|
||||
|
||||
benchmarks2:
|
||||
go test -v -run @ -bench . -bsrc $$HOME/src 2>&1 | tee log-benchmarks2
|
||||
|
||||
mem:
|
||||
go test -run @ -bench BenchmarkParser -memprofile mem.out
|
||||
go tool pprof --lines --alloc_space *.test mem.out
|
||||
|
||||
memgo:
|
||||
go test -run @ -bench BenchmarkGoParser -memprofile mem.out
|
||||
go tool pprof --lines --alloc_space *.test mem.out
|
||||
682
vendor/modernc.org/gc/v3/abi.go
generated
vendored
Normal file
682
vendor/modernc.org/gc/v3/abi.go
generated
vendored
Normal file
|
|
@ -0,0 +1,682 @@
|
|||
// Copyright 2022 The Gc 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 gc // import "modernc.org/gc/v3"
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var (
|
||||
byteOrders = map[string]binary.ByteOrder{
|
||||
"386": binary.LittleEndian,
|
||||
"amd64": binary.LittleEndian,
|
||||
"arm": binary.LittleEndian,
|
||||
"arm64": binary.LittleEndian,
|
||||
"ppc64le": binary.LittleEndian,
|
||||
"riscv64": binary.LittleEndian,
|
||||
"s390x": binary.BigEndian,
|
||||
}
|
||||
|
||||
abiTypes = map[[2]string]map[Kind]ABIType{
|
||||
// go1.19.1
|
||||
{"freebsd", "386"}: {
|
||||
Bool: {1, 1, 1},
|
||||
Chan: {4, 4, 4},
|
||||
Complex128: {16, 4, 4},
|
||||
Complex64: {8, 4, 4},
|
||||
Float32: {4, 4, 4},
|
||||
Float64: {8, 4, 4},
|
||||
Function: {4, 4, 4},
|
||||
Int: {4, 4, 4},
|
||||
Int16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
Int64: {8, 4, 4},
|
||||
Int8: {1, 1, 1},
|
||||
Interface: {8, 4, 4},
|
||||
Map: {4, 4, 4},
|
||||
Pointer: {4, 4, 4},
|
||||
Slice: {12, 4, 4},
|
||||
String: {8, 4, 4},
|
||||
Uint: {4, 4, 4},
|
||||
Uint16: {2, 2, 2},
|
||||
Uint32: {4, 4, 4},
|
||||
Uint64: {8, 4, 4},
|
||||
Uint8: {1, 1, 1},
|
||||
Uintptr: {4, 4, 4},
|
||||
UnsafePointer: {4, 4, 4},
|
||||
},
|
||||
// go1.19.1
|
||||
{"freebsd", "amd64"}: {
|
||||
Bool: {1, 1, 1},
|
||||
Chan: {8, 8, 8},
|
||||
Complex128: {16, 8, 8},
|
||||
Complex64: {8, 4, 4},
|
||||
Float32: {4, 4, 4},
|
||||
Float64: {8, 8, 8},
|
||||
Function: {8, 8, 8},
|
||||
Int: {8, 8, 8},
|
||||
Int16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
Int64: {8, 8, 8},
|
||||
Int8: {1, 1, 1},
|
||||
Interface: {16, 8, 8},
|
||||
Map: {8, 8, 8},
|
||||
Pointer: {8, 8, 8},
|
||||
Slice: {24, 8, 8},
|
||||
String: {16, 8, 8},
|
||||
Uint: {8, 8, 8},
|
||||
Uint16: {2, 2, 2},
|
||||
Uint32: {4, 4, 4},
|
||||
Uint64: {8, 8, 8},
|
||||
Uint8: {1, 1, 1},
|
||||
Uintptr: {8, 8, 8},
|
||||
UnsafePointer: {8, 8, 8},
|
||||
},
|
||||
// go1.18.5
|
||||
{"freebsd", "arm"}: {
|
||||
Bool: {1, 1, 1},
|
||||
Chan: {4, 4, 4},
|
||||
Complex128: {16, 4, 4},
|
||||
Complex64: {8, 4, 4},
|
||||
Float32: {4, 4, 4},
|
||||
Float64: {8, 4, 4},
|
||||
Function: {4, 4, 4},
|
||||
Int: {4, 4, 4},
|
||||
Int16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
Int64: {8, 4, 4},
|
||||
Int8: {1, 1, 1},
|
||||
Interface: {8, 4, 4},
|
||||
Map: {4, 4, 4},
|
||||
Pointer: {4, 4, 4},
|
||||
Slice: {12, 4, 4},
|
||||
String: {8, 4, 4},
|
||||
Uint: {4, 4, 4},
|
||||
Uint16: {2, 2, 2},
|
||||
Uint32: {4, 4, 4},
|
||||
Uint64: {8, 4, 4},
|
||||
Uint8: {1, 1, 1},
|
||||
Uintptr: {4, 4, 4},
|
||||
UnsafePointer: {4, 4, 4},
|
||||
},
|
||||
// go1.19
|
||||
{"freebsd", "arm64"}: {
|
||||
Bool: {1, 1, 1},
|
||||
Chan: {8, 8, 8},
|
||||
Complex128: {16, 8, 8},
|
||||
Complex64: {8, 4, 4},
|
||||
Float32: {4, 4, 4},
|
||||
Float64: {8, 8, 8},
|
||||
Function: {8, 8, 8},
|
||||
Int: {8, 8, 8},
|
||||
Int16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
Int64: {8, 8, 8},
|
||||
Int8: {1, 1, 1},
|
||||
Interface: {16, 8, 8},
|
||||
Map: {8, 8, 8},
|
||||
Pointer: {8, 8, 8},
|
||||
Slice: {24, 8, 8},
|
||||
String: {16, 8, 8},
|
||||
Uint: {8, 8, 8},
|
||||
Uint16: {2, 2, 2},
|
||||
Uint32: {4, 4, 4},
|
||||
Uint64: {8, 8, 8},
|
||||
Uint8: {1, 1, 1},
|
||||
Uintptr: {8, 8, 8},
|
||||
UnsafePointer: {8, 8, 8},
|
||||
},
|
||||
// go1.19.1
|
||||
{"darwin", "amd64"}: {
|
||||
Bool: {1, 1, 1},
|
||||
Chan: {8, 8, 8},
|
||||
Complex128: {16, 8, 8},
|
||||
Complex64: {8, 4, 4},
|
||||
Float32: {4, 4, 4},
|
||||
Float64: {8, 8, 8},
|
||||
Function: {8, 8, 8},
|
||||
Int: {8, 8, 8},
|
||||
Int16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
Int64: {8, 8, 8},
|
||||
Int8: {1, 1, 1},
|
||||
Interface: {16, 8, 8},
|
||||
Map: {8, 8, 8},
|
||||
Pointer: {8, 8, 8},
|
||||
Slice: {24, 8, 8},
|
||||
String: {16, 8, 8},
|
||||
Uint: {8, 8, 8},
|
||||
Uint16: {2, 2, 2},
|
||||
Uint32: {4, 4, 4},
|
||||
Uint64: {8, 8, 8},
|
||||
Uint8: {1, 1, 1},
|
||||
Uintptr: {8, 8, 8},
|
||||
UnsafePointer: {8, 8, 8},
|
||||
},
|
||||
// go1.19.1
|
||||
{"darwin", "arm64"}: {
|
||||
Bool: {1, 1, 1},
|
||||
Chan: {8, 8, 8},
|
||||
Complex128: {16, 8, 8},
|
||||
Complex64: {8, 4, 4},
|
||||
Float32: {4, 4, 4},
|
||||
Float64: {8, 8, 8},
|
||||
Function: {8, 8, 8},
|
||||
Int: {8, 8, 8},
|
||||
Int16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
Int64: {8, 8, 8},
|
||||
Int8: {1, 1, 1},
|
||||
Interface: {16, 8, 8},
|
||||
Map: {8, 8, 8},
|
||||
Pointer: {8, 8, 8},
|
||||
Slice: {24, 8, 8},
|
||||
String: {16, 8, 8},
|
||||
Uint: {8, 8, 8},
|
||||
Uint16: {2, 2, 2},
|
||||
Uint32: {4, 4, 4},
|
||||
Uint64: {8, 8, 8},
|
||||
Uint8: {1, 1, 1},
|
||||
Uintptr: {8, 8, 8},
|
||||
UnsafePointer: {8, 8, 8},
|
||||
},
|
||||
// go1.19.1
|
||||
{"linux", "386"}: {
|
||||
Bool: {1, 1, 1},
|
||||
Chan: {4, 4, 4},
|
||||
Complex128: {16, 4, 4},
|
||||
Complex64: {8, 4, 4},
|
||||
Float32: {4, 4, 4},
|
||||
Float64: {8, 4, 4},
|
||||
Function: {4, 4, 4},
|
||||
Int: {4, 4, 4},
|
||||
Int16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
Int64: {8, 4, 4},
|
||||
Int8: {1, 1, 1},
|
||||
Interface: {8, 4, 4},
|
||||
Map: {4, 4, 4},
|
||||
Pointer: {4, 4, 4},
|
||||
Slice: {12, 4, 4},
|
||||
String: {8, 4, 4},
|
||||
Uint: {4, 4, 4},
|
||||
Uint16: {2, 2, 2},
|
||||
Uint32: {4, 4, 4},
|
||||
Uint64: {8, 4, 4},
|
||||
Uint8: {1, 1, 1},
|
||||
Uintptr: {4, 4, 4},
|
||||
UnsafePointer: {4, 4, 4},
|
||||
},
|
||||
// go1.19.1
|
||||
{"linux", "amd64"}: {
|
||||
Bool: {1, 1, 1},
|
||||
Chan: {8, 8, 8},
|
||||
Complex128: {16, 8, 8},
|
||||
Complex64: {8, 4, 4},
|
||||
Float32: {4, 4, 4},
|
||||
Float64: {8, 8, 8},
|
||||
Function: {8, 8, 8},
|
||||
Int: {8, 8, 8},
|
||||
Int16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
Int64: {8, 8, 8},
|
||||
Int8: {1, 1, 1},
|
||||
Interface: {16, 8, 8},
|
||||
Map: {8, 8, 8},
|
||||
Pointer: {8, 8, 8},
|
||||
Slice: {24, 8, 8},
|
||||
String: {16, 8, 8},
|
||||
Uint: {8, 8, 8},
|
||||
Uint16: {2, 2, 2},
|
||||
Uint32: {4, 4, 4},
|
||||
Uint64: {8, 8, 8},
|
||||
Uint8: {1, 1, 1},
|
||||
Uintptr: {8, 8, 8},
|
||||
UnsafePointer: {8, 8, 8},
|
||||
},
|
||||
// go1.19.1
|
||||
{"linux", "arm"}: {
|
||||
Bool: {1, 1, 1},
|
||||
Chan: {4, 4, 4},
|
||||
Complex128: {16, 4, 4},
|
||||
Complex64: {8, 4, 4},
|
||||
Float32: {4, 4, 4},
|
||||
Float64: {8, 4, 4},
|
||||
Function: {4, 4, 4},
|
||||
Int: {4, 4, 4},
|
||||
Int16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
Int64: {8, 4, 4},
|
||||
Int8: {1, 1, 1},
|
||||
Interface: {8, 4, 4},
|
||||
Map: {4, 4, 4},
|
||||
Pointer: {4, 4, 4},
|
||||
Slice: {12, 4, 4},
|
||||
String: {8, 4, 4},
|
||||
Uint: {4, 4, 4},
|
||||
Uint16: {2, 2, 2},
|
||||
Uint32: {4, 4, 4},
|
||||
Uint64: {8, 4, 4},
|
||||
Uint8: {1, 1, 1},
|
||||
Uintptr: {4, 4, 4},
|
||||
UnsafePointer: {4, 4, 4},
|
||||
},
|
||||
// go1.19.1
|
||||
{"linux", "arm64"}: {
|
||||
Bool: {1, 1, 1},
|
||||
Chan: {8, 8, 8},
|
||||
Complex128: {16, 8, 8},
|
||||
Complex64: {8, 4, 4},
|
||||
Float32: {4, 4, 4},
|
||||
Float64: {8, 8, 8},
|
||||
Function: {8, 8, 8},
|
||||
Int: {8, 8, 8},
|
||||
Int16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
Int64: {8, 8, 8},
|
||||
Int8: {1, 1, 1},
|
||||
Interface: {16, 8, 8},
|
||||
Map: {8, 8, 8},
|
||||
Pointer: {8, 8, 8},
|
||||
Slice: {24, 8, 8},
|
||||
String: {16, 8, 8},
|
||||
Uint: {8, 8, 8},
|
||||
Uint16: {2, 2, 2},
|
||||
Uint32: {4, 4, 4},
|
||||
Uint64: {8, 8, 8},
|
||||
Uint8: {1, 1, 1},
|
||||
Uintptr: {8, 8, 8},
|
||||
UnsafePointer: {8, 8, 8},
|
||||
},
|
||||
// go1.19.1
|
||||
{"linux", "s390x"}: {
|
||||
Bool: {1, 1, 1},
|
||||
Chan: {8, 8, 8},
|
||||
Complex128: {16, 8, 8},
|
||||
Complex64: {8, 4, 4},
|
||||
Float32: {4, 4, 4},
|
||||
Float64: {8, 8, 8},
|
||||
Function: {8, 8, 8},
|
||||
Int: {8, 8, 8},
|
||||
Int16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
Int64: {8, 8, 8},
|
||||
Int8: {1, 1, 1},
|
||||
Interface: {16, 8, 8},
|
||||
Map: {8, 8, 8},
|
||||
Pointer: {8, 8, 8},
|
||||
Slice: {24, 8, 8},
|
||||
String: {16, 8, 8},
|
||||
Uint: {8, 8, 8},
|
||||
Uint16: {2, 2, 2},
|
||||
Uint32: {4, 4, 4},
|
||||
Uint64: {8, 8, 8},
|
||||
Uint8: {1, 1, 1},
|
||||
Uintptr: {8, 8, 8},
|
||||
UnsafePointer: {8, 8, 8},
|
||||
},
|
||||
// go1.19.1
|
||||
{"linux", "ppc64le"}: {
|
||||
Bool: {1, 1, 1},
|
||||
Chan: {8, 8, 8},
|
||||
Complex128: {16, 8, 8},
|
||||
Complex64: {8, 4, 4},
|
||||
Float32: {4, 4, 4},
|
||||
Float64: {8, 8, 8},
|
||||
Function: {8, 8, 8},
|
||||
Int: {8, 8, 8},
|
||||
Int16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
Int64: {8, 8, 8},
|
||||
Int8: {1, 1, 1},
|
||||
Interface: {16, 8, 8},
|
||||
Map: {8, 8, 8},
|
||||
Pointer: {8, 8, 8},
|
||||
Slice: {24, 8, 8},
|
||||
String: {16, 8, 8},
|
||||
Uint: {8, 8, 8},
|
||||
Uint16: {2, 2, 2},
|
||||
Uint32: {4, 4, 4},
|
||||
Uint64: {8, 8, 8},
|
||||
Uint8: {1, 1, 1},
|
||||
Uintptr: {8, 8, 8},
|
||||
UnsafePointer: {8, 8, 8},
|
||||
},
|
||||
// go1.19.1
|
||||
{"linux", "riscv64"}: {
|
||||
Bool: {1, 1, 1},
|
||||
Chan: {8, 8, 8},
|
||||
Complex128: {16, 8, 8},
|
||||
Complex64: {8, 4, 4},
|
||||
Float32: {4, 4, 4},
|
||||
Float64: {8, 8, 8},
|
||||
Function: {8, 8, 8},
|
||||
Int: {8, 8, 8},
|
||||
Int16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
Int64: {8, 8, 8},
|
||||
Int8: {1, 1, 1},
|
||||
Interface: {16, 8, 8},
|
||||
Map: {8, 8, 8},
|
||||
Pointer: {8, 8, 8},
|
||||
Slice: {24, 8, 8},
|
||||
String: {16, 8, 8},
|
||||
Uint: {8, 8, 8},
|
||||
Uint16: {2, 2, 2},
|
||||
Uint32: {4, 4, 4},
|
||||
Uint64: {8, 8, 8},
|
||||
Uint8: {1, 1, 1},
|
||||
Uintptr: {8, 8, 8},
|
||||
UnsafePointer: {8, 8, 8},
|
||||
},
|
||||
// go1.18.3
|
||||
{"netbsd", "386"}: {
|
||||
Bool: {1, 1, 1},
|
||||
Chan: {4, 4, 4},
|
||||
Complex128: {16, 4, 4},
|
||||
Complex64: {8, 4, 4},
|
||||
Float32: {4, 4, 4},
|
||||
Float64: {8, 4, 4},
|
||||
Function: {4, 4, 4},
|
||||
Int: {4, 4, 4},
|
||||
Int16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
Int64: {8, 4, 4},
|
||||
Int8: {1, 1, 1},
|
||||
Interface: {8, 4, 4},
|
||||
Map: {4, 4, 4},
|
||||
Pointer: {4, 4, 4},
|
||||
Slice: {12, 4, 4},
|
||||
String: {8, 4, 4},
|
||||
Uint: {4, 4, 4},
|
||||
Uint16: {2, 2, 2},
|
||||
Uint32: {4, 4, 4},
|
||||
Uint64: {8, 4, 4},
|
||||
Uint8: {1, 1, 1},
|
||||
Uintptr: {4, 4, 4},
|
||||
UnsafePointer: {4, 4, 4},
|
||||
},
|
||||
// go1.18.3
|
||||
{"netbsd", "amd64"}: {
|
||||
Bool: {1, 1, 1},
|
||||
Chan: {8, 8, 8},
|
||||
Complex128: {16, 8, 8},
|
||||
Complex64: {8, 4, 4},
|
||||
Float32: {4, 4, 4},
|
||||
Float64: {8, 8, 8},
|
||||
Function: {8, 8, 8},
|
||||
Int: {8, 8, 8},
|
||||
Int16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
Int64: {8, 8, 8},
|
||||
Int8: {1, 1, 1},
|
||||
Interface: {16, 8, 8},
|
||||
Map: {8, 8, 8},
|
||||
Pointer: {8, 8, 8},
|
||||
Slice: {24, 8, 8},
|
||||
String: {16, 8, 8},
|
||||
Uint: {8, 8, 8},
|
||||
Uint16: {2, 2, 2},
|
||||
Uint32: {4, 4, 4},
|
||||
Uint64: {8, 8, 8},
|
||||
Uint8: {1, 1, 1},
|
||||
Uintptr: {8, 8, 8},
|
||||
UnsafePointer: {8, 8, 8},
|
||||
},
|
||||
// go1.18.3
|
||||
{"netbsd", "arm"}: {
|
||||
Bool: {1, 1, 1},
|
||||
Chan: {4, 4, 4},
|
||||
Complex128: {16, 4, 4},
|
||||
Complex64: {8, 4, 4},
|
||||
Float32: {4, 4, 4},
|
||||
Float64: {8, 4, 4},
|
||||
Function: {4, 4, 4},
|
||||
Int: {4, 4, 4},
|
||||
Int16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
Int64: {8, 4, 4},
|
||||
Int8: {1, 1, 1},
|
||||
Interface: {8, 4, 4},
|
||||
Map: {4, 4, 4},
|
||||
Pointer: {4, 4, 4},
|
||||
Slice: {12, 4, 4},
|
||||
String: {8, 4, 4},
|
||||
Uint: {4, 4, 4},
|
||||
Uint16: {2, 2, 2},
|
||||
Uint32: {4, 4, 4},
|
||||
Uint64: {8, 4, 4},
|
||||
Uint8: {1, 1, 1},
|
||||
Uintptr: {4, 4, 4},
|
||||
UnsafePointer: {4, 4, 4},
|
||||
},
|
||||
// go1.19
|
||||
{"openbsd", "amd64"}: {
|
||||
Bool: {1, 1, 1},
|
||||
Chan: {8, 8, 8},
|
||||
Complex128: {16, 8, 8},
|
||||
Complex64: {8, 4, 4},
|
||||
Float32: {4, 4, 4},
|
||||
Float64: {8, 8, 8},
|
||||
Function: {8, 8, 8},
|
||||
Int: {8, 8, 8},
|
||||
Int16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
Int64: {8, 8, 8},
|
||||
Int8: {1, 1, 1},
|
||||
Interface: {16, 8, 8},
|
||||
Map: {8, 8, 8},
|
||||
Pointer: {8, 8, 8},
|
||||
Slice: {24, 8, 8},
|
||||
String: {16, 8, 8},
|
||||
Uint: {8, 8, 8},
|
||||
Uint16: {2, 2, 2},
|
||||
Uint32: {4, 4, 4},
|
||||
Uint64: {8, 8, 8},
|
||||
Uint8: {1, 1, 1},
|
||||
Uintptr: {8, 8, 8},
|
||||
UnsafePointer: {8, 8, 8},
|
||||
},
|
||||
// go1.19
|
||||
{"openbsd", "arm64"}: {
|
||||
Bool: {1, 1, 1},
|
||||
Chan: {8, 8, 8},
|
||||
Complex128: {16, 8, 8},
|
||||
Complex64: {8, 4, 4},
|
||||
Float32: {4, 4, 4},
|
||||
Float64: {8, 8, 8},
|
||||
Function: {8, 8, 8},
|
||||
Int: {8, 8, 8},
|
||||
Int16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
Int64: {8, 8, 8},
|
||||
Int8: {1, 1, 1},
|
||||
Interface: {16, 8, 8},
|
||||
Map: {8, 8, 8},
|
||||
Pointer: {8, 8, 8},
|
||||
Slice: {24, 8, 8},
|
||||
String: {16, 8, 8},
|
||||
Uint: {8, 8, 8},
|
||||
Uint16: {2, 2, 2},
|
||||
Uint32: {4, 4, 4},
|
||||
Uint64: {8, 8, 8},
|
||||
Uint8: {1, 1, 1},
|
||||
Uintptr: {8, 8, 8},
|
||||
UnsafePointer: {8, 8, 8},
|
||||
},
|
||||
// go1.19
|
||||
{"openbsd", "386"}: {
|
||||
Bool: {1, 1, 1},
|
||||
Chan: {4, 4, 4},
|
||||
Complex128: {16, 4, 4},
|
||||
Complex64: {8, 4, 4},
|
||||
Float32: {4, 4, 4},
|
||||
Float64: {8, 4, 4},
|
||||
Function: {4, 4, 4},
|
||||
Int: {4, 4, 4},
|
||||
Int16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
Int64: {8, 4, 4},
|
||||
Int8: {1, 1, 1},
|
||||
Interface: {8, 4, 4},
|
||||
Map: {4, 4, 4},
|
||||
Pointer: {4, 4, 4},
|
||||
Slice: {12, 4, 4},
|
||||
String: {8, 4, 4},
|
||||
Uint: {4, 4, 4},
|
||||
Uint16: {2, 2, 2},
|
||||
Uint32: {4, 4, 4},
|
||||
Uint64: {8, 4, 4},
|
||||
Uint8: {1, 1, 1},
|
||||
Uintptr: {4, 4, 4},
|
||||
UnsafePointer: {4, 4, 4},
|
||||
},
|
||||
// go1.19.1
|
||||
{"windows", "386"}: {
|
||||
Bool: {1, 1, 1},
|
||||
Chan: {4, 4, 4},
|
||||
Complex128: {16, 4, 4},
|
||||
Complex64: {8, 4, 4},
|
||||
Float32: {4, 4, 4},
|
||||
Float64: {8, 4, 4},
|
||||
Function: {4, 4, 4},
|
||||
Int: {4, 4, 4},
|
||||
Int16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
Int64: {8, 4, 4},
|
||||
Int8: {1, 1, 1},
|
||||
Interface: {8, 4, 4},
|
||||
Map: {4, 4, 4},
|
||||
Pointer: {4, 4, 4},
|
||||
Slice: {12, 4, 4},
|
||||
String: {8, 4, 4},
|
||||
Uint: {4, 4, 4},
|
||||
Uint16: {2, 2, 2},
|
||||
Uint32: {4, 4, 4},
|
||||
Uint64: {8, 4, 4},
|
||||
Uint8: {1, 1, 1},
|
||||
Uintptr: {4, 4, 4},
|
||||
UnsafePointer: {4, 4, 4},
|
||||
},
|
||||
// go1.19.1
|
||||
{"windows", "amd64"}: {
|
||||
Bool: {1, 1, 1},
|
||||
Chan: {8, 8, 8},
|
||||
Complex128: {16, 8, 8},
|
||||
Complex64: {8, 4, 4},
|
||||
Float32: {4, 4, 4},
|
||||
Float64: {8, 8, 8},
|
||||
Function: {8, 8, 8},
|
||||
Int: {8, 8, 8},
|
||||
Int16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
Int64: {8, 8, 8},
|
||||
Int8: {1, 1, 1},
|
||||
Interface: {16, 8, 8},
|
||||
Map: {8, 8, 8},
|
||||
Pointer: {8, 8, 8},
|
||||
Slice: {24, 8, 8},
|
||||
String: {16, 8, 8},
|
||||
Uint: {8, 8, 8},
|
||||
Uint16: {2, 2, 2},
|
||||
Uint32: {4, 4, 4},
|
||||
Uint64: {8, 8, 8},
|
||||
Uint8: {1, 1, 1},
|
||||
Uintptr: {8, 8, 8},
|
||||
UnsafePointer: {8, 8, 8},
|
||||
},
|
||||
// go1.19.1
|
||||
{"windows", "arm64"}: {
|
||||
Bool: {1, 1, 1},
|
||||
Chan: {8, 8, 8},
|
||||
Complex128: {16, 8, 8},
|
||||
Complex64: {8, 4, 4},
|
||||
Float32: {4, 4, 4},
|
||||
Float64: {8, 8, 8},
|
||||
Function: {8, 8, 8},
|
||||
Int: {8, 8, 8},
|
||||
Int16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
Int64: {8, 8, 8},
|
||||
Int8: {1, 1, 1},
|
||||
Interface: {16, 8, 8},
|
||||
Map: {8, 8, 8},
|
||||
Pointer: {8, 8, 8},
|
||||
Slice: {24, 8, 8},
|
||||
String: {16, 8, 8},
|
||||
Uint: {8, 8, 8},
|
||||
Uint16: {2, 2, 2},
|
||||
Uint32: {4, 4, 4},
|
||||
Uint64: {8, 8, 8},
|
||||
Uint8: {1, 1, 1},
|
||||
Uintptr: {8, 8, 8},
|
||||
UnsafePointer: {8, 8, 8},
|
||||
},
|
||||
// go1.19.3
|
||||
{"illumos", "amd64"}: {
|
||||
Bool: {1, 1, 1},
|
||||
Chan: {8, 8, 8},
|
||||
Complex128: {16, 8, 8},
|
||||
Complex64: {8, 4, 4},
|
||||
Float32: {4, 4, 4},
|
||||
Float64: {8, 8, 8},
|
||||
Function: {8, 8, 8},
|
||||
Int: {8, 8, 8},
|
||||
Int16: {2, 2, 2},
|
||||
Int32: {4, 4, 4},
|
||||
Int64: {8, 8, 8},
|
||||
Int8: {1, 1, 1},
|
||||
Interface: {16, 8, 8},
|
||||
Map: {8, 8, 8},
|
||||
Pointer: {8, 8, 8},
|
||||
Slice: {24, 8, 8},
|
||||
String: {16, 8, 8},
|
||||
Uint: {8, 8, 8},
|
||||
Uint16: {2, 2, 2},
|
||||
Uint32: {4, 4, 4},
|
||||
Uint64: {8, 8, 8},
|
||||
Uint8: {1, 1, 1},
|
||||
Uintptr: {8, 8, 8},
|
||||
UnsafePointer: {8, 8, 8},
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
// ABI describes selected parts of the Application Binary Interface.
|
||||
type ABI struct {
|
||||
ByteOrder binary.ByteOrder
|
||||
goarch string
|
||||
goos string
|
||||
Types map[Kind]ABIType
|
||||
}
|
||||
|
||||
type ABIType struct {
|
||||
Size int64
|
||||
Align int64
|
||||
FieldAlign int64
|
||||
}
|
||||
|
||||
// NewABI creates an ABI based on the os+arch pair.
|
||||
func NewABI(os, arch string) (*ABI, error) {
|
||||
byteOrder, ok := byteOrders[arch]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unsupported arch: %s", arch)
|
||||
}
|
||||
|
||||
types0, ok := abiTypes[[2]string{os, arch}]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unsupported os/arch: %s/%s", os, arch)
|
||||
}
|
||||
|
||||
types := make(map[Kind]ABIType, len(types0))
|
||||
for k, v := range types0 {
|
||||
types[k] = v
|
||||
}
|
||||
return &ABI{
|
||||
ByteOrder: byteOrder,
|
||||
Types: types,
|
||||
}, nil
|
||||
}
|
||||
598
vendor/modernc.org/gc/v3/check.go
generated
vendored
Normal file
598
vendor/modernc.org/gc/v3/check.go
generated
vendored
Normal file
|
|
@ -0,0 +1,598 @@
|
|||
// Copyright 2022 The Gc 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 gc // modernc.org/gc/v3
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go/constant"
|
||||
"go/token"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type ctx struct {
|
||||
ast *AST
|
||||
cfg *Config
|
||||
errs errList
|
||||
iota int64
|
||||
pkg *Package
|
||||
|
||||
int32 Type // Set by newCtx
|
||||
untypedFloat Type // Set by newCtx
|
||||
untypedInt Type // Set by newCtx
|
||||
untypedString Type // Set by newCtx
|
||||
}
|
||||
|
||||
func newCtx(cfg *Config) (r *ctx) {
|
||||
r = &ctx{
|
||||
cfg: cfg,
|
||||
iota: -1, // -> Invalid
|
||||
}
|
||||
r.int32 = r.newPredeclaredType(znode, Int32)
|
||||
r.untypedFloat = r.newPredeclaredType(znode, UntypedFloat)
|
||||
r.untypedInt = r.newPredeclaredType(znode, UntypedInt)
|
||||
r.untypedString = r.newPredeclaredType(znode, UntypedString)
|
||||
return r
|
||||
}
|
||||
|
||||
func (c *ctx) err(n Node, msg string, args ...interface{}) {
|
||||
var pos token.Position
|
||||
if n != nil {
|
||||
pos = n.Position()
|
||||
}
|
||||
s := fmt.Sprintf(msg, args...)
|
||||
if trcTODOs && strings.HasPrefix(s, "TODO") {
|
||||
fmt.Fprintf(os.Stderr, "%v: %s (%v)\n", pos, s, origin(2))
|
||||
os.Stderr.Sync()
|
||||
}
|
||||
switch {
|
||||
case extendedErrors:
|
||||
c.errs.err(pos, "%s (%v: %v: %v)", s, origin(4), origin(3), origin(2))
|
||||
default:
|
||||
c.errs.err(pos, s)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ctx) isBuiltin() bool { return c.pkg.Scope.kind == UniverseScope }
|
||||
func (c *ctx) isUnsafe() bool { return c.pkg.isUnsafe }
|
||||
|
||||
func (c *ctx) lookup(sc *Scope, id Token) (pkg *Package, in *Scope, r named) {
|
||||
sc0 := sc
|
||||
pkg = c.pkg
|
||||
for {
|
||||
switch in, nm := sc.lookup(id); x := nm.n.(type) {
|
||||
case *TypeDefNode:
|
||||
if sc.kind == UniverseScope {
|
||||
if sc0.kind != UniverseScope && token.IsExported(id.Src()) {
|
||||
// trc("%v: %q %v %v", id.Position(), id.Src(), sc0.kind, sc.kind)
|
||||
return nil, nil, r
|
||||
}
|
||||
}
|
||||
|
||||
return x.pkg, in, nm
|
||||
default:
|
||||
panic(todo("%v: %q %T", id.Position(), id.Src(), x))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (n *Package) check(c *ctx) (err error) {
|
||||
if n == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
c.pkg = n
|
||||
// trc("PKG %q", n.ImportPath)
|
||||
// defer func() { trc("PKG %q -> err: %v", n.ImportPath, err) }()
|
||||
for _, v := range n.GoFiles {
|
||||
path := filepath.Join(n.FSPath, v.Name())
|
||||
n.AST[path].check(c)
|
||||
}
|
||||
return c.errs.Err()
|
||||
}
|
||||
|
||||
func (n *AST) check(c *ctx) {
|
||||
if n == nil {
|
||||
return
|
||||
}
|
||||
|
||||
c.ast = n
|
||||
n.SourceFile.check(c)
|
||||
}
|
||||
|
||||
func (n *SourceFileNode) check(c *ctx) {
|
||||
if n == nil {
|
||||
return
|
||||
}
|
||||
|
||||
n.PackageClause.check(c)
|
||||
for l := n.ImportDeclList; l != nil; l = l.List {
|
||||
l.ImportDecl.check(c)
|
||||
}
|
||||
for l := n.TopLevelDeclList; l != nil; l = l.List {
|
||||
switch x := l.TopLevelDecl.(type) {
|
||||
case *TypeDeclNode:
|
||||
x.check(c)
|
||||
case *ConstDeclNode:
|
||||
x.check(c)
|
||||
case *VarDeclNode:
|
||||
x.check(c)
|
||||
case *FunctionDeclNode:
|
||||
x.check(c)
|
||||
case *MethodDeclNode:
|
||||
x.check(c)
|
||||
default:
|
||||
panic(todo("%v: %T %s", x.Position(), x, x.Source(false)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (n *MethodDeclNode) check(c *ctx) {
|
||||
if n == nil {
|
||||
return
|
||||
}
|
||||
|
||||
n.Receiver.check(c)
|
||||
n.Signature.check(c)
|
||||
}
|
||||
|
||||
func (n *FunctionDeclNode) check(c *ctx) {
|
||||
if n == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if c.isBuiltin() {
|
||||
switch nm := n.FunctionName.IDENT.Src(); nm {
|
||||
case
|
||||
"append",
|
||||
"cap",
|
||||
"close",
|
||||
"complex",
|
||||
"copy",
|
||||
"delete",
|
||||
"imag",
|
||||
"len",
|
||||
"make",
|
||||
"new",
|
||||
"panic",
|
||||
"print",
|
||||
"println",
|
||||
"real",
|
||||
"recover",
|
||||
|
||||
// Go 1.21
|
||||
"max",
|
||||
"min",
|
||||
"clear":
|
||||
|
||||
n.Signature.t = c.newPredeclaredType(n, Function)
|
||||
default:
|
||||
panic(todo("%v: %q %s", n.Position(), nm, n.Source(false)))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
n.Signature.check(c)
|
||||
if n.TypeParameters != nil {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
}
|
||||
|
||||
func (n *SignatureNode) check(c *ctx) Type {
|
||||
if n == nil {
|
||||
return Invalid
|
||||
}
|
||||
|
||||
if !n.enter(c, n) {
|
||||
return n.Type()
|
||||
}
|
||||
|
||||
in := n.Parameters.check(c)
|
||||
out := n.Result.check(c)
|
||||
return n.setType(newTupleType(n.Parameters, []Type{in, out}))
|
||||
}
|
||||
|
||||
func (n *ResultNode) check(c *ctx) Type {
|
||||
if n == nil {
|
||||
return Invalid
|
||||
}
|
||||
|
||||
switch {
|
||||
case n.Parameters != nil:
|
||||
return n.Parameters.check(c)
|
||||
case n.TypeNode != nil:
|
||||
return n.TypeNode.check(c)
|
||||
default:
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
}
|
||||
|
||||
func (n *ParametersNode) check(c *ctx) Type {
|
||||
if n == nil {
|
||||
return Invalid
|
||||
}
|
||||
|
||||
r := newTupleType(n, nil)
|
||||
for l := n.ParameterDeclList; l != nil; l = l.List {
|
||||
r.Types = append(r.Types, l.ParameterDecl.check(c)...)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func (n *ParameterDeclNode) check(c *ctx) (r []Type) {
|
||||
if n == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
t := n.TypeNode.check(c)
|
||||
for l := n.IdentifierList; l != nil; l = l.List {
|
||||
r = append(r, t)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func (n *VarDeclNode) check(c *ctx) {
|
||||
if n == nil {
|
||||
return
|
||||
}
|
||||
|
||||
switch x := n.VarSpec.(type) {
|
||||
case *VarSpecNode:
|
||||
x.check(c)
|
||||
default:
|
||||
panic(todo("%v: %T %s", n.Position(), x, n.Source(false)))
|
||||
}
|
||||
}
|
||||
|
||||
func (n *VarSpecNode) check(c *ctx) {
|
||||
if n == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if c.isBuiltin() {
|
||||
switch nm := n.IDENT.Src(); nm {
|
||||
case "nil":
|
||||
n.TypeNode = c.newPredeclaredType(n, UntypedNil)
|
||||
default:
|
||||
panic(todo("%v: %q", n.IDENT.Position(), nm))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if n.TypeNode != nil {
|
||||
c.err(n, "TODO %v", n.TypeNode.Source(false))
|
||||
}
|
||||
var e []Expression
|
||||
for l := n.ExpressionList; l != nil; l = l.List {
|
||||
e = append(e, l.Expression.checkExpr(c))
|
||||
}
|
||||
switch len(e) {
|
||||
default:
|
||||
panic(todo("", len(e)))
|
||||
c.err(n, "TODO %v", len(e))
|
||||
}
|
||||
}
|
||||
|
||||
func (n *ConstDeclNode) check(c *ctx) {
|
||||
if n == nil {
|
||||
return
|
||||
}
|
||||
|
||||
switch x := n.ConstSpec.(type) {
|
||||
case *ConstSpecListNode:
|
||||
var prev Node
|
||||
for l := x; l != nil; l = l.List {
|
||||
switch y := l.ConstSpec.(type) {
|
||||
case *ConstSpecNode:
|
||||
y.check(c, prev)
|
||||
if y.Expression != nil || y.TypeNode != nil {
|
||||
prev = y
|
||||
}
|
||||
default:
|
||||
panic(todo("%v: %T %s", n.Position(), y, n.Source(false)))
|
||||
}
|
||||
}
|
||||
case *ConstSpecNode:
|
||||
x.check(c, nil)
|
||||
default:
|
||||
panic(todo("%v: %T %s", n.Position(), x, n.Source(false)))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (n *ConstSpecNode) check(c *ctx, prev Node) {
|
||||
if n == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if !n.enter(c, n) {
|
||||
if n.guard == guardChecking {
|
||||
panic(todo("")) // report recursive
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
defer func() { n.guard = guardChecked }()
|
||||
|
||||
if c.isBuiltin() {
|
||||
switch n.IDENT.Src() {
|
||||
case "true":
|
||||
switch x := n.Expression.(type) {
|
||||
case *BinaryExpressionNode:
|
||||
x.setValue(trueVal)
|
||||
x.setType(c.newPredeclaredType(x, UntypedBool))
|
||||
default:
|
||||
panic(todo("%v: %T %s", n.Position(), x, n.Source(false)))
|
||||
}
|
||||
case "false":
|
||||
switch x := n.Expression.(type) {
|
||||
case *BinaryExpressionNode:
|
||||
x.setValue(falseVal)
|
||||
x.setType(c.newPredeclaredType(x, UntypedBool))
|
||||
default:
|
||||
panic(todo("%v: %T %s", n.Position(), x, n.Source(false)))
|
||||
}
|
||||
case "iota":
|
||||
switch x := n.Expression.(type) {
|
||||
case *BasicLitNode:
|
||||
// ok
|
||||
default:
|
||||
panic(todo("%v: %T %s", n.Position(), x, n.Source(false)))
|
||||
}
|
||||
default:
|
||||
panic(todo("", n.Position(), n.Source(false)))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
save := c.iota
|
||||
c.iota = n.iota
|
||||
|
||||
defer func() { c.iota = save }()
|
||||
|
||||
switch {
|
||||
case n.Expression != nil:
|
||||
n.Expression = n.Expression.checkExpr(c)
|
||||
if n.TypeNode == nil {
|
||||
n.TypeNode = n.Expression.Type()
|
||||
return
|
||||
}
|
||||
|
||||
t := n.TypeNode.check(c)
|
||||
trc("", t)
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
default:
|
||||
// var e Expression
|
||||
// var pe *Expression
|
||||
// switch {
|
||||
// case n.Expression != nil:
|
||||
// e = n.Expression
|
||||
// pe = &n.Expression
|
||||
// default:
|
||||
// switch x := prev.(type) {
|
||||
// case *ConstSpecNode:
|
||||
// e = x.Expression.clone()
|
||||
// pe = &e
|
||||
// default:
|
||||
// panic(todo("%v: %T %s", n.Position(), x, n.Source(false)))
|
||||
// }
|
||||
// }
|
||||
// ev, et := e.checkExpr(c, pe)
|
||||
// e = *pe
|
||||
// if ev.Kind() == constant.Unknown {
|
||||
// c.err(e, "%s is not a constant", e.Source(false))
|
||||
// n.t = Invalid
|
||||
// n.setValue(unknown)
|
||||
// return Invalid
|
||||
// }
|
||||
// switch {
|
||||
// case n.t == nil:
|
||||
// n.t = et
|
||||
// default:
|
||||
|
||||
// c.err(n.Expression, "cannot assign %v (type %v) to type %v", ev, et, n.Type())
|
||||
// return Invalid
|
||||
// } else {
|
||||
// n.setValue(convertValue(c, e, ev, n.Type()))
|
||||
// }
|
||||
// }
|
||||
// return n.Type()
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (n *TypeDeclNode) check(c *ctx) {
|
||||
if n == nil {
|
||||
return
|
||||
}
|
||||
|
||||
for l := n.TypeSpecList; l != nil; l = l.List {
|
||||
switch x := l.TypeSpec.(type) {
|
||||
case *TypeDefNode:
|
||||
switch {
|
||||
case c.isBuiltin():
|
||||
x.pkg = c.pkg
|
||||
switch nm := x.IDENT.Src(); nm {
|
||||
case "bool":
|
||||
x.TypeNode = c.newPredeclaredType(x, Bool)
|
||||
case "int":
|
||||
x.TypeNode = c.newPredeclaredType(x, Int)
|
||||
c.cfg.int = x.TypeNode
|
||||
case "int8":
|
||||
x.TypeNode = c.newPredeclaredType(x, Int8)
|
||||
case "int16":
|
||||
x.TypeNode = c.newPredeclaredType(x, Int16)
|
||||
case "int32":
|
||||
x.TypeNode = c.newPredeclaredType(x, Int32)
|
||||
case "int64":
|
||||
x.TypeNode = c.newPredeclaredType(x, Int64)
|
||||
case "uint":
|
||||
x.TypeNode = c.newPredeclaredType(x, Uint)
|
||||
c.cfg.uint = x.TypeNode
|
||||
case "uint8":
|
||||
x.TypeNode = c.newPredeclaredType(x, Uint8)
|
||||
case "uint16":
|
||||
x.TypeNode = c.newPredeclaredType(x, Uint16)
|
||||
case "uint32":
|
||||
x.TypeNode = c.newPredeclaredType(x, Uint32)
|
||||
case "uint64":
|
||||
x.TypeNode = c.newPredeclaredType(x, Uint64)
|
||||
case "uintptr":
|
||||
x.TypeNode = c.newPredeclaredType(x, Uintptr)
|
||||
case "string":
|
||||
x.TypeNode = c.newPredeclaredType(x, String)
|
||||
case "float32":
|
||||
x.TypeNode = c.newPredeclaredType(x, Float32)
|
||||
case "float64":
|
||||
x.TypeNode = c.newPredeclaredType(x, Float64)
|
||||
case "complex64":
|
||||
x.TypeNode = c.newPredeclaredType(x, Complex64)
|
||||
case "complex128":
|
||||
x.TypeNode = c.newPredeclaredType(x, Complex128)
|
||||
case "comparable":
|
||||
x.TypeNode = c.newPredeclaredType(x, Interface)
|
||||
case "error":
|
||||
x.check(c)
|
||||
default:
|
||||
if token.IsExported(nm) {
|
||||
delete(c.pkg.Scope.nodes, nm)
|
||||
return
|
||||
}
|
||||
|
||||
panic(todo("%v: %T %s", x.Position(), x, x.Source(false)))
|
||||
}
|
||||
case c.isUnsafe():
|
||||
switch nm := x.IDENT.Src(); nm {
|
||||
case "ArbitraryType", "IntegerType", "Pointer":
|
||||
x.TypeNode.check(c)
|
||||
default:
|
||||
panic(todo("%v: %T %s", x.Position(), x, x.Source(false)))
|
||||
}
|
||||
default:
|
||||
switch {
|
||||
case x.TypeParameters != nil:
|
||||
panic(todo("%v: %T %s", x.Position(), x, x.Source(false)))
|
||||
default:
|
||||
x.check(c)
|
||||
}
|
||||
}
|
||||
case *AliasDeclNode:
|
||||
x.check(c)
|
||||
default:
|
||||
panic(todo("%v: %T %s", x.Position(), x, x.Source(false)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (n *AliasDeclNode) check(c *ctx) {
|
||||
if n == nil {
|
||||
return
|
||||
}
|
||||
|
||||
n.TypeNode.check(c)
|
||||
}
|
||||
|
||||
func (n *ImportDeclNode) check(c *ctx) {
|
||||
if n == nil {
|
||||
return
|
||||
}
|
||||
|
||||
type result struct {
|
||||
spec *ImportSpecNode
|
||||
pkg *Package
|
||||
err error
|
||||
}
|
||||
var a []*result
|
||||
var wg sync.WaitGroup
|
||||
for l := n.ImportSpecList; l != nil; l = l.List {
|
||||
r := &result{}
|
||||
a = append(a, r)
|
||||
wg.Add(1)
|
||||
go func(isln *ImportSpecListNode, r *result) {
|
||||
|
||||
defer wg.Done()
|
||||
|
||||
r.spec = isln.ImportSpec
|
||||
r.pkg, r.err = r.spec.check(c)
|
||||
r.spec.pkg = r.pkg
|
||||
}(l, r)
|
||||
}
|
||||
wg.Wait()
|
||||
fileScope := c.ast.FileScope
|
||||
pkgScope := c.pkg.Scope
|
||||
for _, v := range a {
|
||||
switch x := v.err.(type) {
|
||||
case nil:
|
||||
// ok
|
||||
default:
|
||||
panic(todo("%v: %T: %s", v.spec.Position(), x, x))
|
||||
}
|
||||
if c.pkg.ImportPath == "builtin" && v.spec.ImportPath.Src() == `"cmp"` {
|
||||
continue
|
||||
}
|
||||
|
||||
switch ex := fileScope.declare(v.pkg.Name, v.spec, 0, nil, true); {
|
||||
case ex.declTok.IsValid():
|
||||
c.err(n, "%s redeclared, previous declaration at %v:", v.pkg.Name.Src(), ex.declTok.Position())
|
||||
continue
|
||||
}
|
||||
|
||||
switch ex := pkgScope.declare(v.pkg.Name, v.spec, 0, nil, true); {
|
||||
case ex.declTok.IsValid():
|
||||
c.err(n, "%s redeclared, previous declaration at %v:", v.pkg.Name.Src(), ex.declTok.Position())
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (n *ImportSpecNode) check(c *ctx) (*Package, error) {
|
||||
if n == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
switch {
|
||||
case n.PERIOD.IsValid():
|
||||
panic(todo("", n.Position(), n.Source(false)))
|
||||
case n.PackageName.IsValid():
|
||||
//TODO version
|
||||
check := c.pkg.typeCheck
|
||||
switch check {
|
||||
case TypeCheckAll:
|
||||
// nop
|
||||
default:
|
||||
panic(todo("", check))
|
||||
}
|
||||
return c.cfg.newPackage(c.pkg.FSPath, constant.StringVal(n.ImportPath.Value()), "", nil, false, check, c.pkg.guard)
|
||||
default:
|
||||
//TODO version
|
||||
check := c.pkg.typeCheck
|
||||
switch check {
|
||||
case TypeCheckAll:
|
||||
// nop
|
||||
default:
|
||||
if c.pkg.ImportPath == "builtin" && n.ImportPath.Src() == `"cmp"` {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return c.cfg.newPackage(c.pkg.FSPath, constant.StringVal(n.ImportPath.Value()), "", nil, false, check, c.pkg.guard)
|
||||
}
|
||||
}
|
||||
|
||||
func (n *PackageClauseNode) check(c *ctx) {
|
||||
if n == nil {
|
||||
return
|
||||
}
|
||||
|
||||
nm := n.PackageName.Src()
|
||||
if ex := c.pkg.Name; ex.IsValid() && ex.Src() != nm {
|
||||
c.err(n.PackageName, "found different packages %q and %q", ex.Src(), nm)
|
||||
return
|
||||
}
|
||||
|
||||
c.pkg.Name = n.PackageName
|
||||
}
|
||||
559
vendor/modernc.org/gc/v3/etc.go
generated
vendored
Normal file
559
vendor/modernc.org/gc/v3/etc.go
generated
vendored
Normal file
|
|
@ -0,0 +1,559 @@
|
|||
// Copyright 2022 The Gc 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 gc // modernc.org/gc/v3
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go/token"
|
||||
"math"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/dustin/go-humanize"
|
||||
)
|
||||
|
||||
// The list of tokens.
|
||||
const (
|
||||
// Special tokens
|
||||
ILLEGAL = token.ILLEGAL
|
||||
EOF = token.EOF
|
||||
COMMENT = token.COMMENT
|
||||
|
||||
// Identifiers and basic type literals
|
||||
// (these tokens stand for classes of literals)
|
||||
IDENT = token.IDENT // main
|
||||
INT = token.INT // 12345
|
||||
FLOAT = token.FLOAT // 123.45
|
||||
IMAG = token.IMAG // 123.45i
|
||||
CHAR = token.CHAR // 'a'
|
||||
STRING = token.STRING // "abc"
|
||||
|
||||
// Operators and delimiters
|
||||
ADD = token.ADD // +
|
||||
SUB = token.SUB // -
|
||||
MUL = token.MUL // *
|
||||
QUO = token.QUO // /
|
||||
REM = token.REM // %
|
||||
|
||||
AND = token.AND // &
|
||||
OR = token.OR // |
|
||||
XOR = token.XOR // ^
|
||||
SHL = token.SHL // <<
|
||||
SHR = token.SHR // >>
|
||||
AND_NOT = token.AND_NOT // &^
|
||||
|
||||
ADD_ASSIGN = token.ADD_ASSIGN // +=
|
||||
SUB_ASSIGN = token.SUB_ASSIGN // -=
|
||||
MUL_ASSIGN = token.MUL_ASSIGN // *=
|
||||
QUO_ASSIGN = token.QUO_ASSIGN // /=
|
||||
REM_ASSIGN = token.REM_ASSIGN // %=
|
||||
|
||||
AND_ASSIGN = token.AND_ASSIGN // &=
|
||||
OR_ASSIGN = token.OR_ASSIGN // |=
|
||||
XOR_ASSIGN = token.XOR_ASSIGN // ^=
|
||||
SHL_ASSIGN = token.SHL_ASSIGN // <<=
|
||||
SHR_ASSIGN = token.SHR_ASSIGN // >>=
|
||||
AND_NOT_ASSIGN = token.AND_NOT_ASSIGN // &^=
|
||||
|
||||
LAND = token.LAND // &&
|
||||
LOR = token.LOR // ||
|
||||
ARROW = token.ARROW // <-
|
||||
INC = token.INC // ++
|
||||
DEC = token.DEC // --
|
||||
|
||||
EQL = token.EQL // ==
|
||||
LSS = token.LSS // <
|
||||
GTR = token.GTR // >
|
||||
ASSIGN = token.ASSIGN // =
|
||||
NOT = token.NOT // !
|
||||
|
||||
NEQ = token.NEQ // !=
|
||||
LEQ = token.LEQ // <=
|
||||
GEQ = token.GEQ // >=
|
||||
DEFINE = token.DEFINE // :=
|
||||
ELLIPSIS = token.ELLIPSIS // ...
|
||||
|
||||
LPAREN = token.LPAREN // (
|
||||
LBRACK = token.LBRACK // [
|
||||
LBRACE = token.LBRACE // {
|
||||
COMMA = token.COMMA // ,
|
||||
PERIOD = token.PERIOD // .
|
||||
|
||||
RPAREN = token.RPAREN // )
|
||||
RBRACK = token.RBRACK // ]
|
||||
RBRACE = token.RBRACE // }
|
||||
SEMICOLON = token.SEMICOLON // ;
|
||||
COLON = token.COLON // :
|
||||
|
||||
// Keywords
|
||||
BREAK = token.BREAK
|
||||
CASE = token.CASE
|
||||
CHAN = token.CHAN
|
||||
CONST = token.CONST
|
||||
CONTINUE = token.CONTINUE
|
||||
|
||||
DEFAULT = token.DEFAULT
|
||||
DEFER = token.DEFER
|
||||
ELSE = token.ELSE
|
||||
FALLTHROUGH = token.FALLTHROUGH
|
||||
FOR = token.FOR
|
||||
|
||||
FUNC = token.FUNC
|
||||
GO = token.GO
|
||||
GOTO = token.GOTO
|
||||
IF = token.IF
|
||||
IMPORT = token.IMPORT
|
||||
|
||||
INTERFACE = token.INTERFACE
|
||||
MAP = token.MAP
|
||||
PACKAGE = token.PACKAGE
|
||||
RANGE = token.RANGE
|
||||
RETURN = token.RETURN
|
||||
|
||||
SELECT = token.SELECT
|
||||
STRUCT = token.STRUCT
|
||||
SWITCH = token.SWITCH
|
||||
TYPE = token.TYPE
|
||||
VAR = token.VAR
|
||||
|
||||
// additional tokens, handled in an ad-hoc manner
|
||||
TILDE = token.TILDE
|
||||
)
|
||||
|
||||
var (
|
||||
trcTODOs bool
|
||||
extendedErrors bool
|
||||
)
|
||||
|
||||
// origin returns caller's short position, skipping skip frames.
|
||||
func origin(skip int) string {
|
||||
pc, fn, fl, _ := runtime.Caller(skip)
|
||||
f := runtime.FuncForPC(pc)
|
||||
var fns string
|
||||
if f != nil {
|
||||
fns = f.Name()
|
||||
if x := strings.LastIndex(fns, "."); x > 0 {
|
||||
fns = fns[x+1:]
|
||||
}
|
||||
if strings.HasPrefix(fns, "func") {
|
||||
num := true
|
||||
for _, c := range fns[len("func"):] {
|
||||
if c < '0' || c > '9' {
|
||||
num = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if num {
|
||||
return origin(skip + 2)
|
||||
}
|
||||
}
|
||||
}
|
||||
return fmt.Sprintf("%s:%d:%s", filepath.Base(fn), fl, fns)
|
||||
}
|
||||
|
||||
// todo prints and returns caller's position and an optional message tagged with TODO. Output goes to stderr.
|
||||
//
|
||||
//lint:ignore U1000 whatever
|
||||
func todo(s string, args ...interface{}) string {
|
||||
switch {
|
||||
case s == "":
|
||||
s = fmt.Sprintf(strings.Repeat("%v ", len(args)), args...)
|
||||
default:
|
||||
s = fmt.Sprintf(s, args...)
|
||||
}
|
||||
r := fmt.Sprintf("%s\n\tTODO (%s)", origin(2), s)
|
||||
// fmt.Fprintf(os.Stderr, "%s\n", r)
|
||||
// os.Stdout.Sync()
|
||||
return r
|
||||
}
|
||||
|
||||
// trc prints and returns caller's position and an optional message tagged with TRC. Output goes to stderr.
|
||||
//
|
||||
//lint:ignore U1000 whatever
|
||||
func trc(s string, args ...interface{}) string {
|
||||
switch {
|
||||
case s == "":
|
||||
s = fmt.Sprintf(strings.Repeat("%v ", len(args)), args...)
|
||||
default:
|
||||
s = fmt.Sprintf(s, args...)
|
||||
}
|
||||
r := fmt.Sprintf("%s: TRC (%s)", origin(2), s)
|
||||
fmt.Fprintf(os.Stderr, "%s\n", r)
|
||||
os.Stderr.Sync()
|
||||
return r
|
||||
}
|
||||
|
||||
func extractPos(s string) (p token.Position, ok bool) {
|
||||
var prefix string
|
||||
if len(s) > 1 && s[1] == ':' { // c:\foo
|
||||
prefix = s[:2]
|
||||
s = s[2:]
|
||||
}
|
||||
// "testdata/parser/bug/001.c:1193: ..."
|
||||
a := strings.Split(s, ":")
|
||||
// ["testdata/parser/bug/001.c" "1193" "..."]
|
||||
if len(a) < 2 {
|
||||
return p, false
|
||||
}
|
||||
|
||||
line, err := strconv.Atoi(a[1])
|
||||
if err != nil {
|
||||
return p, false
|
||||
}
|
||||
|
||||
col, err := strconv.Atoi(a[2])
|
||||
if err != nil {
|
||||
col = 1
|
||||
}
|
||||
|
||||
return token.Position{Filename: prefix + a[0], Line: line, Column: col}, true
|
||||
}
|
||||
|
||||
// errorf constructs an error value. If extendedErrors is true, the error will
|
||||
// contain its origin.
|
||||
func errorf(s string, args ...interface{}) error {
|
||||
switch {
|
||||
case s == "":
|
||||
s = fmt.Sprintf(strings.Repeat("%v ", len(args)), args...)
|
||||
default:
|
||||
s = fmt.Sprintf(s, args...)
|
||||
}
|
||||
if trcTODOs && strings.HasPrefix(s, "TODO") {
|
||||
fmt.Fprintf(os.Stderr, "%s (%v)\n", s, origin(2))
|
||||
os.Stderr.Sync()
|
||||
}
|
||||
switch {
|
||||
case extendedErrors:
|
||||
return fmt.Errorf("%s (%v: %v: %v)", s, origin(4), origin(3), origin(2))
|
||||
default:
|
||||
return fmt.Errorf("%s", s)
|
||||
}
|
||||
}
|
||||
|
||||
func tokSource(t token.Token) string {
|
||||
switch t {
|
||||
case ILLEGAL:
|
||||
return "ILLEGAL"
|
||||
case EOF:
|
||||
return "EOF"
|
||||
case COMMENT:
|
||||
return "COMMENT"
|
||||
case IDENT:
|
||||
return "IDENT"
|
||||
case INT:
|
||||
return "INT"
|
||||
case FLOAT:
|
||||
return "FLOAT"
|
||||
case IMAG:
|
||||
return "IMAG"
|
||||
case CHAR:
|
||||
return "CHAR"
|
||||
case STRING:
|
||||
return "STRING"
|
||||
case ADD:
|
||||
return "ADD"
|
||||
case SUB:
|
||||
return "SUB"
|
||||
case MUL:
|
||||
return "MUL"
|
||||
case QUO:
|
||||
return "QUO"
|
||||
case REM:
|
||||
return "REM"
|
||||
case AND:
|
||||
return "AND"
|
||||
case OR:
|
||||
return "OR"
|
||||
case XOR:
|
||||
return "XOR"
|
||||
case SHL:
|
||||
return "SHL"
|
||||
case SHR:
|
||||
return "SHR"
|
||||
case AND_NOT:
|
||||
return "AND_NOT"
|
||||
case ADD_ASSIGN:
|
||||
return "ADD_ASSIGN"
|
||||
case SUB_ASSIGN:
|
||||
return "SUB_ASSIGN"
|
||||
case MUL_ASSIGN:
|
||||
return "MUL_ASSIGN"
|
||||
case QUO_ASSIGN:
|
||||
return "QUO_ASSIGN"
|
||||
case REM_ASSIGN:
|
||||
return "REM_ASSIGN"
|
||||
case AND_ASSIGN:
|
||||
return "AND_ASSIGN"
|
||||
case OR_ASSIGN:
|
||||
return "OR_ASSIGN"
|
||||
case XOR_ASSIGN:
|
||||
return "XOR_ASSIGN"
|
||||
case SHL_ASSIGN:
|
||||
return "SHL_ASSIGN"
|
||||
case SHR_ASSIGN:
|
||||
return "SHR_ASSIGN"
|
||||
case AND_NOT_ASSIGN:
|
||||
return "AND_NOT_ASSIGN"
|
||||
case LAND:
|
||||
return "LAND"
|
||||
case LOR:
|
||||
return "LOR"
|
||||
case ARROW:
|
||||
return "ARROW"
|
||||
case INC:
|
||||
return "INC"
|
||||
case DEC:
|
||||
return "DEC"
|
||||
case EQL:
|
||||
return "EQL"
|
||||
case LSS:
|
||||
return "LSS"
|
||||
case GTR:
|
||||
return "GTR"
|
||||
case ASSIGN:
|
||||
return "ASSIGN"
|
||||
case NOT:
|
||||
return "NOT"
|
||||
case NEQ:
|
||||
return "NEQ"
|
||||
case LEQ:
|
||||
return "LEQ"
|
||||
case GEQ:
|
||||
return "GEQ"
|
||||
case DEFINE:
|
||||
return "DEFINE"
|
||||
case ELLIPSIS:
|
||||
return "ELLIPSIS"
|
||||
case LPAREN:
|
||||
return "LPAREN"
|
||||
case LBRACK:
|
||||
return "LBRACK"
|
||||
case LBRACE:
|
||||
return "LBRACE"
|
||||
case COMMA:
|
||||
return "COMMA"
|
||||
case PERIOD:
|
||||
return "PERIOD"
|
||||
case RPAREN:
|
||||
return "RPAREN"
|
||||
case RBRACK:
|
||||
return "RBRACK"
|
||||
case RBRACE:
|
||||
return "RBRACE"
|
||||
case SEMICOLON:
|
||||
return "SEMICOLON"
|
||||
case COLON:
|
||||
return "COLON"
|
||||
case BREAK:
|
||||
return "BREAK"
|
||||
case CASE:
|
||||
return "CASE"
|
||||
case CHAN:
|
||||
return "CHAN"
|
||||
case CONST:
|
||||
return "CONST"
|
||||
case CONTINUE:
|
||||
return "CONTINUE"
|
||||
case DEFAULT:
|
||||
return "DEFAULT"
|
||||
case DEFER:
|
||||
return "DEFER"
|
||||
case ELSE:
|
||||
return "ELSE"
|
||||
case FALLTHROUGH:
|
||||
return "FALLTHROUGH"
|
||||
case FOR:
|
||||
return "FOR"
|
||||
case FUNC:
|
||||
return "FUNC"
|
||||
case GO:
|
||||
return "GO"
|
||||
case GOTO:
|
||||
return "GOTO"
|
||||
case IF:
|
||||
return "IF"
|
||||
case IMPORT:
|
||||
return "IMPORT"
|
||||
case INTERFACE:
|
||||
return "INTERFACE"
|
||||
case MAP:
|
||||
return "MAP"
|
||||
case PACKAGE:
|
||||
return "PACKAGE"
|
||||
case RANGE:
|
||||
return "RANGE"
|
||||
case RETURN:
|
||||
return "RETURN"
|
||||
case SELECT:
|
||||
return "SELECT"
|
||||
case STRUCT:
|
||||
return "STRUCT"
|
||||
case SWITCH:
|
||||
return "SWITCH"
|
||||
case TYPE:
|
||||
return "TYPE"
|
||||
case VAR:
|
||||
return "VAR"
|
||||
case TILDE:
|
||||
return "TILDE"
|
||||
default:
|
||||
panic(todo("", int(t), t))
|
||||
}
|
||||
}
|
||||
|
||||
type data struct {
|
||||
line int
|
||||
cases int
|
||||
cnt int
|
||||
}
|
||||
|
||||
type analyzer struct {
|
||||
sync.Mutex
|
||||
m map[int]*data // line: data
|
||||
}
|
||||
|
||||
func newAnalyzer() *analyzer {
|
||||
return &analyzer{m: map[int]*data{}}
|
||||
}
|
||||
|
||||
func (a *analyzer) record(line, cnt int) {
|
||||
d := a.m[line]
|
||||
if d == nil {
|
||||
d = &data{line: line}
|
||||
a.m[line] = d
|
||||
}
|
||||
d.cases++
|
||||
d.cnt += cnt
|
||||
}
|
||||
|
||||
func (a *analyzer) merge(b *analyzer) {
|
||||
a.Lock()
|
||||
defer a.Unlock()
|
||||
|
||||
for k, v := range b.m {
|
||||
d := a.m[k]
|
||||
if d == nil {
|
||||
d = &data{line: k}
|
||||
a.m[k] = d
|
||||
}
|
||||
d.cases += v.cases
|
||||
d.cnt += v.cnt
|
||||
}
|
||||
}
|
||||
|
||||
func (a *analyzer) report() string {
|
||||
var rows []*data
|
||||
for _, v := range a.m {
|
||||
rows = append(rows, v)
|
||||
}
|
||||
sort.Slice(rows, func(i, j int) bool {
|
||||
a := rows[i]
|
||||
b := rows[j]
|
||||
if a.cases < b.cases {
|
||||
return true
|
||||
}
|
||||
|
||||
if a.cases > b.cases {
|
||||
return false
|
||||
}
|
||||
|
||||
// a.cases == b.cases
|
||||
if a.cnt < b.cnt {
|
||||
return true
|
||||
}
|
||||
|
||||
if a.cnt > b.cnt {
|
||||
return false
|
||||
}
|
||||
|
||||
// a.cnt == b.cnt
|
||||
return a.line < b.line
|
||||
})
|
||||
var b strings.Builder
|
||||
var cases, cnt int
|
||||
for _, row := range rows {
|
||||
cases += row.cases
|
||||
cnt += row.cnt
|
||||
avg := float64(row.cnt) / float64(row.cases)
|
||||
fmt.Fprintf(&b, "parser.go:%d:\t%16s %16s %8.1f\n", row.line, h(row.cases), h(row.cnt), avg)
|
||||
}
|
||||
avg := float64(cnt) / float64(cases)
|
||||
fmt.Fprintf(&b, "<total>\t\t%16s %16s %8.1f\n", h(cases), h(cnt), avg)
|
||||
return b.String()
|
||||
}
|
||||
|
||||
func h(v interface{}) string {
|
||||
switch x := v.(type) {
|
||||
case int:
|
||||
return humanize.Comma(int64(x))
|
||||
case int32:
|
||||
return humanize.Comma(int64(x))
|
||||
case int64:
|
||||
return humanize.Comma(x)
|
||||
case uint32:
|
||||
return humanize.Comma(int64(x))
|
||||
case uint64:
|
||||
if x <= math.MaxInt64 {
|
||||
return humanize.Comma(int64(x))
|
||||
}
|
||||
|
||||
return "-" + humanize.Comma(-int64(x))
|
||||
}
|
||||
return fmt.Sprint(v)
|
||||
}
|
||||
|
||||
type parallel struct {
|
||||
limiter chan struct{}
|
||||
}
|
||||
|
||||
func newParallel() *parallel {
|
||||
return ¶llel{
|
||||
limiter: make(chan struct{}, runtime.GOMAXPROCS(0)),
|
||||
}
|
||||
}
|
||||
|
||||
func (p *parallel) throttle(f func()) {
|
||||
p.limiter <- struct{}{}
|
||||
|
||||
defer func() {
|
||||
<-p.limiter
|
||||
}()
|
||||
|
||||
f()
|
||||
}
|
||||
|
||||
func extraTags(verMajor, verMinor int, goos, goarch string) (r []string) {
|
||||
// https://github.com/golang/go/commit/eeb7899137cda1c2cd60dab65ff41f627436db5b
|
||||
//
|
||||
// In Go 1.17 we added register ABI on AMD64 on Linux/macOS/Windows
|
||||
// as a GOEXPERIMENT, on by default. In Go 1.18, we commit to always
|
||||
// enabling register ABI on AMD64.
|
||||
//
|
||||
// Now "go build" for AMD64 always have goexperiment.regabi* tags
|
||||
// set. However, at bootstrapping cmd/dist does not set the tags
|
||||
// when building go_bootstrap. For this to work, unfortunately, we
|
||||
// need to hard-code AMD64 to use register ABI in runtime code.
|
||||
if verMajor == 1 {
|
||||
switch {
|
||||
case verMinor == 17:
|
||||
switch goos {
|
||||
case "linux", "darwin", "windows":
|
||||
if goarch == "amd64" {
|
||||
r = append(r, "goexperiment.regabiargs", "goexperiment.regabiwrappers")
|
||||
}
|
||||
}
|
||||
case verMinor >= 18:
|
||||
if goarch == "amd64" {
|
||||
r = append(r, "goexperiment.regabiargs", "goexperiment.regabiwrappers")
|
||||
}
|
||||
}
|
||||
}
|
||||
return r
|
||||
}
|
||||
761
vendor/modernc.org/gc/v3/gc.go
generated
vendored
Normal file
761
vendor/modernc.org/gc/v3/gc.go
generated
vendored
Normal file
|
|
@ -0,0 +1,761 @@
|
|||
// Copyright 2022 The Gc 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 -output stringer.go -linecomment -type=Kind,ScopeKind,ChanDir,TypeCheck
|
||||
|
||||
package gc // modernc.org/gc/v3
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go/build"
|
||||
"go/build/constraint"
|
||||
"go/token"
|
||||
"io"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"unicode"
|
||||
|
||||
"github.com/hashicorp/golang-lru/v2"
|
||||
)
|
||||
|
||||
var (
|
||||
trcErrors bool
|
||||
)
|
||||
|
||||
type FileFilter func(cfg *Config, importPath string, matchedFSPaths []string, withTestFiles bool) (pkgFiles []string, err error)
|
||||
|
||||
type TypeCheck int
|
||||
|
||||
const (
|
||||
TypeCheckNone TypeCheck = iota
|
||||
TypeCheckAll
|
||||
)
|
||||
|
||||
type cacheKey struct {
|
||||
buildTagsKey string
|
||||
cfg *Config
|
||||
fsPath string
|
||||
goarch string
|
||||
goos string
|
||||
gopathKey string
|
||||
goroot string
|
||||
importPath string
|
||||
typeCheck TypeCheck
|
||||
|
||||
withTestFiles bool
|
||||
}
|
||||
|
||||
type cacheItem struct {
|
||||
pkg *Package
|
||||
ch chan struct{}
|
||||
}
|
||||
|
||||
func newCacheItem() *cacheItem { return &cacheItem{ch: make(chan struct{})} }
|
||||
|
||||
func (c *cacheItem) set(pkg *Package) {
|
||||
c.pkg = pkg
|
||||
close(c.ch)
|
||||
}
|
||||
|
||||
func (c *cacheItem) wait() *Package {
|
||||
<-c.ch
|
||||
return c.pkg
|
||||
}
|
||||
|
||||
type Cache struct {
|
||||
sync.Mutex
|
||||
lru *lru.TwoQueueCache[cacheKey, *cacheItem]
|
||||
}
|
||||
|
||||
func NewCache(size int) (*Cache, error) {
|
||||
c, err := lru.New2Q[cacheKey, *cacheItem](size)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Cache{lru: c}, nil
|
||||
}
|
||||
|
||||
func MustNewCache(size int) *Cache {
|
||||
c, err := NewCache(size)
|
||||
if err != nil {
|
||||
panic(todo("", err))
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
type ConfigOption func(*Config) error
|
||||
|
||||
// Config configures NewPackage
|
||||
//
|
||||
// Config instances can be shared, they are not mutated once created and
|
||||
// configured.
|
||||
type Config struct {
|
||||
abi *ABI
|
||||
buildTagMap map[string]bool
|
||||
buildTags []string
|
||||
buildTagsKey string // Zero byte separated
|
||||
builtin *Package
|
||||
cache *Cache
|
||||
cmp *Package // Go 1.21
|
||||
env map[string]string
|
||||
fs fs.FS
|
||||
goarch string
|
||||
gocompiler string // "gc", "gccgo"
|
||||
goos string
|
||||
gopath string
|
||||
gopathKey string // Zero byte separated
|
||||
goroot string
|
||||
goversion string
|
||||
lookup func(rel, importPath, version string) (fsPath string, err error)
|
||||
parallel *parallel
|
||||
searchGoPaths []string
|
||||
searchGoroot []string
|
||||
|
||||
int Type // Set by NewConfig
|
||||
uint Type // Set by NewConfig
|
||||
|
||||
arch32bit bool
|
||||
configured bool
|
||||
}
|
||||
|
||||
// NewConfig returns a newly created config or an error, if any.
|
||||
func NewConfig(opts ...ConfigOption) (r *Config, err error) {
|
||||
r = &Config{
|
||||
buildTagMap: map[string]bool{},
|
||||
env: map[string]string{},
|
||||
parallel: newParallel(),
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if r != nil {
|
||||
r.configured = true
|
||||
}
|
||||
}()
|
||||
|
||||
r.lookup = r.DefaultLookup
|
||||
ctx := build.Default
|
||||
r.goos = r.getenv("GOOS", ctx.GOOS)
|
||||
r.goarch = r.getenv("GOARCH", ctx.GOARCH)
|
||||
r.goroot = r.getenv("GOROOT", ctx.GOROOT)
|
||||
r.gopath = r.getenv("GOPATH", ctx.GOPATH)
|
||||
r.buildTags = append(r.buildTags, r.goos, r.goarch)
|
||||
r.gocompiler = runtime.Compiler
|
||||
for _, opt := range opts {
|
||||
if err := opt(r); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if r.abi, err = NewABI(r.goos, r.goarch); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch r.goarch {
|
||||
case "386", "arm":
|
||||
r.arch32bit = true
|
||||
}
|
||||
|
||||
// During a particular build, the following build tags are satisfied:
|
||||
//
|
||||
// the target operating system, as spelled by runtime.GOOS, set with the GOOS environment variable.
|
||||
// the target architecture, as spelled by runtime.GOARCH, set with the GOARCH environment variable.
|
||||
// "unix", if GOOS is a Unix or Unix-like system.
|
||||
// the compiler being used, either "gc" or "gccgo"
|
||||
// "cgo", if the cgo command is supported (see CGO_ENABLED in 'go help environment').
|
||||
// a term for each Go major release, through the current version: "go1.1" from Go version 1.1 onward, "go1.12" from Go 1.12, and so on.
|
||||
// any additional tags given by the -tags flag (see 'go help build').
|
||||
// There are no separate build tags for beta or minor releases.
|
||||
if r.goversion == "" {
|
||||
r.goversion = runtime.Version()
|
||||
}
|
||||
if !strings.HasPrefix(r.goversion, "go") || !strings.Contains(r.goversion, ".") {
|
||||
return nil, fmt.Errorf("cannot parse Go version: %s", r.goversion)
|
||||
}
|
||||
|
||||
ver := strings.SplitN(r.goversion[len("go"):], ".", 2)
|
||||
verMajor, err := strconv.Atoi(ver[0])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot parse Go version %s: %v", r.goversion, err)
|
||||
}
|
||||
|
||||
if verMajor != 1 {
|
||||
return nil, fmt.Errorf("unsupported Go version: %s", r.goversion)
|
||||
}
|
||||
|
||||
switch x, x2 := strings.IndexByte(ver[1], '.'), strings.Index(ver[1], "rc"); {
|
||||
case x >= 0:
|
||||
ver[1] = ver[1][:x]
|
||||
case x2 >= 0:
|
||||
ver[1] = ver[1][:x2]
|
||||
}
|
||||
verMinor, err := strconv.Atoi(ver[1])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot parse Go version %s: %v", r.goversion, err)
|
||||
}
|
||||
|
||||
for i := 1; i <= verMinor; i++ {
|
||||
r.buildTags = append(r.buildTags, fmt.Sprintf("go%d.%d", verMajor, i))
|
||||
}
|
||||
r.buildTags = append(r.buildTags, r.gocompiler)
|
||||
r.buildTags = append(r.buildTags, extraTags(verMajor, verMinor, r.goos, r.goarch)...)
|
||||
if r.getenv("CGO_ENABLED", "1") == "1" {
|
||||
r.buildTags = append(r.buildTags, "cgo")
|
||||
}
|
||||
for i, v := range r.buildTags {
|
||||
tag := strings.TrimSpace(v)
|
||||
r.buildTags[i] = tag
|
||||
r.buildTagMap[tag] = true
|
||||
}
|
||||
sort.Strings(r.buildTags)
|
||||
r.buildTagsKey = strings.Join(r.buildTags, "\x00")
|
||||
r.searchGoroot = []string{filepath.Join(r.goroot, "src")}
|
||||
r.searchGoPaths = filepath.SplitList(r.gopath)
|
||||
r.gopathKey = strings.Join(r.searchGoPaths, "\x00")
|
||||
for i, v := range r.searchGoPaths {
|
||||
r.searchGoPaths[i] = filepath.Join(v, "src")
|
||||
}
|
||||
|
||||
switch r.cmp, err = r.NewPackage("", "cmp", "", nil, false, TypeCheckNone); {
|
||||
case err != nil:
|
||||
r.cmp = nil
|
||||
default:
|
||||
//TODO r.cmp.Scope.kind = UniverseScope
|
||||
}
|
||||
if r.builtin, err = r.NewPackage("", "builtin", "", nil, false, TypeCheckNone); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
r.builtin.Scope.kind = UniverseScope
|
||||
if err := r.builtin.check(newCtx(r)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return r, nil
|
||||
}
|
||||
|
||||
func (c *Config) universe() *Scope {
|
||||
if c.builtin != nil {
|
||||
return c.builtin.Scope
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Config) stat(name string) (fs.FileInfo, error) {
|
||||
if c.fs == nil {
|
||||
return os.Stat(name)
|
||||
}
|
||||
|
||||
name = filepath.ToSlash(name)
|
||||
if x, ok := c.fs.(fs.StatFS); ok {
|
||||
return x.Stat(name)
|
||||
}
|
||||
|
||||
f, err := c.fs.Open(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defer f.Close()
|
||||
|
||||
return f.Stat()
|
||||
}
|
||||
|
||||
func (c *Config) open(name string) (fs.File, error) {
|
||||
if c.fs == nil {
|
||||
return os.Open(name)
|
||||
}
|
||||
|
||||
name = filepath.ToSlash(name)
|
||||
return c.fs.Open(name)
|
||||
}
|
||||
|
||||
func (c *Config) glob(pattern string) (matches []string, err error) {
|
||||
if c.fs == nil {
|
||||
return filepath.Glob(pattern)
|
||||
}
|
||||
|
||||
pattern = filepath.ToSlash(pattern)
|
||||
return fs.Glob(c.fs, pattern)
|
||||
}
|
||||
|
||||
func (c *Config) checkConstraints(pos token.Position, sep string) (r bool) {
|
||||
if !strings.Contains(sep, "//go:build") && !strings.Contains(sep, "+build") {
|
||||
return true
|
||||
}
|
||||
|
||||
// defer func() { trc("", r) }()
|
||||
|
||||
lines := strings.Split(sep, "\n")
|
||||
var build, plusBuild []string
|
||||
for i, line := range lines {
|
||||
if constraint.IsGoBuild(line) && i < len(lines)-1 && lines[i+1] == "" {
|
||||
build = append(build, line)
|
||||
}
|
||||
if constraint.IsPlusBuild(line) {
|
||||
plusBuild = append(plusBuild, line)
|
||||
}
|
||||
}
|
||||
switch len(build) {
|
||||
case 0:
|
||||
// ok
|
||||
case 1:
|
||||
expr, err := constraint.Parse(build[0])
|
||||
if err != nil {
|
||||
return true
|
||||
}
|
||||
|
||||
return expr.Eval(func(tag string) (r bool) {
|
||||
// defer func() { trc("%q: %v", tag, r) }()
|
||||
switch tag {
|
||||
case "unix":
|
||||
return unixOS[c.goos]
|
||||
default:
|
||||
return c.buildTagMap[tag]
|
||||
}
|
||||
})
|
||||
default:
|
||||
panic(todo("%v: %q", pos, build))
|
||||
}
|
||||
|
||||
for _, line := range plusBuild {
|
||||
expr, err := constraint.Parse(line)
|
||||
if err != nil {
|
||||
return true
|
||||
}
|
||||
|
||||
if !expr.Eval(func(tag string) (r bool) {
|
||||
// defer func() { trc("%q: %v", tag, r) }()
|
||||
switch tag {
|
||||
case "unix":
|
||||
return unixOS[c.goos]
|
||||
default:
|
||||
return c.buildTagMap[tag]
|
||||
}
|
||||
}) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Default lookup translates import paths, possibly relative to rel, to file system paths.
|
||||
func (c *Config) DefaultLookup(rel, importPath, version string) (fsPath string, err error) {
|
||||
if importPath == "" {
|
||||
return "", fmt.Errorf("import path cannot be emtpy")
|
||||
}
|
||||
|
||||
// Implementation restriction: A compiler may restrict ImportPaths to non-empty
|
||||
// strings using only characters belonging to Unicode's L, M, N, P, and S
|
||||
// general categories (the Graphic characters without spaces) and may also
|
||||
// exclude the characters !"#$%&'()*,:;<=>?[\]^`{|} and the Unicode replacement
|
||||
// character U+FFFD.
|
||||
if strings.ContainsAny(importPath, "!\"#$%&'()*,:;<=>?[\\]^`{|}\ufffd") {
|
||||
return "", fmt.Errorf("invalid import path: %s", importPath)
|
||||
}
|
||||
|
||||
for _, r := range importPath {
|
||||
if !unicode.Is(unicode.L, r) &&
|
||||
!unicode.Is(unicode.M, r) &&
|
||||
!unicode.Is(unicode.N, r) &&
|
||||
!unicode.Is(unicode.P, r) &&
|
||||
!unicode.Is(unicode.S, r) {
|
||||
return "", fmt.Errorf("invalid import path: %s", importPath)
|
||||
}
|
||||
}
|
||||
var search []string
|
||||
ip0 := importPath
|
||||
switch slash := strings.IndexByte(importPath, '/'); {
|
||||
case strings.HasPrefix(importPath, "./"):
|
||||
if rel != "" {
|
||||
panic(todo(""))
|
||||
}
|
||||
|
||||
return "", fmt.Errorf("invalid import path: %s", importPath)
|
||||
case strings.HasPrefix(importPath, "/"):
|
||||
return importPath, nil
|
||||
case slash > 0:
|
||||
ip0 = importPath[:slash]
|
||||
default:
|
||||
ip0 = importPath
|
||||
}
|
||||
if ip0 != "" {
|
||||
switch {
|
||||
case strings.Contains(ip0, "."):
|
||||
search = c.searchGoPaths
|
||||
default:
|
||||
search = c.searchGoroot
|
||||
}
|
||||
}
|
||||
for _, v := range search {
|
||||
fsPath = filepath.Join(v, importPath)
|
||||
dir, err := c.open(fsPath)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
fi, err := dir.Stat()
|
||||
dir.Close()
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if fi.IsDir() {
|
||||
return fsPath, nil
|
||||
}
|
||||
}
|
||||
|
||||
return "", fmt.Errorf("cannot find package %s, searched %v", importPath, search)
|
||||
}
|
||||
|
||||
func (c *Config) getenv(nm, deflt string) (r string) {
|
||||
if r = c.env[nm]; r != "" {
|
||||
return r
|
||||
}
|
||||
|
||||
if r = os.Getenv(nm); r != "" {
|
||||
return r
|
||||
}
|
||||
|
||||
return deflt
|
||||
}
|
||||
|
||||
func DefaultFileFilter(cfg *Config, importPath string, matchedFSPaths []string, withTestFiles bool) (pkgFiles []string, err error) {
|
||||
w := 0
|
||||
for _, v := range matchedFSPaths {
|
||||
base := filepath.Base(v)
|
||||
base = base[:len(base)-len(filepath.Ext(base))]
|
||||
const testSuffix = "_test"
|
||||
if strings.HasSuffix(base, testSuffix) {
|
||||
if !withTestFiles {
|
||||
continue
|
||||
}
|
||||
|
||||
base = base[:len(base)-len(testSuffix)]
|
||||
}
|
||||
if x := strings.LastIndexByte(base, '_'); x > 0 {
|
||||
last := base[x+1:]
|
||||
base = base[:x]
|
||||
var prevLast string
|
||||
if x := strings.LastIndexByte(base, '_'); x > 0 {
|
||||
prevLast = base[x+1:]
|
||||
}
|
||||
if last != "" && prevLast != "" {
|
||||
// *_GOOS_GOARCH
|
||||
if knownOS[prevLast] && prevLast != cfg.goos {
|
||||
continue
|
||||
}
|
||||
|
||||
if knownArch[last] && last != cfg.goarch {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if last != "" {
|
||||
// *_GOOS or *_GOARCH
|
||||
if knownOS[last] && last != cfg.goos {
|
||||
continue
|
||||
}
|
||||
|
||||
if knownArch[last] && last != cfg.goarch {
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
matchedFSPaths[w] = v
|
||||
w++
|
||||
}
|
||||
return matchedFSPaths[:w], nil
|
||||
}
|
||||
|
||||
// ConfigBuildTags configures build tags.
|
||||
func ConfigBuildTags(tags []string) ConfigOption {
|
||||
return func(cfg *Config) error {
|
||||
if cfg.configured {
|
||||
return fmt.Errorf("ConfigBuildTags: Config instance already configured")
|
||||
}
|
||||
|
||||
cfg.buildTags = append(cfg.buildTags, tags...)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ConfigEnviron configures environment variables.
|
||||
func ConfigEnviron(env []string) ConfigOption {
|
||||
return func(cfg *Config) error {
|
||||
if cfg.configured {
|
||||
return fmt.Errorf("ConfigEnviron: Config instance already configured")
|
||||
}
|
||||
|
||||
for _, v := range env {
|
||||
switch x := strings.IndexByte(v, '='); {
|
||||
case x < 0:
|
||||
cfg.env[v] = ""
|
||||
default:
|
||||
cfg.env[v[:x]] = v[x+1:]
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ConfigFS configures a file system used for opening Go source files. If not
|
||||
// explicitly configured, a default os.DirFS("/") is used on Unix-like
|
||||
// operating systems. On Windows it will be rooted on the volume where
|
||||
// runtime.GOROOT() is.
|
||||
func ConfigFS(fs fs.FS) ConfigOption {
|
||||
return func(cfg *Config) error {
|
||||
if cfg.configured {
|
||||
return fmt.Errorf("ConfigFS: Config instance already configured")
|
||||
}
|
||||
|
||||
cfg.fs = fs
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ConfigLookup configures a lookup function.
|
||||
func ConfigLookup(f func(dir, importPath, version string) (fsPath string, err error)) ConfigOption {
|
||||
return func(cfg *Config) error {
|
||||
if cfg.configured {
|
||||
return fmt.Errorf("ConfigLookup: Config instance already configured")
|
||||
}
|
||||
|
||||
cfg.lookup = f
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ConfigCache configures a cache.
|
||||
func ConfigCache(c *Cache) ConfigOption {
|
||||
return func(cfg *Config) error {
|
||||
if cfg.configured {
|
||||
return fmt.Errorf("ConfigCache: Config instance already configured")
|
||||
}
|
||||
|
||||
cfg.cache = c
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
type importGuard struct {
|
||||
m map[string]struct{}
|
||||
stack []string
|
||||
}
|
||||
|
||||
func newImportGuard() *importGuard { return &importGuard{m: map[string]struct{}{}} }
|
||||
|
||||
// Package represents a Go package. The instance must not be mutated.
|
||||
type Package struct {
|
||||
AST map[string]*AST // AST maps fsPaths of individual files to their respective ASTs
|
||||
FSPath string
|
||||
GoFiles []fs.FileInfo
|
||||
ImportPath string
|
||||
InvalidGoFiles map[string]error // errors for particular files, if any
|
||||
Name Token
|
||||
Scope *Scope // Package scope.
|
||||
Version string
|
||||
cfg *Config
|
||||
guard *importGuard
|
||||
mu sync.Mutex
|
||||
typeCheck TypeCheck
|
||||
|
||||
isUnsafe bool // ImportPath == "usnafe"
|
||||
// isChecked bool
|
||||
}
|
||||
|
||||
// NewPackage returns a Package, possibly cached, for importPath@version or an
|
||||
// error, if any. The fileFilter argument can be nil, in such case
|
||||
// DefaultFileFilter is used, which ignores Files with suffix _test.go unless
|
||||
// withTestFiles is true.
|
||||
//
|
||||
// NewPackage is safe for concurrent use by multiple goroutines.
|
||||
func (c *Config) NewPackage(dir, importPath, version string, fileFilter FileFilter, withTestFiles bool, typeCheck TypeCheck) (pkg *Package, err error) {
|
||||
return c.newPackage(dir, importPath, version, fileFilter, withTestFiles, typeCheck, newImportGuard())
|
||||
}
|
||||
|
||||
func (c *Config) newPackage(dir, importPath, version string, fileFilter FileFilter, withTestFiles bool, typeCheck TypeCheck, guard *importGuard) (pkg *Package, err error) {
|
||||
if _, ok := guard.m[importPath]; ok {
|
||||
return nil, fmt.Errorf("import cycle %v", guard.stack)
|
||||
}
|
||||
|
||||
guard.stack = append(guard.stack, importPath)
|
||||
fsPath, err := c.lookup(dir, importPath, version)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("lookup %s: %v", importPath, err)
|
||||
}
|
||||
|
||||
pat := filepath.Join(fsPath, "*.go")
|
||||
matches, err := c.glob(pat)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("glob %s: %v", pat, err)
|
||||
}
|
||||
|
||||
if len(matches) == 0 {
|
||||
return nil, fmt.Errorf("no Go files in %s", fsPath)
|
||||
}
|
||||
|
||||
if fileFilter == nil {
|
||||
fileFilter = DefaultFileFilter
|
||||
}
|
||||
if matches, err = fileFilter(c, importPath, matches, withTestFiles); err != nil {
|
||||
return nil, fmt.Errorf("matching Go files in %s: %v", fsPath, err)
|
||||
}
|
||||
|
||||
var k cacheKey
|
||||
if c.cache != nil {
|
||||
k = cacheKey{
|
||||
buildTagsKey: c.buildTagsKey,
|
||||
cfg: c,
|
||||
fsPath: fsPath,
|
||||
goarch: c.goarch,
|
||||
goos: c.goos,
|
||||
gopathKey: c.gopathKey,
|
||||
goroot: c.goroot,
|
||||
importPath: importPath,
|
||||
typeCheck: typeCheck,
|
||||
withTestFiles: withTestFiles,
|
||||
}
|
||||
|
||||
c.cache.Lock() // ---------------------------------------- lock
|
||||
item, ok := c.cache.lru.Get(k)
|
||||
if ok {
|
||||
c.cache.Unlock() // ---------------------------- unlock
|
||||
if pkg = item.wait(); pkg != nil && pkg.matches(&k, matches) {
|
||||
return pkg, nil
|
||||
}
|
||||
}
|
||||
|
||||
item = newCacheItem()
|
||||
c.cache.lru.Add(k, item)
|
||||
c.cache.Unlock() // ------------------------------------ unlock
|
||||
|
||||
defer func() {
|
||||
if pkg != nil && err == nil {
|
||||
item.set(pkg)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
r := &Package{
|
||||
AST: map[string]*AST{},
|
||||
FSPath: fsPath,
|
||||
ImportPath: importPath,
|
||||
Scope: newScope(c.universe(), PackageScope),
|
||||
Version: version,
|
||||
cfg: c,
|
||||
guard: guard,
|
||||
isUnsafe: importPath == "unsafe",
|
||||
typeCheck: typeCheck,
|
||||
}
|
||||
|
||||
defer func() { r.guard = nil }()
|
||||
|
||||
sort.Strings(matches)
|
||||
|
||||
defer func() {
|
||||
sort.Slice(r.GoFiles, func(i, j int) bool { return r.GoFiles[i].Name() < r.GoFiles[j].Name() })
|
||||
if err != nil || len(r.InvalidGoFiles) != 0 || typeCheck == TypeCheckNone {
|
||||
return
|
||||
}
|
||||
|
||||
//TODO err = r.check(newCtx(c))
|
||||
}()
|
||||
|
||||
c.parallel.throttle(func() {
|
||||
for _, path := range matches {
|
||||
if err = c.newPackageFile(r, path); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
})
|
||||
return r, err
|
||||
}
|
||||
|
||||
func (c *Config) newPackageFile(pkg *Package, path string) (err error) {
|
||||
f, err := c.open(path)
|
||||
if err != nil {
|
||||
return fmt.Errorf("opening file %q: %v", path, err)
|
||||
}
|
||||
|
||||
defer func() {
|
||||
f.Close()
|
||||
if err != nil {
|
||||
if pkg.InvalidGoFiles == nil {
|
||||
pkg.InvalidGoFiles = map[string]error{}
|
||||
}
|
||||
pkg.InvalidGoFiles[path] = err
|
||||
}
|
||||
}()
|
||||
|
||||
var fi fs.FileInfo
|
||||
if fi, err = f.Stat(); err != nil {
|
||||
return fmt.Errorf("stat %s: %v", path, err)
|
||||
}
|
||||
|
||||
if !fi.Mode().IsRegular() {
|
||||
return nil
|
||||
}
|
||||
|
||||
var b []byte
|
||||
if b, err = io.ReadAll(f); err != nil {
|
||||
return fmt.Errorf("reading %s: %v", path, err)
|
||||
}
|
||||
|
||||
p := newParser(pkg.Scope, path, b, false)
|
||||
if p.peek(0) == PACKAGE {
|
||||
tok := Token{p.s.source, p.s.toks[p.ix].ch, int32(p.ix)}
|
||||
if !c.checkConstraints(tok.Position(), tok.Sep()) {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
pkg.GoFiles = append(pkg.GoFiles, fi)
|
||||
var ast *AST
|
||||
if ast, err = p.parse(); err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
pkg.AST[path] = ast
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Package) matches(k *cacheKey, matches []string) bool {
|
||||
matched := map[string]struct{}{}
|
||||
for _, match := range matches {
|
||||
matched[match] = struct{}{}
|
||||
}
|
||||
for _, cachedInfo := range p.GoFiles {
|
||||
name := cachedInfo.Name()
|
||||
path := filepath.Join(p.FSPath, name)
|
||||
if _, ok := matched[path]; !ok {
|
||||
return false
|
||||
}
|
||||
|
||||
info, err := k.cfg.stat(path)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
if info.IsDir() ||
|
||||
info.Size() != cachedInfo.Size() ||
|
||||
info.ModTime().After(cachedInfo.ModTime()) ||
|
||||
info.Mode() != cachedInfo.Mode() {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// ParseFile parses 'b', assuming it comes from 'path' and returns an AST or error, if any.
|
||||
func ParseFile(path string, b []byte) (*AST, error) {
|
||||
return newParser(newScope(nil, PackageScope), path, b, false).parse()
|
||||
}
|
||||
9415
vendor/modernc.org/gc/v3/parser.go
generated
vendored
Normal file
9415
vendor/modernc.org/gc/v3/parser.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1446
vendor/modernc.org/gc/v3/scanner.go
generated
vendored
Normal file
1446
vendor/modernc.org/gc/v3/scanner.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
115
vendor/modernc.org/gc/v3/stringer.go
generated
vendored
Normal file
115
vendor/modernc.org/gc/v3/stringer.go
generated
vendored
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
// Code generated by "stringer -output stringer.go -linecomment -type=Kind,ScopeKind,ChanDir,TypeCheck"; DO NOT EDIT.
|
||||
|
||||
package gc
|
||||
|
||||
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[InvalidKind-0]
|
||||
_ = x[Array-1]
|
||||
_ = x[Bool-2]
|
||||
_ = x[Chan-3]
|
||||
_ = x[Complex128-4]
|
||||
_ = x[Complex64-5]
|
||||
_ = x[Float32-6]
|
||||
_ = x[Float64-7]
|
||||
_ = x[Function-8]
|
||||
_ = x[Int-9]
|
||||
_ = x[Int16-10]
|
||||
_ = x[Int32-11]
|
||||
_ = x[Int64-12]
|
||||
_ = x[Int8-13]
|
||||
_ = x[Interface-14]
|
||||
_ = x[Map-15]
|
||||
_ = x[Pointer-16]
|
||||
_ = x[Slice-17]
|
||||
_ = x[String-18]
|
||||
_ = x[Struct-19]
|
||||
_ = x[Tuple-20]
|
||||
_ = x[Uint-21]
|
||||
_ = x[Uint16-22]
|
||||
_ = x[Uint32-23]
|
||||
_ = x[Uint64-24]
|
||||
_ = x[Uint8-25]
|
||||
_ = x[Uintptr-26]
|
||||
_ = x[UnsafePointer-27]
|
||||
_ = x[UntypedBool-28]
|
||||
_ = x[UntypedComplex-29]
|
||||
_ = x[UntypedFloat-30]
|
||||
_ = x[UntypedInt-31]
|
||||
_ = x[UntypedNil-32]
|
||||
_ = x[UntypedRune-33]
|
||||
_ = x[UntypedString-34]
|
||||
}
|
||||
|
||||
const _Kind_name = "<invalid type>arrayboolchancomplex128complex64float32float64functionintint16int32int64int8interfacemappointerslicestringstructtupleuintuint16uint32uint64uint8uintptrunsafe.Pointeruntyped booluntyped complexuntyped floatuntyped intuntyped niluntyped runeuntyped string"
|
||||
|
||||
var _Kind_index = [...]uint16{0, 14, 19, 23, 27, 37, 46, 53, 60, 68, 71, 76, 81, 86, 90, 99, 102, 109, 114, 120, 126, 131, 135, 141, 147, 153, 158, 165, 179, 191, 206, 219, 230, 241, 253, 267}
|
||||
|
||||
func (i Kind) String() string {
|
||||
if i >= Kind(len(_Kind_index)-1) {
|
||||
return "Kind(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||
}
|
||||
return _Kind_name[_Kind_index[i]:_Kind_index[i+1]]
|
||||
}
|
||||
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[scZero-0]
|
||||
_ = x[UniverseScope-1]
|
||||
_ = x[PackageScope-2]
|
||||
_ = x[FileScope-3]
|
||||
_ = x[OtherScope-4]
|
||||
}
|
||||
|
||||
const _ScopeKind_name = "scZeroUniverseScopePackageScopeFileScopeOtherScope"
|
||||
|
||||
var _ScopeKind_index = [...]uint8{0, 6, 19, 31, 40, 50}
|
||||
|
||||
func (i ScopeKind) String() string {
|
||||
if i < 0 || i >= ScopeKind(len(_ScopeKind_index)-1) {
|
||||
return "ScopeKind(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||
}
|
||||
return _ScopeKind_name[_ScopeKind_index[i]:_ScopeKind_index[i+1]]
|
||||
}
|
||||
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[SendRecv-0]
|
||||
_ = x[SendOnly-1]
|
||||
_ = x[RecvOnly-2]
|
||||
}
|
||||
|
||||
const _ChanDir_name = "SendRecvSendOnlyRecvOnly"
|
||||
|
||||
var _ChanDir_index = [...]uint8{0, 8, 16, 24}
|
||||
|
||||
func (i ChanDir) String() string {
|
||||
if i < 0 || i >= ChanDir(len(_ChanDir_index)-1) {
|
||||
return "ChanDir(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||
}
|
||||
return _ChanDir_name[_ChanDir_index[i]:_ChanDir_index[i+1]]
|
||||
}
|
||||
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[TypeCheckNone-0]
|
||||
_ = x[TypeCheckAll-1]
|
||||
}
|
||||
|
||||
const _TypeCheck_name = "TypeCheckNoneTypeCheckAll"
|
||||
|
||||
var _TypeCheck_index = [...]uint8{0, 13, 25}
|
||||
|
||||
func (i TypeCheck) String() string {
|
||||
if i < 0 || i >= TypeCheck(len(_TypeCheck_index)-1) {
|
||||
return "TypeCheck(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||
}
|
||||
return _TypeCheck_name[_TypeCheck_index[i]:_TypeCheck_index[i+1]]
|
||||
}
|
||||
90
vendor/modernc.org/gc/v3/syslist.go
generated
vendored
Normal file
90
vendor/modernc.org/gc/v3/syslist.go
generated
vendored
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
// Copyright 2011 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the GO-LICENSE file.
|
||||
|
||||
// Modifications
|
||||
//
|
||||
// Copyright 2022 The Gc 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 build // /usr/local/go/src/go/build/syslist.go
|
||||
|
||||
package gc // import "modernc.org/gc/v3"
|
||||
|
||||
// Go 1.19.3
|
||||
|
||||
// Note that this file is read by internal/goarch/gengoarch.go and by
|
||||
// internal/goos/gengoos.go. If you change this file, look at those
|
||||
// files as well.
|
||||
|
||||
// knownOS is the list of past, present, and future known GOOS values.
|
||||
// Do not remove from this list, as it is used for filename matching.
|
||||
// If you add an entry to this list, look at unixOS, below.
|
||||
var knownOS = map[string]bool{
|
||||
"aix": true,
|
||||
"android": true,
|
||||
"darwin": true,
|
||||
"dragonfly": true,
|
||||
"freebsd": true,
|
||||
"hurd": true,
|
||||
"illumos": true,
|
||||
"ios": true,
|
||||
"js": true,
|
||||
"linux": true,
|
||||
"nacl": true,
|
||||
"netbsd": true,
|
||||
"openbsd": true,
|
||||
"plan9": true,
|
||||
"solaris": true,
|
||||
"windows": true,
|
||||
"zos": true,
|
||||
}
|
||||
|
||||
// unixOS is the set of GOOS values matched by the "unix" build tag.
|
||||
// This is not used for filename matching.
|
||||
// This list also appears in cmd/dist/build.go and
|
||||
// cmd/go/internal/imports/build.go.
|
||||
var unixOS = map[string]bool{
|
||||
"aix": true,
|
||||
"android": true,
|
||||
"darwin": true,
|
||||
"dragonfly": true,
|
||||
"freebsd": true,
|
||||
"hurd": true,
|
||||
"illumos": true,
|
||||
"ios": true,
|
||||
"linux": true,
|
||||
"netbsd": true,
|
||||
"openbsd": true,
|
||||
"solaris": true,
|
||||
}
|
||||
|
||||
// knownArch is the list of past, present, and future known GOARCH values.
|
||||
// Do not remove from this list, as it is used for filename matching.
|
||||
var knownArch = map[string]bool{
|
||||
"386": true,
|
||||
"amd64": true,
|
||||
"amd64p32": true,
|
||||
"arm": true,
|
||||
"armbe": true,
|
||||
"arm64": true,
|
||||
"arm64be": true,
|
||||
"loong64": true,
|
||||
"mips": true,
|
||||
"mipsle": true,
|
||||
"mips64": true,
|
||||
"mips64le": true,
|
||||
"mips64p32": true,
|
||||
"mips64p32le": true,
|
||||
"ppc": true,
|
||||
"ppc64": true,
|
||||
"ppc64le": true,
|
||||
"riscv": true,
|
||||
"riscv64": true,
|
||||
"s390": true,
|
||||
"s390x": true,
|
||||
"sparc": true,
|
||||
"sparc64": true,
|
||||
"wasm": true,
|
||||
}
|
||||
813
vendor/modernc.org/gc/v3/type.go
generated
vendored
Normal file
813
vendor/modernc.org/gc/v3/type.go
generated
vendored
Normal file
|
|
@ -0,0 +1,813 @@
|
|||
// Copyright 2022 The Gc 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 gc // modernc.org/gc/v3
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go/token"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
Invalid = &InvalidType{}
|
||||
)
|
||||
|
||||
var (
|
||||
_ Type = (*ArrayTypeNode)(nil)
|
||||
_ Type = (*ChannelTypeNode)(nil)
|
||||
_ Type = (*FunctionTypeNode)(nil)
|
||||
_ Type = (*InterfaceTypeNode)(nil)
|
||||
_ Type = (*InvalidType)(nil)
|
||||
_ Type = (*MapTypeNode)(nil)
|
||||
_ Type = (*ParenthesizedTypeNode)(nil)
|
||||
_ Type = (*PointerTypeNode)(nil)
|
||||
_ Type = (*PredeclaredType)(nil)
|
||||
_ Type = (*SliceTypeNode)(nil)
|
||||
_ Type = (*StructTypeNode)(nil)
|
||||
_ Type = (*TupleType)(nil)
|
||||
_ Type = (*TypeDefNode)(nil)
|
||||
_ Type = (*TypeNameNode)(nil)
|
||||
_ Type = (*TypeNode)(nil)
|
||||
|
||||
invalidRecursiveType = &InvalidType{}
|
||||
)
|
||||
|
||||
// A Kind represents the specific kind of type that a Type represents. The zero
|
||||
// Kind is not a valid kind.
|
||||
type Kind byte
|
||||
|
||||
// Values of type Kind
|
||||
const (
|
||||
InvalidKind Kind = iota // <invalid type>
|
||||
|
||||
Array // array
|
||||
Bool // bool
|
||||
Chan // chan
|
||||
Complex128 // complex128
|
||||
Complex64 // complex64
|
||||
Float32 // float32
|
||||
Float64 // float64
|
||||
Function // function
|
||||
Int // int
|
||||
Int16 // int16
|
||||
Int32 // int32
|
||||
Int64 // int64
|
||||
Int8 // int8
|
||||
Interface // interface
|
||||
Map // map
|
||||
Pointer // pointer
|
||||
Slice // slice
|
||||
String // string
|
||||
Struct // struct
|
||||
Tuple // tuple
|
||||
Uint // uint
|
||||
Uint16 // uint16
|
||||
Uint32 // uint32
|
||||
Uint64 // uint64
|
||||
Uint8 // uint8
|
||||
Uintptr // uintptr
|
||||
UnsafePointer // unsafe.Pointer
|
||||
UntypedBool // untyped bool
|
||||
UntypedComplex // untyped complex
|
||||
UntypedFloat // untyped float
|
||||
UntypedInt // untyped int
|
||||
UntypedNil // untyped nil
|
||||
UntypedRune // untyped rune
|
||||
UntypedString // untyped string
|
||||
)
|
||||
|
||||
type typeSetter interface {
|
||||
setType(t Type) Type
|
||||
}
|
||||
|
||||
type typeCache struct {
|
||||
t Type
|
||||
}
|
||||
|
||||
func (n *typeCache) Type() Type {
|
||||
if n.t != nil {
|
||||
return n.t
|
||||
}
|
||||
|
||||
n.t = Invalid
|
||||
return Invalid
|
||||
}
|
||||
|
||||
func (n *typeCache) setType(t Type) Type {
|
||||
n.t = t
|
||||
return t
|
||||
}
|
||||
|
||||
func (n *typeCache) enter(c *ctx, nd Node) bool {
|
||||
switch {
|
||||
case n.t == nil:
|
||||
n.t = invalidRecursiveType
|
||||
return true
|
||||
case n.t == invalidRecursiveType:
|
||||
n.t = Invalid
|
||||
c.err(nd, "invalid recursive type")
|
||||
return false
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
type typer interface {
|
||||
Type() Type
|
||||
}
|
||||
|
||||
type Type interface {
|
||||
Node
|
||||
|
||||
// Align returns the alignment in bytes of a value of this type when allocated
|
||||
// in memory.
|
||||
Align() int
|
||||
|
||||
// FieldAlign returns the alignment in bytes of a value of this type when used
|
||||
// as a field in a struct.
|
||||
FieldAlign() int
|
||||
|
||||
// Kind returns the specific kind of this type.
|
||||
Kind() Kind
|
||||
|
||||
// Size returns the number of bytes needed to store a value of the given type;
|
||||
// it is analogous to unsafe.Sizeof.
|
||||
Size() int64
|
||||
|
||||
// String returns a string representation of the type. The string
|
||||
// representation is not guaranteed to be unique among types.
|
||||
String() string
|
||||
|
||||
check(c *ctx) Type
|
||||
}
|
||||
|
||||
func (n *ArrayTypeNode) Align() int { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *ArrayTypeNode) FieldAlign() int { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *ArrayTypeNode) Kind() Kind { return Array }
|
||||
func (n *ArrayTypeNode) Size() int64 { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *ArrayTypeNode) String() string {
|
||||
return fmt.Sprintf("[%v]%v", n.ArrayLength.Value(), n.ElementType)
|
||||
}
|
||||
|
||||
func (n *ArrayTypeNode) check(c *ctx) Type {
|
||||
if n == nil {
|
||||
return Invalid
|
||||
}
|
||||
|
||||
n.ArrayLength = n.ArrayLength.checkExpr(c)
|
||||
v := c.convertValue(n.ArrayLength, n.ArrayLength.Value(), c.cfg.int)
|
||||
if !known(v) {
|
||||
return Invalid
|
||||
}
|
||||
|
||||
n.ElementType.check(c)
|
||||
return n
|
||||
}
|
||||
|
||||
// ChanDir represents a channel direction.
|
||||
type ChanDir int
|
||||
|
||||
// Values of type ChanDir.
|
||||
const (
|
||||
SendRecv ChanDir = iota
|
||||
SendOnly
|
||||
RecvOnly
|
||||
)
|
||||
|
||||
func (n *ChannelTypeNode) Align() int { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
|
||||
func (n *ChannelTypeNode) FieldAlign() int {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *ChannelTypeNode) Kind() Kind { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *ChannelTypeNode) Size() int64 { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *ChannelTypeNode) String() string { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *ChannelTypeNode) check(c *ctx) Type {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *FunctionTypeNode) Align() int { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
|
||||
func (n *FunctionTypeNode) FieldAlign() int {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *FunctionTypeNode) Kind() Kind { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *FunctionTypeNode) Size() int64 { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *FunctionTypeNode) String() string {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
func (n *FunctionTypeNode) check(c *ctx) Type {
|
||||
if !n.enter(c, n) {
|
||||
if n.guard == guardChecking {
|
||||
return Invalid
|
||||
}
|
||||
|
||||
return n
|
||||
}
|
||||
|
||||
defer func() { n.guard = guardChecked }()
|
||||
|
||||
n.Signature.check(c)
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *InterfaceTypeNode) Align() int { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
|
||||
func (n *InterfaceTypeNode) FieldAlign() int {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *InterfaceTypeNode) Kind() Kind { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *InterfaceTypeNode) Size() int64 { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *InterfaceTypeNode) String() string {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
func (n *InterfaceTypeNode) check(c *ctx) Type {
|
||||
if !n.enter(c, n) {
|
||||
if n.guard == guardChecking {
|
||||
return Invalid
|
||||
}
|
||||
|
||||
return n
|
||||
}
|
||||
|
||||
defer func() { n.guard = guardChecked }()
|
||||
|
||||
n.InterfaceElemList.check(c, n)
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *InterfaceElemListNode) check(c *ctx, t *InterfaceTypeNode) {
|
||||
if n == nil {
|
||||
return
|
||||
}
|
||||
|
||||
for l := n; l != nil; l = l.List {
|
||||
l.InterfaceElem.check(c, t)
|
||||
}
|
||||
}
|
||||
|
||||
func (n *InterfaceElemNode) check(c *ctx, t *InterfaceTypeNode) {
|
||||
if n == nil {
|
||||
return
|
||||
}
|
||||
|
||||
n.MethodElem.check(c, t)
|
||||
n.TypeElem.check(c)
|
||||
}
|
||||
|
||||
func (n *MethodElemNode) check(c *ctx, t *InterfaceTypeNode) {
|
||||
if n == nil {
|
||||
return
|
||||
}
|
||||
|
||||
nm := n.MethodName.Src()
|
||||
if ex := t.methods[nm]; ex != nil {
|
||||
panic(todo(""))
|
||||
}
|
||||
|
||||
if t.methods == nil {
|
||||
t.methods = map[string]*MethodElemNode{}
|
||||
}
|
||||
t.methods[nm] = n
|
||||
n.typ = n.Signature.check(c)
|
||||
}
|
||||
|
||||
func (n *TypeElemListNode) check(c *ctx) {
|
||||
if n == nil {
|
||||
return
|
||||
}
|
||||
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
type InvalidType struct{}
|
||||
|
||||
func (n *InvalidType) Align() int { return 1 }
|
||||
func (n *InvalidType) FieldAlign() int { return 1 }
|
||||
func (n *InvalidType) Kind() Kind { return InvalidKind }
|
||||
func (n *InvalidType) Position() (r token.Position) { return r }
|
||||
func (n *InvalidType) Size() int64 { return 1 }
|
||||
func (n *InvalidType) Source(full bool) string { return "<invalid type>" }
|
||||
func (n *InvalidType) String() string { return "<invalid type>" }
|
||||
func (n *InvalidType) check(c *ctx) Type { return n }
|
||||
|
||||
func (n *MapTypeNode) Align() int { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *MapTypeNode) FieldAlign() int { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *MapTypeNode) Kind() Kind { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *MapTypeNode) Size() int64 { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *MapTypeNode) String() string { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *MapTypeNode) check(c *ctx) Type { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
|
||||
func (n *ParenthesizedTypeNode) Align() int {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *ParenthesizedTypeNode) FieldAlign() int {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *ParenthesizedTypeNode) Kind() Kind {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *ParenthesizedTypeNode) Size() int64 {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *ParenthesizedTypeNode) String() string {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *ParenthesizedTypeNode) check(c *ctx) Type {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *PointerTypeNode) Align() int { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
|
||||
func (n *PointerTypeNode) FieldAlign() int {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *PointerTypeNode) Kind() Kind { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *PointerTypeNode) Size() int64 { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *PointerTypeNode) String() string { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
|
||||
func (n *PointerTypeNode) check(c *ctx) Type {
|
||||
if !n.enter(c, n) {
|
||||
if n.guard == guardChecking {
|
||||
return Invalid
|
||||
}
|
||||
|
||||
return n
|
||||
}
|
||||
|
||||
defer func() { n.guard = guardChecked }()
|
||||
|
||||
switch x := n.BaseType.(type) {
|
||||
case *TypeNameNode:
|
||||
x.checkDefined(c)
|
||||
default:
|
||||
panic(todo("%v: %T %s", n.Position(), x, n.Source(false)))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
type PredeclaredType struct {
|
||||
Node
|
||||
kind Kind
|
||||
t ABIType
|
||||
}
|
||||
|
||||
func (c *ctx) newPredeclaredType(n Node, kind Kind) *PredeclaredType {
|
||||
t, ok := c.cfg.abi.Types[kind]
|
||||
if !ok && !isAnyUntypedKind(kind) {
|
||||
panic(todo("%v: internal error %s: %s", n.Position(), n.Source(false), kind))
|
||||
}
|
||||
|
||||
return &PredeclaredType{
|
||||
Node: n,
|
||||
kind: kind,
|
||||
t: t,
|
||||
}
|
||||
}
|
||||
|
||||
func (n *PredeclaredType) Align() int { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
|
||||
func (n *PredeclaredType) FieldAlign() int {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *PredeclaredType) Kind() Kind { return n.kind }
|
||||
func (n *PredeclaredType) Size() int64 { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
|
||||
func (n *PredeclaredType) String() string {
|
||||
switch n.Kind() {
|
||||
case
|
||||
String,
|
||||
UntypedInt:
|
||||
|
||||
return n.Kind().String()
|
||||
default:
|
||||
panic(todo("%v: %s %s", n.Position(), n.Kind(), n.Source(false)))
|
||||
}
|
||||
}
|
||||
|
||||
func (n *PredeclaredType) check(c *ctx) Type {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *SliceTypeNode) Align() int { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *SliceTypeNode) FieldAlign() int { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *SliceTypeNode) Kind() Kind { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *SliceTypeNode) Size() int64 { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *SliceTypeNode) String() string { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
|
||||
func (n *SliceTypeNode) check(c *ctx) Type {
|
||||
if !n.enter(c, n) {
|
||||
if n.guard == guardChecking {
|
||||
return Invalid
|
||||
}
|
||||
|
||||
return n
|
||||
}
|
||||
|
||||
defer func() { n.guard = guardChecked }()
|
||||
|
||||
switch x := n.ElementType.(type) {
|
||||
case *TypeNameNode:
|
||||
x.checkDefined(c)
|
||||
default:
|
||||
panic(todo("%v: %T %s", n.Position(), x, n.Source(false)))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
type Field struct {
|
||||
Declaration *FieldDeclNode
|
||||
Name string
|
||||
}
|
||||
|
||||
func (n *StructTypeNode) Align() int { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *StructTypeNode) FieldAlign() int { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *StructTypeNode) Kind() Kind { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *StructTypeNode) Size() int64 { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *StructTypeNode) String() string { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
|
||||
func (n *StructTypeNode) check(c *ctx) Type {
|
||||
if !n.enter(c, n) {
|
||||
if n.guard == guardChecking {
|
||||
return Invalid
|
||||
}
|
||||
|
||||
return n
|
||||
}
|
||||
|
||||
defer func() { n.guard = guardChecked }()
|
||||
|
||||
for l := n.FieldDeclList; l != nil; l = l.List {
|
||||
n.fields = append(n.fields, l.check(c)...)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *FieldDeclListNode) check(c *ctx) []Field {
|
||||
return n.FieldDecl.check(c)
|
||||
}
|
||||
|
||||
func (n *FieldDeclNode) check(c *ctx) (r []Field) {
|
||||
switch {
|
||||
case n.EmbeddedField != nil:
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
default:
|
||||
n.TypeNode.check(c)
|
||||
for l := n.IdentifierList; l != nil; l = l.List {
|
||||
r = append(r, Field{n, l.IDENT.Src()})
|
||||
}
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
type TupleType struct {
|
||||
Node
|
||||
Types []Type
|
||||
}
|
||||
|
||||
func newTupleType(n Node, types []Type) *TupleType { return &TupleType{n, types} }
|
||||
|
||||
func (n *TupleType) Align() int { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *TupleType) FieldAlign() int { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *TupleType) Kind() Kind { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
|
||||
func (n *TupleType) Size() int64 { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
|
||||
func (n *TupleType) Source(full bool) (r string) {
|
||||
if n.Node != nil {
|
||||
r = n.Node.Source(full)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func (n *TupleType) String() string {
|
||||
var a []string
|
||||
for _, v := range n.Types {
|
||||
a = append(a, v.String())
|
||||
}
|
||||
return fmt.Sprintf("(%s)", strings.Join(a, ", "))
|
||||
}
|
||||
|
||||
func (n *TupleType) check(c *ctx) Type {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *TypeDefNode) Align() int { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *TypeDefNode) FieldAlign() int { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *TypeDefNode) Kind() Kind { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *TypeDefNode) Size() int64 { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *TypeDefNode) String() string { return fmt.Sprintf("%s.%s", n.pkg.ImportPath, n.IDENT.Src()) }
|
||||
|
||||
func (n *TypeDefNode) check(c *ctx) Type {
|
||||
if n == nil {
|
||||
return Invalid
|
||||
}
|
||||
|
||||
if n.pkg != nil {
|
||||
return n
|
||||
}
|
||||
|
||||
n.pkg = c.pkg
|
||||
if n.TypeParameters != nil {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
switch x := n.TypeNode.check(c).(type) {
|
||||
case *PredeclaredType:
|
||||
n.TypeNode = x
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *TypeNameNode) Align() int { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *TypeNameNode) FieldAlign() int { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *TypeNameNode) Kind() Kind { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *TypeNameNode) Size() int64 { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *TypeNameNode) String() string { return n.Name.Source(false) }
|
||||
|
||||
func (n *TypeNameNode) checkDefined(c *ctx) bool {
|
||||
switch x := n.Name.(type) {
|
||||
case Token:
|
||||
switch _, nmd := n.LexicalScope().lookup(x); y := nmd.n.(type) {
|
||||
case *TypeDefNode, *AliasDeclNode:
|
||||
return true
|
||||
default:
|
||||
panic(todo("%v: type=%T %s", y.Position(), y, y.Source(false)))
|
||||
}
|
||||
case *QualifiedIdentNode:
|
||||
if !token.IsExported(x.IDENT.Src()) {
|
||||
panic(todo(""))
|
||||
}
|
||||
|
||||
switch _, nmd := n.LexicalScope().lookup(x.PackageName); y := nmd.n.(type) {
|
||||
case *ImportSpecNode:
|
||||
if y.pkg == nil {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
switch _, nmd := y.pkg.Scope.lookup(x.IDENT); z := nmd.n.(type) {
|
||||
case *TypeDefNode, *AliasDeclNode:
|
||||
return true
|
||||
default:
|
||||
panic(todo("%v: type=%T %s", z.Position(), z, z.Source(false)))
|
||||
}
|
||||
default:
|
||||
panic(todo("%v: type=%T %s", y.Position(), y, y.Source(false)))
|
||||
}
|
||||
default:
|
||||
panic(todo("%v: type=%T %s", n.Position(), x, n.Source(false)))
|
||||
}
|
||||
}
|
||||
|
||||
func (n *TypeNameNode) check(c *ctx) Type {
|
||||
if n == nil {
|
||||
return Invalid
|
||||
}
|
||||
|
||||
switch x := n.Name.(type) {
|
||||
case Token:
|
||||
nm := x.Src()
|
||||
if c.isBuiltin() {
|
||||
switch nm {
|
||||
case "bool":
|
||||
return c.newPredeclaredType(n, Bool)
|
||||
case "uint8":
|
||||
return c.newPredeclaredType(n, Uint8)
|
||||
case "uint16":
|
||||
return c.newPredeclaredType(n, Uint16)
|
||||
case "uint32":
|
||||
return c.newPredeclaredType(n, Uint32)
|
||||
case "uint64":
|
||||
return c.newPredeclaredType(n, Uint64)
|
||||
case "int8":
|
||||
return c.newPredeclaredType(n, Int8)
|
||||
case "int16":
|
||||
return c.newPredeclaredType(n, Int16)
|
||||
case "int32":
|
||||
return c.newPredeclaredType(n, Int32)
|
||||
case "int64":
|
||||
return c.newPredeclaredType(n, Int64)
|
||||
case "float32":
|
||||
return c.newPredeclaredType(n, Float32)
|
||||
case "float64":
|
||||
return c.newPredeclaredType(n, Float64)
|
||||
case "complex64":
|
||||
return c.newPredeclaredType(n, Complex64)
|
||||
case "complex128":
|
||||
return c.newPredeclaredType(n, Complex128)
|
||||
case "string":
|
||||
return c.newPredeclaredType(n, String)
|
||||
case "int":
|
||||
return c.newPredeclaredType(n, Int)
|
||||
case "uint":
|
||||
return c.newPredeclaredType(n, Uint)
|
||||
case "uintptr":
|
||||
return c.newPredeclaredType(n, Uintptr)
|
||||
case "Type":
|
||||
// ok
|
||||
default:
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
}
|
||||
|
||||
pkg, _, nmd := c.lookup(n.LexicalScope(), x)
|
||||
switch y := nmd.n.(type) {
|
||||
case *TypeDefNode:
|
||||
if pkg != c.pkg {
|
||||
return y
|
||||
}
|
||||
|
||||
return y.check(c)
|
||||
case nil:
|
||||
panic(todo("%v: %T %s", x.Position(), y, x.Source(false)))
|
||||
default:
|
||||
panic(todo("%v: %T %s", y.Position(), y, y.Source(false)))
|
||||
}
|
||||
default:
|
||||
panic(todo("%v: %T %s", n.Position(), x, n.Source(false)))
|
||||
}
|
||||
}
|
||||
|
||||
func (n *TypeNode) Align() int { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *TypeNode) FieldAlign() int { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *TypeNode) Kind() Kind { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *TypeNode) Size() int64 { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *TypeNode) String() string { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
func (n *TypeNode) check(c *ctx) Type { panic(todo("%v: %T %s", n.Position(), n, n.Source(false))) }
|
||||
|
||||
func isAnyUntypedType(t Type) bool { return isAnyUntypedKind(t.Kind()) }
|
||||
|
||||
func isAnyUntypedKind(k Kind) bool {
|
||||
switch k {
|
||||
case UntypedBool, UntypedComplex, UntypedFloat, UntypedInt, UntypedNil, UntypedRune, UntypedString:
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
const (
|
||||
guardUnchecked guard = iota
|
||||
guardChecking
|
||||
guardChecked
|
||||
)
|
||||
|
||||
type guard byte
|
||||
|
||||
func (n *guard) enter(c *ctx, nd Node) bool {
|
||||
switch *n {
|
||||
case guardUnchecked:
|
||||
*n = guardChecking
|
||||
return true
|
||||
case guardChecking:
|
||||
c.err(nd, "invalid recursive type")
|
||||
return false
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func isAnyArithmeticType(t Type) bool { return isArithmeticType(t) || isUntypedArithmeticType(t) }
|
||||
|
||||
func isUntypedArithmeticType(t Type) bool {
|
||||
switch t.Kind() {
|
||||
case UntypedInt, UntypedFloat, UntypedComplex:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func isArithmeticType(t Type) bool {
|
||||
return isIntegerType(t) || isFloatType(t) || isComplexType(t)
|
||||
}
|
||||
|
||||
func isComplexType(t Type) bool {
|
||||
switch t.Kind() {
|
||||
case Complex64, Complex128:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func isFloatType(t Type) bool {
|
||||
switch t.Kind() {
|
||||
case Float32, Float64:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func isIntegerType(t Type) bool {
|
||||
switch t.Kind() {
|
||||
case Int, Int8, Int16, Int32, Int64, Uint, Uint8, Uint16, Uint32, Uint64, Uintptr:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ctx) isIdentical(n Node, t, u Type) bool {
|
||||
tk := t.Kind()
|
||||
uk := u.Kind()
|
||||
if tk != uk {
|
||||
return false
|
||||
}
|
||||
|
||||
if t == u {
|
||||
return true
|
||||
}
|
||||
|
||||
if isAnyUntypedKind(tk) && isAnyUntypedKind(uk) && tk == uk {
|
||||
return true
|
||||
}
|
||||
|
||||
switch x := t.(type) {
|
||||
// case *ArrayTypeNode:
|
||||
// switch y := u.(type) {
|
||||
// case *ArrayTypeNode:
|
||||
// return x.Len == y.Len && c.isIdentical(n, x.Elem, y.Elem)
|
||||
// }
|
||||
// case *StructType:
|
||||
// switch y := u.(type) {
|
||||
// case *StructType:
|
||||
// if len(x.Fields) != len(y.Fields) {
|
||||
// return false
|
||||
// }
|
||||
|
||||
// for i, v := range x.Fields {
|
||||
// w := y.Fields[i]
|
||||
// if v.Name != w.Name || !c.isIdentical(n, v.Type(), w.Type()) {
|
||||
// return false
|
||||
// }
|
||||
// }
|
||||
|
||||
// return true
|
||||
// }
|
||||
// case *FunctionType:
|
||||
// switch y := u.(type) {
|
||||
// case *FunctionType:
|
||||
// in, out := x.Parameters.Types, x.Result.Types
|
||||
// in2, out2 := y.Parameters.Types, y.Result.Types
|
||||
// if len(in) != len(in2) || len(out) != len(out2) {
|
||||
// return false
|
||||
// }
|
||||
|
||||
// for i, v := range in {
|
||||
// if !c.isIdentical(n, v, in2[i]) {
|
||||
// return false
|
||||
// }
|
||||
// }
|
||||
|
||||
// for i, v := range out {
|
||||
// if !c.isIdentical(n, v, out2[i]) {
|
||||
// return false
|
||||
// }
|
||||
// }
|
||||
|
||||
// return true
|
||||
// }
|
||||
// case *PointerType:
|
||||
// switch y := u.(type) {
|
||||
// case *PointerType:
|
||||
// return c.isIdentical(n, x.Elem, y.Elem)
|
||||
// }
|
||||
default:
|
||||
c.err(n, "TODO %v %v", x, u)
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (c *ctx) mustIdentical(n Node, t, u Type) bool {
|
||||
if !c.isIdentical(n, t, u) {
|
||||
c.err(n, "incompatible types: %v and %v", t, u)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (c *ctx) checkType(n Node) Type {
|
||||
switch x := n.(type) {
|
||||
case *ArrayTypeNode:
|
||||
return x.check(c)
|
||||
default:
|
||||
c.err(n, "TODO %T", x)
|
||||
return Invalid
|
||||
}
|
||||
}
|
||||
716
vendor/modernc.org/gc/v3/value.go
generated
vendored
Normal file
716
vendor/modernc.org/gc/v3/value.go
generated
vendored
Normal file
|
|
@ -0,0 +1,716 @@
|
|||
// Copyright 2022 The Gc 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 gc // modernc.org/gc/v3
|
||||
|
||||
import (
|
||||
"go/constant"
|
||||
"math"
|
||||
)
|
||||
|
||||
var (
|
||||
_ Expression = (*BasicLitNode)(nil)
|
||||
_ Expression = (*BinaryExpressionNode)(nil)
|
||||
_ Expression = (*CompositeLitNode)(nil)
|
||||
_ Expression = (*ConversionNode)(nil)
|
||||
_ Expression = (*FunctionLitNode)(nil)
|
||||
_ Expression = (*KeyedElementNode)(nil)
|
||||
_ Expression = (*LiteralValueNode)(nil)
|
||||
_ Expression = (*MethodExprNode)(nil)
|
||||
_ Expression = (*OperandNameNode)(nil)
|
||||
_ Expression = (*OperandNode)(nil)
|
||||
_ Expression = (*OperandQualifiedNameNode)(nil)
|
||||
_ Expression = (*ParenthesizedExpressionNode)(nil)
|
||||
_ Expression = (*PrimaryExprNode)(nil)
|
||||
_ Expression = (*UnaryExprNode)(nil)
|
||||
_ Expression = (*ValueExpression)(nil)
|
||||
|
||||
falseVal = constant.MakeBool(false)
|
||||
trueVal = constant.MakeBool(true)
|
||||
unknown = constant.MakeUnknown()
|
||||
)
|
||||
|
||||
func known(v constant.Value) bool { return v != nil && v.Kind() != constant.Unknown }
|
||||
|
||||
type valueCache struct {
|
||||
v constant.Value
|
||||
}
|
||||
|
||||
func (n *valueCache) Value() constant.Value {
|
||||
if n.v != nil {
|
||||
return n.v
|
||||
}
|
||||
|
||||
return unknown
|
||||
}
|
||||
|
||||
func (n *valueCache) setValue(v constant.Value) constant.Value {
|
||||
n.v = v
|
||||
return v
|
||||
}
|
||||
|
||||
type valuer interface {
|
||||
Value() constant.Value
|
||||
}
|
||||
|
||||
type Expression interface {
|
||||
Node
|
||||
checkExpr(c *ctx) Expression
|
||||
clone() Expression
|
||||
typer
|
||||
valuer
|
||||
}
|
||||
|
||||
type ValueExpression struct {
|
||||
Node
|
||||
typeCache
|
||||
valueCache
|
||||
}
|
||||
|
||||
func (n *ValueExpression) checkExpr(c *ctx) Expression {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *ValueExpression) clone() Expression {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *BasicLitNode) Type() Type {
|
||||
switch n.Ch() {
|
||||
case CHAR:
|
||||
return n.ctx.int32
|
||||
case INT:
|
||||
return n.ctx.untypedInt
|
||||
case FLOAT:
|
||||
return n.ctx.untypedFloat
|
||||
case STRING:
|
||||
return n.ctx.untypedString
|
||||
default:
|
||||
panic(todo("%v: %T %s %v", n.Position(), n, n.Source(false), n.Ch()))
|
||||
}
|
||||
}
|
||||
|
||||
func (n *BasicLitNode) Value() constant.Value {
|
||||
return constant.MakeFromLiteral(n.Src(), n.Ch(), 0)
|
||||
}
|
||||
|
||||
func (n *BasicLitNode) checkExpr(c *ctx) Expression {
|
||||
n.ctx = c
|
||||
if !known(n.Value()) {
|
||||
c.err(n, "invalid literal: %s", n.Source(false))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *BasicLitNode) clone() Expression {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *OperandNameNode) Type() Type {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *OperandNameNode) Value() constant.Value {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *OperandNameNode) checkExpr(c *ctx) Expression {
|
||||
in, named := n.LexicalScope().lookup(n.Name)
|
||||
switch x := named.n.(type) {
|
||||
case *ConstSpecNode:
|
||||
switch in.kind {
|
||||
case UniverseScope:
|
||||
switch n.Name.Src() {
|
||||
case "iota":
|
||||
if c.iota < 0 {
|
||||
panic(todo("%v: %T %s", n.Position(), x, n.Source(false)))
|
||||
}
|
||||
|
||||
r := &ValueExpression{Node: x}
|
||||
r.t = c.untypedInt
|
||||
r.v = constant.MakeInt64(c.iota)
|
||||
return r
|
||||
default:
|
||||
panic(todo("%v: %T %s", n.Position(), x, n.Source(false)))
|
||||
}
|
||||
default:
|
||||
return x.Expression
|
||||
}
|
||||
default:
|
||||
panic(todo("%v: %T %s", n.Position(), x, n.Source(false)))
|
||||
}
|
||||
}
|
||||
|
||||
func (n *OperandNameNode) clone() Expression {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *ParenthesizedExpressionNode) Type() Type {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *ParenthesizedExpressionNode) Value() constant.Value {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *ParenthesizedExpressionNode) checkExpr(c *ctx) Expression {
|
||||
return n.Expression.checkExpr(c)
|
||||
}
|
||||
|
||||
func (n *ParenthesizedExpressionNode) clone() Expression {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *LiteralValueNode) Type() Type {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *LiteralValueNode) Value() constant.Value {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *LiteralValueNode) checkExpr(c *ctx) Expression {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *LiteralValueNode) clone() Expression {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *KeyedElementNode) Type() Type {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *KeyedElementNode) Value() constant.Value {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *KeyedElementNode) checkExpr(c *ctx) Expression {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *KeyedElementNode) clone() Expression {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *CompositeLitNode) Type() Type {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *CompositeLitNode) Value() constant.Value {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *CompositeLitNode) checkExpr(c *ctx) Expression {
|
||||
if n == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if !n.enter(c, n) {
|
||||
return n
|
||||
}
|
||||
|
||||
t := n.setType(c.checkType(n.LiteralType))
|
||||
n.LiteralValue.check(c, t)
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *CompositeLitNode) clone() Expression {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *LiteralValueNode) check(c *ctx, t Type) {
|
||||
if n == nil {
|
||||
return
|
||||
}
|
||||
|
||||
switch t.Kind() {
|
||||
case Array:
|
||||
n.checkArray(c, t.(*ArrayTypeNode))
|
||||
default:
|
||||
panic(todo("%v: %T %s %v", n.Position(), n, n.Source(false), t.Kind()))
|
||||
}
|
||||
}
|
||||
|
||||
func (n *LiteralValueNode) checkArray(c *ctx, t *ArrayTypeNode) {
|
||||
panic(todo("%v: %T %s %s", n.Position(), n, t, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *FunctionLitNode) Type() Type {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *FunctionLitNode) Value() constant.Value {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *FunctionLitNode) checkExpr(c *ctx) Expression {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *FunctionLitNode) clone() Expression {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *OperandNode) Type() Type {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *OperandNode) Value() constant.Value {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *OperandNode) checkExpr(c *ctx) Expression {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *OperandNode) clone() Expression {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *OperandQualifiedNameNode) Type() Type {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *OperandQualifiedNameNode) Value() constant.Value {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *OperandQualifiedNameNode) checkExpr(c *ctx) Expression {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *OperandQualifiedNameNode) clone() Expression {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *ConversionNode) Type() Type {
|
||||
return n.TypeNode
|
||||
}
|
||||
|
||||
func (n *ConversionNode) checkExpr(c *ctx) Expression {
|
||||
t := n.TypeNode.check(c)
|
||||
n.Expression = n.Expression.checkExpr(c)
|
||||
v := n.Expression.Value()
|
||||
n.v = c.convertValue(n.Expression, v, t)
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *ConversionNode) clone() Expression {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *MethodExprNode) Type() Type {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *MethodExprNode) Value() constant.Value {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *MethodExprNode) checkExpr(c *ctx) Expression {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *MethodExprNode) clone() Expression {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *PrimaryExprNode) Type() Type {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *PrimaryExprNode) Value() constant.Value {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *PrimaryExprNode) checkExpr(c *ctx) Expression {
|
||||
switch x := n.PrimaryExpr.(type) {
|
||||
case *OperandNameNode:
|
||||
_, named := x.LexicalScope().lookup(x.Name)
|
||||
switch y := named.n.(type) {
|
||||
case *TypeDefNode:
|
||||
switch z := n.Postfix.(type) {
|
||||
case *ArgumentsNode:
|
||||
cnv := &ConversionNode{
|
||||
TypeNode: &TypeNameNode{
|
||||
Name: x.Name,
|
||||
lexicalScoper: x.lexicalScoper,
|
||||
},
|
||||
LPAREN: z.LPAREN,
|
||||
Expression: z.Expression,
|
||||
RPAREN: z.RPAREN,
|
||||
}
|
||||
return cnv.checkExpr(c)
|
||||
default:
|
||||
panic(todo("%v: %T %s", n.Position(), z, n.Source(false)))
|
||||
}
|
||||
default:
|
||||
panic(todo("%v: %T %s", n.Position(), y, n.Source(false)))
|
||||
}
|
||||
default:
|
||||
panic(todo("%v: %T %s", n.Position(), x, n.Source(false)))
|
||||
}
|
||||
|
||||
n.PrimaryExpr = n.PrimaryExpr.checkExpr(c)
|
||||
switch x := n.Postfix.(type) {
|
||||
default:
|
||||
panic(todo("%v: %T %s", n.Position(), x, n.Source(false)))
|
||||
}
|
||||
}
|
||||
|
||||
func (n *PrimaryExprNode) clone() Expression {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *BinaryExpressionNode) checkExpr(c *ctx) (r Expression) {
|
||||
if n == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if n.typeCache.Type() != Invalid {
|
||||
return n
|
||||
}
|
||||
|
||||
n.LHS = n.LHS.checkExpr(c)
|
||||
n.RHS = n.RHS.checkExpr(c)
|
||||
lv := n.LHS.Value()
|
||||
lt := n.LHS.Type()
|
||||
rv := n.RHS.Value()
|
||||
rt := n.RHS.Type()
|
||||
|
||||
defer func() {
|
||||
if known(lv) && known(rv) && r != nil && !known(r.Value()) {
|
||||
c.err(n.Op, "operation value not determined: %v %s %v", lv, n.Op.Src(), rv)
|
||||
}
|
||||
}()
|
||||
|
||||
switch n.Op.Ch() {
|
||||
case SHL, SHR:
|
||||
var u uint64
|
||||
var uOk bool
|
||||
n.t = lt
|
||||
// The right operand in a shift expression must have integer type or be an
|
||||
// untyped constant representable by a value of type uint.
|
||||
switch {
|
||||
case isIntegerType(rt):
|
||||
// ok
|
||||
case known(rv):
|
||||
if isAnyArithmeticType(rt) {
|
||||
rv = c.convertValue(n.RHS, rv, c.cfg.uint)
|
||||
if known(rv) {
|
||||
u, uOk = constant.Uint64Val(rv)
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
c.err(n.Op, "TODO %v", n.Op.Src())
|
||||
return n
|
||||
default:
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
return n
|
||||
}
|
||||
|
||||
// If the left operand of a non-constant shift expression is an untyped
|
||||
// constant, it is first implicitly converted to the type it would assume if
|
||||
// the shift expression were replaced by its left operand alone.
|
||||
switch {
|
||||
case known(lv) && !known(rv):
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
// c.err(n.Op, "TODO %v", n.Op.Ch.str())
|
||||
// return n
|
||||
case known(lv) && known(rv):
|
||||
if !uOk {
|
||||
panic(todo(""))
|
||||
}
|
||||
|
||||
n.t = lt
|
||||
n.v = constant.Shift(lv, n.Op.Ch(), uint(u))
|
||||
default:
|
||||
trc("", known(lv), known(rv), u, uOk)
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
// n.t = lt
|
||||
// n.v = constant.BinaryOp(lv, n.Op.Ch(), rv)
|
||||
}
|
||||
case ADD, SUB, MUL, QUO, REM:
|
||||
if !isAnyArithmeticType(lt) || !isAnyArithmeticType(rt) {
|
||||
c.err(n.Op, "TODO %v %v", lt, rt)
|
||||
break
|
||||
}
|
||||
|
||||
// For other binary operators, the operand types must be identical unless the
|
||||
// operation involves shifts or untyped constants.
|
||||
//
|
||||
// Except for shift operations, if one operand is an untyped constant and the
|
||||
// other operand is not, the constant is implicitly converted to the type of
|
||||
// the other operand.
|
||||
switch {
|
||||
case isAnyUntypedType(lt) && isAnyUntypedType(rt):
|
||||
n.v = constant.BinaryOp(lv, n.Op.Ch(), rv)
|
||||
switch n.v.Kind() {
|
||||
case constant.Int:
|
||||
n.t = c.untypedInt
|
||||
case constant.Float:
|
||||
n.t = c.untypedFloat
|
||||
default:
|
||||
c.err(n.Op, "TODO %v %v %q %v %v -> %v %v", lv, lt, n.Op.Src(), rv, rt, n.v, n.v.Kind())
|
||||
}
|
||||
case isAnyUntypedType(lt) && !isAnyUntypedType(rt):
|
||||
c.err(n.Op, "TODO %v %v %q %v %v", lv, lt, n.Op.Src(), rv, rt)
|
||||
case !isAnyUntypedType(lt) && isAnyUntypedType(rt):
|
||||
c.err(n.Op, "TODO %v %v %q %v %v", lv, lt, n.Op.Src(), rv, rt)
|
||||
default: // case !isAnyUntypedType(lt) && !isAnyUntypedType(rt):
|
||||
c.err(n.Op, "TODO %v %v %q %v %v", lv, lt, n.Op.Src(), rv, rt)
|
||||
}
|
||||
default:
|
||||
c.err(n.Op, "TODO %v %v %q %v %v", lv, lt, n.Op.Src(), rv, rt)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *BinaryExpressionNode) clone() Expression {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (n *UnaryExprNode) checkExpr(c *ctx) Expression {
|
||||
if n == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if n.typeCache.Type() != Invalid {
|
||||
return n
|
||||
}
|
||||
|
||||
n.UnaryExpr = n.UnaryExpr.checkExpr(c)
|
||||
v := n.UnaryExpr.Value()
|
||||
t := n.UnaryExpr.Type()
|
||||
switch n.Op.Ch() {
|
||||
default:
|
||||
trc("", v, t)
|
||||
panic(todo("%v: %T %s", n.Op.Position(), n, n.Source(false)))
|
||||
}
|
||||
}
|
||||
|
||||
func (n *UnaryExprNode) clone() Expression {
|
||||
panic(todo("%v: %T %s", n.Position(), n, n.Source(false)))
|
||||
}
|
||||
|
||||
func (c *ctx) convertValue(n Node, v constant.Value, to Type) (r constant.Value) {
|
||||
if !known(v) {
|
||||
return unknown
|
||||
}
|
||||
|
||||
switch to.Kind() {
|
||||
case
|
||||
Complex128,
|
||||
Complex64,
|
||||
Function,
|
||||
Interface,
|
||||
Map,
|
||||
Pointer,
|
||||
Slice,
|
||||
String,
|
||||
Struct,
|
||||
Tuple,
|
||||
UnsafePointer,
|
||||
UntypedBool,
|
||||
UntypedComplex,
|
||||
UntypedFloat,
|
||||
UntypedInt,
|
||||
UntypedNil,
|
||||
UntypedRune,
|
||||
UntypedString:
|
||||
|
||||
c.err(n, "TODO %v -> %v", v, to)
|
||||
case Int:
|
||||
w := constant.ToInt(v)
|
||||
if !known(w) {
|
||||
c.err(n, "cannot convert %s to %s", v, to)
|
||||
return unknown
|
||||
}
|
||||
|
||||
i64, ok := constant.Int64Val(w)
|
||||
if !ok {
|
||||
c.err(n, "value %s overflows %s", v, to)
|
||||
return unknown
|
||||
}
|
||||
|
||||
switch c.cfg.goarch {
|
||||
case "386", "arm":
|
||||
if i64 < math.MinInt32 || i64 > math.MaxInt32 {
|
||||
c.err(n, "value %s overflows %s", v, to)
|
||||
return unknown
|
||||
}
|
||||
}
|
||||
return w
|
||||
case Int8:
|
||||
w := constant.ToInt(v)
|
||||
if !known(w) {
|
||||
c.err(n, "cannot convert %s to %s", v, to)
|
||||
return unknown
|
||||
}
|
||||
|
||||
i64, ok := constant.Int64Val(w)
|
||||
if !ok {
|
||||
c.err(n, "value %s overflows %s", v, to)
|
||||
return unknown
|
||||
}
|
||||
|
||||
if i64 < math.MinInt8 || i64 > math.MaxInt8 {
|
||||
c.err(n, "value %s overflows %s", v, to)
|
||||
return unknown
|
||||
}
|
||||
|
||||
return w
|
||||
case Int16:
|
||||
w := constant.ToInt(v)
|
||||
if !known(w) {
|
||||
c.err(n, "cannot convert %s to %s", v, to)
|
||||
return unknown
|
||||
}
|
||||
|
||||
i64, ok := constant.Int64Val(w)
|
||||
if !ok {
|
||||
c.err(n, "value %s overflows %s", v, to)
|
||||
return unknown
|
||||
}
|
||||
|
||||
if i64 < math.MinInt16 || i64 > math.MaxInt16 {
|
||||
c.err(n, "value %s overflows %s", v, to)
|
||||
return unknown
|
||||
}
|
||||
|
||||
return w
|
||||
case Int32:
|
||||
w := constant.ToInt(v)
|
||||
if !known(w) {
|
||||
c.err(n, "cannot convert %s to %s", v, to)
|
||||
return unknown
|
||||
}
|
||||
|
||||
i64, ok := constant.Int64Val(w)
|
||||
if !ok {
|
||||
c.err(n, "value %s overflows %s", v, to)
|
||||
return unknown
|
||||
}
|
||||
|
||||
if i64 < math.MinInt32 || i64 > math.MaxInt32 {
|
||||
c.err(n, "value %s overflows %s", v, to)
|
||||
return unknown
|
||||
}
|
||||
|
||||
return w
|
||||
case Int64:
|
||||
w := constant.ToInt(v)
|
||||
if !known(w) {
|
||||
c.err(n, "cannot convert %s to %s", v, to)
|
||||
return unknown
|
||||
}
|
||||
|
||||
if _, ok := constant.Int64Val(w); !ok {
|
||||
c.err(n, "value %s overflows %s", v, to)
|
||||
return unknown
|
||||
}
|
||||
|
||||
return w
|
||||
case Uint, Uintptr:
|
||||
w := constant.ToInt(v)
|
||||
if !known(w) {
|
||||
c.err(n, "cannot convert %s to %s", v, to)
|
||||
return unknown
|
||||
}
|
||||
|
||||
u64, ok := constant.Uint64Val(w)
|
||||
if !ok {
|
||||
c.err(n, "value %s overflows %s", v, to)
|
||||
return unknown
|
||||
}
|
||||
|
||||
switch c.cfg.goarch {
|
||||
case "386", "arm":
|
||||
if u64 > math.MaxUint32 {
|
||||
c.err(n, "value %s overflows %s", v, to)
|
||||
return unknown
|
||||
}
|
||||
}
|
||||
return w
|
||||
case Uint8:
|
||||
w := constant.ToInt(v)
|
||||
if !known(w) {
|
||||
c.err(n, "cannot convert %s to %s", v, to)
|
||||
return unknown
|
||||
}
|
||||
|
||||
u64, ok := constant.Uint64Val(w)
|
||||
if !ok {
|
||||
c.err(n, "value %s overflows %s", v, to)
|
||||
return unknown
|
||||
}
|
||||
|
||||
if u64 > math.MaxUint8 {
|
||||
c.err(n, "value %s overflows %s", v, to)
|
||||
return unknown
|
||||
}
|
||||
|
||||
return w
|
||||
case Uint16:
|
||||
w := constant.ToInt(v)
|
||||
if !known(w) {
|
||||
c.err(n, "cannot convert %s to %s", v, to)
|
||||
return unknown
|
||||
}
|
||||
|
||||
u64, ok := constant.Uint64Val(w)
|
||||
if !ok {
|
||||
c.err(n, "value %s overflows %s", v, to)
|
||||
return unknown
|
||||
}
|
||||
|
||||
if u64 > math.MaxUint16 {
|
||||
c.err(n, "value %s overflows %s", v, to)
|
||||
return unknown
|
||||
}
|
||||
|
||||
return w
|
||||
case Uint32:
|
||||
w := constant.ToInt(v)
|
||||
if !known(w) {
|
||||
c.err(n, "cannot convert %s to %s", v, to)
|
||||
return unknown
|
||||
}
|
||||
|
||||
u64, ok := constant.Uint64Val(w)
|
||||
if !ok {
|
||||
c.err(n, "value %s overflows %s", v, to)
|
||||
return unknown
|
||||
}
|
||||
|
||||
if u64 > math.MaxUint32 {
|
||||
c.err(n, "value %s overflows %s", v, to)
|
||||
return unknown
|
||||
}
|
||||
|
||||
return w
|
||||
case Uint64:
|
||||
w := constant.ToInt(v)
|
||||
if !known(w) {
|
||||
c.err(n, "cannot convert %s to %s", v, to)
|
||||
return unknown
|
||||
}
|
||||
|
||||
if _, ok := constant.Uint64Val(w); !ok {
|
||||
c.err(n, "value %s overflows %s", v, to)
|
||||
return unknown
|
||||
}
|
||||
|
||||
return w
|
||||
case Float32, Float64:
|
||||
return constant.ToFloat(v)
|
||||
case Bool:
|
||||
if v.Kind() == constant.Bool {
|
||||
return v
|
||||
}
|
||||
}
|
||||
return unknown
|
||||
}
|
||||
7
vendor/modernc.org/libc/Makefile
generated
vendored
7
vendor/modernc.org/libc/Makefile
generated
vendored
|
|
@ -9,6 +9,7 @@
|
|||
linux_amd64 \
|
||||
linux_arm \
|
||||
linux_arm64 \
|
||||
strace \
|
||||
|
||||
|
||||
grep=--include=*.go --include=*.l --include=*.y --include=*.yy --include=*.qbe --include=*.ssa
|
||||
|
|
@ -171,6 +172,8 @@ editor:
|
|||
gofmt -l -s -w *.go
|
||||
go test -short 2>&1 | tee -a log
|
||||
go install -v ./...
|
||||
go build -o /dev/null generate.go
|
||||
go build -o /dev/null strace.go
|
||||
|
||||
later:
|
||||
@grep -n $(grep) LATER * || true
|
||||
|
|
@ -197,3 +200,7 @@ work:
|
|||
go work use ../ccgo/v4
|
||||
go work use ../ccgo/v3
|
||||
go work use ../cc/v4
|
||||
|
||||
strace:
|
||||
go run strace.go
|
||||
go build -v ./...
|
||||
|
|
|
|||
5
vendor/modernc.org/libc/build_all_targets.sh
generated
vendored
5
vendor/modernc.org/libc/build_all_targets.sh
generated
vendored
|
|
@ -1,5 +1,5 @@
|
|||
set -e
|
||||
for tag in none dmesg libc.membrk libc.memgrind
|
||||
for tag in none libc.dmesg libc.membrk libc.memgrind libc.strace
|
||||
do
|
||||
echo "-tags=$tag"
|
||||
echo "GOOS=darwin GOARCH=amd64"
|
||||
|
|
@ -32,6 +32,9 @@ do
|
|||
echo "GOOS=linux GOARCH=loong64"
|
||||
GOOS=linux GOARCH=loong64 go build -tags=$tag -v ./...
|
||||
GOOS=linux GOARCH=loong64 go test -tags=$tag -c -o /dev/null
|
||||
echo "GOOS=linux GOARCH=mips64le"
|
||||
GOOS=linux GOARCH=mips64le go build -tags=$tag -v ./...
|
||||
GOOS=linux GOARCH=mips64le go test -tags=$tag -c -o /dev/null
|
||||
echo "GOOS=linux GOARCH=ppc64le"
|
||||
GOOS=linux GOARCH=ppc64le go build -tags=$tag -v ./...
|
||||
GOOS=linux GOARCH=ppc64le go test -tags=$tag -c -o /dev/null
|
||||
|
|
|
|||
528
vendor/modernc.org/libc/capi_illumos_amd64.go
generated
vendored
Normal file
528
vendor/modernc.org/libc/capi_illumos_amd64.go
generated
vendored
Normal file
|
|
@ -0,0 +1,528 @@
|
|||
// Code generated by 'go generate' - DO NOT EDIT.
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
var CAPI = map[string]struct{}{
|
||||
"_IO_putc": {},
|
||||
"___errno_location": {},
|
||||
"__assert_fail": {},
|
||||
"__builtin___memcpy_chk": {},
|
||||
"__builtin___memmove_chk": {},
|
||||
"__builtin___memset_chk": {},
|
||||
"__builtin___snprintf_chk": {},
|
||||
"__builtin___sprintf_chk": {},
|
||||
"__builtin___strcat_chk": {},
|
||||
"__builtin___strcpy_chk": {},
|
||||
"__builtin___strncpy_chk": {},
|
||||
"__builtin___vsnprintf_chk": {},
|
||||
"__builtin_abort": {},
|
||||
"__builtin_abs": {},
|
||||
"__builtin_add_overflowInt64": {},
|
||||
"__builtin_add_overflowUint32": {},
|
||||
"__builtin_add_overflowUint64": {},
|
||||
"__builtin_bswap16": {},
|
||||
"__builtin_bswap32": {},
|
||||
"__builtin_bswap64": {},
|
||||
"__builtin_bzero": {},
|
||||
"__builtin_clz": {},
|
||||
"__builtin_clzl": {},
|
||||
"__builtin_clzll": {},
|
||||
"__builtin_constant_p_impl": {},
|
||||
"__builtin_copysign": {},
|
||||
"__builtin_copysignf": {},
|
||||
"__builtin_copysignl": {},
|
||||
"__builtin_exit": {},
|
||||
"__builtin_expect": {},
|
||||
"__builtin_fabs": {},
|
||||
"__builtin_fabsf": {},
|
||||
"__builtin_fabsl": {},
|
||||
"__builtin_free": {},
|
||||
"__builtin_getentropy": {},
|
||||
"__builtin_huge_val": {},
|
||||
"__builtin_huge_valf": {},
|
||||
"__builtin_inf": {},
|
||||
"__builtin_inff": {},
|
||||
"__builtin_infl": {},
|
||||
"__builtin_isnan": {},
|
||||
"__builtin_isunordered": {},
|
||||
"__builtin_llabs": {},
|
||||
"__builtin_malloc": {},
|
||||
"__builtin_memcmp": {},
|
||||
"__builtin_memcpy": {},
|
||||
"__builtin_memset": {},
|
||||
"__builtin_mmap": {},
|
||||
"__builtin_mul_overflowInt64": {},
|
||||
"__builtin_mul_overflowUint128": {},
|
||||
"__builtin_mul_overflowUint64": {},
|
||||
"__builtin_nan": {},
|
||||
"__builtin_nanf": {},
|
||||
"__builtin_nanl": {},
|
||||
"__builtin_object_size": {},
|
||||
"__builtin_popcount": {},
|
||||
"__builtin_popcountl": {},
|
||||
"__builtin_prefetch": {},
|
||||
"__builtin_printf": {},
|
||||
"__builtin_snprintf": {},
|
||||
"__builtin_sprintf": {},
|
||||
"__builtin_strchr": {},
|
||||
"__builtin_strcmp": {},
|
||||
"__builtin_strcpy": {},
|
||||
"__builtin_strlen": {},
|
||||
"__builtin_sub_overflowInt64": {},
|
||||
"__builtin_trap": {},
|
||||
"__builtin_unreachable": {},
|
||||
"__ccgo_dmesg": {},
|
||||
"__ccgo_getMutexType": {},
|
||||
"__ccgo_in6addr_anyp": {},
|
||||
"__ccgo_pthreadAttrGetDetachState": {},
|
||||
"__ccgo_pthreadMutexattrGettype": {},
|
||||
"__ccgo_sqlite3_log": {},
|
||||
"__cmsg_nxthdr": {},
|
||||
"__ctype_b_loc": {},
|
||||
"__ctype_get_mb_cur_max": {},
|
||||
"__errno_location": {},
|
||||
"__floatscan": {},
|
||||
"__fpclassify": {},
|
||||
"__fpclassifyf": {},
|
||||
"__fpclassifyl": {},
|
||||
"__fsmu8": {},
|
||||
"__h_errno_location": {},
|
||||
"__inet_aton": {},
|
||||
"__intscan": {},
|
||||
"__isalnum_l": {},
|
||||
"__isalpha_l": {},
|
||||
"__isdigit_l": {},
|
||||
"__islower_l": {},
|
||||
"__isnan": {},
|
||||
"__isnanf": {},
|
||||
"__isnanl": {},
|
||||
"__isoc99_sscanf": {},
|
||||
"__isprint_l": {},
|
||||
"__isupper_l": {},
|
||||
"__isxdigit_l": {},
|
||||
"__lockfile": {},
|
||||
"__lookup_ipliteral": {},
|
||||
"__lookup_name": {},
|
||||
"__lookup_serv": {},
|
||||
"__shgetc": {},
|
||||
"__shlim": {},
|
||||
"__strncasecmp_l": {},
|
||||
"__sync_add_and_fetch_uint32": {},
|
||||
"__sync_sub_and_fetch_uint32": {},
|
||||
"__syscall1": {},
|
||||
"__syscall3": {},
|
||||
"__syscall4": {},
|
||||
"__toread": {},
|
||||
"__toread_needs_stdio_exit": {},
|
||||
"__uflow": {},
|
||||
"__unlockfile": {},
|
||||
"_exit": {},
|
||||
"_longjmp": {},
|
||||
"_obstack_begin": {},
|
||||
"_obstack_newchunk": {},
|
||||
"_setjmp": {},
|
||||
"abort": {},
|
||||
"abs": {},
|
||||
"accept": {},
|
||||
"access": {},
|
||||
"acos": {},
|
||||
"acosh": {},
|
||||
"alarm": {},
|
||||
"asin": {},
|
||||
"asinh": {},
|
||||
"atan": {},
|
||||
"atan2": {},
|
||||
"atanh": {},
|
||||
"atexit": {},
|
||||
"atof": {},
|
||||
"atoi": {},
|
||||
"atol": {},
|
||||
"backtrace": {},
|
||||
"backtrace_symbols_fd": {},
|
||||
"bind": {},
|
||||
"bsearch": {},
|
||||
"bzero": {},
|
||||
"calloc": {},
|
||||
"ceil": {},
|
||||
"ceilf": {},
|
||||
"cfgetospeed": {},
|
||||
"cfsetispeed": {},
|
||||
"cfsetospeed": {},
|
||||
"chdir": {},
|
||||
"chmod": {},
|
||||
"chown": {},
|
||||
"clock_gettime": {},
|
||||
"close": {},
|
||||
"closedir": {},
|
||||
"confstr": {},
|
||||
"connect": {},
|
||||
"copysign": {},
|
||||
"copysignf": {},
|
||||
"copysignl": {},
|
||||
"cos": {},
|
||||
"cosf": {},
|
||||
"cosh": {},
|
||||
"ctime": {},
|
||||
"ctime_r": {},
|
||||
"dlclose": {},
|
||||
"dlerror": {},
|
||||
"dlopen": {},
|
||||
"dlsym": {},
|
||||
"dup2": {},
|
||||
"dup3": {},
|
||||
"endpwent": {},
|
||||
"environ": {},
|
||||
"execvp": {},
|
||||
"exit": {},
|
||||
"exp": {},
|
||||
"fabs": {},
|
||||
"fabsf": {},
|
||||
"fabsl": {},
|
||||
"faccessat": {},
|
||||
"fchmod": {},
|
||||
"fchmodat": {},
|
||||
"fchown": {},
|
||||
"fchownat": {},
|
||||
"fclose": {},
|
||||
"fcntl": {},
|
||||
"fcntl64": {},
|
||||
"fdopen": {},
|
||||
"ferror": {},
|
||||
"fflush": {},
|
||||
"fgetc": {},
|
||||
"fgets": {},
|
||||
"fileno": {},
|
||||
"floor": {},
|
||||
"fmod": {},
|
||||
"fmodl": {},
|
||||
"fopen": {},
|
||||
"fopen64": {},
|
||||
"fork": {},
|
||||
"fprintf": {},
|
||||
"fputc": {},
|
||||
"fputs": {},
|
||||
"fread": {},
|
||||
"free": {},
|
||||
"freeaddrinfo": {},
|
||||
"frexp": {},
|
||||
"fscanf": {},
|
||||
"fseek": {},
|
||||
"fstat": {},
|
||||
"fstat64": {},
|
||||
"fstatfs": {},
|
||||
"fsync": {},
|
||||
"ftell": {},
|
||||
"ftruncate": {},
|
||||
"ftruncate64": {},
|
||||
"fts64_close": {},
|
||||
"fts64_open": {},
|
||||
"fts64_read": {},
|
||||
"fts_close": {},
|
||||
"fts_open": {},
|
||||
"fts_read": {},
|
||||
"fwrite": {},
|
||||
"gai_strerror": {},
|
||||
"getaddrinfo": {},
|
||||
"getc": {},
|
||||
"getcwd": {},
|
||||
"getegid": {},
|
||||
"getentropy": {},
|
||||
"getenv": {},
|
||||
"geteuid": {},
|
||||
"getgid": {},
|
||||
"getgrgid": {},
|
||||
"getgrgid_r": {},
|
||||
"getgrnam": {},
|
||||
"getgrnam_r": {},
|
||||
"gethostbyaddr": {},
|
||||
"gethostbyaddr_r": {},
|
||||
"gethostbyname": {},
|
||||
"gethostbyname2": {},
|
||||
"gethostbyname2_r": {},
|
||||
"gethostbyname_r": {},
|
||||
"gethostname": {},
|
||||
"getnameinfo": {},
|
||||
"getpeername": {},
|
||||
"getpid": {},
|
||||
"getpwnam": {},
|
||||
"getpwnam_r": {},
|
||||
"getpwuid": {},
|
||||
"getpwuid_r": {},
|
||||
"getrandom": {},
|
||||
"getresgid": {},
|
||||
"getresuid": {},
|
||||
"getrlimit": {},
|
||||
"getrlimit64": {},
|
||||
"getrusage": {},
|
||||
"getservbyname": {},
|
||||
"getsockname": {},
|
||||
"getsockopt": {},
|
||||
"gettimeofday": {},
|
||||
"getuid": {},
|
||||
"gmtime_r": {},
|
||||
"h_errno": {},
|
||||
"htonl": {},
|
||||
"htons": {},
|
||||
"hypot": {},
|
||||
"inet_ntoa": {},
|
||||
"inet_ntop": {},
|
||||
"inet_pton": {},
|
||||
"initstate": {},
|
||||
"initstate_r": {},
|
||||
"ioctl": {},
|
||||
"isalnum": {},
|
||||
"isalpha": {},
|
||||
"isascii": {},
|
||||
"isatty": {},
|
||||
"isdigit": {},
|
||||
"islower": {},
|
||||
"isnan": {},
|
||||
"isnanf": {},
|
||||
"isnanl": {},
|
||||
"isprint": {},
|
||||
"isupper": {},
|
||||
"iswalnum": {},
|
||||
"iswspace": {},
|
||||
"isxdigit": {},
|
||||
"kill": {},
|
||||
"ldexp": {},
|
||||
"link": {},
|
||||
"linkat": {},
|
||||
"listen": {},
|
||||
"llabs": {},
|
||||
"localeconv": {},
|
||||
"localtime": {},
|
||||
"localtime_r": {},
|
||||
"log": {},
|
||||
"log10": {},
|
||||
"log2": {},
|
||||
"longjmp": {},
|
||||
"lrand48": {},
|
||||
"lseek": {},
|
||||
"lseek64": {},
|
||||
"lstat": {},
|
||||
"lstat64": {},
|
||||
"malloc": {},
|
||||
"mblen": {},
|
||||
"mbrtowc": {},
|
||||
"mbsinit": {},
|
||||
"mbstowcs": {},
|
||||
"mbtowc": {},
|
||||
"memchr": {},
|
||||
"memcmp": {},
|
||||
"memcpy": {},
|
||||
"memmove": {},
|
||||
"memset": {},
|
||||
"mkdir": {},
|
||||
"mkdirat": {},
|
||||
"mkfifo": {},
|
||||
"mknod": {},
|
||||
"mknodat": {},
|
||||
"mkostemp": {},
|
||||
"mkstemp": {},
|
||||
"mkstemp64": {},
|
||||
"mkstemps": {},
|
||||
"mkstemps64": {},
|
||||
"mktime": {},
|
||||
"mmap": {},
|
||||
"mmap64": {},
|
||||
"modf": {},
|
||||
"mremap": {},
|
||||
"munmap": {},
|
||||
"nanf": {},
|
||||
"nanosleep": {},
|
||||
"nl_langinfo": {},
|
||||
"ntohs": {},
|
||||
"obstack_free": {},
|
||||
"obstack_vprintf": {},
|
||||
"open": {},
|
||||
"open64": {},
|
||||
"openat": {},
|
||||
"opendir": {},
|
||||
"openpty": {},
|
||||
"pathconf": {},
|
||||
"pause": {},
|
||||
"pclose": {},
|
||||
"perror": {},
|
||||
"pipe": {},
|
||||
"pipe2": {},
|
||||
"poll": {},
|
||||
"popen": {},
|
||||
"posix_fadvise": {},
|
||||
"pow": {},
|
||||
"pread": {},
|
||||
"printf": {},
|
||||
"pselect": {},
|
||||
"pthread_attr_destroy": {},
|
||||
"pthread_attr_getdetachstate": {},
|
||||
"pthread_attr_init": {},
|
||||
"pthread_attr_setdetachstate": {},
|
||||
"pthread_attr_setscope": {},
|
||||
"pthread_attr_setstacksize": {},
|
||||
"pthread_cond_broadcast": {},
|
||||
"pthread_cond_destroy": {},
|
||||
"pthread_cond_init": {},
|
||||
"pthread_cond_signal": {},
|
||||
"pthread_cond_timedwait": {},
|
||||
"pthread_cond_wait": {},
|
||||
"pthread_create": {},
|
||||
"pthread_detach": {},
|
||||
"pthread_equal": {},
|
||||
"pthread_exit": {},
|
||||
"pthread_getspecific": {},
|
||||
"pthread_join": {},
|
||||
"pthread_key_create": {},
|
||||
"pthread_key_delete": {},
|
||||
"pthread_mutex_destroy": {},
|
||||
"pthread_mutex_init": {},
|
||||
"pthread_mutex_lock": {},
|
||||
"pthread_mutex_trylock": {},
|
||||
"pthread_mutex_unlock": {},
|
||||
"pthread_mutexattr_destroy": {},
|
||||
"pthread_mutexattr_init": {},
|
||||
"pthread_mutexattr_settype": {},
|
||||
"pthread_self": {},
|
||||
"pthread_setspecific": {},
|
||||
"putc": {},
|
||||
"putchar": {},
|
||||
"puts": {},
|
||||
"pwrite": {},
|
||||
"qsort": {},
|
||||
"raise": {},
|
||||
"rand": {},
|
||||
"rand_r": {},
|
||||
"random": {},
|
||||
"random_r": {},
|
||||
"read": {},
|
||||
"readdir": {},
|
||||
"readdir64": {},
|
||||
"readlink": {},
|
||||
"readlinkat": {},
|
||||
"readv": {},
|
||||
"realloc": {},
|
||||
"reallocarray": {},
|
||||
"realpath": {},
|
||||
"recv": {},
|
||||
"recvfrom": {},
|
||||
"recvmsg": {},
|
||||
"remove": {},
|
||||
"rename": {},
|
||||
"renameat2": {},
|
||||
"rewind": {},
|
||||
"rindex": {},
|
||||
"rint": {},
|
||||
"rmdir": {},
|
||||
"round": {},
|
||||
"scalbn": {},
|
||||
"scalbnl": {},
|
||||
"sched_yield": {},
|
||||
"select": {},
|
||||
"send": {},
|
||||
"sendmsg": {},
|
||||
"sendto": {},
|
||||
"setbuf": {},
|
||||
"setenv": {},
|
||||
"setjmp": {},
|
||||
"setlocale": {},
|
||||
"setrlimit": {},
|
||||
"setrlimit64": {},
|
||||
"setsid": {},
|
||||
"setsockopt": {},
|
||||
"setstate": {},
|
||||
"setvbuf": {},
|
||||
"shmat": {},
|
||||
"shmctl": {},
|
||||
"shmdt": {},
|
||||
"shutdown": {},
|
||||
"sigaction": {},
|
||||
"signal": {},
|
||||
"sin": {},
|
||||
"sinf": {},
|
||||
"sinh": {},
|
||||
"sleep": {},
|
||||
"snprintf": {},
|
||||
"socket": {},
|
||||
"sprintf": {},
|
||||
"sqrt": {},
|
||||
"srand48": {},
|
||||
"sscanf": {},
|
||||
"stat": {},
|
||||
"stat64": {},
|
||||
"stderr": {},
|
||||
"stdin": {},
|
||||
"stdout": {},
|
||||
"strcasecmp": {},
|
||||
"strcat": {},
|
||||
"strchr": {},
|
||||
"strcmp": {},
|
||||
"strcpy": {},
|
||||
"strcspn": {},
|
||||
"strdup": {},
|
||||
"strerror": {},
|
||||
"strerror_r": {},
|
||||
"strlcat": {},
|
||||
"strlcpy": {},
|
||||
"strlen": {},
|
||||
"strncasecmp": {},
|
||||
"strncat": {},
|
||||
"strncmp": {},
|
||||
"strncpy": {},
|
||||
"strnlen": {},
|
||||
"strpbrk": {},
|
||||
"strrchr": {},
|
||||
"strspn": {},
|
||||
"strstr": {},
|
||||
"strtod": {},
|
||||
"strtof": {},
|
||||
"strtoimax": {},
|
||||
"strtok": {},
|
||||
"strtol": {},
|
||||
"strtold": {},
|
||||
"strtoll": {},
|
||||
"strtoul": {},
|
||||
"strtoull": {},
|
||||
"strtoumax": {},
|
||||
"symlink": {},
|
||||
"symlinkat": {},
|
||||
"sysconf": {},
|
||||
"system": {},
|
||||
"tan": {},
|
||||
"tanh": {},
|
||||
"tcgetattr": {},
|
||||
"tcsendbreak": {},
|
||||
"tcsetattr": {},
|
||||
"time": {},
|
||||
"tmpfile": {},
|
||||
"tolower": {},
|
||||
"toupper": {},
|
||||
"trunc": {},
|
||||
"tzset": {},
|
||||
"umask": {},
|
||||
"uname": {},
|
||||
"ungetc": {},
|
||||
"unlink": {},
|
||||
"unlinkat": {},
|
||||
"unsetenv": {},
|
||||
"usleep": {},
|
||||
"utime": {},
|
||||
"utimensat": {},
|
||||
"utimes": {},
|
||||
"uuid_copy": {},
|
||||
"uuid_generate_random": {},
|
||||
"uuid_parse": {},
|
||||
"uuid_unparse": {},
|
||||
"vasprintf": {},
|
||||
"vfprintf": {},
|
||||
"vfscanf": {},
|
||||
"vprintf": {},
|
||||
"vsnprintf": {},
|
||||
"vsprintf": {},
|
||||
"vsscanf": {},
|
||||
"waitpid": {},
|
||||
"wcschr": {},
|
||||
"wctomb": {},
|
||||
"wcwidth": {},
|
||||
"write": {},
|
||||
"writev": {},
|
||||
"zero_struct_address": {},
|
||||
}
|
||||
528
vendor/modernc.org/libc/capi_linux_mips64le.go
generated
vendored
Normal file
528
vendor/modernc.org/libc/capi_linux_mips64le.go
generated
vendored
Normal file
|
|
@ -0,0 +1,528 @@
|
|||
// Code generated by 'go generate' - DO NOT EDIT.
|
||||
|
||||
package libc // import "modernc.org/libc"
|
||||
|
||||
var CAPI = map[string]struct{}{
|
||||
"_IO_putc": {},
|
||||
"___errno_location": {},
|
||||
"__assert_fail": {},
|
||||
"__builtin___memcpy_chk": {},
|
||||
"__builtin___memmove_chk": {},
|
||||
"__builtin___memset_chk": {},
|
||||
"__builtin___snprintf_chk": {},
|
||||
"__builtin___sprintf_chk": {},
|
||||
"__builtin___strcat_chk": {},
|
||||
"__builtin___strcpy_chk": {},
|
||||
"__builtin___strncpy_chk": {},
|
||||
"__builtin___vsnprintf_chk": {},
|
||||
"__builtin_abort": {},
|
||||
"__builtin_abs": {},
|
||||
"__builtin_add_overflowInt64": {},
|
||||
"__builtin_add_overflowUint32": {},
|
||||
"__builtin_add_overflowUint64": {},
|
||||
"__builtin_bswap16": {},
|
||||
"__builtin_bswap32": {},
|
||||
"__builtin_bswap64": {},
|
||||
"__builtin_bzero": {},
|
||||
"__builtin_clz": {},
|
||||
"__builtin_clzl": {},
|
||||
"__builtin_clzll": {},
|
||||
"__builtin_constant_p_impl": {},
|
||||
"__builtin_copysign": {},
|
||||
"__builtin_copysignf": {},
|
||||
"__builtin_copysignl": {},
|
||||
"__builtin_exit": {},
|
||||
"__builtin_expect": {},
|
||||
"__builtin_fabs": {},
|
||||
"__builtin_fabsf": {},
|
||||
"__builtin_fabsl": {},
|
||||
"__builtin_free": {},
|
||||
"__builtin_getentropy": {},
|
||||
"__builtin_huge_val": {},
|
||||
"__builtin_huge_valf": {},
|
||||
"__builtin_inf": {},
|
||||
"__builtin_inff": {},
|
||||
"__builtin_infl": {},
|
||||
"__builtin_isnan": {},
|
||||
"__builtin_isunordered": {},
|
||||
"__builtin_llabs": {},
|
||||
"__builtin_malloc": {},
|
||||
"__builtin_memcmp": {},
|
||||
"__builtin_memcpy": {},
|
||||
"__builtin_memset": {},
|
||||
"__builtin_mmap": {},
|
||||
"__builtin_mul_overflowInt64": {},
|
||||
"__builtin_mul_overflowUint128": {},
|
||||
"__builtin_mul_overflowUint64": {},
|
||||
"__builtin_nan": {},
|
||||
"__builtin_nanf": {},
|
||||
"__builtin_nanl": {},
|
||||
"__builtin_object_size": {},
|
||||
"__builtin_popcount": {},
|
||||
"__builtin_popcountl": {},
|
||||
"__builtin_prefetch": {},
|
||||
"__builtin_printf": {},
|
||||
"__builtin_snprintf": {},
|
||||
"__builtin_sprintf": {},
|
||||
"__builtin_strchr": {},
|
||||
"__builtin_strcmp": {},
|
||||
"__builtin_strcpy": {},
|
||||
"__builtin_strlen": {},
|
||||
"__builtin_sub_overflowInt64": {},
|
||||
"__builtin_trap": {},
|
||||
"__builtin_unreachable": {},
|
||||
"__ccgo_dmesg": {},
|
||||
"__ccgo_getMutexType": {},
|
||||
"__ccgo_in6addr_anyp": {},
|
||||
"__ccgo_pthreadAttrGetDetachState": {},
|
||||
"__ccgo_pthreadMutexattrGettype": {},
|
||||
"__ccgo_sqlite3_log": {},
|
||||
"__cmsg_nxthdr": {},
|
||||
"__ctype_b_loc": {},
|
||||
"__ctype_get_mb_cur_max": {},
|
||||
"__errno_location": {},
|
||||
"__floatscan": {},
|
||||
"__fpclassify": {},
|
||||
"__fpclassifyf": {},
|
||||
"__fpclassifyl": {},
|
||||
"__fsmu8": {},
|
||||
"__h_errno_location": {},
|
||||
"__inet_aton": {},
|
||||
"__intscan": {},
|
||||
"__isalnum_l": {},
|
||||
"__isalpha_l": {},
|
||||
"__isdigit_l": {},
|
||||
"__islower_l": {},
|
||||
"__isnan": {},
|
||||
"__isnanf": {},
|
||||
"__isnanl": {},
|
||||
"__isoc99_sscanf": {},
|
||||
"__isprint_l": {},
|
||||
"__isupper_l": {},
|
||||
"__isxdigit_l": {},
|
||||
"__lockfile": {},
|
||||
"__lookup_ipliteral": {},
|
||||
"__lookup_name": {},
|
||||
"__lookup_serv": {},
|
||||
"__shgetc": {},
|
||||
"__shlim": {},
|
||||
"__strncasecmp_l": {},
|
||||
"__sync_add_and_fetch_uint32": {},
|
||||
"__sync_sub_and_fetch_uint32": {},
|
||||
"__syscall1": {},
|
||||
"__syscall3": {},
|
||||
"__syscall4": {},
|
||||
"__toread": {},
|
||||
"__toread_needs_stdio_exit": {},
|
||||
"__uflow": {},
|
||||
"__unlockfile": {},
|
||||
"_exit": {},
|
||||
"_longjmp": {},
|
||||
"_obstack_begin": {},
|
||||
"_obstack_newchunk": {},
|
||||
"_setjmp": {},
|
||||
"abort": {},
|
||||
"abs": {},
|
||||
"accept": {},
|
||||
"access": {},
|
||||
"acos": {},
|
||||
"acosh": {},
|
||||
"alarm": {},
|
||||
"asin": {},
|
||||
"asinh": {},
|
||||
"atan": {},
|
||||
"atan2": {},
|
||||
"atanh": {},
|
||||
"atexit": {},
|
||||
"atof": {},
|
||||
"atoi": {},
|
||||
"atol": {},
|
||||
"backtrace": {},
|
||||
"backtrace_symbols_fd": {},
|
||||
"bind": {},
|
||||
"bsearch": {},
|
||||
"bzero": {},
|
||||
"calloc": {},
|
||||
"ceil": {},
|
||||
"ceilf": {},
|
||||
"cfgetospeed": {},
|
||||
"cfsetispeed": {},
|
||||
"cfsetospeed": {},
|
||||
"chdir": {},
|
||||
"chmod": {},
|
||||
"chown": {},
|
||||
"clock_gettime": {},
|
||||
"close": {},
|
||||
"closedir": {},
|
||||
"confstr": {},
|
||||
"connect": {},
|
||||
"copysign": {},
|
||||
"copysignf": {},
|
||||
"copysignl": {},
|
||||
"cos": {},
|
||||
"cosf": {},
|
||||
"cosh": {},
|
||||
"ctime": {},
|
||||
"ctime_r": {},
|
||||
"dlclose": {},
|
||||
"dlerror": {},
|
||||
"dlopen": {},
|
||||
"dlsym": {},
|
||||
"dup2": {},
|
||||
"dup3": {},
|
||||
"endpwent": {},
|
||||
"environ": {},
|
||||
"execvp": {},
|
||||
"exit": {},
|
||||
"exp": {},
|
||||
"fabs": {},
|
||||
"fabsf": {},
|
||||
"fabsl": {},
|
||||
"faccessat": {},
|
||||
"fchmod": {},
|
||||
"fchmodat": {},
|
||||
"fchown": {},
|
||||
"fchownat": {},
|
||||
"fclose": {},
|
||||
"fcntl": {},
|
||||
"fcntl64": {},
|
||||
"fdopen": {},
|
||||
"ferror": {},
|
||||
"fflush": {},
|
||||
"fgetc": {},
|
||||
"fgets": {},
|
||||
"fileno": {},
|
||||
"floor": {},
|
||||
"fmod": {},
|
||||
"fmodl": {},
|
||||
"fopen": {},
|
||||
"fopen64": {},
|
||||
"fork": {},
|
||||
"fprintf": {},
|
||||
"fputc": {},
|
||||
"fputs": {},
|
||||
"fread": {},
|
||||
"free": {},
|
||||
"freeaddrinfo": {},
|
||||
"frexp": {},
|
||||
"fscanf": {},
|
||||
"fseek": {},
|
||||
"fstat": {},
|
||||
"fstat64": {},
|
||||
"fstatfs": {},
|
||||
"fsync": {},
|
||||
"ftell": {},
|
||||
"ftruncate": {},
|
||||
"ftruncate64": {},
|
||||
"fts64_close": {},
|
||||
"fts64_open": {},
|
||||
"fts64_read": {},
|
||||
"fts_close": {},
|
||||
"fts_open": {},
|
||||
"fts_read": {},
|
||||
"fwrite": {},
|
||||
"gai_strerror": {},
|
||||
"getaddrinfo": {},
|
||||
"getc": {},
|
||||
"getcwd": {},
|
||||
"getegid": {},
|
||||
"getentropy": {},
|
||||
"getenv": {},
|
||||
"geteuid": {},
|
||||
"getgid": {},
|
||||
"getgrgid": {},
|
||||
"getgrgid_r": {},
|
||||
"getgrnam": {},
|
||||
"getgrnam_r": {},
|
||||
"gethostbyaddr": {},
|
||||
"gethostbyaddr_r": {},
|
||||
"gethostbyname": {},
|
||||
"gethostbyname2": {},
|
||||
"gethostbyname2_r": {},
|
||||
"gethostbyname_r": {},
|
||||
"gethostname": {},
|
||||
"getnameinfo": {},
|
||||
"getpeername": {},
|
||||
"getpid": {},
|
||||
"getpwnam": {},
|
||||
"getpwnam_r": {},
|
||||
"getpwuid": {},
|
||||
"getpwuid_r": {},
|
||||
"getrandom": {},
|
||||
"getresgid": {},
|
||||
"getresuid": {},
|
||||
"getrlimit": {},
|
||||
"getrlimit64": {},
|
||||
"getrusage": {},
|
||||
"getservbyname": {},
|
||||
"getsockname": {},
|
||||
"getsockopt": {},
|
||||
"gettimeofday": {},
|
||||
"getuid": {},
|
||||
"gmtime_r": {},
|
||||
"h_errno": {},
|
||||
"htonl": {},
|
||||
"htons": {},
|
||||
"hypot": {},
|
||||
"inet_ntoa": {},
|
||||
"inet_ntop": {},
|
||||
"inet_pton": {},
|
||||
"initstate": {},
|
||||
"initstate_r": {},
|
||||
"ioctl": {},
|
||||
"isalnum": {},
|
||||
"isalpha": {},
|
||||
"isascii": {},
|
||||
"isatty": {},
|
||||
"isdigit": {},
|
||||
"islower": {},
|
||||
"isnan": {},
|
||||
"isnanf": {},
|
||||
"isnanl": {},
|
||||
"isprint": {},
|
||||
"isupper": {},
|
||||
"iswalnum": {},
|
||||
"iswspace": {},
|
||||
"isxdigit": {},
|
||||
"kill": {},
|
||||
"ldexp": {},
|
||||
"link": {},
|
||||
"linkat": {},
|
||||
"listen": {},
|
||||
"llabs": {},
|
||||
"localeconv": {},
|
||||
"localtime": {},
|
||||
"localtime_r": {},
|
||||
"log": {},
|
||||
"log10": {},
|
||||
"log2": {},
|
||||
"longjmp": {},
|
||||
"lrand48": {},
|
||||
"lseek": {},
|
||||
"lseek64": {},
|
||||
"lstat": {},
|
||||
"lstat64": {},
|
||||
"malloc": {},
|
||||
"mblen": {},
|
||||
"mbrtowc": {},
|
||||
"mbsinit": {},
|
||||
"mbstowcs": {},
|
||||
"mbtowc": {},
|
||||
"memchr": {},
|
||||
"memcmp": {},
|
||||
"memcpy": {},
|
||||
"memmove": {},
|
||||
"memset": {},
|
||||
"mkdir": {},
|
||||
"mkdirat": {},
|
||||
"mkfifo": {},
|
||||
"mknod": {},
|
||||
"mknodat": {},
|
||||
"mkostemp": {},
|
||||
"mkstemp": {},
|
||||
"mkstemp64": {},
|
||||
"mkstemps": {},
|
||||
"mkstemps64": {},
|
||||
"mktime": {},
|
||||
"mmap": {},
|
||||
"mmap64": {},
|
||||
"modf": {},
|
||||
"mremap": {},
|
||||
"munmap": {},
|
||||
"nanf": {},
|
||||
"nanosleep": {},
|
||||
"nl_langinfo": {},
|
||||
"ntohs": {},
|
||||
"obstack_free": {},
|
||||
"obstack_vprintf": {},
|
||||
"open": {},
|
||||
"open64": {},
|
||||
"openat": {},
|
||||
"opendir": {},
|
||||
"openpty": {},
|
||||
"pathconf": {},
|
||||
"pause": {},
|
||||
"pclose": {},
|
||||
"perror": {},
|
||||
"pipe": {},
|
||||
"pipe2": {},
|
||||
"poll": {},
|
||||
"popen": {},
|
||||
"posix_fadvise": {},
|
||||
"pow": {},
|
||||
"pread": {},
|
||||
"printf": {},
|
||||
"pselect": {},
|
||||
"pthread_attr_destroy": {},
|
||||
"pthread_attr_getdetachstate": {},
|
||||
"pthread_attr_init": {},
|
||||
"pthread_attr_setdetachstate": {},
|
||||
"pthread_attr_setscope": {},
|
||||
"pthread_attr_setstacksize": {},
|
||||
"pthread_cond_broadcast": {},
|
||||
"pthread_cond_destroy": {},
|
||||
"pthread_cond_init": {},
|
||||
"pthread_cond_signal": {},
|
||||
"pthread_cond_timedwait": {},
|
||||
"pthread_cond_wait": {},
|
||||
"pthread_create": {},
|
||||
"pthread_detach": {},
|
||||
"pthread_equal": {},
|
||||
"pthread_exit": {},
|
||||
"pthread_getspecific": {},
|
||||
"pthread_join": {},
|
||||
"pthread_key_create": {},
|
||||
"pthread_key_delete": {},
|
||||
"pthread_mutex_destroy": {},
|
||||
"pthread_mutex_init": {},
|
||||
"pthread_mutex_lock": {},
|
||||
"pthread_mutex_trylock": {},
|
||||
"pthread_mutex_unlock": {},
|
||||
"pthread_mutexattr_destroy": {},
|
||||
"pthread_mutexattr_init": {},
|
||||
"pthread_mutexattr_settype": {},
|
||||
"pthread_self": {},
|
||||
"pthread_setspecific": {},
|
||||
"putc": {},
|
||||
"putchar": {},
|
||||
"puts": {},
|
||||
"pwrite": {},
|
||||
"qsort": {},
|
||||
"raise": {},
|
||||
"rand": {},
|
||||
"rand_r": {},
|
||||
"random": {},
|
||||
"random_r": {},
|
||||
"read": {},
|
||||
"readdir": {},
|
||||
"readdir64": {},
|
||||
"readlink": {},
|
||||
"readlinkat": {},
|
||||
"readv": {},
|
||||
"realloc": {},
|
||||
"reallocarray": {},
|
||||
"realpath": {},
|
||||
"recv": {},
|
||||
"recvfrom": {},
|
||||
"recvmsg": {},
|
||||
"remove": {},
|
||||
"rename": {},
|
||||
"renameat2": {},
|
||||
"rewind": {},
|
||||
"rindex": {},
|
||||
"rint": {},
|
||||
"rmdir": {},
|
||||
"round": {},
|
||||
"scalbn": {},
|
||||
"scalbnl": {},
|
||||
"sched_yield": {},
|
||||
"select": {},
|
||||
"send": {},
|
||||
"sendmsg": {},
|
||||
"sendto": {},
|
||||
"setbuf": {},
|
||||
"setenv": {},
|
||||
"setjmp": {},
|
||||
"setlocale": {},
|
||||
"setrlimit": {},
|
||||
"setrlimit64": {},
|
||||
"setsid": {},
|
||||
"setsockopt": {},
|
||||
"setstate": {},
|
||||
"setvbuf": {},
|
||||
"shmat": {},
|
||||
"shmctl": {},
|
||||
"shmdt": {},
|
||||
"shutdown": {},
|
||||
"sigaction": {},
|
||||
"signal": {},
|
||||
"sin": {},
|
||||
"sinf": {},
|
||||
"sinh": {},
|
||||
"sleep": {},
|
||||
"snprintf": {},
|
||||
"socket": {},
|
||||
"sprintf": {},
|
||||
"sqrt": {},
|
||||
"srand48": {},
|
||||
"sscanf": {},
|
||||
"stat": {},
|
||||
"stat64": {},
|
||||
"stderr": {},
|
||||
"stdin": {},
|
||||
"stdout": {},
|
||||
"strcasecmp": {},
|
||||
"strcat": {},
|
||||
"strchr": {},
|
||||
"strcmp": {},
|
||||
"strcpy": {},
|
||||
"strcspn": {},
|
||||
"strdup": {},
|
||||
"strerror": {},
|
||||
"strerror_r": {},
|
||||
"strlcat": {},
|
||||
"strlcpy": {},
|
||||
"strlen": {},
|
||||
"strncasecmp": {},
|
||||
"strncat": {},
|
||||
"strncmp": {},
|
||||
"strncpy": {},
|
||||
"strnlen": {},
|
||||
"strpbrk": {},
|
||||
"strrchr": {},
|
||||
"strspn": {},
|
||||
"strstr": {},
|
||||
"strtod": {},
|
||||
"strtof": {},
|
||||
"strtoimax": {},
|
||||
"strtok": {},
|
||||
"strtol": {},
|
||||
"strtold": {},
|
||||
"strtoll": {},
|
||||
"strtoul": {},
|
||||
"strtoull": {},
|
||||
"strtoumax": {},
|
||||
"symlink": {},
|
||||
"symlinkat": {},
|
||||
"sysconf": {},
|
||||
"system": {},
|
||||
"tan": {},
|
||||
"tanh": {},
|
||||
"tcgetattr": {},
|
||||
"tcsendbreak": {},
|
||||
"tcsetattr": {},
|
||||
"time": {},
|
||||
"tmpfile": {},
|
||||
"tolower": {},
|
||||
"toupper": {},
|
||||
"trunc": {},
|
||||
"tzset": {},
|
||||
"umask": {},
|
||||
"uname": {},
|
||||
"ungetc": {},
|
||||
"unlink": {},
|
||||
"unlinkat": {},
|
||||
"unsetenv": {},
|
||||
"usleep": {},
|
||||
"utime": {},
|
||||
"utimensat": {},
|
||||
"utimes": {},
|
||||
"uuid_copy": {},
|
||||
"uuid_generate_random": {},
|
||||
"uuid_parse": {},
|
||||
"uuid_unparse": {},
|
||||
"vasprintf": {},
|
||||
"vfprintf": {},
|
||||
"vfscanf": {},
|
||||
"vprintf": {},
|
||||
"vsnprintf": {},
|
||||
"vsprintf": {},
|
||||
"vsscanf": {},
|
||||
"waitpid": {},
|
||||
"wcschr": {},
|
||||
"wctomb": {},
|
||||
"wcwidth": {},
|
||||
"write": {},
|
||||
"writev": {},
|
||||
"zero_struct_address": {},
|
||||
}
|
||||
16
vendor/modernc.org/libc/ccgo.go
generated
vendored
16
vendor/modernc.org/libc/ccgo.go
generated
vendored
|
|
@ -802,6 +802,22 @@ func PostIncAtomicUint32(p *uint32, d uint32) uint32 { return atomic.AddUint
|
|||
func PostIncAtomicUint64(p *uint64, d uint64) uint64 { return atomic.AddUint64(p, d) - d }
|
||||
func PostIncAtomicUintptr(p *uintptr, d uintptr) uintptr { return atomic.AddUintptr(p, d) - d }
|
||||
|
||||
func PostIncAtomicInt32P(p uintptr, d int32) int32 {
|
||||
return atomic.AddInt32((*int32)(unsafe.Pointer(p)), d) - d
|
||||
}
|
||||
func PostIncAtomicInt64P(p uintptr, d int64) int64 {
|
||||
return atomic.AddInt64((*int64)(unsafe.Pointer(p)), d) - d
|
||||
}
|
||||
func PostIncAtomicUint32P(p uintptr, d uint32) uint32 {
|
||||
return atomic.AddUint32((*uint32)(unsafe.Pointer(p)), d) - d
|
||||
}
|
||||
func PostIncAtomicUint64P(p uintptr, d uint64) uint64 {
|
||||
return atomic.AddUint64((*uint64)(unsafe.Pointer(p)), d) - d
|
||||
}
|
||||
func PostIncAtomicUintptrP(p uintptr, d uintptr) uintptr {
|
||||
return atomic.AddUintptr((*uintptr)(unsafe.Pointer(p)), d) - d
|
||||
}
|
||||
|
||||
func PostDecInt8(p *int8, d int8) int8 { r := *p; *p -= d; return r }
|
||||
func PostDecInt16(p *int16, d int16) int16 { r := *p; *p -= d; return r }
|
||||
func PostDecInt32(p *int32, d int32) int32 { r := *p; *p -= d; return r }
|
||||
|
|
|
|||
5
vendor/modernc.org/libc/errno/capi_illumos_amd64.go
generated
vendored
Normal file
5
vendor/modernc.org/libc/errno/capi_illumos_amd64.go
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
// Code generated by 'ccgo errno/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o errno/errno_illumos_amd64.go -pkgname errno', DO NOT EDIT.
|
||||
|
||||
package errno
|
||||
|
||||
var CAPI = map[string]struct{}{}
|
||||
2
vendor/modernc.org/libc/errno/capi_linux_loong64.go
generated
vendored
2
vendor/modernc.org/libc/errno/capi_linux_loong64.go
generated
vendored
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by 'ccgo errno/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o errno/errno_linux_amd64.go -pkgname errno', DO NOT EDIT.
|
||||
// Code generated by 'ccgo errno/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o errno/errno_linux_loong64.go -pkgname errno', DO NOT EDIT.
|
||||
|
||||
package errno
|
||||
|
||||
|
|
|
|||
5
vendor/modernc.org/libc/errno/capi_linux_mips64le.go
generated
vendored
Normal file
5
vendor/modernc.org/libc/errno/capi_linux_mips64le.go
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
// Code generated by 'ccgo errno/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o errno/errno_linux_amd64.go -pkgname errno', DO NOT EDIT.
|
||||
|
||||
package errno
|
||||
|
||||
var CAPI = map[string]struct{}{}
|
||||
167
vendor/modernc.org/libc/errno/errno_illumos_amd64.go
generated
vendored
Normal file
167
vendor/modernc.org/libc/errno/errno_illumos_amd64.go
generated
vendored
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
// Code generated by 'ccgo errno/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o errno/errno_illumos_amd64.go -pkgname errno', DO NOT EDIT.
|
||||
|
||||
package errno
|
||||
|
||||
import (
|
||||
"math"
|
||||
"reflect"
|
||||
"sync/atomic"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
var _ = math.Pi
|
||||
var _ reflect.Kind
|
||||
var _ atomic.Value
|
||||
var _ unsafe.Pointer
|
||||
|
||||
const (
|
||||
E2BIG = 7 // errno.h:57:1:
|
||||
EACCES = 13 // errno.h:63:1:
|
||||
EADDRINUSE = 125 // errno.h:173:1:
|
||||
EADDRNOTAVAIL = 126 // errno.h:174:1:
|
||||
EADV = 68 // errno.h:128:1:
|
||||
EAFNOSUPPORT = 124 // errno.h:171:1:
|
||||
EAGAIN = 11 // errno.h:61:1:
|
||||
EALREADY = 149 // errno.h:193:1:
|
||||
EBADE = 50 // errno.h:104:1:
|
||||
EBADF = 9 // errno.h:59:1:
|
||||
EBADFD = 81 // errno.h:143:1:
|
||||
EBADMSG = 77 // errno.h:139:1:
|
||||
EBADR = 51 // errno.h:105:1:
|
||||
EBADRQC = 54 // errno.h:108:1:
|
||||
EBADSLT = 55 // errno.h:109:1:
|
||||
EBFONT = 57 // errno.h:112:1:
|
||||
EBUSY = 16 // errno.h:66:1:
|
||||
ECANCELED = 47 // errno.h:97:1:
|
||||
ECHILD = 10 // errno.h:60:1:
|
||||
ECHRNG = 37 // errno.h:87:1:
|
||||
ECOMM = 70 // errno.h:131:1:
|
||||
ECONNABORTED = 130 // errno.h:180:1:
|
||||
ECONNREFUSED = 146 // errno.h:189:1:
|
||||
ECONNRESET = 131 // errno.h:181:1:
|
||||
EDEADLK = 45 // errno.h:95:1:
|
||||
EDEADLOCK = 56 // errno.h:110:1:
|
||||
EDESTADDRREQ = 96 // errno.h:163:1:
|
||||
EDOM = 33 // errno.h:83:1:
|
||||
EDQUOT = 49 // errno.h:101:1:
|
||||
EEXIST = 17 // errno.h:67:1:
|
||||
EFAULT = 14 // errno.h:64:1:
|
||||
EFBIG = 27 // errno.h:77:1:
|
||||
EHOSTDOWN = 147 // errno.h:190:1:
|
||||
EHOSTUNREACH = 148 // errno.h:191:1:
|
||||
EIDRM = 36 // errno.h:86:1:
|
||||
EILSEQ = 88 // errno.h:152:1:
|
||||
EINPROGRESS = 150 // errno.h:194:1:
|
||||
EINTR = 4 // errno.h:54:1:
|
||||
EINVAL = 22 // errno.h:72:1:
|
||||
EIO = 5 // errno.h:55:1:
|
||||
EISCONN = 133 // errno.h:183:1:
|
||||
EISDIR = 21 // errno.h:71:1:
|
||||
EL2HLT = 44 // errno.h:94:1:
|
||||
EL2NSYNC = 38 // errno.h:88:1:
|
||||
EL3HLT = 39 // errno.h:89:1:
|
||||
EL3RST = 40 // errno.h:90:1:
|
||||
ELIBACC = 83 // errno.h:147:1:
|
||||
ELIBBAD = 84 // errno.h:148:1:
|
||||
ELIBEXEC = 87 // errno.h:151:1:
|
||||
ELIBMAX = 86 // errno.h:150:1:
|
||||
ELIBSCN = 85 // errno.h:149:1:
|
||||
ELNRNG = 41 // errno.h:91:1:
|
||||
ELOCKUNMAPPED = 72 // errno.h:135:1:
|
||||
ELOOP = 90 // errno.h:154:1:
|
||||
EMFILE = 24 // errno.h:74:1:
|
||||
EMLINK = 31 // errno.h:81:1:
|
||||
EMSGSIZE = 97 // errno.h:164:1:
|
||||
EMULTIHOP = 74 // errno.h:138:1:
|
||||
ENAMETOOLONG = 78 // errno.h:140:1:
|
||||
ENETDOWN = 127 // errno.h:176:1:
|
||||
ENETRESET = 129 // errno.h:178:1:
|
||||
ENETUNREACH = 128 // errno.h:177:1:
|
||||
ENFILE = 23 // errno.h:73:1:
|
||||
ENOANO = 53 // errno.h:107:1:
|
||||
ENOBUFS = 132 // errno.h:182:1:
|
||||
ENOCSI = 43 // errno.h:93:1:
|
||||
ENODATA = 61 // errno.h:120:1:
|
||||
ENODEV = 19 // errno.h:69:1:
|
||||
ENOENT = 2 // errno.h:52:1:
|
||||
ENOEXEC = 8 // errno.h:58:1:
|
||||
ENOLCK = 46 // errno.h:96:1:
|
||||
ENOLINK = 67 // errno.h:127:1:
|
||||
ENOMEM = 12 // errno.h:62:1:
|
||||
ENOMSG = 35 // errno.h:85:1:
|
||||
ENONET = 64 // errno.h:124:1:
|
||||
ENOPKG = 65 // errno.h:125:1:
|
||||
ENOPROTOOPT = 99 // errno.h:166:1:
|
||||
ENOSPC = 28 // errno.h:78:1:
|
||||
ENOSR = 63 // errno.h:122:1:
|
||||
ENOSTR = 60 // errno.h:119:1:
|
||||
ENOSYS = 89 // errno.h:153:1:
|
||||
ENOTACTIVE = 73 // errno.h:137:1:
|
||||
ENOTBLK = 15 // errno.h:65:1:
|
||||
ENOTCONN = 134 // errno.h:184:1:
|
||||
ENOTDIR = 20 // errno.h:70:1:
|
||||
ENOTEMPTY = 93 // errno.h:157:1:
|
||||
ENOTRECOVERABLE = 59 // errno.h:116:1:
|
||||
ENOTSOCK = 95 // errno.h:162:1:
|
||||
ENOTSUP = 48 // errno.h:98:1:
|
||||
ENOTTY = 25 // errno.h:75:1:
|
||||
ENOTUNIQ = 80 // errno.h:142:1:
|
||||
ENXIO = 6 // errno.h:56:1:
|
||||
EOPNOTSUPP = 122 // errno.h:169:1:
|
||||
EOVERFLOW = 79 // errno.h:141:1:
|
||||
EOWNERDEAD = 58 // errno.h:115:1:
|
||||
EPERM = 1 // errno.h:51:1:
|
||||
EPFNOSUPPORT = 123 // errno.h:170:1:
|
||||
EPIPE = 32 // errno.h:82:1:
|
||||
EPROTO = 71 // errno.h:132:1:
|
||||
EPROTONOSUPPORT = 120 // errno.h:167:1:
|
||||
EPROTOTYPE = 98 // errno.h:165:1:
|
||||
ERANGE = 34 // errno.h:84:1:
|
||||
EREMCHG = 82 // errno.h:144:1:
|
||||
EREMOTE = 66 // errno.h:126:1:
|
||||
ERESTART = 91 // errno.h:155:1:
|
||||
EROFS = 30 // errno.h:80:1:
|
||||
ESHUTDOWN = 143 // errno.h:186:1:
|
||||
ESOCKTNOSUPPORT = 121 // errno.h:168:1:
|
||||
ESPIPE = 29 // errno.h:79:1:
|
||||
ESRCH = 3 // errno.h:53:1:
|
||||
ESRMNT = 69 // errno.h:129:1:
|
||||
ESTALE = 151 // errno.h:197:1:
|
||||
ESTRPIPE = 92 // errno.h:156:1:
|
||||
ETIME = 62 // errno.h:121:1:
|
||||
ETIMEDOUT = 145 // errno.h:188:1:
|
||||
ETOOMANYREFS = 144 // errno.h:187:1:
|
||||
ETXTBSY = 26 // errno.h:76:1:
|
||||
EUNATCH = 42 // errno.h:92:1:
|
||||
EUSERS = 94 // errno.h:158:1:
|
||||
EWOULDBLOCK = 11 // errno.h:192:1:
|
||||
EXDEV = 18 // errno.h:68:1:
|
||||
EXFULL = 52 // errno.h:106:1:
|
||||
X_ERRNO_H = 0 // errno.h:33:1:
|
||||
X_FILE_OFFSET_BITS = 64 // <builtin>:25:1:
|
||||
X_LP64 = 1 // <predefined>:286:1:
|
||||
X_SYS_ERRNO_H = 0 // errno.h:41:1:
|
||||
Sun = 1 // <predefined>:172:1:
|
||||
Unix = 1 // <predefined>:175:1:
|
||||
)
|
||||
|
||||
type Ptrdiff_t = int64 /* <builtin>:3:26 */
|
||||
|
||||
type Size_t = uint64 /* <builtin>:9:23 */
|
||||
|
||||
type Wchar_t = int32 /* <builtin>:15:24 */
|
||||
|
||||
type X__int128_t = struct {
|
||||
Flo int64
|
||||
Fhi int64
|
||||
} /* <builtin>:21:43 */ // must match modernc.org/mathutil.Int128
|
||||
type X__uint128_t = struct {
|
||||
Flo uint64
|
||||
Fhi uint64
|
||||
} /* <builtin>:22:44 */ // must match modernc.org/mathutil.Int128
|
||||
|
||||
type X__builtin_va_list = uintptr /* <builtin>:46:14 */
|
||||
type X__float128 = float64 /* <builtin>:47:21 */
|
||||
// ANSI C++ requires that errno be a macro
|
||||
|
||||
var _ int8 /* gen.c:2:13: */
|
||||
311
vendor/modernc.org/libc/errno/errno_linux_loong64.go
generated
vendored
311
vendor/modernc.org/libc/errno/errno_linux_loong64.go
generated
vendored
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by 'ccgo errno/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o errno/errno_linux_amd64.go -pkgname errno', DO NOT EDIT.
|
||||
// Code generated by 'ccgo errno/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o errno/errno_linux_loong64.go -pkgname errno', DO NOT EDIT.
|
||||
|
||||
package errno
|
||||
|
||||
|
|
@ -15,155 +15,166 @@ var _ atomic.Value
|
|||
var _ unsafe.Pointer
|
||||
|
||||
const (
|
||||
E2BIG = 7 // errno-base.h:11:1:
|
||||
EACCES = 13 // errno-base.h:17:1:
|
||||
EADDRINUSE = 98 // errno.h:81:1:
|
||||
EADDRNOTAVAIL = 99 // errno.h:82:1:
|
||||
EADV = 68 // errno.h:51:1:
|
||||
EAFNOSUPPORT = 97 // errno.h:80:1:
|
||||
EAGAIN = 11 // errno-base.h:15:1:
|
||||
EALREADY = 114 // errno.h:97:1:
|
||||
EBADE = 52 // errno.h:33:1:
|
||||
EBADF = 9 // errno-base.h:13:1:
|
||||
EBADFD = 77 // errno.h:60:1:
|
||||
EBADMSG = 74 // errno.h:57:1:
|
||||
EBADR = 53 // errno.h:34:1:
|
||||
EBADRQC = 56 // errno.h:37:1:
|
||||
EBADSLT = 57 // errno.h:38:1:
|
||||
EBFONT = 59 // errno.h:42:1:
|
||||
EBUSY = 16 // errno-base.h:20:1:
|
||||
ECANCELED = 125 // errno.h:109:1:
|
||||
ECHILD = 10 // errno-base.h:14:1:
|
||||
ECHRNG = 44 // errno.h:25:1:
|
||||
ECOMM = 70 // errno.h:53:1:
|
||||
ECONNABORTED = 103 // errno.h:86:1:
|
||||
ECONNREFUSED = 111 // errno.h:94:1:
|
||||
ECONNRESET = 104 // errno.h:87:1:
|
||||
EDEADLK = 35 // errno.h:7:1:
|
||||
EDEADLOCK = 35 // errno.h:40:1:
|
||||
EDESTADDRREQ = 89 // errno.h:72:1:
|
||||
EDOM = 33 // errno-base.h:37:1:
|
||||
EDOTDOT = 73 // errno.h:56:1:
|
||||
EDQUOT = 122 // errno.h:105:1:
|
||||
EEXIST = 17 // errno-base.h:21:1:
|
||||
EFAULT = 14 // errno-base.h:18:1:
|
||||
EFBIG = 27 // errno-base.h:31:1:
|
||||
EHOSTDOWN = 112 // errno.h:95:1:
|
||||
EHOSTUNREACH = 113 // errno.h:96:1:
|
||||
EHWPOISON = 133 // errno.h:121:1:
|
||||
EIDRM = 43 // errno.h:24:1:
|
||||
EILSEQ = 84 // errno.h:67:1:
|
||||
EINPROGRESS = 115 // errno.h:98:1:
|
||||
EINTR = 4 // errno-base.h:8:1:
|
||||
EINVAL = 22 // errno-base.h:26:1:
|
||||
EIO = 5 // errno-base.h:9:1:
|
||||
EISCONN = 106 // errno.h:89:1:
|
||||
EISDIR = 21 // errno-base.h:25:1:
|
||||
EISNAM = 120 // errno.h:103:1:
|
||||
EKEYEXPIRED = 127 // errno.h:111:1:
|
||||
EKEYREJECTED = 129 // errno.h:113:1:
|
||||
EKEYREVOKED = 128 // errno.h:112:1:
|
||||
EL2HLT = 51 // errno.h:32:1:
|
||||
EL2NSYNC = 45 // errno.h:26:1:
|
||||
EL3HLT = 46 // errno.h:27:1:
|
||||
EL3RST = 47 // errno.h:28:1:
|
||||
ELIBACC = 79 // errno.h:62:1:
|
||||
ELIBBAD = 80 // errno.h:63:1:
|
||||
ELIBEXEC = 83 // errno.h:66:1:
|
||||
ELIBMAX = 82 // errno.h:65:1:
|
||||
ELIBSCN = 81 // errno.h:64:1:
|
||||
ELNRNG = 48 // errno.h:29:1:
|
||||
ELOOP = 40 // errno.h:21:1:
|
||||
EMEDIUMTYPE = 124 // errno.h:108:1:
|
||||
EMFILE = 24 // errno-base.h:28:1:
|
||||
EMLINK = 31 // errno-base.h:35:1:
|
||||
EMSGSIZE = 90 // errno.h:73:1:
|
||||
EMULTIHOP = 72 // errno.h:55:1:
|
||||
ENAMETOOLONG = 36 // errno.h:8:1:
|
||||
ENAVAIL = 119 // errno.h:102:1:
|
||||
ENETDOWN = 100 // errno.h:83:1:
|
||||
ENETRESET = 102 // errno.h:85:1:
|
||||
ENETUNREACH = 101 // errno.h:84:1:
|
||||
ENFILE = 23 // errno-base.h:27:1:
|
||||
ENOANO = 55 // errno.h:36:1:
|
||||
ENOBUFS = 105 // errno.h:88:1:
|
||||
ENOCSI = 50 // errno.h:31:1:
|
||||
ENODATA = 61 // errno.h:44:1:
|
||||
ENODEV = 19 // errno-base.h:23:1:
|
||||
ENOENT = 2 // errno-base.h:6:1:
|
||||
ENOEXEC = 8 // errno-base.h:12:1:
|
||||
ENOKEY = 126 // errno.h:110:1:
|
||||
ENOLCK = 37 // errno.h:9:1:
|
||||
ENOLINK = 67 // errno.h:50:1:
|
||||
ENOMEDIUM = 123 // errno.h:107:1:
|
||||
ENOMEM = 12 // errno-base.h:16:1:
|
||||
ENOMSG = 42 // errno.h:23:1:
|
||||
ENONET = 64 // errno.h:47:1:
|
||||
ENOPKG = 65 // errno.h:48:1:
|
||||
ENOPROTOOPT = 92 // errno.h:75:1:
|
||||
ENOSPC = 28 // errno-base.h:32:1:
|
||||
ENOSR = 63 // errno.h:46:1:
|
||||
ENOSTR = 60 // errno.h:43:1:
|
||||
ENOSYS = 38 // errno.h:18:1:
|
||||
ENOTBLK = 15 // errno-base.h:19:1:
|
||||
ENOTCONN = 107 // errno.h:90:1:
|
||||
ENOTDIR = 20 // errno-base.h:24:1:
|
||||
ENOTEMPTY = 39 // errno.h:20:1:
|
||||
ENOTNAM = 118 // errno.h:101:1:
|
||||
ENOTRECOVERABLE = 131 // errno.h:117:1:
|
||||
ENOTSOCK = 88 // errno.h:71:1:
|
||||
ENOTSUP = 95 // errno.h:30:1:
|
||||
ENOTTY = 25 // errno-base.h:29:1:
|
||||
ENOTUNIQ = 76 // errno.h:59:1:
|
||||
ENXIO = 6 // errno-base.h:10:1:
|
||||
EOPNOTSUPP = 95 // errno.h:78:1:
|
||||
EOVERFLOW = 75 // errno.h:58:1:
|
||||
EOWNERDEAD = 130 // errno.h:116:1:
|
||||
EPERM = 1 // errno-base.h:5:1:
|
||||
EPFNOSUPPORT = 96 // errno.h:79:1:
|
||||
EPIPE = 32 // errno-base.h:36:1:
|
||||
EPROTO = 71 // errno.h:54:1:
|
||||
EPROTONOSUPPORT = 93 // errno.h:76:1:
|
||||
EPROTOTYPE = 91 // errno.h:74:1:
|
||||
ERANGE = 34 // errno-base.h:38:1:
|
||||
EREMCHG = 78 // errno.h:61:1:
|
||||
EREMOTE = 66 // errno.h:49:1:
|
||||
EREMOTEIO = 121 // errno.h:104:1:
|
||||
ERESTART = 85 // errno.h:68:1:
|
||||
ERFKILL = 132 // errno.h:119:1:
|
||||
EROFS = 30 // errno-base.h:34:1:
|
||||
ESHUTDOWN = 108 // errno.h:91:1:
|
||||
ESOCKTNOSUPPORT = 94 // errno.h:77:1:
|
||||
ESPIPE = 29 // errno-base.h:33:1:
|
||||
ESRCH = 3 // errno-base.h:7:1:
|
||||
ESRMNT = 69 // errno.h:52:1:
|
||||
ESTALE = 116 // errno.h:99:1:
|
||||
ESTRPIPE = 86 // errno.h:69:1:
|
||||
ETIME = 62 // errno.h:45:1:
|
||||
ETIMEDOUT = 110 // errno.h:93:1:
|
||||
ETOOMANYREFS = 109 // errno.h:92:1:
|
||||
ETXTBSY = 26 // errno-base.h:30:1:
|
||||
EUCLEAN = 117 // errno.h:100:1:
|
||||
EUNATCH = 49 // errno.h:30:1:
|
||||
EUSERS = 87 // errno.h:70:1:
|
||||
EWOULDBLOCK = 11 // errno.h:22:1:
|
||||
EXDEV = 18 // errno-base.h:22:1:
|
||||
EXFULL = 54 // errno.h:35:1:
|
||||
X_ASM_GENERIC_ERRNO_BASE_H = 0 // errno-base.h:3:1:
|
||||
X_ASM_GENERIC_ERRNO_H = 0 // errno.h:3:1:
|
||||
X_ATFILE_SOURCE = 1 // features.h:342:1:
|
||||
X_BITS_ERRNO_H = 1 // errno.h:20:1:
|
||||
X_DEFAULT_SOURCE = 1 // features.h:227:1:
|
||||
X_ERRNO_H = 1 // errno.h:23:1:
|
||||
X_FEATURES_H = 1 // features.h:19:1:
|
||||
X_FILE_OFFSET_BITS = 64 // <builtin>:25:1:
|
||||
X_LP64 = 1 // <predefined>:284:1:
|
||||
X_POSIX_C_SOURCE = 200809 // features.h:281:1:
|
||||
X_POSIX_SOURCE = 1 // features.h:279:1:
|
||||
X_STDC_PREDEF_H = 1 // <predefined>:162:1:
|
||||
X_SYS_CDEFS_H = 1 // cdefs.h:19:1:
|
||||
Linux = 1 // <predefined>:231:1:
|
||||
Unix = 1 // <predefined>:177:1:
|
||||
E2BIG = 7 // errno-base.h:11:1:
|
||||
EACCES = 13 // errno-base.h:17:1:
|
||||
EADDRINUSE = 98 // errno.h:81:1:
|
||||
EADDRNOTAVAIL = 99 // errno.h:82:1:
|
||||
EADV = 68 // errno.h:51:1:
|
||||
EAFNOSUPPORT = 97 // errno.h:80:1:
|
||||
EAGAIN = 11 // errno-base.h:15:1:
|
||||
EALREADY = 114 // errno.h:97:1:
|
||||
EBADE = 52 // errno.h:33:1:
|
||||
EBADF = 9 // errno-base.h:13:1:
|
||||
EBADFD = 77 // errno.h:60:1:
|
||||
EBADMSG = 74 // errno.h:57:1:
|
||||
EBADR = 53 // errno.h:34:1:
|
||||
EBADRQC = 56 // errno.h:37:1:
|
||||
EBADSLT = 57 // errno.h:38:1:
|
||||
EBFONT = 59 // errno.h:42:1:
|
||||
EBUSY = 16 // errno-base.h:20:1:
|
||||
ECANCELED = 125 // errno.h:109:1:
|
||||
ECHILD = 10 // errno-base.h:14:1:
|
||||
ECHRNG = 44 // errno.h:25:1:
|
||||
ECOMM = 70 // errno.h:53:1:
|
||||
ECONNABORTED = 103 // errno.h:86:1:
|
||||
ECONNREFUSED = 111 // errno.h:94:1:
|
||||
ECONNRESET = 104 // errno.h:87:1:
|
||||
EDEADLK = 35 // errno.h:7:1:
|
||||
EDEADLOCK = 35 // errno.h:40:1:
|
||||
EDESTADDRREQ = 89 // errno.h:72:1:
|
||||
EDOM = 33 // errno-base.h:37:1:
|
||||
EDOTDOT = 73 // errno.h:56:1:
|
||||
EDQUOT = 122 // errno.h:105:1:
|
||||
EEXIST = 17 // errno-base.h:21:1:
|
||||
EFAULT = 14 // errno-base.h:18:1:
|
||||
EFBIG = 27 // errno-base.h:31:1:
|
||||
EHOSTDOWN = 112 // errno.h:95:1:
|
||||
EHOSTUNREACH = 113 // errno.h:96:1:
|
||||
EHWPOISON = 133 // errno.h:121:1:
|
||||
EIDRM = 43 // errno.h:24:1:
|
||||
EILSEQ = 84 // errno.h:67:1:
|
||||
EINPROGRESS = 115 // errno.h:98:1:
|
||||
EINTR = 4 // errno-base.h:8:1:
|
||||
EINVAL = 22 // errno-base.h:26:1:
|
||||
EIO = 5 // errno-base.h:9:1:
|
||||
EISCONN = 106 // errno.h:89:1:
|
||||
EISDIR = 21 // errno-base.h:25:1:
|
||||
EISNAM = 120 // errno.h:103:1:
|
||||
EKEYEXPIRED = 127 // errno.h:111:1:
|
||||
EKEYREJECTED = 129 // errno.h:113:1:
|
||||
EKEYREVOKED = 128 // errno.h:112:1:
|
||||
EL2HLT = 51 // errno.h:32:1:
|
||||
EL2NSYNC = 45 // errno.h:26:1:
|
||||
EL3HLT = 46 // errno.h:27:1:
|
||||
EL3RST = 47 // errno.h:28:1:
|
||||
ELIBACC = 79 // errno.h:62:1:
|
||||
ELIBBAD = 80 // errno.h:63:1:
|
||||
ELIBEXEC = 83 // errno.h:66:1:
|
||||
ELIBMAX = 82 // errno.h:65:1:
|
||||
ELIBSCN = 81 // errno.h:64:1:
|
||||
ELNRNG = 48 // errno.h:29:1:
|
||||
ELOOP = 40 // errno.h:21:1:
|
||||
EMEDIUMTYPE = 124 // errno.h:108:1:
|
||||
EMFILE = 24 // errno-base.h:28:1:
|
||||
EMLINK = 31 // errno-base.h:35:1:
|
||||
EMSGSIZE = 90 // errno.h:73:1:
|
||||
EMULTIHOP = 72 // errno.h:55:1:
|
||||
ENAMETOOLONG = 36 // errno.h:8:1:
|
||||
ENAVAIL = 119 // errno.h:102:1:
|
||||
ENETDOWN = 100 // errno.h:83:1:
|
||||
ENETRESET = 102 // errno.h:85:1:
|
||||
ENETUNREACH = 101 // errno.h:84:1:
|
||||
ENFILE = 23 // errno-base.h:27:1:
|
||||
ENOANO = 55 // errno.h:36:1:
|
||||
ENOBUFS = 105 // errno.h:88:1:
|
||||
ENOCSI = 50 // errno.h:31:1:
|
||||
ENODATA = 61 // errno.h:44:1:
|
||||
ENODEV = 19 // errno-base.h:23:1:
|
||||
ENOENT = 2 // errno-base.h:6:1:
|
||||
ENOEXEC = 8 // errno-base.h:12:1:
|
||||
ENOKEY = 126 // errno.h:110:1:
|
||||
ENOLCK = 37 // errno.h:9:1:
|
||||
ENOLINK = 67 // errno.h:50:1:
|
||||
ENOMEDIUM = 123 // errno.h:107:1:
|
||||
ENOMEM = 12 // errno-base.h:16:1:
|
||||
ENOMSG = 42 // errno.h:23:1:
|
||||
ENONET = 64 // errno.h:47:1:
|
||||
ENOPKG = 65 // errno.h:48:1:
|
||||
ENOPROTOOPT = 92 // errno.h:75:1:
|
||||
ENOSPC = 28 // errno-base.h:32:1:
|
||||
ENOSR = 63 // errno.h:46:1:
|
||||
ENOSTR = 60 // errno.h:43:1:
|
||||
ENOSYS = 38 // errno.h:18:1:
|
||||
ENOTBLK = 15 // errno-base.h:19:1:
|
||||
ENOTCONN = 107 // errno.h:90:1:
|
||||
ENOTDIR = 20 // errno-base.h:24:1:
|
||||
ENOTEMPTY = 39 // errno.h:20:1:
|
||||
ENOTNAM = 118 // errno.h:101:1:
|
||||
ENOTRECOVERABLE = 131 // errno.h:117:1:
|
||||
ENOTSOCK = 88 // errno.h:71:1:
|
||||
ENOTSUP = 95 // errno.h:30:1:
|
||||
ENOTTY = 25 // errno-base.h:29:1:
|
||||
ENOTUNIQ = 76 // errno.h:59:1:
|
||||
ENXIO = 6 // errno-base.h:10:1:
|
||||
EOPNOTSUPP = 95 // errno.h:78:1:
|
||||
EOVERFLOW = 75 // errno.h:58:1:
|
||||
EOWNERDEAD = 130 // errno.h:116:1:
|
||||
EPERM = 1 // errno-base.h:5:1:
|
||||
EPFNOSUPPORT = 96 // errno.h:79:1:
|
||||
EPIPE = 32 // errno-base.h:36:1:
|
||||
EPROTO = 71 // errno.h:54:1:
|
||||
EPROTONOSUPPORT = 93 // errno.h:76:1:
|
||||
EPROTOTYPE = 91 // errno.h:74:1:
|
||||
ERANGE = 34 // errno-base.h:38:1:
|
||||
EREMCHG = 78 // errno.h:61:1:
|
||||
EREMOTE = 66 // errno.h:49:1:
|
||||
EREMOTEIO = 121 // errno.h:104:1:
|
||||
ERESTART = 85 // errno.h:68:1:
|
||||
ERFKILL = 132 // errno.h:119:1:
|
||||
EROFS = 30 // errno-base.h:34:1:
|
||||
ESHUTDOWN = 108 // errno.h:91:1:
|
||||
ESOCKTNOSUPPORT = 94 // errno.h:77:1:
|
||||
ESPIPE = 29 // errno-base.h:33:1:
|
||||
ESRCH = 3 // errno-base.h:7:1:
|
||||
ESRMNT = 69 // errno.h:52:1:
|
||||
ESTALE = 116 // errno.h:99:1:
|
||||
ESTRPIPE = 86 // errno.h:69:1:
|
||||
ETIME = 62 // errno.h:45:1:
|
||||
ETIMEDOUT = 110 // errno.h:93:1:
|
||||
ETOOMANYREFS = 109 // errno.h:92:1:
|
||||
ETXTBSY = 26 // errno-base.h:30:1:
|
||||
EUCLEAN = 117 // errno.h:100:1:
|
||||
EUNATCH = 49 // errno.h:30:1:
|
||||
EUSERS = 87 // errno.h:70:1:
|
||||
EWOULDBLOCK = 11 // errno.h:22:1:
|
||||
EXDEV = 18 // errno-base.h:22:1:
|
||||
EXFULL = 54 // errno.h:35:1:
|
||||
X_ABILP64 = 3 // <predefined>:377:1:
|
||||
X_ASM_GENERIC_ERRNO_BASE_H = 0 // errno-base.h:3:1:
|
||||
X_ASM_GENERIC_ERRNO_H = 0 // errno.h:3:1:
|
||||
X_ATFILE_SOURCE = 1 // features.h:353:1:
|
||||
X_BITS_ERRNO_H = 1 // errno.h:20:1:
|
||||
X_DEFAULT_SOURCE = 1 // features.h:238:1:
|
||||
X_ERRNO_H = 1 // errno.h:23:1:
|
||||
X_FEATURES_H = 1 // features.h:19:1:
|
||||
X_FILE_OFFSET_BITS = 64 // <builtin>:25:1:
|
||||
X_LOONGARCH_ARCH = "loongarch64" // <predefined>:214:1:
|
||||
X_LOONGARCH_ARCH_LOONGARCH64 = 1 // <predefined>:340:1:
|
||||
X_LOONGARCH_FPSET = 32 // <predefined>:265:1:
|
||||
X_LOONGARCH_SIM = 3 // <predefined>:233:1:
|
||||
X_LOONGARCH_SPFPSET = 32 // <predefined>:88:1:
|
||||
X_LOONGARCH_SZINT = 32 // <predefined>:230:1:
|
||||
X_LOONGARCH_SZLONG = 64 // <predefined>:388:1:
|
||||
X_LOONGARCH_SZPTR = 64 // <predefined>:200:1:
|
||||
X_LOONGARCH_TUNE = "la464" // <predefined>:245:1:
|
||||
X_LOONGARCH_TUNE_LA464 = 1 // <predefined>:63:1:
|
||||
X_LP64 = 1 // <predefined>:372:1:
|
||||
X_POSIX_C_SOURCE = 200809 // features.h:292:1:
|
||||
X_POSIX_SOURCE = 1 // features.h:290:1:
|
||||
X_STDC_PREDEF_H = 1 // <predefined>:223:1:
|
||||
X_SYS_CDEFS_H = 1 // cdefs.h:20:1:
|
||||
Linux = 1 // <predefined>:308:1:
|
||||
Unix = 1 // <predefined>:247:1:
|
||||
)
|
||||
|
||||
type Ptrdiff_t = int64 /* <builtin>:3:26 */
|
||||
|
|
|
|||
187
vendor/modernc.org/libc/errno/errno_linux_mips64le.go
generated
vendored
Normal file
187
vendor/modernc.org/libc/errno/errno_linux_mips64le.go
generated
vendored
Normal file
|
|
@ -0,0 +1,187 @@
|
|||
// Code generated by 'ccgo errno/gen.c -crt-import-path "" -export-defines "" -export-enums "" -export-externs X -export-fields F -export-structs "" -export-typedefs "" -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o errno/errno_linux_amd64.go -pkgname errno', DO NOT EDIT.
|
||||
|
||||
package errno
|
||||
|
||||
import (
|
||||
"math"
|
||||
"reflect"
|
||||
"sync/atomic"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
var _ = math.Pi
|
||||
var _ reflect.Kind
|
||||
var _ atomic.Value
|
||||
var _ unsafe.Pointer
|
||||
|
||||
const (
|
||||
E2BIG = 7 // errno-base.h:11:1:
|
||||
EACCES = 13 // errno-base.h:17:1:
|
||||
EADDRINUSE = 98 // errno.h:81:1:
|
||||
EADDRNOTAVAIL = 99 // errno.h:82:1:
|
||||
EADV = 68 // errno.h:51:1:
|
||||
EAFNOSUPPORT = 97 // errno.h:80:1:
|
||||
EAGAIN = 11 // errno-base.h:15:1:
|
||||
EALREADY = 114 // errno.h:97:1:
|
||||
EBADE = 52 // errno.h:33:1:
|
||||
EBADF = 9 // errno-base.h:13:1:
|
||||
EBADFD = 77 // errno.h:60:1:
|
||||
EBADMSG = 74 // errno.h:57:1:
|
||||
EBADR = 53 // errno.h:34:1:
|
||||
EBADRQC = 56 // errno.h:37:1:
|
||||
EBADSLT = 57 // errno.h:38:1:
|
||||
EBFONT = 59 // errno.h:42:1:
|
||||
EBUSY = 16 // errno-base.h:20:1:
|
||||
ECANCELED = 125 // errno.h:109:1:
|
||||
ECHILD = 10 // errno-base.h:14:1:
|
||||
ECHRNG = 44 // errno.h:25:1:
|
||||
ECOMM = 70 // errno.h:53:1:
|
||||
ECONNABORTED = 103 // errno.h:86:1:
|
||||
ECONNREFUSED = 111 // errno.h:94:1:
|
||||
ECONNRESET = 104 // errno.h:87:1:
|
||||
EDEADLK = 35 // errno.h:7:1:
|
||||
EDEADLOCK = 35 // errno.h:40:1:
|
||||
EDESTADDRREQ = 89 // errno.h:72:1:
|
||||
EDOM = 33 // errno-base.h:37:1:
|
||||
EDOTDOT = 73 // errno.h:56:1:
|
||||
EDQUOT = 122 // errno.h:105:1:
|
||||
EEXIST = 17 // errno-base.h:21:1:
|
||||
EFAULT = 14 // errno-base.h:18:1:
|
||||
EFBIG = 27 // errno-base.h:31:1:
|
||||
EHOSTDOWN = 112 // errno.h:95:1:
|
||||
EHOSTUNREACH = 113 // errno.h:96:1:
|
||||
EHWPOISON = 133 // errno.h:121:1:
|
||||
EIDRM = 43 // errno.h:24:1:
|
||||
EILSEQ = 84 // errno.h:67:1:
|
||||
EINPROGRESS = 115 // errno.h:98:1:
|
||||
EINTR = 4 // errno-base.h:8:1:
|
||||
EINVAL = 22 // errno-base.h:26:1:
|
||||
EIO = 5 // errno-base.h:9:1:
|
||||
EISCONN = 106 // errno.h:89:1:
|
||||
EISDIR = 21 // errno-base.h:25:1:
|
||||
EISNAM = 120 // errno.h:103:1:
|
||||
EKEYEXPIRED = 127 // errno.h:111:1:
|
||||
EKEYREJECTED = 129 // errno.h:113:1:
|
||||
EKEYREVOKED = 128 // errno.h:112:1:
|
||||
EL2HLT = 51 // errno.h:32:1:
|
||||
EL2NSYNC = 45 // errno.h:26:1:
|
||||
EL3HLT = 46 // errno.h:27:1:
|
||||
EL3RST = 47 // errno.h:28:1:
|
||||
ELIBACC = 79 // errno.h:62:1:
|
||||
ELIBBAD = 80 // errno.h:63:1:
|
||||
ELIBEXEC = 83 // errno.h:66:1:
|
||||
ELIBMAX = 82 // errno.h:65:1:
|
||||
ELIBSCN = 81 // errno.h:64:1:
|
||||
ELNRNG = 48 // errno.h:29:1:
|
||||
ELOOP = 40 // errno.h:21:1:
|
||||
EMEDIUMTYPE = 124 // errno.h:108:1:
|
||||
EMFILE = 24 // errno-base.h:28:1:
|
||||
EMLINK = 31 // errno-base.h:35:1:
|
||||
EMSGSIZE = 90 // errno.h:73:1:
|
||||
EMULTIHOP = 72 // errno.h:55:1:
|
||||
ENAMETOOLONG = 36 // errno.h:8:1:
|
||||
ENAVAIL = 119 // errno.h:102:1:
|
||||
ENETDOWN = 100 // errno.h:83:1:
|
||||
ENETRESET = 102 // errno.h:85:1:
|
||||
ENETUNREACH = 101 // errno.h:84:1:
|
||||
ENFILE = 23 // errno-base.h:27:1:
|
||||
ENOANO = 55 // errno.h:36:1:
|
||||
ENOBUFS = 105 // errno.h:88:1:
|
||||
ENOCSI = 50 // errno.h:31:1:
|
||||
ENODATA = 61 // errno.h:44:1:
|
||||
ENODEV = 19 // errno-base.h:23:1:
|
||||
ENOENT = 2 // errno-base.h:6:1:
|
||||
ENOEXEC = 8 // errno-base.h:12:1:
|
||||
ENOKEY = 126 // errno.h:110:1:
|
||||
ENOLCK = 37 // errno.h:9:1:
|
||||
ENOLINK = 67 // errno.h:50:1:
|
||||
ENOMEDIUM = 123 // errno.h:107:1:
|
||||
ENOMEM = 12 // errno-base.h:16:1:
|
||||
ENOMSG = 42 // errno.h:23:1:
|
||||
ENONET = 64 // errno.h:47:1:
|
||||
ENOPKG = 65 // errno.h:48:1:
|
||||
ENOPROTOOPT = 92 // errno.h:75:1:
|
||||
ENOSPC = 28 // errno-base.h:32:1:
|
||||
ENOSR = 63 // errno.h:46:1:
|
||||
ENOSTR = 60 // errno.h:43:1:
|
||||
ENOSYS = 38 // errno.h:18:1:
|
||||
ENOTBLK = 15 // errno-base.h:19:1:
|
||||
ENOTCONN = 107 // errno.h:90:1:
|
||||
ENOTDIR = 20 // errno-base.h:24:1:
|
||||
ENOTEMPTY = 39 // errno.h:20:1:
|
||||
ENOTNAM = 118 // errno.h:101:1:
|
||||
ENOTRECOVERABLE = 131 // errno.h:117:1:
|
||||
ENOTSOCK = 88 // errno.h:71:1:
|
||||
ENOTSUP = 95 // errno.h:30:1:
|
||||
ENOTTY = 25 // errno-base.h:29:1:
|
||||
ENOTUNIQ = 76 // errno.h:59:1:
|
||||
ENXIO = 6 // errno-base.h:10:1:
|
||||
EOPNOTSUPP = 95 // errno.h:78:1:
|
||||
EOVERFLOW = 75 // errno.h:58:1:
|
||||
EOWNERDEAD = 130 // errno.h:116:1:
|
||||
EPERM = 1 // errno-base.h:5:1:
|
||||
EPFNOSUPPORT = 96 // errno.h:79:1:
|
||||
EPIPE = 32 // errno-base.h:36:1:
|
||||
EPROTO = 71 // errno.h:54:1:
|
||||
EPROTONOSUPPORT = 93 // errno.h:76:1:
|
||||
EPROTOTYPE = 91 // errno.h:74:1:
|
||||
ERANGE = 34 // errno-base.h:38:1:
|
||||
EREMCHG = 78 // errno.h:61:1:
|
||||
EREMOTE = 66 // errno.h:49:1:
|
||||
EREMOTEIO = 121 // errno.h:104:1:
|
||||
ERESTART = 85 // errno.h:68:1:
|
||||
ERFKILL = 132 // errno.h:119:1:
|
||||
EROFS = 30 // errno-base.h:34:1:
|
||||
ESHUTDOWN = 108 // errno.h:91:1:
|
||||
ESOCKTNOSUPPORT = 94 // errno.h:77:1:
|
||||
ESPIPE = 29 // errno-base.h:33:1:
|
||||
ESRCH = 3 // errno-base.h:7:1:
|
||||
ESRMNT = 69 // errno.h:52:1:
|
||||
ESTALE = 116 // errno.h:99:1:
|
||||
ESTRPIPE = 86 // errno.h:69:1:
|
||||
ETIME = 62 // errno.h:45:1:
|
||||
ETIMEDOUT = 110 // errno.h:93:1:
|
||||
ETOOMANYREFS = 109 // errno.h:92:1:
|
||||
ETXTBSY = 26 // errno-base.h:30:1:
|
||||
EUCLEAN = 117 // errno.h:100:1:
|
||||
EUNATCH = 49 // errno.h:30:1:
|
||||
EUSERS = 87 // errno.h:70:1:
|
||||
EWOULDBLOCK = 11 // errno.h:22:1:
|
||||
EXDEV = 18 // errno-base.h:22:1:
|
||||
EXFULL = 54 // errno.h:35:1:
|
||||
X_ASM_GENERIC_ERRNO_BASE_H = 0 // errno-base.h:3:1:
|
||||
X_ASM_GENERIC_ERRNO_H = 0 // errno.h:3:1:
|
||||
X_ATFILE_SOURCE = 1 // features.h:342:1:
|
||||
X_BITS_ERRNO_H = 1 // errno.h:20:1:
|
||||
X_DEFAULT_SOURCE = 1 // features.h:227:1:
|
||||
X_ERRNO_H = 1 // errno.h:23:1:
|
||||
X_FEATURES_H = 1 // features.h:19:1:
|
||||
X_FILE_OFFSET_BITS = 64 // <builtin>:25:1:
|
||||
X_LP64 = 1 // <predefined>:284:1:
|
||||
X_POSIX_C_SOURCE = 200809 // features.h:281:1:
|
||||
X_POSIX_SOURCE = 1 // features.h:279:1:
|
||||
X_STDC_PREDEF_H = 1 // <predefined>:162:1:
|
||||
X_SYS_CDEFS_H = 1 // cdefs.h:19:1:
|
||||
Linux = 1 // <predefined>:231:1:
|
||||
Unix = 1 // <predefined>:177:1:
|
||||
)
|
||||
|
||||
type Ptrdiff_t = int64 /* <builtin>:3:26 */
|
||||
|
||||
type Size_t = uint64 /* <builtin>:9:23 */
|
||||
|
||||
type Wchar_t = int32 /* <builtin>:15:24 */
|
||||
|
||||
type X__int128_t = struct {
|
||||
Flo int64
|
||||
Fhi int64
|
||||
} /* <builtin>:21:43 */ // must match modernc.org/mathutil.Int128
|
||||
type X__uint128_t = struct {
|
||||
Flo uint64
|
||||
Fhi uint64
|
||||
} /* <builtin>:22:44 */ // must match modernc.org/mathutil.Int128
|
||||
|
||||
type X__builtin_va_list = uintptr /* <builtin>:46:14 */
|
||||
type X__float128 = float64 /* <builtin>:47:21 */
|
||||
|
||||
var _ int8 /* gen.c:2:13: */
|
||||
5
vendor/modernc.org/libc/fcntl/capi_illumos_amd64.go
generated
vendored
Normal file
5
vendor/modernc.org/libc/fcntl/capi_illumos_amd64.go
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
// Code generated by 'ccgo fcntl/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o fcntl/fcntl_illumos_amd64.go -pkgname fcntl', DO NOT EDIT.
|
||||
|
||||
package fcntl
|
||||
|
||||
var CAPI = map[string]struct{}{}
|
||||
2
vendor/modernc.org/libc/fcntl/capi_linux_loong64.go
generated
vendored
2
vendor/modernc.org/libc/fcntl/capi_linux_loong64.go
generated
vendored
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by 'ccgo fcntl/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o fcntl/fcntl_linux_amd64.go -pkgname fcntl', DO NOT EDIT.
|
||||
// Code generated by 'ccgo fcntl/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o fcntl/fcntl_linux_loong64.go -pkgname fcntl', DO NOT EDIT.
|
||||
|
||||
package fcntl
|
||||
|
||||
|
|
|
|||
5
vendor/modernc.org/libc/fcntl/capi_linux_mips64le.go
generated
vendored
Normal file
5
vendor/modernc.org/libc/fcntl/capi_linux_mips64le.go
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
// Code generated by 'ccgo fcntl/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o fcntl/fcntl_linux_amd64.go -pkgname fcntl', DO NOT EDIT.
|
||||
|
||||
package fcntl
|
||||
|
||||
var CAPI = map[string]struct{}{}
|
||||
3242
vendor/modernc.org/libc/fcntl/fcntl_illumos_amd64.go
generated
vendored
Normal file
3242
vendor/modernc.org/libc/fcntl/fcntl_illumos_amd64.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
709
vendor/modernc.org/libc/fcntl/fcntl_linux_loong64.go
generated
vendored
709
vendor/modernc.org/libc/fcntl/fcntl_linux_loong64.go
generated
vendored
File diff suppressed because it is too large
Load diff
1087
vendor/modernc.org/libc/fcntl/fcntl_linux_mips64le.go
generated
vendored
Normal file
1087
vendor/modernc.org/libc/fcntl/fcntl_linux_mips64le.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
5
vendor/modernc.org/libc/fts/capi_illumos_amd64.go
generated
vendored
Normal file
5
vendor/modernc.org/libc/fts/capi_illumos_amd64.go
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
// Code generated by 'ccgo fts/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o fts/fts_illumos_amd64.go -pkgname fts', DO NOT EDIT.
|
||||
|
||||
package fts
|
||||
|
||||
var CAPI = map[string]struct{}{}
|
||||
2
vendor/modernc.org/libc/fts/capi_linux_loong64.go
generated
vendored
2
vendor/modernc.org/libc/fts/capi_linux_loong64.go
generated
vendored
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by 'ccgo fts/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o fts/fts_linux_amd64.go -pkgname fts', DO NOT EDIT.
|
||||
// Code generated by 'ccgo fts/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o fts/fts_linux_loong64.go -pkgname fts', DO NOT EDIT.
|
||||
|
||||
package fts
|
||||
|
||||
|
|
|
|||
5
vendor/modernc.org/libc/fts/capi_linux_mips64le.go
generated
vendored
Normal file
5
vendor/modernc.org/libc/fts/capi_linux_mips64le.go
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
// Code generated by 'ccgo fts/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o fts/fts_linux_amd64.go -pkgname fts', DO NOT EDIT.
|
||||
|
||||
package fts
|
||||
|
||||
var CAPI = map[string]struct{}{}
|
||||
3038
vendor/modernc.org/libc/fts/fts_illumos_amd64.go
generated
vendored
Normal file
3038
vendor/modernc.org/libc/fts/fts_illumos_amd64.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
996
vendor/modernc.org/libc/fts/fts_linux_loong64.go
generated
vendored
996
vendor/modernc.org/libc/fts/fts_linux_loong64.go
generated
vendored
File diff suppressed because it is too large
Load diff
1904
vendor/modernc.org/libc/fts/fts_linux_mips64le.go
generated
vendored
Normal file
1904
vendor/modernc.org/libc/fts/fts_linux_mips64le.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
5
vendor/modernc.org/libc/grp/capi_illumos_amd64.go
generated
vendored
Normal file
5
vendor/modernc.org/libc/grp/capi_illumos_amd64.go
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
// Code generated by 'ccgo grp/gen.c -crt-import-path -export-defines -export-enums -export-externs X -export-fields F -export-structs -export-typedefs -header -hide _OSSwapInt16,_OSSwapInt32,_OSSwapInt64 -ignore-unsupported-alignment -o grp/grp_illumos_amd64.go -pkgname grp', DO NOT EDIT.
|
||||
|
||||
package grp
|
||||
|
||||
var CAPI = map[string]struct{}{}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue