Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Perlito5 - js2 - caret Var fix

  • Loading branch information...
commit aed21d65350140871d0f0d5607959b293280bf12 1 parent 22e3af4
Flavio S. Glock authored
9 html/perlito5.js
@@ -196,7 +196,7 @@ function p5scalar_deref(v) {
196 196 }
197 197 var c = v.charCodeAt(0);
198 198 if (c < 27) {
199   - v = '^' + String.fromCharCode(c + 64) + v.substr(1);
  199 + v = String.fromCharCode(c + 64) + v.substr(1);
200 200 pkg_name = 'main';
201 201 }
202 202 return p5pkg[pkg_name]["v_"+v];
@@ -216,7 +216,7 @@ function p5scalar_deref_set(v, n) {
216 216 }
217 217 var c = v.charCodeAt(0);
218 218 if (c < 27) {
219   - v = '^' + String.fromCharCode(c + 64) + v.substr(1);
  219 + v = String.fromCharCode(c + 64) + v.substr(1);
220 220 pkg_name = 'main';
221 221 }
222 222 p5pkg[pkg_name]["v_"+v] = n;
@@ -227,10 +227,12 @@ function p5scalar_deref_set(v, n) {
227 227 }
228 228
229 229 p5make_package("main");
  230 +p5make_package("Perlito5");
  231 +p5pkg["Perlito5"].v_PKG_NAME = "main";
230 232 p5pkg["main"]["v_@"] = []; // $@
231 233 p5pkg["main"]["v_|"] = 0; // $|
232 234 p5pkg["main"]["List_#"] = []; // @#
233   -p5pkg["main"]["v_^O"] = isNode ? "node.js" : "javascript2";
  235 +p5scalar_deref_set(String.fromCharCode(15), isNode ? "node.js" : "javascript2"); // $^O
234 236 p5pkg["main"]["List_INC"] = [];
235 237 p5pkg["main"]["Hash_INC"] = {};
236 238 p5pkg["main"]["List_ARGV"] = [];
@@ -246,7 +248,6 @@ if (isNode) {
246 248 p5pkg["main"]["List_ARGV"] = arguments;
247 249 }
248 250
249   -p5make_package("Perlito5");
250 251 p5make_package("Perlito5::IO");
251 252 p5make_package("Perlito5::Runtime");
252 253 p5make_package("Perlito5::Grammar");
4 perlito5.pl
2 additions, 2 deletions not shown
9 src5/lib/Perlito5/Javascript2/Runtime.pm
@@ -202,7 +202,7 @@ function p5scalar_deref(v) {
202 202 }
203 203 var c = v.charCodeAt(0);
204 204 if (c < 27) {
205   - v = '^' + String.fromCharCode(c + 64) + v.substr(1);
  205 + v = String.fromCharCode(c + 64) + v.substr(1);
206 206 pkg_name = 'main';
207 207 }
208 208 return p5pkg[pkg_name]["v_"+v];
@@ -222,7 +222,7 @@ function p5scalar_deref_set(v, n) {
222 222 }
223 223 var c = v.charCodeAt(0);
224 224 if (c < 27) {
225   - v = '^' + String.fromCharCode(c + 64) + v.substr(1);
  225 + v = String.fromCharCode(c + 64) + v.substr(1);
226 226 pkg_name = 'main';
227 227 }
228 228 p5pkg[pkg_name]["v_"+v] = n;
@@ -233,10 +233,12 @@ function p5scalar_deref_set(v, n) {
233 233 }
234 234
235 235 p5make_package("main");
  236 +p5make_package("Perlito5");
  237 +p5pkg["Perlito5"].v_PKG_NAME = "main";
236 238 p5pkg["main"]["v_@"] = []; // $@
237 239 p5pkg["main"]["v_|"] = 0; // $|
238 240 p5pkg["main"]["List_#"] = []; // @#
239   -p5pkg["main"]["v_^O"] = isNode ? "node.js" : "javascript2";
  241 +p5scalar_deref_set(String.fromCharCode(15), isNode ? "node.js" : "javascript2"); // $^O
240 242 p5pkg["main"]["List_INC"] = [];
241 243 p5pkg["main"]["Hash_INC"] = {};
242 244 p5pkg["main"]["List_ARGV"] = [];
@@ -252,7 +254,6 @@ if (isNode) {
252 254 p5pkg["main"]["List_ARGV"] = arguments;
253 255 }
254 256
255   -p5make_package("Perlito5");
256 257 p5make_package("Perlito5::IO");
257 258 p5make_package("Perlito5::Runtime");
258 259 p5make_package("Perlito5::Grammar");
34 src5/lib/Perlito5/Javascript3/Runtime.pm
@@ -210,11 +210,18 @@ function p5scalar_deref(v) {
210 210 if (typeof v === "string") {
211 211 var pkg_name = v.split(/::/);
212 212 if (pkg_name.length > 1) {
213   - var name = pkg_name.pop();
  213 + v = pkg_name.pop();
214 214 pkg_name = pkg_name.join("::");
215   - return p5pkg[pkg_name]["v_"+name];
216 215 }
217   - return p5pkg[p5pkg["Perlito5"].v_PKG_NAME]["v_"+v];
  216 + else {
  217 + pkg_name = p5pkg["Perlito5"].v_PKG_NAME;
  218 + }
  219 + var c = v.charCodeAt(0);
  220 + if (c < 27) {
  221 + v = String.fromCharCode(c + 64) + v.substr(1);
  222 + pkg_name = 'main';
  223 + }
  224 + return p5pkg[pkg_name]["v_"+v];
218 225 }
219 226 return v._scalar_;
220 227 }
@@ -223,23 +230,31 @@ function p5scalar_deref_set(v, n) {
223 230 if (typeof v === "string") {
224 231 var pkg_name = v.split(/::/);
225 232 if (pkg_name.length > 1) {
226   - var name = pkg_name.pop();
  233 + v = pkg_name.pop();
227 234 pkg_name = pkg_name.join("::");
228   - p5pkg[pkg_name]["v_"+name] = n;
229   - return p5pkg[pkg_name]["v_"+name];
230 235 }
231   - p5pkg[p5pkg["Perlito5"].v_PKG_NAME]["v_"+v] = n;
232   - return p5pkg[p5pkg["Perlito5"].v_PKG_NAME]["v_"+v];
  236 + else {
  237 + pkg_name = p5pkg["Perlito5"].v_PKG_NAME;
  238 + }
  239 + var c = v.charCodeAt(0);
  240 + if (c < 27) {
  241 + v = String.fromCharCode(c + 64) + v.substr(1);
  242 + pkg_name = 'main';
  243 + }
  244 + p5pkg[pkg_name]["v_"+v] = n;
  245 + return p5pkg[pkg_name]["v_"+v];
233 246 }
234 247 v._scalar_ = n;
235 248 return v._scalar_;
236 249 }
237 250
238 251 p5make_package("main");
  252 +p5make_package("Perlito5");
  253 +p5pkg["Perlito5"].v_PKG_NAME = "main";
239 254 p5pkg["main"]["v_@"] = new p5Scalar(""); // $@
240 255 p5pkg["main"]["v_|"] = new p5Scalar(0); // $|
241 256 p5pkg["main"]["List_#"] = new p5Array([]); // @#
242   -p5pkg["main"]["v_^O"] = new p5Scalar(isNode ? "node.js" : "javascript3");
  257 +p5scalar_deref_set(String.fromCharCode(15), isNode ? "node.js" : "javascript2"); // $^O
243 258 p5pkg["main"]["List_INC"] = new p5Array([]);
244 259 p5pkg["main"]["Hash_INC"] = new p5Hash({});
245 260 p5pkg["main"]["List_ARGV"] = new p5Array([]);
@@ -252,7 +267,6 @@ if (isNode) {
252 267 p5pkg["main"]["List_ARGV"] = new p5Array(arguments);
253 268 }
254 269
255   -p5make_package("Perlito5");
256 270 p5make_package("Perlito5::IO");
257 271 p5make_package("Perlito5::Runtime");
258 272 p5make_package("Perlito5::Grammar");

0 comments on commit aed21d6

Please sign in to comment.
Something went wrong with that request. Please try again.