Permalink
Browse files

Perlito5 - js2 - fix package stringification

  • Loading branch information...
1 parent 1fdfe81 commit 2b905bc7fe690874f637b4bd2e7c11e9c0e5999a @fglock committed Nov 30, 2012
Showing with 18 additions and 4 deletions.
  1. +8 −1 html/perlito5.js
  2. +1 −1 perlito5.pl
  3. +8 −1 src5/lib/Perlito5/Javascript2/Runtime.pm
  4. +1 −1 t5/01-perlito/32-autoload-method.t
View
@@ -75,6 +75,7 @@ function p5make_package(pkg_name) {
p5pkg[pkg_name] = new tmp();
p5pkg[pkg_name]._ref_ = pkg_name;
p5pkg[pkg_name]._class_ = p5pkg[pkg_name]; // XXX memory leak
+ p5pkg[pkg_name]._is_package_ = 1;
// TODO - add the other package global variables
p5pkg[pkg_name]["List_ISA"] = [];
@@ -131,11 +132,17 @@ function p5method_lookup(method, class_name, seen) {
}
function p5call(invocant, method, list, p5want) {
- list.unshift(invocant);
if (typeof invocant === "string") {
+ list.unshift(invocant);
invocant = p5make_package(invocant);
}
+ else if ( invocant.hasOwnProperty("_is_package_") ) {
+ list.unshift(invocant._ref_); // invocant is a "package" object
+ }
+ else {
+ list.unshift(invocant);
+ }
if ( invocant.hasOwnProperty("_class_") ) {
View

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -81,6 +81,7 @@ function p5make_package(pkg_name) {
p5pkg[pkg_name] = new tmp();
p5pkg[pkg_name]._ref_ = pkg_name;
p5pkg[pkg_name]._class_ = p5pkg[pkg_name]; // XXX memory leak
+ p5pkg[pkg_name]._is_package_ = 1;
// TODO - add the other package global variables
p5pkg[pkg_name]["List_ISA"] = [];
@@ -137,11 +138,17 @@ function p5method_lookup(method, class_name, seen) {
}
function p5call(invocant, method, list, p5want) {
- list.unshift(invocant);
if (typeof invocant === "string") {
+ list.unshift(invocant);
invocant = p5make_package(invocant);
}
+ else if ( invocant.hasOwnProperty("_is_package_") ) {
+ list.unshift(invocant._ref_); // invocant is a "package" object
+ }
+ else {
+ list.unshift(invocant);
+ }
if ( invocant.hasOwnProperty("_class_") ) {
@@ -12,7 +12,7 @@ say "1..5";
sub AUTOLOAD {
say "# A::AUTOLOAD @_";
print "not " if $_[0] ne 'A';
- say "ok 1 # TODO package stringification bug";
+ say "ok 1";
print "not " if $_[1] != 123;
say "ok 2";
say "# $AUTOLOAD";

0 comments on commit 2b905bc

Please sign in to comment.