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 {

What I wanna use serialization for

The most pressing use case is loading modules databases Really Fast™. There we we need to be able to deserialize a .moarvm file, which most likely is a structure of hashes and arrays, besides strings representing identifiers and file names. (I would like to serialize CompUnits and IO::Paths directly, but that would not survive a rakudo rebuild. A json backup on the otherhand could serve as a fallback, but that also means we are limited to what json can. Not much.)

diff --git a/src/Perl6/Metamodel/BOOTSTRAP.nqp b/src/Perl6/Metamodel/BOOTSTRAP.nqp
index 3c4380d..9156616 100644
--- a/src/Perl6/Metamodel/BOOTSTRAP.nqp
+++ b/src/Perl6/Metamodel/BOOTSTRAP.nqp
@@ -1103,9 +1103,13 @@ BEGIN {
Attribute.HOW.add_method(Attribute, 'new',
nqp::getstaticcode(sub ($self, :$name!, :$type!, :$package!, :$inlined = 0, :$has_accessor,
:$positional_delegate = 0, :$associative_delegate = 0, *%other) {
+ nqp::say('BOOTSTRAP:1106 ' ~ $self.HOW.name($self) ~ ' ' ~ $name);
my $attr := nqp::create($self);
@FROGGS
FROGGS / Ser.pm
Created September 10, 2015 19:30
unit module Ser;
use nqp;
sub serialize($obj is copy) is export {
my Mu $sh := nqp::list_s();
my $name = 'Ser_' ~ nqp::time_n();
my Mu $sc := nqp::createsc(nqp::unbox_s($name));
nqp::setobjsc($obj, $sc);
nqp::scsetobj($sc, 0, $obj);
my $serialized = nqp::serialize($sc, $sh);
my %h = 1 => [ [<what what>], [<how how>] ], 2 => [ [<this this>] ];
my $i = 0;
%h.values».map({"{++$i} " Z~ @($^a)}).say;
@FROGGS
FROGGS / perl6-gdb-m.sh
Created April 8, 2015 07:32
sample output of perl6-gdb-m
$ perl6-gdb-m -e 'say uniname(nqp::null_s)'
================================================================================================
This is Rakudo Perl 6 running in the GNU debugger, which often allwos to generate useful back-
traces to debug or report issues in Rakudo, the MoarVM backend or the currently running code.
The currently used MoarVM backend is not compiled with debugging symbols, you might want to
reconfigure and reinstall MoarVM with --debug enabled.
This Rakudo version is 2015.3.186.g.260.e.3.cd built on MoarVM version 2015.3.64.g.79.b.6087,
running on ubuntu (14.4.2.LTS.Trusty.Tahr) / linux (81.Ubuntu.SMP.Tue.Mar.24.19.29.48.UTC.2015)
Acme::Meow * True True moar
JSON::Tiny * True True moar
Testing * True True moar
mandelbrot * moar
IO::Prompter * True False moar
Math::Polynomial * True True moar
Math::Vector * True True moar
Math::ContinuedFractions * True True moar
Math::ChebyshevPolynomial * True True moar
Math::OddFunctions * True True moar