ast,build: allow setting data attributes

Previously GLOBL/DATA attributes are set to RODATA. This diff removes
that default and allows them to be set through the DataAttributes
context method.

Updates #2
This commit is contained in:
Michael McLoughlin
2018-12-31 19:04:14 -08:00
parent f2315d539c
commit 816fa4c0e6
8 changed files with 19 additions and 11 deletions

View File

@@ -1,6 +1,7 @@
package build
import (
"github.com/mmcloughlin/avo"
"github.com/mmcloughlin/avo/operand"
"github.com/mmcloughlin/avo/reg"
@@ -46,6 +47,7 @@ func (c *Context) Store(src reg.Register, dst gotypes.Component) {
func (c *Context) ConstData(name string, v operand.Constant) operand.Mem {
g := c.StaticGlobal(name)
c.DataAttributes(avo.RODATA | avo.NOPTR)
c.AppendDatum(v)
return g
}