MCPcopy Create free account
hub / github.com/MayaPosch/NymphCast / AdjustOffset

Method AdjustOffset

src/server/angelscript/angelscript/source/as_restore.cpp:3221–3371  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3219}
3220
3221int asCReader::SListAdjuster::AdjustOffset(int offset)
3222{
3223 if( offset < lastOffset )
3224 {
3225 reader->Error(TXT_INVALID_BYTECODE_d);
3226 return 0;
3227 }
3228
3229 // If it is the same offset being accessed again, just return the same adjusted value
3230 if( lastOffset == offset )
3231 return lastAdjustedOffset;
3232
3233 lastOffset = offset;
3234 lastAdjustedOffset = maxOffset;
3235
3236 // What is being expected at this position?
3237 if( patternNode->type == asLPT_REPEAT || patternNode->type == asLPT_REPEAT_SAME )
3238 {
3239 // Align the offset to 4 bytes boundary
3240 if( maxOffset & 0x3 )
3241 {
3242 maxOffset += 4 - (maxOffset & 0x3);
3243 lastAdjustedOffset = maxOffset;
3244 }
3245
3246 // Don't move the patternNode yet because the caller must make a call to SetRepeatCount too
3247 maxOffset += 4;
3248 nextOffset = offset+1;
3249 return lastAdjustedOffset;
3250 }
3251 else if( patternNode->type == asLPT_TYPE )
3252 {
3253 const asCDataType &dt = reinterpret_cast<asSListPatternDataTypeNode*>(patternNode)->dataType;
3254 if( dt.GetTokenType() == ttQuestion )
3255 {
3256 if( nextTypeId != -1 )
3257 {
3258 if( repeatCount > 0 )
3259 repeatCount--;
3260
3261 asCDataType nextdt = patternType->engine->GetDataTypeFromTypeId(nextTypeId);
3262 asUINT size;
3263 if(nextdt.IsObjectHandle() || (nextdt.GetTypeInfo() && (nextdt.GetTypeInfo()->flags & asOBJ_REF)) )
3264 size = AS_PTR_SIZE*4;
3265 else
3266 size = nextdt.GetSizeInMemoryBytes();
3267
3268 // Align the offset to 4 bytes boundary
3269 if( size >= 4 && (maxOffset & 0x3) )
3270 {
3271 maxOffset += 4 - (maxOffset & 0x3);
3272 lastAdjustedOffset = maxOffset;
3273 }
3274
3275 // Only move the patternNode if we're not expecting any more repeated entries
3276 if( repeatCount == 0 )
3277 patternNode = patternNode->next;
3278

Callers 2

TranslateFunctionMethod · 0.80
WriteByteCodeMethod · 0.80

Calls 9

GetTokenTypeMethod · 0.80
GetDataTypeFromTypeIdMethod · 0.80
IsObjectHandleMethod · 0.80
GetTypeInfoMethod · 0.80
GetSizeInMemoryBytesMethod · 0.80
PushLastMethod · 0.80
PopLastMethod · 0.80
ErrorMethod · 0.45
GetLengthMethod · 0.45

Tested by

no test coverage detected