This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Merge cpplib and front end hashtables, part 1


Daniel Berlin wrote:-

> But it wouldn't have compiled, right?

Sure it would have.

#define ADD(X,Y) X+Y
ADD(2,3)

for a trivial example.  I assume you'd like to be able to handle
these?  In GDB, I'd like to be able to use a lot of the GCC macros for
trees, say, which get way more complex.

> Remember, we get the macros from the *debug info*.

My understanding is that (Dwarf2) debug info is the same as a #define
line without the #define, so it's no different to where cpplib gets
them from.  Or are we talking about stabs or Dwarf1 (which I know
nothing about).

Incidentally, if you really want something expanded to text, you could
write a subroutine that looped calling cpp_get_token() until it got a
CPP_EOF token, calling cpp_spell_token() on each token it receives.
cpp_token_len() gives you (an upper bound on) the amount of space you
need to spell the token, so I reckon you could write a simple loop to
get what you want into an expandable buffer with 3 cpplib calls and
around a dozen lines.  Another loop to add the macro definitions with
a call to cpp_define is say 5 lines.  Initialization of the library
and pushing thedyour text buffer you want expanded is maybe another 10
say.  I think you could do everything in 50 to 100 lines max.

cpplib has to do something very similar when evaluating the #
preprocessing operator to convert an arbitrary sequence of tokens to
text, after all.

Neil.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]