Every repository with this icon (
Every repository with this icon (
| Description: | Cardinal - Ruby compiler for Parrot edit |
-
5 comments Created 4 months ago by dtmactionxhas-branchxpirxLeftover Implicit Conversion Perlismswaited-onxcrb(main):001:0>puts [1,2]+3 5 irb >> puts [1,2]+3 TypeError: can't convert Fixnum into Array from (irb):1:in `+' from (irb):1Comments
-
6 comments Created 4 months ago by treedactionxhas-branchxImplement Exception Usage From Rubywaiting-onxThe grammar already has
rescue/ensureclauses, butmethod begin_enddoesn't actually do anything with them yet.There doesn't seem to be anything for
raisein the grammar.Comments
I've started working on this. "raise" kinda works, but I've discovered a bug that should probably be addressed.
Aaaaaand there's a bug with Parrot where we can't throw anything but parrot;Exception itself. Throwing subclasses causes an exception to be thrown. Yes, seriously.
Talked to Whiteknight about it. He says that allowing subclasses of Exception is a goal, but an indefinite one. It may be a while. I'll try to get as far as I can with this without needing subclasses.
I have a local branch where I've been working on this. I've got a new top-level Exception Handler that prints things more like Ruby, although some annotations are missing (notably 'file' for everything), so it looks kinda funny. Also have
raisea little more done and aliasedfailto itTene mentioned the idea of decoupling cardinal;Exception and packing it into a parrot;Exception as the payload. May be workable.
-
5 comments Created 4 months ago by treedactionxhas-branchxpirxDitch P6objectwaited-onxRework things to avoid P6object.
Comments
I've merged iss34 into my local iss41 branch. This is starting to get nasty. I think I'll also need to do an object model here, too.
-
5 comments Created 4 months ago by treedactionxhas-branchxpirxReimplement Object Modelwaited-onxProbably need to subclass
p6object. (Amusingly, Rakudo already has; look there.)Comments
Need to match this diagram:
+------------------+ | | Object---->(Object) | ^ ^ ^ ^ | | | | | | | | +-----+ +---------+ | | | | | | | +-----------+ | | | | | | | +------+ | Module--->(Module) | | | ^ ^ | OtherClass-->(OtherClass) | | | | | | Class---->(Class) | ^ | | | +----------------+(Classes) are metaclasses.
-
1 comment Created 4 months ago by treedwaited-onxChange perlistic .WHAT style to Ruby .class stylewaiting-onx -
As exhibited in alias.t, alias methods don't work, causing a parsefail.
Comments
The code in alias.t is wrong it should be:
alias :increment :inc
That wouldn't parse either, because we don't have symbols yet, but at least it is the code that should work in the endI expect to hit symbols after this object model thing, and maybe after exceptions.
Probably contemporaneously with the MRO.
-
I'm not sure what it's supposed to do, but freeze.t shows a failure in the .freeze method.
Comments
-
0 comments Created 5 months ago by treedneeds-infoxHash has trouble with default valuestest-failxExhibited in hash/hast.t, Hash has some (crashy) issues with default values. I tried to trace it, but then I go into an infinite loop of double free errors.
Comments
-
0 comments Created 5 months ago by treedneeds-infoxImplement increment() for CardinalStringtest-failxThere's some stubbed out test code waiting on this in range/each.t
Comments
-
Not sure what it does, but time.t says it's broken.
Comments
-
time.t has this as a todo, although it doesn't go into what's broken with them.
Comments
-
The parser is horrifically slow, and this needs to be fixed.
Comments
-
Exhibited in test:file:file, File class methods don't work. Something about File not being found.
Comments
-
0 comments Created 5 months ago by treedneeds-infoxopen() doesn't seem to existtest-failxAs shown in test:kernel:open, open() doesn't seem to exist.
Comments
-
1 comment Created 4 months ago by joerineeds-infoxpirx0, the empty array and the empty string evaluate to falsetest-failx -
0 comments Created 4 months ago by treedneeds-infoxNamespace problems when precompilingtest-failxI stumbled across a problem after enabling precompilation and changing the test suite to use it for a speed bonus.
t/02-functions.t has a function that it calls first. When running as precompiled, having this function in the global namespace causes loading cardinal.pbc to fail. Tene suggests that it's because of the "first" methods on Array and Range.
Comments
-
4 comments Created 5 months ago by treedneeds-infoxparserxFix parsing of range literalstest-failxParens around ranges don't seem to work, and range/new.t indicates there may be other issues.
(See also range.t)
Comments
Range parsing is implemented as
infix:..andinfix:...; the not working with parens is a general issue with any optable stuff. Unsure how to handle this, as optable stuff is still very much magic to me.The comment in range/new.t was outdated other than references the paren issue.
Well, the paren fix is in, but there's still something wacky going on:
crb(main):001:0>puts (1..3).class [1, 2, 3] Null PMC access in find_method()I think that is parsed as (puts (1..3)).class instead of puts((1..3).class), which would also mean that the object returned by puts is not the nil from NilClass but an Undef or something like that
Unfortunately both of the expressions I gave fail to parse, so I can't really test that, but the output from target=parse seems to confirm my suspicions
-
Parrot's default MRO is C3, which applies to both Perl6 and Python (>2.3). Unfortunately, it does not apply to Ruby. So, we have to do it ourselves. Apparently Rakudo still does their own (?), so we can look there for inspiration.
Comments
-
0 comments Created 4 months ago by treedneeds-infoxEmbedded Expressions in Strings Not Parsing CorrectlyparserxI'm not sure how to fix it, because the relevant code is in quote_expression.pir, but embedded expressions (#{foo}) in strings are parsing weirdly.
Basically, the end doesn't actually become the end. If you have "foo #{'bar'} baz", it'll render as "foo barbaz". Even weirder stuff happens if you have another embedded expression after the first.
Comments
-
6 comments Created 4 months ago by treedhas-branchxpirxwaited-onxRename CardinalFoo to Foowaiting-onxShould be able to do this now.
Comments
This is done, but is blocking on a Parrot bug: https://trac.parrot.org/parrot/ticket/909
Another option is to do our own metaclass which could maybe tie in with #33.
-
2 comments Created 4 months ago by dtmpirxcorrect exception to throw for array index out of boundswaiting-onxWhats the correct exception to throw for an index out of bounds. Ruby/irb shows it as IndexError:
>> [1].insert(-10, 'boo') IndexError: index -9 out of array from (irb):6:in `insert' from (irb):6Comments
Should be able to throw an IndexError. I declared the whole hierarchy of Ruby exceptions, except Errno::*.
(Catching is slightly more difficult if you want it to be fast.)
-
2 comments Created 5 months ago by treedtest-failxIntegers equal to String of that Integerwaiting-onxAs shown in integer/integer.t, 300 == '300' and the like are evaluating to true.
Maybe integers are being autoconverted to_s before the comparison?
Could perhaps be solved by implementing an infix:== for CardinalInteger, if it's not already.
Comments
This is caused by the leftover Perlisms from when a lot of the originating code was taken from Rakudo. Namely: implicit conversion. Ruby doesn't do it by default. So in order to fix this, here are the steps that'll be taken:
Go through and add the implicit (to_str, to_int, etc.) and explicit (to_s, to_i, etc.) methods for all the stdlib classes that declare them. Then add stuff into Object so that anything that doesn't have an explicit implicit conversion method won't convert implicitly. This'll probably break a lot of things, but it'll at least let us know where things depend on implicit conversion. Then we go through and fix those.
The second step is to implement == as Ruby does, checking for the implicit methods before attempting equality. This should fix these failures.
-
2 comments Created 5 months ago by treedtest-failxSlurpy argument isn't coming through as an Array?waiting-onxAs exhibited in 11-slurpy.t, slurpy arguments don't seem to be coming through as an Array. It's possible that this is just a case of CardinalArray vs. Array.
Comments
-
8 comments Created 5 months ago by treedtest-failxobj.class returning unexpected valueswaiting-onx.class on Proc is not Proc. It's probably CardinalProc, but I haven't looked. Unsure how to go about this one. (Shows up in proc.t.)
Comments
Okay. I've done some research now. Took me some time because I had to fix a bug first to even try this. .class on a Proc is "Proc()", but only if you declare it as a proc. A bare proc (literal?) is a Sub, which has no .class.
A Range is coming across as CardinalRange, though. Unsure whether the better way to fix this is to simply rename the class, or get .class to lie.
1) hll_map Sub
2) Now that Cardinal is in its own .HLL, you should be able to get rid of all the crap CardinalFoo names, because no more namespace conflicts with core parrot types.The last issue is that it'll be appending () to the names, which I think is solveable by adding to_s to the Metaclass that other metaclasses inherit from. Then having Object.class use that.
Okay, wow. hll_mapping Sub resulted in cardinal throwing sigbus for any attempt at execution. Did I do something particularly weird here?
diff --git a/src/classes/Proc.pir b/src/classes/Proc.pir index 0073b1f..5034529 100644 --- a/src/classes/Proc.pir +++ b/src/classes/Proc.pir @@ -20,9 +20,14 @@ Perform initializations and create the Proc class .namespace ['Proc'] .sub 'onload' :anon :init :load - .local pmc cardinalmeta + .local pmc cardinalmeta, core_type, hll_type, interp $P0 = get_hll_global ['CardinalObject'], '!CARDINALMETA' cardinalmeta = $P0.'new_class'('Proc', 'parent'=>'CardinalObject', 'attr'=>'!block') + + core_type = get_class 'Sub' + hll_type = get_class 'Proc' + interp = getinterp + interp.'hll_map'(core_type, hll_type) .end .sub 'get_bool' :vtableCould be that Proc doesn't actually subclass Sub, but it still shouldn't be crashing.
Issue #27 concerns a rewrite of Proc which should help with this.
-
1 comment Created 5 months ago by treedhll-interopxparserxMake [] and []= operators use vtable keyed lookup for everythingwaiting-onxExcerpted from an IM with Stephen Weeks:
also, one big item that needs to be fixed is array indexes. They're not inter-hll safe right now.
It just calls the '[]' and '[]=' methods on the object.The better solution is to just do normal keyed lookup and have any methods named '[]' or '[]=' be detected and set them as :vtable('get_pmc_keyed') or whatever
Comments
-
1 comment Created 5 months ago by treedtest-failxMultiple assignment is brokenwaiting-onx -
0 comments Created 3 months ago by treedneeds-infoxneeds-infoxparserxpirxImplement Symbolswaited-onxAs the title says, we need to implement symbols. This'll happen in both parser and PIR. Probably end up storing them in a Hash in _cardinal OSLT.
Comments













To quote #9:
This is caused by the leftover Perlisms from when a lot of the originating code was taken from Rakudo. Namely: implicit conversion. Ruby doesn't do it by default. So in order to fix this, here are the steps that'll be taken:
Go through and add the implicit (to_str, to_int, etc.) and explicit (to_s, to_i, etc.) methods for all the stdlib classes that declare them. Then add stuff into Object so that anything that doesn't have an explicit implicit conversion method won't convert implicitly. This'll probably break a lot of things, but it'll at least let us know where things depend on implicit conversion. Then we go through and fix those.
#9 is now waitiing on this.
Been working on this today. Got a bunch of it done.
One problem I encountered which I don't quite understand is that removing the
get_stringvtable fromNilClasscauses cardinal.pir to not be able to instantiate aCardinalArray, because it can't find it. Might just have to live with this in until someone can figure out why that happens.Another problem is that
parrot;Integerdeclares ato_intmethod, whereascardinal;Integerabsolutely cannot have ato_int.Not sure what to do about this. One might consider replacing
to_intwith a method that just throws an Exception, but that's still a little screwy in the case of "Hey, object, do you have a to_int method?" "Yes, yes, I do." "Sweet, I can treat you like an int." Then blammo.So, yeah, this is a problem.
Parrot has opcodes for adding methods, but none for removing them.
My work so far is on the iss32 branch.