@@ -230,6 +230,29 @@ enum FunctionFlags
230
230
ffIsClassMember = 0x2000000 ,
231
231
};
232
232
233
+ enum ScopeInfoFlags : byte
234
+ {
235
+ sifNone = 0x0 ,
236
+ sifIsDynamic = 0x1 ,
237
+ sifIsObject = 0x2 ,
238
+ sifMustInstantiate = 0x4 ,
239
+ sifIsCached = 0x8 ,
240
+ sifHasLocalInClosure = 0x10 ,
241
+ sifIsGeneratorFunctionBody = 0x20 ,
242
+ sifIsAsyncFunctionBody = 0x40 ,
243
+ };
244
+
245
+ enum SymbolInfoFlags : byte
246
+ {
247
+ syifNone = 0x0 ,
248
+ syifHasFuncAssignment = 0x1 ,
249
+ syifIsBlockVariable = 0x2 ,
250
+ syifIsConst = 0x4 ,
251
+ syifIsFuncExpr = 0x8 ,
252
+ syifIsModuleExportStorage = 0x10 ,
253
+ syifIsModuleImport = 0x20 ,
254
+ };
255
+
233
256
// Kinds of constant
234
257
enum ConstantType : byte
235
258
{
@@ -2353,30 +2376,32 @@ class ByteCodeBufferBuilder
2353
2376
}
2354
2377
PrependUInt32 (builder, _u (" ScopeInfo FunctionInfo relative id" ), relativeFunctionId);
2355
2378
2356
- BYTE flags = (scopeInfo->isDynamic ? 0x1 : 0 )
2357
- | (scopeInfo->isObject ? 0x2 : 0 )
2358
- | (scopeInfo->mustInstantiate ? 0x4 : 0 )
2359
- | (scopeInfo->isCached ? 0x8 : 0 )
2360
- | (scopeInfo->hasLocalInClosure ? 0x10 : 0 )
2361
- | (scopeInfo->isGeneratorFunctionBody ? 0x20 : 0 )
2362
- | (scopeInfo->isAsyncFunctionBody ? 0x40 : 0 );
2379
+ ScopeInfoFlags scopeInfoFlags = (ScopeInfoFlags)
2380
+ ( (scopeInfo->isDynamic ? sifIsDynamic : sifNone)
2381
+ | (scopeInfo->isObject ? sifIsObject : sifNone)
2382
+ | (scopeInfo->mustInstantiate ? sifMustInstantiate : sifNone)
2383
+ | (scopeInfo->isCached ? sifIsCached : sifNone)
2384
+ | (scopeInfo->hasLocalInClosure ? sifHasLocalInClosure : sifNone)
2385
+ | (scopeInfo->isGeneratorFunctionBody ? sifIsGeneratorFunctionBody : sifNone)
2386
+ | (scopeInfo->isAsyncFunctionBody ? sifIsAsyncFunctionBody : sifNone));
2363
2387
2364
- PrependByte (builder, _u (" ScopeInfo flags" ), flags );
2388
+ PrependByte (builder, _u (" ScopeInfo flags" ), scopeInfoFlags );
2365
2389
PrependInt32 (builder, _u (" ScopeInfo scope type" ), scopeInfo->scopeType );
2366
2390
PrependInt32 (builder, _u (" ScopeInfo scope id" ), scopeInfo->scopeId );
2367
2391
2368
2392
for (int i = 0 ; i < scopeInfo->symbolCount ; i++)
2369
2393
{
2370
2394
ScopeInfo::SymbolInfo* sym = scopeInfo->symbols + i;
2371
2395
2372
- flags = (sym->hasFuncAssignment ? 0x1 : 0 )
2373
- | (sym->isBlockVariable ? 0x2 : 0 )
2374
- | (sym->isConst ? 0x4 : 0 )
2375
- | (sym->isFuncExpr ? 0x8 : 0 )
2376
- | (sym->isModuleExportStorage ? 0x10 : 0 )
2377
- | (sym->isModuleImport ? 0x20 : 0 );
2396
+ SymbolInfoFlags symbolInfoFlags = (SymbolInfoFlags)
2397
+ ( (sym->hasFuncAssignment ? syifHasFuncAssignment : syifNone)
2398
+ | (sym->isBlockVariable ? syifIsBlockVariable : syifNone)
2399
+ | (sym->isConst ? syifIsConst : syifNone)
2400
+ | (sym->isFuncExpr ? syifIsFuncExpr : syifNone)
2401
+ | (sym->isModuleExportStorage ? syifIsModuleExportStorage : syifNone)
2402
+ | (sym->isModuleImport ? syifIsModuleImport : syifNone));
2378
2403
2379
- PrependByte (builder, _u (" SymbolInfo flags" ), flags );
2404
+ PrependByte (builder, _u (" SymbolInfo flags" ), symbolInfoFlags );
2380
2405
PrependByte (builder, _u (" SymbolInfo symbol type" ), (BYTE)sym->symbolType );
2381
2406
2382
2407
PropertyId symPropertyId = sym->propertyId ;
@@ -4273,15 +4298,15 @@ class ByteCodeBufferReader
4273
4298
4274
4299
*scopeInfo = RecyclerNewPlusZ (scriptContext->GetRecycler (), symbolCount * sizeof (ScopeInfo::SymbolInfo), ScopeInfo, functionInfo, symbolCount);
4275
4300
4276
- BYTE flags ;
4277
- current = ReadByte (current, &flags );
4278
- (*scopeInfo)->isDynamic = (flags & 0x1 ) != 0 ;
4279
- (*scopeInfo)->isObject = (flags & 0x2 ) != 0 ;
4280
- (*scopeInfo)->mustInstantiate = (flags & 0x4 ) != 0 ;
4281
- (*scopeInfo)->isCached = (flags & 0x8 ) != 0 ;
4282
- (*scopeInfo)->hasLocalInClosure = (flags & 0x10 ) != 0 ;
4283
- (*scopeInfo)->isGeneratorFunctionBody = (flags & 0x20 ) != 0 ;
4284
- (*scopeInfo)->isAsyncFunctionBody = (flags & 0x40 ) != 0 ;
4301
+ ScopeInfoFlags scopeInfoFlags ;
4302
+ current = ReadByte (current, (byte*)&scopeInfoFlags );
4303
+ (*scopeInfo)->isDynamic = (scopeInfoFlags & sifIsDynamic ) != 0 ;
4304
+ (*scopeInfo)->isObject = (scopeInfoFlags & sifIsObject ) != 0 ;
4305
+ (*scopeInfo)->mustInstantiate = (scopeInfoFlags & sifMustInstantiate ) != 0 ;
4306
+ (*scopeInfo)->isCached = (scopeInfoFlags & sifIsCached ) != 0 ;
4307
+ (*scopeInfo)->hasLocalInClosure = (scopeInfoFlags & sifHasLocalInClosure ) != 0 ;
4308
+ (*scopeInfo)->isGeneratorFunctionBody = (scopeInfoFlags & sifIsGeneratorFunctionBody ) != 0 ;
4309
+ (*scopeInfo)->isAsyncFunctionBody = (scopeInfoFlags & sifIsAsyncFunctionBody ) != 0 ;
4285
4310
(*scopeInfo)->areNamesCached = false ;
4286
4311
4287
4312
int scopeType;
@@ -4294,13 +4319,14 @@ class ByteCodeBufferReader
4294
4319
{
4295
4320
ScopeInfo::SymbolInfo* sym = (*scopeInfo)->symbols + i;
4296
4321
4297
- current = ReadByte (current, &flags);
4298
- sym->hasFuncAssignment = (flags & 0x1 ) != 0 ;
4299
- sym->isBlockVariable = (flags & 0x2 ) != 0 ;
4300
- sym->isConst = (flags & 0x4 ) != 0 ;
4301
- sym->isFuncExpr = (flags & 0x8 ) != 0 ;
4302
- sym->isModuleExportStorage = (flags & 0x10 ) != 0 ;
4303
- sym->isModuleImport = (flags & 0x20 ) != 0 ;
4322
+ SymbolInfoFlags symbolInfoFlags;
4323
+ current = ReadByte (current, (byte*)&symbolInfoFlags);
4324
+ sym->hasFuncAssignment = (symbolInfoFlags & syifHasFuncAssignment) != 0 ;
4325
+ sym->isBlockVariable = (symbolInfoFlags & syifIsBlockVariable) != 0 ;
4326
+ sym->isConst = (symbolInfoFlags & syifIsConst) != 0 ;
4327
+ sym->isFuncExpr = (symbolInfoFlags & syifIsFuncExpr) != 0 ;
4328
+ sym->isModuleExportStorage = (symbolInfoFlags & syifIsModuleExportStorage) != 0 ;
4329
+ sym->isModuleImport = (symbolInfoFlags & syifIsModuleImport) != 0 ;
4304
4330
4305
4331
current = ReadByte (current, (BYTE*)&sym->symbolType );
4306
4332
@@ -4596,6 +4622,8 @@ class ByteCodeBufferReader
4596
4622
4597
4623
};
4598
4624
4625
+ // This constructor is for allocating a ByteCodeCache without a reader (ie: before the bytecode buffer is generated).
4626
+ // SetReader() should be called before using the cache.
4599
4627
ByteCodeCache::ByteCodeCache (ScriptContext * scriptContext, int builtInPropertyCount)
4600
4628
: reader(nullptr ), propertyCount(0 ), builtInPropertyCount(builtInPropertyCount), raw(nullptr ), propertyIds(nullptr ), localFunctionIdToFunctionInfoMap(nullptr )
4601
4629
{
0 commit comments