Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Reimplement compilation of subsets

  • Loading branch information...
commit 52fdc3b020ed57ae0afacd8a3bd82fa567fb0c12 1 parent 9f04acf
@sorear authored
Showing with 45 additions and 0 deletions.
  1. +14 −0 lib/CodeGen.cs
  2. +31 −0 src/niecza
View
14 lib/CodeGen.cs
@@ -4118,8 +4118,22 @@ public class DowncallReceiver : CallReceiver {
nst.mo.rtype = type;
nst.mo.isPackage = (type == "package");
nst.mo.isRole = (type == "role" || type == "prole");
+ nst.mo.isSubset = (type == "subset");
return new Handle(nst);
+ } else if (cmd == "type_set_basetype") {
+ STable subset = (STable)Handle.Unbox(args[1]);
+ STable basety = (STable)Handle.Unbox(args[2]);
+
+ subset.mo.FillSubset(basety);
+ subset.initObject = basety.initObject;
+ subset.initVar = basety.initVar;
+ return null;
+ } else if (cmd == "type_set_where") {
+ STable subset = (STable)Handle.Unbox(args[1]);
+ SubInfo where = (SubInfo)Handle.Unbox(args[2]);
+ subset.mo.subsetWhereThunk = where.protosub;
+ return null;
} else if (cmd == "create_sub") {
RuntimeUnit ru = (RuntimeUnit)Handle.Unbox(args[1]);
string name = (string)args[2];
View
31 src/niecza
@@ -21,6 +21,37 @@ use Sig;
use STD;
augment class NieczaActions {
+method type_declarator:subset ($/) {
+ my ($basetype) = self.process_name($*OFTYPE<longname>);
+ $basetype //= $*CURLEX<!sub>.compile_get_pkg('CORE', 'Any');
+ my @exports;
+
+ for map *.ast, @$<trait> -> $t {
+ if $t<export> {
+ push @exports, @( $t<export> );
+ } elsif $t<of> {
+ $basetype = $t<of>;
+ } else {
+ $/.CURSOR.sorry("Unsupported subset trait $t.keys()");
+ }
+ }
+
+ my $body = self.thunk_sub($<EXPR> ?? $<EXPR>.ast !! mklex($/, 'True'));
+
+ my ($lexvar, $obj) = "Any";
+
+ $/.CURSOR.trymop({
+ ($lexvar, $obj) = self.do_new_package($/, scope => $*SCOPE,
+ name => $<longname>, class => 'subset', :@exports);
+
+ $*CURLEX<!sub>.create_static_pad;
+
+ $obj.set_basetype($basetype);
+ $obj.set_where($body);
+ });
+
+ make mklex($/, $lexvar);
+}
}
CgOp._register_ops: < who sc_root sc_indir temporize _addmethod _invalidate
Please sign in to comment.
Something went wrong with that request. Please try again.