Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove no longer used "NAMOutput" and "Metamodel" modules

  • Loading branch information...
commit 51e9a2656ce90b7e37a4a2104516eced05219dc2 1 parent d83bf51
@sorear authored
View
12 Makefile
@@ -15,10 +15,9 @@ cskernel=Kernel.cs Builtins.cs Cursor.cs JSYNC.cs NieczaCLR.cs Utils.cs \
.PHONY: help
libunits=CORE JSYNC
-srcunits=CClass CgOp Op OpHelpers Sig RxOp STD NieczaGrammar Metamodel \
- OptRxSimple NAMOutput Operator NieczaActions NieczaFrontendSTD \
- NieczaPassSimplifier OptBeta NieczaPathSearch NieczaBackendDotnet \
- NieczaCompiler GetOptLong
+srcunits=CClass CgOp Op OpHelpers Sig RxOp STD NieczaGrammar OptRxSimple \
+ Operator NieczaActions NieczaFrontendSTD NieczaPassSimplifier \
+ OptBeta NieczaPathSearch NieczaBackendDotnet NieczaCompiler GetOptLong
all: run/Niecza.exe obj/Run.Kernel.dll obj/Run.CORE.dll
@git describe --tags > VERSION
@@ -117,9 +116,6 @@ help:
boot/obj/Run.NieczaBackendDotnet.ser: boot/obj/Run.CompilerBlob.dll
# grep -r '^use' src/*.pm6 | sed 's|src/\(.*\)\.pm6:use \(.*\);|boot/obj/Run.\1.ser: boot/obj/Run.\2.ser|' | grep -v MONKEY_TYPING
-boot/obj/Run.NAMOutput.ser: boot/obj/Run.JSYNC.ser
-boot/obj/Run.NAMOutput.ser: boot/obj/Run.Metamodel.ser
-boot/obj/Run.NAMOutput.ser: boot/obj/Run.Sig.ser
boot/obj/Run.NieczaActions.ser: boot/obj/Run.CgOp.ser
boot/obj/Run.NieczaActions.ser: boot/obj/Run.Op.ser
boot/obj/Run.NieczaActions.ser: boot/obj/Run.RxOp.ser
@@ -127,10 +123,8 @@ boot/obj/Run.NieczaActions.ser: boot/obj/Run.Sig.ser
boot/obj/Run.NieczaActions.ser: boot/obj/Run.CClass.ser
boot/obj/Run.NieczaActions.ser: boot/obj/Run.OpHelpers.ser
boot/obj/Run.NieczaActions.ser: boot/obj/Run.Operator.ser
-boot/obj/Run.NieczaBackendDotnet.ser: boot/obj/Run.NAMOutput.ser
boot/obj/Run.NieczaBackendDotnet.ser: boot/obj/Run.JSYNC.ser
boot/obj/Run.NieczaBackendDotnet.ser: boot/obj/Run.NieczaPassSimplifier.ser
-boot/obj/Run.NieczaBackendDotnet.ser: boot/obj/Run.Metamodel.ser
boot/obj/Run.NieczaCompiler.ser: boot/obj/Run.JSYNC.ser
boot/obj/Run.NieczaFrontendSTD.ser: boot/obj/Run.STD.ser
boot/obj/Run.NieczaFrontendSTD.ser: boot/obj/Run.NieczaGrammar.ser
View
808 src/Metamodel.pm6
@@ -1,808 +0,0 @@
-class Metamodel;
-
-method locstr($fo, $lo, $fn, $ln) {
- $fo := $fo // '???';
- $lo := $lo // '???';
- $fn := $fn // '???';
- $ln := $ln // '???';
-
- $fn eq $fo ?? " (see line $lo)" !! " (see $fo line $lo)";
-}
-
-# keep synchronized with the list of Kernel.PHASER_XXX values
-enum Phaser < INIT END UNIT_INIT KEEP UNDO LEAVE ENTER PRE POST CATCH CONTROL >;
-
-### NIECZA COMPILER METAMODEL
-# The metamodel exists to create a timeline inside the compiler. Previously,
-# the compiler operated as a pure tree transformer with no conception of how
-# PRE-INIT code would play out, thus precluding a lot of important
-# optimizations (based on precomputing immutable objects and optimizing
-# references to them, mostly).
-#
-# The metamodel has two main life stages. First, it is built; an incremental
-# process logically called BEGIN. Then, it is processed to perform closed-
-# world optimizations and generate code; this is (UNIT)CHECK.
-#
-# Kinds of objects which exist in the metamodel
-# - Static subs
-# - Packages (incl. classes, modules, grammars)
-# - Stashes (Foo::)
-#
-# This graph is a lot more random than the old trees were...
-
-# While manipulating metamodel bits during BEGIN, these contextuals are needed:
-# $*unit: current unit for new objects to attach to
-# %*units: maps unit names to unit objects
-# $*CURSUB<!sub>: the top non-transparent sub
-
-# Almost all longname and most identifier uses in Perl6 can be divided into
-# two groups.
-#
-# DECLARATIVE references, like class Foo::Bar::Baz {}, have an ending token,
-# and the remainder identifies a stash. Leading :: is ignored; if 0 tokens,
-# anon is forced, if 1, scope-sensitive special behavior, if 2+, our required.
-# Evaluating a declarative reference returns a (stash,name) pair.
-#
-# REFERENTIAL names, like $Foo::Bar::baz, are interpreted as referring to a
-# single variable; in many cases this is used to look for a type object.
-# Referential names default to MY:: if 1 token and 0 leading colon.
-# Evaluating a referential name returns or binds a variable.
-#
-# The one exception seems to be method calls, which take a referential name
-# plus an extra identifier to name the method.
-#
-# Trailing :: is forbidden when declaring and means .WHO when referencing.
-#
-# Functions for handling names in actions:
-#
-# package_var: Basic function for handling referential names, produces Op.
-#
-# immed_ref: Like package_var in a BEGIN context.
-#
-# decl_expr:
-#
-# immed_decl:
-
-# A stash is an object like Foo::. Stashes are named to allow them to be
-# sensibly named across merges.
-#
-# 'my' stashes are really 'our' stashes with gensym mergable names. Because
-# stashes have no identity beyond their contents and set of names, they don't
-# mind being copied around a lot.
-#
-# Stashes are not referencable objects in precompilation mode. You need to
-# keep the paths around, instead.
-#
-# This object holds the stash universe for a unit.
-# XXX forward decls are a little broken
-my $Package;
-class Namespace {
- # all maps stash names to stashes. Stashes are represented as simple
- # hashes here; the values are always arrays like [$xref, $file, $line].
- # $xref may be undefined to indicate a stash entry with no compile-time
- # value (our $x, my $x is export).
- #
- # Stash names are keyed like "GLOBAL::Foo::Bar" or "MAIN:15". Stashes
- # outside GLOBAL or PROCESS are anonymous packages, for my aliasing.
- has %.all;
-
- # Records *local* operations, so they may be stored and used to
- # set up the runtime stashes. Read-only log access is part of the
- # public API.
- #
- # Each entry is an arrayref of the form [$who, $name, $xref, $file, $line].
- has @.log;
-
- # This is set up post-creation by NieczaGrammar. It points to a package
- # with a who of ''.
- has $.root is rw;
-
- method _merge_item($i1, $i2, $who, $name) {
- # supress absent entries
- return $i2 unless defined $i1;
- return $i1 unless defined $i2;
-
- # suppress simple COMMONs if no absent
- return $i2 unless defined $i1[0];
- return $i1 unless defined $i2[0];
-
- # ooh, we now know we have no COMMONs
- my $item1 = $*unit.deref($i1[0]);
- my $item2 = $*unit.deref($i2[0]);
-
- return $i1 if $item1 === $item2;
-
- if $item1.^isa($Package) && $item2.^isa($Package) &&
- $item1.who eq $item2.who &&
- ($item1.WHAT === $Package || $item2.WHAT === $Package) {
- return $i1;
- }
-
- die "Two definitions found for symbol {$who}::$name\n\n" ~
- " first at $i1[1] line $i1[2]\n" ~
- " second at $i2[1] line $i2[2]";
- }
-
- method exists($who, $item) {
- return ?(%!all{$who}{$item});
- }
-
- method get($who, $item) {
- return %!all{$who}{$item}[0]
- }
-
- method bind($who, $name, $item, :$file, :$line, :$pos) { #OK not used
- my $slot := %!all{$who}{$name};
- $slot = self._merge_item($slot, [ $item,
- $file // '???', $line // '???' ], $who, $name);
- push @!log, [ $who, $name, $item, $file, $line ];
- }
-
- method get_pkg($from is copy, *@names, :$auto) {
- for @names {
- my $sl = self.get($from.who, $_);
- my $pkg;
- if $sl && $sl[0] && ($pkg = $*unit.deref($sl)).^isa($Package) {
- } elsif !$auto {
- die "Name component $_ not found in $from.who()";
- } else {
- $pkg = $Package.new(name => $_, who => $from.who ~ '::' ~ $_);
- self.bind($from.who, $_, $pkg.xref);
- }
- $from = $pkg;
- }
- $from;
- }
-
- # Add a new unit set to the from-set and checks mergability
- method add_from($from) {
- for %*units{$from}.ns.log -> $logent {
- # not using bind since we don't want this in the log
- my $slot := %!all{$logent[0]}{$logent[1]};
- $slot = self._merge_item($slot, [ $logent[2], $logent[3],
- $logent[4] ], $logent[0], $logent[1]);
- }
- }
-
- # List objects in a stash for use by the importer; returns pairs
- # of [name, xref]
- method list_stash($who) {
- my $h = %!all{$who};
- map -> $a { $a => $h{$a}[0] }, sort keys $h;
- }
-}
-
-class RefTarget {
- has $.xref;
- has $.name = 'ANON';
-
- # TODO BUILD
- method new(:$no_xref, *%_) {
- my $n = callwith(self, |%_);
- return $n if $no_xref;
- $n.xref = [ $*unit.name, +$*unit.xref, $n.name ];
- push $*unit.xref, $n;
- $n
- }
-
- method set_name($name) {
- $!xref[2] = $!name = $name;
- }
-}
-
-class Package is RefTarget {
- has $.closed;
- has $.who;
-
- method close() { $!closed = True; }
-}
-$Package = Package;
-
-class Module is Package {
-}
-
-class Method {
- # normally a Str, but may be Op for param roles
- has $.name = die "Method.name is required";
- # normal, private, meta, sub
- has $.kind = die "Method.kind is required"; # Str
- has $.multi = die "Method.multi is required"; # Str
- has $.var; # Str
- has $.body; # Xref
- has $.file;
- has $.line;
-}
-
-class Attribute {
- has $.name; # Str, required
- has $.sigil; # Str, required
- has $.public; # Bool
- has $.ivar; # Str
- has $.ibody; # Xref
- has $.typeconstraint; # Xref
- has $.file;
- has $.line;
-}
-
-class Class is Module {
- has $.attributes = [];
- has $.methods = [];
- has $.superclasses = [];
- has $.linearized_mro; # is rw
- has $!closing;
-
- method add_attribute($name, $sigil, $public, $ivar, $ibody,
- $typeconstraint, :$file, :$line, :$pos) { #OK not used
- if grep $name eq *.name, @($!attributes) -> $O {
- die "Two definitions of attribute $name" ~ Metamodel.locstr($O[0].file, $O[0].line, $file, $line);
- }
- push $.attributes, Metamodel::Attribute.new(:$name, :$sigil,
- :$public, :$ivar, :$ibody, :$typeconstraint, :$file, :$line);
- $.attributes.[*-1];
- }
-
- method add_method($multi, $kind, $name, $var, $body, :$file, :$line, :$pos) { #OK not used
- if $name ~~ Str && $multi eq 'only' &&
- grep { $name eq .name && $kind eq .kind }, @($!methods) -> $O {
- die "Two definitions of method $name" ~ Metamodel.locstr($O[0].file, $O[0].line, $file, $line);
- }
- push $.methods, Metamodel::Method.new(:$name, :$body, :$kind, :$multi,
- :$file, :$line);
- }
-
- method add_super($targ) {
- die "bad attempt to add null super" unless $targ;
- push $.superclasses, $targ;
- }
-
- sub c3clear($item, @lists) {
- for @lists -> $l {
- my $i = 1;
- while $i < $l {
- return False if $*unit.deref($l[$i]) === $*unit.deref($item);
- $i++;
- }
- }
-
- for @lists -> $l {
- $l.shift if $l && $*unit.deref($l[0]) === $*unit.deref($item);
- }
-
- True;
- }
-
- sub c3merge(@onto, @lists) {
- my $ix = 0;
- while $ix < @lists {
- #say "C3 MRO status ($ix):";
- #say "Onto: ", @onto.map({ $*unit.deref($_).name }).join(" <- ");
- #say $_.map({ $*unit.deref($_).name }).join(" <- ") for @lists;
- #say "---";
- my $l = @lists[$ix];
- if !$l || !c3clear((my $item = $l[0]), @lists) {
- $ix++;
- next;
- }
- push @onto, $item;
- $ix = 0;
- }
-
- my $bad = False;
- for @lists -> $l { $bad ||= $l }
- if $bad {
- my @hrl = @lists.grep(*.Bool).map(
- { $^l.map({ $*unit.deref($^i).name }).join(" <- ") });
- die "C3-MRO wedged! @hrl.join(" | ")";
- }
- }
-
- method close() {
- return if $.closed;
- if ($!closing) {
- die "Class hierarchy circularty detected at $.name\n";
- }
- $!closing = True;
-
- if (($.name ne 'Mu' || !$*unit.is_true_setting)
- && !$.superclasses) {
- self.add_super($*CURLEX<!sub>.compile_get_pkg(self._defsuper).xref);
- }
-
- my @merge;
- push @merge, [ $.xref ];
- for @$.superclasses -> $x {
- my $d = $*unit.deref($x);
- $d.close unless $d.linearized_mro;
- push @merge, [ @( $d.linearized_mro ) ];
- }
- push @merge, [ @( $.superclasses ) ];
- my @mro;
- c3merge(@mro, @merge);
- $.linearized_mro = @mro;
- nextsame;
- }
-
- method _defsuper() { 'CORE', 'Any' }
-}
-
-# roles come in two types; Role objects are used for simple roles, while roles
-# with parameters get ParametricRole. Instantiations of parametric roles
-# would get ConcreteRole, but that won't be implemented in Niecza A since it
-# requires evaluating role parameters, unless we restrict it to typenames or
-# something.
-class Role is Module {
- has $.attributes = [];
- has $.methods = [];
- has $.superclasses = [];
-
- method add_attribute($name, $sigil, $public, $ivar, $ibody, $typeconstraint, :$file, :$line, :$pos) { #OK not used
- if grep $name eq *.name, @($!attributes) -> $O {
- die "Two definitions of attribute $name" ~ Metamodel.locstr($O[0].file, $O[0].line, $file, $line);
- }
- push $.attributes, Metamodel::Attribute.new(:$name, :$sigil,
- :$public, :$ivar, :$ibody, :$typeconstraint, :$file, :$line);
- $.attributes.[*-1];
- }
-
- method add_method($multi, $kind, $name, $var, $body, :$file, :$line, :$pos) { #OK not used
- if $name ~~ Str && $multi eq 'only' &&
- grep { $name eq .name && $kind eq .kind }, @($!methods) -> $O {
- die "Two definitions of method $name" ~ Metamodel.locstr($O[0].file, $O[0].line, $file, $line);
- }
- if $name !~~ Str {
- die "Computed names are legal only in parametric roles";
- }
- push $.methods, Metamodel::Method.new(:$name, :$body, :$kind,
- :$multi, :$file, :$line);
- }
-
- method add_super($targ) {
- die "bad attempt to add null super" unless $targ;
- push $.superclasses, $targ;
- }
-}
-
-class ParametricRole is Module {
- has $.attributes = [];
- has $.methods = [];
- has $.superclasses = [];
-
- method add_attribute($name, $sigil, $public, $ivar, $ibody, $typeconstraint, :$file, :$line, :$pos) { #OK not used
- if grep $name eq *.name, @($!attributes) -> $O {
- die "Two definitions of attribute $name" ~ Metamodel.locstr($O[0].file, $O[0].line, $file, $line);
- }
- push $.attributes, Metamodel::Attribute.new(:$name, :$sigil,
- :$public, :$ivar, :$ibody, :$typeconstraint, :$file, :$line);
- $.attributes.[*-1];
- }
-
- method add_method($multi, $kind, $name, $var, $body, :$file, :$line, :$pos) { #OK not used
- if $name ~~ Str && $multi eq 'only' &&
- grep { $name eq .name && $kind eq .kind }, @($!methods) -> $O {
- die "Two definitions of method $name" ~ Metamodel.locstr($O[0].file, $O[0].line, $file, $line);
- }
- push $.methods, ::Metamodel::Method.new(:$name, :$body, :$var, :$kind, :$multi, :$file, :$line);
- }
-
- method add_super($targ) {
- die "bad attempt to add null super" unless $targ;
- push $.superclasses, $targ;
- }
-}
-
-class Grammar is Class {
- method _defsuper() { 'CORE', 'Grammar' }
-}
-
-# subsets are a bit simpler than roles/grammars/classes, as they have
-# no body and so attributes &c cannot be added to them directly.
-class Subset is Module {
- # subset <longname>? <trait>* [where <EXPR>]?
- has $.basetype is rw;
- # Xref to a sub which will be called once the first time the subset
- # is used.
- has $.where is rw;
-}
-
-#####
-
-# This is a static lexical; they exist in finite number per unit. They may
-# occupy specific slots in pads, or globals, or something else entirely.
-class Lexical {
- has $.file;
- has $.line;
- has $.pos;
-
- # my $foo, @foo, %foo, &foo
- class Simple is Lexical {
- has Bool $.list = False;
- has Bool $.hash = False;
- has Bool $.noinit = False;
- has Bool $.defouter = False;
- has Bool $.roinit = False;
- has $.typeconstraint; # Xref
- }
-
- # These are used for $?foo et al, and should be inaccessible until assigned,
- # although the current code won't enforce that well.
- class Hint is Lexical {
- }
-
- # These store destinations for lexotic control transfers, and clone like
- # subs to handle recursion properly.
- class Label is Lexical {
- }
-
- class Dispatch is Lexical {
- }
-
- # our...
- class Common is Lexical {
- has $.pkg = die "M:L:Common.path required"; # Xref to Package
- has $.name = die "M:L:Common.name required"; # Str
- }
-
- # mostly for state
- class Alias is Lexical {
- has $.to = die "M:L:Alias.to required"; # Str
- }
-
- # sub foo { ... }
- class SubDef is Lexical {
- has $.body; # Metamodel::StaticSub
- }
-
- # my class Foo { } or our class Foo { }; either case, the true
- # stash lives in stashland. Actually this points at a package now.
- class Stash is Lexical {
- has $.pkg; # Xref
- }
-}
-
-# The life cycle of a static sub has three phases.
-# 1. Open - the end of the sub hasn't been seen, so the full code is absent.
-# 2. Closing - all attributes are available but no references exist. The
-# perfect time for most optimizations, especially ones that look like
-# escape analyses.
-# 3. Closed - references exist, possibly even from BEGIN-run code. The sub
-# must be treated as semantically immutable. The code can probably still
-# be changed to reflect new information, though.
-
-# figure out how post-declared lexicals should interact with codegen
-# std accepts: sub foo() { bar }; BEGIN { foo }; sub bar() { }
-# DONE: TimToady says bar can be compiled to a runtime search
-class StaticSub is RefTarget {
- has $.unit; # Metamodel::Unit
- has $.outerx; # Xref
- # points directly to the outer so that explain_mystery doesn't need
- # to worry about inlining...
- has $.outer_direct is rw;
- has Bool $.run_once is rw = False;
- has Bool $.spad_exists is rw = False;
- has Bool $.transparent = False; # ignored by OUTER::
- has %.lexicals;
- has $.code is rw; # Op
- has $.signature is rw; # Sig
- has $.zyg = []; # Array of Metamodel::StaticSub
-
- # inject a take EMPTY
- has Bool $.gather_hack is rw = False;
- # inject a role constructor (Xref)
- has $.parametric_role_hack is rw;
- # some tuples for method definitions; munged into a phaser
- has $.augment_hack is rw;
- # emit code to assign to a hint; [ $subref, $name ]
- has $.hint_hack is rw;
-
- has $.is_phaser is rw; # Int
- has Bool $.strong_used is rw = False; # prevents elision
- has $.body_of is rw; # Xref of Package
- has $.in_class is rw; # Xref of Package
- has $.cur_pkg is rw; # Xref of Package
- has Bool $.returnable is rw = False; # catches &return
- has Bool $.augmenting is rw = False; # traps add_attribute
- has Bool $.unsafe is rw = False; # disallowed in safe mode
- has Str $.class is rw = 'Sub';
- has $.ltm is rw;
- # a place to hang off extra stuff that's not used for most subs
- # currently: "prec" for operators, "builtin" for primitives
- has $.extend is rw;
-
- # used during parse only
- has Str $.outervar is rw; # Xref, used during parse
- has $.methodof is rw; # Xref, used during parse
- has %.lexicals-used;
- # not just local lexicals, but all in parse; from current or any inside
- # block
-
- method outer() {
- $!outer_direct //= ($!outerx ?? $*unit.deref($!outerx) !! StaticSub)
- }
-
- method true_setting() {
- my $cursor = self;
- while $cursor && !$cursor.unit.is_true_setting {
- $cursor = $cursor.outer;
- }
- $cursor || self;
- }
-
- method to_unit() {
- my $cursor = self;
- my $unit = self.unit;
- my $outer;
- while ($outer = $cursor.outer) && $outer.unit === $unit {
- $cursor = $outer
- }
- $cursor;
- }
-
- method is_routine() {
- state %routine = (:Routine, :Sub, :Submethod, :Method, :Regex);
- %routine{$!class}
- }
-
- method add_child($z) { push $.zyg, $z }
- method children() { @$.zyg }
-
- method clear_optree() {
- $.code = Any;
- $.ltm = Any;
- }
-
- method create_static_pad() {
- return Nil if $!spad_exists;
- $!spad_exists = True;
- $.outer.create_static_pad if $.outer && $.outer.unit === $!unit;
- }
-
- method noninlinable() {
- loop (my $c = self; $c && $c.unit === $*unit; $c = $c.outer) {
- $c.strong_used = True;
- }
- }
-
- method topicalizer() {
- $.signature && ?( grep { .slot && .slot eq '$_' }, @( $.signature.params ) )
- }
-
- # helper for compile_get_pkg; handles stuff like SETTING::OUTER::Foo,
- # recursively.
- method _lexy_ref(*@names, :$auto) {
- @names || die "Cannot use a lexical pseudopackage as a compile time package reference";
- self // die "Passed top of lexical tree";
- given shift @names {
- when 'OUTER' { return self.outer._lexy_ref(@names, :$auto) }
- when 'SETTING' { return self.to_unit.outer._lexy_ref(@names, :$auto) }
- when 'UNIT' { return self.to_unit._lexy_ref(@names, :$auto) }
- when 'CALLER' { die "Cannot use CALLER in a compile time name" }
- default {
- my $lex = self.find_lex($_);
- $lex // die "No lexical found for $_";
- $lex.^isa(Metamodel::Lexical::Stash) || die "Lexical $_ is not a package";
- return $*unit.get_pkg($*unit.deref($lex.pkg), @names, :$auto);
- }
- }
- }
-
- # returns direct reference to package, or dies
- method compile_get_pkg(*@names, :$auto) {
- @names || die "Cannot make a compile time reference to the semantic root package";
- my $n0 = shift(@names);
- if $n0 eq 'OUR' {
- return $*unit.get_pkg($*unit.deref($!cur_pkg), @names, :$auto);
- } elsif $n0 eq 'PROCESS' or $n0 eq 'GLOBAL' {
- return $*unit.abs_pkg($n0, @names, :$auto);
- } elsif $n0 eq any < COMPILING DYNAMIC CLR CALLER > {
- # Yes, COMPILING is right here. Because COMPILING is only valid
- # when recursively running code within the compiler, but this
- # function is only called directly from the compiler. The closest
- # it comes to making sense is if you use eval in a macro. Don't
- # do that, okay?
- die "Pseudo package $n0 may not be used in compile time reference";
- } elsif $n0 eq 'MY' {
- return self._lexy_ref(@names, :$auto);
- } elsif $n0 eq 'CORE' {
- return self.true_setting._lexy_ref(@names, :$auto);
- } elsif $n0 eq 'OUTER' or $n0 eq 'SETTING' or $n0 eq 'UNIT' {
- return self._lexy_ref($n0, @names, :$auto);
- } elsif $n0 ne 'PARENT' && self.find_lex($n0) {
- return self._lexy_ref($n0, @names, :$auto);
- } elsif $n0 ~~ /^\W/ {
- return $*unit.get_pkg($*unit.deref($!cur_pkg), $n0, @names, :$auto);
- } else {
- return $*unit.abs_pkg('GLOBAL', $n0, @names, :$auto);
- }
- }
-
- method bind_our_name($path, $name, $item, *%_) {
- my $pkg = self.compile_get_pkg($path ?? @$path !! 'OUR', :auto);
- $*unit.bind($pkg, $name, $item, |%_);
- }
-
- method find_lex($name) {
- my $l = %!lexicals{$name};
- if $l {
- return $l.^isa(Metamodel::Lexical::Alias) ??
- self.find_lex($l.to) !! $l;
- }
- return ($.outer ?? $.outer.find_lex($name) !! Metamodel::Lexical);
- }
-
- method delete_lex($name) {
- my $l = %!lexicals{$name};
- if $l {
- if $l.^isa(Metamodel::Lexical::Alias) { self.delete_lex($l.to) }
- else { %!lexicals{$name}:delete }
- } else {
- $.outer && $.outer.unit === $.unit && $.outer.delete_lex($name);
- }
- }
-
- method add_lex($slot, $item) {
- if %!lexicals{$slot} -> $o {
- my $l = Metamodel.locstr($o.file, $o.line, $item.file, $item.line);
- if $slot ~~ /^\w/ {
- die "Illegal redeclaration of symbol '$slot'$l";
- } elsif $slot ~~ /^\&/ {
- die "Illegal redeclaration of routine '$slot.substr(1)'$l";
- } else {
- $*worry.("Useless redeclaration of variable $slot$l");
- return;
- }
- }
- # We don't know in advance if $_ exists. This is OK.
- # TODO: The semantics are off here. $_ should be in every block.
- elsif $slot ne '$_' && %!lexicals-used{$slot} -> $p {
- my $truename = $slot;
- my $c = self;
- while $c && !$c.lexicals{$slot} {
- $truename ~~ s/<?before \w>/OUTER::/;
- $c = $c.outer;
- }
- die "Lexical tracking inconsistency" unless $c;
- my $o = $c.lexicals{$slot};
- die "Lexical symbol '$slot' is already bound to an outer symbol{Metamodel.locstr($o.file, $o.line, $item.file, $item.line)};\n the implicit outer binding at line $p.value() must be rewritten as $truename\n before you can unambiguously declare a new '$slot' in this scope";
- }
- %!lexicals{$slot} = $item;
- if substr($slot,0,1) eq '&' && (%*MYSTERY{substr($slot,1)}:exists) {
- %!lexicals-used{$slot} = True;
- }
- }
-
- method add_my_name($slot, *%param) {
- self.add_lex($slot, Metamodel::Lexical::Simple.new(|%param));
- }
-
- method add_hint($slot, *%params) {
- self.add_lex($slot, Metamodel::Lexical::Hint.new(|%params));
- }
-
- method add_label($slot, *%params) {
- self.add_lex($slot, Metamodel::Lexical::Label.new(|%params));
- }
-
- method add_dispatcher($slot, *%params) {
- self.add_lex($slot, Metamodel::Lexical::Dispatch.new(|%params));
- }
-
- method add_common_name($slot, $pkg, $name, :$file, :$line, :$pos) {
- $*unit.bind($*unit.deref($pkg), $name, Any, :$file, :$line)
- unless $*unit.ns.exists($*unit.deref($pkg).who, $name);
- self.add_lex($slot, Metamodel::Lexical::Common.new(:$pkg, :$name,
- :$file, :$line, :$pos));
- }
-
- method add_state_name($slot, $back, *%param) {
- # outermost sub isn't cloned so a fallback to my is safe
- my $up = (self === self.to_unit) ?? self !! self.outer;
- $up.lexicals{$back} = Metamodel::Lexical::Simple.new(|%param);
- if defined($slot) {
- self.add_lex($slot, Metamodel::Lexical::Alias.new(to => $back,
- |%param));
- }
- }
-
- method add_my_stash($slot, $pkg, *%params) {
- self.add_lex($slot, Metamodel::Lexical::Stash.new(:$pkg, |%params));
- }
-
- method add_my_sub($slot, $body, *%params) {
- self.add_lex($slot, Metamodel::Lexical::SubDef.new(:$body, |%params));
- }
-
- method add_exports($name, $xref, $tags) {
- for @$tags -> $tag {
- $*unit.bind($*unit.get_pkg($*unit.deref($!cur_pkg), 'EXPORT',
- $tag, :auto), $name, $xref);
- }
- +$tags;
- }
-
- method close() { }
-}
-
-class Unit {
- has Metamodel::StaticSub $.mainline is rw;
- has Str $.name;
- has Metamodel::Namespace $.ns;
- has $.setting_ref is rw;
- has $.bottom_ref is rw;
- has $.xref = [];
- has $.tdeps = {};
- has Str $.filename is rw;
- has $.modtime is rw; # Numeric
- has Int $.next_anon_stash is rw = 0; # is rw, Int
- has @.stubbed_stashes; # Pair[Stash,Cursor]
-
- method bind($pkg,$name,$item,*%_) { $!ns.bind($pkg.who,$name,$item,|%_) }
- method list_stash($pkg) { $!ns.list_stash($pkg.who) }
- method get($pkg,$name) { $!ns.get($pkg.who,$name) }
- method get_pkg($pkg,*@names,:$auto) { $!ns.get_pkg($pkg,@names,:$auto) }
- method abs_pkg(*@names, :$auto) {
- $!ns.get_pkg($*unit.deref($!ns.root),@names,:$auto)
- }
-
- method is_true_setting() { $!name eq 'CORE' }
-
- method get_unit($name) { %*units{$name} }
-
- method anon_stash() { "{$.name}:{$.next_anon_stash++}" }
-
- method deref($thing) {
- die "trying to dereference null" unless $thing;
- self.get_unit($thing[0]).xref[$thing[1]] // die "invalid ref @$thing";
- }
-
- method visit_units_preorder($cb) {
- my %seen;
- sub rec {
- return Nil if %seen{$_};
- %seen{$_} = True;
- for sort keys self.get_unit($_).tdeps { rec($_) }
- $cb(self.get_unit($_));
- }
- rec($.name);
- }
-
- method visit_local_packages($cb) {
- for @$.xref -> $x {
- $cb($x) if defined($x) && $x.^isa(Metamodel::Package);
- }
- }
-
- method clear_optrees() {
- self.visit_local_subs_postorder({ $_.clear_optree })
- }
-
- method visit_local_subs_postorder($cb) {
- sub rec {
- for $_.children { rec($_) }
- $cb($_);
- }
- rec($.mainline);
- }
-
- method visit_local_subs_preorder($cb) {
- sub rec {
- $cb($_);
- for $_.children { rec($_) }
- }
- rec($.mainline);
- }
-
- method need_unit($u2name) {
- return %*units{$u2name} if $.tdeps{$u2name};
- my $u2 = %*units{$u2name} //= $*module_loader.($u2name);
- $.tdeps{$u2name} = [ $u2.filename, $u2.modtime ];
- my @new = $u2name;
- for keys $u2.tdeps -> $k {
- next if $.tdeps{$k};
- push @new, $k;
- %*units{$k} //= $*module_loader.($k);
- $.tdeps{$k} = $u2.tdeps{$k};
- }
- $!ns.add_from($_) for @new;
- $u2;
- }
-}
View
352 src/NAMOutput.pm6
@@ -1,352 +0,0 @@
-class NAMOutput;
-
-use JSYNC;
-use Metamodel;
-use Sig;
-use MONKEY_TYPING;
-
-method run($*unit) {
- my @*subsnam;
-
- $*unit.visit_local_subs_postorder(&nam_sub);
- to-json($*unit.to_nam) ~ "\n" ~ to-json(@*subsnam);
-}
-
-sub nam_sub($s) {
- my $code = $s.code;
- if $s.topicalizer {
- $code = ::Op::TopicalHook.new(inner => $code);
- }
- my $lx = $s.lexicals;
- my @labels = grep { $lx{$_}.^isa(::Metamodel::Lexical::Label) }, $lx.keys;
- if @labels {
- $code = ::Op::LabelHook.new(labels => @labels, inner => $code);
- }
- if $s.parametric_role_hack {
- for @( $*unit.deref($s.parametric_role_hack).methods ) -> $me {
- if $me.name ~~ ::GLOBAL::Op {
- $me.name = $me.name.cgop($s);
- }
- }
- }
- @*subsnam[$s.xref[1]] = [
- $s.xref, # for documentation
- $s.parametric_role_hack,
- $s.augment_hack,
- $s.hint_hack,
- $s.is_phaser,
- $s.body_of,
- $s.in_class,
- $s.cur_pkg,
- $code.cgop($s),
- ];
-}
-
-method load($text) {
- $text := $text.substr(0, $text.index("\n"));
- unit_from_nam(from-json($text));
-}
-
-augment class Metamodel::Unit { #OK exist
- method to_nam() {
- [
- $.name,
- [ map { [$_, @( $.tdeps{$_} )] }, sort keys $.tdeps ],
- $.mainline.xref,
- $.setting_ref,
- $.bottom_ref,
- $.filename,
- $.modtime,
- $.ns.root,
- [ $.ns.log ],
- [ map { $_ && $_.to_nam }, @$.xref ],
- ]
- }
-}
-
-sub unit_from_nam(@block) {
- my ($name, $td, $mlref, $setting, $bottom, $filename, $modtime,
- $nsroot, $nslog, $xr) = @block;
- my $*uname = $name;
- my $*unit = ::Metamodel::Unit.new(
- name => $name,
- ns => ::Metamodel::Namespace.new(log => @$nslog,
- root => $nsroot),
- setting_ref => $setting,
- bottom_ref => $bottom,
- filename => $filename,
- modtime => $modtime,
- tdeps => _hash_constructor(map { (shift($_) => $_) }, @$td));
-
- my $*xref = $*unit.xref;
- my $*xid = 0;
- while $*xid < @$xr {
- my $xv = $xr[$*xid];
- push $*xref, $xv && ($xv[0] eq 'sub' ?? &sub_from_nam !! &packagely)($xv);
- $*xid++;
- }
- # XXX suboptimality
- $*xid = 0;
- while $*xid < @$xr {
- if ($xr[$*xid] && $xr[$*xid][0] eq 'sub') {
- for @( $xr[$*xid][8] ) -> $row {
- my ($k,$v) = lex_from_nam($row);
- $*xref[$*xid].lexicals{$k} = $v;
- }
- for @( $xr[$*xid][4] ) -> $z {
- push $*xref[$*xid].zyg, $*xref[$z];
- }
- }
- $*xid++;
- }
- $*unit.mainline = $*unit.xref[$mlref[1]];
-
- $*unit;
-}
-
-augment class Metamodel::StaticSub { #OK exist
- method to_nam() {
- my $flags = 0;
- $flags +|= 1 if $.run_once;
- $flags +|= 2 if $.spad_exists;
- $flags +|= 4 if $.gather_hack;
- $flags +|= 8 if $.strong_used;
- $flags +|= 16 if $.returnable;
- $flags +|= 32 if $.augmenting;
- $flags +|= 64 if $.transparent;
- $flags +|= 128 if $.unsafe;
- [
- 'sub',
- $.name,
- $.outerx,
- $flags,
- [ map { $_.xref[1] }, @$.zyg ],
- $.class,
- $.ltm,
- ($.signature && [ map { $_.to_nam }, @( $.signature.params ) ]),
- [ map { [ $_, @( $.lexicals{$_}.to_nam ) ] },
- sort keys $.lexicals ],
- $.extend,
- ]
- }
-}
-
-sub sub_from_nam(@block) {
- my ($kind, $name, $outer, $flags, $zyg, #OK
- $cls, $ltm, $sig, $rlx, $ext) = @block; #OK
- # Most of these are used only by code-gen. Lexicals are injected later.
-
- ::Metamodel::StaticSub.new(
- :no_xref,
- unit => $*unit,
- name => $name,
- xref => [ $*uname, $*xid, $name ],
- outerx => $outer,
- run_once => ?($flags +& 1),
- spad_exists => ?($flags +& 2),
- transparent => ?($flags +& 64),
- extend => $ext,
- zyg => [],
- class => $cls,
- ltm => $ltm,
- )
-}
-
-my %pkgtypes = (
- package => ::Metamodel::Package,
- module => ::Metamodel::Module,
- class => ::Metamodel::Class,
- grammar => ::Metamodel::Grammar,
- role => ::Metamodel::Role,
- parametricrole => ::Metamodel::ParametricRole,
- subset => ::Metamodel::Subset,
-);
-
-my %typecodes = map { ($_.value.typename => $_.key) }, %pkgtypes;
-
-augment class Metamodel::Package { #OK exist
- method to_nam(*@more) {
- [
- %typecodes{self.typename},
- $.name,
- $.who,
- @more
- ]
- }
-}
-
-sub packagely(@block) {
- my ($type, $name, $who, $attr, $meth, $sup, $mro) = @block;
- # these two are nonstandard
- if $type eq 'subset' {
- return ::Metamodel::Subset.new(
- :no_xref, :$name, :$who,
- xref => [ $*uname, $*xid, $name ],
- basetype => $attr,
- where => $meth,
- );
- }
-
- # this relies on .new ignoring unrecognized keys
- %pkgtypes{$type}.new(
- :no_xref, :$name, :$who,
- xref => [ $*uname, $*xid, $name ],
- attributes => $attr && [ map &attr_from_nam, @$attr ],
- methods => $meth && [ map &method_from_nam, @$meth ],
- superclasses => $sup,
- linearized_mro => $mro
- )
-}
-
-augment class Metamodel::Class { #OK exist
- method to_nam() {
- nextwith(self,
- [ map { $_.to_nam }, @$.attributes ],
- [ map { $_.to_nam }, @$.methods ],
- $.superclasses,
- $.linearized_mro);
- }
-}
-
-augment class Metamodel::Role { #OK exist
- method to_nam() {
- nextwith(self,
- [ map { $_.to_nam }, @$.attributes ],
- [ map { $_.to_nam }, @$.methods ],
- $.superclasses);
- }
-}
-
-augment class Metamodel::ParametricRole { #OK exist
- method to_nam() {
- nextwith(self,
- [ map { $_.to_nam }, @$.attributes ],
- [ map { $_.to_nam }, @$.methods ],
- $.superclasses);
- }
-}
-
-augment class Metamodel::Subset { #OK exist
- method to_nam() {
- nextwith(self,
- $.basetype,
- $.where);
- }
-}
-
-my %methodtypes = ( normal => 0, private => 1, sub => 2 );
-my %methodmulti = ( only => 0, proto => 4, multi => 8 );
-my @methodfromtype = ('normal', 'private', 'sub');
-my @methodfrommulti = ('only', 'proto', 'multi');
-augment class Metamodel::Method { #OK exist
- method to_nam() {
- [ $.name, %methodtypes{$.kind} + %methodmulti{$.multi}, $.var, $.body ]
- }
-}
-
-augment class Metamodel::Attribute { #OK exist
- method to_nam() {
- [ $.name, $.sigil, $.public, $.ivar, $.ibody, $.typeconstraint ]
- }
-}
-
-sub method_from_nam(@block) {
- my ($name, $kind, $var, $body) = @block;
- ::Metamodel::Method.new(:$name, :$var, :$body,
- kind => @methodfromtype[$kind +& 3],
- multi => @methodfrommulti[$kind +> 2]);
-}
-
-sub attr_from_nam(@block) {
- my ($name, $sigil, $public, $ivar, $ibody, $typeconstraint) = @block;
- ::Metamodel::Attribute.new(:$name, :$public, :$ivar, :$ibody, :$sigil,
- :$typeconstraint);
-}
-
-augment class Sig::Parameter { #OK exist
- method to_nam() {
- my $flags = 0;
- $flags = $flags +| 1 if $.slurpy;
- $flags = $flags +| 2 if $.slurpycap;
- $flags = $flags +| 4 if $.rwtrans;
- $flags = $flags +| 8 if $.full_parcel;
- $flags = $flags +| 16 if $.optional;
- $flags = $flags +| 32 if $.positional;
- $flags = $flags +| 64 if $.rw;
- $flags = $flags +| 128 if $.list;
- $flags = $flags +| 256 if $.hash;
- $flags = $flags +| 512 if $.defouter;
- $flags = $flags +| 1024 if $.invocant;
- $flags = $flags +| 2048 if $.multi_ignored;
- $flags = $flags +| 4096 if $.is_copy;
-
- [
- $.name,
- $flags,
- $.slot,
- $.names,
- $.mdefault,
- $.tclass
- ]
- }
-}
-
-sub parm_from_nam(@block) {
- my ($name, $flags, $slot, $names, $mdefault, $tclass) = @block; #OK
- ::Sig::Parameter.new(
- slurpy => ?($flags +& 1), slurpycap => ?($flags +& 2),
- rwtrans => ?($flags +& 4), full_parcel => ?($flags +& 8),
- optional => ?($flags +& 16), positional => ?($flags +& 32),
- rw => ?($flags +& 64), list => ?($flags +& 128),
- hash => ?($flags +& 256), defouter => ?($flags +& 512),
- invocant => ?($flags +& 1024), multi_ignored => ?($flags +& 2048),
- is_copy => ?($flags +& 4096),
- name => $name, slot => $slot, names => $names, :$tclass);
-}
-
-augment class Metamodel::Lexical::Simple { #OK exist
- method to_nam() { ['simple', 4 * $!noinit + 2 * $!list + 1 * $!hash +
- 8 * $!roinit + 16 * $!defouter, $!typeconstraint] }
-}
-augment class Metamodel::Lexical::Common { #OK exist
- method to_nam() { ['common', $.pkg, $.name ] }
-}
-augment class Metamodel::Lexical::Alias { #OK exist
- method to_nam() { ['alias', $.to] }
-}
-augment class Metamodel::Lexical::Hint { #OK exist
- method to_nam() { ['hint'] }
-}
-augment class Metamodel::Lexical::Label { #OK exist
- method to_nam() { ['label'] }
-}
-augment class Metamodel::Lexical::Dispatch { #OK exist
- method to_nam() { ['dispatch'] }
-}
-augment class Metamodel::Lexical::SubDef { #OK exist
- method to_nam() { ['sub', @( $.body.xref ) ] }
-}
-augment class Metamodel::Lexical::Stash { #OK exist
- method to_nam() { ['stash', @( $.pkg ) ] }
-}
-
-sub lex_from_nam(@block) {
- my ($name, $type, @xtra) = @block;
- return ($name, ::Metamodel::Lexical::Simple.new)
- if $type eq 'simple';
- return ($name, ::Metamodel::Lexical::Common.new(name => @xtra[1],
- pkg => @xtra[0])) if $type eq 'common';
- return ($name, ::Metamodel::Lexical::Alias.new(to => @xtra[0]))
- if $type eq 'alias';
- return ($name, ::Metamodel::Lexical::Hint.new)
- if $type eq 'hint';
- return ($name, ::Metamodel::Lexical::Label.new)
- if $type eq 'label';
- return ($name, ::Metamodel::Lexical::Dispatch.new)
- if $type eq 'dispatch';
- return ($name, ::Metamodel::Lexical::SubDef.new(body => $*xref[@xtra[1]]))
- if $type eq 'sub';
- return ($name, ::Metamodel::Lexical::Stash.new(pkg => @xtra))
- if $type eq 'stash';
- die "weird lex type $type";
-}
View
19 src/NieczaActions.pm6
@@ -2288,7 +2288,7 @@ method add_attribute($/, $name, $sigil, $accessor, $type) {
$nb.set_outervar($ac);
$*CURLEX<!sub>.add_my_sub($ac, $nb, |mnode($/));
$ns.add_attribute($name, $sigil, +$accessor, $type, |mnode($/));
- $ns.add_method(::Metamodel::SubVisibility::private, $name, $nb,
+ $ns.add_method($*backend.sub_visibility("private"), $name, $nb,
|mnode($/));
if $accessor {
$ns.add_method(0, $name, $nb, |mnode($/));
@@ -2437,13 +2437,12 @@ method type_declarator:subset ($/) {
$/.CURSOR.trymop({
($lexvar, $obj) = self.do_new_package($/, scope => $*SCOPE,
- name => $<longname>, class => ::Metamodel::Subset,
- :@exports);
+ name => $<longname>, class => 'subset', :@exports);
$*CURLEX<!sub>.create_static_pad;
- $obj.basetype = $basetype.xref;
- $obj.where = $body.xref;
+ $obj.set_basetype($basetype);
+ $obj.set_where($body);
});
make mklex($/, $lexvar);
@@ -2483,7 +2482,7 @@ method init_constant($con, $rhs) {
name => "$con.name() init");
$body.outer.create_static_pad;
$con.init = True;
- $body.set_phaser(+::Metamodel::Phaser::UNIT_INIT);
+ $body.set_phaser($*backend.phaser('UNIT_INIT'));
$con;
}
@@ -3098,7 +3097,7 @@ method package_def ($/) {
$ph.finish(::Op::CgOp.new(op => $fin));
$sub.create_static_pad;
- $ph.set_phaser(+::Metamodel::Phaser::INIT);
+ $ph.set_phaser($*backend.phaser('INIT'));
make ::Op::CallSub.new(|node($/), invocant => mklex($/, $bodyvar));
}
@@ -3465,7 +3464,7 @@ sub phaser($/, $ph, :$unique, :$topic, :$csp) {
if $unique {
$/.CURSOR.sorry("Limit one $ph phaser per block, please.")
- if $sub.outer.contains_phaser(+::Metamodel::Phaser.($ph));
+ if $sub.outer.contains_phaser($*backend.phaser($ph));
my $code = ($<blast><statement> // $<blast><block><blockoid> // $<block><blockoid>).ast;
# TODO avoid double finishing
$sub.finish(::Op::CatchyWrapper.new(inner => $code));
@@ -3479,7 +3478,7 @@ sub phaser($/, $ph, :$unique, :$topic, :$csp) {
$sub.set_signature(Sig.simple('$_'));
}
$*CURLEX<!sub>.create_static_pad if $csp;
- $sub.set_phaser(+::Metamodel::Phaser.($ph));
+ $sub.set_phaser($*backend.phaser($ph));
make ::Op::StatementList.new;
}
@@ -3499,7 +3498,7 @@ method statement_prefix:INIT ($/) { phaser($/, 'INIT', :csp) }
# XXX 'As soon as possible' isn't quite soon enough here
method statement_prefix:BEGIN ($/) {
$*CURLEX<!sub>.create_static_pad;
- $<blast>.ast.set_phaser(+::Metamodel::Phaser::UNIT_INIT);
+ $<blast>.ast.set_phaser($*backend.phaser('UNIT_INIT'));
make ::Op::StatementList.new;
# MAJOR HACK - allows test code like BEGIN { @*INC.push: ... } to work
View
24 src/NieczaBackendDotnet.pm6
@@ -1,14 +1,28 @@
class NieczaBackendDotnet;
-use NAMOutput;
use JSYNC;
use NieczaPassSimplifier;
-use Metamodel;
has $.safemode = False;
has $.obj_dir;
has $.run_args = [];
+enum Phaser < INIT END UNIT_INIT KEEP UNDO LEAVE ENTER PRE POST CATCH CONTROL >;
+enum MultiMode ( only => 0, proto => 4, multi => 8 );
+enum SubVisibility ( normal => 0, private => 1, sub => 2 );
+
+method phaser($n) { +Phaser.($n) }
+method sub_visibility($n) { +SubVisibility.($n) }
+method multi_mode($n) { +MultiMode.($n) }
+
+sub locstr($fo, $lo, $fn, $ln) {
+ $fo := $fo // '???';
+ $lo := $lo // '???';
+ $fn := $fn // '???';
+ $ln := $ln // '???';
+
+ $fn eq $fo ?? " (see line $lo)" !! " (see $fo line $lo)";
+}
sub upcalled(*@args) {
my $v = $*compiler.verbose;
@@ -137,7 +151,7 @@ class StaticSub {
given @args[0] {
when 'collision' {
my ($ , $slot, $nf,$nl,$of,$ol) = @args;
- my $l = Metamodel.locstr($of, $ol, $nf, $nl);
+ my $l = locstr($of, $ol, $nf, $nl);
if $slot ~~ /^\w/ {
die "Illegal redeclaration of symbol '$slot'$l";
} elsif $slot ~~ /^\&/ {
@@ -150,7 +164,7 @@ class StaticSub {
my ($ , $slot, $count, $line, $nf,$nl,$of,$ol) = @args;
my $truename = $slot;
$truename ~~ s/<?before \w>/OUTER::/ for ^$count;
- die "Lexical symbol '$slot' is already bound to an outer symbol{Metamodel.locstr($of, $ol, $nf, $nl)};\n the implicit outer binding at line $line must be rewritten as $truename\n before you can unambiguously declare a new '$slot' in this scope";
+ die "Lexical symbol '$slot' is already bound to an outer symbol{locstr($of, $ol, $nf, $nl)};\n the implicit outer binding at line $line must be rewritten as $truename\n before you can unambiguously declare a new '$slot' in this scope";
}
when 'sub' {
my ($ , $slot) = @args;
@@ -264,8 +278,6 @@ class StaticSub {
}
}
-enum Metamodel::MultiMode ( only => 0, proto => 4, multi => 8 );
-enum Metamodel::SubVisibility ( normal => 0, private => 1, sub => 2 );
class Type {
method FALLBACK($name, *@args) { downcall("type_$name", self, @args) }
View
34 src/niecza
@@ -2,9 +2,6 @@ use MONKEY_TYPING;
use CClass;
use CgOp;
use GetOptLong;
-use JSYNC;
-use Metamodel;
-use NAMOutput;
use NieczaActions;
use NieczaBackendDotnet;
use NieczaCompiler;
@@ -103,37 +100,6 @@ method blockoid($/) {
make $<statementlist>.ast;
}
}
-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.