Changeset 22528
- Timestamp:
- 10/07/08 21:28:28 (6 weeks ago)
- Location:
- misc
- Files:
-
- 9 modified
-
elf/elf_h (modified) (6 diffs)
-
elf/elf_h_src/EmitSimpleP5.pm (modified) (1 diff)
-
elf/elf_h_src/IRx1_Analysis.pm (modified) (1 diff)
-
elf/elf_h_src/IRx1_FromAST.pm (modified) (2 diffs)
-
elf/elf_h_src/IRx1_FromAST_create.pl (modified) (2 diffs)
-
elf/elf_h_src/PrimitivesP5.pm (modified) (1 diff)
-
elfish/on_sbcl/EmitSBCL.pm (modified) (9 diffs)
-
elfish/on_sbcl/Makefile (modified) (1 diff)
-
elfish/on_sbcl/PrimitivesSBCL.pm (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
misc/elf/elf_h
r22521 r22528 100 100 sub lcfirst { CORE::lcfirst($_[0]); } 101 101 102 sub length { CORE::length($_[0]); }103 102 sub bytes { use bytes; CORE::length($_[0]); } 104 103 sub chars { CORE::length($_[0]); } … … 2204 2203 (do{my $v = ($m->match_string()); 2205 2204 my $s = GLOBAL::substr($v, 0, 1); 2206 my $n = GLOBAL::substr($v, 1, $v-> length());2205 my $n = GLOBAL::substr($v, 1, $v->chars()); 2207 2206 IRx1::Var->newp($m, $s, GLOBAL::undef(), $n)})}; 2208 2207 my $construct_circumfix = sub {my($m)=@_; … … 2336 2335 (do{($multisig = [IRx1::Signature->newp($m, [], GLOBAL::undef())])}) 2337 2336 }; 2338 IRx1::MethodDecl->newp($m, GLOBAL::undef(), GLOBAL::undef(), $plurality, irbuild_ir($m->hash()->{"ident"}), $multisig->[0], irbuild_ir($m->hash()->{"trait"}), irbuild_ir($m->hash()->{"block"}) )})};2337 IRx1::MethodDecl->newp($m, GLOBAL::undef(), GLOBAL::undef(), $plurality, irbuild_ir($m->hash()->{"ident"}), $multisig->[0], irbuild_ir($m->hash()->{"trait"}), irbuild_ir($m->hash()->{"block"}), GLOBAL::undef(), GLOBAL::undef())})}; 2339 2338 my $construct_signature = sub {my($m)=@_; 2340 2339 (do{IRx1::Signature->newp($m, irbuild_ir($m->hash()->{"parsep"}), GLOBAL::undef())})}; … … 2904 2903 ; 2905 2904 2905 { package IRx1::Apply; 2906 use base "Any";(do{sub provides_a_list{my $self=CORE::shift;(do{(($self->function eq "infix\:\,") && $self->capture->contains_a_list())})}}) 2907 } 2908 ; 2909 2906 2910 { package IRx1::Capture; 2907 use base "Any";(do{sub contains_a_list{my $self=CORE::shift;(do{ my $found;2908 $self->arguments->map(sub {my($e)=@_; 2909 (do{ if((($e->isa("IRx1\:\:Base") && $e->provides_a_list()))) {2910 (do{($found = 1)})2911 } })});2912 $found})}})2911 use base "Any";(do{sub contains_a_list{my $self=CORE::shift;(do{for(($self->arguments)->flatten){ 2912 (do{if((($_->isa("IRx1\:\:Base") && $_->provides_a_list()))) { 2913 (do{return(1)}) 2914 }}) 2915 }; 2916 GLOBAL::undef()})}}) 2913 2917 } 2914 2918 ; … … 3037 3041 \ \ sub\ lcfirst\ \ \{\ CORE\:\:lcfirst\(\$_\[0\]\)\;\ \}\ 3038 3042 \ 3039 \ \ sub\ length\ \ \ \{\ CORE\:\:length\(\$_\[0\]\)\;\ \}\3040 3043 \ \ sub\ bytes\ \ \ \ \{\ use\ bytes\;\ CORE\:\:length\(\$_\[0\]\)\;\ \}\ 3041 3044 \ \ sub\ chars\ \ \ \ \{\ CORE\:\:length\(\$_\[0\]\)\;\ \}\ … … 3914 3917 ; 3915 3918 ($GLOBAL::PID = (sub {$$})->()); 3919 ($GLOBAL::OS = (sub {$^O})->()); 3920 ($GLOBAL::OSVER = (sub {`/bin/uname -a`})->()); 3921 ($GLOBAL::EXECUTABLE_NAME = (sub {$0})->()); 3922 sub not_used_only_once{(do{[$GLOBAL::OS, $GLOBAL::OSVER, $GLOBAL::EXECUTABLE_NAME]})}; 3916 3923 3917 3924 { package GLOBAL; -
misc/elf/elf_h_src/EmitSimpleP5.pm
r22501 r22528 133 133 sub lcfirst { CORE::lcfirst($_[0]); } 134 134 135 sub length { CORE::length($_[0]); }136 135 sub bytes { use bytes; CORE::length($_[0]); } 137 136 sub chars { CORE::length($_[0]); } -
misc/elf/elf_h_src/IRx1_Analysis.pm
r22521 r22528 239 239 method provides_a_list { self.method eq "flatten" } 240 240 } 241 class IRx1::Apply { 242 method provides_a_list { 243 $.function eq 'infix:,' && $.capture.contains_a_list; 244 } 245 } 241 246 class IRx1::Capture { 242 247 method contains_a_list { 243 my $found;244 $.arguments.map(sub($e){245 if ($e.isa('IRx1::Base') && $e.provides_a_list) { $found = 1 }});246 $found;247 } 248 } 248 for $.arguments { 249 if ($_.isa('IRx1::Base') && $_.provides_a_list) { return 1 } 250 } 251 undef; 252 } 253 } -
misc/elf/elf_h_src/IRx1_FromAST.pm
r22521 r22528 322 322 my $v = ($m.match_string); 323 323 my $s = substr($v,0,1); 324 my $n = substr($v,1,$v. length);324 my $n = substr($v,1,$v.chars); 325 325 IRx1::Var.newp($m,$s,undef,$n); 326 326 }; … … 492 492 my $multisig = irbuild_ir($m.hash{'multisig'}); 493 493 if not($multisig) { $multisig = [IRx1::Signature.newp($m,[],undef)]; } 494 IRx1::MethodDecl.newp($m,undef,undef,$plurality,irbuild_ir($m.hash{'ident'}),$multisig.[0],irbuild_ir($m.hash{'trait'}),irbuild_ir($m.hash{'block'}) );494 IRx1::MethodDecl.newp($m,undef,undef,$plurality,irbuild_ir($m.hash{'ident'}),$multisig.[0],irbuild_ir($m.hash{'trait'}),irbuild_ir($m.hash{'block'}),undef,undef); 495 495 }; 496 496 -
misc/elf/elf_h_src/IRx1_FromAST_create.pl
r22521 r22528 237 237 my $v = *text*; 238 238 my $s = substr($v,0,1); 239 my $n = substr($v,1,$v. length);239 my $n = substr($v,1,$v.chars); 240 240 Var.newp($s,undef,$n) 241 241 … … 372 372 my $multisig = $m<multisig>; 373 373 if not($multisig) { $multisig = [Signature.newp([],undef)]; } 374 MethodDecl.newp(undef,undef,$plurality,$m<ident>,$multisig.[0],$m<trait>,$m<block> )374 MethodDecl.newp(undef,undef,$plurality,$m<ident>,$multisig.[0],$m<trait>,$m<block>,undef,undef) 375 375 376 376 signature -
misc/elf/elf_h_src/PrimitivesP5.pm
r22521 r22528 9 9 10 10 $*PID = (sub () is p5 {'$$'}).(); 11 $*OS = (sub () is p5 {'$^O'}).(); 12 $*OSVER = (sub () is p5 {'`/bin/uname -a`'}).(); 13 $*EXECUTABLE_NAME = (sub () is p5 {'$0'}).(); 14 sub not_used_only_once { [$*OS,$*OSVER,$*EXECUTABLE_NAME] } 11 15 12 16 package GLOBAL { # sub *f(){} isn't working yet. -
misc/elfish/on_sbcl/EmitSBCL.pm
r22522 r22528 21 21 ''; 22 22 } 23 method prelude ($n){23 method prelude { 24 24 '#| 25 #fasl=`dirname $0`/`basename $0 .lisp`.fasl26 #[ $fasl -ot $0 ] && sbcl --noinform --eval "(compile-file \"$0\")" --eval "(quit)"27 #exec sbcl --noinform --load $fasl --end-toplevel-options "$@"28 exec sbcl --noinform --load $0 --eval "(quit)" --end-toplevel-options "$@"25 fasl=`dirname $0`/`basename $0 .lisp`.fasl 26 [ $fasl -ot $0 ] && sbcl --noinform --eval "(compile-file \"$0\")" --eval "(quit)" 27 exec sbcl --noinform --load $fasl --end-toplevel-options "$@" 28 #exec sbcl --noinform --load $0 --eval "(quit)" --end-toplevel-options "$@" 29 29 |# 30 30 … … 257 257 (defun flatten-lists (args) 258 258 (reduce #\'append 259 (mapcar (lambda (e) (if (and (listp e) (not (null e))) 260 e (list e))) 259 (mapcar (lambda (e) 260 (if (and (listp e) 261 ;;(not (null e)) ;#XXX disappears undef args! 262 ;;# boxing undef is now important. :/ 263 ) 264 e (list e))) 261 265 args))) 262 266 … … 292 296 293 297 (dm |M::Str| ((x null) &rest argl) (declare (ignorable x argl)) "") 294 (dm |M::WHAT| ((x null) &rest argl) (declare (ignorable x argl)) " nil")298 (dm |M::WHAT| ((x null) &rest argl) (declare (ignorable x argl)) "Undef") 295 299 (dm |M::substr| ((s string) from len) (subseq s from (+ from len))) 296 300 … … 367 371 \'nil 368 372 (let ((sym (gensym))) 369 `(let ((,sym ,(car args))) (if (to-b ,sym) ,sym (or6 ,@(cdr args))))))) 373 `(let ((,sym ,(car args))) 374 (if (or ,(null (cdr args)) (to-b ,sym)) ,sym (or6 ,@(cdr args))))))) 370 375 (defmacro and6 (&rest args) 371 376 (cond ((null args) t) … … 380 385 } 381 386 382 method e ($x) {387 method e ($x) { 383 388 my $ref = $x.WHAT; 384 389 if $ref eq 'Undef' { $x } … … 676 681 my $words = $s.split('\s+'); 677 682 my $self = self; 678 $e_capture = $words.map(sub($x){$self. qstr($x)}).join(" ");683 $e_capture = $words.map(sub($x){$self.UP_qstr($x)}).join(" "); 679 684 } 680 685 } 681 686 if $n.capture.contains_a_list { 682 '(ap '~$meth~' (cons '~$invocant~' (flatten-lists '~$e_capture~')))';687 '(ap '~$meth~' (cons '~$invocant~' (flatten-lists (list '~$e_capture~'))))'; 683 688 } 684 689 else { … … 694 699 method qstr ($str) { 695 700 '"'~$str.re_gsub('\\\\','\\\\').re_gsub('"','\"')~'"' 701 } 702 method UP_qstr ($str) { 703 '(UP "'~$str.re_gsub('\\\\','\\\\').re_gsub('"','\"')~'")' 696 704 } 697 705 … … 763 771 my $words = $s.split('\s+'); 764 772 my $self = self; 765 return $.emit_array($words.map(sub($x){$self. qstr($x)}).join(" "));773 return $.emit_array($words.map(sub($x){$self.UP_qstr($x)}).join(" ")); 766 774 } 767 775 } … … 789 797 if $n.capture.contains_a_list { 790 798 $pre = '(ap '; 791 $mid = ' (flatten-lists ';792 $post = ')) ';799 $mid = ' (flatten-lists (list '; 800 $post = ')))'; 793 801 } 794 802 -
misc/elfish/on_sbcl/Makefile
r22522 r22528 11 11 ${ELF} -I ${ELFDIR} EmitSBCL.pm -x -o elfcl Elf_SBCL.pm 12 12 time ${SBCL} --eval '(compile-file "elfcl")' --eval '(quit)' >& elfcl.out 13 chmod a+x elfcl 13 14 14 15 have_parser_cache: -
misc/elfish/on_sbcl/PrimitivesSBCL.pm
r22522 r22528 104 104 multi unlink_ ($filename) is cl {' (sb-unix:unix-unlink (S |$filename|)) '} 105 105 multi not ($x) { if $x { undef } else { 1 } } 106 multi defined ($x) is cl {' (UP (if |$x| 1 nil)) '} #X undef as nil 106 multi defined ($x) is cl {' (UP (if |$x| 1 nil)) '} ;#X undef as nil 107 multi substr($s,$offset,$length) { $s.substr($offset,$length) } 107 108 } 108 109 … … 151 152 (UP (if (probe-file (S |$filename|)) t nil)) 152 153 '} 153 sub elf_main () { Program.new().main(@*ARGS); } 154 sub elf_main () { 155 Program.new().main(@*ARGS); 156 exit(0); 157 } 158 sub module_require ($module) { 159 my $file = find_required_module($module); 160 $file || die("Cant locate $module in ( "~@*INC.join(" ")~" ).\n"); 161 eval_file($file); 162 }; 163 sub find_required_module ($module) { 164 my $names = [$module, $module~".pm", $module~".p6"]; 165 for @*INC { my $dir = $_; 166 for $names { my $name = $_; 167 my $file = $dir~"/"~$name; 168 if file_exists($file) { 169 return $file; 170 } 171 } 172 } 173 return undef; 174 } 175 sub import ($module,*@args) { 176 undef 177 } 178 sub eval_file ($file) { 179 $*compiler0.eval_file($file); 180 } 181 sub eval_perl6 ($code,$env) { 182 $*compiler0.eval_perl6($code,$env); 183 } 184 sub eval ($code,$env) { 185 eval_perl6($code,$env); 186 } 187 154 188 } 155 189 # regexp elf bootstrap primitives … … 227 261 (UP (subseq s off (min len (+ off (N |$length|)))))) 228 262 '} 263 method chars () is cl {' 264 (let* ((s (slot-value self \'|Str::._native_|)) 265 (len (length s))) 266 (UP len)) 267 '} 229 268 } 230 269 … … 297 336 (from (wrapped-index len (N |$from|))) 298 337 (to (wrapped-index len (N |$to|)))) 299 (new-Array ( subseq a from to)))338 (new-Array (coerce (subseq a from to) \'list))) 300 339 '} 301 340 method reverse () is cl {'
