yet another small cleanup and obscure bugfix related to #2333
This commit is contained in:
parent
1810d9f318
commit
df54c63b1b
|
@ -1,6 +1,6 @@
|
|||
// Generated by CoffeeScript 1.3.3
|
||||
(function() {
|
||||
var extend, flatten, _ref;
|
||||
var extend, flatten;
|
||||
|
||||
exports.starts = function(string, literal, start) {
|
||||
return literal === string.substr(start, literal.length);
|
||||
|
@ -74,15 +74,4 @@
|
|||
return array[array.length - (back || 0) - 1];
|
||||
};
|
||||
|
||||
exports.some = (_ref = Array.prototype.some) != null ? _ref : function(fn) {
|
||||
var e, _i, _len;
|
||||
for (_i = 0, _len = this.length; _i < _len; _i++) {
|
||||
e = this[_i];
|
||||
if (fn(e)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
|
|
@ -1176,7 +1176,7 @@
|
|||
props = this.properties;
|
||||
propNames = [];
|
||||
normaliseString = function(s) {
|
||||
var octalNormalised, quoteNormalised;
|
||||
var escapeNormalised, quoteNormalised;
|
||||
quoteNormalised = (function() {
|
||||
switch (s[0]) {
|
||||
case '"':
|
||||
|
@ -1185,11 +1185,13 @@
|
|||
return s.slice(1, -1).replace(/\\'/g, "'");
|
||||
}
|
||||
})();
|
||||
octalNormalised = quoteNormalised.replace(/\\([0abtnvfr\n\\])/, function(match, c) {
|
||||
var map;
|
||||
map = {
|
||||
escapeNormalised = quoteNormalised.replace(/\\x([0-9a-f]{2})|\\u([0-9a-f]{4})/ig, function(match, h, u) {
|
||||
return String.fromCharCode(parseInt(h != null ? h : u, 16));
|
||||
});
|
||||
return escapeNormalised.replace(/\\([\s\S])/g, function(match, c) {
|
||||
var _ref2;
|
||||
return (_ref2 = {
|
||||
0: "\0",
|
||||
a: "\a",
|
||||
b: "\b",
|
||||
t: "\t",
|
||||
n: "\n",
|
||||
|
@ -1198,11 +1200,7 @@
|
|||
r: "\r",
|
||||
"\\": "\\",
|
||||
"\n": ""
|
||||
};
|
||||
return map[c];
|
||||
});
|
||||
return octalNormalised.replace(/\\x([0-9a-f]{2})|\\u([0-9a-f]{4})/i, function(match, h, u) {
|
||||
return String.fromCharCode(parseInt(h != null ? h : u, 16));
|
||||
}[c]) != null ? _ref2 : c;
|
||||
});
|
||||
};
|
||||
isDuplicate = function(x) {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Generated by CoffeeScript 1.3.3
|
||||
(function() {
|
||||
var ACCESSOR, CoffeeScript, Module, REPL_PROMPT, REPL_PROMPT_CONTINUATION, REPL_PROMPT_MULTILINE, SIMPLEVAR, Script, autocomplete, backlog, completeAttribute, completeVariable, enableColours, error, getCompletions, inspect, multilineMode, pipedInput, readline, repl, run, stdin, stdout,
|
||||
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
||||
var ACCESSOR, CoffeeScript, Module, REPL_PROMPT, REPL_PROMPT_CONTINUATION, REPL_PROMPT_MULTILINE, SIMPLEVAR, Script, autocomplete, backlog, completeAttribute, completeVariable, enableColours, error, getCompletions, inspect, multilineMode, pipedInput, readline, repl, run, stdin, stdout;
|
||||
|
||||
stdin = process.openStdin();
|
||||
|
||||
|
@ -42,35 +41,28 @@
|
|||
};
|
||||
|
||||
completeAttribute = function(text) {
|
||||
var all, candidates, completions, key, match, obj, prefix, _i, _len, _ref;
|
||||
var all, completions, key, match, obj, possibilities, prefix, val;
|
||||
if (match = text.match(ACCESSOR)) {
|
||||
all = match[0], obj = match[1], prefix = match[2];
|
||||
try {
|
||||
obj = Script.runInThisContext(obj);
|
||||
} catch (e) {
|
||||
val = Script.runInThisContext(obj);
|
||||
} catch (error) {
|
||||
return;
|
||||
}
|
||||
if (obj == null) {
|
||||
return;
|
||||
}
|
||||
obj = Object(obj);
|
||||
candidates = Object.getOwnPropertyNames(obj);
|
||||
while (obj = Object.getPrototypeOf(obj)) {
|
||||
_ref = Object.getOwnPropertyNames(obj);
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
key = _ref[_i];
|
||||
if (__indexOf.call(candidates, key) < 0) {
|
||||
candidates.push(key);
|
||||
}
|
||||
val = Object(val);
|
||||
possibilities = Object.getOwnPropertyNames(val);
|
||||
for (key in val) {
|
||||
if (~possibilities.indexOf(val)) {
|
||||
possibilities.push(key);
|
||||
}
|
||||
}
|
||||
completions = getCompletions(prefix, candidates);
|
||||
completions = getCompletions(prefix, possibilities);
|
||||
return [completions, prefix];
|
||||
}
|
||||
};
|
||||
|
||||
completeVariable = function(text) {
|
||||
var candidates, completions, free, key, keywords, r, vars, _i, _len, _ref;
|
||||
var completions, free, keywords, possibilities, r, vars, _ref;
|
||||
free = (_ref = text.match(SIMPLEVAR)) != null ? _ref[1] : void 0;
|
||||
if (text === "") {
|
||||
free = "";
|
||||
|
@ -89,14 +81,8 @@
|
|||
}
|
||||
return _results;
|
||||
})();
|
||||
candidates = vars;
|
||||
for (_i = 0, _len = keywords.length; _i < _len; _i++) {
|
||||
key = keywords[_i];
|
||||
if (__indexOf.call(candidates, key) < 0) {
|
||||
candidates.push(key);
|
||||
}
|
||||
}
|
||||
completions = getCompletions(free, candidates);
|
||||
possibilities = vars.concat(keywords);
|
||||
completions = getCompletions(free, possibilities);
|
||||
return [completions, free];
|
||||
}
|
||||
};
|
||||
|
@ -106,7 +92,7 @@
|
|||
_results = [];
|
||||
for (_i = 0, _len = candidates.length; _i < _len; _i++) {
|
||||
el = candidates[_i];
|
||||
if (0 === el.indexOf(prefix)) {
|
||||
if (el.indexOf(prefix) === 0) {
|
||||
_results.push(el);
|
||||
}
|
||||
}
|
||||
|
@ -251,12 +237,11 @@
|
|||
repl._onLine(repl.line);
|
||||
return;
|
||||
}
|
||||
if (backlog || repl.line) {
|
||||
if (backlog) {
|
||||
backlog = '';
|
||||
repl.historyIndex = -1;
|
||||
repl.output.write('\n');
|
||||
repl.setPrompt(REPL_PROMPT);
|
||||
repl.output.write('\n(^C again to quit)');
|
||||
return repl._line((repl.line = ''));
|
||||
return repl.prompt();
|
||||
} else {
|
||||
return repl.close();
|
||||
}
|
||||
|
|
|
@ -806,13 +806,10 @@ exports.Obj = class Obj extends Base
|
|||
quoteNormalised = switch s[0]
|
||||
when '"' then s[1...-1].replace /\\"/g, '"'
|
||||
when "'" then s[1...-1].replace /\\'/g, "'"
|
||||
octalNormalised = quoteNormalised.replace /\\([0abtnvfr\n\\])/, (match, c) ->
|
||||
map =
|
||||
0:"\0", a:"\a", b:"\b", t:"\t", n:"\n", v:"\v",
|
||||
f:"\f", r:"\r", "\\":"\\", "\n":""
|
||||
map[c]
|
||||
octalNormalised.replace /\\x([0-9a-f]{2})|\\u([0-9a-f]{4})/i, (match, h, u) ->
|
||||
escapeNormalised = quoteNormalised.replace /\\x([0-9a-f]{2})|\\u([0-9a-f]{4})/ig, (match, h, u) ->
|
||||
String.fromCharCode parseInt (h ? u), 16
|
||||
escapeNormalised.replace /\\([\s\S])/g, (match, c) ->
|
||||
{0:"\0", b:"\b", t:"\t", n:"\n", v:"\v", f:"\f", r:"\r", "\\":"\\", "\n":""}[c] ? c
|
||||
isDuplicate = (x) ->
|
||||
mx = x.match /^['"]/
|
||||
(y) ->
|
||||
|
|
|
@ -70,10 +70,13 @@ test "#2333: more duplicate property prohibitions", ->
|
|||
strict '{.1:0, 1e-1:0}'
|
||||
strict '{100:0, 1e2:0}'
|
||||
strict '{"\\0":0, "\\x00":0}'
|
||||
strict '{"\\n":0, "\\x0A":0}'
|
||||
strict '{"\\a", "\\u0061"}'
|
||||
strict '{"\\t":0, "\\x09":0}'
|
||||
strict '{"c":0, "\\c":0}'
|
||||
strict '{"\\\\":0, "\\x5c":0}'
|
||||
strict "{'\n0':0, 0:0}"
|
||||
strict '{"\n0":0, 0:0}'
|
||||
strict "{'\\\n0':0, 0:0}"
|
||||
strict '{"\\\n0":0, "\\x00":0}'
|
||||
strict 'a = 0; {a, "a":0}'
|
||||
strict "{'\\'a':0, \"'a\":0}"
|
||||
strict "{'\\\\a':0, '\\\\a':0}"
|
||||
|
|
Loading…
Reference in New Issue