Pointers and dynamic arrays are accounted for
This commit is contained in:
parent
ae0765b8f4
commit
308996f059
@ -125,16 +125,6 @@ func (analyzer analysisOperation) analyzeTypeSection () (
|
|||||||
outputSection.what, err = analyzer.analyzeType(inputSection.Type())
|
outputSection.what, err = analyzer.analyzeType(inputSection.Type())
|
||||||
if err != nil { return }
|
if err != nil { return }
|
||||||
|
|
||||||
// type sections are only allowed to inherit other type sections
|
|
||||||
_, inheritsFromTypeSection := outputSection.what.actual.(*TypeSection)
|
|
||||||
if !inheritsFromTypeSection {
|
|
||||||
err = inputSection.Type().NewError (
|
|
||||||
"type sections can only inherit from other type " +
|
|
||||||
"sections",
|
|
||||||
infoerr.ErrorKindError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !inputSection.Argument().Nil() {
|
if !inputSection.Argument().Nil() {
|
||||||
outputSection.argument,
|
outputSection.argument,
|
||||||
err = analyzer.analyzeArgument(inputSection.Argument())
|
err = analyzer.analyzeArgument(inputSection.Argument())
|
||||||
|
@ -38,8 +38,12 @@ typeSection ro ../tests/analyzer/typeSection.fInheritObjectFromOther
|
|||||||
type 1 basic Int
|
type 1 basic Int
|
||||||
arg uint 238
|
arg uint 238
|
||||||
typeSection ro ../tests/analyzer/typeSection.gPointer
|
typeSection ro ../tests/analyzer/typeSection.gPointer
|
||||||
type 1 pointer {Int}
|
type 1 pointer {
|
||||||
|
type 1 basic Int
|
||||||
|
}
|
||||||
typeSection ro ../tests/analyzer/typeSection.hDynamicArray
|
typeSection ro ../tests/analyzer/typeSection.hDynamicArray
|
||||||
type 1 dynamicArray {Int}
|
type 1 dynamicArray {
|
||||||
|
type 1 basic Int
|
||||||
|
}
|
||||||
`, test)
|
`, test)
|
||||||
}
|
}
|
||||||
|
@ -284,11 +284,21 @@ func (analyzer analysisOperation) analyzeType (
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch inputType.Kind() {
|
||||||
|
case parser.TypeKindBasic:
|
||||||
|
outputType.kind = TypeKindBasic
|
||||||
|
case parser.TypeKindPointer:
|
||||||
|
outputType.kind = TypeKindPointer
|
||||||
|
case parser.TypeKindVariableArray:
|
||||||
|
outputType.kind = TypeKindVariableArray
|
||||||
|
}
|
||||||
|
|
||||||
if inputType.Kind() != parser.TypeKindBasic {
|
if inputType.Kind() != parser.TypeKindBasic {
|
||||||
// analyze type this type points to, if it exists
|
// analyze type this type points to, if it exists
|
||||||
var points Type
|
var points Type
|
||||||
points, err = analyzer.analyzeType(inputType.Points())
|
points, err = analyzer.analyzeType(inputType.Points())
|
||||||
outputType.points = &points
|
outputType.points = &points
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// analyze the type section this type uses
|
// analyze the type section this type uses
|
||||||
var node any
|
var node any
|
||||||
|
Reference in New Issue
Block a user