examples/sha1: single block
This commit is contained in:
19
ast.go
19
ast.go
@@ -10,15 +10,6 @@ type Asm interface {
|
||||
Asm() string
|
||||
}
|
||||
|
||||
// GoType represents a Golang type.
|
||||
type GoType interface{}
|
||||
|
||||
// Parameter represents a parameter to an assembly function.
|
||||
type Parameter struct {
|
||||
Name string
|
||||
Type GoType
|
||||
}
|
||||
|
||||
type Operand interface {
|
||||
Asm
|
||||
}
|
||||
@@ -112,6 +103,7 @@ func NewFile() *File {
|
||||
type Function struct {
|
||||
Name string
|
||||
Signature *gotypes.Signature
|
||||
LocalSize int
|
||||
|
||||
Nodes []Node
|
||||
|
||||
@@ -133,6 +125,12 @@ func (f *Function) SetSignature(s *gotypes.Signature) {
|
||||
f.Signature = s
|
||||
}
|
||||
|
||||
func (f *Function) AllocLocal(size int) operand.Mem {
|
||||
ptr := operand.NewStackAddr(f.LocalSize)
|
||||
f.LocalSize += size
|
||||
return ptr
|
||||
}
|
||||
|
||||
func (f *Function) AddInstruction(i *Instruction) {
|
||||
f.AddNode(i)
|
||||
}
|
||||
@@ -164,8 +162,7 @@ func (f *Function) Stub() string {
|
||||
|
||||
// FrameBytes returns the size of the stack frame in bytes.
|
||||
func (f *Function) FrameBytes() int {
|
||||
// TODO(mbm): implement Function.FrameBytes()
|
||||
return 0
|
||||
return f.LocalSize
|
||||
}
|
||||
|
||||
// ArgumentBytes returns the size of the arguments in bytes.
|
||||
|
||||
Reference in New Issue
Block a user