LoadSymbolResolverBase

class LoadSymbolResolverBase : public rrllvm::LoadSymbolResolver

provide common sbml model functionality to three kinds of resolvers.

This has common functionality such as dealing with sbml elements such as reactions, species and so forth.

Subclassed by rrllvm::SBMLInitialValueSymbolResolver

Public Functions

llvm::Value *loadReactionRate(const libsbml::Reaction*)

shortcut to get a reaction rate, performance wise, quicker than going through all the loadSymbolValue types.

virtual void recursiveSymbolPush(const std::string &symbol) override
virtual void recursiveSymbolPop() override
virtual bool isLocalParameter(const std::string &symbol) override
void flushCache()

Flush the symbol cache.

This is required in branches and switch blocks as a symbol used in a previous block can not be re-used in the current block.

virtual size_t pushCacheBlock() override

nested conditionals (or functions?) can push a local cache block, where symbols would be chached.

These need to be popped as these symbols are not valid outside of the local conditional or scope block.

virtual size_t popCacheBlock() override

Pop a scoped cache block, this clears these values, and any subsequent reads re-evaluate the requested symbol.

Will throw an exception if an empty stack pop is attempted.

Protected Types

typedef std::list<std::string> StringStack
typedef std::unordered_map<std::string, llvm::Value*> ValueMap
typedef std::deque<ValueMap> ValueMapStack

Protected Functions

LoadSymbolResolverBase(const ModelGeneratorContext &ctx, llvm::Value *modelData)
llvm::Value *cacheValue(const std::string &symbol, const llvm::ArrayRef<llvm::Value*> &args, llvm::Value *value = nullptr)

check in the symbol cache if the symbol exists, if so return it.

If the value is not NULL, it is cached and returned.

Cached function args not currently supported (just return NULL).

Protected Attributes

const ModelGeneratorContext &modelGenContext
const libsbml::Model *model
const LLVMModelDataSymbols &modelDataSymbols
const LLVMModelSymbols &modelSymbols
llvm::IRBuilder &builder
llvm::Value *modelData
StringStack symbolStack
ValueMapStack symbolCache