Commit Graph

57 Commits

Author SHA1 Message Date
Axel Naumann
bf31a650a9 Fix symbol requesting.
git-svn-id: http://root.cern.ch/svn/root/trunk@46983 27541ba8-7e3a-0410-8455-c3a389f83636
2012-11-01 19:10:12 +00:00
Axel Naumann
ee3b83e48a Implement unnamed macros:
* MetaProcessor::readInputFromFile passes the content to the Interpreter as if typed at the prompt
* they do not get passed to CINT in TCintWithCling


git-svn-id: http://root.cern.ch/svn/root/trunk@46898 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-30 13:40:25 +00:00
Axel Naumann
5bb394667e Doc fix
git-svn-id: http://root.cern.ch/svn/root/trunk@46897 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-30 13:34:09 +00:00
Axel Naumann
a62cc82f24 Pass CompilationResult through
* MetaProcessor
* loadFile
* TCintWithCling::ProcessLine().
Second part of fixing #98499.

Also fix a few dubious "return 0" instead of returnign the indent in MetaProcessor.


git-svn-id: http://root.cern.ch/svn/root/trunk@46873 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-29 14:23:53 +00:00
Vassil Vassilev
8c385cf901 Use better naming.
git-svn-id: http://root.cern.ch/svn/root/trunk@46809 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-25 14:07:19 +00:00
Vassil Vassilev
5d4af3ddc7 Add a way to disable the complaints of HandleMissing symbol, when it is ok for
the symbol to be missing.


git-svn-id: http://root.cern.ch/svn/root/trunk@46795 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-25 09:17:45 +00:00
Vassil Vassilev
f398425dbb Add note.
git-svn-id: http://root.cern.ch/svn/root/trunk@46791 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-25 08:33:40 +00:00
Vassil Vassilev
88bd362c63 Keep the const version only for now.
git-svn-id: http://root.cern.ch/svn/root/trunk@46742 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-23 13:03:08 +00:00
Vassil Vassilev
71ccaf68b7 Fix a typo, which will silence doxygen warnings.
git-svn-id: http://root.cern.ch/svn/root/trunk@46734 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-23 08:52:48 +00:00
Vassil Vassilev
acef61e88f Fix not only the address but the string too.
git-svn-id: http://root.cern.ch/svn/root/trunk@46681 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-19 13:49:34 +00:00
Vassil Vassilev
94994c05dc Publish the head of the transaction list so that the transactions become
iteratable. (We will use it in TCintWithCling)


git-svn-id: http://root.cern.ch/svn/root/trunk@46677 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-19 13:30:06 +00:00
Vassil Vassilev
da3a51f5f8 Make the transaction class single list.
git-svn-id: http://root.cern.ch/svn/root/trunk@46676 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-19 13:29:03 +00:00
Vassil Vassilev
d916876642 RunFunction takes FunctionDecl as an argument. Thus it avoids a lookup and
simplifies the implementation.


git-svn-id: http://root.cern.ch/svn/root/trunk@46673 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-19 11:56:52 +00:00
Vassil Vassilev
dac353c6df Each transaction has one wrapper function that we use all over.
Register the wrapper function in the transaction so that we can find it without
having to iterate over the rest of the declarations.


git-svn-id: http://root.cern.ch/svn/root/trunk@46672 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-19 11:49:49 +00:00
Vassil Vassilev
24cdb599f7 In many modes (eg like evaluate and value print) we need to find the last
expression in the wrapper function and do things with it. In some cases we 
must consider variable declarations as expressions (eg. int i = 5;) and take
the l-value and build a DeclRefExpr and return it.
Extract that common functionality out in a utility function and call it whenever
needed.


git-svn-id: http://root.cern.ch/svn/root/trunk@46668 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-19 09:22:36 +00:00
Axel Naumann
9327a62ee1 Revert test r46655
git-svn-id: http://root.cern.ch/svn/root/trunk@46656 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-18 17:43:39 +00:00
Axel Naumann
5b0f6be89c Test for struct/class: who is complaining?
git-svn-id: http://root.cern.ch/svn/root/trunk@46655 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-18 17:42:39 +00:00
Vassil Vassilev
7f6039444b When we evaluate we *must* provide a value where the evaluated result to be stored
git-svn-id: http://root.cern.ch/svn/root/trunk@46642 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-18 12:24:04 +00:00
Vassil Vassilev
bdc04cd18e Extract the code duplication in separate routine.
git-svn-id: http://root.cern.ch/svn/root/trunk@46638 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-18 12:05:53 +00:00
Vassil Vassilev
f48a4881cd Add super efficient execute function. It doesn't do any fancy things with the
declarations - it just compiles and runs given expression or statement.


git-svn-id: http://root.cern.ch/svn/root/trunk@46636 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-18 11:56:20 +00:00
Vassil Vassilev
fe93a54d61 Silence doxygen warning.
git-svn-id: http://root.cern.ch/svn/root/trunk@46628 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-18 08:19:19 +00:00
Vassil Vassilev
ec129305af Centralize the unique name prefix (the names generated by the interpreter use it)
and provide utility function which checks if a decls has such name.


git-svn-id: http://root.cern.ch/svn/root/trunk@46593 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-17 08:52:24 +00:00
Vassil Vassilev
ae3a0dfdad * Factor out the duplicate code.
* Avoid alloc/dealloc of the entire body of the function (the CompoundStmt) by
using ugly iterator + offset tricks.


git-svn-id: http://root.cern.ch/svn/root/trunk@46553 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-15 16:57:53 +00:00
Vassil Vassilev
c5a8df6c88 Prepare cling for fixing bug #98146. In principle the bug could be fixed in 10
seconds, but I don't like where EvaluateInternal is going.
At first place it shouldn't do any smart guessing what the transformers would do.
Second it shouldn't try to attach expression evaluation (storing the result in 
cling::Value) while preparing for value printing.

To sum up:
* Simplify the old craft in EvaluateInternal
  - Move the value printing logic into the value printer transformer. 
  - Move the expression evaluation login (mainly coming through the 
Interpreter::evaluate interface) into separate transformer.
* Attach the new transformer to the list of transformers (the size of it was 
increased as well.)
* Add new compilation option switch that the new transformer will react on.
* Turn on the switch where necessary.
* Simplify value printer logic. Now everything is at one place, which makes it
simpler and easier to debug.
* Make IncrementalParser::Parse to take compilation options' reference instead of
constructing it's own.
* As consequence of the new implementation - two bugs in the testsuite were 
uncovered. Propose a fix for them.
* Improve documentation.
* TODO: There is some code duplication, which will be factored out soon.


git-svn-id: http://root.cern.ch/svn/root/trunk@46549 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-15 13:42:09 +00:00
Vassil Vassilev
01896277e2 Centralize the common code in to a method and just call it. Reduces a *lot* the
code duplication.
Adjust the creation of ParserStateRAII object used to recover the parser on exit.


git-svn-id: http://root.cern.ch/svn/root/trunk@46510 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-12 16:09:04 +00:00
Vassil Vassilev
be7177b93c Extract out the common part of setting up and recovering the parser.
git-svn-id: http://root.cern.ch/svn/root/trunk@46508 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-12 15:27:02 +00:00
Axel Naumann
4908b97968 Don't allocate twice for small values.
The StoredValue has to be heap allocated, so it can be deleted when refcount == 0.
But the value it points to now is simply contained inside the StoredValue if
* it fits into the GenericValue (double,...)
* it is <= 80 bytes.
This grows StoredValue (not Ref!) from 48 to 128 bytes on Linux 64bit.
Given that many OSes allocate an extra 16 bytes for each allocation (i.e. the actual cost is 80-16 bytes), this is still reasonable.


git-svn-id: http://root.cern.ch/svn/root/trunk@46491 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-12 13:22:12 +00:00
Vassil Vassilev
475ad9a757 * SymbolResolverCallback should create DynamicIDHandler as its InterpreterExternalSemaSource.
* InterpreterExternalSemaSource::setCallbacks is not needed any more. 
  It can be set in the constructor instead.


git-svn-id: http://root.cern.ch/svn/root/trunk@46444 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-10 15:50:17 +00:00
Vassil Vassilev
9d654b26f9 No need to enable/disable, check for enabled/disabled callback. Either they are
there and we use them or not.


git-svn-id: http://root.cern.ch/svn/root/trunk@46440 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-10 14:50:45 +00:00
Vassil Vassilev
a047926b87 Usually we have to distinguish between lookup failures. Eg. there are certain
lookups that are expected (by the compiler) to fail and those which should not fail.

I was misled (wasn't thinking at all: Thanks Axel for questioning the checkin) 
because I thought we cannot distinguish those two different cases in the test
callback. 
Silly mistake:
  Revert the changes in the testsuite.
  Revert the default setup of the test callback in enableDynamicLookup

The problem is solved by extracting out the function which determines whether
a lookup is not expected to fail. (It still needs better place.)


git-svn-id: http://root.cern.ch/svn/root/trunk@46438 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-10 14:37:10 +00:00
Vassil Vassilev
3bba03cf9f *The JIT is configured to compile with RTTI so when we #include the SymbolResolverCallback
it looks for typeinfo of the InterpreterCallbacks (compiled with fno-rtti).

*Move the SymbolResolverCallback into InterpreterCallbacks.(h,cpp). Ideally it is 
used only in the testsuite so we could hack in the build system to build the 
SymbolResolverCallback with fno-rtti and include just the header file but that's
for later.
*Set the symbol resolver callback in enableDynamicLookup for now.
*Clear up the logic behind InterpreterExternalSemaSource and InterpreterCallbacks.
*Now the DynamicIDHandler derives from InterpreterExternalSemaSource.
*Adapt the testsuite to the change.
*Request the InterpreterCallback constructor to be put in the binary.


git-svn-id: http://root.cern.ch/svn/root/trunk@46435 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-10 13:00:17 +00:00
Vassil Vassilev
e75c9b1a13 The callback class implements LookupObject callback, which should be called even
no dynamic scopes are involved. The information about a failed lookup comes from 
slightly different channel - ExternalSemaSource (if attached to sema).

In order to make the callback LookupObject work when we attach an arbitrary 
callback class we should attach ExternalSemaSource to Sema as well. This require
a default implementation for an ExternalSemaSource.


git-svn-id: http://root.cern.ch/svn/root/trunk@46396 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-09 10:17:19 +00:00
Vassil Vassilev
6e341e8376 Implement functions that check whether a name was interpreter-generated.
git-svn-id: http://root.cern.ch/svn/root/trunk@46395 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-09 09:48:54 +00:00
Vassil Vassilev
a67f0ebca8 * Add another overload taking DeclarationName as an argument. This is useful when
we have to deal with failed lookups.
* Improve documentation.


git-svn-id: http://root.cern.ch/svn/root/trunk@46394 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-09 09:41:26 +00:00
Axel Naumann
0a9ed8027c Remove cling::Value-compatible overloads.
Use "m_" as member prefix.
Remove adopt() - not needed.
Remove hasValue() - it's meaningless (use isValid() to check validity of value).


git-svn-id: http://root.cern.ch/svn/root/trunk@46341 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-05 13:10:28 +00:00
Axel Naumann
bc18a88f10 Essential part of r46334. Log was:
Add cling::StoredValueRef: a ref-counted value with automatic storage management.
Update Interpreter to use that instead of cling::Value.
This fixes an issue where the called neded to guess the return type of the wrapper function, such that for instance Interpreter::Evaluate() has storage for the wrapper's aggregate SRet return value if needed.
Instead, the Interpreter now allocates the proper storage for return values, and hands out references to it.
StoredValueRef is tiny (8bytes on 64bit Linux); default allocation is cheap.


git-svn-id: http://root.cern.ch/svn/root/trunk@46335 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-05 12:18:14 +00:00
Axel Naumann
3ec1741cf9 Add cling::StoredValueRef: a ref-counted value with automatic storage management.
Update Interpreter to use that instead of cling::Value.
This fixes an issue where the called neded to guess the return type of the wrapper function, such that for instance Interpreter::Evaluate() has storage for the wrapper's aggregate SRet return value if needed.
Instead, the Interpreter now allocates the proper storage for return values, and hands out references to it.
StoredValueRef is tiny (8bytes on 64bit Linux); default allocation is cheap.

Update TCintWithCling and friends; don't pass the returnValue in if the caller does not need it.
TClingCallFunc: provide storage for fArgs.


git-svn-id: http://root.cern.ch/svn/root/trunk@46334 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-05 12:09:51 +00:00
Vassil Vassilev
5e4f599000 Typo.
git-svn-id: http://root.cern.ch/svn/root/trunk@46331 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-05 10:32:03 +00:00
Vassil Vassilev
f8d42d206f Add sensible constructor.
git-svn-id: http://root.cern.ch/svn/root/trunk@46319 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-04 16:03:05 +00:00
Vassil Vassilev
a7261215a3 Add multiplex external sema source, which is a list of sema sources. When it is
used it dispatches the events to every element of the list of sources.

This is used because we want to have ASTDeclReader and our custom external source
catching LookupUnqualified callbacks, happening on failed lookup.


git-svn-id: http://root.cern.ch/svn/root/trunk@46317 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-04 15:47:10 +00:00
Vassil Vassilev
32f4bd161b Add non-const getter.
git-svn-id: http://root.cern.ch/svn/root/trunk@46288 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-03 12:57:09 +00:00
Vassil Vassilev
a41c19237c * Remove the craftwork from dealing with setting callbacks.
* Simplify the impelentation of DynIDHandler.
* Create a shortcut for getting the semantic analysis object.


git-svn-id: http://root.cern.ch/svn/root/trunk@46287 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-03 12:40:41 +00:00
Vassil Vassilev
0ada6afba2 Silence doxygen warnings
git-svn-id: http://root.cern.ch/svn/root/trunk@46279 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-03 09:21:57 +00:00
Vassil Vassilev
e087402f78 * Implement interpreter callbacks, which the Interpreter owns.
* Implement new callback functions - on transaction committed and transaction unloaded.
* Publish the Transaction class so that it can be visible by TCintWithCling.
* Publish the CompilationOptions needed by Transaction.
* Fix the references of Transaction and CompilationOptions.
* Forward declare where possible.
* Add missing keywords.
* Improve include style.


git-svn-id: http://root.cern.ch/svn/root/trunk@46264 27541ba8-7e3a-0410-8455-c3a389f83636
2012-10-02 10:30:25 +00:00
Vassil Vassilev
9cc45252ae Use more meaningful names - irrelevant for the users, priceless for developers.
git-svn-id: http://root.cern.ch/svn/root/trunk@46210 27541ba8-7e3a-0410-8455-c3a389f83636
2012-09-27 08:51:01 +00:00
Vassil Vassilev
d057925245 Improve documentation.
git-svn-id: http://root.cern.ch/svn/root/trunk@46198 27541ba8-7e3a-0410-8455-c3a389f83636
2012-09-26 13:27:48 +00:00
Axel Naumann
afd46ea54a Rename getMangledName() into mangleName().
git-svn-id: http://root.cern.ch/svn/root/trunk@46147 27541ba8-7e3a-0410-8455-c3a389f83636
2012-09-24 15:20:19 +00:00
Axel Naumann
621c0173c2 Cache MangleContext as a private member of the interpreter, so we don't have to re-create it all the time.
Implement JITed version of ExecutionContext::getAddressOfGlobal(), which now also needs a Module.


git-svn-id: http://root.cern.ch/svn/root/trunk@46139 27541ba8-7e3a-0410-8455-c3a389f83636
2012-09-24 12:11:46 +00:00
Axel Naumann
6323e0e50c Implement Interpreter::getAddressOfGlobal(const clang::NamedDecl*) (test comes "in a minute")
Factor out mangling into Interpreter::getMangledName().
Spelling.


git-svn-id: http://root.cern.ch/svn/root/trunk@46136 27541ba8-7e3a-0410-8455-c3a389f83636
2012-09-24 09:57:43 +00:00
Vassil Vassilev
c38e4407ef Use better names for the internal functions so that they are more visible while
debugging.


git-svn-id: http://root.cern.ch/svn/root/trunk@46024 27541ba8-7e3a-0410-8455-c3a389f83636
2012-09-18 15:14:58 +00:00