@@ -59,6 +59,8 @@ import '../metadata/direct_call.dart'
5959 show DirectCallMetadata, DirectCallMetadataRepository;
6060import '../metadata/inferred_type.dart'
6161 show InferredType, InferredTypeMetadataRepository;
62+ import '../metadata/obfuscation_prohibitions.dart'
63+ show ObfuscationProhibitionsMetadataRepository;
6264import '../metadata/procedure_attributes.dart'
6365 show ProcedureAttributesMetadata, ProcedureAttributesMetadataRepository;
6466
@@ -193,6 +195,14 @@ class BytecodeGenerator extends RecursiveVisitor<Null> {
193195
194196 inferredTypeMetadata = component
195197 .metadata[InferredTypeMetadataRepository .repositoryTag]? .mapping;
198+
199+ final obfuscationProhibitionsMetadataRepository = component
200+ .metadata[ObfuscationProhibitionsMetadataRepository .repositoryTag];
201+ if (obfuscationProhibitionsMetadataRepository != null ) {
202+ bytecodeComponent.protectedNames =
203+ obfuscationProhibitionsMetadataRepository
204+ .mapping[component]? .protectedNames;
205+ }
196206 }
197207
198208 @override
@@ -249,7 +259,7 @@ class BytecodeGenerator extends RecursiveVisitor<Null> {
249259 source = bytecodeComponent.uriToSource[uri];
250260 if (source == null ) {
251261 final importUri =
252- objectTable.getNameHandle ( null , astSource.importUri.toString ());
262+ objectTable.getConstStringHandle ( astSource.importUri.toString ());
253263 source = new SourceFile (importUri);
254264 bytecodeComponent.sourceFiles.add (source);
255265 bytecodeComponent.uriToSource[uri] = source;
@@ -276,7 +286,7 @@ class BytecodeGenerator extends RecursiveVisitor<Null> {
276286 LibraryDeclaration getLibraryDeclaration (
277287 Library library, List <ClassDeclaration > classes) {
278288 final importUri =
279- objectTable.getNameHandle ( null , library.importUri.toString ());
289+ objectTable.getConstStringHandle ( library.importUri.toString ());
280290 int flags = 0 ;
281291 for (var dependency in library.dependencies) {
282292 final targetLibrary = dependency.targetLibrary;
@@ -287,10 +297,10 @@ class BytecodeGenerator extends RecursiveVisitor<Null> {
287297 flags | = LibraryDeclaration .usesDartFfiFlag;
288298 }
289299 }
290- final name = objectTable.getNameHandle ( null , library.name ?? '' );
300+ final name = objectTable.getPublicNameHandle ( library.name ?? '' );
291301 final script = getScript (library.fileUri, true );
292302 final extensionUris =
293- objectTable.getPublicNameHandles (getNativeExtensionUris (library));
303+ objectTable.getConstStringHandles (getNativeExtensionUris (library));
294304 if (extensionUris.isNotEmpty) {
295305 flags | = LibraryDeclaration .hasExtensionsFlag;
296306 }
@@ -380,7 +390,7 @@ class BytecodeGenerator extends RecursiveVisitor<Null> {
380390 }
381391 }
382392
383- final nameHandle = objectTable.getNameHandle ( null , topLevelClassName);
393+ final nameHandle = objectTable.getPublicNameHandle ( topLevelClassName);
384394 final script = getScript (library.fileUri, true );
385395
386396 final classDeclaration = new ClassDeclaration (
@@ -710,7 +720,7 @@ class BytecodeGenerator extends RecursiveVisitor<Null> {
710720 flags | = FunctionDeclaration .isExternalFlag;
711721 } else {
712722 flags | = FunctionDeclaration .isNativeFlag;
713- nativeName = objectTable.getNameHandle ( null , externalName);
723+ nativeName = objectTable.getConstStringHandle ( externalName);
714724 }
715725 }
716726 int position = TreeNode .noOffset;
@@ -1825,7 +1835,7 @@ class BytecodeGenerator extends RecursiveVisitor<Null> {
18251835 assert (numOptionalNamed != 0 );
18261836 for (int i = 0 ; i < numOptionalNamed; i++ ) {
18271837 final param = locals.sortedNamedParameters[i];
1828- asm.emitLoadConstant (numFixed + i, cp.addString (param.name));
1838+ asm.emitLoadConstant (numFixed + i, cp.addName (param.name));
18291839 asm.emitLoadConstant (numFixed + i, _getDefaultParamConstIndex (param));
18301840 }
18311841 }
@@ -2030,7 +2040,7 @@ class BytecodeGenerator extends RecursiveVisitor<Null> {
20302040 isCaptured
20312041 ? locals.getVarIndexInContext (variable)
20322042 : locals.getVarIndexInFrame (variable),
2033- cp.addString (variable.name),
2043+ cp.addName (variable.name),
20342044 cp.addType (variable.type),
20352045 variable.fileOffset,
20362046 initializedPosition);
@@ -2276,7 +2286,7 @@ class BytecodeGenerator extends RecursiveVisitor<Null> {
22762286 _genPushInstantiatorAndFunctionTypeArguments ([type, bound]);
22772287 asm.emitPushConstant (cp.addType (type));
22782288 asm.emitPushConstant (cp.addType (bound));
2279- asm.emitPushConstant (cp.addString (typeParam.name));
2289+ asm.emitPushConstant (cp.addName (typeParam.name));
22802290 asm.emitAssertSubtype ();
22812291 }
22822292
@@ -2294,11 +2304,12 @@ class BytecodeGenerator extends RecursiveVisitor<Null> {
22942304 asm.emitDrop1 ();
22952305 }
22962306
2297- void _genAssertAssignable (DartType type, {String name = '' }) {
2307+ void _genAssertAssignable (DartType type, {String name, String message }) {
22982308 assert (! typeEnvironment.isTop (type));
22992309 asm.emitPushConstant (cp.addType (type));
23002310 _genPushInstantiatorAndFunctionTypeArguments ([type]);
2301- asm.emitPushConstant (cp.addString (name));
2311+ asm.emitPushConstant (
2312+ name != null ? cp.addName (name) : cp.addString (message));
23022313 bool isIntOk = typeEnvironment.isSubtypeOf (
23032314 typeEnvironment.coreTypes.intLegacyRawType,
23042315 type,
@@ -2451,11 +2462,11 @@ class BytecodeGenerator extends RecursiveVisitor<Null> {
24512462
24522463 final List <NameAndType > parameters = < NameAndType > [];
24532464 for (var v in function.positionalParameters) {
2454- parameters.add (new NameAndType (objectTable.getNameHandle ( null , v.name),
2465+ parameters.add (new NameAndType (objectTable.getPublicNameHandle ( v.name),
24552466 objectTable.getHandle (v.type)));
24562467 }
24572468 for (var v in function.namedParameters) {
2458- parameters.add (new NameAndType (objectTable.getNameHandle ( null , v.name),
2469+ parameters.add (new NameAndType (objectTable.getPublicNameHandle ( v.name),
24592470 objectTable.getHandle (v.type)));
24602471 }
24612472 if (function.requiredParameterCount != parameters.length) {
@@ -2475,7 +2486,7 @@ class BytecodeGenerator extends RecursiveVisitor<Null> {
24752486 return new ClosureDeclaration (
24762487 flags,
24772488 objectTable.getHandle (parent),
2478- objectTable.getNameHandle ( null , name),
2489+ objectTable.getPublicNameHandle ( name),
24792490 position,
24802491 endPosition,
24812492 typeParams,
@@ -2758,7 +2769,7 @@ class BytecodeGenerator extends RecursiveVisitor<Null> {
27582769 _genPushReceiver ();
27592770
27602771 // Argument 0 for _allocateInvocationMirror(): function name.
2761- asm.emitPushConstant (cp.addString (name));
2772+ asm.emitPushConstant (cp.addName (name));
27622773
27632774 // Argument 1 for _allocateInvocationMirror(): arguments descriptor.
27642775 asm.emitPushConstant (argDescCpIndex);
@@ -2791,7 +2802,8 @@ class BytecodeGenerator extends RecursiveVisitor<Null> {
27912802 return ;
27922803 }
27932804
2794- _genAssertAssignable (type, name: node.isTypeError ? '' : symbolForTypeCast);
2805+ _genAssertAssignable (type,
2806+ message: node.isTypeError ? '' : symbolForTypeCast);
27952807 }
27962808
27972809 @override
0 commit comments