Skip to content

Commit

Permalink
Merge pull request #1405 from goplus/main
Browse files Browse the repository at this point in the history
v1.1.6
  • Loading branch information
xushiwei authored Aug 26, 2023
2 parents 388f0cf + 262efe7 commit dff1ae3
Show file tree
Hide file tree
Showing 38 changed files with 938 additions and 308 deletions.
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
*.golden text eol=lf

*.gop text eol=lf
*.go text eol=lf
*.go text eol=lf
*.gox text eol=lf
8 changes: 4 additions & 4 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ jobs:
Test:
strategy:
matrix:
go-version: [1.16.x, 1.17.x, 1.18.x]
go-version: [1.16.x, 1.17.x, 1.18.x, 1.19.x, 1.20.x]
os: [ubuntu-latest, windows-latest, macos-11]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}

Expand All @@ -34,4 +34,4 @@ jobs:
run: go test -v -coverprofile="coverage.txt" -covermode=atomic ./...

- name: Codecov
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v3
6 changes: 3 additions & 3 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Checkout tag
run: |
Expand All @@ -20,7 +20,7 @@ jobs:
echo "TAG_NAME=${tag_name}" >> $GITHUB_ENV
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: 1.17

Expand All @@ -35,4 +35,4 @@ jobs:
tag: ${{ env.TAG_NAME }}
file: ./build-dir/gop-*.zip
file_glob: true
prerelease: true
prerelease: true
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ coverage.txt
.gop/
gop_autogen*.go
go.json
go.work
go.work.sum
go.work*
format.result
*.cache

Expand Down
20 changes: 8 additions & 12 deletions ast/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

// Package ast declares the types used to represent syntax trees for Go+
// packages.
//
package ast

import (
Expand Down Expand Up @@ -71,7 +70,6 @@ type Comment = ast.Comment

// A CommentGroup represents a sequence of comments
// with no other tokens and no empty lines between.
//
type CommentGroup = ast.CommentGroup

// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -526,7 +524,6 @@ func (x *ChanType) End() token.Pos { return x.Value.End() }

// exprNode() ensures that only expression/type nodes can be
// assigned to an Expr.
//
func (*BadExpr) exprNode() {}
func (*Ident) exprNode() {}
func (*Ellipsis) exprNode() {}
Expand Down Expand Up @@ -577,7 +574,6 @@ func (x *Ident) String() string {

// A statement is represented by a tree consisting of one
// or more of the following concrete statement nodes.
//
type (
// A BadStmt node is a placeholder for statements containing
// syntax errors for which no correct statement nodes can be
Expand Down Expand Up @@ -910,7 +906,6 @@ func (s *RangeStmt) End() token.Pos { return s.Body.End() }

// stmtNode() ensures that only statement nodes can be
// assigned to a Stmt.
//
func (*BadStmt) stmtNode() {}
func (*DeclStmt) stmtNode() {}
func (*EmptyStmt) stmtNode() {}
Expand Down Expand Up @@ -938,7 +933,6 @@ func (*RangeStmt) stmtNode() {}

// A Spec node represents a single (non-parenthesized) import,
// constant, type, or variable declaration.
//
type (
// The Spec type stands for any of *ImportSpec, *ValueSpec, and *TypeSpec.
Spec interface {
Expand All @@ -962,6 +956,7 @@ type (
Doc *CommentGroup // associated documentation; or nil
Names []*Ident // value names (len(Names) > 0)
Type Expr // value type; or nil
Tag *BasicLit // classfile field tag; or nil
Values []Expr // initial values; or nil
Comment *CommentGroup // line comments; or nil
}
Expand All @@ -988,7 +983,12 @@ func (s *ImportSpec) Pos() token.Pos {
}

// Pos returns position of first character belonging to the node.
func (s *ValueSpec) Pos() token.Pos { return s.Names[0].Pos() }
func (s *ValueSpec) Pos() token.Pos {
if len(s.Names) == 0 {
return s.Type.Pos()
}
return s.Names[0].Pos()
}

// Pos returns position of first character belonging to the node.
func (s *TypeSpec) Pos() token.Pos { return s.Name.Pos() }
Expand Down Expand Up @@ -1017,13 +1017,11 @@ func (s *TypeSpec) End() token.Pos { return s.Type.End() }

// specNode() ensures that only spec nodes can be
// assigned to a Spec.
//
func (*ImportSpec) specNode() {}
func (*ValueSpec) specNode() {}
func (*TypeSpec) specNode() {}

// A declaration is represented by one of the following declaration nodes.
//
type (
// A BadDecl node is a placeholder for declarations containing
// syntax errors for which no correct declaration nodes can be
Expand Down Expand Up @@ -1096,7 +1094,6 @@ func (d *FuncDecl) End() token.Pos {

// declNode() ensures that only declaration nodes can be
// assigned to a Decl.
//
func (*BadDecl) declNode() {}
func (*GenDecl) declNode() {}
func (*FuncDecl) declNode() {}
Expand Down Expand Up @@ -1124,7 +1121,6 @@ type FileType = int16
// interpretation of the syntax tree by the manipulating program: Except for Doc
// and Comment comments directly associated with nodes, the remaining comments
// are "free-floating" (see also issues #18593, #20744).
//
type File struct {
Doc *CommentGroup // associated documentation; or nil
Package token.Pos // position of "package" keyword
Expand All @@ -1139,6 +1135,7 @@ type File struct {
NoPkgDecl bool // no `package xxx` declaration
IsClass bool // is a classfile
IsProj bool // is a project classfile
IsNormalGox bool // is a normal .gox file
}

// Pos returns position of first character belonging to the node.
Expand All @@ -1154,7 +1151,6 @@ func (f *File) End() token.Pos {

// A Package node represents a set of source files
// collectively building a Go package.
//
type Package struct {
Name string // package name
Scope *Scope // package scope across all files
Expand Down
11 changes: 1 addition & 10 deletions ast/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func exportFilter(name string) bool {
// stripped. The File.Comments list is not changed.
//
// FileExports reports whether there are exported declarations.
//
func FileExports(src *File) bool {
return filterFile(src, exportFilter, true)
}
Expand All @@ -48,7 +47,6 @@ func FileExports(src *File) bool {
//
// PackageExports reports whether there are exported declarations;
// it returns false otherwise.
//
func PackageExports(pkg *Package) bool {
return filterPackage(pkg, exportFilter, true)
}
Expand All @@ -73,7 +71,6 @@ func filterIdentList(list []*Ident, f Filter) []*Ident {
// fieldName assumes that x is the type of an anonymous field and
// returns the corresponding field name. If x is not an acceptable
// anonymous field, the result is nil.
//
func fieldName(x Expr) *Ident {
switch t := x.(type) {
case *Ident:
Expand Down Expand Up @@ -243,7 +240,6 @@ func filterSpecList(list []Spec, f Filter, export bool) []Spec {
//
// FilterDecl reports whether there are any declared names left after
// filtering.
//
func FilterDecl(decl Decl, f Filter) bool {
return filterDecl(decl, f, false)
}
Expand All @@ -268,7 +264,6 @@ func filterDecl(decl Decl, f Filter, export bool) bool {
//
// FilterFile reports whether there are any top-level declarations
// left after filtering.
//
func FilterFile(src *File, f Filter) bool {
return filterFile(src, f, false)
}
Expand All @@ -295,7 +290,6 @@ func filterFile(src *File, f Filter, export bool) bool {
//
// FilterPackage reports whether there are any top-level declarations
// left after filtering.
//
func FilterPackage(pkg *Package, f Filter) bool {
return filterPackage(pkg, f, false)
}
Expand Down Expand Up @@ -329,7 +323,6 @@ const (
// nameOf returns the function (foo) or method name (foo.bar) for
// the given function declaration. If the AST is incorrect for the
// receiver, it assumes a function instead.
//
func nameOf(f *FuncDecl) string {
if r := f.Recv; r != nil && len(r.List) == 1 {
// looks like a correct receiver declaration
Expand All @@ -349,12 +342,10 @@ func nameOf(f *FuncDecl) string {

// separator is an empty //-style comment that is interspersed between
// different comment groups when they are concatenated into a single group
//
var separator = &Comment{Slash: token.NoPos, Text: "//"}

// MergePackageFiles creates a file AST by merging the ASTs of the
// files belonging to a package. The mode flags control merging behavior.
//
func MergePackageFiles(pkg *Package, mode MergeMode) *File {
// Count the number of package docs, comments and declarations across
// all package files. Also, compute sorted list of filenames, so that
Expand Down Expand Up @@ -509,6 +500,6 @@ func MergePackageFiles(pkg *Package, mode MergeMode) *File {
// TODO(gri) need to compute unresolved identifiers!
return &File{
doc, pos, NewIdent(pkg.Name), decls, pkg.Scope,
imports, nil, comments, nil, false, false, false, false,
imports, nil, comments, nil, false, false, false, false, false,
}
}
7 changes: 6 additions & 1 deletion builtin/ng/int128.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ import (
"math/bits"
)

const (
Int128_Max = 1<<127 - 1
Int128_Min = -1 << 127
Int128_IsUntyped = true
)

const (
signBit = 0x8000000000000000
maxInt64 = 1<<63 - 1
Expand Down Expand Up @@ -634,7 +640,6 @@ func (i Int128) Gop_Rsh(n Gop_ninteger) Int128 {
// Mul returns the product of two I128s.
//
// Overflow should wrap around, as per the Go spec.
//
func (i Int128) Gop_Mul__1(n Int128) (dest Int128) {
hi, lo := bits.Mul64(i.lo, n.lo)
hi += i.hi*n.lo + i.lo*n.hi
Expand Down
7 changes: 6 additions & 1 deletion builtin/ng/uint128.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ const (
GopPackage = true // to indicate this is a Go+ package
)

const (
Uint128_Max = 1<<128 - 1
Uint128_Min = 0
Uint128_IsUntyped = true
)

const (
maxUint64 = (1 << 64) - 1
intSize = 32 << (^uint(0) >> 63)
Expand Down Expand Up @@ -349,7 +355,6 @@ func (u Uint128) ReverseBytes() Uint128 {
//
// The specific value returned by Cmp is undefined, but it is guaranteed to
// satisfy the above constraints.
//
func (u Uint128) Cmp__1(n Uint128) int {
if u.hi == n.hi {
if u.lo > n.lo {
Expand Down
20 changes: 11 additions & 9 deletions cl/builtin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/goplus/gox"
"github.com/goplus/gox/cpackages"
"github.com/goplus/gox/packages"
"github.com/goplus/mod/gopmod"
"github.com/goplus/mod/modfile"
)

var (
Expand Down Expand Up @@ -114,7 +114,7 @@ func TestClRangeStmt(t *testing.T) {

func TestGmxSettings(t *testing.T) {
pkg := gox.NewPackage("", "foo", goxConf)
gmx := newGmx(nil, pkg, "main.t2gmx", &Config{
gmx := newGmx(nil, pkg, "main.t2gmx", &ast.File{IsProj: true}, &Config{
LookupClass: lookupClass,
})
scheds := gmx.getScheds(pkg.CB())
Expand All @@ -132,7 +132,7 @@ func TestGmxSettings(t *testing.T) {
}}, &Config{
LookupClass: lookupClassErr,
})
if e := err.Error(); e != `github.com/goplus/gop/cl/internal/libc.Gop_game not found` {
if e := err.Error(); e != `github.com/goplus/gop/cl/internal/libc.Game not found` {
t.Fatal("newGmx:", e)
}
}
Expand All @@ -146,21 +146,23 @@ func TestSpxLookup(t *testing.T) {
spxLookup(nil, "foo")
}

func lookupClass(ext string) (c *gopmod.Class, ok bool) {
func lookupClass(ext string) (c *modfile.Project, ok bool) {
switch ext {
case ".t2gmx", ".t2spx":
return &gopmod.Class{
ProjExt: ".t2gmx", WorkExt: ".t2spx",
return &modfile.Project{
Ext: ".t2gmx", Class: "Game",
Works: []*modfile.Class{{Ext: ".t2spx", Class: "Sprite"}},
PkgPaths: []string{"github.com/goplus/gop/cl/internal/spx2"}}, true
}
return
}

func lookupClassErr(ext string) (c *gopmod.Class, ok bool) {
func lookupClassErr(ext string) (c *modfile.Project, ok bool) {
switch ext {
case ".t2gmx", ".t2spx":
return &gopmod.Class{
ProjExt: ".t2gmx", WorkExt: ".t2spx",
return &modfile.Project{
Ext: ".t2gmx", Class: "Game",
Works: []*modfile.Class{{Ext: ".t2spx", Class: "Sprite"}},
PkgPaths: []string{"github.com/goplus/gop/cl/internal/libc"}}, true
}
return
Expand Down
Loading

0 comments on commit dff1ae3

Please sign in to comment.