Re: [CVS ci] bitwise string vtables; ands, ors opcodes
According to Vladimir Lipskiy: The patch below implements the missing XORS ops. Context diffs preferred, I think. Sure. Index: string.c === RCS file: /cvs/public/parrot/string.c,v retrieving revision 1.141 diff -r1.141 string.c 1008,1012c1008 STRING * string_bitwise_and(struct Parrot_Interp *interpreter, STRING *s1, STRING *s2, STRING **dest) { const char *s1start; const char *s2start; char *dp; STRING *res; size_t len; len = s1 ? s1-bufused : 0; if (s2 s2-bufused len) len = s2-bufused; if (dest *dest) --- if (dest *dest) res = *dest; else if (!s1 || !s2) res = string_make(interpreter, NULL, 0, NULL, 0, NULL); if (!s1 || !s2) { res-bufused = 0; res-strlen = 0; return res; } /* trigger GC for debug */ if (interpreter GC_DEBUG(interpreter)) Parrot_do_dod_run(interpreter, 1); if (s1-type != s2-type || s1-encoding != s2-encoding) { s1 = string_transcode(interpreter, s1, NULL, string_unicode_type, NULL); s2 = string_transcode(interpreter, s2, NULL, string_unicode_type, NULL); } /* get the real len after trancode */ --- len = s1 ? s1-bufused : 0; if (s2 s2-bufused len) len = s2-bufused; if (!dest || *dest) --- if (!dest || !*dest) res = string_make(interpreter, NULL, len, s1-encoding, 0, s1-type); --- else if (res-bufused len) string_grow(interpreter, res, len - res-bufused); s1start = s1-strstart; s2start = s2-strstart; dp = res-strstart; res-bufused = len; for ( ; len ; ++s1start, ++s2start, ++dp, --len) *dp = *s1start *s2start; res-strlen = s1-strlen; if (s2-strlen s1-strlen) res-strlen = s2-strlen; if (dest) *dest = res; return res; } /*=for api string string_bitwise_or * or two strings, performing type and encoding conversions if * necessary. If *dest != NULL reuse dest, else create a new result */ STRING * string_bitwise_or(struct Parrot_Interp *interpreter, STRING *s1, STRING *s2, STRING **dest) { const char *s1start; const char *s2start; const char *s1end; const char *s2end; char *dp; STRING *res; size_t len; len = s1 ? s1-bufused : 0; if (s2 s2-bufused len) len = s2-bufused; --- if (dest *dest) res = *dest; else if (len == 0) --- else if (!s1 !s2) res = string_make(interpreter, NULL, 0, NULL, 0, NULL); if (!len) { --- if (!s1 !s2) { res-bufused = 0; res-strlen = 0; return res; } /* trigger GC for debug */ if (interpreter GC_DEBUG(interpreter)) Parrot_do_dod_run(interpreter, 1); if (s1 s2) { if (s1-type != s2-type || s1-encoding != s2-encoding) { s1 = string_transcode(interpreter, s1, NULL, string_unicode_type, NULL); s2 = string_transcode(interpreter, s2, NULL, string_unicode_type, NULL); } } len = s1 ? s1-bufused: 0; if (s2 s2-bufused len) len = s2-bufused; if (!dest || !*dest) res = string_make(interpreter, NULL, len, s1 ? s1-encoding : NULL, 0, s1 ? s1-type : NULL); else if (res-bufused len) string_grow(interpreter, res, len - res-bufused); if (s1) { s1start = s1-strstart; s1end = s1start + s1-bufused; res-strlen = s1-strlen; } else s1start = s1end = NULL; if (s2) { s2start = s2-strstart; s2end = s2start + s2-bufused; if ((s1 s2-strlen s1-strlen) || !s1) --- if (!s1 || s2-strlen s1-strlen) res-strlen = s2-strlen; } else s2start = s2end = NULL; dp = res-strstart; res-bufused = len; for ( ; len ; ++s1start, ++s2start, ++dp, --len) { if (s1start s1end s2start s2end) *dp = *s1start | *s2start; else if (s1start s1end) *dp = *s1start; else *dp = *s2start; } if (dest) *dest = res; return res; } --- /*=for api string string_bitwise_xor * or two strings, performing type and encoding conversions if * necessary. If *dest != NULL reuse dest, else create a new result */ STRING * string_bitwise_xor(struct Parrot_Interp *interpreter, STRING *s1, STRING *s2, STRING **dest) { const char *s1start; const char *s2start; const char *s1end; const char *s2end; char *dp; STRING *res; size_t len; if (dest *dest) res = *dest; else if (!s1 !s2) res = string_make(interpreter, NULL, 0, NULL, 0, NULL); if (!s1 !s2) { res-bufused = 0; res-strlen = 0; return res; } /* trigger GC for debug */
Re: We *need* this op! :-)
On Thu, 7 Aug 2003, Jos Visser wrote: Accompanying patch adds the fortytwo op to Parrot, so the following PASM becomes legal: fortytwo I0 print I0 print \n end Example: $ ../parrot test42.pasm 42 Why not just use a macro? # .macro fortytwo (A) #set .A, 42 # .endm # # .fortytwo(I0) # print I0 # print \n # end Simon
calling conventions, variable-length parameter lists
I want to be able to have a function with this kind of signature: func ($param1, *$otherparams) AFAIK, there is no way to implement this with the current calling conventions. You would have to do something with variable register IDs, which we don't have and which would probably be a bad idea, anyway. Maybe non_prototyped pcc subs should always have all their parameters shoved into an array? (and likewise for return values :-). Hopefully most subroutine calls will be prototyped, anyway, so it wouldn't cause too much of an overall speed-hit, and it would make many things a lot simpler (not to mention even *possible*). __ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com
RE: Perl 6's for() signature
-Original Message- From: Luke Palmer [mailto:[EMAIL PROTECTED] Actually, in Perl 6, they'll do that anyway. Scope in loops is strictly defined by the location of the braces WRT the location of my. That is: while (my $x = somefunc()) { ... } # $x still in scope And the same for all other loops. Cfor loops are an exception, sortof, because they're really declaring a parameterized block instead of a lexical variable. It seems like we could maybe generalize this exception: In cases where we say my block = - $a, $b { do_stuff; } for (my $a = 0, $b = 1; $a $b; ++$a) block; We're really just pulling the block vars out so we can tweak them. Perhaps the right approach is that all lexically scoped vars declared within loop keywords that take blocks are parameters, and persist until the end of the loop-block. while (my $line = ) { # or loop, or for, or do/while, or whatever ... } print $line; # error -- line out of scope The obvious accompaniment is Cis scoped(BLOCK) or maybe Cis persistent. FOR_LOOP: for (...) { while (my $line is scoped(FOR_LOOP) = ) { ... } print $line; # Okay -- $line ends with the for. } =Austin
Re: [perl #23029] [PATCH] -Wpadded annoying
Lars Balker Rasmussen (via RT) [EMAIL PROTECTED] writes: # New Ticket Created by Lars Balker Rasmussen # Please include the string: [perl #23029] # in the subject line of all future correspondence about this issue. # URL: http://rt.perl.org/rt2/Ticket/Display.html?id=23029 -Wpadded seems to be more trouble than it's worth at this stage, so I suggest getting rid of it. It clashes with a FreeBSD header file, and the amount of warnings on Solaris just explodes, hiding more interesting stuff. Resubmitted... -- attachment 1 -- url: http://rt.perl.org/rt2/attach/61205/45206/2d805d/padded.patch Index: config/auto/gcc.pl === RCS file: /cvs/public/parrot/config/auto/gcc.pl,v retrieving revision 1.6 diff -u -a -r1.6 gcc.pl --- config/auto/gcc.pl15 Jul 2003 18:08:34 - 1.6 +++ config/auto/gcc.pl17 Jul 2003 20:37:13 - @@ -74,7 +74,7 @@ 2.7 = , 2.8 = -Wsign-compare, 2.95 = , - 3.0 = -Wformat-nonliteral -Wformat-security -Wpacked -Wpadded -Wdisabled-optimization, + 3.0 = -Wformat-nonliteral -Wformat-security -Wpacked -Wdisabled-optimization, # -Wsequence-point is part of -Wall # -Wfloat-equal may not be what we want # We shouldn't be using __packed__, but I doubt -Wpacked will harm us -- Lars Balker Rasmussen Consult::Perl
Re: struct Parrot_Lexicals; ArrayHash
Leo~ Why not just use a hash and ditch the array then? Matt Leopold Toetsch wrote: The current implementation of find_lex (by_name) is suboptimal. A linear scan over the list of lexical names is performed (s. sub.c:lexicals_get_position()). A better way would be to provide a list of lexicals plus a name hash, where hash values are indices into the list. As such a functionality might be handy is a general PMC class, I think, best is to generate a new class named ArrayHash or SortedHash or such. Proposed Synopsis: set P0[key], value list_push(value); hash_put(key = list.elements-1) set P0[key; idx], value list[idx] = value; hash_put(key = idx) set value, P0[key] # retrieve by key set value, P0[idx] # or by index Comments welcome, leo
Re: assign opcodes
Togos [EMAIL PROTECTED] wrote: if you assign an integer to a PerlString, it's still a PerlString. No more. I don't know, if its correct. But the behavior now seems more natural to me: new P1, .PerlInt set P1, 42 new P0, .PerlUndef assign P0, P1 # LHS is PerlInt now The dest has to be morphed into the RHS type, IMHO. Personally, I would like = to mean 'set', and maybe - do 'assign'. That's a true alternative and with no problems WRT backward compatibility. leo
Re: parrot bug: continuations/multiple return
Michal Wallace wrote: [snip] def f(): return g() [snip] # f from line 3 .pcc_sub _sub1 non_prototyped .local object res1# (visitReturn:528) find_lex $P2, 'g' # (callingExpression:325) newsub $P3, .Continuation, ret0# (callingExpression:331) .pcc_begin non_prototyped # (callingExpression:332) .pcc_call $P2, $P3# (callingExpression:335) ret0: .result res1 # (callingExpression:338) .pcc_end # (callingExpression:339) .pcc_begin_return # (visitReturn:530) .return res1 # (visitReturn:531) .pcc_end_return # (visitReturn:532) .end Does python allow tail calls to be optomized? That is, would it be legal python semantics if f were to become: .pcc_sub _sub1 non_prototyped find_lex $P2, 'g' .pcc_begin non_prototyped .pcc_call $P2, P1 .pcc_end .end (untested) Also... why is $P2 merely an imcc temporary, without a real name? That is, why not do: .pcc_sub _sub1 non_prototyped .local object sub1 find_lex sub1, 'g' .pcc_begin non_prototyped .pcc_call sub1, P1 .pcc_end .end The more different prefixes you use (res, sub, $P), the lower the numbers you'll need to append to them to make the names unique. Not to mention, it'll make the generated code more meaningful. Another advantage is that with '.local' names, if you accidentally use a name declared in one subroutine, in another, imcc will consider this to be an error. Such a mistake might be otherwise difficult to spot. -- $a=24;split//,240513;s/\B/ = /for@@=qw(ac ab bc ba cb ca );{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print [EMAIL PROTECTED] ]\n;((6=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))redo;}
Re: [perl #23029] [PATCH] -Wpadded annoying
Lars Balker Rasmussen [EMAIL PROTECTED] wrote: -Wpadded seems to be more trouble than it's worth at this stage, so I Thanks, applied, leo
Re: #define name collisions -- yet another small project
At 5:27 AM +0300 8/9/03, Vladimir Lipskiy wrote: So, the project. Someone needs to go through the configure procedure and the headers and throw a PARROT_ prefix in front of all the HAS_ defines we define, so we can avoid this problem. I have a look at the configure procedure and didn't find anything that could have set up something like HAS_STDLIB_H. While configuring we generate 3 header files: config.h, has_header.h, feature.h. In the config.h file nearly every define has the PARROT_ prefix and others that don't have it are harmless unless DEFAULT_SIZE. In has_header.h we define a good deal of HAS_HEADER_* defines. I judge those could be worthy of the PARROT_ prefixing. And if I judge correctly we will have to make alternations in the following files, too: Works for me. Next. In feature.h or, rather, in the feature.pl script we try (when possible) to define the following HAS_: HAS_POSIX_MEMALIGN HAS_SOME_MEMALIGN HAS_MEMALIGN HAS_JIT_FCOMIP HAS_SIGACTION HAS_SETITIMER HAS_SOME_SYS_TIMER HAS_SETENV HAS_UNSETENV Prefixing those could cause a monstrous number of changes in other files. And I can hardly believe that any of those could do any harm. Well... the problem we may run into is if we end up yanking in headers that define those differently than we do, which is what started this in the first place. We're in the inenviable position of potentially including almost anything, so we're vulnerable to all the bizarre ways that people define things and use what they've defined, which is why I want to get defensive about this before we get bitten. -- Dan --it's like this--- Dan Sugalski even samurai [EMAIL PROTECTED] have teddy bears and even teddy bears get drunk
Re: bug: two segfaults
I've committed a würgaround. LMAO!
RE: We *need* this op! :-)
On Fri, Aug 08, 2003 at 01:51PM -0400, David H. Adler wrote: On Fri, Aug 08, 2003 at 12:33:03PM +0100, Nicholas Clark wrote: On Fri, Aug 08, 2003 at 02:20:46AM -0400, David H. Adler wrote: On Thu, Aug 07, 2003 at 12:57:11PM -0400, Gordon Henriksen wrote: This is really a language feature; you should add it to the hq9+ implementation. Sadly, this was not considered when hq9+ was developed, so it's not actually part of the language. Maybe someone should develop and extended version - hq9+42 No, hq9*6, surely? Well, that loses the all-important increment op. How about hq9+(6*9) ? Maybe just h9q+a...? -- Gordon Henriksen IT Manager ICLUBcentral Inc. [EMAIL PROTECTED]
Re: IMCC hangs
Seems to be related with the multiple freeing reported by Michael. I thought his name was Michal (:8
Re: Re[2]: parrot, win32, stand-alone distribution, separate Parrot maillist
Is it as simple as checking whether the OS is Windows, and setting %options to contain appropriate paths, e.g. It's no use while checking if the OS is Windows, 'cause the distribution is intended for only Win 32 users. So you should predefine the hash below. %options = ( buildprefix = '', prefix = 'c:\parrot', exec_prefix = 'c:\parrot', bindir = 'c:\parrot\bin', libdir = 'c:\parrot\lib', includedir = 'c:\parrot\include', ); As these directories may not exist in Windows, and I don't see anything that creates non-existent directories, I believe I'll need to write something that checks if they are there and creates them if they are not. IMHO, you better try tweaking some directories out of Perl. So if I had my perl installed at D:\Perl\5.6.1, I would be overflowed with joy having found your script installed Parrot as D:\Perl\Parrot and be cussing if it woudn't be so.
Re: bug: two segfaults
At 12:14 -0400 8/10/03, Uri Guttman wrote: VL == Vladimir Lipskiy [EMAIL PROTECTED] writes: I've committed a würgaround. i get the english side of the pun. what does the german(?) side mean? The german verb würgen means to strangle, if I'm not mistaken... Liz
[CVS ci] Exec
Now Exec works exactly like the jit, I have checked in the missing restart, fixed some bugs at Parrot_jit_store_retval and make exec_start call runops instead of calling run_compiled directly, so now all test are successful. Have fun. Daniel.
Re: parrot bug: continuations/multiple return
Leopold Toetsch [EMAIL PROTECTED] writes: As calling conventions clearly state, that the caller has to save everything, its probably up to imcc/pcc.c to insert above statements, if another sub gets called from a sub. I'll fix that in a minute ;-) If and only if that's not a tail call of course.
configure.pl failed under cygwin, build failed on win32
hello, I just picked up a fresh copy with cvs. Under cygwin, ./Configure.pl fails with the message: Determining some sizes...Linker failed (see test.ldo) at lib/Parrot/Configure/Step.pm line 147 So I tried under win32 (MS VS 6.0). Now, Configure.pl is ok, but nmake ends with a fatal error. I don't know how to discover the reason... (are there ways for that?). message: NMAKE : fatal error U1077: 'e:\AP806_source\perl.exe' : return code '0x2' Stop. Klaas-Jan
Re: why new_pad *INT*?
On Sat, 9 Aug 2003, Sean O'Rourke wrote: The problem is that when adder() gets returned, it needs to remember the enclosing pad. So this needs to be newsub $P1, .Closure, _sub1 which (IIRC) will save the lexical environment in which it was created (see closure.pmc), then restore that when it is invoked. Thanks! I see the light. :) I just made all python routines closures for now, and all my tests passed. Sincerely, Michal J Wallace Sabren Enterprises, Inc. - contact: [EMAIL PROTECTED] hosting: http://www.cornerhost.com/ my site: http://www.withoutane.com/ --
Re: parrot bug: continuations/multiple return
Michal Wallace wrote: Benjamin Goldberg wrote: Michal Wallace wrote: [snip] Also... why is $P2 merely an imcc temporary, without a real name? That is, why not do: .pcc_sub _sub1 non_prototyped .local object sub1 find_lex sub1, 'g' .pcc_begin non_prototyped .pcc_call sub1, P1 .pcc_end .end The more different prefixes you use (res, sub, $P), the lower the numbers you'll need to append to them to make the names unique. Not to mention, it'll make the generated code more meaningful. Another advantage is that with '.local' names, if you accidentally use a name declared in one subroutine, in another, imcc will consider this to be an error. Such a mistake might be otherwise difficult to spot. Hmmm. The counters are global so there shouldn't be any conflicts. I'd actually been trying to move away from .local now that I started using lexicals... If there's going to be two sets of names for everything I'd rather one of them was just $Pxx... Ehh, why would there be two sets of names for everything? You mean, one of them the name to lookup in the pad, the other the imcc name of the register to use? There's no reason not to use the same name for both. (Except that using a unique .local name is still good for preventing accidental leakage of a name from one sub to another) Now, if I could say: .lexical g That would be really nice... :) This is where .macro comes in handy :) .macro lexical(name_in_pad, register_name) local .register_name find_lex .register_name, .name_in_pad .endm And in pirate.py, you'd do: self.append('.lexical %s %s', lexname, lexname) Ok, so it's not *quite* what you were asking for, but it's close enough, eh? :) -- $a=24;split//,240513;s/\B/ = /for@@=qw(ac ab bc ba cb ca );{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print [EMAIL PROTECTED] ]\n;((6=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))redo;}
Prefixing #define names
OK. I'm starting out a prefixing story and here is CHAPTER I. The HAS_HEADER_ defines. prefixing.diff Description: Binary data
Re: generic code generator? [was: subroutines and python status]
On Tue, 5 Aug 2003, Joseph Ryan wrote: Okay, I don't have a good syntax in mind yet, the point is it's a template language and you can subclass/override/extend the template. Maybe there's no syntax and it just uses cleanly coded classes in some oo language. Or perl6 with it's grammars and rules. I don't know. I think that trying to define a new syntax for a new meta-language is a bad idea. The goal of a GCG (Generic Code Generator) should be to allieviate the compiler writers of the responsiblity of generating code. Forcing them to generate different code doesn't help solve the problem. (-: Good point. I don't think I was very clear yesterday. Let me try again. Let's say you're generating... I dunno.. haskell: haskell_parser - ast - pirate - parrot_code -- imcc - pbc ^ | parrot_code__templates So the haskell parser only has to generate a pirate ast structure. Either that's a very basic string (I like your XML idea) *or*, in the future, the parser calls pirate tree-building-methods directly. The tree-building methods are why I was talking about C, but for now, I don't mind doing a bunch of xml-generation every time we call eval/exec. (It's probably the simplest thing to do right now and should be pretty easy for everyone) 1.) Instead of forcing the compiler writer to generate code, the compiler writer would only have to transform the parse tree into a structure that is name-consistant with the GCG's standard, and then use any of a number of existing libraries to dump the tree as YAML/XML. I like it! :) 2.) Since there are more YAML/XML parsers than I can count implemented in nearly modern useful language I can think of, the GCG could be generated in any language without causing a stall on starting on the generic code generation part of the project. (you know, the important part) Agreed! 3.) It would be possible to handle language-specific nodes by defining some sort of raw node whose value could be raw imcc code. That's where the templates come in, but since my crack at a template language last night sucked so bad, I'm thinking that at least for prototyping I'm going to use a python class. So I'm thinking I'm going to try refactoring so that I can do this: pypirate something.py something.xml cat something.xml pirate -l python something.imc imcc something.imc or just: pypirate something.py | pirate -l python | imcc or just: pypyrate -r something.py That also means the pirate command can be written in any language we like. Probably eventually that'll be perl6, but for now (unless someone else wants to volunteer some code) I plan to work from the code I have for python. Sincerely, Michal J Wallace Sabren Enterprises, Inc. - contact: [EMAIL PROTECTED] hosting: http://www.cornerhost.com/ my site: http://www.withoutane.com/ --
Re: configure.pl failed under cygwin, build failed on win32
Under cygwin, ./Configure.pl fails with the message: Determining some sizes...Linker failed (see test.ldo) at lib/Parrot/Configure/Step.pm line Try to add this line link = 'gcc', to config/init/hints/cygwin.pl As a result, it must be in the following way: Configure::Data-set( link = 'link', s/link = 'link'/link='gcc'/ Sorry. I was meditating on MSVC.
Re: calling conventions, variable-length parameter lists
Luke said: sub ($param1, [EMAIL PROTECTED]) In which case, if it's prototyped, we stuff everything besides the first parameter into a PMC representing @otherparams. And if you meant something else, can't help ya. Luke Maybe I misunderstand what 'prototyped' means. I assume this means that the caller knows exactly what function it is calling, and so knows that how the callee expects its parameters to be organised (one in P5, the rest in an array in P6 or whatever). If you don't know exactly what function you're calling (like you got a Sub object out of a variable) then you have to do a non_prototyped call on it. now, assuming I got that right: Are you saying that it will be impossible to implement variable-length parameter lists to non-prototyped functions? Because that's kind of essential to at least a few languages. Ruby's 'print' function, for instance, has a signature that looks something like this: print(*stuff_to_print) Now, you take that method and pass it out to someone, and they want to call it. How are they to know that they're supposed to shove the parameters into an array? Now, if you *always* put all the parameters into an array for non_prototyped subs, this wouldn't be a problem. But otherwise you can't host Ruby. And I *know* you don't plan to miss out on that, so obviously I'm missing something :-) __ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com
Re: #define name collisions -- yet another small project
At 9:21 PM +0300 8/8/03, Vladimir Lipskiy wrote: So, the project. Someone needs to go through the configure procedure and the headers and throw a PARROT_ prefix in front of all the HAS_ defines we define, so we can avoid this problem. Some defines have the HAVE_ prefix. Should those be also prefixed? If they're being set in our configure stuff, yes. If we add PARROT_ to HAVE_, we will end up with the PARROT_HAVE_ prefix, what IMHO is harsh. It might be alot better if we firstly had changed HAVE_ for HAS_. What do you think?
pirate guide
Just got the parrot calling conventions working for Py-Pirate. I also wrote a guide that explains how the code is laid out for people who don't know python: http://pirate.versionhost.com/viewcvs.cgi/pirate/GUIDE?rev=1.1 Sincerely, Michal J Wallace Sabren Enterprises, Inc. - contact: [EMAIL PROTECTED] hosting: http://www.cornerhost.com/ my site: http://www.withoutane.com/ --