From 2e3f75fd8783fdabb27b77b2cc00c70927245958 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sat, 29 Aug 2009 20:19:47 -0500 Subject: [PATCH] fix STRUCT: functor when a slot name is the same as a non-lexical word name --- basis/functors/functors-tests.factor | 12 ++++++------ basis/functors/functors.factor | 14 ++++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/basis/functors/functors-tests.factor b/basis/functors/functors-tests.factor index a8d97927f8..bcdc1bae74 100644 --- a/basis/functors/functors-tests.factor +++ b/basis/functors/functors-tests.factor @@ -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 diff --git a/basis/functors/functors.factor b/basis/functors/functors.factor index befe3aa174..dcfd140e92 100644 --- a/basis/functors/functors.factor +++ b/basis/functors/functors.factor @@ -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 {