Compiling dynamic PMCs

2005-07-28 Thread Klaas-Jan Stol

hi,

as my attempt to write a lua compiler is continuing (slowly but surely), 
and quite some stuff is working already (although rather s l o w), I 
decided it was time to write the PMCs representing the various Lua 
datatypes. I understood from my previous postings (and replies on those) 
that PMCs can be either implemented in PIR (although they are really 
created as objects, right?), or in C as .pmc files. I get the feeling 
writing them in C as .pmc files is the way to go, so I started with the 
first pmc for the lua language: LuaNil.pmc. Whenever a variable hasn't 
been assigned a value, its 'value' is nil. (pretty much the same as 
None, I think).


According to the README file in the 'dynclasses' directory, adding 
dynamic PMCs can be done by:


1. write the PMC
2. edit parrot/config/gen/makefiles/dynclasses.in
3. make

In my case this didn't work. Editing the dynclasses.in file didn't 
trigger the make system to make my PMC.
After getting a fresh parrot, before making it, I added my pmc file, 
edited the dynclasses.in file, and started making parrot. This works (of 
course), but it's a bit cumbersome to do this everytime I'm adding a 
PMC. Anybody got an idea what may go wrong?


thanks,

klaas-jan





Re: Compiling dynamic PMCs

2005-07-28 Thread Leopold Toetsch

Klaas-Jan Stol wrote:


1. write the PMC
2. edit parrot/config/gen/makefiles/dynclasses.in
3. make

In my case this didn't work.


The .in files are processed by Configure.pl to create the real files.

perl Configure.pl ...

should do it, possibly after 'make realclean'.



thanks,

klaas-jan


leo



[PATCH] Readme file dynclasses

2005-07-28 Thread Klaas-Jan Stol

hi,

attached a patch that changes the README file in dynclasses directory. 
The original doesn't mention you have to do perl Configure.pl after 
adding a new PMC file.


klaas-jan
--- README  2005-07-28 13:10:51.0 +0200
+++ README.new  2005-07-28 13:10:32.0 +0200
@@ -58,8 +58,10 @@
 =item 2
 
 Edit C../config/gen/makefiles/dynclasses.in and append your PMC(s) to
-the build target and:
-
+the build target. The dynclasses.in file is processed by Configure.pl to 
+create the real makefiles. So, invoke the configure script, then make:
+   
+   $ perl Configure.pl
$ make
 
 =item 3


Re: Compiling dynamic PMCs

2005-07-28 Thread Klaas-Jan Stol

Leopold Toetsch wrote:


Klaas-Jan Stol wrote:


1. write the PMC
2. edit parrot/config/gen/makefiles/dynclasses.in
3. make

In my case this didn't work.



The .in files are processed by Configure.pl to create the real files.

perl Configure.pl ...

should do it, possibly after 'make realclean'.


thanks, that works. I sent a patch to update this document a minute ago 
(it's only a minor detail, but it may help other beginning PMC writers 
and prevend this question being asked again)


kj




Re: pmc syntax

2005-07-28 Thread Leopold Toetsch

Klaas-Jan Stol wrote:

Suppose I would want to have my own custom representation of None. 


What should I do to have my child class be a singleton too? (just 
extending singleton as well?)


None isn't a singleton. But have a look at the Null PMC or better env.pmc.

$ grep singletion classes/*.pmc

(the way to create singletons might change though)


thanks for your help,
klaas-jan


leo




Re: pmc syntax

2005-07-28 Thread Klaas-Jan Stol

Leopold Toetsch wrote:


Klaas-Jan Stol wrote:

Suppose I would want to have my own custom representation of None. 



What should I do to have my child class be a singleton too? (just 
extending singleton as well?)



None isn't a singleton. But have a look at the Null PMC or better 
env.pmc.


$ grep singletion classes/*.pmc


mmm, I looked at classes/none.pmc, this is a copy/paste:
===
#include assert.h

static PMC * Py_None;

pmclass None singleton {

===
Maybe this is wrong?
I'll have a look at the null pmc, thanks!


(the way to create singletons might change though)


thanks for your help,
klaas-jan



leo


klaas-jan




Re: [PATCH] Readme file dynclasses

2005-07-28 Thread Leopold Toetsch

Klaas-Jan Stol wrote:

hi,

attached a patch that changes the README file in dynclasses directory. 
The original doesn't mention you have to do perl Configure.pl after 
adding a new PMC file.


Thanks, applied - r8710.
leo



Re: pmc syntax

2005-07-28 Thread Leopold Toetsch

Klaas-Jan Stol wrote:


mmm, I looked at classes/none.pmc, this is a copy/paste:
===
#include assert.h

static PMC * Py_None;

pmclass None singleton {


Ah, yep - None is a singleton too - sorry for my confusion.

So it should be rather easy to subclass None, implement get/set_pointer 
and use a distinct file-static PMC* storage for your singleton.


leo



Re: pmc syntax

2005-07-28 Thread Klaas-Jan Stol

Leopold Toetsch wrote:


Klaas-Jan Stol wrote:


mmm, I looked at classes/none.pmc, this is a copy/paste:
===
#include assert.h

static PMC * Py_None;

pmclass None singleton {



Ah, yep - None is a singleton too - sorry for my confusion.

So it should be rather easy to subclass None, implement 
get/set_pointer and use a distinct file-static PMC* storage for your 
singleton.


leo

ah great. it works! :-). Apparently, inheriting from a singleton class 
doesn't make the child class a singleton, you have to add the 
singleton keyword in the class definition header.


one more question though:

1a: when are set_pointer and get_pointer actually called?
1b: in set_pointer (I copied it from None.pmc) an assertion is done. Why 
is this? (this is also part of question 1a: set_pointer is called once, 
apparently?)


void set_pointer(void* ptr) {
 assert(!Lua_Nil);
   Lua_Nil = (PMC*) ptr;
}

Anyway:

   P0 = new LuaNil
   print P0

prints nil. Great! :-)

thanks.
klaas-jan



Re: pmc syntax

2005-07-28 Thread Leopold Toetsch

Klaas-Jan Stol wrote:


1a: when are set_pointer and get_pointer actually called?


From pmc.c:pmc_new

1b: in set_pointer (I copied it from None.pmc) an assertion is done. Why 
is this? (this is also part of question 1a: set_pointer is called once, 
apparently?)


Well, it asserts that you really just create one PMC of that kind.


thanks.
klaas-jan


leo



Re: embedding ParTcl

2005-07-28 Thread Will Coleda

On Jul 27, 2005, at 9:46 PM, Thilo Planz wrote:



Hi,

I have a few beginner's question about ParTcl.

I am trying to embed ParTcl into a PIR application, which seems to  
work quite nicely, except that I have not yet figured out how to do  
certain things.





This is almost certainly no fault of your own. =-)



=

1) Is there a way to reset the Tcl interpreter between invocations?


.sub _main @MAIN
load_bytecode languages/tcl/lib/tcllib.pbc

$P1 = compreg 'TCL'
  $P0 = compile $P1, 'set a 1; puts $a'
  $P0()

  # now reset the TCL interpreter somehow

  $P0 = compile $P1, 'incr a; puts $a'
  $P0()
.end




Well, the interpreter is running inside parrot - all the sub and  
variable definitions are stored in parrot namespaces... so for your  
particular example, removing the global variable '$a' from the  
namespace Tcl should be sufficient. The interpreter should have its  
own state which you can reset, but a lot of that is hidden in globals  
in the _Tcl namespace.


I think when we add support for [interp] and [safe], you'll be able  
to do manage this process more cleanly.






2) I can access TCL variables from PIR using

find_global _Tcl, __read

Is there any way to access Parrot globals from TCL ( other than  
doing inline PIR to assign them to a TCL variable) ?





At this point, no. We need the [namespace] command to be able to poke  
around outside the Tcl namespace. At which point you'll be able to  
do something like:


set a ::_parrot::Perl6::\$b

Interoperability between HLLs isn't finalized yet, though, so I'm not  
sure if we'll each end up in our own top level namespace.






3) Is there a way to pass parameters to the subroutine produced by  
the TCL compiler ?


.sub _main @MAIN
load_bytecode languages/tcl/lib/tcllib.pbc

$P1 = compreg 'TCL'
  $P0 = compile $P1, 'puts $first_parameter'
  $P0('hello')

  # now reset the TCL interpreter somehow
.end




Nope. I would expect this to work:

.sub main @MAIN

  load_bytecode languages/tcl/lib/tcllib.pbc

  $P0 = compreg TCL
  $P1 = compile $P0, proc _tmp {a} {puts $a}
  $P1()

  $P2 = find_global Tcl, _tmp

  $P3 = new String
  $P3 = hello
  $P2($P3)
.end

That is, define a sub in Tcl that does what you want, then invoke  
that sub. This fails on the last line, however, with _scratch_pad:  
too deep. Adding this as a TODO item in the partcl test suite...






4) Is there a way to pass parameters from TCL to inline PIR code ?
My current work-around is to put them into variables and access  
those using __Tcl::__read.




At the moment, no. However, since [inline] is a partcl creation (not  
part of pure tcl), we can define whatever semantics we like: We could  
pre-process the string and expand variable/backslash/command  
substitution...


But, as I noted above: every variable and proc in the script is  
really a parrot variable at some level: so you can use find_global,  
find_lex, find_name, etc. Variables have a $ sigil, procedures have a  
 sigil. Variables in tcl's level 0 are parrot globals, everything  
used in a proc is a lexical. {{ check out t/tcl_pir_compiler.t test #  
2 for an example going in the other direction. }}


The sigils are to avoid problems with code like: set a 2; a, which  
until a week or so ago, failed because it was trying to execute a  
String PMC with a value of 2, instead of correctly complaining about  
an invalid command.







Thanks,

Thilo



Thank you! Sorry the answer to most of your questions was no... If  
there's anything I can do to help improve partcl for your use, let me  
know. Since I was able to get a concrete TODO test out of #3, that'll  
probably get fixed first.


Regards.



Re: [perl #36597] [PATCH]Dominance Frontiers

2005-07-28 Thread Curtis Rawls
Can someone apply this?  I have another patch ready that depends on this one.
Thanks!
-Curtis

On 7/19/05, via RT Curtis Rawls [EMAIL PROTECTED] wrote:
 # New Ticket Created by  Curtis Rawls
 # Please include the string:  [perl #36597]
 # in the subject line of all future correspondence about this issue.
 # URL: https://rt.perl.org/rt3/Ticket/Display.html?id=36597 
 
 
 This patch adds support for dominance frontiers in imcc, including:
 -Array of Sets for dominance frontiers
 -An efficient algorithm described in A Simple, Fast Dominance
 Algorithm, Cooper et al. (2001)
 -Free and dump functions
 
 -Curtis
 
 



Re: [perl #36597] [PATCH]Dominance Frontiers

2005-07-28 Thread Will Coleda

FYI, on OS X 10.4.2, I get:

Failed Test   Stat Wstat Total Fail  Failed  List of Failed
 
---

t/p6rules/backtrack.t1   256151   6.67%  2
t/pmc/eval.t 3   768143  21.43%  12-14
t/pmc/perlstring.t   1   256681   1.47%  61
t/pmc/string.t   1   256351   2.86%  28

I have some slight differences from svn-latest which of course  
shouldn't affect these tests. =-)


On Jul 19, 2005, at 10:39 PM, Curtis Rawls (via RT) wrote:


# New Ticket Created by  Curtis Rawls
# Please include the string:  [perl #36597]
# in the subject line of all future correspondence about this issue.
# URL: https://rt.perl.org/rt3/Ticket/Display.html?id=36597 


This patch adds support for dominance frontiers in imcc, including:
-Array of Sets for dominance frontiers
-An efficient algorithm described in A Simple, Fast Dominance
Algorithm, Cooper et al. (2001)
-Free and dump functions

-Curtis

df.patch





Re: [perl #36597] [PATCH]Dominance Frontiers

2005-07-28 Thread Will Coleda
The eval tests are failing with a pristine checkout so we can ignore  
those. Applying your patch to a pristine build yields only the  
backtrack.t failure: #2 eats 100% of the CPU until I kill it: it  
doesn't behave that way in svn-head.


Looks like PerlString and String were red herrings. Should track down  
why p6rules is misbehaving with your patch, though.


Regards.

On Jul 28, 2005, at 1:55 PM, Will Coleda wrote:


FYI, on OS X 10.4.2, I get:

Failed Test   Stat Wstat Total Fail  Failed  List of Failed
-- 
-

t/p6rules/backtrack.t1   256151   6.67%  2
t/pmc/eval.t 3   768143  21.43%  12-14
t/pmc/perlstring.t   1   256681   1.47%  61
t/pmc/string.t   1   256351   2.86%  28

I have some slight differences from svn-latest which of course  
shouldn't affect these tests. =-)


On Jul 19, 2005, at 10:39 PM, Curtis Rawls (via RT) wrote:



# New Ticket Created by  Curtis Rawls
# Please include the string:  [perl #36597]
# in the subject line of all future correspondence about this issue.
# URL: https://rt.perl.org/rt3/Ticket/Display.html?id=36597 


This patch adds support for dominance frontiers in imcc, including:
-Array of Sets for dominance frontiers
-An efficient algorithm described in A Simple, Fast Dominance
Algorithm, Cooper et al. (2001)
-Free and dump functions

-Curtis

df.patch










Re: [perl #36677] Parrot cannot startup if STDERR or STDOUT is closed

2005-07-28 Thread jerry gay
i've added a new test t/run/exit.t that checks parrot exit codes under
different scenarios. the 8 subtests all pass on win32.

hopefully this will reproduce the behavior you're seeing.
~jerry

On 7/27/05, via RT Michael G Schwern [EMAIL PROTECTED] wrote:
 # New Ticket Created by  Michael G Schwern
 # Please include the string:  [perl #36677]
 # in the subject line of all future correspondence about this issue.
 # URL: https://rt.perl.org/rt3/Ticket/Display.html?id=36677 
 
 
 Parrot cannot start up if either STDOUT or STDERR are closed.  In both cases
 it exits with 65.  This problem was noticed because ponie (which uses Parrot)
 would not start up if STDERR was closed.
 
 $ perl -wle 'close STDERR; system(parrot --version); print $?  8'
 65
 $ perl -wle 'close STDOUT; system(parrot --version); print STDERR $?  8'
 Parrot IO: Failed init layer(unix).
 
 65
 $ perl -wle 'system(parrot --version); print $?  8'
 This is parrot version 0.1.2-devel built for ppc-darwin.
 Copyright (C) 2001-2005 The Perl Foundation.  All Rights Reserved.
 
 Parrot may be copied only under the terms of either the Artistic License or 
 the
 GNU General Public License, which may be found in the Parrot source kit.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See either
 the GNU General Public License or the Artistic License for more details.
 
 PASM/PIR compiler version 0.1.2.
 
 0
 
 
 --
 Michael G Schwern [EMAIL PROTECTED] http://www.pobox.com/~schwern
 You are wicked and wrong to have broken inside and peeked at the
 implementation and then relied upon it.
 -- tchrist in [EMAIL PROTECTED]



Re: [perl #36597] [PATCH]Dominance Frontiers

2005-07-28 Thread Andy Dougherty
On Thu, 28 Jul 2005, Will Coleda wrote:

 Applying your patch to a pristine build yields only the backtrack.t failure:
 #2 eats 100% of the CPU until I kill it: it doesn't behave that way in
 svn-head.

I can confirm the backtrack #2 failure under SPARC/Solaris.  I can't say 
what other tests may have changed; the script I had running the comparison 
got stuck at backtrack.t and never finished.

-- 
Andy Dougherty  [EMAIL PROTECTED]


[svn ci] (r8717) Win32 Dynclasses

2005-07-28 Thread Jonathan Worthington

Hi,

Dynclasses now work on Win32 when building Parrot with the MS Visual Studio 
compiler.  That means that all t\dynclass\*.t passes.  :-)


I've also (after ci'ing a fix to config/gen/makefiles/tcl.in) managed to 
build Partcl on Win32 and run the tests.  Here's what I'm seeing.


Failed Test   Status Wstat Total Fail  Failed  List of Failed
--

t\cmd_expr.t  433   6.98%  41-43
t\cmd_linsert.t51  20.00%  2
t\cmd_proc.t   41  25.00%  4
t\cmd_source.t 21  50.00%  1
t\cmd_string.t374  10.81%  16, 33-35
t\cmd_time.t   11 100.00%  1
t\tcl_backslash.t 162  12.50%  12, 14
t\tcl_command_subst.t 101  10.00%  10
t\tcl_misc.t  121   8.33%  12
t\tcl_pir_compiler.t   31  33.33%  3
Failed 10/39 test scripts, 74.36% okay. 16/266 subtests failed, 93.98% okay.

Any problems, let me know.

Take care,

Jonathan 



[perl #31649] [TODO] Win32 - Automatically Export Symbols

2005-07-28 Thread Jonathan Worthington via RT
This is the Better Way to do part of what my recent dynclasses ci did.
But, I think that some input is needed into what should be in the Parrot
API for extensions and what should not. Also, it'd be changes that touch
a lot of files and I'm not sure that's wise while we've got leo's branch
- someone may know better than I here.

If someone could provide input into what should be in the Parrot API
then I'll happily deal with this task and fix up dynclass building to do
things this way at the appropriate time.

Thanks,

Jonathan