2013-02-25 14:19:15 +04:00
//--------------------------------------------------------------------*- C++ -*-
2012-10-15 17:42:09 +04:00
// CLING - the C++ LLVM-based InterpreterG :)
// author: Vassil Vassilev <vasil.georgiev.vasilev@cern.ch>
2014-01-07 14:08:37 +04:00
//
// This file is dual-licensed: you can choose to license it under the University
// of Illinois Open Source License or the GNU Lesser General Public License. See
// LICENSE.TXT for details.
2012-10-15 17:42:09 +04:00
//------------------------------------------------------------------------------
2014-02-18 14:33:12 +04:00
# ifndef CLING_VALUE_EXTRACTION_SYNTHESIZER_H
# define CLING_VALUE_EXTRACTION_SYNTHESIZER_H
2012-10-15 17:42:09 +04:00
2015-03-16 16:58:26 +03:00
# include "ASTTransformer.h"
2012-10-15 17:42:09 +04:00
namespace clang {
class ASTContext ;
2015-03-16 16:49:28 +03:00
class Decl ;
Handle returns, temporary results, independent on JIT's runFunction.
Here we don't want to depend on the JIT runFunction, because of its limitations,
when it comes to return value handling. There it is not clear who provides the
storage and who cleans it up in a platform independent way.
Depending on the type we need to synthesize a call to cling:
0) void : do nothing;
1) enum, integral, float, double, referece, pointer types :
call to cling::internal::setValueNoAlloc(...);
2) object type (alloc on the stack) :
cling::internal::setValueWithAlloc
2.1) constant arrays:
call to cling::runtime::internal::copyArray(...)
We need to synthesize later (see RuntimeUniverse.h)
Wrapper has signature: void w(cling::StoredValueRef SVR)
case 1):
setValueNoAlloc(gCling, &SVR, lastExprTy, lastExpr())
case 2):
new (setValueWithAlloc(gCling, &SVR, lastExprTy)) (lastExpr)
case 2.1):
copyArray(src, placement, N)
2014-02-18 01:53:21 +04:00
class Expr ;
2012-10-15 17:42:09 +04:00
class Sema ;
Handle returns, temporary results, independent on JIT's runFunction.
Here we don't want to depend on the JIT runFunction, because of its limitations,
when it comes to return value handling. There it is not clear who provides the
storage and who cleans it up in a platform independent way.
Depending on the type we need to synthesize a call to cling:
0) void : do nothing;
1) enum, integral, float, double, referece, pointer types :
call to cling::internal::setValueNoAlloc(...);
2) object type (alloc on the stack) :
cling::internal::setValueWithAlloc
2.1) constant arrays:
call to cling::runtime::internal::copyArray(...)
We need to synthesize later (see RuntimeUniverse.h)
Wrapper has signature: void w(cling::StoredValueRef SVR)
case 1):
setValueNoAlloc(gCling, &SVR, lastExprTy, lastExpr())
case 2):
new (setValueWithAlloc(gCling, &SVR, lastExprTy)) (lastExpr)
case 2.1):
copyArray(src, placement, N)
2014-02-18 01:53:21 +04:00
class VarDecl ;
2012-10-15 17:42:09 +04:00
}
namespace cling {
2015-03-16 16:49:28 +03:00
class ValueExtractionSynthesizer : public WrapperTransformer {
2012-10-15 17:42:09 +04:00
private :
///\brief Needed for the AST transformations, owned by Sema.
///
clang : : ASTContext * m_Context ;
2014-08-04 06:05:42 +04:00
Handle returns, temporary results, independent on JIT's runFunction.
Here we don't want to depend on the JIT runFunction, because of its limitations,
when it comes to return value handling. There it is not clear who provides the
storage and who cleans it up in a platform independent way.
Depending on the type we need to synthesize a call to cling:
0) void : do nothing;
1) enum, integral, float, double, referece, pointer types :
call to cling::internal::setValueNoAlloc(...);
2) object type (alloc on the stack) :
cling::internal::setValueWithAlloc
2.1) constant arrays:
call to cling::runtime::internal::copyArray(...)
We need to synthesize later (see RuntimeUniverse.h)
Wrapper has signature: void w(cling::StoredValueRef SVR)
case 1):
setValueNoAlloc(gCling, &SVR, lastExprTy, lastExpr())
case 2):
new (setValueWithAlloc(gCling, &SVR, lastExprTy)) (lastExpr)
case 2.1):
copyArray(src, placement, N)
2014-02-18 01:53:21 +04:00
///\brief cling::runtime::gCling variable cache.
///
clang : : VarDecl * m_gClingVD ;
///\brief cling::runtime::internal::setValueNoAlloc cache.
///
clang : : Expr * m_UnresolvedNoAlloc ;
///\brief cling::runtime::internal::setValueWithAlloc cache.
///
clang : : Expr * m_UnresolvedWithAlloc ;
///\brief cling::runtime::internal::copyArray cache.
///
clang : : Expr * m_UnresolvedCopyArray ;
2012-10-15 17:42:09 +04:00
public :
///\ brief Constructs the return synthesizer.
///
///\param[in] S - The semantic analysis object.
///
2014-02-18 14:33:12 +04:00
ValueExtractionSynthesizer ( clang : : Sema * S ) ;
2014-04-04 17:13:18 +04:00
2014-02-18 14:33:12 +04:00
virtual ~ ValueExtractionSynthesizer ( ) ;
2012-10-15 17:42:09 +04:00
2015-03-16 16:49:28 +03:00
Result Transform ( clang : : Decl * D ) override ;
Handle returns, temporary results, independent on JIT's runFunction.
Here we don't want to depend on the JIT runFunction, because of its limitations,
when it comes to return value handling. There it is not clear who provides the
storage and who cleans it up in a platform independent way.
Depending on the type we need to synthesize a call to cling:
0) void : do nothing;
1) enum, integral, float, double, referece, pointer types :
call to cling::internal::setValueNoAlloc(...);
2) object type (alloc on the stack) :
cling::internal::setValueWithAlloc
2.1) constant arrays:
call to cling::runtime::internal::copyArray(...)
We need to synthesize later (see RuntimeUniverse.h)
Wrapper has signature: void w(cling::StoredValueRef SVR)
case 1):
setValueNoAlloc(gCling, &SVR, lastExprTy, lastExpr())
case 2):
new (setValueWithAlloc(gCling, &SVR, lastExprTy)) (lastExpr)
case 2.1):
copyArray(src, placement, N)
2014-02-18 01:53:21 +04:00
private :
///\brief
/// Here we don't want to depend on the JIT runFunction, because of its
/// limitations, when it comes to return value handling. There it is
/// not clear who provides the storage and who cleans it up in a
/// platform independent way.
//
/// Depending on the type we need to synthesize a call to cling:
/// 0) void : do nothing;
2014-04-04 17:13:18 +04:00
/// 1) enum, integral, float, double, referece, pointer types :
Handle returns, temporary results, independent on JIT's runFunction.
Here we don't want to depend on the JIT runFunction, because of its limitations,
when it comes to return value handling. There it is not clear who provides the
storage and who cleans it up in a platform independent way.
Depending on the type we need to synthesize a call to cling:
0) void : do nothing;
1) enum, integral, float, double, referece, pointer types :
call to cling::internal::setValueNoAlloc(...);
2) object type (alloc on the stack) :
cling::internal::setValueWithAlloc
2.1) constant arrays:
call to cling::runtime::internal::copyArray(...)
We need to synthesize later (see RuntimeUniverse.h)
Wrapper has signature: void w(cling::StoredValueRef SVR)
case 1):
setValueNoAlloc(gCling, &SVR, lastExprTy, lastExpr())
case 2):
new (setValueWithAlloc(gCling, &SVR, lastExprTy)) (lastExpr)
case 2.1):
copyArray(src, placement, N)
2014-02-18 01:53:21 +04:00
/// call to cling::internal::setValueNoAlloc(...);
/// 2) object type (alloc on the stack) :
/// cling::internal::setValueWithAlloc
/// 2.1) constant arrays:
/// call to cling::runtime::internal::copyArray(...)
2014-04-04 17:13:18 +04:00
///
Handle returns, temporary results, independent on JIT's runFunction.
Here we don't want to depend on the JIT runFunction, because of its limitations,
when it comes to return value handling. There it is not clear who provides the
storage and who cleans it up in a platform independent way.
Depending on the type we need to synthesize a call to cling:
0) void : do nothing;
1) enum, integral, float, double, referece, pointer types :
call to cling::internal::setValueNoAlloc(...);
2) object type (alloc on the stack) :
cling::internal::setValueWithAlloc
2.1) constant arrays:
call to cling::runtime::internal::copyArray(...)
We need to synthesize later (see RuntimeUniverse.h)
Wrapper has signature: void w(cling::StoredValueRef SVR)
case 1):
setValueNoAlloc(gCling, &SVR, lastExprTy, lastExpr())
case 2):
new (setValueWithAlloc(gCling, &SVR, lastExprTy)) (lastExpr)
case 2.1):
copyArray(src, placement, N)
2014-02-18 01:53:21 +04:00
/// We need to synthesize later:
2014-03-09 16:53:19 +04:00
/// Wrapper has signature: void w(cling::Value V)
Handle returns, temporary results, independent on JIT's runFunction.
Here we don't want to depend on the JIT runFunction, because of its limitations,
when it comes to return value handling. There it is not clear who provides the
storage and who cleans it up in a platform independent way.
Depending on the type we need to synthesize a call to cling:
0) void : do nothing;
1) enum, integral, float, double, referece, pointer types :
call to cling::internal::setValueNoAlloc(...);
2) object type (alloc on the stack) :
cling::internal::setValueWithAlloc
2.1) constant arrays:
call to cling::runtime::internal::copyArray(...)
We need to synthesize later (see RuntimeUniverse.h)
Wrapper has signature: void w(cling::StoredValueRef SVR)
case 1):
setValueNoAlloc(gCling, &SVR, lastExprTy, lastExpr())
case 2):
new (setValueWithAlloc(gCling, &SVR, lastExprTy)) (lastExpr)
case 2.1):
copyArray(src, placement, N)
2014-02-18 01:53:21 +04:00
/// case 1):
/// setValueNoAlloc(gCling, &SVR, lastExprTy, lastExpr())
/// case 2):
/// new (setValueWithAlloc(gCling, &SVR, lastExprTy)) (lastExpr)
/// case 2.1):
/// copyArray(src, placement, N)
///
2014-04-04 17:13:18 +04:00
clang : : Expr * SynthesizeSVRInit ( clang : : Expr * E ) ;
Handle returns, temporary results, independent on JIT's runFunction.
Here we don't want to depend on the JIT runFunction, because of its limitations,
when it comes to return value handling. There it is not clear who provides the
storage and who cleans it up in a platform independent way.
Depending on the type we need to synthesize a call to cling:
0) void : do nothing;
1) enum, integral, float, double, referece, pointer types :
call to cling::internal::setValueNoAlloc(...);
2) object type (alloc on the stack) :
cling::internal::setValueWithAlloc
2.1) constant arrays:
call to cling::runtime::internal::copyArray(...)
We need to synthesize later (see RuntimeUniverse.h)
Wrapper has signature: void w(cling::StoredValueRef SVR)
case 1):
setValueNoAlloc(gCling, &SVR, lastExprTy, lastExpr())
case 2):
new (setValueWithAlloc(gCling, &SVR, lastExprTy)) (lastExpr)
case 2.1):
copyArray(src, placement, N)
2014-02-18 01:53:21 +04:00
2014-08-04 06:05:42 +04:00
// Find and cache cling::runtime::gCling, setValueNoAlloc,
Handle returns, temporary results, independent on JIT's runFunction.
Here we don't want to depend on the JIT runFunction, because of its limitations,
when it comes to return value handling. There it is not clear who provides the
storage and who cleans it up in a platform independent way.
Depending on the type we need to synthesize a call to cling:
0) void : do nothing;
1) enum, integral, float, double, referece, pointer types :
call to cling::internal::setValueNoAlloc(...);
2) object type (alloc on the stack) :
cling::internal::setValueWithAlloc
2.1) constant arrays:
call to cling::runtime::internal::copyArray(...)
We need to synthesize later (see RuntimeUniverse.h)
Wrapper has signature: void w(cling::StoredValueRef SVR)
case 1):
setValueNoAlloc(gCling, &SVR, lastExprTy, lastExpr())
case 2):
new (setValueWithAlloc(gCling, &SVR, lastExprTy)) (lastExpr)
case 2.1):
copyArray(src, placement, N)
2014-02-18 01:53:21 +04:00
// setValueWithAlloc on first request.
void FindAndCacheRuntimeDecls ( ) ;
2012-10-15 17:42:09 +04:00
} ;
} // namespace cling
2014-02-18 14:33:12 +04:00
# endif // CLING_VALUE_EXTRACTION_SYNTHESIZER_H