Page Menu
Home
Xreate
Search
Configure Global Search
Log In
Docs
Questions
Repository
Issues
Patches
Internal API
Files
F4826293
interpretation-instructions.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
Tue, Aug 25, 10:36 AM
Size
2 KB
Mime Type
text/x-c++
Expires
Thu, Aug 27, 10:36 AM (1 d, 4 h)
Engine
blob
Format
Raw Data
Handle
287102
Attached To
rXR Xreate
interpretation-instructions.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>
* Created on June 15, 2018, 5:32 PM
*
*/
#include "compilation/interpretation-instructions.h"
#include "analysis/interpretation.h"
#include "transcendlayer.h"
#include "targets.h"
using namespace std;
namespace xreate{
namespace interpretation{
Expression
IntrinsicQueryInstruction::process(const Expression& expression) {
AST* ast = static_cast<TargetInterpretation*> (__scope->function->man)->ast;
TranscendLayer* transcend = static_cast<TargetInterpretation*> (__scope->function->man)->pass->man->transcend;
InterpretationFunction* function = static_cast<InterpretationFunction*> (__scope->function);
ExpandedType targetT = ast->expandType(expression.type);
assert(expression.operands.size() == 1);
assert(expression.operands.front().__state == Expression::STRING);
assert(targetT->__operator == TypeOperator::LIST);
std::string namePredicate = expression.operands.front().getValueString();
StaticModel model = (static_cast<TargetInterpretation*> (function->man))->pass->man->transcend->query(namePredicate);
Expression result(Operator::LIST,{});
result.operands.reserve(model.size());
ExpandedType elementT = targetT->__operands.at(0).__operator == TypeOperator::SLAVE
? dereferenceSlaveType(ExpandedType(targetT->__operands.at(0)), transcend)
: ExpandedType(targetT->__operands.at(0));
if(model.size()) {
if (elementT->__operator == TypeOperator::LIST_NAMED) {
//edge case, content's type is LIST_NAMED:
for(const auto& row : model) {
result.operands.push_back(representTransExpression(row.second, elementT, transcend));
}
} else {
for (const auto& row : model) {
assert(row.second.args().size);
result.operands.push_back(representTransExpression(row.second.args()[0], elementT, transcend));
}
}
}
return result;
}
}
} //end of xreate::interpretation
Event Timeline
Log In to Comment