Add Position() method to type
This commit is contained in:
parent
e30f2a74da
commit
bc88782938
|
@ -11,7 +11,7 @@ import "git.tebibyte.media/fspl/fspl/errors"
|
|||
// function.
|
||||
type Signature struct {
|
||||
// Syntax
|
||||
Position errors.Position
|
||||
Pos errors.Position
|
||||
Name string
|
||||
Arguments []*Declaration
|
||||
Return Type
|
||||
|
@ -23,6 +23,7 @@ type Signature struct {
|
|||
ArgumentMap map[string] *Declaration
|
||||
}
|
||||
func (*Signature) ty(){}
|
||||
func (this *Signature) Position () errors.Position { return this.Pos }
|
||||
func (this *Signature) Access () Access { return this.Acc }
|
||||
func (this *Signature) Unit () uuid.UUID { return this.Unt }
|
||||
func (this *Signature) String () string {
|
||||
|
|
|
@ -9,6 +9,9 @@ import "git.tebibyte.media/fspl/fspl/errors"
|
|||
type Type interface {
|
||||
fmt.Stringer
|
||||
|
||||
// Position returns the position of the type within its source file.
|
||||
Position () errors.Position
|
||||
|
||||
// Equals reports whether this type is equivalent to another type.
|
||||
Equals (ty Type) bool
|
||||
|
||||
|
@ -27,7 +30,7 @@ type Type interface {
|
|||
// TypeNamed refers to a user-defined or built in named type.
|
||||
type TypeNamed struct {
|
||||
// Syntax
|
||||
Position errors.Position
|
||||
Pos errors.Position
|
||||
UnitNickname string
|
||||
Name string
|
||||
Type Type
|
||||
|
@ -37,6 +40,7 @@ type TypeNamed struct {
|
|||
Unt uuid.UUID
|
||||
}
|
||||
func (*TypeNamed) ty(){}
|
||||
func (this *TypeNamed) Position () errors.Position { return this.Pos }
|
||||
func (this *TypeNamed) Access () Access { return this.Acc }
|
||||
func (this *TypeNamed) Unit () uuid.UUID { return this.Unt }
|
||||
func (this *TypeNamed) String () string {
|
||||
|
@ -59,7 +63,7 @@ func (this *TypeNamed) Equals (ty Type) bool {
|
|||
|
||||
// TypePointer is a pointer to another type.
|
||||
type TypePointer struct {
|
||||
Position errors.Position
|
||||
Pos errors.Position
|
||||
Referenced Type
|
||||
|
||||
// Semantics
|
||||
|
@ -67,6 +71,7 @@ type TypePointer struct {
|
|||
Unt uuid.UUID
|
||||
}
|
||||
func (*TypePointer) ty(){}
|
||||
func (this *TypePointer) Position () errors.Position { return this.Pos }
|
||||
func (this *TypePointer) Access () Access { return this.Acc }
|
||||
func (this *TypePointer) Unit () uuid.UUID { return this.Unt }
|
||||
func (this *TypePointer) String () string {
|
||||
|
@ -85,7 +90,7 @@ func (this *TypePointer) Equals (ty Type) bool {
|
|||
// eachother. Its length is not built into its type and can be changed at
|
||||
// runtime.
|
||||
type TypeSlice struct {
|
||||
Position errors.Position
|
||||
Pos errors.Position
|
||||
Element Type
|
||||
|
||||
// Semantics
|
||||
|
@ -93,6 +98,7 @@ type TypeSlice struct {
|
|||
Unt uuid.UUID
|
||||
}
|
||||
func (*TypeSlice) ty(){}
|
||||
func (this *TypeSlice) Position () errors.Position { return this.Pos }
|
||||
func (this *TypeSlice) Access () Access { return this.Acc }
|
||||
func (this *TypeSlice) Unit () uuid.UUID { return this.Unt }
|
||||
func (this *TypeSlice) String () string {
|
||||
|
@ -111,7 +117,7 @@ func (this *TypeSlice) Equals (ty Type) bool {
|
|||
// length of an array is fixed and is part of its type. Arrays are passed by
|
||||
// value unless a pointer is used.
|
||||
type TypeArray struct {
|
||||
Position errors.Position
|
||||
Pos errors.Position
|
||||
Length int
|
||||
Element Type
|
||||
|
||||
|
@ -120,6 +126,7 @@ type TypeArray struct {
|
|||
Unt uuid.UUID
|
||||
}
|
||||
func (*TypeArray) ty(){}
|
||||
func (this *TypeArray) Position () errors.Position { return this.Pos }
|
||||
func (this *TypeArray) Access () Access { return this.Acc }
|
||||
func (this *TypeArray) Unit () uuid.UUID { return this.Unt }
|
||||
func (this *TypeArray) String () string {
|
||||
|
@ -128,7 +135,7 @@ func (this *TypeArray) String () string {
|
|||
func (this *TypeArray) Hash () Hash {
|
||||
referenced := HashType(this.Element)
|
||||
return NewHash(append (
|
||||
[]byte(fmt.Sprintf("TypeArray:%s:", this.Length)),
|
||||
[]byte(fmt.Sprintf("TypeArray:%d:", this.Length)),
|
||||
referenced[:]...))
|
||||
}
|
||||
func (this *TypeArray) Equals (ty Type) bool {
|
||||
|
@ -143,7 +150,7 @@ func (this *TypeArray) Equals (ty Type) bool {
|
|||
// are specified in. Structs are passed by value unless a pointer is used.
|
||||
type TypeStruct struct {
|
||||
// Syntax
|
||||
Position errors.Position
|
||||
Pos errors.Position
|
||||
Members []*Declaration
|
||||
|
||||
// Semantics
|
||||
|
@ -153,6 +160,7 @@ type TypeStruct struct {
|
|||
MemberMap map[string] *Declaration
|
||||
}
|
||||
func (*TypeStruct) ty(){}
|
||||
func (this *TypeStruct) Position () errors.Position { return this.Pos }
|
||||
func (this *TypeStruct) Access () Access { return this.Acc }
|
||||
func (this *TypeStruct) Unit () uuid.UUID { return this.Unt }
|
||||
func (this *TypeStruct) String () string {
|
||||
|
@ -190,7 +198,7 @@ func (this *TypeStruct) Equals (ty Type) bool {
|
|||
// pointer to an interface, the pointer's reference will be used instead.
|
||||
type TypeInterface struct {
|
||||
// Syntax
|
||||
Position errors.Position
|
||||
Pos errors.Position
|
||||
Behaviors []*Signature
|
||||
|
||||
// Semantics
|
||||
|
@ -200,6 +208,7 @@ type TypeInterface struct {
|
|||
BehaviorMap map[string] *Signature
|
||||
}
|
||||
func (*TypeInterface) ty(){}
|
||||
func (this *TypeInterface) Position () errors.Position { return this.Pos }
|
||||
func (this *TypeInterface) Access () Access { return this.Acc }
|
||||
func (this *TypeInterface) Unit () uuid.UUID { return this.Unt }
|
||||
func (this *TypeInterface) String () string {
|
||||
|
@ -239,16 +248,15 @@ func (this *TypeInterface) Equals (ty Type) bool {
|
|||
// allowed list.
|
||||
type TypeUnion struct {
|
||||
// Syntax
|
||||
Position errors.Position
|
||||
Pos errors.Position
|
||||
Allowed []Type
|
||||
|
||||
// Semantics
|
||||
Acc Access
|
||||
Unt uuid.UUID
|
||||
TypeOrder []string
|
||||
AllowedMap map[string] Type
|
||||
Acc Access
|
||||
Unt uuid.UUID
|
||||
}
|
||||
func (*TypeUnion) ty(){}
|
||||
func (this *TypeUnion) Position () errors.Position { return this.Pos }
|
||||
func (this *TypeUnion) Access () Access { return this.Acc }
|
||||
func (this *TypeUnion) Unit () uuid.UUID { return this.Unt }
|
||||
func (this *TypeUnion) String () string {
|
||||
|
@ -281,7 +289,7 @@ func (this *TypeUnion) Equals (ty Type) bool {
|
|||
|
||||
// TypeInt represents any signed or unsigned integer type.
|
||||
type TypeInt struct {
|
||||
Position errors.Position
|
||||
Pos errors.Position
|
||||
Width int
|
||||
Signed bool
|
||||
|
||||
|
@ -290,6 +298,7 @@ type TypeInt struct {
|
|||
Unt uuid.UUID
|
||||
}
|
||||
func (*TypeInt) ty(){}
|
||||
func (this *TypeInt) Position () errors.Position { return this.Pos }
|
||||
func (this *TypeInt) Access () Access { return this.Acc }
|
||||
func (this *TypeInt) Unit () uuid.UUID { return this.Unt }
|
||||
func (this *TypeInt) String () string {
|
||||
|
@ -311,7 +320,7 @@ func (this *TypeInt) Equals (ty Type) bool {
|
|||
|
||||
// TypeFloat represents any floating point type.
|
||||
type TypeFloat struct {
|
||||
Position errors.Position
|
||||
Pos errors.Position
|
||||
Width int
|
||||
|
||||
// Semantics
|
||||
|
@ -319,6 +328,7 @@ type TypeFloat struct {
|
|||
Unt uuid.UUID
|
||||
}
|
||||
func (*TypeFloat) ty(){}
|
||||
func (this *TypeFloat) Position () errors.Position { return this.Pos }
|
||||
func (this *TypeFloat) Access () Access { return this.Acc }
|
||||
func (this *TypeFloat) Unit () uuid.UUID { return this.Unt }
|
||||
func (this *TypeFloat) String () string {
|
||||
|
@ -336,7 +346,7 @@ func (this *TypeFloat) Equals (ty Type) bool {
|
|||
// is chosen based on the machine word size (32 on 32 bit systems, 64 on 64 bit
|
||||
// systems, etc)
|
||||
type TypeWord struct {
|
||||
Position errors.Position
|
||||
Pos errors.Position
|
||||
Signed bool
|
||||
|
||||
// Semantics
|
||||
|
@ -344,6 +354,7 @@ type TypeWord struct {
|
|||
Unt uuid.UUID
|
||||
}
|
||||
func (*TypeWord) ty(){}
|
||||
func (this *TypeWord) Position () errors.Position { return this.Pos }
|
||||
func (this *TypeWord) Access () Access { return this.Acc }
|
||||
func (this *TypeWord) Unit () uuid.UUID { return this.Unt }
|
||||
func (this *TypeWord) String () string {
|
||||
|
|
Loading…
Reference in New Issue