Skip to content

Instantly share code, notes, and snippets.

View FROGGS's full-sized avatar

Tobias Leich FROGGS

  • Germany (near Berlin)
View GitHub Profile
@FROGGS
FROGGS / p6-Net-LDAP.pm6
Created March 13, 2018 16:08
p6-Net-LDAP
use v6;
unit class Net::LDAP;
use NativeCall;
enum LDAP_OPT_X_TLS <NEVER HARD DEMAND ALLOW TRY>;
constant LDAP_SUCCESS = 0;
constant LDAP_VERSION3 = 3;
constant LDAP_OPT_PROTOCOL_VERSION = 0x0011;
constant LDAP_OPT_X_TLS_REQUIRE_CERT = 0x6006;
@FROGGS
FROGGS / Routes.pm6
Created March 10, 2018 10:41
adding HTTP methods to cro
use Cro::HTTP::Router;
sub r(Str $method, &handler --> Nil) { $*CRO-ROUTE-SET.add-handler($method, &handler) }
sub routes() is export {
route {
get -> {
content 'text/html', '<h1> hello </h1>';
}
r 'LINK', -> {
diff --git a/src/core/CompUnit/PrecompilationRepository.pm b/src/core/CompUnit/PrecompilationRepository.pm
index 2976e02..16a0eb2 100644
--- a/src/core/CompUnit/PrecompilationRepository.pm
+++ b/src/core/CompUnit/PrecompilationRepository.pm
@@ -244,7 +246,7 @@ class CompUnit::PrecompilationRepository::Default does CompUnit::PrecompilationR
$RMD("id: $dependency.id(), src: $dependency.src(), spec: $dependency.spec()") if $RMD;
my $path = self.store.path($compiler-id, $dependency.id);
if $path.e {
- spurt($path ~ '.rev-deps', "$dependency.id()\n", :append);
+ spurt($path ~ '.rev-deps', "$id\n", :append);
v6;
grammar BUU {
token TOP { <abc>+ };
token abc { ('a') <bc>* };
token bc { [ ('b') <c>* ]+ }
token c { 'c' };
};
class BuuAbc {
@FROGGS
FROGGS / unposal.md
Last active December 22, 2015 11:19
nqp::(un)pack proposal
my @items := nqp::unpack( 'U2 (xxxC)[W]', $binary_string );

I, FROGGS, solemnly propose the implementation of pack() and unpack in nqp.

For one, these are useful for Perl 5 and Perl 6, and the other reason is that they should be pretty fast. If a backend then can even provide a faster implementation (e.g. in C), then it would be easy to #ifdef it in.

The signatures I propose are:

test script

sub ed_green_thread() { Q:PIR {
    .local pmc interp, task, block, block_name
    .local string name
    interp     = getinterp
    task       = interp.'current_task'()
    block_name = pop task
    name       = block_name
@FROGGS
FROGGS / add-i-mt.t
Created July 31, 2013 23:18
= Call it as: nqp add-i-mt. = It computes the sum of the two input RPMCAs (line 80/81), and returns the array containing the sums.
use QAST;
plan(1);
sub is_pirt_result($producer, $expected, $desc) {
my $pirt := $producer();
my $pir := $pirt.pir();
my $pbc := nqp::getcomp('nqp').compile($pir, :from('pir'));
$pbc := $pbc();
if nqp::islist($pbc) {
# generate code that runs the block only once
make QAST::Stmts.new(
QAST::Op.new(
:op('if'),
QAST::Op.new( :op('p6stateinit') ),
QAST::Op.new(
:op('p6store'),
QAST::Var.new( :name($sym), :scope('lexical') ),
QAST::Op.new( :op('call'), $<blorst>.ast )
),
@FROGGS
FROGGS / codepoints.diff
Created July 9, 2013 12:48
Super Slow Support(tm) for 32-bit unicode codepoints in nqp::chars() and nqp::substr(). This increases rakudo's parse time from 57s to nearly ten minutes.
diff --git a/src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java b/src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java
index c193007..e1d3418 100644
--- a/src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java
+++ b/src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java
@@ -2648,7 +2648,7 @@ public final class Ops {
/* String operations. */
public static long chars(String val) {
- return val.length();
+ return val.codePointCount(0, val.length());
@FROGGS
FROGGS / RT117415.diff
Last active December 17, 2015 10:49
RT117415 - patch for "Use of regex characters as substitution delimiter fails"
diff --git a/src/QRegex/P5Regex/Grammar.nqp b/src/QRegex/P5Regex/Grammar.nqp
index e29167b..5be2be3 100644
--- a/src/QRegex/P5Regex/Grammar.nqp
+++ b/src/QRegex/P5Regex/Grammar.nqp
@@ -69,7 +69,7 @@ grammar QRegex::P5Regex::Grammar is HLL::Grammar {
<![|)]>
<!rxstopper>
<atom>
- [ <.ws> <quantifier=p5quantifier> ]**0..1
+ [ <.ws> <!before <rxstopper> > <quantifier=p5quantifier> ]**0..1