Skip to content

Commit

Permalink
Rather than dying when trying to run code we didn't compile yet, inst…
Browse files Browse the repository at this point in the history
…ead try to compile it on-demand and run it. Missing various environmental bits just yet, but essentially works.
  • Loading branch information
jnthn committed May 14, 2011
1 parent d0f50b8 commit 3b5eec5
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/NQP/SymbolTable.pm
Expand Up @@ -199,18 +199,20 @@ class NQP::SymbolTable is HLL::Compiler::SerializationContextBuilder {
)));
}

# For methods, we need a "stub" that we'll clone and use for the
# compile-time representation. It'll really just complain that it
# does that code hasn't been compiled yet. (Need something more
# complex to handle roles, but one step at a time...)
my $stub_code := sub (*@args, *%named) {
pir::die("Cannot run code that has not yet been compiled.");
};

# Adds a method to the meta-object, and stores an event for the action.
# Note that methods are always subject to fixing up since the actual
# compiled code isn't available until compilation is complete.
method pkg_add_method($obj, $meta_method_name, $name, $method_past, $is_dispatcher) {
# For methods, we need a "stub" that we'll clone and use for the
# compile-time representation. If it ever gets invoked it'll go
# and compile the code and run it.
# XXX Lexical environment.
# XXX Cache compiled output.
my $stub_code := sub (*@args, *%named) {
my $compiled := PAST::Compiler.compile($method_past);
$compiled(|@args, |%named);
};

# See if we already have our compile-time dummy. If not, create it.
my $fixups := PAST::Stmts.new();
my $dummy;
Expand Down

0 comments on commit 3b5eec5

Please sign in to comment.