Changeset 22313

Show
Ignore:
Timestamp:
09/22/08 19:30:53 (2 months ago)
Author:
pmurias
Message:

[pugs][smop]
lexical variable work in pugs -Cm0ld
Pugs.Compile.compile marks lexical delarations in PIL1 although not fully correctly

Files:
5 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/CodeGen/M0ld.hs

    r22306 r22313  
    2828    ++ "$void = $OUT_scalar.\"STORE\"($OUT_root);\n" 
    2929    ++ "\n" 
     30 
    3031    ++ "my $Code_scalar = $scope.\"postcircumfix:{ }\"(\"Code\");\n" 
    3132    ++ "my $Code_root_scalar = ?SMOP__S1P__RootNamespace.\"postcircumfix:{ }\"(\"::Code\");\n" 
    3233    ++ "my $Code = $Code_root_scalar.\"FETCH\"();\n" 
    3334    ++ "$void = $Code_scalar.\"STORE\"($Code);\n" 
     35 
     36    ++ "my $Scalar_scalar = $scope.\"postcircumfix:{ }\"(\"Scalar\");\n" 
     37    ++ "my $Scalar_root_scalar = ?SMOP__S1P__RootNamespace.\"postcircumfix:{ }\"(\"::Scalar\");\n" 
     38    ++ "my $Scalar = $Scalar_root_scalar.\"FETCH\"();\n" 
     39    ++ "$void = $Scalar_scalar.\"STORE\"($Scalar);\n" 
     40 
    3441    ++ "\n" 
    3542    ++ "\n" 
     
    4148            ++ "my $Code_scalar = $scope.\"lookup\"(\"Code\");\n" 
    4249            ++ "my $Code = $Code_scalar.\"FETCH\"();\n" 
     50            ++ "my $Scalar_scalar = $scope.\"lookup\"(\"Scalar\");\n" 
     51            ++ "my $Scalar = $Scalar_scalar.\"FETCH\"();\n" 
    4352 
    4453instance EmitM0ld PIL_Environment where 
     
    4958    emit statement r = case statement of 
    5059        PNil                           -> return "nil" 
    51         PPad {}                        -> return "pad" 
     60        PPad {pStmts=rest,pScope=SMy,pSyms=[(var,_)]} -> do 
     61            new_scalar <- uniqueId 
     62            lexpad_cell <- uniqueId 
     63            rest <- emit rest r 
     64            return $ 
     65                "my " ++ new_scalar ++ " = $Scalar.\"new\"();\n" 
     66                ++  "my " ++ lexpad_cell ++ " = $scope.\"postcircumfix:{ }\"(" ++ (show var) ++ ");\n" 
     67                ++ "my $void = " ++ lexpad_cell ++ ".\"STORE\"(" ++ new_scalar ++ ");\n" 
     68                ++ rest 
    5269        PStmts{pStmt=stmt,pStmts=PNil} -> emit stmt r 
    5370        PStmts{pStmt=stmt,pStmts=rest} -> do  
  • src/Pugs/Compile.hs

    r21930 r22313  
    2626import Language.PIR 
    2727import Text.PrettyPrint 
     28import qualified Data.ByteString.Char8 as BS 
    2829 
    2930tcVoid, tcLValue :: TCxt 
     
    384385_PVar = PVar . cast 
    385386 
     387addPad stmt entry = PPad{pStmts=stmt,pScope=SMy,pSyms=[((BS.unpack $ cast $ fst entry),PRawName "...")]} 
    386388{-| Compiles various 'Exp's to 'PIL_Expr's. -} 
    387389instance Compile Exp PIL_Expr where 
     
    399401        bodyC   <- compile body 
    400402        return $ PExp $ PApp cxt (pBlock bodyC) Nothing [] 
    401     compile (Syn "sub" [Val (VCode sub)]) = do 
     403    compile (Syn "sub" [Val (VCode sub)]) =  do 
    402404        bodyC   <- enter sub $ compile $ case subBody sub of 
    403405            Syn "block" [exp]   -> exp 
    404406            exp                 -> exp 
    405407        paramsC <- compile $ subParams sub 
    406         return $ PCode (subType sub) paramsC (subLValue sub) (isMulti sub) bodyC 
     408        return $ PCode (subType sub) paramsC (subLValue sub) (isMulti sub) (foldl addPad bodyC (padToList $ subInnerPad sub)) 
    407409    compile (Syn "module" _) = compile Noop 
    408410    compile (Syn "match" exp) = compile $ Syn "rx" exp -- wrong 
  • v6/smop/src/smop_s1p_hash.c

    r22017 r22313  
    7474      ret = SMOP_REFERENCE(interpreter,cell); 
    7575    } else { 
    76       fprintf(stderr,"wrong number of arguments to postrcicumfix:<{ }>\n"); 
     76      fprintf(stderr,"wrong number of arguments to postcircumfix:<{ }>\n"); 
    7777    } 
    7878 
  • v6/smop/src/smop_s1p_root_namespace.c

    r22281 r22313  
    3030  smop_s1p_root_namespace_insert(SMOP__GlobalInterpreter,"::MoldFrame", SMOP__Mold__Frame); 
    3131  smop_s1p_root_namespace_insert(SMOP__GlobalInterpreter,"::Code", SMOP__S1P__Code); 
     32  smop_s1p_root_namespace_insert(SMOP__GlobalInterpreter,"::Scalar", SMOP__S1P__Scalar); 
    3233} 
    3334 
  • v6/smop/test/33_pugs_simple.p6-pugs

    r22306 r22313  
    1 $*OUT.print("1..","1\n"); 
    2 $*OUT.print("ok 1\n"); 
     1my $one = "1"; 
     2$*OUT.print("1..1","\n"); 
     3$*OUT.print("ok ",$one,"\n");