Show
Ignore:
Timestamp:
08/16/06 19:28:24 (2 years ago)
Author:
audreyt
Message:

* Glorious refactoring of the Var type.

Previously, Var is type synonym to String, and all package

lookups, OUTER
handling, sigil and twigil parsing etc were done in an extremely adhoc way with String operations.

Now we split Var into several parts.
Take "&Moose::Elk::infix:<antler>" as an example:

v_sigil
VarSigil? -- SScalar
v_twigil
VarTwigil? -- TNone
v_package
Pkg -- ["Moose", "Elk"]
v_categ
VarCateg? -- C_infix
v_name
ID -- "antler"

The names are stored as interned ByteStrings? for fast comparison.

All involved types are changed from String to new types as well,

such as (envPackage
Pkg).
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Prim/Param.hs

    r5843 r12317  
    55) where 
    66import Pugs.AST 
     7import Pugs.Internals 
    78 
    89doFoldParam :: String -> String -> [Param] -> [Param] 
    910doFoldParam cxt [] []       = [(buildParam cxt "" "$?1" (Val VUndef)) { isLValue = False }] 
    10 doFoldParam cxt [] (p:ps)   = ((buildParam cxt "" (strInc $ paramName p) (Val VUndef)) { isLValue = False }:p:ps) 
     11doFoldParam cxt [] (p:ps)   = ((buildParam cxt "" (strInc . cast $ paramName p) (Val VUndef)) { isLValue = False }:p:ps) 
    1112doFoldParam cxt (s:name) ps = ((buildParam cxt [s] name (Val VUndef)) { isLValue = False } : ps) 
    1213 
     
    2324    = \ps -> ((buildParam typ "?" "$?1" (Val VUndef)) { isLValue = True }:ps) 
    2425    | (('r':'w':'!':typ), "=$_") <- break (== '=') str 
    25     = \ps -> ((buildParam typ "?" "$?1" (Var "$_")) { isLValue = True }:ps) 
     26    = \ps -> ((buildParam typ "?" "$?1" (_Var "$_")) { isLValue = True }:ps) 
    2627    | (typ, "=$_") <- break (== '=') str 
    27     = \ps -> ((buildParam typ "?" "$?1" (Var "$_")) { isLValue = False }:ps) 
     28    = \ps -> ((buildParam typ "?" "$?1" (_Var "$_")) { isLValue = False }:ps) 
    2829    | (typ, ('=':def)) <- break (== '=') str 
    2930    = let readVal "Num" = Val . VNum . read