Skip to content

Instantly share code, notes, and snippets.

View arnsholt's full-sized avatar

Arne Skjærholt arnsholt

View GitHub Profile
@arnsholt
arnsholt / mixinfix1.patch
Created October 20, 2013 10:51
First attempt at fixing mixin bug
diff --git a/src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/P6Opaque.java b/src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/P6Opaque.java
index dc9fd60..9cb26cb 100644
--- a/src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/P6Opaque.java
+++ b/src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/P6Opaque.java
@@ -644,7 +644,7 @@ public class P6Opaque extends REPR {
// Ensure target type is also P6opaque-based.
if (!(newType.st.REPR instanceof P6Opaque))
throw ExceptionHandling.dieInternal(tc, "P6opaque can only rebless to another P6opaque-based type");
-
+
@arnsholt
arnsholt / test.pl
Last active December 25, 2015 23:49
Rakudo/JVM rolw mixin shenanigans
my role Foo {
has $!setup;
method postcircumfix:<( )>($args) {
#say self.?bar // 'not what we want';
if nqp::can(self, 'bar') { say self.bar }
else { say 'no what we want' }
}
}
@arnsholt
arnsholt / nativecall.t
Created September 3, 2013 19:24
NativeCall weirdness
plan(1);
my $arg_hash;
my $return_hash;
class Call is repr('NativeCall') { }
class CPointer is repr('CPointer') { }
my $printf := nqp::create(Call);
$arg_hash := nqp::hash();
From cdeabc2ba7f357b886184c2a73b8beb48e1720c9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Arne=20Skj=C3=A6rholt?= <arnsholt@gmail.com>
Date: Thu, 29 Aug 2013 17:51:29 +0200
Subject: [PATCH] Temporary commit for jnthn.
---
lib/NativeCall.pm6 | 7 +++++--
t/02-simple-args.t | 14 +++++++-------
2 files changed, 12 insertions(+), 9 deletions(-)
sub foo() { say "in sub"; }
role Test {
method postcircumfix:<( )>($args) {
say "overridden";
}
}
role Other {
method bar() { say "foo"; }
# Expects to be live in .../zavolaj/
use lib '.';
use t::CompileTestLib;
use NativeCall;
compile_test_lib('08-callbacks');
sub TakeACallback(&cb()) is native('./08-callbacks') { * }
sub simple_callback() {
/*
* Grammar production: [Cat, [Cat]] or [Cat, Term]
* DI: [Cat, Consumed, Left]
*/
%disr(Rest, Stack, Grammar) :- fail.
disr(Input, Grammar) :- disr(Input, [], Grammar).
% SHIFT: Word of category Cat next word in input: ``push Cat -> Word \dot'' onto stack.
disr([W|Rest], Stack, Grammar) :- grammar_terminal(Grammar, W, Cat), DI = [Cat, [W], []], disr(Rest, [DI|Stack], Grammar).
% SEED: Given a completed DI of category CatB on top of the stack and a production CatA -> CatB ..., replace the top item with a new DI [CatA, [CatB], ...]
use lib '.';
use t::CompileTestLib;
use NativeCall;
compile_test_lib('08-callbacks');
sub TakeACallback(&cb()) is native('./08-callbacks') { * }
sub simple_callback() {
say 'simple callback';
@arnsholt
arnsholt / VTABLE_does.c
Created March 23, 2013 13:40
Tweaked VTABLE_does
VTABLE INTVAL does(STRING *what) {
PMC *decont = decontainerize(interp, SELF);
if (Parrot_str_equal(interp, what, CONST_STRING(interp, "invokable"))) {
return 1;
}
else if (Parrot_str_equal(interp, what, CONST_STRING(interp, "array"))) {
return Parrot_str_equal(interp, REPR(decont)->name, CONST_STRING(interp, "VMArray"));
}
else if (Parrot_str_equal(interp, what, CONST_STRING(interp, "hash"))) {
QAST::Operations.add_core_op('list', :inlinable(1), -> $qastcomp, $op {
# Create register for the resulting list and make an empty one.
my $arr := $qastcomp.as_post(QAST::Op.new(:op('create'), QAST::Op.new(:op('hlllist'))));
# Push all the things.
if +$op.list {
my $list_reg := $*REGALLOC.fresh_p();
my $ops := PIRT::Ops.new(:result($list_reg));
$ops.push_pirop('set', $list_reg, $arr);