chaoticgd/ccc

Enums declared in structs are not handled correctly

Closed this issue · 3 comments

Tested with Burnout Revenge (Alpha 7)'s executable, SLUS_212.42.

When an enum declared within a struct is parsed, the following error occurs: [ccc/stabs.cpp:261] error: Expected ':' or ',', got ';' (3b).

In this case, the error is caused by members of CB4AIDebug, which should look something like this when parsed correctly:

struct CB4AIDebug {
    enum { eRenderLanesNone, eRenderLanesNearPlayer, /* Continues... */ } meRenderLanes;
    enum { eRenderCornersNone, eRenderCornersAll,  /* Continues... */ } meRenderCorners;
    enum { eLaneDrawLaneType, eLaneDrawResetType, eLaneDrawCount } meLaneDrawType;
    // Rest of the structure is parsed without issue
};

If needed, this is the symbol in question:

CB4AIDebug:Tt1495=s2560meRenderLanes:/01496=eeRenderLanesNone:0,eRenderLanesNearPlayer:1,eRenderLanesAll:2,eRenderLanesAI:3,eRenderLanesPatch:4,eRenderLanesCount:5,;,0,32;meRenderCorners:/01497=eeRenderCornersNone:0,eRenderCornersAll:1,eRenderCornersAI:2,eRenderCornersCount:3,;,32,32;meLaneDrawType:/01498=eeLaneDrawLaneType:0,eLaneDrawResetType:1,eLaneDrawCount:2,;,64,32;mbShowTarget:/021,96,8;mbShowSpline:/021,104,8;mbIgnoreResetAILaneError:/021,112,8;mbShowDebugAggressiveHUD:/021,120,8;mnRenderSegmentsAhead:/0187,128,32;meDriverIndex:/01355,160,32;mnLastNumRaceCars:/0187,192,32;maacDecisions:/01499=ar1;0;5;1500=ar1;0;31;2,224,1536;maacDrivers:/01501=ar1;0;5;1502=ar1;0;127;2,1760,6144;maacSlamStates:/01501,7904,6144;maaLastPoints:/01503=ar1;0;5;1504=ar1;0;3;519,14080,3072;maaLastLanePoints:/01503,17152,3072;mnLastPointIndex:/0187,20224,32;mnLastPointUpdateCount:/0187,20256,32;mnNumLastPoints:/0187,20288,32;mbRenderPoints:/021,20320,8;mbShowLinks:/021,20328,8;mnLaneIndex:/0187,20352,32;mnSegmentIndex:/0187,20384,32;__as::1505=##1506=&1495;:RC10CB4AIDebug;2A.;CB4AIDebug::1507=##1508=*1495;:RC10CB4AIDebug;2A.1509=##1508;:;2A.;Construct::1510=##22;:;2A.;Prepare::1511=##21;:;2A.;Update::1510:;2A.;Release::1510:;2A.;Destruct::1510:;2A.;RenderWorld::1510:;2A.;RenderOverlays::1510:;2A.;IsIgnoreAILaneError::1511:;2A.;DrawSegment::1512=##22;:PC16CB4AILaneSegmentGQ29GtMathPs26CGtV4dbf;1A.;DrawAILaneSegment::1513=##22;:P16CB4AILaneSegment;1A.;DrawAICorner::1514=##22;:P17CB4AICornerStruct;1A.;_RenderAvoidanceMap::1184:RCQ29GtMathPs26CGtV2dT1Pvbf;0A?;_RenderRaceMap::1184:RCQ29GtMathPs26CGtV2dT1Pvbf;0A?;_RenderLanesGetText::1174:PvT1PcPCc;0A?;_RenderCornersGetText::1174:PvT1PcPCc;0A?;_RenderLaneTypeGetText::1174:PvT1PcPCc;0A?;_TogglePlayerAIControlled::63:Pv;0A?;_SaveAICheckpointTimes::63:Pv;0A?;;

Notably, this isn't isolated. I've had at least 2 other executables with the same issue.

Good timing, I just started working on ccc again a couple days ago. I'm in the process of rewriting the AST and printing code. By the time I'm done this bug should be fixed.

Fixed it. There were two problems: (1) Inline enum types causing a parsing error, and, get this: (2) The symbol name right at the start of each STABS symbol is not escaped, so it can contain a :: (namespace separator) even though the field is supposed to be terminated by a ':', I think only in the case where the namespace separator is part of a template parameter. 🙃

You'll have to wait until I'm done with the rest of the rewrite for it to be merged to master.

Alright, I'll merge it now. I don't think I'm entirely done with it yet, but I think it's already better than what's currently on main.