5
ast.go
5
ast.go
@@ -94,11 +94,14 @@ type Section interface {
|
|||||||
|
|
||||||
// File represents an assembly file.
|
// File represents an assembly file.
|
||||||
type File struct {
|
type File struct {
|
||||||
|
Includes []string
|
||||||
Sections []Section
|
Sections []Section
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewFile() *File {
|
func NewFile() *File {
|
||||||
return &File{}
|
return &File{
|
||||||
|
Includes: []string{"textflag.h"},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *File) AddSection(s Section) {
|
func (f *File) AddSection(s Section) {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ func NewGoAsm(cfg Config) Printer {
|
|||||||
|
|
||||||
func (p *goasm) Print(f *avo.File) ([]byte, error) {
|
func (p *goasm) Print(f *avo.File) ([]byte, error) {
|
||||||
p.header()
|
p.header()
|
||||||
|
p.includes(f.Includes)
|
||||||
for _, s := range f.Sections {
|
for _, s := range f.Sections {
|
||||||
switch s := s.(type) {
|
switch s := s.(type) {
|
||||||
case *avo.Function:
|
case *avo.Function:
|
||||||
@@ -38,12 +39,16 @@ func (p *goasm) Print(f *avo.File) ([]byte, error) {
|
|||||||
|
|
||||||
func (p *goasm) header() {
|
func (p *goasm) header() {
|
||||||
p.Comment(p.cfg.GeneratedWarning())
|
p.Comment(p.cfg.GeneratedWarning())
|
||||||
p.NL()
|
|
||||||
p.include("textflag.h")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *goasm) include(path string) {
|
func (p *goasm) includes(paths []string) {
|
||||||
p.Printf("#include \"%s\"\n", path)
|
if len(paths) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
p.NL()
|
||||||
|
for _, path := range paths {
|
||||||
|
p.Printf("#include \"%s\"\n", path)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *goasm) function(f *avo.Function) {
|
func (p *goasm) function(f *avo.Function) {
|
||||||
|
|||||||
Reference in New Issue
Block a user