feat(asm): the operand forms and defines GOROOT writes
Assisted-by: GLM 5.3 Flash
This commit is contained in:
@@ -34,6 +34,12 @@ type Options struct {
|
||||
// Expand enables macro expansion, include splicing and the
|
||||
// statement-separator reading of ';' that the expanded bodies rely on.
|
||||
Expand bool
|
||||
// Predefines names the macros defined before the file is read. The
|
||||
// go command drives go tool asm with -D GOOS_<goos> -D GOARCH_<arch>,
|
||||
// and GOROOT's own headers (go_tls.h, asm_riscv64.h) select their
|
||||
// platform blocks with #ifdef on exactly those names, so an assembler
|
||||
// without them cannot see the platform definitions at all.
|
||||
Predefines map[string]string
|
||||
}
|
||||
|
||||
// ParseWithOptions parses src like Parse, optionally preprocessing it first.
|
||||
@@ -44,6 +50,9 @@ func ParseWithOptions(path, src string, opts Options) (*ast.File, []error) {
|
||||
var errs []error
|
||||
if opts.Expand {
|
||||
pp := &preproc{opts: opts, macros: map[string]*macroDef{}}
|
||||
for name, value := range opts.Predefines {
|
||||
pp.macros[name] = ¯oDef{name: name, body: lexer.Tokenize(value)}
|
||||
}
|
||||
lines = pp.fileLines(path, tokens, token.Position{})
|
||||
errs = pp.errs
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user