本文整理汇总了C++中FunctionDefinition类的典型用法代码示例。如果您正苦于以下问题:C++ FunctionDefinition类的具体用法?C++ FunctionDefinition怎么用?C++ FunctionDefinition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FunctionDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: START_TEST
END_TEST
START_TEST ( test_uncertml_write_normalDistribution)
{
const char *expected =
"<UncertML xmlns=\"http://www.uncertml.org/3.0\">\n"
" <NormalDistribution definition=\"http://www.uncertml.org/distributions/normal\">\n"
" <mean>\n"
" <var varId=\"mu\"/>\n"
" </mean>\n"
" <variance>\n"
" <var varId=\"sigma\"/>\n"
" </variance>\n"
" </NormalDistribution>\n"
"</UncertML>";
char *filename = safe_strcat(TestDataDirectory, "normalDistrib.xml");
SBMLDocument *document = readSBMLFromFile(filename);
fail_unless ( document->getModel() != NULL );
FunctionDefinition * fd = document->getModel()->getFunctionDefinition(0);
DistribFunctionDefinitionPlugin * plug =
static_cast<DistribFunctionDefinitionPlugin*>(fd->getPlugin("distrib"));
const DrawFromDistribution * d = plug->getDrawFromDistribution();
const UncertMLNode * uncert = d->getUncertML();
std::string xml = uncert->toXMLString();
fail_unless( equals(expected, xml.c_str()) );
}
示例2: main
int main(int argc, char* argv[])
{
std::cout << "\n Testing ActionsAndRules class\n "
<< std::string(30,'=') << std::endl;
try
{
//std::queue<std::string> resultsQ;
PrintPreproc pp;
PreprocStatement pps;
pps.addAction(&pp);
FunctionDefinition fnd;
PrintFunction prt;
fnd.addAction(&prt);
Toker toker("../ActionsAndRules.h");
SemiExp se(&toker);
Parser parser(&se);
parser.addRule(&pps);
parser.addRule(&fnd);
while(se.get())
parser.parse();
std::cout << "\n\n";
}
catch(std::exception& ex)
{
std::cout << "\n\n " << ex.what() << "\n\n";
}
}
示例3: StatementList
void CodeGenVisitor::JIT(Expression* e) {
StatementList* sl = new StatementList();
sl->addStatement(new ReturnStatement(e));
FunctionDefinition* fd = new FunctionDefinition(Type::INT, "", new ParameterList(), sl);
value_ = 0;
fd->accept(this);
if (!value_) {
delete fd;
throw "error evaluating expression";
}
llvm::Function* f = dynamic_cast<llvm::Function*>(value_);
void* fPtr = ee_->getPointerToFunction(f);
// some casting ... because we like magic
int (*fP)() = (int (*)())(intptr_t)fPtr;
std::cout << "Evaluated to: " << fP() << std::endl;
// throw it away
f->eraseFromParent();
}
示例4: reset
void AdaptSignatureAssistant::textChanged(KTextEditor::View* view, const KTextEditor::Range& invocationRange, const QString& removedText)
{
reset();
m_view = view;
//FIXME: update signature assistant to play well with the rename assistant
KTextEditor::Range sigAssistRange = invocationRange;
if (!removedText.isEmpty()) {
sigAssistRange.setRange(sigAssistRange.start(), sigAssistRange.start());
}
m_document = view->document()->url();
DUChainReadLocker lock(DUChain::lock(), 300);
if(!lock.locked()) {
qCDebug(CPP) << "failed to lock duchain in time";
return;
}
KTextEditor::Range simpleInvocationRange = KTextEditor::Range(sigAssistRange);
Declaration* funDecl = getDeclarationAtCursor(simpleInvocationRange.start(), m_document);
if(!funDecl || !funDecl->type<FunctionType>())
return;
if(QtFunctionDeclaration* classFun = dynamic_cast<QtFunctionDeclaration*>(funDecl)) {
if (classFun->isSignal()) {
// do not offer to change signature of a signal, as the implementation will be generated by moc
return;
}
}
Declaration* otherSide = 0;
FunctionDefinition* definition = dynamic_cast<FunctionDefinition*>(funDecl);
if (definition)
{
m_editingDefinition = true;
otherSide = definition->declaration();
}
else if ((definition = FunctionDefinition::definition(funDecl)))
{
m_editingDefinition = false;
otherSide = definition;
}
if (!otherSide)
return;
m_otherSideContext = DUContextPointer(DUChainUtils::getFunctionContext(otherSide));
if (!m_otherSideContext)
return;
m_declarationName = funDecl->identifier();
m_otherSideId = otherSide->id();
m_otherSideTopContext = ReferencedTopDUContext(otherSide->topContext());
m_oldSignature = getDeclarationSignature(otherSide, m_otherSideContext.data(), true);
//Schedule an update, to make sure the ranges match
DUChain::self()->updateContextForUrl(m_otherSideTopContext->url(), TopDUContext::AllDeclarationsAndContexts);
}
示例5: MMOFunction
void
MMOModel::add (const FunctionDefinition &f)
{
string fname = f.getId ();
MMOFunction *func = new MMOFunction (fname);
int na = f.getNumArguments ();
MMOMath d = MMOMath (_replace, &_functions, _prefix);
list<string> funcArgs;
for (int i = 0; i < na; i++)
{
d.parseEquation (f.getArgument (i));
string argExp = d.getExp ();
MMODecl *adec = new MMODecl (argExp, function_input);
func->add (adec);
funcArgs.push_back (argExp);
}
string var = MMOUtils::getInstance ()->getVar ();
d.parseEquation (f.getBody ());
_addAlgebraicReplacement (d);
MMODecl *adec = new MMODecl (var, d.getExp (), function_definition);
func->add (adec);
_functions[fname] = pair<list<string>, ASTNode*> (
funcArgs, new ASTNode (*f.getBody ()));
_add (func, external_functions);
}
示例6:
void
FunctionDefinitionRecursion::addDependencies(const Model& m,
const FunctionDefinition& object)
{
unsigned int ns;
std::string thisId = object.getId();
/* loop thru the list of names in the Math
* if they refer to a FunctionDefinition add to the map
* with the variable as key
*/
List* variables = object.getMath()->getListOfNodes( ASTNode_isFunction );
for (ns = 0; ns < variables->getSize(); ns++)
{
ASTNode* node = static_cast<ASTNode*>( variables->get(ns) );
string name = node->getName() ? node->getName() : "";
if (m.getFunctionDefinition(name))
{
mIdMap.insert(pair<const std::string, std::string>(thisId, name));
}
}
delete variables;
}
示例7:
CodeGen::CodeGen(AbstractSyntaxTree *tree) {
for(unsigned i = 0; i < tree->functions.size(); ++i) {
FunctionDefinition *fn = tree->functions[i];
currentFn = fn;
Value *f = fn->codegen();
}
}
示例8: writeLine
bool ASTPrinter::visit(FunctionDefinition const& _node)
{
writeLine("FunctionDefinition \"" + _node.getName() + "\"" +
(_node.isPublic() ? " - public" : "") +
(_node.isDeclaredConst() ? " - const" : ""));
printSourcePart(_node);
return goDeeper();
}
示例9: AbstractNavigationContext
AbstractDeclarationNavigationContext::AbstractDeclarationNavigationContext( DeclarationPointer decl, KDevelop::TopDUContextPointer topContext, AbstractNavigationContext* previousContext)
: AbstractNavigationContext((topContext ? topContext : TopDUContextPointer(decl ? decl->topContext() : 0)), previousContext), m_declaration(decl), m_fullBackwardSearch(false)
{
//Jump from definition to declaration if possible
FunctionDefinition* definition = dynamic_cast<FunctionDefinition*>(m_declaration.data());
if(definition && definition->declaration())
m_declaration = DeclarationPointer(definition->declaration());
}
示例10: configureRuleForFunction
FunctionDefinition* configureRuleForFunction(Parser* pParser, Repository* pRepo)
{
FunctionDefinition* pFunctionDefinition = new FunctionDefinition();
PushFunction* pPushFunction = new PushFunction(pRepo);
AddFunctionNode* pAddFunctionNode = new AddFunctionNode(pRepo);
pFunctionDefinition->addAction(pPushFunction);
pFunctionDefinition->addAction(pAddFunctionNode);
pParser->addRule(pFunctionDefinition);
return pFunctionDefinition;
}
示例11: START_TEST
END_TEST
START_TEST ( test_FunctionDefinition_parent_create )
{
Model *m = new Model(2, 4);
FunctionDefinition *fd = m->createFunctionDefinition();
ListOf *lo = m->getListOfFunctionDefinitions();
fail_unless(lo == m->getFunctionDefinition(0)->getParentSBMLObject());
fail_unless(lo == fd->getParentSBMLObject());
fail_unless(m == lo->getParentSBMLObject());
}
示例12: START_TEST
END_TEST
START_TEST ( test_FunctionDefinition )
{
FunctionDefinition* fd = new FunctionDefinition(2, 4);
fail_unless (!(fd->hasRequiredAttributes()));
fd->setId("fd");
fail_unless (fd->hasRequiredAttributes());
delete fd;
}
示例13: START_TEST
END_TEST
START_TEST ( test_FunctionDefinition )
{
FunctionDefinition* fd = new FunctionDefinition(2, 4);
fail_unless (!(fd->hasRequiredElements()));
fd->setMath(SBML_parseFormula("fd"));
fail_unless (fd->hasRequiredElements());
delete fd;
}
示例14: main
int main(int argc, char* argv[])
{
std::cout << "\n Testing ActionsAndRules class\n "
<< std::string(30,'=') << std::endl;
RelationshipAnal* p = new RelationshipAnal;
TypeAnal* q = new TypeAnal;
try
{
PrintPreproc pp;
PreprocStatement pps;
pps.addAction(&pp);
FunctionDefinition fnd;
PrintFunction prt;
fnd.addAction(&prt);
ClassStructEnumDefinition cls1;
std::vector<std::string> classResult;
PrintClass cls2(&classResult);
cls1.addAction(&cls2);
InheritanceDetection* cls3 = new InheritanceDetection;
InheritanceAction* cls4 = new InheritanceAction(q, p);
cls3->addAction(cls4);
Toker toker("../ActionsAndRules.h");
SemiExp se(&toker);
Parser parser(&se);
parser.addRule(&pps);
parser.addRule(&fnd);
parser.addRule(&cls1);
parser.addRule(cls3);
while(se.get())
parser.parse();
std::cout << "\n\n";
}
catch(std::exception& ex)
{
std::cout << "\n\n " << ex.what() << "\n\n";
}
}
示例15: main
int main(int argc, char* argv[])
{
std::cout << "\n Testing ActionsAndRules class\n "
<< std::string(30,'=') << std::endl;
try
{
std::queue<std::string> resultsQ;
PreprocToQ ppq(resultsQ);
//Modified Pallavi
PrintPreproc ppq;
PreprocStatement pps;
pps.addAction(&ppq);
FunctionDefinition fnd;
PrettyPrintToQ pprtQ(resultsQ);
//Modified Pallavi
PrettyPrintFunction pprtQ;
fnd.addAction(&pprtQ);
Toker toker("../ActionsAndRules.h");
SemiExp se(&toker);
Parser parser(&se);
parser.addRule(&pps);
parser.addRule(&fnd);
while(se.get())
parser.parse();
size_t len = resultsQ.size();
for(size_t i=0; i<len; ++i)
{
std::cout << "\n " << resultsQ.front().c_str();
resultsQ.pop();
}
std::cout << "\n\n";
}
catch(std::exception& ex)
{
std::cout << "\n\n " << ex.what() << "\n\n";
}
}
开发者ID:pallaviiyengar,项目名称:RemotePerformanceAssistant,代码行数:44,代码来源:127.0.0.1_8588_ActionsAndRules.cpp