29 lines
572 B
Go
29 lines
572 B
Go
package asm
|
|
|
|
import (
|
|
"maps"
|
|
|
|
"git.akyoto.dev/cli/q/src/build/data"
|
|
)
|
|
|
|
// Assembler contains a list of instructions.
|
|
type Assembler struct {
|
|
Data data.Data
|
|
Instructions []Instruction
|
|
}
|
|
|
|
// Merge combines the contents of this assembler with another one.
|
|
func (a *Assembler) Merge(b Assembler) {
|
|
maps.Copy(a.Data, b.Data)
|
|
a.Instructions = append(a.Instructions, b.Instructions...)
|
|
}
|
|
|
|
// SetData sets the data for the given label.
|
|
func (a *Assembler) SetData(label string, bytes []byte) {
|
|
if a.Data == nil {
|
|
a.Data = data.Data{}
|
|
}
|
|
|
|
a.Data[label] = bytes
|
|
}
|