Rename some routines in data
This commit is contained in:
parent
15541b8675
commit
f994c4dc08
@ -39,7 +39,7 @@ func (this *generator) generateAssignmentSource (
|
||||
irToType, err := this.generateType(to)
|
||||
if err != nil { return nil, err }
|
||||
destination := this.blockManager.newAllocaFront(irToType)
|
||||
toDataField := this.getInterfaceData(destination, irToType)
|
||||
toDataField := this.getInterfaceDataFieldLoc(destination, irToType)
|
||||
|
||||
fromType := from.Type()
|
||||
switch fromBase := analyzer.ReduceToBase(fromType).(type) {
|
||||
@ -50,16 +50,16 @@ func (this *generator) generateAssignmentSource (
|
||||
if err != nil { return nil, err }
|
||||
irFromType, err := this.generateType(fromType)
|
||||
if err != nil { return nil, err }
|
||||
fromDataField := this.getInterfaceData(source, irFromType)
|
||||
fromData := this.blockManager.NewLoad(new(llvm.TypePointer), fromDataField)
|
||||
fromDataFieldAddress := this.getInterfaceDataFieldLoc(source, irFromType)
|
||||
fromData := this.blockManager.NewLoad(new(llvm.TypePointer), fromDataFieldAddress)
|
||||
this.blockManager.NewStore(fromData, toDataField)
|
||||
|
||||
// re-assign behaviors
|
||||
for _, name := range toBase.BehaviorOrder {
|
||||
fromBehaviorField := this.getInterfaceBehavior (
|
||||
fromBehaviorField := this.getInterfaceBehaviorFieldLoc (
|
||||
fromBase, source,
|
||||
irFromType, name)
|
||||
toBehaviorField := this.getInterfaceBehavior (
|
||||
toBehaviorField := this.getInterfaceBehaviorFieldLoc (
|
||||
toBase, destination,
|
||||
irToType, name)
|
||||
fromBehavior := this.blockManager.NewLoad(new(llvm.TypePointer), fromBehaviorField)
|
||||
@ -82,12 +82,12 @@ func (this *generator) generateAssignmentSource (
|
||||
|
||||
// assign behaviors
|
||||
for _, name := range toBase.BehaviorOrder {
|
||||
toBehaviorField := this.getInterfaceBehavior (
|
||||
toBehaviorFieldAddress := this.getInterfaceBehaviorFieldLoc (
|
||||
toBase, destination,
|
||||
irToType, name)
|
||||
fromBehavior, err := this.method(fromReferenced.Name, name)
|
||||
if err != nil { return nil, err }
|
||||
this.blockManager.NewStore(fromBehavior, toBehaviorField)
|
||||
this.blockManager.NewStore(fromBehavior, toBehaviorFieldAddress)
|
||||
}
|
||||
|
||||
// conversion from other type to interface
|
||||
@ -105,12 +105,12 @@ func (this *generator) generateAssignmentSource (
|
||||
|
||||
// assign behaviors
|
||||
for _, name := range toBase.BehaviorOrder {
|
||||
toBehaviorField := this.getInterfaceBehavior (
|
||||
toBehaviorFieldAddress := this.getInterfaceBehaviorFieldLoc (
|
||||
toBase, destination,
|
||||
irToType, name)
|
||||
fromBehavior, err := this.method(fromType.Name, name)
|
||||
if err != nil { return nil, err }
|
||||
this.blockManager.NewStore(fromBehavior, toBehaviorField)
|
||||
this.blockManager.NewStore(fromBehavior, toBehaviorFieldAddress)
|
||||
}
|
||||
}
|
||||
return this.blockManager.NewLoad(irToType, destination), nil
|
||||
|
@ -37,14 +37,14 @@ func (this *generator) getSliceDataAddress (slice llvm.Value, irType llvm.Type)
|
||||
dataAddressFieldAddress)
|
||||
}
|
||||
|
||||
func (this *generator) getInterfaceData (iface llvm.Value, irType llvm.Type) llvm.Value {
|
||||
func (this *generator) getInterfaceDataFieldLoc (iface llvm.Value, irType llvm.Type) llvm.Value {
|
||||
return this.blockManager.NewGetElementPtr (
|
||||
irType, iface,
|
||||
llvm.NewConstInt(llvm.I32, 0),
|
||||
llvm.NewConstInt(llvm.I32, 0))
|
||||
}
|
||||
|
||||
func (this *generator) getInterfaceBehavior (
|
||||
func (this *generator) getInterfaceBehaviorFieldLoc (
|
||||
ty *entity.TypeInterface,
|
||||
iface llvm.Value,
|
||||
irType llvm.Type,
|
||||
|
@ -83,10 +83,10 @@ func (this *generator) generateMethodCallVal (call *entity.MethodCall) (llvm.Val
|
||||
if err != nil { return nil, err }
|
||||
source, err := this.generateExpressionLoc(call.Source)
|
||||
if err != nil { return nil, err }
|
||||
irBehavior := this.getInterfaceBehavior(sourceType, source, irSourceType, call.Name)
|
||||
irBehavior := this.getInterfaceBehaviorFieldLoc(sourceType, source, irSourceType, call.Name)
|
||||
|
||||
if irBehavior != nil {
|
||||
irValue := this.getInterfaceData(source, irSourceType)
|
||||
irValue := this.getInterfaceDataFieldLoc(source, irSourceType)
|
||||
signature, err := this.getInterfaceBehaviorSignature(sourceType, call.Name)
|
||||
if err != nil { return nil, err }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user