[LLVMdev] Scheme + LLVM JIT
Chris Lattner
sabre at nondot.org
Mon May 16 13:50:02 PDT 2005
On Fri, 13 May 2005, Alexander Friedman wrote:
>>> This requires being able to parse strings. The LLVM 'Parser.h' interface
>>> (and implementation) has the built in assumptions that it will always be
>>> parsing from the file system. Would you guys accept a patch that makes
>>> it more general (ie, parse from file or string)?
>>
>> Yes, that's a generally useful thing to have, I'd like to see it happen if
>> it doesn't impact the efficiency of the lexer.
>
> Ok, here's a patch. I added a 'parseAsmString' function to the Parser
> interface. It doesn't seem to break any tests, so parsing files seems
> to still work ok.
This looks basically ok. There are minor things (";;" -> ";"), and the
commented out code should be removed.
I'm concerned that this leaks the buffer created for the file, can you
verify that it doesn't?
> I havn't tested parsing strings yet. My code is extremely simple and
> *should* work, but we know where that line of thinking leads. Should I
> submit a test case (it would have to be a C file that links in the
> parser)?
Sure, that sounds good. I'd definitely prefer that it be tested before it
goes into CVS. Perhaps adding something to llvm/examples would be a good
way to go.
One suggestion, you might change the API to be something like this:
ParseAsmString(const char *, Module *)
Where the function parses the string and appends it into the specified
module. This would make self-extending code simpler (no need to parse
into one module then link into the preexisting one).
-Chris
--
http://nondot.org/sabre/
http://llvm.cs.uiuc.edu/
More information about the llvm-dev
mailing list