This commit is contained in:
parent
312e3b2e31
commit
a67bc440fc
2 changed files with 7 additions and 4 deletions
|
@ -73,11 +73,14 @@ func (a *Assembler) Compile(b *build.Build) (code []byte, data []byte) {
|
||||||
|
|
||||||
// Merge combines the contents of this assembler with another one.
|
// Merge combines the contents of this assembler with another one.
|
||||||
func (a *Assembler) Merge(b *Assembler) {
|
func (a *Assembler) Merge(b *Assembler) {
|
||||||
maps.Copy(a.Data, b.Data)
|
skip := 0
|
||||||
|
|
||||||
for _, instr := range b.Instructions {
|
for a.Skip(b.Instructions[skip]) {
|
||||||
a.Append(instr)
|
skip++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a.Instructions = append(a.Instructions, b.Instructions[skip:]...)
|
||||||
|
maps.Copy(a.Data, b.Data)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetData sets the data for the given label.
|
// SetData sets the data for the given label.
|
||||||
|
|
|
@ -22,7 +22,7 @@ func WriteFile(executable string, b *build.Build, env *core.Environment) error {
|
||||||
traversed := make(map[*core.Function]bool, len(env.Functions))
|
traversed := make(map[*core.Function]bool, len(env.Functions))
|
||||||
|
|
||||||
final := asm.Assembler{
|
final := asm.Assembler{
|
||||||
Instructions: make([]asm.Instruction, 0, 8),
|
Instructions: make([]asm.Instruction, 0, 32),
|
||||||
Data: make(data.Data, 32),
|
Data: make(data.Data, 32),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue