Merge pull request 'objt-bitfields' (#8) from objt-bitfields into main
Reviewed-on: sashakoshka/arf#8
This commit is contained in:
commit
821fa0ecb3
@ -96,6 +96,17 @@ func (parser *ParsingOperation) parseObjtMember () (
|
|||||||
if err != nil { return }
|
if err != nil { return }
|
||||||
member.what, err = parser.parseType()
|
member.what, err = parser.parseType()
|
||||||
if err != nil { return }
|
if err != nil { return }
|
||||||
|
|
||||||
|
println(parser.token.Describe())
|
||||||
|
|
||||||
|
// if there is a bit width, get it
|
||||||
|
if parser.token.Is(lexer.TokenKindBinaryAnd) {
|
||||||
|
err = parser.nextToken(lexer.TokenKindUInt)
|
||||||
|
if err != nil { return }
|
||||||
|
member.bitWidth = parser.token.Value().(uint64)
|
||||||
|
err = parser.nextToken()
|
||||||
|
if err != nil { return }
|
||||||
|
}
|
||||||
|
|
||||||
// parse default value
|
// parse default value
|
||||||
if parser.token.Is(lexer.TokenKindNewline) {
|
if parser.token.Is(lexer.TokenKindNewline) {
|
||||||
|
@ -9,6 +9,9 @@ func TestObjt (test *testing.T) {
|
|||||||
objt ro Basic:Obj
|
objt ro Basic:Obj
|
||||||
ro that:Basic
|
ro that:Basic
|
||||||
ro this:Basic
|
ro this:Basic
|
||||||
|
objt ro BitFields:Obj
|
||||||
|
ro that:Int & 1
|
||||||
|
ro this:Int & 24 298
|
||||||
objt ro ComplexInit:Obj
|
objt ro ComplexInit:Obj
|
||||||
ro basic:Int 87
|
ro basic:Int 87
|
||||||
ro complex0:Bird
|
ro complex0:Bird
|
||||||
|
@ -297,6 +297,10 @@ func (member ObjtMember) ToString (indent int) (output string) {
|
|||||||
output += member.permission.ToString() + " "
|
output += member.permission.ToString() + " "
|
||||||
output += member.name + ":"
|
output += member.name + ":"
|
||||||
output += member.what.ToString()
|
output += member.what.ToString()
|
||||||
|
|
||||||
|
if member.bitWidth > 0 {
|
||||||
|
output += fmt.Sprint(" & ", member.bitWidth)
|
||||||
|
}
|
||||||
|
|
||||||
isComplexInitialization :=
|
isComplexInitialization :=
|
||||||
member.defaultValue.kind == ArgumentKindObjectInitializationValues ||
|
member.defaultValue.kind == ArgumentKindObjectInitializationValues ||
|
||||||
|
@ -178,8 +178,9 @@ type TypeSection struct {
|
|||||||
type ObjtMember struct {
|
type ObjtMember struct {
|
||||||
location file.Location
|
location file.Location
|
||||||
name string
|
name string
|
||||||
|
|
||||||
what Type
|
what Type
|
||||||
|
bitWidth uint64
|
||||||
permission types.Permission
|
permission types.Permission
|
||||||
defaultValue Argument
|
defaultValue Argument
|
||||||
}
|
}
|
||||||
@ -188,7 +189,8 @@ type ObjtMember struct {
|
|||||||
type ObjtSection struct {
|
type ObjtSection struct {
|
||||||
location file.Location
|
location file.Location
|
||||||
name string
|
name string
|
||||||
|
|
||||||
|
// TODO: make this Identifier instead of Type
|
||||||
inherits Type
|
inherits Type
|
||||||
permission types.Permission
|
permission types.Permission
|
||||||
// TODO: order matters here we need to store these in an array
|
// TODO: order matters here we need to store these in an array
|
||||||
@ -225,6 +227,7 @@ type FaceBehavior struct {
|
|||||||
type FaceSection struct {
|
type FaceSection struct {
|
||||||
location file.Location
|
location file.Location
|
||||||
name string
|
name string
|
||||||
|
// TODO: make this Identifier instead of string
|
||||||
inherits string
|
inherits string
|
||||||
|
|
||||||
permission types.Permission
|
permission types.Permission
|
||||||
|
@ -4,6 +4,10 @@ objt ro Basic:Obj
|
|||||||
ro that:Basic
|
ro that:Basic
|
||||||
ro this:Basic
|
ro this:Basic
|
||||||
|
|
||||||
|
objt ro BitFields:Obj
|
||||||
|
ro that:Int & 1
|
||||||
|
ro this:Int & 24 298
|
||||||
|
|
||||||
objt ro Init:Obj
|
objt ro Init:Obj
|
||||||
ro that:String "hello world"
|
ro that:String "hello world"
|
||||||
ro this:Int 23
|
ro this:Int 23
|
||||||
|
Reference in New Issue
Block a user