Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: frog/leg/ssa/js_names.dart

Issue 9873021: Move frog/leg to lib/compiler/implementation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « frog/leg/ssa/codegen_helpers.dart ('k') | frog/leg/ssa/nodes.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 class JsNames {
6 static final javaScriptKeywords = const <String>[
7 // These are current keywords
8 "break", "delete", "function", "return", "typeof", "case", "do", "if",
9 "switch", "var", "catch", "else", "in", "this", "void", "continue",
10 "false", "instanceof", "throw", "while", "debugger", "finally", "new",
11 "true", "with", "default", "for", "null", "try",
12
13 // These are future keywords
14 "abstract", "double", "goto", "native", "static", "boolean", "enum",
15 "implements", "package", "super", "byte", "export", "import", "private",
16 "synchronized", "char", "extends", "int", "protected", "throws",
17 "class", "final", "interface", "public", "transient", "const", "float",
18 "long", "short", "volatile"
19 ];
20
21 static final reservedGlobalSymbols = const <String>[
22 // Section references are from Ecma-262
23 // (http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pd f)
24
25 // 15.1.1 Value Properties of the Global Object
26 "NaN", "Infinity", "undefined",
27
28 // 15.1.2 Function Properties of the Global Object
29 "eval", "parseInt", "parseFloat", "isNan", "isFinite",
30
31 // 15.1.3 URI Handling Function Properties
32 "decodeURI", "decodeURIComponent",
33 "encodeURI",
34 "encodeURIComponent",
35
36 // 15.1.4 Constructor Properties of the Global Object
37 "Object", "Function", "Array", "String", "Boolean", "Number", "Date",
38 "RegExp", "Error", "EvalError", "RangeError", "ReferenceError",
39 "SyntaxError", "TypeError", "URIError",
40
41 // 15.1.5 Other Properties of the Global Object
42 "Math",
43
44 // 10.1.6 Activation Object
45 "arguments",
46
47 // B.2 Additional Properties (non-normative)
48 "escape", "unescape",
49
50 // Window props (https://developer.mozilla.org/en/DOM/window)
51 "applicationCache", "closed", "Components", "content", "controllers",
52 "crypto", "defaultStatus", "dialogArguments", "directories",
53 "document", "frameElement", "frames", "fullScreen", "globalStorage",
54 "history", "innerHeight", "innerWidth", "length",
55 "location", "locationbar", "localStorage", "menubar",
56 "mozInnerScreenX", "mozInnerScreenY", "mozScreenPixelsPerCssPixel",
57 "name", "navigator", "opener", "outerHeight", "outerWidth",
58 "pageXOffset", "pageYOffset", "parent", "personalbar", "pkcs11",
59 "returnValue", "screen", "scrollbars", "scrollMaxX", "scrollMaxY",
60 "self", "sessionStorage", "sidebar", "status", "statusbar", "toolbar",
61 "top", "window",
62
63 // Window methods (https://developer.mozilla.org/en/DOM/window)
64 "alert", "addEventListener", "atob", "back", "blur", "btoa",
65 "captureEvents", "clearInterval", "clearTimeout", "close", "confirm",
66 "disableExternalCapture", "dispatchEvent", "dump",
67 "enableExternalCapture", "escape", "find", "focus", "forward",
68 "GeckoActiveXObject", "getAttention", "getAttentionWithCycleCount",
69 "getComputedStyle", "getSelection", "home", "maximize", "minimize",
70 "moveBy", "moveTo", "open", "openDialog", "postMessage", "print",
71 "prompt", "QueryInterface", "releaseEvents", "removeEventListener",
72 "resizeBy", "resizeTo", "restore", "routeEvent", "scroll", "scrollBy",
73 "scrollByLines", "scrollByPages", "scrollTo", "setInterval",
74 "setResizeable", "setTimeout", "showModalDialog", "sizeToContent",
75 "stop", "uuescape", "updateCommands", "XPCNativeWrapper",
76 "XPCSafeJSOjbectWrapper",
77
78 // Mozilla Window event handlers, same cite
79 "onabort", "onbeforeunload", "onchange", "onclick", "onclose",
80 "oncontextmenu", "ondragdrop", "onerror", "onfocus", "onhashchange",
81 "onkeydown", "onkeypress", "onkeyup", "onload", "onmousedown",
82 "onmousemove", "onmouseout", "onmouseover", "onmouseup",
83 "onmozorientation", "onpaint", "onreset", "onresize", "onscroll",
84 "onselect", "onsubmit", "onunload",
85
86 // Safari Web Content Guide
87 // http://developer.apple.com/library/safari/#documentation/AppleApplication s/Reference/SafariWebContent/SafariWebContent.pdf
88 // WebKit Window member data, from WebKit DOM Reference
89 // (http://developer.apple.com/safari/library/documentation/AppleApplication s/Reference/WebKitDOMRef/DOMWindow_idl/Classes/DOMWindow/index.html)
90 "ontouchcancel", "ontouchend", "ontouchmove", "ontouchstart",
91 "ongesturestart", "ongesturechange", "ongestureend",
92
93 // extra window methods
94 "uneval",
95
96 // keywords https://developer.mozilla.org/en/New_in_JavaScript_1.7,
97 // https://developer.mozilla.org/en/New_in_JavaScript_1.8.1
98 "getPrototypeOf", "let", "yield",
99
100 // "future reserved words"
101 "abstract", "int", "short", "boolean", "interface", "static", "byte",
102 "long", "char", "final", "native", "synchronized", "float", "package",
103 "throws", "goto", "private", "transient", "implements", "protected",
104 "volatile", "double", "public",
105
106 // IE methods
107 // (http://msdn.microsoft.com/en-us/library/ms535873(VS.85).aspx#)
108 "attachEvent", "clientInformation", "clipboardData", "createPopup",
109 "dialogHeight", "dialogLeft", "dialogTop", "dialogWidth",
110 "onafterprint", "onbeforedeactivate", "onbeforeprint",
111 "oncontrolselect", "ondeactivate", "onhelp", "onresizeend",
112
113 // Common browser-defined identifiers not defined in ECMAScript
114 "event", "external", "Debug", "Enumerator", "Global", "Image",
115 "ActiveXObject", "VBArray", "Components",
116
117 // Functions commonly defined on Object
118 "toString", "getClass", "constructor", "prototype", "valueOf",
119
120 // Client-side JavaScript identifiers, which are needed for linkers
121 // that don't ensure GWT's window != $wnd, document != $doc, etc.
122 // Taken from the Rhino book, pg 715
123 "Anchor", "Applet", "Attr", "Canvas", "CanvasGradient",
124 "CanvasPattern", "CanvasRenderingContext2D", "CDATASection",
125 "CharacterData", "Comment", "CSS2Properties", "CSSRule",
126 "CSSStyleSheet", "Document", "DocumentFragment", "DocumentType",
127 "DOMException", "DOMImplementation", "DOMParser", "Element", "Event",
128 "ExternalInterface", "FlashPlayer", "Form", "Frame", "History",
129 "HTMLCollection", "HTMLDocument", "HTMLElement", "IFrame", "Image",
130 "Input", "JSObject", "KeyEvent", "Link", "Location", "MimeType",
131 "MouseEvent", "Navigator", "Node", "NodeList", "Option", "Plugin",
132 "ProcessingInstruction", "Range", "RangeException", "Screen", "Select",
133 "Table", "TableCell", "TableRow", "TableSelection", "Text", "TextArea",
134 "UIEvent", "Window", "XMLHttpRequest", "XMLSerializer",
135 "XPathException", "XPathResult", "XSLTProcessor",
136
137 // These keywords trigger the loading of the java-plugin. For the
138 // next-generation plugin, this results in starting a new Java process.
139 "java", "Packages", "netscape", "sun", "JavaObject", "JavaClass",
140 "JavaArray", "JavaMember",
141
142 // GWT-defined identifiers
143 "\$wnd", "\$doc", "\$entry", "\$moduleName", "\$moduleBase",
144 "\$gwt_version", "\$sessionId",
145
146 // Identifiers used by JsStackEmulator; later set to obfuscatable
147 "\$stack", "\$stackDepth", "\$location",
148
149 // TODO: prove why this is necessary or remove it
150 "call"
151 ];
152
153 static final reservedPropertySymbols =
154 const <String>["__PROTO__", "prototype", "constructor"];
155
156 static Set<String> _reserved;
157
158 static Set<String> get reserved() {
159 if (_reserved === null) {
160 _reserved = new Set<String>();
161 _reserved.addAll(reservedPropertySymbols);
162 _reserved.addAll(reservedGlobalSymbols);
163 _reserved.addAll(javaScriptKeywords);
164 }
165 return _reserved;
166 }
167
168 // TODO(ngeoffray): only the namer should call this method.
169 // Eventually move it there.
170 /*
171 * Returns a name that does not clash with reserved JS keywords,
172 * and also ensures it won't clash with other identifiers.
173 */
174 static String getValid(String name) {
175 if (reserved.contains(name)) {
176 name = '$name\$';
177 assert(!reserved.contains(name));
178 } else if (name.contains(@'$')) {
179 name = name.replaceAll(@'$', @'$$');
180 }
181 return name;
182 }
183 }
OLDNEW
« no previous file with comments | « frog/leg/ssa/codegen_helpers.dart ('k') | frog/leg/ssa/nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698