start at some basic passes

This commit is contained in:
Michael McLoughlin
2018-12-02 12:28:33 -08:00
parent 0ceb1c55a4
commit 43575d8b61
14 changed files with 7209 additions and 3904 deletions

View File

@@ -42,7 +42,7 @@ func (c *ctors) instruction(i inst.Instruction) {
c.Printf("func %s(%s) (*avo.Instruction, error) {\n", i.Opcode, s.ParameterList())
c.checkargs(i, s)
c.Printf("\treturn &avo.Instruction{Opcode: %#v, Operands: %s}, nil\n", i.Opcode, s.ParameterSlice())
c.Printf("\treturn &%s, nil\n", construct(i, s))
c.Printf("}\n\n")
}
@@ -72,6 +72,19 @@ func (c *ctors) doc(i inst.Instruction) []string {
return lines
}
func construct(i inst.Instruction, s signature) string {
buf := bytes.NewBuffer(nil)
fmt.Fprintf(buf, "avo.Instruction{\n")
fmt.Fprintf(buf, "\tOpcode: %#v,\n", i.Opcode)
fmt.Fprintf(buf, "\tOperands: %s,\n", s.ParameterSlice())
if i.IsBranch() {
fmt.Fprintf(buf, "\tIsBranch: true,\n")
fmt.Fprintf(buf, "\tIsConditional: %#v,\n", i.IsConditionalBranch())
}
fmt.Fprintf(buf, "}")
return buf.String()
}
func (c *ctors) checkargs(i inst.Instruction, s signature) {
if i.IsNiladic() {
return