Implemented function pointers as parameters
This commit is contained in:
parent
977028f8ab
commit
699dbe4fd5
5 changed files with 76 additions and 36 deletions
|
@ -15,8 +15,24 @@ import (
|
|||
func (f *Function) ExpressionToMemory(node *expression.Expression, memory asm.Memory) (*types.Type, error) {
|
||||
if node.IsLeaf() {
|
||||
if node.Token.Kind == token.Identifier {
|
||||
f.MemoryLabel(asm.STORE, memory, fmt.Sprintf("%s.%s", f.Package, node.Token.Text(f.File.Bytes)))
|
||||
return types.Pointer, nil
|
||||
name := node.Token.Text(f.File.Bytes)
|
||||
variable := f.VariableByName(name)
|
||||
|
||||
if variable != nil {
|
||||
f.UseVariable(variable)
|
||||
f.MemoryRegister(asm.STORE, memory, variable.Register)
|
||||
return types.Pointer, nil
|
||||
}
|
||||
|
||||
uniqueName := fmt.Sprintf("%s.%s", f.Package, name)
|
||||
_, exists := f.Functions[uniqueName]
|
||||
|
||||
if exists {
|
||||
f.MemoryLabel(asm.STORE, memory, uniqueName)
|
||||
return types.Pointer, nil
|
||||
}
|
||||
|
||||
return nil, errors.New(&errors.UnknownIdentifier{Name: name}, f.File, node.Token.Position)
|
||||
}
|
||||
|
||||
if node.Token.IsNumeric() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue