Re: Parrot is very (intentionally) broken

2002-02-10 Thread Jeff G

Jeff G wrote:
 
 Simon Cozens wrote:
 
  I've just committed some changes after which Parrot will not compile.
  This is quite deliberate. Basically, I'm trying to get the keyed stuff
  working the way we want, and that requires some painful changes to the
  source. The upshot is:
 
  All the vtable functions _index and index_s are dead; they've been
  removed from the vtable structure, and so things which expect to find
  them won't compile.
  I've added another multimethod, _keyed, which does their job. This
  means the vtable structure has been rearranged, and everything depending
  on it will break.
  Arrays and hashes won't work at all until they're rewritten to use
  keys instead of integer/string indices.
 
  I'm working on unbreaking it, patches welcome.
 
  --
  You are in a maze of little twisting passages, all different.
 
 Well, the first set of patches have been committed. The following things
 still need to be done:
 
 1) Move key.c's bucket functions to perlhash.pmc.
 2) Rewrite perlhash.pmc class functions to use the proper hashing
 functions.
 3) Rewrite global_setup.c to use PerlHash members
 4) Rewrite core.ops to use the new get_{type}_keyed
 5) Lots of testing.

array and perlarray are done, perlhash should be done tonight. Moving
code around was fairly simple, but I was interrupted before I could add
perlhash to the CVS import.

--
Jeff [EMAIL PROTECTED]



[COMMIT] Changing vtable.tbl format...

2002-02-04 Thread Jeff G

The new format looks much more C-like, as opposed to the old
tab-delimited type. The format now looks roughly like this:

init() # Assumes both 'void' type and 'unique' class.
INTVAL get_integer (INTVAL value) # C-like prototyping mechanism
void logical_or (PMC * value, PMC * dest) # 'unique' assumed, knows how
to handle comma-separated argument list, also knows about whitespace
separating 'PMC' and '*'.

This is one part of a partial redesign to add the tag 'src_value',
'dst_value', and the new type 'keyed', which will let us handle Parrot
assembly syntax such as 'set P0[5],32'. This will be part of the next
round of modifications.
--
Jeff [EMAIL PROTECTED]



[COMMIT] Changed aggregate PMCs to use the internal SELF-data cache

2002-02-01 Thread Jeff G

This is the first step of three major changes coming over the weekend.
The only change visible to the assembler will be the syntax 'set
P0[3],7' and 'set P5[foo],P30[7]' for accessing array and hash
aggregates. The changes should also allow us to implement
multidimensional arrays.
--
Jeff [EMAIL PROTECTED]



[COMMIT] PerlArray fixes

2002-01-29 Thread Jeff G

PerlArray was previously unable to use negative indices to do anything
but access integer values. This has now been fixed to let you use
negative indices to access all basic types and alter basic types.

The next step is threefold:
1 - Unify (get_integer_index, get_number_index, get_string_index) into
get_index
2 - Add the PMC type to the array and hash indices
3 - Change the assembler syntax for array and hash indices to look like
P0[-7] and P5[foo]
--
Jeff [EMAIL PROTECTED]



[COMMIT] Array type

2002-01-28 Thread Jeff G

I've just added a new 'Array' type alongside the current PerlArray. Some
target languages may not like to use Perl's array style, so they now can
use the basic Array type. As the test (t/op/pmc_array.t) indicates, no
preallocation is done. I probably need to support exceptions at some
future date, but as there are (currently) only 6 vtable entries which
would care, I've temporarily put it off.

Soon, the 6 vtable entries will collapse into 2 entries. The
get_{foo}_index and set_{foo}_index members will be collapsed into
'get_index' and 'set_index' members. I've also done some initial work on
Unicode integration, but I think these changes take precedence for the
time being. Problems still exist in PerlArray that I'll root out over
the next week and fix.

--
Jeff [EMAIL PROTECTED]



[COMMIT] IntQueue added...

2002-01-13 Thread Jeff G

This is strictly a teaching tool for an upcoming perl.com article. I've
put it into CVS rather than have to explain to newbies what the code may
have looked like at one time.

--
Jeff [EMAIL PROTECTED]



Re: Problem with key.c?

2002-01-08 Thread Jeff G

Simon Glover wrote:
 
  In amongst all the unused parameter warnings, gcc throws up these two for
  key.c:
 
   key.c: In function `key_element_value_s':
   key.c:275: warning: passing arg 2 of `find_bucket' from incompatible
pointer type
 
   key.c: In function `key_set_element_value_s':
   key.c:339: warning: assignment from incompatible pointer type
 
  The corresponding lines are:
 
   pair = find_bucket(interpreter,key-keys[hash].cache.struct_val,idx);
 
  and:
 
   key-keys[hash].cache.struct_val = bucket;
 
  In the first case, we're passing a STRING* value to a function that's
  expecting a BUCKET*; in the second, trying to fit a BUCKET* into a
  STRING*. This doesn't seem right, but I have to confess my C's not really
  up to figuring out what's supposed to be going on here. Can anyone shed
  some light?
 
  Simon

It's okay, actually. I'm using the STRING* pointer to contain the chain
of buckets, which may seem strange but it's actually the intended use of
the -struct-_val member. Most of the time that pointer gets used for a
STRING*, so it was given a STRING* type rather than a void* type which
would lose the benefit of typechecking. This is one case where C's
strong typing hurts. The only real alternatives are to either declare
struct_val as void* and lose all benefit, or declare it as STRING* which
handles the most common case, and unfortunately causes a warning when
other (equally reasonable) alternatives are used. I probably should
suppress this warning with an explicit cast, and in all likelihood will
do so after tracking down a bug in key.c some time this week.

--
Jeff [EMAIL PROTECTED]



[COMMIT] PerlHash buckets

2002-01-07 Thread Jeff G

The implementation is pretty straightforward, and doesn't yet match
perl5's implementation.

Inserting a key:

1) Hash the key to a number, and fold it to between 0 and NUM_BUCKETS.
2) Create a new bucket, and save both the value and key in it.
3) Tack the bucket onto the appropriate hash index.

Finding a key:

1) Hash the key to a number, and fold it to between 0 and NUM_BUCKETS
2) Go to the appropriate hash index.
3) Walk the list of buckets looking for the appropriate key.
4) If it's been found, return the value.

TODO:

PerlArray and PerlHash can't store PMCs as values yet.
PerlHash doesn't quite correspond to the Perl5 algorithm, inasmuch as it
deals with a fixed number of buckets. It should check the number of
buckets in use, and once it surpasses an arbitrary limit, double the
number of buckets and rehash the key list.

More severe testing. I've personally tested it with 255 different
key/value combinations, and it stored and retrieved values properly.
Given the fact that there are 128 buckets, it's obviously using bucket
overflow.

I'll be doing more testing later on, and fixing what bugs I find later
on this week.

--
Jeff [EMAIL PROTECTED]



[COMMIT] PerlHash class added.

2002-01-04 Thread Jeff G

Sample:

new P0,PerlHash
set P0,-6,foo # Store the value -6 in key 'foo' of the hash P0
set I0,P0,foo # Recover the value at foo

No work has yet been done on hash collision, and behavior for undefined
hash keys is not yet
decided upon.

--
Jeff [EMAIL PROTECTED]



Note on PMC.pod...

2002-01-02 Thread Jeff G

I have come down off the mountain, and bear a partially-written article
for perl.com on how to roll your own PMCs and what this means. Should
hit perl.com sometime within the next two months, with any luck.

It needs the final bit written, and as I've just spent the better part
of a week at almost 2 miles up in the Rockies, I need to make sure the
rarified atmosphere didn't affect my brain too badly. Same goes for the
known-incomplete PerlHash class. It works, but has no collision
resolution yet.

--
Jeff [EMAIL PROTECTED]



[COMMIT] PerlArray type

2001-12-17 Thread Jeff G

Note the three-parameter set() ops, specifically.
A little lacking in documentation, but they do indeed work.

new P0,PerlArray # Initializes a new PerlArray
set P0,N0,I0 sets index I0 of array P0 to the number in register N0
get S0,P0,I0 sets S0 to the string in index I0 of P0

Does the current Perl6 licensing situation permit me to use the perl5
hashing algorithm?

--
Jeff [EMAIL PROTECTED]



[COMMIT] miniperl has been somewhat busy...

2001-12-16 Thread Jeff G

I've restructured the output from the miniperl parser to make things a
little less confusing than having HoLoHoLo... monstrosities floating
around, and added a rather large and hopefully somewhat comprehensive
test suite into Miniperl/t. The code generator now handles expressions
fairly cleanly, unfortunately I haven't added a backend optimizer yet,
so it generates code that has commands like 'set P0, P1', so that
instruction needs to be added. The consensus on that thread seems to be
that it should perform a deep copy of the PMC, at least to the pointer
level. I'll hopefully be committing this tonight.

--
Jeff [EMAIL PROTECTED]



[COMMIT] Optimizer

2001-12-13 Thread Jeff G

Doesn't do much beyond strength reduction and constant folding, but it's
there. Also, if you look at the parsing routines I've created a fairly
simple data structure to hold lines of a post-macro-processed assembler
program. The output routine preserves comments and whitespace within
reason.

--
Jeff [EMAIL PROTECTED]



[COMMIT] languages/miniperl

2001-12-12 Thread Jeff G

Now that PMCs are perl-like, it's about time to start language
development.

Currently it's sophisticated enough to be able to compile and run the
following perl{56} code:

my ($a,$b);
$b=foo;
$a=-71.5;
print $a;
print $b;

But that will change soon. There aren't any tests currently, awaiting a
comprehensive test suite when the parser does something non-trivial.
Feel free to play with the code, enhance it, c.

--
Jeff [EMAIL PROTECTED]



[COMMIT] Added a nascent make.pl implementation...

2001-12-12 Thread Jeff G

Caveats from the commit mail are roughly as follows:

Nearly-complete 'make' replacement in perl.
Non-compliant bits - Takes absolutely -NO- special flags...
   - Dies on undefined macros such as $(PDISASM) in
current make
   - Dies on recursive macro expansions
 (Doesn't test for mutual or multipart loops)
   - In general it seems to be a little less lenient...
Missing bits - File mod/creation times aren't being looked at
 - Actions aren't being taken
 - The few funky variables ($@, $) aren't being dealt with
Bugs - Line numbers are slipping a bit.

It actually detects a few errors (?) in our current makefile. This
probably means that some of the variables ($(MAKE) for instance) are
actually generated within make, and there are probably a few more
environment variables that need to be inserted.

One further bug that I'd forgotten about - I don't remember if the macro
expander deals with multiply-nested macros, beyond getting lucky and
expanding A-B before B-C, so it can replace C with A.

Feel free to fix this up... I'll be over here working on miniperl.

--
Jeff [EMAIL PROTECTED]



Re: Nmake is stupid.

2001-12-12 Thread Jeff G

Dan Sugalski wrote:
 
 At 05:40 PM 12/12/2001 -0800, Robert Spier wrote:
 | patches integrated in soon, and a longer-term solution (i.e. a perl make)
 | should be ready not too long after that.
 
 bool query  {
Dan, you've been unclear.  Is a perl5 based make system
 where you want to be today?
 }
 
 Perl, yes. At the moment perl 5, but we'll morph it over to perl 6 when
 we've a working parser for it.

What's this when?
make.pl v. ~0.6  committed. It uses a fairly simple line-based parser,
not P::RD. I didn't want to require non-core modules, but we can
certainly take this and morph it into something more perl-like. As a
matter of fact, I would prefer to do this, but doing that would break
GNU make compatibility. Given the HoHoHoHo... data structure I use to
hold dependencies it would be fairly straightforward to map onto
something using P::RD.

--
Jeff [EMAIL PROTECTED]



[COMMIT] Key aggregate code committed.

2001-12-10 Thread Jeff G

Added files:
  key.c
  include/parrot/key.h
  t/op/key.t

Altered files:
  MANIFEST
  Makefile.in
  include/parrot/parrot.h
  core.ops

Implements generic aggregate support in the Sn registers. t/op/key.t has
quick samples of its use. It does have fairly rigorous internal tests,
but the memory allocation is rather primitive. It does do the job, but
as nobody's come up with a memory gc scheme, it doesn't matter yet.

--
Jeff [EMAIL PROTECTED]



Re: Key stuff for aggregates

2001-12-06 Thread Jeff G

Tests passed...

---cut here---
new_key S0
  clone_key S1,S0
  size_key  S1,5
  key_size  I0,S1
  print I0 (3) 
  print I0
  print \n
toss_key S0

#ke_type I1,S1,1

  ke_set_value S1,0,5
  ke_value I0,S1,0
  ke_type I1,S1,0
  print I0 (5) I1 (0): 
  print I0
  print  
  print I1
  print \n

  ke_set_value S1,1,-3.75
  ke_value N0,S1,1
  ke_type I1,S1,1
  print N0 (-3.75) I1 (0): 
  print N0
  print  
  print I1
  print \n

  ke_set_value S1,2,bar
  ke_value S0,S1,2
  ke_type I1,S1,2
  print S0 (bar) I1 (0): 
  print S0
  print  
  print I1
  print \n

end
---cut here---

I added the ke_set_value operation to allow us to set key indices.
The above test passed, and it'll be available after 0.03 is finished.

--
Jeff [EMAIL PROTECTED]



Re: Key stuff for aggregates

2001-12-04 Thread Jeff G

Dan Sugalski wrote:
 
 'Kay, here's the preliminary assembly-level docs for keys, which is how
 we're going to be accessing entries in aggregates.
 
 --Snip here---
 =head2 Key operations
 
 Keys are used to get access to individual elements of an aggregate
 variable.  This is done to allow for opaque, packed, and
 multidimensional aggregate types.
 
 A key entry may be an integer, string, or PMC. Integers are used for
 array lookups, strings for hash lookups, and PMCs for either.
 
 =over 4
 
 =item new_key Sx

The fact that the S registers are in fact generic struct registers is
not evident from outside the internal code. For those of us implementing
instructions, it might be useful to explicitly cast values like $1 to
the correct type, in order to make sure we recognize this.

The following code came up frequently when writing the key() functions
that Dan enumerated int his file...

key_inc(interpreter, $1, $2);
Explicitly casting $1 to (KEY*) helps reinforce this fact, eliminates a
compile-time warning, and doesn't cost any runtime penalty.

--
Jeff [EMAIL PROTECTED]



Re: Thoughts on vtables...

2001-12-02 Thread Jeff G

Simon Cozens wrote:
 
 On Sun, Dec 02, 2001 at 02:21:38AM -0500, Jeff G wrote:
Currently vtable.h is dynamically constructed from what would appear
  to be a union of all possible operators on {int,num,string}. Now, this
  is certainly handy (especially after having to cast one type to another,
  and making heavy use of said vtable entries), but this will also become
  unwieldy quickly. One simple example we have right now is the existence
  of operations like PerlNum_logical_or.
 
 I don't think there'll be any more we want to add.

Are you quite sure? Implementing things like arrays of PMCs will be hard
without operations like set_value(PMC* pmc, INTVAL index). And don't get
me started about things like native Scheme list types... Cons, car, and
cdr operations would probably add at least nine entries at a minimum. Or
are PMCs that are formed of compound scalars going to be implemented in
some other new fashion, or entirely at the assembly level?
 
It's nice to have the ability to call any vtable method blithely
  against any PMC, and in fact the current PMC strings c do just that.
  (Incidentally it would be nice to have some way to identify a value by
  other than an if(){}else(){} on its vtable member...)
 
 I don't see what you mean - isn't this what pmc-vtable-type is about?

I suppose so, but it still feels rather crufty to me for some reason.
Maybe a simple pmc-get_type() function would do the trick?

Looking at the current tests, apparently the new 'interpreter' PMC
  also uses type 0, so the problem would appear to be slightly deeper than
  what I've commented on.
 
 That's just a hack. I think you're expecetd to know that interpreter PMCs
 aren't real ones. However, type 0 will soon be used by a PerlUndef class.

Yes, I figured that the interpreter PMC type was more or less a
placeholder. I simply was pointing out that more than one type was
currently residing on the same index.

  Incidentally, I personally would find something
  like 'new P0,interpreter' or 'new P0,perl_scalar' clearer than a
  cryptic digit.
 
 Yep. This requires fixing the assembler to know about the enum in vtable.h

That enum won't mean much once we have PMCs in there gamboling about,
changing vtables dynamically between int and string and such... Maybe we
should add a small layer of indirection and end up with class names such
as 'perl_undef' and 'perl_scalar' that will isolate the code below the
layer where the compiler author will have to care about what initial
type the PMC is beyond undef/scalar/array/hash?

 Simon
 
 --
 The use of COBOL cripples the mind; its teaching should, therefore, be
 regarded as a criminal offence.
 -- Edsger W. Dijkstra, SIGPLAN Notices, Volume 17, Number 5



[PATCH] Very small, very crude implementation of PerlArray

2001-12-02 Thread Jeff G

Because of the problems I've had sending diffs to the list, I'm just
putting this onto my webserver at
http://216.254.0.2/~jgoff/Files/Array.tgz.

This is a *VERY* crude implementation of a very limited array in Parrot.

In addition to the PerlArray class, it also adds two new instructions to
the parrot core:

get i, p, i|ic # Retrieve the integer at index $3 of PMC $2 into $1
set p, i|ic, i|ic # Store value $2 into PMC $1 at index $3

Now, this is -STRICTLY- proof-of-concept, so the implementation doesn't
do the following:
1) Dynamic memory allocation - You're stuck with a max. of 8 integers
2) PMCs - You're stuck with the integer type - I'm planning to fix this
problem tonight

Internally there are of course more things wrong with it, for instance
it should use perlarray_init to do the initialization instead of relying
on perlarray_get_integer_index. This also brings up a small point, that
once a new type is added, every other type needs to become at least
mildly aware of it, especially the perlint, because it by default
assumes that when a new type is being created, it starts as perlint.

I'll be the first person to admit that this code is full of limitations
and probably bugs, but again it's a rough proof of concept. It does only
one thing, but it seems to do it fairly well. Needs a lot of feature
enhancement before it can become a real array class. It does seem to
work fairly well so far, but it's got a long road to go before it
becomes reality.

-Jeff
[EMAIL PROTECTED]



RE: [PATCH] Don't count on snprintf

2001-12-01 Thread Jeff G

Applied Andy's patch just to keep the tree sane while the actual issue
gets worked out. I'll probably pull out perl5's snprintf function and
add it to the vtables. One other issue I can see in the vtable stuff is
that there's no easy way to add a library of vtable operations (such as,
in this case, snprintf) to an existing set of operations. I'll be
pondering this while I'm out getting shopping done, so don't be
surprised to see a patch proposal later on tonight...

-Jeff
[EMAIL PROTECTED]



[COMMIT] Makefile changes

2001-12-01 Thread Jeff G

classes/ now has a real Makefile.in
Configure.pl now dynamically builds classes/Makefile, and no longer
passes in -I./include as an expanded parameter.
Makefile.in has the classes/perl*.o targets removed, replaced with a 'cd
classes; make' target.

This is done in anticipation of being able to decouple building classes
from the rest of the application. One area that probably should be
patched by someone is that '-I./include' should probably be dynamically
generated at each level, instead of being hardcoded as it is currently.

-Jeff
[EMAIL PROTECTED]



Thoughts on vtables...

2001-12-01 Thread Jeff G

Now I'll be the first to admit that I'm probably not the most coherent
in the world at (looks at the clock) 1:19 A.M. but I'm sitting here
trying to get something like a PerlInt_Array ready for compilation and
noticing some problems. It's also entirely possible that I'm looking at
this in the wrong fashion, so someone please correct me if I'm wrong.

  Currently vtable.h is dynamically constructed from what would appear
to be a union of all possible operators on {int,num,string}. Now, this
is certainly handy (especially after having to cast one type to another,
and making heavy use of said vtable entries), but this will also become
unwieldy quickly. One simple example we have right now is the existence
of operations like PerlNum_logical_or.

  It's nice to have the ability to call any vtable method blithely
against any PMC, and in fact the current PMC strings c do just that.
(Incidentally it would be nice to have some way to identify a value by
other than an if(){}else(){} on its vtable member...) However, as we add
more and more members to this vtable structure, it will become really
unwieldy.

  I'm not advocating custom-created vtables for each single class (That
would involve tables to do the mapping of get_integer functionality from
one vtable class to the next, or making sure that get_integer was always
item 1 in a particular vtable or some such...) Instead I'd like to see
each different vtable type (object, if you will) have its own set of
vtable entries.

  This would involve (unfortunately) one more level of indirection
(Namely the interpreter looking at the current PMC type, and dispatching
to a new vtable), but it would save a great deal of space within the
vtable design. I'll probably work on this design once I have a clearer
head. Looking back on this, I guess this rant equates to Make 'new
P0,n' switch in vtable #n when used.

  Looking at the current tests, apparently the new 'interpreter' PMC
also uses type 0, so the problem would appear to be slightly deeper than
what I've commented on. Incidentally, I personally would find something
like 'new P0,interpreter' or 'new P0,perl_scalar' clearer than a
cryptic digit. However it would be slightly slower to compile that way.

  In any case, please take these ramblings with several grains of salt.
Tomorrow I'll work on the system I suggested and see how far I can get
with this idea.

-Jeff
[EMAIL PROTECTED]



Silly question...

2001-11-29 Thread Jeff G

Shouldn't we be placing set_p_i and the like in vtable.ops?

-Jeff
Radio Shack: You've got questions, we've got blank stares!



Re: Silly question...

2001-11-29 Thread Jeff G

Jeff G wrote:
 
 Shouldn't we be placing set_p_i and the like in vtable.ops?

Of course, I meant vtable.tbl... Based on this confusion I'm now
wondering if it wouldn't be better to let a human create the vtable.ops
file and leave vtable.tbl as an auxiliary file that's used to generate
the appropriate entries for vtable.h and the like.

-Jeff
[EMAIL PROTECTED]



[COMMIT] Final PMC additions

2001-11-29 Thread Jeff G

concat, set, {add,sub,mul,div} implemented.
The following instructions will now work as in perl5...

set P0,3
set P1,foo
concat P0,P0,P1 # 3foo
set P0,3
add P0,P0,P1 # 3
set P0,-13.3
set P1,13.3
add P0,P0,P1 # 0 (even though P1 is a string)

The code for add/sub/mul/div has to be able to be simplified somehow. It
passes the requisite tests so I'm calling it good for now, but there's
probably a very simple optimization that I'm missing at 1:30 A.M.

-Jeff
[EMAIL PROTECTED]



Re: [COMMIT] Added basic integer PMC ops

2001-11-25 Thread Jeff G

Simon Cozens wrote:
 
 On Sun, Nov 25, 2001 at 12:57:19AM -0500, Jeff G wrote:
  Along with testing in t/op/pmc.t
 
 Wait! This is all bogus. Not only do we need overflow checking, but
 we also need to deal with the contingency that in, say,
 
 add P1, P2, P3
 
 the value PMC may not be an integer, and hence we have to promote
 everything.

Yes we do, and I agree, but I wasn't able to figure out how to load in
the PerlNum class, which (obviously) is required in order to have
something to promote to, so I stuck to testing and fixing integer
operations. I'll see about numeric/string operations some time this
week.

 I've left the code in, updated to fit Angel's preprocessor, but this
 is something we need to remember.
 
 --
 If you want to travel around the world and be invited to speak at a lot
 of different places, just write a Unix operating system.
 (By Linus Torvalds)



[COMMIT] Added basic integer PMC ops

2001-11-24 Thread Jeff G

Along with testing in t/op/pmc.t

-Jeff
[EMAIL PROTECTED]



Re: [PMC] Test suite (Inline this time...)

2001-11-22 Thread Jeff G

All right, inserting the file *inline* this time...

*grumble*grumble*Netscape*grumble*firewall*grumble*

In any case, the file is now known to be below these comments.
As noted previously, many of these tests should actually return
something (an error string, or maybe an actual numeric value or string
value), but what it should return hasn't been decided on or properly
cast. For reasons that I'm hoping are obvious this file isn't being
committed, but I have it locally in CVS so it won't go away any time
soon.

---cut here---
#! perl -w

use Parrot::Test tests = 1;

#
# For consistency's sake, make sure tests are in INS order
#
# Border conditions for integer: 0, negative value, positive value
# Border conditions for number: 0.0, negative value, positive value
# Border conditions for string: '', one-char string
#
# Test data going into a PMC
# Test data getting into a PMC
# Test data getting out of a PMC
# Test PMC-only ops
#
# '' as a test result means one of the following:
#
# No output should be generated
# (We need some sort of test against undef, to better validate things)
# Should generate an error whose text hasn't been decided on
# (Usually 'operation on undefined string' or the like)
# Ambiguous return result.
# (For instance, should concat P0,,5 set a numeric 5 or Sorry, not a
string)
#

output_is('CODE','','set P0,0');
set P0,0
end
CODE
output_is('CODE','','set P0,2');
set P0,2
end
CODE
output_is('CODE','','set P0,-7');
set P0,-7
end
CODE
output_is('CODE','','set P0,I0 (not assigned)');
set P0,I0
end
CODE
output_is('CODE','','set P0,I0 (0)');
set I0,0
set P0,I0
end
CODE
output_is('CODE','','set P0,I0 (9)');
set I0,9
set P0,I0
end
CODE
output_is('CODE','','set P0,I0 (-3)');
set I0,-3
set P0,I0
end
CODE
output_is('CODE','','set P0,0.0');
set P0,0.0
end
CODE
output_is('CODE','','set P0,1.1');
set P0,1.1
end
CODE
output_is('CODE','','set P0,-4.6');
set P0,-4.6
end
CODE
output_is('CODE','','set P0,N0 (0.0)');
set N0,0.0
set P0,N0
end
CODE
output_is('CODE','','set P0,N0 (3.5)');
set N0,3.5
set P0,N0
end
CODE
output_is('CODE','','set P0,N0 (-8.7)');
set N0,-8.7
set P0,N0
end
CODE
output_is('CODE','','set P0,N0');
set P0,N0
end
CODE
output_is('CODE','','set P0,');
set P0,
end
CODE
output_is('CODE','','set P0,a');
set P0,a
end
CODE
output_is('CODE','','set P0,S0 ()');
set S0,
set P0,S0
end
CODE
output_is('CODE','','set P0,S0 (a)');
set S0,a
set P0,S0
end
CODE
output_is('CODE','','set P0,S0');
set P0,S0
end
CODE

#
# Now that input is verified, we can test output.
#
output_is('CODE',0,'print parrot integer (0)');
set P0,0
print P0
end
CODE
output_is('CODE',2,'print parrot integer (2)');
set P0,2
print P0
end
CODE
output_is('CODE',-6,'print parrot integer (-6)');
set P0,-6
print P0
end
CODE
output_is('CODE',0.0,'print parrot number (0.0)');
set P0,0.0
print P0
end
CODE
output_is('CODE',9.27,'print parrot number (9.27)');
set P0,9.27
print P0
end
CODE
output_is('CODE',-7.19,'print negative parrot number (-7.19)');
set P0,-7.19
print P0
end
CODE
output_is('CODE','','print parrot string ()');
set P0,
print P0
end
CODE
output_is('CODE','a','print parrot string (a)');
set P0,a
print P0
end
CODE

#
# Two-parameter PMC ops
#
output_is('CODE',~5,'not integer (5)');
not P0,5
print P0
end
CODE
output_is('CODE','','not numeric (-3.2)');
not P0,-3.2
print P0
end
CODE
output_is('CODE','','not string (ab)');
not P0,ab
print P0
end
CODE

#
# Three-parameter PMC ops
# 
# undef-undef, undef-integer, undef-numeric, undef-string
#  integer-integer, integer-numeric, integer-string
#   numeric-numeric, numeric-string
#string-string
output_is('CODE','','add undef-undef');
add P0,P1,P2
print P0
end
CODE
output_is('CODE','','sub undef-undef');
sub P0,P1,P2
print P0
end
CODE
output_is('CODE','','mul undef-undef');
mul P0,P1,P2
print P0
end
CODE
output_is('CODE','','div undef-undef');
div P0,P1,P2
print P0
end
CODE
output_is('CODE','','mod undef-undef');
mod P0,P1,P2
print P0
end
CODE
output_is('CODE','','concat undef-undef');
concat P0,P1,P2
print P0
end
CODE
output_is('CODE','','and undef-undef');
and P0,P1,P2
print P0
end
CODE
output_is('CODE','','or 

[PMC] Patch to combine core.ops and vtable.ops all.ops

2001-11-22 Thread Jeff G

Rather wordy, I know, but it also points out how many places depend upon
the name 'core' in the current code.

I'm also posting a different version shortly that combines core.ops and
vtable.ops into one core_ops.{c,h,pm}.

-Jeff
[EMAIL PROTECTED]

--- cut here ---
diff -ru parrot_orig/Configure.pl parrot/Configure.pl
--- parrot_orig/Configure.plThu Nov 22 16:52:23 2001
+++ parrot/Configure.pl Thu Nov 22 20:02:57 2001
@@ -62,6 +62,7 @@
 #defaults for them.
 #XXX Figure out better defaults
 my(%c)=(
+   cat =  ($Config{cat}  ||'cat'),
iv =   ($Config{ivtype}   ||'long'),
intvalsize =   undef,
 
diff -ru parrot_orig/Makefile.in parrot/Makefile.in
--- parrot_orig/Makefile.in Thu Nov 22 16:52:23 2001
+++ parrot/Makefile.in  Thu Nov 22 20:13:40 2001
@@ -1,18 +1,19 @@
 O = ${o}
 RM_F = ${rm_f}
+CAT = ${cat}
 
 INC=include/parrot
 
 H_FILES = $(INC)/config.h $(INC)/exceptions.h $(INC)/io.h $(INC)/op.h \
 $(INC)/register.h $(INC)/string.h $(INC)/events.h $(INC)/interpreter.h
\
 $(INC)/memory.h $(INC)/parrot.h $(INC)/stacks.h $(INC)/packfile.h \
-$(INC)/global_setup.h $(INC)/vtable.h $(INC)/oplib/core_ops.h \
-$(INC)/runops_cores.h $(INC)/trace.h $(INC)/oplib/vtable_ops.h \
+$(INC)/global_setup.h $(INC)/vtable.h $(INC)/oplib/all_ops.h \
+$(INC)/runops_cores.h $(INC)/trace.h \
 $(INC)/pmc.h $(INC)/resources.h $(INC)/platform.h
 
 O_FILES = global_setup$(O) interpreter$(O) parrot$(O) register$(O) \
-core_ops$(O) memory$(O) packfile$(O) stacks$(O) string$(O) encoding$(O)
\
-chartype$(O) runops_cores$(O) trace$(O) vtable_ops$(O) pmc$(O) \
+all_ops$(O) memory$(O) packfile$(O) stacks$(O) string$(O) encoding$(O)
\
+chartype$(O) runops_cores$(O) trace$(O) pmc$(O) \
 encodings/singlebyte$(O) encodings/utf8$(O) encodings/utf16$(O) \
 encodings/utf32$(O) chartypes/unicode$(O) chartypes/usascii$(O)
resources$(O) \
 platform$(O) classes/perlint$(O) classes/perlstring$(O)
classes/perlnum$(O)
@@ -42,7 +43,7 @@
 libparrot.so: $(O_FILES)
$(CC) -shared $(C_LIBS) -o $@ $(O_FILES)
 
-$(TEST_PROG): test_main$(O) $(O_FILES) Parrot/OpLib/core.pm
+$(TEST_PROG): test_main$(O) $(O_FILES) Parrot/OpLib/all.pm
$(CC) $(CFLAGS) -o $(TEST_PROG) $(O_FILES) test_main$(O)
$(C_LIBS)
 
 $(PDUMP): pdump$(O) $(O_FILES)
@@ -53,11 +54,17 @@
 examples/assembly/mops.pbc: examples/assembly/mops.pasm assemble.pl
cd examples/assembly; make mops.pbc PERL=$(PERL)
 
-Parrot/OpLib/core.pm: core.ops ops2pm.pl
-   $(PERL) ops2pm.pl core.ops
+all.ops: core.ops vtable.ops
+   $(CAT) core.ops vtable.ops  all.ops
 
-Parrot/OpLib/vtable.pm: vtable.ops ops2pm.pl
-   $(PERL) ops2pm.pl vtable.ops
+Parrot/OpLib/all.pm: all.ops ops2pm.pl
+   $(PERL) ops2pm.pl all.ops
+
+#Parrot/OpLib/core.pm: core.ops ops2pm.pl
+#  $(PERL) ops2pm.pl core.ops
+
+#Parrot/OpLib/vtable.pm: vtable.ops ops2pm.pl
+#  $(PERL) ops2pm.pl vtable.ops
 
 examples/assembly/mops.c: examples/assembly/mops.pbc pbc2c.pl
$(PERL) pbc2c.pl examples/assembly/mops.pbc 
examples/assembly/mops.c
@@ -109,17 +116,14 @@
 
 stacks$(O): $(H_FILES)
 
-core_ops$(O): $(H_FILES) core_ops.c
+all_ops$(O): $(H_FILES) all_ops.c
 
-core_ops.c $(INC)/oplib/core_ops.h: core.ops ops2c.pl
-   $(PERL) ops2c.pl core.ops
+all_ops.c $(INC)/oplib/all_ops.h: all.ops ops2c.pl
+   $(PERL) ops2c.pl all.ops
 
 vtable.ops: make_vtable_ops.pl
$(PERL) make_vtable_ops.pl  vtable.ops
 
-vtable_ops.c $(INC)/oplib/vtable_ops.h: vtable.ops ops2c.pl
-   $(PERL) ops2c.pl vtable.ops
-
 $(INC)/config.h: Configure.pl config_h.in
$(PERL) Configure.pl
 
@@ -135,13 +139,13 @@
$(RM_F) *$(O) classes/*$(O) chartypes/*$(O) encodings/*$(O)
$(RM_F) *.s core_ops.c $(TEST_PROG) $(PDISASM) $(PDUMP)
$(RM_F) $(INC)/vtable.h
-   $(RM_F) $(INC)/oplib/core_ops.h
-   $(RM_F) $(INC)/oplib/vtable_ops.h vtable_ops.c vtable.ops
+   $(RM_F) $(INC)/oplib/all_ops.h
+   $(RM_F) vtable.ops
$(RM_F) $(TEST_PROG) $(PDISASM) $(PDUMP)
$(RM_F) t/op/*.pasm t/op/*.pbc t/op/*.out
$(RM_F) examples/assembly/mops$(EXE) examples/assembly/mops.c
$(RM_F) examples/assembly/mops$(O) examples/assembly/mops.pbc
-   $(RM_F) Parrot/OpLib/core.pm
+   $(RM_F) Parrot/OpLib/all.pm
cd docs; make clean
 
 distclean:
diff -ru parrot_orig/Parrot/Assembler.pm parrot/Parrot/Assembler.pm
--- parrot_orig/Parrot/Assembler.pm Thu Nov 22 16:52:23 2001
+++ parrot/Parrot/Assembler.pm  Thu Nov 22 20:16:17 2001
@@ -33,7 +33,7 @@
 use Getopt::Long;
 
 use Parrot::Op;
-use Parrot::OpLib::core;
+use Parrot::OpLib::all;
 
 #use Parrot::Opcode;
 
@@ -290,7 +290,7 @@
 
 my %opcodes;
 
-foreach my $op (@$Parrot::OpLib::core::ops) {
+foreach my $op (@$Parrot::OpLib::all::ops) {
   $opcodes{$op-full_name} = $op;
 }
 
diff -ru parrot_orig/interpreter.c parrot/interpreter.c
--- parrot_orig/interpreter.c   Thu Nov 22 16:52:23 2001
+++ parrot/interpreter.cThu Nov 22 20:10:42 2001
@@ 

[PMC] Patch to combine core.ops and vtable.ops into core_ops.{c,h,pm}

2001-11-22 Thread Jeff G

Slightly cleaner patch than the crude method of cat'ing the ops files
into one .ops file.
Also doesn't require patching all the places dependent upon 'core'.

-Jeff
[EMAIL PROTECTED]

---cut here---
diff -ru parrot_orig/Makefile.in parrot/Makefile.in
--- parrot_orig/Makefile.in Thu Nov 22 16:52:23 2001
+++ parrot/Makefile.in  Thu Nov 22 19:44:11 2001
@@ -7,12 +7,12 @@
 $(INC)/register.h $(INC)/string.h $(INC)/events.h $(INC)/interpreter.h
\
 $(INC)/memory.h $(INC)/parrot.h $(INC)/stacks.h $(INC)/packfile.h \
 $(INC)/global_setup.h $(INC)/vtable.h $(INC)/oplib/core_ops.h \
-$(INC)/runops_cores.h $(INC)/trace.h $(INC)/oplib/vtable_ops.h \
+$(INC)/runops_cores.h $(INC)/trace.h \
 $(INC)/pmc.h $(INC)/resources.h $(INC)/platform.h
 
 O_FILES = global_setup$(O) interpreter$(O) parrot$(O) register$(O) \
 core_ops$(O) memory$(O) packfile$(O) stacks$(O) string$(O) encoding$(O)
\
-chartype$(O) runops_cores$(O) trace$(O) vtable_ops$(O) pmc$(O) \
+chartype$(O) runops_cores$(O) trace$(O) pmc$(O) \
 encodings/singlebyte$(O) encodings/utf8$(O) encodings/utf16$(O) \
 encodings/utf32$(O) chartypes/unicode$(O) chartypes/usascii$(O)
resources$(O) \
 platform$(O) classes/perlint$(O) classes/perlstring$(O)
classes/perlnum$(O)
@@ -54,10 +54,7 @@
cd examples/assembly; make mops.pbc PERL=$(PERL)
 
 Parrot/OpLib/core.pm: core.ops ops2pm.pl
-   $(PERL) ops2pm.pl core.ops
-
-Parrot/OpLib/vtable.pm: vtable.ops ops2pm.pl
-   $(PERL) ops2pm.pl vtable.ops
+   $(PERL) ops2pm.pl core.ops vtable.ops
 
 examples/assembly/mops.c: examples/assembly/mops.pbc pbc2c.pl
$(PERL) pbc2c.pl examples/assembly/mops.pbc 
examples/assembly/mops.c
@@ -111,15 +108,12 @@
 
 core_ops$(O): $(H_FILES) core_ops.c
 
-core_ops.c $(INC)/oplib/core_ops.h: core.ops ops2c.pl
-   $(PERL) ops2c.pl core.ops
+core_ops.c $(INC)/oplib/core_ops.h: core.ops vtable.ops ops2c.pl
+   $(PERL) ops2c.pl core.ops vtable.ops
 
 vtable.ops: make_vtable_ops.pl
$(PERL) make_vtable_ops.pl  vtable.ops
 
-vtable_ops.c $(INC)/oplib/vtable_ops.h: vtable.ops ops2c.pl
-   $(PERL) ops2c.pl vtable.ops
-
 $(INC)/config.h: Configure.pl config_h.in
$(PERL) Configure.pl
 
@@ -136,7 +130,7 @@
$(RM_F) *.s core_ops.c $(TEST_PROG) $(PDISASM) $(PDUMP)
$(RM_F) $(INC)/vtable.h
$(RM_F) $(INC)/oplib/core_ops.h
-   $(RM_F) $(INC)/oplib/vtable_ops.h vtable_ops.c vtable.ops
+   $(RM_F) vtable.ops
$(RM_F) $(TEST_PROG) $(PDISASM) $(PDUMP)
$(RM_F) t/op/*.pasm t/op/*.pbc t/op/*.out
$(RM_F) examples/assembly/mops$(EXE) examples/assembly/mops.c
diff -ru parrot_orig/ops2c.pl parrot/ops2c.pl
--- parrot_orig/ops2c.plThu Nov 22 16:52:23 2001
+++ parrot/ops2c.pl Thu Nov 22 19:42:10 2001
@@ -9,16 +9,20 @@
 use strict;
 use Parrot::OpsFile;
 
+sub Usage {
+print STDERR _EOF_;
+usage: $0 input.ops [input2.ops ...]\n;
+_EOF_
+exit 1;
+}
 
 #
 # Process command-line argument:
 #
 
-if (@ARGV != 1) {
-  die ops2c.pl: usage: perl ops2c.pl input.ops\n;
-}
+Usage() unless @ARGV;
 
-my $file = $ARGV[0];
+my $file = 'core.ops';
 
 my $base = $file;
 $base =~ s/\.ops$//;
@@ -32,10 +36,22 @@
 #
 # Read the input file:
 #
+$file = shift @ARGV;
+die $0: Could not read ops file '$file'!\n unless -e $file;
 
 my $ops = new Parrot::OpsFile $file;
 
-die ops2c.pl: Could not read ops file '$file'!\n unless $ops;
+for $file (@ARGV) {
+die $0: Could not read ops file '$file'!\n unless -e $file;
+my $temp_ops = new Parrot::OpsFile $file;
+for(@{$temp_ops-{OPS}}) {
+   push @{$ops-{OPS}},$_;
+}
+}
+my $cur_code = 0;
+for(@{$ops-{OPS}}) {
+   $_-{CODE}=$cur_code++;
+}
 
 my $num_ops = scalar $ops-ops;
 my $num_entries = $num_ops + 1; # For trailing NULL
diff -ru parrot_orig/ops2pm.pl parrot/ops2pm.pl
--- parrot_orig/ops2pm.pl   Thu Nov 22 16:52:23 2001
+++ parrot/ops2pm.plThu Nov 22 19:42:10 2001
@@ -13,16 +13,21 @@
 #$Data::Dumper::Terse  = 1;
 #$Data::Dumper::Indent = 0;
 
+sub Usage {
+print STDERR _EOF_;
+usage: $0 input.ops [input2.ops ...]
+_EOF_
+exit;
+}
+
 
 #
 # Process command-line argument:
 #
 
-if (@ARGV != 1) {
-  die ops2c.pl: usage: perl ops2pm.pl input.ops\n;
-}
+Usage() unless @ARGV;
 
-my $file = $ARGV[0];
+my $file = 'core.ops';
 
 my $base = $file;
 $base =~ s/\.ops$//;
@@ -33,12 +38,27 @@
 
 
 #
-# Read the input file:
+# Read the first input file:
 #
 
+use Data::Dumper;
+
+$file = shift @ARGV;
+die $0: Could not read ops file '$file'!\n unless -e $file;
 my $ops = new Parrot::OpsFile $file;
 
-die ops2pm.pl: Could not read ops file '$file'!\n unless $ops;
+for $file (@ARGV) {
+die $0: Could not read ops file '$file'!\n unless -e $file;
+my $temp_ops = new Parrot::OpsFile $file;
+for(@{$temp_ops-{OPS}}) {
+   push @{$ops-{OPS}},$_;
+}
+}
+my $cur_code = 0;
+for(@{$ops-{OPS}}) {
+$_-{CODE}=$cur_code++;
+}
+
 
 my $num_ops = scalar $ops-ops;
 my $num_entries = $num_ops + 1; # For trailing NULL
@@ -49,10 +69,10 @@
 #
 
 if 

[PATCH] Makefile cleans out .pasm, .pbc, .out files from t/op directory

2001-11-20 Thread Jeff G

Presence of old .pasm c files can cause tests to fail because they
blindly attempt to write to string17.pasm or whatever.

-Jeff
[EMAIL PROTECTED]




[PATCHES] Quoting fixes

2001-11-18 Thread Jeff G

(This might be a duplicate, if so, my apologies)

Allows the following quoting styles:
print 'foo'
print foo \bar\ baz

-Jeff
[EMAIL PROTECTED]