Changeset 6801
- Timestamp:
- 09/06/05 17:00:17 (3 years ago)
- Files:
-
- 13 modified
-
debian/patches/00list (modified) (2 props)
-
debian/patches/10smoker.dpatch (modified) (2 props)
-
debian/smoker.yml (modified) (2 props)
-
ext/Test/lib/Test.pm (modified) (1 diff)
-
perl5/PIL2JS/lib/PIL.pm (modified) (1 diff)
-
perl5/PIL2JS/lib/PIL/Subs.pm (modified) (5 diffs)
-
perl5/PIL2JS/libjs/PIL2JS.js (modified) (2 diffs)
-
src/Pugs/CodeGen/PIR.hs (modified) (4 diffs)
-
src/Pugs/Compile.hs (modified) (6 diffs)
-
src/Pugs/PIL1.hs (modified) (9 diffs)
-
src/Pugs/PIL1.hs-drift (modified) (2 diffs)
-
t/var/constant.t (modified) (4 diffs)
-
util/cperl6-mode.el (modified) (2 props)
Legend:
- Unmodified
- Added
- Removed
-
debian/patches/00list
- Property svn:mime-type set to text/plain; charset=UTF-8
- Property svn:eol-style set to native
-
debian/patches/10smoker.dpatch
- Property svn:mime-type set to text/plain; charset=UTF-8
- Property svn:eol-style set to native
-
debian/smoker.yml
- Property svn:mime-type set to text/plain; charset=UTF-8
- Property svn:eol-style set to native
-
ext/Test/lib/Test.pm
r6708 r6801 182 182 multi sub skip (Int $count, Str $reason, +$depends) returns Bool is export { 183 183 for (1 .. $count) { 184 # Hack -- PIL2JS doesn't support multisubs yet 185 if $*OS eq "browser" { 186 Test::proclaim(1, "", "skip $reason", :depends($depends)); 187 } else { 188 Test::skip $reason, :depends($depends); 189 } 184 Test::skip $reason, :depends($depends); 190 185 } 191 186 } -
perl5/PIL2JS/lib/PIL.pm
r6694 r6801 201 201 # B.pm: use A; my $a = 4; # ==> my $a_1 = 4; XXX! 202 202 203 {204 my %seen;205 $self->{pilGlob} = [grep { not $seen{$_->{pSubName}}++ } @{ $self->{pilGlob} }];206 }203 #{ 204 # my %seen; 205 # $self->{pilGlob} = [grep { not $seen{$_->{pSubName}}++ } @{ $self->{pilGlob} }]; 206 #} 207 207 208 208 my $fixed_tree = $self->fixup; -
perl5/PIL2JS/lib/PIL/Subs.pm
r6693 r6801 14 14 15 15 sub prefix { "Sub" } 16 sub name :lvalue { $_[0]->{pSubName} } 17 sub type :lvalue { $_[0]->{pSubType} } 18 sub params :lvalue { $_[0]->{pSubParams} } 19 sub lvalue :lvalue { $_[0]->{pSubLValue} } 20 sub body :lvalue { $_[0]->{pSubBody} } 16 sub name :lvalue { $_[0]->{pSubName} } 17 sub type :lvalue { $_[0]->{pSubType} } 18 sub params :lvalue { $_[0]->{pSubParams} } 19 sub lvalue :lvalue { $_[0]->{pSubLValue} } 20 sub body :lvalue { $_[0]->{pSubBody} } 21 sub multi :lvalue { $_[0]->{pSubIsMulti} } 21 22 22 23 sub fixup { … … 55 56 if $self->name =~ /^__export_c.*import$/; 56 57 57 my $js = sprintf 58 "%s%s = new PIL2JS.Box(%s.FETCH());\n%s.FETCH().pil2js_name = %s;\n", 59 $PIL::IN_GLOBPIL ? "" : "var ", 58 my $def = sprintf "new PIL2JS.Box(%s.FETCH())", $self->SUPER::as_js; 59 my $name = sprintf "%s.FETCH().pil2js_name = %s", 60 60 PIL::name_mangle($self->name), 61 $self->SUPER::as_js, 62 PIL::name_mangle($self->name), 61 PIL::doublequote(($self->name =~ /^&.*::(?:prefix:|postfix:|infix:|circumfix:|coerce:|self:|term:|postcircumfix:|rule_modifier:|trait_verb:|trait_auxiliary:|scope_declarator:|statement_control:|infix_postfix_meta_operator:|postfix_prefix_meta_operator:|prefix_postfix_meta_operator:|infix_circumfix_meta_operator:)?(.+)$/)[0] or $self->name); 63 62 # "or $self->name" needed for the /^__export/ and /^__init/ subs. 64 PIL::doublequote(($self->name =~ /^&.*::(?:prefix:|postfix:|infix:|circumfix:|coerce:|self:|term:|postcircumfix:|rule_modifier:|trait_verb:|trait_auxiliary:|scope_declarator:|statement_control:|infix_postfix_meta_operator:|postfix_prefix_meta_operator:|prefix_postfix_meta_operator:|infix_circumfix_meta_operator:)?(.+)$/)[0] or $self->name); 63 64 my $decl = $self->multi 65 ? sprintf "if(!%s) var %s = new PIL2JS.Box(PIL2JS.new_multi());\n%s.FETCH().pil2js_multi.add_variant(%s, %d)", 66 PIL::name_mangle($self->name), 67 PIL::name_mangle($self->name), 68 PIL::name_mangle($self->name), 69 $def, 70 $self->arity 71 : sprintf "%s%s = %s;", 72 $PIL::IN_GLOBPIL ? "" : "var ", 73 PIL::name_mangle($self->name), 74 $def; 75 my $js = "$decl;\n$name;\n"; 65 76 66 77 # Special magic for methods. … … 96 107 sub prefix { "" } 97 108 sub name { "<anonymous@{[$PIL::CUR_SUBNAME ? ' in ' . $PIL::CUR_SUBNAME : '']}>" } 98 sub type :lvalue { $_[0]->{pType} } 99 sub params :lvalue { $_[0]->{pParams} } 100 sub lvalue :lvalue { $_[0]->{pLValue} } 101 sub body :lvalue { $_[0]->{pBody} } 109 sub arity { $_[0]->params->arity } 110 sub type :lvalue { $_[0]->{pType} } 111 sub params :lvalue { $_[0]->{pParams} } 112 sub lvalue :lvalue { $_[0]->{pLValue} } 113 sub body :lvalue { $_[0]->{pBody} } 114 sub multi :lvalue { $_[0]->{pIsMulti} } 102 115 103 116 sub fixup { … … 120 133 ? (pSubName => $self->name) 121 134 : (), 122 "p" . $self->prefix . "Type" => $self->type, 123 "p" . $self->prefix . "LValue" => $self->lvalue, 135 "p" . $self->prefix . "Type" => $self->type, 136 "p" . $self->prefix . "LValue" => $self->lvalue, 137 "p" . $self->prefix . "IsMulti" => $self->multi, 124 138 $self->params->fixup( 125 139 $self->prefix, … … 199 213 my $wrappedbody = "$new_pad;\n$callchain$magical_vars\n$bind;\n\n$body"; 200 214 201 my $jsbody = $params . "\n" . $self->params->autothread_wrapper($wrappedbody); 202 203 return sprintf "PIL2JS.Box.constant_func(%d, function (args) {\n%s;\n%s;\n%s\n%s\n})", 204 $self->params->arity, 215 my $jsbody = $self->multi 216 ? "$params\nif(only_check_for_params) return;\n\n" . $self->params->autothread_wrapper($wrappedbody) 217 : $params . "\n" . $self->params->autothread_wrapper($wrappedbody); 218 219 return sprintf "PIL2JS.Box.constant_func(%d, function (args) {\n%s;\n%s%s;\n%s\n%s\n})", 220 $self->arity, 205 221 # Lexicalize PIL2JS and thus speed up PIL2JS 206 222 PIL::add_indent(1, "var PIL2JS = AlsoPIL2JS_SpeedupHack"), 223 $self->multi 224 ? PIL::add_indent(1, "var only_check_for_params = args.only_check_for_params;\n") 225 : "", 207 226 PIL::add_indent(1, $backup), 208 227 PIL::add_indent(1, $ccsetup), -
perl5/PIL2JS/libjs/PIL2JS.js
r6693 r6801 105 105 106 106 var candidates = []; 107 for(var i = 0; i < this.variants; i++) { 108 if(this.variants[arity] == argc) { 109 candidates.push(this.variants[arity]); 107 for(var i = 0; i < this.variants.length; i++) { 108 if(this.variants[i].arity == argc) { 109 candidates.push(this.variants[i]); 110 } 111 } 112 113 if(candidates.length == 0) { 114 // Hack? 115 for(var i = 0; i < this.variants.length; i++) { 116 var pargs = [].concat(orig_args); 117 pargs.only_check_for_params = true; 118 119 var ok = true; 120 try { this.variants[i].code.FETCH()(pargs) } catch(err) { 121 // The sub wasn't able to bind pargs to its parameters. 122 ok = false; 123 } 124 125 // Was the sub able to bind pargs to its parameters? 126 if(ok) { 127 // Yes, so add the sub to our candidate list! 128 candidates.push(this.variants[i]); 129 } 110 130 } 111 131 } … … 117 137 } 118 138 119 return can idates[0].code(orig_args);139 return candidates[0].code.FETCH()(orig_args); 120 140 }; 121 141 PIL2JS.new_multi = function () { -
src/Pugs/CodeGen/PIR.hs
r6424 r6801 106 106 tellLabel endL 107 107 return (ExpLV this) 108 trans (PCode styp params _ body) = do108 trans (PCode styp params _ _ body) = do 109 109 [begL, endL] <- genLabel ["blockBegin", "blockEnd"] 110 110 this <- genPMC "block" … … 126 126 127 127 instance Translate PIL_Decl Decl where 128 trans (PSub name styp params lvalue body) | Just (pkg, name') <- isQualified name = do129 declC <- trans $ PSub name' styp params lvalue body128 trans (PSub name styp params lvalue ismulti body) | Just (pkg, name') <- isQualified name = do 129 declC <- trans $ PSub name' styp params lvalue ismulti body 130 130 return $ DeclNS pkg [declC] 131 trans (PSub name styp params _ body) = do131 trans (PSub name styp params _ _ body) = do 132 132 (_, stmts) <- listen $ do 133 133 let prms = map tpParam params … … 186 186 tellIns $ lhsC <:= rhsC 187 187 return lhsC 188 trans (PApp _ exp@(PCode _ _ _ _ ) Nothing []) = do188 trans (PApp _ exp@(PCode _ _ _ _ _) Nothing []) = do 189 189 blockC <- trans exp 190 190 tellIns $ [reg tempPMC] <-& blockC $ [] … … 383 383 , InsNew tempPMC PerlScalar 384 384 , "store_global" .- [lit "$_", tempPMC] 385 ]) ++ [ StmtRaw (text (name ++ "()")) | PSub name@('_':'_':_) _ _ _ _ <- pilGlob penv ] ++385 ]) ++ [ StmtRaw (text (name ++ "()")) | PSub name@('_':'_':_) _ _ _ _ _ <- pilGlob penv ] ++ 386 386 [ StmtRaw (text "main()") 387 387 , StmtIns $ tempPMC <-- "find_global" $ [lit "Perl6::Internals", lit "&exit"] -
src/Pugs/Compile.hs
r6682 r6801 105 105 name' | ':' `elem` name = name 106 106 | otherwise = "main::" ++ name -- XXX wrong 107 return [PSub initL SubPrim [] False bodyC]107 return [PSub initL SubPrim [] False False bodyC] 108 108 canCompile _ = return [] 109 109 doCode name vsub = case subBody vsub of … … 117 117 compile (name, decls) = do 118 118 let bodyC = [ PStmts . PStmt . PExp $ PApp tcVoid (PExp (PVar sub)) Nothing [] 119 | PSub sub _ _ _ _ <- decls119 | PSub sub _ _ _ _ _ <- decls 120 120 ] 121 return (PSub name SubPrim [] False (combine bodyC PNil):decls)121 return (PSub name SubPrim [] False False (combine bodyC PNil):decls) 122 122 123 123 instance Compile (SubName, VCode) [PIL_Decl] where … … 126 126 bodyC = PStmts (PStmt . PExp $ storeC) PNil 127 127 exportL = "__export_" ++ (render $ varText name) 128 return [PSub exportL SubPrim [] False bodyC]128 return [PSub exportL SubPrim [] False False bodyC] 129 129 compile (name, vsub) = do 130 130 bodyC <- enter cxtItemAny . compile $ case subBody vsub of … … 132 132 body -> body 133 133 paramsC <- compile $ subParams vsub 134 return [PSub name (subType vsub) paramsC (subLValue vsub) bodyC]134 return [PSub name (subType vsub) paramsC (subLValue vsub) (isMulti vsub) bodyC] 135 135 136 136 instance Compile (String, [(TVar Bool, TVar VRef)]) PIL_Expr where … … 236 236 237 237 pBlock :: PIL_Stmts -> PIL_Expr 238 pBlock = PCode SubBlock [] False 238 pBlock = PCode SubBlock [] False False 239 239 240 240 {- … … 372 372 exp -> exp 373 373 paramsC <- compile $ subParams sub 374 return $ PCode (subType sub) paramsC (subLValue sub) bodyC374 return $ PCode (subType sub) paramsC (subLValue sub) (isMulti sub) bodyC 375 375 compile (Syn "module" _) = compile Noop 376 376 compile (Syn "match" exp) = compile $ Syn "rx" exp -- wrong -
src/Pugs/PIL1.hs
r6424 r6801 73 73 , pParams :: ![TParam] 74 74 , pLValue :: !Bool 75 , pIsMulti :: !Bool 75 76 , pBody :: !PIL_Stmts 76 77 } … … 82 83 , pSubParams :: ![TParam] 83 84 , pSubLValue :: !Bool 85 , pSubIsMulti :: !Bool 84 86 , pSubBody :: !PIL_Stmts 85 87 } … … 258 260 putByte bh 3 259 261 put_ bh ad 260 put_ bh (PCode ae af ag ah ) = do262 put_ bh (PCode ae af ag ah ai) = do 261 263 putByte bh 4 262 264 put_ bh ae … … 264 266 put_ bh ag 265 267 put_ bh ah 268 put_ bh ai 266 269 get bh = do 267 270 h <- getByte bh … … 284 287 ag <- get bh 285 288 ah <- get bh 286 return (PCode ae af ag ah) 289 ai <- get bh 290 return (PCode ae af ag ah ai) 287 291 288 292 instance Perl5 PIL_Expr where … … 293 297 showPerl5 (PThunk aa) = showP5HashObj "PThunk" 294 298 [("pThunk", showPerl5 aa)] 295 showPerl5 (PCode aa ab ac ad ) = showP5HashObj "PCode"299 showPerl5 (PCode aa ab ac ad ae) = showP5HashObj "PCode" 296 300 [("pType", showPerl5 aa) , ("pParams", showPerl5 ab) , 297 ("pLValue", showPerl5 ac) , ("pBody", showPerl5 ad)] 301 ("pLValue", showPerl5 ac) , ("pIsMulti", showPerl5 ad) , 302 ("pBody", showPerl5 ae)] 298 303 299 304 instance JSON PIL_Expr where … … 304 309 showJSON (PThunk aa) = showJSHashObj "PThunk" 305 310 [("pThunk", showJSON aa)] 306 showJSON (PCode aa ab ac ad ) = showJSHashObj "PCode"311 showJSON (PCode aa ab ac ad ae) = showJSHashObj "PCode" 307 312 [("pType", showJSON aa) , ("pParams", showJSON ab) , 308 ("pLValue", showJSON ac) , ("pBody", showJSON ad)] 313 ("pLValue", showJSON ac) , ("pIsMulti", showJSON ad) , 314 ("pBody", showJSON ae)] 309 315 310 316 instance Binary PIL_Decl where 311 put_ bh (PSub aa ab ac ad ae ) = do317 put_ bh (PSub aa ab ac ad ae af) = do 312 318 put_ bh aa 313 319 put_ bh ab … … 315 321 put_ bh ad 316 322 put_ bh ae 323 put_ bh af 317 324 get bh = do 318 325 aa <- get bh … … 321 328 ad <- get bh 322 329 ae <- get bh 323 return (PSub aa ab ac ad ae) 330 af <- get bh 331 return (PSub aa ab ac ad ae af) 324 332 325 333 instance Perl5 PIL_Decl where 326 showPerl5 (PSub aa ab ac ad ae ) = showP5HashObj "PSub"334 showPerl5 (PSub aa ab ac ad ae af) = showP5HashObj "PSub" 327 335 [("pSubName", showPerl5 aa) , ("pSubType", showPerl5 ab) , 328 336 ("pSubParams", showPerl5 ac) , ("pSubLValue", showPerl5 ad) , 329 ("pSub Body", showPerl5 ae)]337 ("pSubIsMulti", showPerl5 ae) , ("pSubBody", showPerl5 af)] 330 338 331 339 instance JSON PIL_Decl where 332 showJSON (PSub aa ab ac ad ae ) = showJSHashObj "PSub"340 showJSON (PSub aa ab ac ad ae af) = showJSHashObj "PSub" 333 341 [("pSubName", showJSON aa) , ("pSubType", showJSON ab) , 334 342 ("pSubParams", showJSON ac) , ("pSubLValue", showJSON ad) , 335 ("pSub Body", showJSON ae)]343 ("pSubIsMulti", showJSON ae) , ("pSubBody", showJSON af)] 336 344 337 345 instance Binary PIL_Literal where -
src/Pugs/PIL1.hs-drift
r6424 r6801 71 71 , pParams :: ![TParam] 72 72 , pLValue :: !Bool 73 , pIsMulti :: !Bool 73 74 , pBody :: !PIL_Stmts 74 75 } … … 80 81 , pSubParams :: ![TParam] 81 82 , pSubLValue :: !Bool 83 , pSubIsMulti :: !Bool 82 84 , pSubBody :: !PIL_Stmts 83 85 } -
t/var/constant.t
r6796 r6801 122 122 eval ' 123 123 { 124 my constant grtz= 42;125 $ok++ if grtz== 42;124 my constant wack = 42; 125 $ok++ if wack == 42; 126 126 } 127 127 128 $ok++ unless eval " grtz; 1";128 $ok++ unless eval "wack; 1"; 129 129 '; 130 130 … … 136 136 137 137 eval ' 138 my constant grtz= 42;139 $ok++ if grtz== 42;138 my constant wack = 42; 139 $ok++ if wack == 42; 140 140 141 141 { 142 my constant grtz= 23;143 $ok++ if grtz== 23;142 my constant wack = 23; 143 $ok++ if wack == 23; 144 144 } 145 145 146 $ok++ if grtz== 23;146 $ok++ if wack == 23; 147 147 '; 148 148 … … 155 155 eval ' 156 156 { 157 our constant g rtz= 42;158 $ok++ if g rtz== 42;157 our constant globconst1 = 42; 158 $ok++ if globconst1 == 42; 159 159 } 160 160 161 $ok++ if g rtz;161 $ok++ if globconst1 == 42; 162 162 '; 163 163 … … 170 170 eval ' 171 171 { 172 constant g rtz= 42;173 $ok++ if g rtz== 42;172 constant globconst2 = 42; 173 $ok++ if globconst2 == 42; 174 174 } 175 175 176 $ok++ if g rtz;176 $ok++ if globconst2 == 42; 177 177 '; 178 178 -
util/cperl6-mode.el
- Property svn:mime-type set to text/plain; charset=UTF-8
- Property svn:eol-style set to native
