Skip to content

Commit

Permalink
Stub in Rakudo container support.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed May 10, 2013
1 parent aea68d2 commit a70ab6e
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/main.nqp
Expand Up @@ -4,16 +4,16 @@ use Perl6::Compiler;

#?if parrot
sub MAIN(@ARGS) {
# Initialize dynops and PMCs.
pir::rakudo_dynop_setup__v();

# Bump up Parrot's recursion limit
pir::getinterp__P().recursion_limit(100000);
#?endif
#?if !parrot
sub MAIN(*@ARGS) {
#?endif

# Initialize Rakudo runtime support.
nqp::p6init();

# Create and configure compiler object.
my $comp := Perl6::Compiler.new();
$comp.language('perl6');
Expand Down
1 change: 1 addition & 0 deletions src/vm/jvm/Perl6/Ops.nqp
Expand Up @@ -88,6 +88,7 @@ $ops.add_hll_op('perl6', 'p6bool', $p6bool);
# Make some of them also available from NQP land, since we use them in the
# metamodel and bootstrap.
$ops.add_hll_op('nqp', 'p6bool', $p6bool);
$ops.map_classlib_hll_op('nqp', 'p6init', $TYPE_P6OPS, 'p6init', [], $RT_OBJ, :tc);
$ops.map_classlib_hll_op('nqp', 'p6settypes', $TYPE_P6OPS, 'p6settypes', [$RT_OBJ], $RT_OBJ, :tc);
$ops.map_classlib_hll_op('nqp', 'p6var', $TYPE_P6OPS, 'p6var', [$RT_OBJ], $RT_OBJ, :tc);
$ops.map_classlib_hll_op('nqp', 'p6parcel', $TYPE_P6OPS, 'p6parcel', [$RT_OBJ, $RT_OBJ], $RT_OBJ, :tc);
Expand Down
9 changes: 9 additions & 0 deletions src/vm/jvm/runtime/org/perl6/rakudo/Ops.java
Expand Up @@ -9,6 +9,15 @@
public final class Ops {
private static SixModelObject False;
private static SixModelObject True;
private static boolean initialized = false;

public static SixModelObject p6init(ThreadContext tc) {
if (!initialized) {
tc.gc.contConfigs.put("rakudo_scalar", new RakudoContainerConfigurer());
initialized = true;
}
return null;
}

public static SixModelObject p6settypes(SixModelObject conf, ThreadContext tc) {
False = conf.at_key_boxed(tc, "False");
Expand Down
16 changes: 16 additions & 0 deletions src/vm/jvm/runtime/org/perl6/rakudo/RakudoContainerConfigurer.java
@@ -0,0 +1,16 @@
package org.perl6.rakudo;

import org.perl6.nqp.runtime.ThreadContext;
import org.perl6.nqp.sixmodel.*;

public class RakudoContainerConfigurer extends ContainerConfigurer {
/* Sets this container spec in place for the specified STable. */
public void setContainerSpec(ThreadContext tc, STable st) {
st.ContainerSpec = new RakudoContainerSpec();
}

/* Configures the container spec with the specified info. */
public void configureContainerSpec(ThreadContext tc, STable st, SixModelObject config) {
/* Nothing to configure here. */
}
}
38 changes: 38 additions & 0 deletions src/vm/jvm/runtime/org/perl6/rakudo/RakudoContainerSpec.java
@@ -0,0 +1,38 @@
package org.perl6.rakudo;

import org.perl6.nqp.runtime.ThreadContext;
import org.perl6.nqp.sixmodel.*;

public class RakudoContainerSpec extends ContainerSpec {
/* Fetches a value out of a container. Used for decontainerization. */
public SixModelObject fetch(ThreadContext tc, SixModelObject cont) {
throw new RuntimeException("Rakudo scalar fetch NYI");
}

/* Stores a value in a container. Used for assignment. */
public void store(ThreadContext tc, SixModelObject cont, SixModelObject obj) {
throw new RuntimeException("Rakudo scalar store NYI");
}

/* Stores a value in a container, without any checking of it (this
* assumes an optimizer or something else already did it). Used for
* assignment. */
public void storeUnchecked(ThreadContext tc, SixModelObject cont, SixModelObject obj) {
throw new RuntimeException("Rakudo scalar store NYI");
}

/* Name of this container specification. */
public String name() {
return "rakudo_scalar";
}

/* Serializes the container data, if any. */
public void serialize(ThreadContext tc, STable st, SerializationWriter writer) {
/* No data to serialize. */
}

/* Deserializes the container data, if any. */
public void deserialize(ThreadContext tc, STable st, SerializationReader reader) {
/* No data to deserialize. */
}
}
4 changes: 2 additions & 2 deletions tools/build/Makefile-JVM.in
Expand Up @@ -252,8 +252,8 @@ $(PERL6_M_CLASS): $(METAMODEL_SOURCES)

$(PERL6_B_CLASS): $(BOOTSTRAP_SOURCES) $(PERL6_M_CLASS)
$(PERL) $(GEN_CAT) $(BOOTSTRAP_SOURCES) > src/gen/BOOTSTRAP.nqp
$(NQP) --target=classfile --output=$(PERL6_B_CLASS) --encoding=utf8 \
src/gen/BOOTSTRAP.nqp
$(PERL) tools\build\nqp-jvm-rr.pl $(NQP) --target=classfile \
--output=$(PERL6_B_CLASS) --encoding=utf8 src/gen/BOOTSTRAP.nqp

$(SETTING_CLASS): $(PERL6_CLASS) $(PERL6_B_CLASS) $(CORE_SOURCES)
$(PERL) $(GEN_CAT) $(CORE_SOURCES) > src/gen/CORE.setting
Expand Down
31 changes: 31 additions & 0 deletions tools/build/nqp-jvm-rr.pl
@@ -0,0 +1,31 @@
#!/usr/bin/perl
# Copyright (C) 2013, The Perl Foundation.

use strict;
use warnings;
use 5.008;

my ($existing) = shift @ARGV;

unless (-e $existing) {
$existing = "$existing.bat";
}
unless (-e $existing) {
die "Could not find " . $ARGV[0];
}

open my $fh, "<", $existing;
my $runner;
while (<$fh>) {
$runner = $_;
}
close $fh;

$runner =~ s/nqp-runtime\.jar\;/nqp-runtime.jar;rakudo-runtime.jar;/;
$runner =~ s/nqp-runtime\.jar\:/nqp-runtime.jar:rakudo-runtime.jar:/;

my $args = join ' ', @ARGV;
$runner =~ s/"\$\@"/$args/;
$runner =~ s/\%\*/$args/;

system $runner;

0 comments on commit a70ab6e

Please sign in to comment.