Related articles |
---|
basic question about runtime query parsing shahbazc@gmail.com (falcon) (2005-07-11) |
Re: basic question about runtime query parsing antounk@comcast.net (Antoun Kanawati) (2005-07-12) |
Re: basic question about runtime query parsing skandgoe@gwdg.de (Skandinavisches Seminar) (2005-07-12) |
Re: basic question about runtime query parsing wyrmwif@tsoft.org (SM Ryan) (2005-07-12) |
Re: basic question about runtime query parsing gneuner2@comcast.net (George Neuner) (2005-07-12) |
Re: basic question about runtime query parsing kers@hpl.hp.com (Chris Dollin) (2005-07-17) |
Re: basic question about runtime query parsing lfinsto1@gwdg.de (Laurence Finston) (2005-07-22) |
Re: basic question about runtime query parsing shahbazc@gmail.com (falcon) (2005-07-22) |
Re: basic question about runtime query parsing kers@hpl.hp.com (Chris Dollin) (2005-07-26) |
[5 later articles] |
From: | "Skandinavisches Seminar" <skandgoe@gwdg.de> |
Newsgroups: | comp.compilers |
Date: | 12 Jul 2005 05:14:35 -0400 |
Organization: | GWDG, Goettingen |
References: | 05-07-045 |
Keywords: | SQL, parse |
Posted-Date: | 12 Jul 2005 05:14:35 EDT |
Falcon wrote:
> By that I mean, if someone issues 'create table(x int, y int, z int),'
> I parse it and figure out I need a struct{int x, int y, int z} (this
> struct will then be passed all over the code). How do I create this
> struct during runtime?
By using 'malloc()' to allocate memory on the heap, also known as "dynamic
allocation". You can then put a pointer to the object you've created into
an appropriate data structure, such as a singly or doubly-linked list or a
tree.
> One way I can think of is to output the struct
> definition to a file, compile it on the fly and use it.
I don't believe that compilation "on the fly" is possible with C. You
could invoke the compiler from your program, but it won't be possible
to link the generated code with your program while it's running.
Unless you don't have virtual memory, and/or you have extremely large
memory requirements, I wouldn't bother writing anything to external
files. Your run-time system's virtual memory management ("swapper")
will take care of this for you. With 32 bit addresses, you will have
not quite 2^32 bytes of virtual memory, which ought to be enough for
most purposes. It's not hard to determine exactly how virtual memory
you have available. I wrote a toy program for doing this some months
ago. If you want, I can dig it out for you.
Laurence Finston
http://www.gnu.org/software/3dldf/LDF.html
Return to the
comp.compilers page.
Search the
comp.compilers archives again.