Skip to content

Instantly share code, notes, and snippets.

View bacek's full-sized avatar

Vasily Chekalkin bacek

View GitHub Profile
~/src/nqp-rx (multis)$ cat t.nqp
our multi sub foo(Float $node) {
say("Float");
}
our multi sub foo($node) {
say("Default");
}
foo(42.5 - 0.5);
diff --git a/src/NQP/Actions.pm b/src/NQP/Actions.pm
index 6a345c0..b404c48 100644
--- a/src/NQP/Actions.pm
+++ b/src/NQP/Actions.pm
@@ -380,7 +380,9 @@ method scope_declarator:sym<our>($/) { make $<scoped>.ast; }
method scope_declarator:sym<has>($/) { make $<scoped>.ast; }
method scoped($/) {
- make $<declarator>.ast;
+ make $<declarator>
# GC don't care how this work. Pools/Arenas/Blocks/whatever.
class Allocator {
has $object_size;
method allocate() { ... };
method free(pointer $obj) { ... };
};
# Current PObj.
class PObj {
diff --git a/src/NQP/Actions.pm b/src/NQP/Actions.pm
index a37f9c1..689273e 100644
--- a/src/NQP/Actions.pm
+++ b/src/NQP/Actions.pm
@@ -616,7 +616,7 @@ method term:sym<self>($/) {
method term:sym<identifier>($/) {
my $past := $<args>.ast;
- $past.name(~$<identifier>);
+ $past.name(~$<deflongname>);
@bacek
bacek / gist:961919
Created May 9, 2011 02:02
Alternative patch for gms
diff --git a/src/gc/gc_gms.c b/src/gc/gc_gms.c
index 88b9956..48d2e28 100644
--- a/src/gc/gc_gms.c
+++ b/src/gc/gc_gms.c
@@ -1511,6 +1511,8 @@ establish if *ptr is.owned
*/
+#define INVALID_PTR_MASK (PTR_SIZE - 1)
+
@bacek
bacek / gist:969536
Created May 12, 2011 21:49
PCC "hell"
~/src/parrot (master)$ cat t.pir
.sub "main" :main
$P0 = new ['ResizablePMCArray']
"foo"($P0 :flat)
push $P0, "bang"
"foo"($P0 :flat)
push $P0, "bang"
"foo"($P0 :flat)
"foo"($P0 :flat, "quux")
.return ()
@bacek
bacek / gist:1359348
Created November 11, 2011 21:31
Уй-ю-юй!

From: Arkady Klimovsky

To: bacek@bacek.com

Антипод (Вы сами так себя назвали, правда-правда :) ), добрый день!

Меня зовут Аркадий Климовский, talent-manager компании Яндекс.

@bacek
bacek / gist:1720728
Created February 2, 2012 01:14
Parrot is actually fast...
~/src/parrot (master) $ time perl examples/benchmarks/primes2.pl
N primes calculated to 5000 is 670
last is: 4999
real 0m1.131s
user 0m1.092s
sys 0m0.008s
~/src/parrot (master) $ time ./parrot examples/benchmarks/primes2.pir
N primes calculated to 5000 is 670
last is: 4999
In master:
....
019f compreg P2, "PASM" P2=PMCNULL
01a2 set_args PC5 (2), P2, S0 PC5=FixedIntegerArray=PMC(0x91c3aec) P2=IMCCompiler=PMC(0x91c38d0) S0="t/pmc/sub_1.pasm"
01a6 tailcallmethod P2, "compile_file" P2=IMCCompiler=PMC(0x91c38d0)
010c get_results PC2 (1), P0 PC2=FixedIntegerArray=PMC(0x91c39fc) P0=PMCNULL
010f if_null S2, 14 S2=""
011d set_args PC3 (2), P0, "init" PC3=FixedIntegerArray=PMC(0x91c3a4c) P0=PackfileView=PMC(0x9246a1c)
0121 callmethodcc P0, "subs_by_tag" P0=PackfileView=PMC(0x9246a1c)
0124 get_results PC2 (1), P2 PC2=FixedIntegerArray=PMC(0x91c39fc) P2=Integer=PMC(0x9215c94: 1)
@bacek
bacek / gist:1873726
Created February 21, 2012 04:42
Rakudo's patch for cont_reuse Parrot's branch.
diff --git a/src/binder/multidispatch.c b/src/binder/multidispatch.c
index b1be465..4aa085e 100644
--- a/src/binder/multidispatch.c
+++ b/src/binder/multidispatch.c
@@ -545,7 +545,6 @@ static PMC* find_best_candidate(PARROT_INTERP, Rakudo_md_candidate_info **candid
INTVAL i;
for (i = 0; i < possibles_count; i++) {
- interp->current_cont = (PMC *)NEED_CONTINUATION;
Parrot_pcc_set_signature(interp, CURRENT_CONTEXT(interp), NULL);