YY**TYPE Definitions and PB #2
Unanswered
tajmone
asked this question in
Code Adaptation
Replies: 1 comment
-
Data Types Correspondence TableThe following table only lists PB types which are size-equivalent on both x64 and x32.
References |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In
lempar.c
we find variousYY**TYPE
definitions, likeYYCODETYPE
,YYACTIONTYPE
andYYMINORTYPE
which in the final parser will specify which C type to use for representing various data types according to their minimum data-size requirements. E.g.:In the generated parser, the result is something like this:
All these types are calculated via the
minimum_size_type()
function found inreport.c
:The above function must be tweaked to use PB types.
The choice of the types requires careful consideration. This is intended to save memory space in the parser data storage, but PureBasic is known to be quirky when handling signed and unsigned types in a same expression, and in general it behaves best with signed types.
Furthermore, PB doesn't support the u32 type, so that might have to be skipped.
In any case, some tests should be done to prevent having to do lots of horrible hacks to convert unsigned types to signed, which might ultimately slow down execution (not to mention potential bugs, which would be hard to track).
Furthermore, users are reporting many issues with unsigned types being treated differently by the Fasm and GCC backends in PB 6 Beta (and since casting has always been a quirky and undocumented, chances are that these problems will still be in the final version).
Then there's the problem of how to handle in PB the C-style single
#define
:A quick solution, would be to use a
macro
to define the type. But it would be much better if the various types were stored somewhere in Lemon, and correctly injected as PB types (.b
,.u
,.i
, etc.) in the generated code, every time aYY**TYPE
is needed, but unfortunately these types are calculated on the fly, injected and dropped! So to preserve them for later use might require tweaking the code and either adding extra fields in an existing structure to preserve them, or create a new structure for that purpose.Beta Was this translation helpful? Give feedback.
All reactions