Page Menu
Home
Xreate
Search
Configure Global Search
Log In
Docs
Questions
Repository
Issues
Patches
Internal API
Files
F2731021
abstractpass.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Mar 14, 2:49 AM
Size
2 KB
Mime Type
text/x-c++
Expires
Mon, Mar 16, 2:49 AM (1 d, 15 h)
Engine
blob
Format
Raw Data
Handle
242886
Attached To
rXR Xreate
abstractpass.cpp
View Options
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Author: pgess <v.melnychenko@xreate.org>
*/
/**
* \file abstractpass.h
* \brief Infrastructure to iterate over AST to facilitate analysis and compilation.
*/
#include "abstractpass.h"
#include "attachments.h"
#include "xreatemanager.h"
using namespace std;
namespace xreate {
template<>
void defaultValue<void>(){}
void IPass::finish(){}
IPass::IPass(PassManager *manager)
: man(manager) {
}
template<>
void
AbstractPass<void>::processSymbol(const Symbol& symbol, PassContext context, const std::string& hintSymbol)
{
if (__visitedSymbols.isCached(symbol))
return;
__visitedSymbols.setCachedValue(symbol);
const Expression& declaration = CodeScope::getDefinition(symbol);
if (declaration.isDefined()){
PassContext context2 = context.updateScope(symbol.scope);
process(declaration, context2, hintSymbol);
}
}
template<>
void
AbstractPass<void>::process(const Expression& expression, PassContext context, const std::string& varDecl){
if (expression.__state == Expression::COMPOUND){
for (const Expression &op: expression.getOperands()) {
process(op, context);
}
for (CodeScope* scope: expression.blocks) {
process(scope, context);
}
if (expression.op == Operator::CALL){
processExpressionCall(expression, context);
}
return;
}
if (expression.__state == Expression::IDENT){
assert(context.scope);
processSymbol(Attachments::get<Symbol>(expression), context, expression.getValueString());
}
}
}
/**
* \class xreate::IPass
*
* Each pass has to have IPass interface to be controllable by XreateManager.
* However in most cases users should inherit minimal useful implementation xreate::AbstractPass
*
* \note It's usually expected that custom Pass publish processing results by one of the following means:
* - xreate::Attachments for communicating with other Passes
* - IAnalysisReport to feed xreate::ClaspLayer solver
*
* \sa xreate::XreateManager, xreate::AbstractPass
*/
/**
* \class xreate::AbstractPass
*
* Iterates over %AST and provides functions to alter processing of particular %AST nodes.
* Thus client should not re-implement every possible node processing
* and it's enough to focus only on relevant nodes.
*
* Template parameter `Output` specify type of node processing result data.
*
* Automatically caches already visited nodes
*
* \note It's usually expected that custom Pass publish processing results by one of the following means:
* - xreate::Attachments for communicating with other Passes
* - IAnalysisReport to feed xreate::ClaspLayer solver
*
*
* \sa xreate::XreateManager, xreate::IPass, xreate::AST
*/
Event Timeline
Log In to Comment