[chore] Downgrade sqlite v1.29.2 -> v1.28.0 (#2736)

* [chore] Downgrade sqlite v1.29.2 -> v1.29.0

* go down to v1.28.0
This commit is contained in:
tobi 2024-03-08 11:45:15 +01:00 committed by GitHub
commit ebdee5aed8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
117 changed files with 1835338 additions and 2454288 deletions

20
vendor/modernc.org/cc/v3/AUTHORS generated vendored Normal file
View file

@ -0,0 +1,20 @@
# 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>
Huang Qiqi <huangqiqi@loongson.cn>
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>

20
vendor/modernc.org/cc/v3/CONTRIBUTORS generated vendored Normal file
View file

@ -0,0 +1,20 @@
# 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>
Huang Qiqi <huangqiqi@loongson.cn>
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>

27
vendor/modernc.org/cc/v3/LICENSE generated vendored Normal file
View file

@ -0,0 +1,27 @@
Copyright (c) 2017 The CC 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/cc/v3/Makefile generated vendored Normal file
View file

@ -0,0 +1,141 @@
# 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=linux GOARCH=loong64 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_linux_loong64:
GOOS=linux GOARCH=loong64 make test
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=illumos GOARCH=amd64 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=loong64 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=386 go build -v ./...
GOOS=netbsd GOARCH=amd64 go build -v ./...
GOOS=netbsd GOARCH=arm go build -v ./...
GOOS=openbsd GOARCH=386 go build -v ./...
GOOS=openbsd GOARCH=amd64 go build -v ./...
GOOS=openbsd GOARCH=arm64 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 Normal file
View file

@ -0,0 +1,11 @@
# 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 Normal file

File diff suppressed because it is too large Load diff

870
vendor/modernc.org/cc/v3/abi_platforms.go generated vendored Normal file
View file

@ -0,0 +1,870 @@
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,
"loong64": 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,
{"openbsd", "arm64"}: false,
{"darwin", "amd64"}: true,
{"darwin", "arm64"}: true,
{"freebsd", "386"}: true,
{"freebsd", "amd64"}: true,
{"illumos", "amd64"}: true,
{"linux", "386"}: true,
{"linux", "amd64"}: true,
{"linux", "loong64"}: true,
{"netbsd", "386"}: true,
{"netbsd", "amd64"}: true,
{"openbsd", "386"}: true,
{"openbsd", "amd64"}: 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},
},
// gcc (Loongnix 8.3.0-6.lnd.vec.33) 8.3.0
{"linux", "loong64"}: {
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},
},
// gcc (OmniOS 151044/12.2.0-il-0) 12.2.0
{"illumos", "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},
},
}

5232
vendor/modernc.org/cc/v3/ast.go generated vendored Normal file

File diff suppressed because it is too large Load diff

1187
vendor/modernc.org/cc/v3/ast2.go generated vendored Normal file

File diff suppressed because it is too large Load diff

1057
vendor/modernc.org/cc/v3/cc.go generated vendored Normal file

File diff suppressed because it is too large Load diff

5276
vendor/modernc.org/cc/v3/check.go generated vendored Normal file

File diff suppressed because it is too large Load diff

3101
vendor/modernc.org/cc/v3/cpp.go generated vendored Normal file

File diff suppressed because it is too large Load diff

84
vendor/modernc.org/cc/v3/enum.go generated vendored Normal file
View file

@ -0,0 +1,84 @@
// 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 Normal file
View file

@ -0,0 +1,156 @@
// 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 Normal file
View file

@ -0,0 +1,632 @@
// 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 Normal file

File diff suppressed because it is too large Load diff

97
vendor/modernc.org/cc/v3/lexer.l generated vendored Normal file
View file

@ -0,0 +1,97 @@
%{
// 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 Normal file

File diff suppressed because it is too large Load diff

4311
vendor/modernc.org/cc/v3/parser.go generated vendored Normal file

File diff suppressed because it is too large Load diff

1033
vendor/modernc.org/cc/v3/parser.yy generated vendored Normal file

File diff suppressed because it is too large Load diff

1266
vendor/modernc.org/cc/v3/scanner.go generated vendored Normal file

File diff suppressed because it is too large Load diff

99
vendor/modernc.org/cc/v3/stringer.go generated vendored Normal file
View file

@ -0,0 +1,99 @@
// 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 Normal file

File diff suppressed because it is too large Load diff

4
vendor/modernc.org/cc/v3/unconvert.sh generated vendored Normal file
View file

@ -0,0 +1,4 @@
until unconvert -fastmath . &> /dev/null
do
unconvert -fastmath -apply . &> /dev/null
done

27
vendor/modernc.org/ccgo/v3/LICENSE generated vendored Normal file
View file

@ -0,0 +1,27 @@
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 Normal file
View file

@ -0,0 +1,141 @@
# 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 Normal file

File diff suppressed because it is too large Load diff

39
vendor/modernc.org/ccgo/v3/lib/cover.go generated vendored Normal file
View file

@ -0,0 +1,39 @@
// 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 Normal file
View file

@ -0,0 +1,91 @@
= 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 Normal file
View file

@ -0,0 +1,43 @@
// 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 Normal file
View file

@ -0,0 +1,110 @@
// 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
}
}
}

13228
vendor/modernc.org/ccgo/v3/lib/go.go generated vendored Normal file

File diff suppressed because it is too large Load diff

553
vendor/modernc.org/ccgo/v3/lib/init.go generated vendored Normal file
View file

@ -0,0 +1,553 @@
// 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 Normal file
View file

@ -0,0 +1,10 @@
// 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 Normal file
View file

@ -0,0 +1,20 @@
// 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 Normal file
View file

@ -0,0 +1,12 @@
// 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 Normal file
View file

@ -0,0 +1,58 @@
// 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 Normal file
View file

@ -0,0 +1,4 @@
until unconvert -fastmath . &> /dev/null
do
unconvert -fastmath -apply . &> /dev/null
done

488
vendor/modernc.org/ccgo/v3/lib/util.go generated vendored Normal file
View file

@ -0,0 +1,488 @@
// 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
}
if info.Mode()&os.ModeSymlink != 0 {
target, err := filepath.EvalSymlinks(path)
if err != nil {
return fmt.Errorf("cannot evaluate symlink %s: %v", path, err)
}
if info, err = os.Stat(target); err != nil {
return fmt.Errorf("cannot stat %s: %v", target, err)
}
if info.IsDir() {
rel, err := filepath.Rel(src, path)
if err != nil {
return err
}
dst2 := filepath.Join(dst, rel)
if err := os.MkdirAll(dst2, 0770); err != nil {
return err
}
f, b, err := CopyDir(dst2, target, canOverwrite)
files += f
bytes += b
return err
}
path = target
}
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
}

69
vendor/modernc.org/gc/v3/LICENSE generated vendored
View file

@ -1,69 +0,0 @@
-------------------------------------------------------------------------------
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
View file

@ -1,113 +0,0 @@
.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
View file

@ -1,682 +0,0 @@
// 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
View file

@ -1,598 +0,0 @@
// 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
View file

@ -1,559 +0,0 @@
// 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 &parallel{
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
View file

@ -1,761 +0,0 @@
// 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

File diff suppressed because it is too large Load diff

1446
vendor/modernc.org/gc/v3/scanner.go generated vendored

File diff suppressed because it is too large Load diff

115
vendor/modernc.org/gc/v3/stringer.go generated vendored
View file

@ -1,115 +0,0 @@
// 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
View file

@ -1,90 +0,0 @@
// 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
View file

@ -1,813 +0,0 @@
// 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
View file

@ -1,716 +0,0 @@
// 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
}

11
vendor/modernc.org/opt/AUTHORS generated vendored Normal file
View file

@ -0,0 +1,11 @@
# 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.
Jan Mercl <0xjnml@gmail.com>

9
vendor/modernc.org/opt/CONTRIBUTORS generated vendored Normal file
View file

@ -0,0 +1,9 @@
# 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.
Jan Mercl <0xjnml@gmail.com>

27
vendor/modernc.org/opt/LICENSE generated vendored Normal file
View file

@ -0,0 +1,27 @@
Copyright (c) 2019 The Opt 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.

18
vendor/modernc.org/opt/Makefile generated vendored Normal file
View file

@ -0,0 +1,18 @@
# Copyright 2022 The Opt 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: clean edit editor
clean:
rm -f log-* cpu.test mem.test *.out
go clean
edit:
@touch log
@if [ -f "Session.vim" ]; then gvim -S & else gvim -p Makefile *.go & fi
editor:
gofmt -l -s -w *.go
go test -o /dev/null -c
go install 2>&1 | tee log-editor

11
vendor/modernc.org/opt/README.md generated vendored Normal file
View file

@ -0,0 +1,11 @@
# opt
Package opt implements command-line flag parsing.
### Installation
$ go get [-u] modernc.org/opt
### Documentation
[godoc.org/modernc.org/opt](http://godoc.org/modernc.org/opt)

155
vendor/modernc.org/opt/opt.go generated vendored Normal file
View file

@ -0,0 +1,155 @@
// Package opt implements command-line flag parsing.
package opt // import "modernc.org/opt"
import (
"fmt"
"strings"
)
type opt struct {
handler func(opt, arg string) error
name string
arg bool // Enable argument, e.g. `-I foo` or `-I=foo`
}
// A Set represents a set of defined options.
type Set struct {
cfg map[string]*opt
imm []*opt
}
// NewSet returns a new, empty option set.
func NewSet() *Set { return &Set{cfg: map[string]*opt{}} }
// Opt defines a simple option, e.g. `-f`. When the option is found during
// Parse, the handler is called with the value of the option, e.g. "-f".
func (p *Set) Opt(name string, handler func(opt string) error) {
p.cfg[name] = &opt{
handler: func(opt, arg string) error { return handler(opt) },
}
}
// Arg defines a simple option with an argument, e.g. `-I foo` or `-I=foo`.
// Setting imm argument enables additionally `-Ifoo`. When the option is found
// during Parse, the handler is called with the values of the option and the
// argument, e.g. "-I" and "foo" for all of the variants.
func (p *Set) Arg(name string, imm bool, handler func(opt, arg string) error) {
switch {
case imm:
p.imm = append(p.imm, &opt{
handler: handler,
name: name,
})
default:
p.cfg[name] = &opt{
arg: true,
handler: handler,
name: name,
}
}
}
// Parse parses opts. Must be called after all options are defined. The handler
// is called for all items in opts that were not defined before using Opt or
// Arg.
//
// If any handler returns a non-nil error, Parse will stop. If the error is of
// type Skip, the error returned by Parse will contain all the unprocessed
// items of opts.
//
// The opts slice must not be modified by any handler while Parser is
// executing.
func (p *Set) Parse(opts []string, handler func(string) error) (err error) {
defer func() {
switch err.(type) {
case Skip:
err = Skip(opts)
}
}()
for len(opts) != 0 {
opt := opts[0]
opt0 := opt
opts = opts[1:]
var arg string
out:
switch {
case strings.HasPrefix(opt, "-"):
name := opt[1:]
for _, cfg := range p.imm {
if strings.HasPrefix(name, cfg.name) {
switch {
case name == cfg.name:
if len(opts) == 0 {
return fmt.Errorf("missing argument of %s", opt)
}
if err = cfg.handler(opt, opts[0]); err != nil {
return err
}
opts = opts[1:]
default:
opt = opt[:len(cfg.name)+1]
val := strings.TrimPrefix(name[len(cfg.name):], "=")
if err = cfg.handler(opt, val); err != nil {
return err
}
}
break out
}
}
if n := strings.IndexByte(opt, '='); n > 0 {
arg = opt[n+1:]
name = opt[1:n]
opt = opt[:n]
}
switch cfg := p.cfg[name]; {
case cfg == nil:
if err = handler(opt0); err != nil {
return err
}
default:
switch {
case cfg.arg:
switch {
case arg != "":
if err = cfg.handler(opt, arg); err != nil {
return err
}
default:
if len(opts) == 0 {
return fmt.Errorf("missing argument of %s", opt)
}
if err = cfg.handler(opt, opts[0]); err != nil {
return err
}
opts = opts[1:]
}
default:
if err = cfg.handler(opt, ""); err != nil {
return err
}
}
}
default:
if opt == "" {
break
}
if err = handler(opt); err != nil {
return err
}
}
}
return nil
}
// Skip is an error that contains all unprocessed items passed to Parse.
type Skip []string
func (s Skip) Error() string { return fmt.Sprint([]string(s)) }

4
vendor/modernc.org/opt/unconvert.sh generated vendored Normal file
View file

@ -0,0 +1,4 @@
until unconvert -fastmath . &> /dev/null
do
unconvert -fastmath -apply . &> /dev/null
done

231
vendor/modernc.org/sqlite/Makefile generated vendored
View file

@ -1,12 +1,42 @@
# Copyright 2024 The Sqlite Authors. All rights reserved.
# Copyright 2017 The Sqlite 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 build_all_targets clean edit editor test vendor work
.PHONY: all clean cover cpu editor internalError later mem nuke todo edit tcl extraquick full tidy uncomment unconvert
grep=--include=*.go --include=*.l --include=*.y --include=*.yy
ngrep='TODOOK\|internal\/vfs\|internal\/bin\|internal\/mptest\|.*stringer.*\.go'
host=$(shell go env GOOS)-$(shell go env GOARCH)
testlog=testdata/testlog-$(shell echo $$GOOS)-$(shell echo $$GOARCH)$(shell echo $$SQLITE_TEST_SUFFIX)
all: editor
golint 2>&1
staticcheck 2>&1
date
go version 2>&1 | tee log
./unconvert.sh
gofmt -l -s -w *.go
go test -i
go test -v 2>&1 -timeout 24h | tee -a log
go run speedtest1/main_$(shell go env GOOS)_$(shell go env GOARCH).go
golint 2>&1 | grep -v $(ngrep) || true
misspell *.go
staticcheck || true
maligned || true
git diff --unified=0 testdata *.golden
grep -n --color=always 'FAIL\|PASS' log
go version
date 2>&1 | tee -a log
# $ go install modernc.org/uncomment@latest
uncomment:
uncomment -v -gofmt libtest/sqlite*.go internal/mptest/main*.go internal/testfixture/testfixture*.go speedtest1/main*.go vfs/vfs*.go
uncomment -v -gofmt -keep-godoc lib/sqlite*.go
# $ go install github.com/mdempsky/unconvert@latest
unconvert:
./unconvert.sh && echo ok || echo fail
tidy: uncomment unconvert
gofmt -l -s -w .
build_all_targets:
GOOS=darwin GOARCH=amd64 go test -c -o /dev/null
@ -30,34 +60,183 @@ build_all_targets:
GOOS=windows GOARCH=arm64 go test -c -o /dev/null
echo done
# 3900x
windows_amd64:
@echo "Should be executed only on linux/amd64."
CCGO_CPP=x86_64-w64-mingw32-cpp TARGET_GOOS=windows TARGET_GOARCH=amd64 go generate 2>&1 | tee log-generate
GOOS=windows GOARCH=amd64 go test -c -o /dev/null
windows_arm64:
go run addport.go windows_amd64 windows_arm64
GOOS=windows GOARCH=arm64 go test -c -o /dev/null
# 3900x
windows_386:
@echo "Should be executed only on linux/amd64."
CCGO_CPP=i686-w64-mingw32-cpp TARGET_GOOS=windows TARGET_GOARCH=386 go generate 2>&1 | tee log-generate
GOOS=windows GOARCH=386 go test -c -o /dev/null
# 3900x/qemu
darwin_amd64:
@echo "Should be executed only on darwin/amd64."
go generate 2>&1 | tee log-generate
go test -c -o /dev/null
# 3900x/qemu
netbsd_amd64:
@echo "Should be executed only on netbsd/amd64."
go generate 2>&1 | tee log-generate
go test -c -o /dev/null
# darwin-m1
darwin_arm64:
@echo "Should be executed only on darwin/arm64."
go generate 2>&1 | tee log-generate
go test -c -o /dev/null
# 3900x/qemu
freebsd_amd64:
@echo "Should be executed only on freebsd/amd64."
go generate 2>&1 | tee log-generate
go test -c -o /dev/null
freebsd_arm64:
go run addport.go freebsd_amd64 freebsd_arm64
GOOS=freebsd GOARCH=arm64 go test -c -o /dev/null
# 3900x/qemu
freebsd_386:
@echo "Should be executed only on freebsd/386."
go generate 2>&1 | tee log-generate
go test -c -o /dev/null
# 3900x/qemu
freebsd_arm:
@echo "Should be executed only on freebsd/arm."
go generate 2>&1 | tee log-generate
go test -c -o /dev/null
# 3900x
linux_amd64:
@echo "Should be executed only on linux/amd64."
go generate 2>&1 | tee log-generate
go test -c -o /dev/null
# 3900x
linux_386:
@echo "Should be executed only on linux/amd64."
CCGO_CPP=i686-linux-gnu-cpp TARGET_GOARCH=386 TARGET_GOOS=linux go generate 2>&1 | tee log-generate
GOOS=linux GOARCH=386 go test -c -o /dev/null
# 3900x
linux_arm:
@echo "Should be executed only on linux/amd64."
CCGO_CPP=arm-linux-gnueabi-cpp TARGET_GOARCH=arm TARGET_GOOS=linux go generate 2>&1 | tee log-generate
GOOS=linux GOARCH=arm go test -c -o /dev/null
# 3900x
linux_arm64:
@echo "Should be executed only on linux/amd64."
CCGO_CPP=aarch64-linux-gnu-cpp TARGET_GOARCH=arm64 TARGET_GOOS=linux go generate 2>&1 | tee log-generate
GOOS=linux GOARCH=arm64 go test -c -o /dev/null
# 3900x
linux_ppc64le:
@echo "Should be executed only on linux/amd64."
CCGO_CPP=powerpc64le-linux-gnu-cpp TARGET_GOARCH=ppc64le TARGET_GOOS=linux go generate 2>&1 | tee log-generate
GOOS=linux GOARCH=ppc64le go test -c -o /dev/null
# linux/riscv64
linux_riscv64:
@echo "Should be executed only on linux/amd64."
CCGO_CPP=riscv64-linux-gnu-cpp TARGET_GOARCH=riscv64 TARGET_GOOS=linux go generate 2>&1 | tee log-generate
GOOS=linux GOARCH=riscv64 go test -c -o /dev/null
# 3900x
linux_s390x:
@echo "Should be executed only on linux/amd64."
CCGO_CPP=s390x-linux-gnu-cpp TARGET_GOARCH=s390x TARGET_GOOS=linux go generate 2>&1 | tee log-generate
GOOS=linux GOARCH=s390x go test -c -o /dev/null
# 3900x/qemu
openbsd_amd64:
@echo "Should be executed only on openbsd/amd64."
go generate 2>&1 | tee log-generate
go test -c -o /dev/null
# 3900x/qemu
openbsd_arm64:
@echo "Should be executed only on openbsd/arm64."
GOGC=10 GOMEMLIMIT=6GiB go generate 2>&1 | tee log-generate
go test -c -o /dev/null
generate_all_targets_on_linux_amd64: linux_amd64 linux_386 linux_arm linux_arm64 linux_s390x linux_ppc64le linux_riscv64 windows_amd64 windows_arm64 #TODO windows_386
gofmt -l -s -w .
echo done
tcl_test_wine:
GOOS=windows GOARCH=amd64 go build -o testfixture.exe modernc.org/sqlite/internal/testfixture
run_tcl_test_wine:
TCL_LIBRARY=Z:/home/jnml/src/modernc.org/tcl/assets wine testfixture.exe ./testdata/tcl/zipfile.test
extraquick:
go test -timeout 24h -v -failfast -suite extraquick -maxerror 1 2>&1 | tee log-extraquick
date
full:
go test -timeout 24h -v -run Tcl -suite full 2>&1 | tee log-full
date
clean:
rm -f log-* cpu.test mem.test *.out go.work*
go clean
rm -f *~ *.test *.out test.db* tt4-test*.db* test_sv.* testdb-*
cover:
t=$(shell tempfile) ; 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 novim -S & else novim -p Makefile all_test.go generator.go & fi
@if [ -f "Session.vim" ]; then gvim -S & else gvim -p Makefile all_test.go sqlite.go & fi
editor:
gofmt -l -s -w . 2>&1 | tee log-editor
go test -c -o /dev/null 2>&1 | tee -a log-editor
go build -v -o /dev/null ./... 2>&1 | tee -a log-editor
go build -o /dev/null migrate.go
gofmt -l -s -w *.go
go install -v ./...
go test -c -o /dev/null -tags=cgo,cgotest
test:
go test -v -timeout 24h 2>&1 | tee log-test
vendor:
go run vendor_libsqlite3.go && make build_all_targets
internalError:
egrep -ho '"internal error.*"' *.go | sort | cat -n
work:
rm -f go.work*
go work init
go work use .
go work use ../cc/v4
go work use ../ccgo/v3
go work use ../ccgo/v4
go work use ../libc
go work use ../libtcl8.6
go work use ../libsqlite3
go work use ../libz
later:
@grep -n $(grep) LATER * || true
@grep -n $(grep) MAYBE * || true
mem: clean
go test -run @ -bench . -memprofile mem.out -memprofilerate 1 -timeout 24h
go tool pprof -lines -web -alloc_space *.test mem.out
memgrind:
go test -v -timeout 24h -tags libc.memgrind,cgobench -bench . -suite extraquick -xtags=libc.memgrind
regression_base_release:
GO111MODULE=on go test -v -timeout 24h -tags=cgobench -run @ -bench '(Reading1|InsertComparative)/sqlite[^3]' -recs_per_sec_as_mbps 2>&1 | tee log-regression-base
regression_base_master:
GO111MODULE=off go test -v -timeout 24h -tags=cgobench -run @ -bench '(Reading1|InsertComparative)/sqlite[^3]' -recs_per_sec_as_mbps 2>&1 | tee log-regression-base
regression_check:
GO111MODULE=off go test -v -timeout 24h -tags=cgobench -run @ -bench '(Reading1|InsertComparative)/sqlite[^3]' -recs_per_sec_as_mbps 2>&1 | tee log-regression
benchcmp -changed -mag log-regression-base log-regression
nuke: clean
go clean -i
todo:
@grep -nr $(grep) ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* * | grep -v $(ngrep) || true
@grep -nr $(grep) TODO * | grep -v $(ngrep) || true
@grep -nr $(grep) BUG * | grep -v $(ngrep) || true
@grep -nr $(grep) [^[:alpha:]]println * | grep -v $(ngrep) || true

85
vendor/modernc.org/sqlite/doc.go generated vendored
View file

@ -19,19 +19,19 @@
//
// OS Arch SQLite version
// ------------------------------
// darwin amd64 3.45.1
// darwin arm64 3.45.1
// freebsd amd64 3.45.1
// freebsd arm64 3.45.1
// linux 386 3.45.1
// linux amd64 3.45.1
// linux arm 3.45.1
// linux arm64 3.45.1
// linux ppc64le 3.45.1
// linux riscv64 3.45.1
// linux s390x 3.45.1
// windows amd64 3.45.1
// windows arm64 3.45.1
// darwin amd64 3.41.2
// darwin arm64 3.41.2
// freebsd amd64 3.41.2
// freebsd arm64 3.41.2
// linux 386 3.41.2
// linux amd64 3.41.2
// linux arm 3.41.2
// linux arm64 3.41.2
// linux ppc64le 3.41.2
// linux riscv64 3.41.2
// linux s390x 3.41.2
// windows amd64 3.41.2
// windows arm64 3.41.2
//
// # Builders
//
@ -39,13 +39,62 @@
//
// https://modern-c.appspot.com/-/builder/?importpath=modernc.org%2fsqlite
//
// # Speedtest1
//
// Numbers for the pure Go version were produced by
//
// ~/src/modernc.org/sqlite/speedtest1$ go build && ./speedtest1
//
// Numbers for the pure C version were produced by
//
// ~/src/modernc.org/sqlite/testdata/sqlite-src-3410200/test$ gcc speedtest1.c ../../sqlite-amalgamation-3410200/sqlite3.c -lpthread -ldl && ./a.out
//
// The results are from Go version 1.20.4 and GCC version 10.2.1 on a
// Linux/amd64 machine, CPU: AMD Ryzen 9 3900X 12-Core Processor × 24, 128GB
// RAM. Shown are the best of 3 runs.
//
// Go C
//
// -- Speedtest1 for SQLite 3.41.2 2023-03-22 11:56:21 0d1fc92f94cb6b76bffe3ec34d69 -- Speedtest1 for SQLite 3.41.2 2023-03-22 11:56:21 0d1fc92f94cb6b76bffe3ec34d69
// 100 - 50000 INSERTs into table with no index...................... 0.071s 100 - 50000 INSERTs into table with no index...................... 0.077s
// 110 - 50000 ordered INSERTS with one index/PK..................... 0.114s 110 - 50000 ordered INSERTS with one index/PK..................... 0.082s
// 120 - 50000 unordered INSERTS with one index/PK................... 0.137s 120 - 50000 unordered INSERTS with one index/PK................... 0.099s
// 130 - 25 SELECTS, numeric BETWEEN, unindexed...................... 0.083s 130 - 25 SELECTS, numeric BETWEEN, unindexed...................... 0.091s
// 140 - 10 SELECTS, LIKE, unindexed................................. 0.210s 140 - 10 SELECTS, LIKE, unindexed................................. 0.120s
// 142 - 10 SELECTS w/ORDER BY, unindexed............................ 0.276s 142 - 10 SELECTS w/ORDER BY, unindexed............................ 0.182s
// 145 - 10 SELECTS w/ORDER BY and LIMIT, unindexed.................. 0.183s 145 - 10 SELECTS w/ORDER BY and LIMIT, unindexed.................. 0.099s
// 150 - CREATE INDEX five times..................................... 0.172s 150 - CREATE INDEX five times..................................... 0.127s
// 160 - 10000 SELECTS, numeric BETWEEN, indexed..................... 0.080s 160 - 10000 SELECTS, numeric BETWEEN, indexed..................... 0.078s
// 161 - 10000 SELECTS, numeric BETWEEN, PK.......................... 0.080s 161 - 10000 SELECTS, numeric BETWEEN, PK.......................... 0.078s
// 170 - 10000 SELECTS, text BETWEEN, indexed........................ 0.187s 170 - 10000 SELECTS, text BETWEEN, indexed........................ 0.169s
// 180 - 50000 INSERTS with three indexes............................ 0.196s 180 - 50000 INSERTS with three indexes............................ 0.154s
// 190 - DELETE and REFILL one table................................. 0.200s 190 - DELETE and REFILL one table................................. 0.155s
// 200 - VACUUM...................................................... 0.180s 200 - VACUUM...................................................... 0.142s
// 210 - ALTER TABLE ADD COLUMN, and query........................... 0.004s 210 - ALTER TABLE ADD COLUMN, and query........................... 0.005s
// 230 - 10000 UPDATES, numeric BETWEEN, indexed..................... 0.093s 230 - 10000 UPDATES, numeric BETWEEN, indexed..................... 0.080s
// 240 - 50000 UPDATES of individual rows............................ 0.153s 240 - 50000 UPDATES of individual rows............................ 0.137s
// 250 - One big UPDATE of the whole 50000-row table................. 0.024s 250 - One big UPDATE of the whole 50000-row table................. 0.019s
// 260 - Query added column after filling............................ 0.004s 260 - Query added column after filling............................ 0.005s
// 270 - 10000 DELETEs, numeric BETWEEN, indexed..................... 0.278s 270 - 10000 DELETEs, numeric BETWEEN, indexed..................... 0.263s
// 280 - 50000 DELETEs of individual rows............................ 0.188s 280 - 50000 DELETEs of individual rows............................ 0.180s
// 290 - Refill two 50000-row tables using REPLACE................... 0.411s 290 - Refill two 50000-row tables using REPLACE................... 0.359s
// 300 - Refill a 50000-row table using (b&1)==(a&1)................. 0.175s 300 - Refill a 50000-row table using (b&1)==(a&1)................. 0.151s
// 310 - 10000 four-ways joins....................................... 0.427s 310 - 10000 four-ways joins....................................... 0.365s
// 320 - subquery in result set...................................... 0.440s 320 - subquery in result set...................................... 0.521s
// 400 - 70000 REPLACE ops on an IPK................................. 0.125s 400 - 70000 REPLACE ops on an IPK................................. 0.106s
// 410 - 70000 SELECTS on an IPK..................................... 0.081s 410 - 70000 SELECTS on an IPK..................................... 0.078s
// 500 - 70000 REPLACE on TEXT PK.................................... 0.174s 500 - 70000 REPLACE on TEXT PK.................................... 0.116s
// 510 - 70000 SELECTS on a TEXT PK.................................. 0.153s 510 - 70000 SELECTS on a TEXT PK.................................. 0.117s
// 520 - 70000 SELECT DISTINCT....................................... 0.083s 520 - 70000 SELECT DISTINCT....................................... 0.067s
// 980 - PRAGMA integrity_check...................................... 0.436s 980 - PRAGMA integrity_check...................................... 0.377s
// 990 - ANALYZE..................................................... 0.107s 990 - ANALYZE..................................................... 0.038s
// TOTAL....................................................... 5.525s TOTAL....................................................... 4.637s
//
// This particular test executes 16.1% faster in the C version.
//
// # Changelog
//
// 2024-02-13: v1.29.0
//
// Upgrade to SQLite 3.45.1, release notes at https://sqlite.org/releaselog/3_45_1.html.
//
// 2023-12-14 v1.28.0:
// 2023-12-14 v1.28.0:
//
// (*Driver).RegisterConnectionHook: added
// ConnectionHookFn: added

887
vendor/modernc.org/sqlite/generator.go generated vendored Normal file
View file

@ -0,0 +1,887 @@
// Copyright 2017 The Sqlite 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 generator
// +build generator
//TODO 2023-02-23, netbsd/amd64 fails generating SQLite 3.41:
//
// C front end 36/85: testdata/sqlite-src-3410000/ext/recover/sqlite3recover.c ... testdata/sqlite-src-3410000/ext/recover/sqlite3recover.c:2023:41: front-end: undefined: SQLITE_FCNTL_RESET_CACHE
package main
import (
"archive/zip"
"bufio"
"bytes"
"flag"
"fmt"
"io"
"net/http"
"os"
"os/exec"
"path/filepath"
"runtime"
"sort"
"strings"
"modernc.org/ccgo/v3/lib"
)
// gcc
// -g
// -O2
// -DSQLITE_OS_UNIX=1
// -I.
// -I/home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src
// -I/home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/rtree
// -I/home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/icu
// -I/home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/fts3
// -I/home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/async
// -I/home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/session
// -I/home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/userauth
// -D_HAVE_SQLITE_CONFIG_H
// -DBUILD_sqlite
// -DNDEBUG
// -I/usr/include/tcl8.6
// -DSQLITE_THREADSAFE=1
// -DSQLITE_HAVE_ZLIB=1
// -DSQLITE_NO_SYNC=1
// -DSQLITE_TEMP_STORE=1
// -DSQLITE_TEST=1
// -DSQLITE_CRASH_TEST=1
// -DTCLSH_INIT_PROC=sqlite3TestInit
// -DSQLITE_SERVER=1
// -DSQLITE_PRIVATE=
// -DSQLITE_CORE
// -DBUILD_sqlite
// -DSQLITE_SERIES_CONSTRAINT_VERIFY=1
// -DSQLITE_DEFAULT_PAGE_SIZE=1024
// -DSQLITE_ENABLE_STMTVTAB
// -DSQLITE_ENABLE_DBPAGE_VTAB
// -DSQLITE_ENABLE_BYTECODE_VTAB
// -DSQLITE_ENABLE_DESERIALIZE
// -o testfixture
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test1.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test2.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test3.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test4.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test5.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test6.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test7.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test8.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test9.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_autoext.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_async.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_backup.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_bestindex.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_blob.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_btree.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_config.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_delete.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_demovfs.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_devsym.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_fs.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_func.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_hexio.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_init.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_intarray.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_journal.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_malloc.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_md5.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_multiplex.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_mutex.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_onefile.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_osinst.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_pcache.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_quota.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_rtree.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_schema.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_server.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_superlock.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_syscall.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_tclsh.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_tclvar.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_thread.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_vdbecov.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_vfs.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_windirent.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_window.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_wsd.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/fts3/fts3_term.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/fts3/fts3_test.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/session/test_session.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/rbu/test_rbu.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/expert/sqlite3expert.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/expert/test_expert.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/amatch.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/carray.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/closure.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/csv.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/decimal.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/eval.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/explain.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/fileio.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/fuzzer.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/fts5/fts5_tcl.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/fts5/fts5_test_mi.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/fts5/fts5_test_tok.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/ieee754.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/mmapwarm.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/nextchar.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/normalize.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/percentile.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/prefixes.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/regexp.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/remember.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/series.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/spellfix.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/totype.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/unionvtab.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/wholenumber.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/zipfile.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/userauth/userauth.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/tclsqlite.c
// sqlite3.c
// -L/usr/lib/x86_64-linux-gnu
// -ltcl8.6
// -ldl
// -lz
// -lpthread
const (
volatiles = "-volatile=sqlite3_io_error_pending,sqlite3_open_file_count,sqlite3_pager_readdb_count,sqlite3_pager_writedb_count,sqlite3_pager_writej_count,sqlite3_search_count,sqlite3_sort_count,saved_cnt,randomnessPid"
)
// 2022-11-27 Removing -DSQLITE_ENABLE_SNAPSHOT from configTest. This #define
// makes a single test fail on linux/ppc64le. That test is run only when the
// -DSQLITE_ENABLE_SNAPSHOT is present when compiling the testfixture. When
// investigating the failure it turns out this #define is actually NOT present
// when doing '$ ./configure && make tcltest' in sqlite-src-3400000, ie. in the
// original C code.
//
// libtool: link: gcc -g -O2 -DSQLITE_OS_UNIX=1 -I. -I/home/jnml/sqlite-src-3400000/src -I/home/jnml/sqlite-src-3400000/ext/rtree -I/home/jnml/sqlite-src-3400000/ext/icu -I/home/jnml/sqlite-src-3400000/ext/fts3 -I/home/jnml/sqlite-src-3400000/ext/async -I/home/jnml/sqlite-src-3400000/ext/session -I/home/jnml/sqlite-src-3400000/ext/userauth -D_HAVE_SQLITE_CONFIG_H -DBUILD_sqlite -DNDEBUG -I/usr/include/tcl8.6 -DSQLITE_THREADSAFE=1 -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_HAVE_ZLIB=1 -DSQLITE_NO_SYNC=1 -DSQLITE_TEMP_STORE=1 -DSQLITE_TEST=1 -DSQLITE_CRASH_TEST=1 -DTCLSH_INIT_PROC=sqlite3TestInit -DSQLITE_SERVER=1 -DSQLITE_PRIVATE= -DSQLITE_CORE -DBUILD_sqlite -DSQLITE_SERIES_CONSTRAINT_VERIFY=1 -DSQLITE_DEFAULT_PAGE_SIZE=1024 -DSQLITE_ENABLE_STMTVTAB -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_ENABLE_BYTECODE_VTAB -DSQLITE_CKSUMVFS_STATIC -o testfixture ...
var (
configProduction = []string{
"-DHAVE_USLEEP",
"-DLONGDOUBLE_TYPE=double",
"-DSQLITE_CORE",
"-DSQLITE_DEFAULT_MEMSTATUS=0",
"-DSQLITE_ENABLE_COLUMN_METADATA",
"-DSQLITE_ENABLE_DBSTAT_VTAB",
"-DSQLITE_ENABLE_FTS5",
"-DSQLITE_ENABLE_GEOPOLY",
"-DSQLITE_ENABLE_MATH_FUNCTIONS",
"-DSQLITE_ENABLE_MEMORY_MANAGEMENT",
"-DSQLITE_ENABLE_OFFSET_SQL_FUNC",
"-DSQLITE_ENABLE_PREUPDATE_HOOK",
"-DSQLITE_ENABLE_RBU",
"-DSQLITE_ENABLE_RTREE",
"-DSQLITE_ENABLE_SESSION",
"-DSQLITE_ENABLE_SNAPSHOT",
"-DSQLITE_ENABLE_STAT4",
"-DSQLITE_ENABLE_UNLOCK_NOTIFY", // Adds sqlite3_unlock_notify().
"-DSQLITE_LIKE_DOESNT_MATCH_BLOBS",
"-DSQLITE_MUTEX_APPDEF=1",
"-DSQLITE_MUTEX_NOOP",
"-DSQLITE_SOUNDEX",
"-DSQLITE_THREADSAFE=1",
//DONT "-DNDEBUG", // To enable GO_GENERATE=-DSQLITE_DEBUG
//DONT "-DSQLITE_DQS=0", // testfixture
//DONT "-DSQLITE_NO_SYNC=1",
//DONT "-DSQLITE_OMIT_DECLTYPE", // testfixture
//DONT "-DSQLITE_OMIT_DEPRECATED", // mptest
//DONT "-DSQLITE_OMIT_LOAD_EXTENSION", // mptest
//DONT "-DSQLITE_OMIT_SHARED_CACHE",
//DONT "-DSQLITE_USE_ALLOCA",
//TODO "-DHAVE_MALLOC_USABLE_SIZE"
//TODO "-DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1", //TODO report bug
//TODO "-DSQLITE_ENABLE_FTS3",
//TODO "-DSQLITE_ENABLE_FTS3_PARENTHESIS",
//TODO "-DSQLITE_ENABLE_FTS3_TOKENIZER",
//TODO "-DSQLITE_ENABLE_FTS4",
//TODO "-DSQLITE_ENABLE_ICU",
//TODO "-DSQLITE_MAX_EXPR_DEPTH=0", // bug reported https://sqlite.org/forum/forumpost/87b9262f66, fixed in https://sqlite.org/src/info/5f58dd3a19605b6f
//TODO "-DSQLITE_MAX_MMAP_SIZE=8589934592", // testfixture, bug reported https://sqlite.org/forum/forumpost/34380589f7, fixed in https://sqlite.org/src/info/d8e47382160e98be
//TODO- "-DSQLITE_DEBUG",
//TODO- "-DSQLITE_ENABLE_API_ARMOR",
//TODO- "-DSQLITE_MEMDEBUG",
}
configTest = []string{
"-DHAVE_USLEEP",
"-DLONGDOUBLE_TYPE=double",
"-DSQLITE_CKSUMVFS_STATIC",
"-DSQLITE_CORE", // testfixture
"-DSQLITE_DEFAULT_MEMSTATUS=1",
"-DSQLITE_DEFAULT_PAGE_SIZE=1024", // testfixture, hardcoded. See file_pages in autovacuum.test.
"-DSQLITE_ENABLE_BYTECODE_VTAB", // testfixture
"-DSQLITE_ENABLE_COLUMN_METADATA",
"-DSQLITE_ENABLE_DBPAGE_VTAB", // testfixture
"-DSQLITE_ENABLE_DBSTAT_VTAB",
"-DSQLITE_ENABLE_DESERIALIZE", // testfixture
"-DSQLITE_ENABLE_EXPLAIN_COMMENTS",
"-DSQLITE_ENABLE_FTS5",
"-DSQLITE_ENABLE_GEOPOLY",
"-DSQLITE_ENABLE_MATH_FUNCTIONS",
"-DSQLITE_ENABLE_MEMORY_MANAGEMENT",
"-DSQLITE_ENABLE_OFFSET_SQL_FUNC",
"-DSQLITE_ENABLE_PREUPDATE_HOOK",
"-DSQLITE_ENABLE_RBU",
"-DSQLITE_ENABLE_RTREE",
"-DSQLITE_ENABLE_SESSION",
"-DSQLITE_ENABLE_STAT4",
"-DSQLITE_ENABLE_STMTVTAB", // testfixture
"-DSQLITE_ENABLE_UNLOCK_NOTIFY", // Adds sqlite3_unlock_notify().
"-DSQLITE_LIKE_DOESNT_MATCH_BLOBS",
"-DSQLITE_MUTEX_APPDEF=1",
"-DSQLITE_MUTEX_NOOP",
"-DSQLITE_SOUNDEX",
"-DSQLITE_TEMP_STORE=1", // testfixture
"-DSQLITE_TEST",
"-DSQLITE_THREADSAFE=1",
//DONT "-DNDEBUG", // To enable GO_GENERATE=-DSQLITE_DEBUG
//DONT "-DSQLITE_DQS=0", // testfixture
//DONT "-DSQLITE_ENABLE_SNAPSHOT",
//DONT "-DSQLITE_NO_SYNC=1",
//DONT "-DSQLITE_OMIT_DECLTYPE", // testfixture
//DONT "-DSQLITE_OMIT_DEPRECATED", // mptest
//DONT "-DSQLITE_OMIT_LOAD_EXTENSION", // mptest
//DONT "-DSQLITE_OMIT_SHARED_CACHE",
//DONT "-DSQLITE_USE_ALLOCA",
//TODO "-DHAVE_MALLOC_USABLE_SIZE"
//TODO "-DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1", //TODO report bug
//TODO "-DSQLITE_ENABLE_FTS3",
//TODO "-DSQLITE_ENABLE_FTS3_PARENTHESIS",
//TODO "-DSQLITE_ENABLE_FTS3_TOKENIZER",
//TODO "-DSQLITE_ENABLE_FTS4",
//TODO "-DSQLITE_ENABLE_ICU",
//TODO "-DSQLITE_MAX_EXPR_DEPTH=0", // bug reported https://sqlite.org/forum/forumpost/87b9262f66, fixed in https://sqlite.org/src/info/5f58dd3a19605b6f
//TODO "-DSQLITE_MAX_MMAP_SIZE=8589934592", // testfixture, bug reported https://sqlite.org/forum/forumpost/34380589f7, fixed in https://sqlite.org/src/info/d8e47382160e98be
//TODO- "-DSQLITE_DEBUG",
//TODO- "-DSQLITE_ENABLE_API_ARMOR",
//TODO- "-DSQLITE_MEMDEBUG",
}
downloads = []struct {
dir, url string
sz int
dev bool
}{
{sqliteDir, "https://www.sqlite.org/2023/sqlite-amalgamation-3410200.zip", 2457, false},
{sqliteSrcDir, "https://www.sqlite.org/2023/sqlite-src-3410200.zip", 12814, false},
}
sqliteDir = filepath.FromSlash("testdata/sqlite-amalgamation-3410200")
sqliteSrcDir = filepath.FromSlash("testdata/sqlite-src-3410200")
)
func download() {
tmp, err := os.MkdirTemp("", "")
if err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err)
return
}
defer os.RemoveAll(tmp)
for _, v := range downloads {
dir := filepath.FromSlash(v.dir)
root := filepath.Dir(v.dir)
fi, err := os.Stat(dir)
switch {
case err == nil:
if !fi.IsDir() {
fmt.Fprintf(os.Stderr, "expected %s to be a directory\n", dir)
}
continue
default:
if !os.IsNotExist(err) {
fmt.Fprintf(os.Stderr, "%s", err)
continue
}
}
if err := func() error {
fmt.Printf("Downloading %v MB from %s\n", float64(v.sz)/1000, v.url)
resp, err := http.Get(v.url)
if err != nil {
return err
}
defer resp.Body.Close()
base := filepath.Base(v.url)
name := filepath.Join(tmp, base)
f, err := os.Create(name)
if err != nil {
return err
}
defer os.Remove(name)
n, err := io.Copy(f, resp.Body)
if err != nil {
return err
}
if _, err := f.Seek(0, io.SeekStart); err != nil {
return err
}
switch {
case strings.HasSuffix(base, ".zip"):
r, err := zip.NewReader(f, n)
if err != nil {
return err
}
for _, f := range r.File {
fi := f.FileInfo()
if fi.IsDir() {
if err := os.MkdirAll(filepath.Join(root, f.Name), 0770); err != nil {
return err
}
continue
}
if err := func() error {
rc, err := f.Open()
if err != nil {
return err
}
defer rc.Close()
file, err := os.OpenFile(filepath.Join(root, f.Name), os.O_CREATE|os.O_WRONLY, fi.Mode())
if err != nil {
return err
}
w := bufio.NewWriter(file)
if _, err = io.Copy(w, rc); err != nil {
return err
}
if err := w.Flush(); err != nil {
return err
}
return file.Close()
}(); err != nil {
return err
}
}
return nil
}
panic("internal error") //TODOOK
}(); err != nil {
fmt.Fprintln(os.Stderr, err)
}
}
}
func fail(s string, args ...interface{}) {
fmt.Fprintf(os.Stderr, s, args...)
os.Exit(1)
}
var (
oFullPathComments = flag.Bool("full-path-comments", false, "")
)
func main() {
flag.Parse()
fmt.Printf("Running on %s/%s.\n", runtime.GOOS, runtime.GOARCH)
env := os.Getenv("GO_GENERATE")
goarch := runtime.GOARCH
goos := runtime.GOOS
if s := os.Getenv("TARGET_GOOS"); s != "" {
goos = s
}
if s := os.Getenv("TARGET_GOARCH"); s != "" {
goarch = s
}
var more []string
if env != "" {
more = strings.Split(env, ",")
}
ndebug := []string{"-DNDEBUG"}
for _, v := range more {
if v == "-DSQLITE_DEBUG" {
ndebug = nil
}
}
more = append(more, ndebug...)
download()
switch goos {
case "linux", "freebsd", "openbsd":
configProduction = append(configProduction, "-DSQLITE_OS_UNIX=1")
case "netbsd":
configProduction = append(configProduction, []string{
"-DSQLITE_OS_UNIX=1",
"-D__libc_cond_broadcast=pthread_cond_broadcast",
"-D__libc_cond_destroy=pthread_cond_destroy",
"-D__libc_cond_init=pthread_cond_init",
"-D__libc_cond_signal=pthread_cond_signal",
"-D__libc_cond_wait=pthread_cond_wait",
"-D__libc_mutex_destroy=pthread_mutex_destroy",
"-D__libc_mutex_init=pthread_mutex_init",
"-D__libc_mutex_lock=pthread_mutex_lock",
"-D__libc_mutex_trylock=pthread_mutex_trylock",
"-D__libc_mutex_unlock=pthread_mutex_unlock",
"-D__libc_mutexattr_destroy=pthread_mutexattr_destroy",
"-D__libc_mutexattr_init=pthread_mutexattr_init",
"-D__libc_mutexattr_settype=pthread_mutexattr_settype",
"-D__libc_thr_yield=sched_yield",
}...)
case "darwin":
configProduction = append(configProduction,
"-DSQLITE_OS_UNIX=1",
"-DSQLITE_WITHOUT_ZONEMALLOC",
)
configTest = append(configTest,
"-DSQLITE_OS_UNIX=1",
"-DSQLITE_WITHOUT_ZONEMALLOC",
)
case "windows":
configProduction = append(configProduction,
"-DSQLITE_OS_WIN=1",
"-D_MSC_VER=1900",
)
configTest = append(configTest,
"-DSQLITE_OS_WIN=1",
"-D_MSC_VER=1900",
)
default:
fail("unknows/unsupported os: %s\n", goos)
}
makeSqliteProduction(goos, goarch, more)
makeSqliteTest(goos, goarch, more)
makeMpTest(goos, goarch, more)
makeSpeedTest(goos, goarch, more)
makeTestfixture(goos, goarch, more)
ccgo.MustCopyDir(true, "testdata/tcl", sqliteSrcDir+"/test", nil)
ccgo.MustCopyDir(true, "testdata/tcl", "testdata/overlay", nil)
}
func configure(goos, goarch string) {
wd, err := os.Getwd()
if err != nil {
fail("%s", err)
}
defer os.Chdir(wd)
if err := os.Chdir(sqliteSrcDir); err != nil {
fail("%s", err)
}
cmd := newCmd("make", "distclean")
cmd.Run()
var args []string
switch goos {
case "linux", "freebsd", "netbsd", "openbsd":
// nop
case "darwin":
args = append(args, "--with-tcl=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Tcl.framework")
case "windows":
switch goarch {
case "amd64":
args = append(args, "--host=x86_64-w64-mingw32")
case "386":
args = append(args, "--host=i686-w64-mingw32")
default:
fail("unknown/unsupported os/arch: %s/%s\n", goos, goarch)
}
default:
fail("unknown/unsupported os/arch: %s/%s\n", goos, goarch)
}
cmd = newCmd("./configure", args...)
if err = cmd.Run(); err != nil {
fail("%s\n", err)
}
cmd = newCmd("make", "parse.h", "opcodes.h")
if err = cmd.Run(); err != nil {
fail("%s\n", err)
}
}
func newCmd(bin string, args ...string) *exec.Cmd {
fmt.Printf("==== newCmd %s\n", bin)
for _, v := range args {
fmt.Printf("\t%v\n", v)
}
r := exec.Command(bin, args...)
r.Stdout = os.Stdout
r.Stderr = os.Stderr
return r
}
func makeTestfixture(goos, goarch string, more []string) {
dir := filepath.FromSlash(fmt.Sprintf("internal/testfixture"))
files := []string{
"ext/expert/sqlite3expert.c",
"ext/expert/test_expert.c",
"ext/fts3/fts3_term.c",
"ext/fts3/fts3_test.c",
"ext/fts5/fts5_tcl.c",
"ext/fts5/fts5_test_mi.c",
"ext/fts5/fts5_test_tok.c",
"ext/misc/amatch.c",
"ext/misc/appendvfs.c",
"ext/misc/basexx.c",
"ext/misc/carray.c",
"ext/misc/cksumvfs.c",
"ext/misc/closure.c",
"ext/misc/csv.c",
"ext/misc/decimal.c",
"ext/misc/eval.c",
"ext/misc/explain.c",
"ext/misc/fileio.c",
"ext/misc/fuzzer.c",
"ext/misc/ieee754.c",
"ext/misc/mmapwarm.c",
"ext/misc/nextchar.c",
"ext/misc/normalize.c",
"ext/misc/percentile.c",
"ext/misc/prefixes.c",
"ext/misc/qpvtab.c",
"ext/misc/regexp.c",
"ext/misc/remember.c",
"ext/misc/series.c",
"ext/misc/spellfix.c",
"ext/misc/totype.c",
"ext/misc/unionvtab.c",
"ext/misc/wholenumber.c",
"ext/rbu/test_rbu.c",
"ext/recover/dbdata.c",
"ext/recover/sqlite3recover.c",
"ext/recover/test_recover.c",
"ext/rtree/test_rtreedoc.c",
"ext/session/test_session.c",
"ext/userauth/userauth.c",
"src/tclsqlite.c",
"src/test1.c",
"src/test2.c",
"src/test3.c",
"src/test4.c",
"src/test5.c",
"src/test6.c",
"src/test8.c",
"src/test9.c",
"src/test_async.c",
"src/test_autoext.c",
"src/test_backup.c",
"src/test_bestindex.c",
"src/test_blob.c",
"src/test_btree.c",
"src/test_config.c",
"src/test_delete.c",
"src/test_demovfs.c",
"src/test_devsym.c",
"src/test_fs.c",
"src/test_func.c",
"src/test_hexio.c",
"src/test_init.c",
"src/test_intarray.c",
"src/test_journal.c",
"src/test_malloc.c",
"src/test_md5.c",
"src/test_multiplex.c",
"src/test_mutex.c",
"src/test_onefile.c",
"src/test_osinst.c",
"src/test_pcache.c",
"src/test_quota.c",
"src/test_rtree.c",
"src/test_schema.c",
"src/test_superlock.c",
"src/test_syscall.c",
"src/test_tclsh.c",
"src/test_tclvar.c",
"src/test_thread.c",
"src/test_vdbecov.c",
"src/test_vfs.c",
"src/test_windirent.c",
"src/test_window.c",
"src/test_wsd.c",
}
for i, v := range files {
files[i] = filepath.Join(sqliteSrcDir, filepath.FromSlash(v))
}
configure(goos, goarch)
var defines, includes []string
switch goos {
case "freebsd", "openbsd":
includes = []string{"-I/usr/local/include/tcl8.6"}
case "linux":
includes = []string{"-I/usr/include/tcl8.6"}
case "windows":
includes = []string{"-I/usr/include/tcl8.6"}
case "netbsd":
includes = []string{"-I/usr/pkg/include"}
defines = []string{
"-D__libc_cond_broadcast=pthread_cond_broadcast",
"-D__libc_cond_destroy=pthread_cond_destroy",
"-D__libc_cond_init=pthread_cond_init",
"-D__libc_cond_signal=pthread_cond_signal",
"-D__libc_cond_wait=pthread_cond_wait",
"-D__libc_mutex_destroy=pthread_mutex_destroy",
"-D__libc_mutex_init=pthread_mutex_init",
"-D__libc_mutex_lock=pthread_mutex_lock",
"-D__libc_mutex_trylock=pthread_mutex_trylock",
"-D__libc_mutex_unlock=pthread_mutex_unlock",
"-D__libc_mutexattr_destroy=pthread_mutexattr_destroy",
"-D__libc_mutexattr_init=pthread_mutexattr_init",
"-D__libc_mutexattr_settype=pthread_mutexattr_settype",
"-D__libc_thr_yield=sched_yield",
}
}
args := join(
[]string{
"ccgo",
"-DBUILD_sqlite",
"-DNDEBUG",
"-DSQLITE_CKSUMVFS_STATIC",
"-DSQLITE_CORE",
"-DSQLITE_CRASH_TEST=1",
"-DSQLITE_DEFAULT_PAGE_SIZE=1024",
"-DSQLITE_ENABLE_BYTECODE_VTAB",
"-DSQLITE_ENABLE_DBPAGE_VTAB",
"-DSQLITE_ENABLE_MATH_FUNCTIONS",
"-DSQLITE_ENABLE_STMTVTAB",
"-DSQLITE_NO_SYNC=1",
"-DSQLITE_OMIT_LOAD_EXTENSION",
"-DSQLITE_PRIVATE=\"\"",
"-DSQLITE_SERIES_CONSTRAINT_VERIFY=1",
"-DSQLITE_SERVER=1",
"-DSQLITE_TEMP_STORE=1",
"-DSQLITE_TEST=1",
"-DSQLITE_THREADSAFE=1",
"-DTCLSH_INIT_PROC=sqlite3TestInit",
"-D_HAVE_SQLITE_CONFIG_H",
},
defines,
includes,
[]string{
"-export-defines", "",
"-export-fields", "F",
"-ignore-unsupported-alignment",
"-trace-translation-units",
volatiles,
"-lmodernc.org/sqlite/libtest",
"-lmodernc.org/tcl/lib",
"-lmodernc.org/z/lib",
"-o", filepath.Join(dir, fmt.Sprintf("testfixture_%s_%s.go", goos, goarch)),
fmt.Sprintf("-I%s", filepath.Join(sqliteSrcDir, filepath.FromSlash("ext/async"))),
fmt.Sprintf("-I%s", filepath.Join(sqliteSrcDir, filepath.FromSlash("ext/fts3"))),
fmt.Sprintf("-I%s", filepath.Join(sqliteSrcDir, filepath.FromSlash("ext/icu"))),
fmt.Sprintf("-I%s", filepath.Join(sqliteSrcDir, filepath.FromSlash("ext/rtree"))),
fmt.Sprintf("-I%s", filepath.Join(sqliteSrcDir, filepath.FromSlash("ext/session"))),
fmt.Sprintf("-I%s", filepath.Join(sqliteSrcDir, filepath.FromSlash("ext/userauth"))),
fmt.Sprintf("-I%s", filepath.Join(sqliteSrcDir, filepath.FromSlash("src"))),
fmt.Sprintf("-I%s", sqliteDir),
fmt.Sprintf("-I%s", sqliteSrcDir),
},
otherOpts(),
files,
more,
configTest,
)
task := ccgo.NewTask(args, nil, nil)
if err := task.Main(); err != nil {
fail("%s\n", err)
}
}
func otherOpts() (r []string) {
if *oFullPathComments {
r = append(r, "-full-path-comments")
}
return r
}
func makeSpeedTest(goos, goarch string, more []string) {
task := ccgo.NewTask(
join(
[]string{
"ccgo",
"-export-defines", "",
"-ignore-unsupported-alignment",
"-o", filepath.FromSlash(fmt.Sprintf("speedtest1/main_%s_%s.go", goos, goarch)),
"-trace-translation-units",
filepath.Join(sqliteSrcDir, "test", "speedtest1.c"),
fmt.Sprintf("-I%s", sqliteDir),
"-l", "modernc.org/sqlite/lib",
},
otherOpts(),
more,
configProduction,
),
nil,
nil,
)
if err := task.Main(); err != nil {
fail("%s\n", err)
}
}
func makeMpTest(goos, goarch string, more []string) {
task := ccgo.NewTask(
join(
[]string{
"ccgo",
"-export-defines", "",
"-ignore-unsupported-alignment",
"-o", filepath.FromSlash(fmt.Sprintf("internal/mptest/main_%s_%s.go", goos, goarch)),
"-trace-translation-units",
// filepath.Join(sqliteSrcDir, "mptest", "mptest.c"),
filepath.Join("testdata", "mptest.c"),
fmt.Sprintf("-I%s", sqliteDir),
"-l", "modernc.org/sqlite/lib",
},
otherOpts(),
more,
configProduction,
),
nil,
nil,
)
if err := task.Main(); err != nil {
fail("%s\n", err)
}
}
func makeSqliteProduction(goos, goarch string, more []string) {
fn := filepath.FromSlash(fmt.Sprintf("lib/sqlite_%s_%s.go", goos, goarch))
task := ccgo.NewTask(
join(
[]string{
"ccgo",
"-DSQLITE_PRIVATE=",
"-export-defines", "",
"-export-enums", "",
"-export-externs", "X",
"-export-fields", "F",
"-export-typedefs", "",
"-ignore-unsupported-alignment",
"-pkgname", "sqlite3",
volatiles,
"-o", fn,
"-trace-translation-units",
filepath.Join(sqliteDir, "sqlite3.c"),
},
otherOpts(),
more,
configProduction,
),
nil,
nil,
)
if err := task.Main(); err != nil {
fail("%s\n", err)
}
if err := patchXsqlite3_initialize(fn); err != nil {
fail("%s\n", err)
}
}
func makeSqliteTest(goos, goarch string, more []string) {
fn := filepath.FromSlash(fmt.Sprintf("libtest/sqlite_%s_%s.go", goos, goarch))
task := ccgo.NewTask(
join(
[]string{
"ccgo",
"-DSQLITE_PRIVATE=",
"-export-defines", "",
"-export-enums", "",
"-export-externs", "X",
"-export-fields", "F",
"-export-typedefs", "",
"-ignore-unsupported-alignment",
"-pkgname", "sqlite3",
volatiles,
"-o", fn,
"-trace-translation-units",
volatiles,
filepath.Join(sqliteDir, "sqlite3.c"),
},
otherOpts(),
more,
configTest,
),
nil,
nil,
)
if err := task.Main(); err != nil {
fail("%s\n", err)
}
if err := patchXsqlite3_initialize(fn); err != nil {
fail("%s\n", err)
}
}
func join(a ...[]string) (r []string) {
n := 0
for _, v := range a {
n += len(v)
}
r = make([]string, 0, n)
for _, v := range a {
r = append(r, v...)
}
return r
}
func patchXsqlite3_initialize(fn string) error {
const s = "func Xsqlite3_initialize(tls *libc.TLS) int32 {"
return patch(fn, func(b []byte) []diff {
x := bytes.Index(b, []byte(s))
return []diff{{x, x + len(s), `
var mu mutex
func init() { mu.recursive = true }
func Xsqlite3_initialize(tls *libc.TLS) int32 {
mu.enter(tls.ID)
defer mu.leave(tls.ID)
`}}
})
}
type diff struct {
from, to int // byte offsets
replace string // replaces b[from:to]
}
func patch(fn string, f func([]byte) []diff) error {
b, err := os.ReadFile(fn)
if err != nil {
return err
}
diffs := f(b)
sort.Slice(diffs, func(i, j int) bool { return diffs[i].from < diffs[j].from })
var patched [][]byte
off := 0
for _, diff := range diffs {
from := diff.from - off
to := diff.to - off
patched = append(patched, b[:from])
patched = append(patched, []byte(diff.replace))
b = b[to:]
off += to
}
patched = append(patched, b)
return os.WriteFile(fn, bytes.Join(patched, nil), 0660)
}

1384
vendor/modernc.org/sqlite/lib/capi_darwin_amd64.go generated vendored Normal file

File diff suppressed because it is too large Load diff

1384
vendor/modernc.org/sqlite/lib/capi_darwin_arm64.go generated vendored Normal file

File diff suppressed because it is too large Load diff

1360
vendor/modernc.org/sqlite/lib/capi_freebsd_386.go generated vendored Normal file

File diff suppressed because it is too large Load diff

1360
vendor/modernc.org/sqlite/lib/capi_freebsd_amd64.go generated vendored Normal file

File diff suppressed because it is too large Load diff

1360
vendor/modernc.org/sqlite/lib/capi_freebsd_arm.go generated vendored Normal file

File diff suppressed because it is too large Load diff

1360
vendor/modernc.org/sqlite/lib/capi_freebsd_arm64.go generated vendored Normal file

File diff suppressed because it is too large Load diff

1360
vendor/modernc.org/sqlite/lib/capi_linux_386.go generated vendored Normal file

File diff suppressed because it is too large Load diff

1360
vendor/modernc.org/sqlite/lib/capi_linux_amd64.go generated vendored Normal file

File diff suppressed because it is too large Load diff

1360
vendor/modernc.org/sqlite/lib/capi_linux_arm.go generated vendored Normal file

File diff suppressed because it is too large Load diff

1360
vendor/modernc.org/sqlite/lib/capi_linux_arm64.go generated vendored Normal file

File diff suppressed because it is too large Load diff

1361
vendor/modernc.org/sqlite/lib/capi_linux_ppc64le.go generated vendored Normal file

File diff suppressed because it is too large Load diff

1361
vendor/modernc.org/sqlite/lib/capi_linux_riscv64.go generated vendored Normal file

File diff suppressed because it is too large Load diff

1361
vendor/modernc.org/sqlite/lib/capi_linux_s390x.go generated vendored Normal file

File diff suppressed because it is too large Load diff

1352
vendor/modernc.org/sqlite/lib/capi_netbsd_amd64.go generated vendored Normal file

File diff suppressed because it is too large Load diff

1359
vendor/modernc.org/sqlite/lib/capi_openbsd_amd64.go generated vendored Normal file

File diff suppressed because it is too large Load diff

1359
vendor/modernc.org/sqlite/lib/capi_openbsd_arm64.go generated vendored Normal file

File diff suppressed because it is too large Load diff

1379
vendor/modernc.org/sqlite/lib/capi_windows_amd64.go generated vendored Normal file

File diff suppressed because it is too large Load diff

1379
vendor/modernc.org/sqlite/lib/capi_windows_arm64.go generated vendored Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

199250
vendor/modernc.org/sqlite/lib/sqlite_windows_amd64.go generated vendored Normal file

File diff suppressed because one or more lines are too long

199250
vendor/modernc.org/sqlite/lib/sqlite_windows_arm64.go generated vendored Normal file

File diff suppressed because one or more lines are too long

36
vendor/modernc.org/sqlite/sqlite.go generated vendored
View file

@ -492,23 +492,10 @@ func toNamedValues(vals []driver.Value) (r []driver.NamedValue) {
func (s *stmt) exec(ctx context.Context, args []driver.NamedValue) (r driver.Result, err error) {
var pstmt uintptr
var done int32
if ctx != nil {
if ctxDone := ctx.Done(); ctxDone != nil {
select {
case <-ctxDone:
return nil, ctx.Err()
default:
}
defer interruptOnDone(ctx, s.c, &done)()
}
if ctx != nil && ctx.Done() != nil {
defer interruptOnDone(ctx, s.c, &done)()
}
defer func() {
if ctx != nil && atomic.LoadInt32(&done) != 0 {
r, err = nil, ctx.Err()
}
}()
for psql := s.psql; *(*byte)(unsafe.Pointer(psql)) != 0 && atomic.LoadInt32(&done) == 0; {
if pstmt, err = s.c.prepareV2(&psql); err != nil {
return nil, err
@ -545,7 +532,7 @@ func (s *stmt) exec(ctx context.Context, args []driver.NamedValue) (r driver.Res
switch rc & 0xff {
case sqlite3.SQLITE_DONE, sqlite3.SQLITE_ROW:
r, err = newResult(s.c)
// nop
default:
return s.c.errstr(int32(rc))
}
@ -561,7 +548,7 @@ func (s *stmt) exec(ctx context.Context, args []driver.NamedValue) (r driver.Res
return nil, err
}
}
return r, err
return newResult(s.c)
}
// NumInput returns the number of placeholder parameters.
@ -589,23 +576,14 @@ func (s *stmt) Query(args []driver.Value) (driver.Rows, error) { //TODO StmtQuer
func (s *stmt) query(ctx context.Context, args []driver.NamedValue) (r driver.Rows, err error) {
var pstmt uintptr
var done int32
if ctx != nil {
if ctxDone := ctx.Done(); ctxDone != nil {
select {
case <-ctxDone:
return nil, ctx.Err()
default:
}
defer interruptOnDone(ctx, s.c, &done)()
}
if ctx != nil && ctx.Done() != nil {
defer interruptOnDone(ctx, s.c, &done)()
}
var allocs []uintptr
defer func() {
if ctx != nil && atomic.LoadInt32(&done) != 0 {
r, err = nil, ctx.Err()
} else if r == nil && err == nil {
if r == nil && err == nil {
r, err = newRows(s.c, pstmt, allocs, true)
}
}()

View file

@ -1,124 +0,0 @@
// Copyright 2024 The Sqlite 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 none
// +build none
// Tool for 1.28+ -> 1.29+. Pulls adjusted libsqlite3 code to this repo.
package main
import (
"bytes"
"fmt"
"go/token"
"os"
"path/filepath"
"strings"
"modernc.org/gc/v3"
)
func fail(rc int, msg string, args ...any) {
fmt.Fprintln(os.Stderr, strings.TrimSpace(fmt.Sprintf(msg, args...)))
os.Exit(rc)
}
func main() {
for _, v := range []struct{ goos, goarch string }{
{"darwin", "amd64"},
{"darwin", "arm64"},
{"freebsd", "amd64"},
{"freebsd", "arm64"},
{"linux", "386"},
{"linux", "amd64"},
{"linux", "arm"},
{"linux", "arm64"},
{"linux", "ppc64le"},
{"linux", "riscv64"},
{"linux", "s390x"},
{"windows", "amd64"},
} {
fmt.Printf("%s/%s\n", v.goos, v.goarch)
base := fmt.Sprintf("ccgo_%s_%s.go", v.goos, v.goarch)
if v.goos == "windows" {
base = "ccgo_windows.go"
}
ifn := filepath.Join("..", "libsqlite3", base)
in, err := os.ReadFile(ifn)
if err != nil {
fail(1, "%s\n", err)
}
ast, err := gc.ParseFile(ifn, in)
if err != nil {
fail(1, "%s\n", err)
}
b := bytes.NewBuffer(nil)
s := ast.SourceFile.PackageClause.Source(true)
s = strings.Replace(s, "package libsqlite3", "package sqlite3", 1)
fmt.Fprintln(b, s)
fmt.Fprint(b, ast.SourceFile.ImportDeclList.Source(true))
taken := map[string]struct{}{}
for n := ast.SourceFile.TopLevelDeclList; n != nil; n = n.List {
switch x := n.TopLevelDecl.(type) {
case *gc.TypeDeclNode:
adn := x.TypeSpecList.TypeSpec.(*gc.AliasDeclNode)
nm := adn.IDENT.Src()
taken[nm] = struct{}{}
}
}
loop:
for n := ast.SourceFile.TopLevelDeclList; n != nil; n = n.List {
switch x := n.TopLevelDecl.(type) {
case *gc.ConstDeclNode:
switch y := x.ConstSpec.(type) {
case *gc.ConstSpecNode:
if y.IDENT.Src() != "SQLITE_TRANSIENT" {
fmt.Fprintln(b, x.Source(true))
}
default:
panic(fmt.Sprintf("%v: %T %q", x.Position(), y, x.Source(false)))
}
case *gc.FunctionDeclNode:
fmt.Fprintln(b, x.Source(true))
case *gc.TypeDeclNode:
fmt.Fprintln(b, x.Source(true))
adn := x.TypeSpecList.TypeSpec.(*gc.AliasDeclNode)
nm := adn.IDENT.Src()
nm2 := nm[1:]
if _, ok := taken[nm2]; ok {
break
}
if token.IsExported(nm) {
fmt.Fprintf(b, "\ntype %s = %s\n", nm2, nm)
}
case *gc.VarDeclNode:
fmt.Fprintln(b, x.Source(true))
default:
fmt.Printf("%v: TODO %T\n", n.Position(), x)
break loop
}
}
b.WriteString(`
type Sqlite3_int64 = sqlite3_int64
type Sqlite3_mutex_methods = sqlite3_mutex_methods
type Sqlite3_value = sqlite3_value
type Sqlite3_index_info = sqlite3_index_info
type Sqlite3_module = sqlite3_module
type Sqlite3_vtab = sqlite3_vtab
type Sqlite3_vtab_cursor = sqlite3_vtab_cursor
`)
base = strings.Replace(base, "ccgo_", "sqlite_", 1)
if err := os.WriteFile(filepath.Join("lib", base), b.Bytes(), 0660); err != nil {
fail(1, "%s\n", err)
}
}
}