aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/compiler/compiler.go
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2023-09-19 16:46:40 +0200
committerAleksandr Nogikh <nogikh@google.com>2023-10-04 09:27:33 +0000
commit8144982a26c6b8e5f0f5401c2a2de99e4ced04cd (patch)
treee17e1e9cfd27739da3f002744506d22e73ff2c0d /pkg/compiler/compiler.go
parentc4dc646bee41c7e983a13750652f1035ae27b737 (diff)
sys: refactor const extraction
1) Make FabricateSyscallConsts() operate on ConstFile. 2) Expose Pos inside ConstInfo.
Diffstat (limited to 'pkg/compiler/compiler.go')
-rw-r--r--pkg/compiler/compiler.go20
1 files changed, 5 insertions, 15 deletions
diff --git a/pkg/compiler/compiler.go b/pkg/compiler/compiler.go
index b3e39be06..15502e70b 100644
--- a/pkg/compiler/compiler.go
+++ b/pkg/compiler/compiler.go
@@ -8,7 +8,6 @@ package compiler
import (
"fmt"
"path/filepath"
- "sort"
"strconv"
"strings"
@@ -137,6 +136,7 @@ type compiler struct {
structVarlen map[string]bool
structTypes map[string]prog.Type
builtinConsts map[string]uint64
+ fileMeta map[string]Meta
}
type warn struct {
@@ -154,10 +154,12 @@ func (comp *compiler) warning(pos ast.Pos, msg string, args ...interface{}) {
}
func (comp *compiler) filterArch() {
- files := comp.fileList()
+ if comp.fileMeta == nil {
+ comp.fileMeta = comp.fileList()
+ }
comp.desc = comp.desc.Filter(func(n ast.Node) bool {
pos, typ, name := n.Info()
- meta := files[filepath.Base(pos.File)]
+ meta := comp.fileMeta[filepath.Base(pos.File)]
if meta.SupportsArch(comp.target.Arch) {
return true
}
@@ -347,18 +349,6 @@ func (comp *compiler) parseIntType(name string) (size uint64, bigEndian bool) {
return size, be
}
-func toArray(m map[string]bool) []string {
- delete(m, "")
- var res []string
- for v := range m {
- if v != "" {
- res = append(res, v)
- }
- }
- sort.Strings(res)
- return res
-}
-
func arrayContains(a []string, v string) bool {
for _, s := range a {
if s == v {