Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011, the Dart project authors. All rights reserved. | 1 // Copyright 2011, the Dart project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 * Returns the JsName for the given element. If the element is global and | 55 * Returns the JsName for the given element. If the element is global and |
| 56 * hasn't been declared yet, it is done now. | 56 * hasn't been declared yet, it is done now. |
| 57 */ | 57 */ |
| 58 JsName getName(Symbol symbol) { | 58 JsName getName(Symbol symbol) { |
| 59 JsName jsName = names.get(symbol); | 59 JsName jsName = names.get(symbol); |
| 60 if (jsName != null) { | 60 if (jsName != null) { |
| 61 assert !jsName.getShortIdent().equals("Object$Dart"); | 61 assert !jsName.getShortIdent().equals("Object$Dart"); |
| 62 return jsName; | 62 return jsName; |
| 63 } | 63 } |
| 64 assert ElementKind.of(symbol).equals(ElementKind.CLASS) | 64 assert ElementKind.of(symbol).equals(ElementKind.CLASS) |
| 65 : "Only classes can be lazily declared. Undeclared: " | 65 || ElementKind.of(symbol).equals(ElementKind.FUNCTION_TYPE_ALIAS) : "Onl y classes or typedefs can be lazily declared. Undeclared: " |
|
zundel
2011/11/16 22:17:15
> 100 chars
codefu
2011/11/16 22:39:55
I ran the formatter on this one only to have to sc
| |
| 66 + symbol.getOriginalSymbolName(); | 66 + symbol.getOriginalSymbolName(); |
| 67 ClassElement classElement = (ClassElement) symbol; | 67 ClassElement classElement = (ClassElement) symbol; |
| 68 String name = classElement.getName(); | 68 String name = classElement.getName(); |
| 69 String nativeName = classElement.getNativeName(); | 69 String nativeName = classElement.getNativeName(); |
| 70 if (nativeName == null) { | 70 if (nativeName == null) { |
| 71 String mangledClassName = mangler.mangleClassName(classElement); | 71 String mangledClassName = mangler.mangleClassName(classElement); |
| 72 jsName = globalScope.declareName(mangledClassName, mangledClassName, name) ; | 72 jsName = globalScope.declareName(mangledClassName, mangledClassName, name) ; |
| 73 } else { | 73 } else { |
| 74 jsName = globalScope.declareName(nativeName); | 74 jsName = globalScope.declareName(nativeName); |
| 75 } | 75 } |
| 76 // Class names are globally accessible. | 76 // Class names are globally accessible. |
| 77 jsName.setObfuscatable(false); | 77 jsName.setObfuscatable(false); |
| 78 names.put(symbol, jsName); | 78 names.put(symbol, jsName); |
| 79 assert !jsName.getShortIdent().equals("Object$Dart") : "unexpected " + ((Cla ssElement) symbol).getNode().getSource().getName(); | 79 assert !jsName.getShortIdent().equals("Object$Dart") : "unexpected " + ((Cla ssElement) symbol).getNode().getSource().getName(); |
| 80 return jsName; | 80 return jsName; |
| 81 } | 81 } |
| 82 | 82 |
| 83 void setName(Symbol symbol, JsName name) { | 83 void setName(Symbol symbol, JsName name) { |
| 84 names.put(symbol, name); | 84 names.put(symbol, name); |
| 85 } | 85 } |
| 86 } | 86 } |
| OLD | NEW |