*Greatly* reduced the amount of excess IR related to string literals

This commit is contained in:
Sasha Koshka 2024-01-28 14:11:41 -05:00
parent 1f53fc5214
commit 83aefbae07
4 changed files with 175 additions and 68 deletions

View File

@ -16,6 +16,9 @@ func (this *generator) generateAssignment (assignment *entity.Assignment) (llvm.
destination) destination)
} }
// TODO possibly break generateAssignmentToDestination into several routines,
// each handling one destination type
// generateAssignmentToDestination performs type coercions if necessary, mainly // generateAssignmentToDestination performs type coercions if necessary, mainly
// interface assignment. This should be called when the user is assigning a // interface assignment. This should be called when the user is assigning a
// value to something via an assignment statement, a function/method call, or a // value to something via an assignment statement, a function/method call, or a
@ -126,8 +129,28 @@ func (this *generator) generateAssignmentToDestination ( // TODO: add -Val suffi
return this.blockManager.NewLoad(irDestType, irDestLoc), nil return this.blockManager.NewLoad(irDestType, irDestLoc), nil
} }
// conversion from any type to pointer
case *entity.TypePointer:
// assignments
switch source := source.(type) {
// assignment from array literal to pointer
case *entity.LiteralArray:
if destinationSpecified {
_, err := this.generateLiteralArrayLoc(source, irDestLoc)
return nil, err
}
// assignment from string literal to pointer
case *entity.LiteralString:
if destinationSpecified {
_, err := this.generateLiteralStringLoc(source, irDestLoc)
return nil, err
}
}
// conversion from any type to slice // conversion from any type to slice
case *entity.TypeSlice: case *entity.TypeSlice:
// conversions
switch sourceTypeBase := analyzer.ReduceToBase(source.Type()).(type) { switch sourceTypeBase := analyzer.ReduceToBase(source.Type()).(type) {
// conversion from array to slice // conversion from array to slice
case *entity.TypeArray: case *entity.TypeArray: