]> gitweb.factorcode.org Git - factor.git/commitdiff
fix STRUCT: functor when a slot name is the same as a non-lexical word name
authorJoe Groff <arcata@gmail.com>
Sun, 30 Aug 2009 01:19:47 +0000 (20:19 -0500)
committerJoe Groff <arcata@gmail.com>
Sun, 30 Aug 2009 01:19:47 +0000 (20:19 -0500)
basis/functors/functors-tests.factor
basis/functors/functors.factor

index a8d97927f8c021c32483ce98154dba8de102eb40..bcdc1bae740bc23c96836a836f3d531670293682 100644 (file)
@@ -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
index befe3aa174fa029f58dad732dbafce256b9b7e46..dcfd140e92da6d908dd6132d2616324eac477d32 100644 (file)
@@ -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 {