Permalink
Browse files

Perlito5 - js2 - caret Var fix

  • Loading branch information...
1 parent 22e3af4 commit aed21d65350140871d0f0d5607959b293280bf12 @fglock committed Nov 28, 2012
Showing with 36 additions and 20 deletions.
  1. +5 −4 html/perlito5.js
  2. +2 −2 perlito5.pl
  3. +5 −4 src5/lib/Perlito5/Javascript2/Runtime.pm
  4. +24 −10 src5/lib/Perlito5/Javascript3/Runtime.pm
View
@@ -196,7 +196,7 @@ function p5scalar_deref(v) {
}
var c = v.charCodeAt(0);
if (c < 27) {
- v = '^' + String.fromCharCode(c + 64) + v.substr(1);
+ v = String.fromCharCode(c + 64) + v.substr(1);
pkg_name = 'main';
}
return p5pkg[pkg_name]["v_"+v];
@@ -216,7 +216,7 @@ function p5scalar_deref_set(v, n) {
}
var c = v.charCodeAt(0);
if (c < 27) {
- v = '^' + String.fromCharCode(c + 64) + v.substr(1);
+ v = String.fromCharCode(c + 64) + v.substr(1);
pkg_name = 'main';
}
p5pkg[pkg_name]["v_"+v] = n;
@@ -227,10 +227,12 @@ function p5scalar_deref_set(v, n) {
}
p5make_package("main");
+p5make_package("Perlito5");
+p5pkg["Perlito5"].v_PKG_NAME = "main";
p5pkg["main"]["v_@"] = []; // $@
p5pkg["main"]["v_|"] = 0; // $|
p5pkg["main"]["List_#"] = []; // @#
-p5pkg["main"]["v_^O"] = isNode ? "node.js" : "javascript2";
+p5scalar_deref_set(String.fromCharCode(15), isNode ? "node.js" : "javascript2"); // $^O
p5pkg["main"]["List_INC"] = [];
p5pkg["main"]["Hash_INC"] = {};
p5pkg["main"]["List_ARGV"] = [];
@@ -246,7 +248,6 @@ if (isNode) {
p5pkg["main"]["List_ARGV"] = arguments;
}
-p5make_package("Perlito5");
p5make_package("Perlito5::IO");
p5make_package("Perlito5::Runtime");
p5make_package("Perlito5::Grammar");
View
Oops, something went wrong.
@@ -202,7 +202,7 @@ function p5scalar_deref(v) {
}
var c = v.charCodeAt(0);
if (c < 27) {
- v = '^' + String.fromCharCode(c + 64) + v.substr(1);
+ v = String.fromCharCode(c + 64) + v.substr(1);
pkg_name = 'main';
}
return p5pkg[pkg_name]["v_"+v];
@@ -222,7 +222,7 @@ function p5scalar_deref_set(v, n) {
}
var c = v.charCodeAt(0);
if (c < 27) {
- v = '^' + String.fromCharCode(c + 64) + v.substr(1);
+ v = String.fromCharCode(c + 64) + v.substr(1);
pkg_name = 'main';
}
p5pkg[pkg_name]["v_"+v] = n;
@@ -233,10 +233,12 @@ function p5scalar_deref_set(v, n) {
}
p5make_package("main");
+p5make_package("Perlito5");
+p5pkg["Perlito5"].v_PKG_NAME = "main";
p5pkg["main"]["v_@"] = []; // $@
p5pkg["main"]["v_|"] = 0; // $|
p5pkg["main"]["List_#"] = []; // @#
-p5pkg["main"]["v_^O"] = isNode ? "node.js" : "javascript2";
+p5scalar_deref_set(String.fromCharCode(15), isNode ? "node.js" : "javascript2"); // $^O
p5pkg["main"]["List_INC"] = [];
p5pkg["main"]["Hash_INC"] = {};
p5pkg["main"]["List_ARGV"] = [];
@@ -252,7 +254,6 @@ if (isNode) {
p5pkg["main"]["List_ARGV"] = arguments;
}
-p5make_package("Perlito5");
p5make_package("Perlito5::IO");
p5make_package("Perlito5::Runtime");
p5make_package("Perlito5::Grammar");
@@ -210,11 +210,18 @@ function p5scalar_deref(v) {
if (typeof v === "string") {
var pkg_name = v.split(/::/);
if (pkg_name.length > 1) {
- var name = pkg_name.pop();
+ v = pkg_name.pop();
pkg_name = pkg_name.join("::");
- return p5pkg[pkg_name]["v_"+name];
}
- return p5pkg[p5pkg["Perlito5"].v_PKG_NAME]["v_"+v];
+ else {
+ pkg_name = p5pkg["Perlito5"].v_PKG_NAME;
+ }
+ var c = v.charCodeAt(0);
+ if (c < 27) {
+ v = String.fromCharCode(c + 64) + v.substr(1);
+ pkg_name = 'main';
+ }
+ return p5pkg[pkg_name]["v_"+v];
}
return v._scalar_;
}
@@ -223,23 +230,31 @@ function p5scalar_deref_set(v, n) {
if (typeof v === "string") {
var pkg_name = v.split(/::/);
if (pkg_name.length > 1) {
- var name = pkg_name.pop();
+ v = pkg_name.pop();
pkg_name = pkg_name.join("::");
- p5pkg[pkg_name]["v_"+name] = n;
- return p5pkg[pkg_name]["v_"+name];
}
- p5pkg[p5pkg["Perlito5"].v_PKG_NAME]["v_"+v] = n;
- return p5pkg[p5pkg["Perlito5"].v_PKG_NAME]["v_"+v];
+ else {
+ pkg_name = p5pkg["Perlito5"].v_PKG_NAME;
+ }
+ var c = v.charCodeAt(0);
+ if (c < 27) {
+ v = String.fromCharCode(c + 64) + v.substr(1);
+ pkg_name = 'main';
+ }
+ p5pkg[pkg_name]["v_"+v] = n;
+ return p5pkg[pkg_name]["v_"+v];
}
v._scalar_ = n;
return v._scalar_;
}
p5make_package("main");
+p5make_package("Perlito5");
+p5pkg["Perlito5"].v_PKG_NAME = "main";
p5pkg["main"]["v_@"] = new p5Scalar(""); // $@
p5pkg["main"]["v_|"] = new p5Scalar(0); // $|
p5pkg["main"]["List_#"] = new p5Array([]); // @#
-p5pkg["main"]["v_^O"] = new p5Scalar(isNode ? "node.js" : "javascript3");
+p5scalar_deref_set(String.fromCharCode(15), isNode ? "node.js" : "javascript2"); // $^O
p5pkg["main"]["List_INC"] = new p5Array([]);
p5pkg["main"]["Hash_INC"] = new p5Hash({});
p5pkg["main"]["List_ARGV"] = new p5Array([]);
@@ -252,7 +267,6 @@ if (isNode) {
p5pkg["main"]["List_ARGV"] = new p5Array(arguments);
}
-p5make_package("Perlito5");
p5make_package("Perlito5::IO");
p5make_package("Perlito5::Runtime");
p5make_package("Perlito5::Grammar");

0 comments on commit aed21d6

Please sign in to comment.