fix STRUCT: functor when a slot name is the same as a non-lexical word name
parent
309b11213c
commit
2e3f75fd87
|
@ -161,10 +161,10 @@ WHERE
|
|||
|
||||
STRUCT: T-class
|
||||
{ NAME int }
|
||||
{ "x" { TYPE 4 } }
|
||||
{ "y" { "short" N } }
|
||||
{ "z" TYPE initial: 5 }
|
||||
{ "w" { "int" 2 } } ;
|
||||
{ x { TYPE 4 } }
|
||||
{ y { "short" N } }
|
||||
{ z TYPE initial: 5 }
|
||||
{ float { "float" 2 } } ;
|
||||
|
||||
;FUNCTOR
|
||||
|
||||
|
@ -203,11 +203,11 @@ STRUCT: T-class
|
|||
{ c-type "char" }
|
||||
}
|
||||
T{ struct-slot-spec
|
||||
{ name "w" }
|
||||
{ name "float" }
|
||||
{ offset 16 }
|
||||
{ class object }
|
||||
{ initial f }
|
||||
{ c-type { "int" 2 } }
|
||||
{ c-type { "float" 2 } }
|
||||
}
|
||||
}
|
||||
] [ a-struct struct-slots ] unit-test
|
||||
|
|
|
@ -58,15 +58,17 @@ M: object (fake-quotations>) , ;
|
|||
[ parse-definition* ] dip
|
||||
parsed ;
|
||||
|
||||
: >string-param ( string -- string/param )
|
||||
dup search dup lexical? [ nip ] [ drop ] if ;
|
||||
|
||||
: scan-c-type* ( -- c-type/param )
|
||||
scan {
|
||||
{ [ dup "{" = ] [ drop \ } parse-until >array ] }
|
||||
{ [ dup search ] [ search ] }
|
||||
[ ]
|
||||
} cond ;
|
||||
scan dup "{" = [ drop \ } parse-until >array ] [ >string-param ] if ;
|
||||
|
||||
: scan-string-param ( -- name/param )
|
||||
scan >string-param ;
|
||||
|
||||
:: parse-struct-slot* ( accum -- accum )
|
||||
scan-param :> name
|
||||
scan-string-param :> name
|
||||
scan-c-type* :> c-type
|
||||
\ } parse-until :> attributes
|
||||
accum {
|
||||
|
|
Loading…
Reference in New Issue