Untested rules for pulling types from other section kinds
This commit is contained in:
parent
d5687d7b0e
commit
5463435fae
@ -205,8 +205,8 @@ func (analyzer *analysisOperation) resolvePrimitive (
|
||||
case "U32": section = &PrimitiveU32
|
||||
case "U64": section = &PrimitiveU64
|
||||
case "Obj": section = &PrimitiveObj
|
||||
case "Face": section = &PrimitiveFace
|
||||
case "Func": section = &PrimitiveFunc
|
||||
// case "Face": section = &PrimitiveFace
|
||||
// case "Func": section = &PrimitiveFunc
|
||||
case "String": section = &BuiltInString
|
||||
default:
|
||||
exists = false
|
||||
|
@ -160,6 +160,8 @@ func (literal StringLiteral) canBePassedAs (what Type) (allowed bool) {
|
||||
|
||||
reduced, worked := what.reduce()
|
||||
if worked {
|
||||
// if the type was reduced to a non-basic type, only pass to
|
||||
// singular dynamic arrays.
|
||||
if !what.isSingular() { return }
|
||||
if reduced.kind != TypeKindVariableArray { return }
|
||||
what = reduced
|
||||
|
@ -83,15 +83,20 @@ func (section TypeSection) Member (
|
||||
}
|
||||
|
||||
if !exists {
|
||||
actual := section.what.actual
|
||||
if actual == nil { return }
|
||||
if section.what.actual == nil { return }
|
||||
|
||||
actual, isTypeSection := section.what.actual.(*TypeSection)
|
||||
if !isTypeSection { return }
|
||||
member, exists = actual.Member(name)
|
||||
}
|
||||
|
||||
case TypeKindPointer:
|
||||
points := section.what.points
|
||||
if points == nil { return }
|
||||
member, exists = points.actual.Member(name)
|
||||
|
||||
actual, isTypeSection := points.actual.(*TypeSection)
|
||||
if !isTypeSection { return }
|
||||
member, exists = actual.Member(name)
|
||||
}
|
||||
|
||||
return
|
||||
@ -164,7 +169,7 @@ func (analyzer *analysisOperation) analyzeObjectMembers (
|
||||
) (
|
||||
err error,
|
||||
) {
|
||||
inheritedSection := into.what.actual
|
||||
inheritedSection := into.what.actual.(*TypeSection)
|
||||
inheritsFromSameModule := analyzer.inCurrentModule(inheritedSection)
|
||||
|
||||
for index := 0; index < from.MembersLength(); index ++ {
|
||||
|
@ -107,11 +107,35 @@ func (what Type) underlyingPrimitive () (underlying *TypeSection) {
|
||||
return
|
||||
|
||||
case nil:
|
||||
panic("invalid state: Type.actual is nil")
|
||||
panic (
|
||||
"invalid state: Type.actual is nil for " +
|
||||
what.Describe() + " " +
|
||||
what.locatable.location.Describe())
|
||||
|
||||
default:
|
||||
// if none of the primitives matched, recurse.
|
||||
underlying = actual.what.underlyingPrimitive()
|
||||
switch actual.(type) {
|
||||
case *TypeSection:
|
||||
underlying =
|
||||
actual.(*TypeSection).
|
||||
what.underlyingPrimitive()
|
||||
// TODO
|
||||
// case *FaceSection:
|
||||
// TODO: depending on if this is an object interface or
|
||||
// a function interface, return either Face or Func.
|
||||
// we can assume this because of inheritence rules.
|
||||
|
||||
// // case *EnumSection:
|
||||
// underlying =
|
||||
// actual.(*EnumSection).
|
||||
// what.underlyingPrimitive()
|
||||
|
||||
default:
|
||||
panic (
|
||||
"invalid state: type " + what.Describe() +
|
||||
"has illegal actual " +
|
||||
what.locatable.location.Describe())
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -137,7 +161,23 @@ func (what Type) isSingular () (singular bool) {
|
||||
if actual == nil {
|
||||
return
|
||||
} else {
|
||||
singular = actual.what.isSingular()
|
||||
switch actual.(type) {
|
||||
case *TypeSection:
|
||||
singular = actual.(*TypeSection).what.isSingular()
|
||||
// TODO: uncomment this when these sections have been
|
||||
// implemented
|
||||
// case *FaceSection:
|
||||
// singular = true
|
||||
|
||||
// case *EnumSection:
|
||||
// singular = actual.(*EnumSection).what.isSingular()
|
||||
|
||||
default:
|
||||
panic (
|
||||
"invalid state: type " + what.Describe() +
|
||||
"has illegal actual " +
|
||||
what.locatable.location.Describe())
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -163,7 +203,25 @@ func (what Type) reduce () (reduced Type, reducible bool) {
|
||||
}
|
||||
|
||||
// otherwise, recurse
|
||||
reduced, reducible = what.actual.what.reduce()
|
||||
switch what.actual.(type) {
|
||||
case *TypeSection:
|
||||
reduced, reducible = what.actual.(*TypeSection).what.reduce()
|
||||
|
||||
// TODO: uncomment this when these sections have been
|
||||
// implemented
|
||||
// case *FaceSection:
|
||||
// singular = true
|
||||
|
||||
// case *EnumSection:
|
||||
// reduced, reducible = what.actual.(*EnumSection).what.reduce()
|
||||
|
||||
default:
|
||||
panic (
|
||||
"invalid state: type " + what.Describe() +
|
||||
"has illegal actual " +
|
||||
what.locatable.location.Describe())
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@ -208,11 +266,16 @@ func (analyzer analysisOperation) analyzeType (
|
||||
return
|
||||
}
|
||||
|
||||
var worked bool
|
||||
outputType.actual, worked = actual.(*TypeSection)
|
||||
if !worked {
|
||||
actualIsValidSectionKind := false
|
||||
switch actual.(type) {
|
||||
// TODO: uncomment once these sections are implemented
|
||||
case *TypeSection /* , *EnumSection, *FaceSection */:
|
||||
actualIsValidSectionKind = true
|
||||
}
|
||||
|
||||
if !actualIsValidSectionKind {
|
||||
err = inputType.NewError (
|
||||
"this must refer to a type or an interface",
|
||||
"this must refer to a type, interface, or enum",
|
||||
infoerr.ErrorKindError)
|
||||
return
|
||||
}
|
||||
@ -246,10 +309,6 @@ func (what Type) Describe () (description string) {
|
||||
description += "F32"
|
||||
case &PrimitiveF64:
|
||||
description += "F64"
|
||||
case &PrimitiveFunc:
|
||||
description += "Func"
|
||||
case &PrimitiveFace:
|
||||
description += "Face"
|
||||
case &PrimitiveObj:
|
||||
description += "Obj"
|
||||
case &PrimitiveU64:
|
||||
@ -272,11 +331,15 @@ func (what Type) Describe () (description string) {
|
||||
description += "UInt"
|
||||
case &PrimitiveInt:
|
||||
description += "Int"
|
||||
// case &PrimitiveFunc:
|
||||
// description += "Func"
|
||||
// case &PrimitiveFace:
|
||||
// description += "Face"
|
||||
case &BuiltInString:
|
||||
description += "String"
|
||||
|
||||
case nil:
|
||||
panic("invalid state: Type.actual is nil")
|
||||
description += "NIL-TYPE-ACTUAL"
|
||||
|
||||
default:
|
||||
description += actual.ModuleName() + "." + actual.Name()
|
||||
|
Reference in New Issue
Block a user