return 0, false
}
-var Pseudos = map[string]obj.As{
- "DATA": obj.ADATA,
- "FUNCDATA": obj.AFUNCDATA,
- "GLOBL": obj.AGLOBL,
- "PCDATA": obj.APCDATA,
- "TEXT": obj.ATEXT,
-}
-
// Set configures the architecture specified by GOARCH and returns its representation.
// It returns nil if GOARCH is not recognized.
func Set(GOARCH string) *Arch {
p.errorf("missing operand")
}
}
- i, present := arch.Pseudos[word]
- if present {
- p.pseudo(i, word, operands)
+ if p.pseudo(word, operands) {
return true
}
- i, present = p.arch.Instructions[word]
+ i, present := p.arch.Instructions[word]
if present {
p.instruction(i, word, cond, operands)
return true
p.asmInstruction(op, cond, p.addr)
}
-func (p *Parser) pseudo(op obj.As, word string, operands [][]lex.Token) {
- switch op {
- case obj.ATEXT:
- p.asmText(word, operands)
- case obj.ADATA:
+func (p *Parser) pseudo(word string, operands [][]lex.Token) bool {
+ switch word {
+ case "DATA":
p.asmData(word, operands)
- case obj.AGLOBL:
+ case "FUNCDATA":
+ p.asmFuncData(word, operands)
+ case "GLOBL":
p.asmGlobl(word, operands)
- case obj.APCDATA:
+ case "PCDATA":
p.asmPCData(word, operands)
- case obj.AFUNCDATA:
- p.asmFuncData(word, operands)
+ case "TEXT":
+ p.asmText(word, operands)
default:
- p.errorf("unimplemented: %s", word)
+ return false
}
+ return true
}
func (p *Parser) start(operand []lex.Token) {
"strings"
"testing"
- "cmd/asm/internal/arch"
"cmd/asm/internal/lex"
)
parser.errorCount = 0
parser.lineNum++
parser.histLineNum++
- op, ok := arch.Pseudos[test.pseudo]
- if !ok {
+ if !parser.pseudo(test.pseudo, tokenize(test.operands)) {
t.Fatalf("Wrong pseudo-instruction: %s", test.pseudo)
}
- parser.pseudo(op, test.pseudo, tokenize(test.operands))
errorLine := buf.String()
if test.expected != errorLine {
t.Errorf("Unexpected error %q; expected %q", errorLine, test.expected)