Project

General

Profile

7 krennw
/**
*
* OOAS Compiler - C++ AST
*
* Copyright 2015, AIT Austrian Institute of Technology.
* All rights reserved.
*
* SEE THE "LICENSE" FILE FOR THE TERMS UNDER WHICH THIS FILE IS PROVIDED.
*
* If you modify the file please update the list of contributors below to in-
* clude your name. Please also stick to the coding convention of using TABs
* to do the basic (block-level) indentation and spaces for anything after
* that. (Enable the display of special chars and it should be pretty obvious
* what this means.) Also, remove all trailing whitespace.
*
* Contributors:
* Willibald Krenn (AIT)
* Stephan Zimmerer (AIT)
* Christoph Czurda (AIT)
*
*/
2 krennw


#include "ProtoBufAstTraversal.hpp"
#include <tiresias.h>
#include <cstdint>
#include <iostream>
#include <fstream>
#include <boost/format.hpp>

namespace Ast {

ProtoBufAstTraversal::ProtoBufAstTraversal (CallContext* context) :
m_context(context)
{}

ProtoBufAstTraversal::~ProtoBufAstTraversal () {}

void* ProtoBufAstTraversal::deserialize(){
GOOGLE_PROTOBUF_VERIFY_VERSION;

// read in the serialized AST
serialize::PBAstTraversal traversal;
std::fstream input(m_context->m_astLocation, std::ios::in | std::ios::binary);
if (!traversal.ParseFromIstream(&input)) {
std::cerr << "Failed to parse seralized ast from " << m_context->m_astLocation << std::endl;
throw;
}

return doDeserialize(traversal);
}


void* ProtoBufAstTraversal::deserialize(const std::uint8_t * buffer, std::uint32_t size) {
GOOGLE_PROTOBUF_VERIFY_VERSION;

// read in the serialized AST
serialize::PBAstTraversal traversal;
if (!traversal.ParseFromArray(buffer, size)) {
std::cerr << "Failed to parse seralized ast from memory buffer." << std::endl;
throw;
}

return doDeserialize(traversal);
}

void* ProtoBufAstTraversal::doDeserialize(serialize::PBAstTraversal & traversal) {
// Function calls may be passed a null reference, which has no UUID assigned.
// Instead it is tagged "NULL" and must be mapped to a nullptr manually.
m_objects[0] = (void*) nullptr;

for(int i = 0; i < traversal.calls_size(); i++){
const serialize::PBFunctionCall& call = traversal.calls(i);

if(call.has_allocate())
allocate(call);
else if (call.has_add())
add(call);
else if (call.has_identifier())
identifier(call);
else if (call.has_type())
type(call);
else if (call.has_statement())
statement(call);
else if (call.has_expression())
expression(call);
}

void* result = m_objects.at(traversal.main_module());

// Delete all global objects allocated by libprotobuf.
google::protobuf::ShutdownProtobufLibrary();

return result;
}


/**
* Calls to allocation functions, like create identifier etc
* */
void ProtoBufAstTraversal::allocate(const serialize::PBFunctionCall& call){
void* object;

switch (call.allocate()) {
case serialize::PBAllocation::TIRESIAS_CREATE_IDENTIFIER :
{
// DLL void* TIRESIAS_CREATE_IDENTIFIER(void* context, std::int32_t ordinal, std::int32_t subOrd);
object = TIRESIAS_CREATE_IDENTIFIER (m_context
5 krennw
, call.parameters(0).int32_value()
, call.parameters(1).int32_value());
2 krennw
break;
}
case serialize::PBAllocation::TIRESIAS_CREATE_TYPE :
{
// DLL void* TIRESIAS_CREATE_TYPE(void* context, std::int32_t ordinal);
5 krennw
object = TIRESIAS_CREATE_TYPE (m_context, call.parameters(0).int32_value());
2 krennw
break;
}
case serialize::PBAllocation::TIRESIAS_CREATE_STATEMENT :
{
// DLL void* TIRESIAS_CREATE_STATEMENT(void* context, std::int32_t ordinal);
5 krennw
object = TIRESIAS_CREATE_STATEMENT (m_context, call.parameters(0).int32_value());
2 krennw
break;
}
case serialize::PBAllocation::TIRESIAS_CREATE_EXPRESSION :
{
// DLL void* TIRESIAS_CREATE_EXPRESSION(void* context, std::int32_t ordinal, std::int32_t subOrd);
object = TIRESIAS_CREATE_EXPRESSION (m_context
5 krennw
, call.parameters(0).int32_value()
, call.parameters(1).int32_value());
2 krennw
break;
}
case serialize::PBAllocation::TIRESIAS_CREATE_IDENTIFIERLIST :
{
object = TIRESIAS_CREATE_IDENTIFIERLIST (m_context);
break;
}
case serialize::PBAllocation::TIRESIAS_CREATE_TYPELIST :
{
object = TIRESIAS_CREATE_TYPELIST (m_context);
break;
}
case serialize::PBAllocation::TIRESIAS_CREATE_STATEMENTLIST :
{
object = TIRESIAS_CREATE_STATEMENTLIST (m_context);
break;
}
case serialize::PBAllocation::TIRESIAS_CREATE_EXPRESSIONLIST :
{
object = TIRESIAS_CREATE_EXPRESSIONLIST (m_context);
break;
}
case serialize::PBAllocation::TIRESIAS_CREATE_SYMBTAB :
{
object = TIRESIAS_CREATE_SYMBTAB (m_context);
break;
}
case serialize::PBAllocation::TIRESIAS_CREATE_PARAMLIST :
{
object = TIRESIAS_CREATE_PARAMLIST (m_context);
break;
}
case serialize::PBAllocation::TIRESIAS_CREATE_ACTIONSYSTEMINSTANCE :
{
object = TIRESIAS_CREATE_ACTIONSYSTEMINSTANCE (m_context);
break;
}
case serialize::PBAllocation::TIRESIAS_CREATE_ACTIONSYSTEMINSTANCELIST :
{
object = TIRESIAS_CREATE_ACTIONSYSTEMINSTANCELIST (m_context);
break;
}
case serialize::PBAllocation::TIRESIAS_CAST_ASTELEMENT_TO_ISCOPE :
{
// DLL void* TIRESIAS_CAST_ASTELEMENT_TO_ISCOPE(void* context, void* astelement);
5 krennw
object = TIRESIAS_CAST_ASTELEMENT_TO_ISCOPE(m_context
, m_objects.at(call.parameters(0).uint64_value()));
2 krennw
break;
}
default:
m_context->logError("Unknown value for enum PBAllocation.");
abort();
}

std::uint64_t id = call.return_value().return_id();
m_objects[id] = object;
}

/**
* Calls to functions that add objects to containers, like add identifier to symboltable etc.
* */
void ProtoBufAstTraversal::add(const serialize::PBFunctionCall& call){
switch (call.add()) {
case serialize::PBAdd::TIRESIAS_ADD_IDENTIFIERTOLIST :
{
// DLL bool TIRESIAS_ADD_IDENTIFIERTOLIST(void* context, void* idList, void* idRef);
TIRESIAS_ADD_IDENTIFIERTOLIST (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, m_objects.at(call.parameters(1).uint64_value()));
2 krennw
break;
}
case serialize::PBAdd::TIRESIAS_ADD_TYPETOLIST :
{
// DLL bool TIRESIAS_ADD_TYPETOLIST(void* context, void* typeList, void* type);
TIRESIAS_ADD_TYPETOLIST (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, m_objects.at(call.parameters(1).uint64_value()));
2 krennw
break;
}
case serialize::PBAdd::TIRESIAS_ADD_STATEMENTTOLIST :
{
// DLL bool TIRESIAS_ADD_STATEMENTTOLIST(void* context, void* stmtList, void* stmntRef);
TIRESIAS_ADD_STATEMENTTOLIST (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, m_objects.at(call.parameters(1).uint64_value()));
2 krennw
break;
}
case serialize::PBAdd::TIRESIAS_ADD_EXPRESSIONTOLIST :
{
// DLL bool TIRESIAS_ADD_EXPRESSIONTOLIST(void* context, void* exprList, void* exprRef);
TIRESIAS_ADD_EXPRESSIONTOLIST (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, m_objects.at(call.parameters(1).uint64_value()));
2 krennw
break;
}
case serialize::PBAdd::TIRESIAS_ADD_IDTOSYMBTAB :
{
// DLL bool TIRESIAS_ADD_IDTOSYMBTAB(void* context, void* symbolTable, void* identifier);
TIRESIAS_ADD_IDTOSYMBTAB (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, m_objects.at(call.parameters(1).uint64_value()));
2 krennw
break;
}
case serialize::PBAdd::TIRESIAS_ADD_PARAMTOLIST :
{
// DLL bool TIRESIAS_ADD_PARAMTOLIST(void* context, void* parameterList, void* par);
TIRESIAS_ADD_PARAMTOLIST (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, m_objects.at(call.parameters(1).uint64_value()));
2 krennw
break;
}
case serialize::PBAdd::TIRESIAS_ADD_ACTIONSYSTEMINSTANCETOLIST :
{
// DLL bool TIRESIAS_ADD_ACTIONSYSTEMINSTANCETOLIST(void* context, void* objectsList, void* instanceRef);
TIRESIAS_ADD_ACTIONSYSTEMINSTANCETOLIST (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, m_objects.at(call.parameters(1).uint64_value()));
2 krennw
break;
}
case serialize::PBAdd::TIRESIAS_ADD_IDENTIFIERTOBLOCK :
{
// DLL bool TIRESIAS_ADD_IDENTIFIERTOBLOCK(void* context, void* idList, void* idRef);
TIRESIAS_ADD_IDENTIFIERTOBLOCK (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, m_objects.at(call.parameters(1).uint64_value()));
2 krennw
break;
}
default:
m_context->logError("Unknown value for enum PBAdd.");
abort();
}
}

/**
* Calls to functions that initialize the various subtypes of Identifier.
* */
void ProtoBufAstTraversal::identifier(const serialize::PBFunctionCall& call){
5 krennw
bool ok = true;
2 krennw
switch (call.identifier()) {
case serialize::PBIdentifiers::TIRESIAS_INIT_ENUMIDENTIFIER :
{
// DLL bool TIRESIAS_INIT_ENUMIDENTIFIER(void* context,
// void* enumId, std::int32_t line, std::int32_t col, const char* text,
// void* scopeRef, void* typeRef, bool haveValue, std::int32_t value);
5 krennw
ok = TIRESIAS_INIT_ENUMIDENTIFIER (m_context
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, call.parameters(3).literal_value().c_str()
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value())
, call.parameters(6).bool_value()
, call.parameters(7).int32_value());
2 krennw
break;
}
case serialize::PBIdentifiers::TIRESIAS_INIT_CONSTIDENTIFIER :
{
// DLL bool TIRESIAS_INIT_CONSTIDENTIFIER(void* context,
// void* constId, std::int32_t line, std::int32_t col, const char* text,
// void* scopeRef, void* typeRef, void* valueRef);
5 krennw
ok = TIRESIAS_INIT_CONSTIDENTIFIER (m_context
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, call.parameters(3).literal_value().c_str()
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value())
, m_objects.at(call.parameters(6).uint64_value()));
2 krennw
break;
}
case serialize::PBIdentifiers::TIRESIAS_INIT_ATTRIDENTIFIER :
{
// DLL bool TIRESIAS_INIT_ATTRIDENTIFIER(void* context,
// void* attrId, std::int32_t line, std::int32_t col, const char* text,
// void* scopeRef, void* typeRef, void* initRef,
// bool isStatic, bool isControllable, bool isObservable);
5 krennw
ok = TIRESIAS_INIT_ATTRIDENTIFIER (m_context
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, call.parameters(3).literal_value().c_str()
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value())
, m_objects.at(call.parameters(6).uint64_value())
, call.parameters(7).bool_value()
, call.parameters(8).bool_value()
, call.parameters(9).bool_value());
2 krennw
break;
}
case serialize::PBIdentifiers::TIRESIAS_INIT_EXPRVARIDENTIFIER :
{
// DLL bool TIRESIAS_INIT_EXPRVARIDENTIFIER(void* context,
// void* exprVarId, std::int32_t line, std::int32_t col, const char* text,
// void* scopeRef, void* typeRef, bool initialized);
5 krennw
ok = TIRESIAS_INIT_EXPRVARIDENTIFIER (m_context
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, call.parameters(3).literal_value().c_str()
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value())
, call.parameters(6).bool_value());
2 krennw
break;
}
case serialize::PBIdentifiers::TIRESIAS_INIT_PARAMIDENTIFIER :
{
// DLL bool TIRESIAS_INIT_PARAMIDENTIFIER(void* context,
// void* paramId, std::int32_t line, std::int32_t column, const char* text,
// void* scopeRef, void* typeRef);
5 krennw
ok = TIRESIAS_INIT_PARAMIDENTIFIER (m_context
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, call.parameters(3).literal_value().c_str()
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value()));
2 krennw
break;
}
case serialize::PBIdentifiers::TIRESIAS_INIT_LOCVARIDENTIFIER :
{
// DLL bool TIRESIAS_INIT_LOCVARIDENTIFIER(void* context,
// void* locVarId, std::int32_t line, std::int32_t column, const char* text,
// void* scopeRef, void* typeRef);
5 krennw
ok = TIRESIAS_INIT_LOCVARIDENTIFIER (m_context
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, call.parameters(3).literal_value().c_str()
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value()));
2 krennw
break;
}
case serialize::PBIdentifiers::TIRESIAS_INIT_TYPEIDENTIFIER :
{
// DLL bool TIRESIAS_INIT_TYPEIDENTIFIER(void* context,
// void* typeId, std::int32_t line, std::int32_t column, const char* text,
// void* scopeRef, void* typeRef, const char* prefix);
5 krennw
ok = TIRESIAS_INIT_TYPEIDENTIFIER (m_context
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, call.parameters(3).literal_value().c_str()
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value())
, call.parameters(6).literal_value().c_str());
2 krennw
break;
}
case serialize::PBIdentifiers::TIRESIAS_INIT_SELFIDENTIFIER :
{
// DLL bool TIRESIAS_INIT_SELFIDENTIFIER(void* context,
// void* typeId, std::int32_t line, std::int32_t column, const char* text,
// void* scopeRef, void* typeRef, const char* prefix);
5 krennw
ok = TIRESIAS_INIT_SELFIDENTIFIER (m_context
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, call.parameters(3).literal_value().c_str()
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value())
, call.parameters(6).literal_value().c_str());
2 krennw
break;
}
case serialize::PBIdentifiers::TIRESIAS_INIT_METHODIDENTIFIER :
{
// DLL bool TIRESIAS_INIT_METHODIDENTIFIER(void* context,
// void* methodId, std::int32_t line, std::int32_t column, const char* text,
// void* scopeRef, void* typeRef, const char* prefix, void* parameterListRef,
// void* symbolTableRef, void* bodyRef);
5 krennw
ok = TIRESIAS_INIT_METHODIDENTIFIER (m_context
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, call.parameters(3).literal_value().c_str()
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value())
, call.parameters(6).literal_value().c_str()
, m_objects.at(call.parameters(7).uint64_value())
, m_objects.at(call.parameters(8).uint64_value())
, m_objects.at(call.parameters(9).uint64_value()));
2 krennw
break;
}
case serialize::PBIdentifiers::TIRESIAS_INIT_MODULE :
{
// DLL bool TIRESIAS_INIT_MODULE(void* context, void* moduleId,
// int line, int column, const char* text, void* scopeRef,
// void* typeRef, const char* prefix, void* symTabRef);
5 krennw
ok = TIRESIAS_INIT_MODULE (m_context
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, call.parameters(3).literal_value().c_str()
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value())
, call.parameters(6).literal_value().c_str()
, m_objects.at(call.parameters(7).uint64_value()));
2 krennw
break;
}
case serialize::PBIdentifiers::TIRESIAS_INIT_MAINMODULE :
{
// DLL bool TIRESIAS_INIT_MAINMODULE(void* context,
// void* moduleId, int line, int column, const char* text,
// void* scopeRef, void* typeRef, const char* prefix,
// void* symTabRef, void* identifierListRef);
5 krennw
ok = TIRESIAS_INIT_MAINMODULE (m_context
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, call.parameters(3).literal_value().c_str()
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value())
, call.parameters(6).literal_value().c_str()
, m_objects.at(call.parameters(7).uint64_value())
, m_objects.at(call.parameters(8).uint64_value()));
2 krennw
break;
}
default:
m_context->logError("Unknown value for enum PBIdentifiers.");
abort();
}
5 krennw
if (!ok) {
m_context->logError("Error initializing identifier.");
abort();
}
2 krennw
}

/**
* Calls to functions that initialize the various subtypes of Type.
* */
void ProtoBufAstTraversal::type(const serialize::PBFunctionCall& call){
switch (call.type()) {
case serialize::PBTypes::TIRESIAS_INIT_INTTYPE :
{
// DLL bool TIRESIAS_INIT_INTTYPE(void* context, void* typeId,
// void* identifierRef, bool anonymousType, std::int32_t low,
// std::int32_t high);
TIRESIAS_INIT_INTTYPE (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, m_objects.at(call.parameters(1).uint64_value())
, call.parameters(2).bool_value()
, call.parameters(3).int32_value()
, call.parameters(4).int32_value());
2 krennw
break;
}
case serialize::PBTypes::TIRESIAS_INIT_BOOLTYPE :
{
// DLL bool TIRESIAS_INIT_BOOLTYPE(void* context, void* typeId,
// void* identifierRef, bool anonymousType);
TIRESIAS_INIT_BOOLTYPE (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, m_objects.at(call.parameters(1).uint64_value())
, call.parameters(2).bool_value());
2 krennw
break;
}
case serialize::PBTypes::TIRESIAS_INIT_VALUEDENUMTYPE :
{
// DLL bool TIRESIAS_INIT_VALUEDENUMTYPE(void* context,
// void* typeId, void* identifierRef,
// bool anonymousType, void* symTabRef, void* intTypeRef);
TIRESIAS_INIT_VALUEDENUMTYPE (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, m_objects.at(call.parameters(1).uint64_value())
, call.parameters(2).bool_value()
, m_objects.at(call.parameters(3).uint64_value())
, m_objects.at(call.parameters(4).uint64_value()));
2 krennw
break;
}
case serialize::PBTypes::TIRESIAS_INIT_ENUMTYPE :
{
// DLL bool TIRESIAS_INIT_ENUMTYPE(void* context, void* typeId,
// void* identifierRef, bool anonymousType,
// void* symTabRef);
TIRESIAS_INIT_ENUMTYPE (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, m_objects.at(call.parameters(1).uint64_value())
, call.parameters(2).bool_value()
, m_objects.at(call.parameters(3).uint64_value()));
2 krennw
break;
}
case serialize::PBTypes::TIRESIAS_INIT_LISTTYPE :
{
// DLL bool TIRESIAS_INIT_LISTTYPE(void* context, void* typeId,
// void* identifierRef, bool anonymousType,
// void* innerTypeRef, std::uint32_t maxNumberOfElements);
TIRESIAS_INIT_LISTTYPE (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, m_objects.at(call.parameters(1).uint64_value())
, call.parameters(2).bool_value()
, m_objects.at(call.parameters(3).uint64_value())
, call.parameters(4).uint32_value());
2 krennw
break;
}
case serialize::PBTypes::TIRESIAS_INIT_TUPLETYPE :
{
// DLL bool TIRESIAS_INIT_TUPLETYPE(void* context, void* typeId,
// void* identifierRef, bool anonymousType,
// void* typeListRef);
TIRESIAS_INIT_TUPLETYPE (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, m_objects.at(call.parameters(1).uint64_value())
, call.parameters(2).bool_value()
, m_objects.at(call.parameters(3).uint64_value()));
2 krennw
break;
}
case serialize::PBTypes::TIRESIAS_INIT_FUNCTIONTYPE :
{
// DLL bool TIRESIAS_INIT_FUNCTIONTYPE(void* context,
// void* typeId, void* identifierRef,
// bool anonymousType, void* paramTypeListRef,
// void* returnTypeRef, std::int32_t functionKind, bool isPure);
TIRESIAS_INIT_FUNCTIONTYPE (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, m_objects.at(call.parameters(1).uint64_value())
, call.parameters(2).bool_value()
, m_objects.at(call.parameters(3).uint64_value())
, m_objects.at(call.parameters(4).uint64_value())
, call.parameters(5).int32_value()
, call.parameters(6).bool_value());
2 krennw
break;
}
case serialize::PBTypes::TIRESIAS_INIT_ACTIONSYSTEMINSTANCE :
{
// DLL bool TIRESIAS_INIT_ACTIONSYSTEMINSTANCE(void* context,
// void* instance, void* typeRef, const char* name,
// std::int32_t numOfCreatedObjs, void* parentInstanceRef);
TIRESIAS_INIT_ACTIONSYSTEMINSTANCE (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, m_objects.at(call.parameters(1).uint64_value())
, call.parameters(2).literal_value().c_str()
, call.parameters(3).int32_value()
, m_objects.at(call.parameters(4).uint64_value()));
2 krennw
break;
}
case serialize::PBTypes::TIRESIAS_INIT_ACTIONSYSTEMTYPE :
{
// DLL bool TIRESIAS_INIT_ACTIONSYSTEMTYPE(void* context,
// void* typeId, void* identifierRef,
// bool anonymousType, void* baseTypeRef,
// void* parentScopeRef, void* doOdBlockRef,
// void* symTab, void* objectsListRef,
// void* derivedObjectsListRef, bool autoConstruction,
// bool isInSystemDescription);
TIRESIAS_INIT_ACTIONSYSTEMTYPE (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, m_objects.at(call.parameters(1).uint64_value())
, call.parameters(2).bool_value()
, m_objects.at(call.parameters(3).uint64_value())
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value())
, m_objects.at(call.parameters(6).uint64_value())
, m_objects.at(call.parameters(7).uint64_value())
, m_objects.at(call.parameters(8).uint64_value())
, call.parameters(9).bool_value()
, call.parameters(10).bool_value());
2 krennw
break;
}
case serialize::PBTypes::TIRESIAS_INIT_NULLTYPE :
{
// DLL bool TIRESIAS_INIT_NULLTYPE(void* context, void* typeId,
// void* identifierRef, bool anonymousType);
TIRESIAS_INIT_NULLTYPE (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, m_objects.at(call.parameters(1).uint64_value())
, call.parameters(2).bool_value());
2 krennw
break;
}
default:
m_context->logError("Unknown value for enum PBTypes.");
abort();

}
}

/**
* Calls to functions that initialize the various subtypes of Statement.
* */
void ProtoBufAstTraversal::statement(const serialize::PBFunctionCall& call){
switch (call.statement()) {
case serialize::PBStatements::TIRESIAS_INIT_SKIP :
{
// DLL bool TIRESIAS_INIT_SKIP(void* context, void* stmnt,
// std::int32_t line, std::int32_t col);
TIRESIAS_INIT_SKIP (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value());
2 krennw
break;
}
case serialize::PBStatements::TIRESIAS_INIT_BREAK :
{
// DLL bool TIRESIAS_INIT_BREAK(void* context, void* stmnt,
// std::int32_t line, std::int32_t col);
TIRESIAS_INIT_BREAK (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value());
2 krennw
break;
}
case serialize::PBStatements::TIRESIAS_INIT_ABORT :
{
// DLL bool TIRESIAS_INIT_ABORT(void* context, void* stmnt,
// std::int32_t line, std::int32_t col);
TIRESIAS_INIT_ABORT (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value());
2 krennw
break;
}
case serialize::PBStatements::TIRESIAS_INIT_NONDETBLOCK :
{
// DLL bool TIRESIAS_INIT_NONDETBLOCK(void* context, void* block,
// std::int32_t line, std::int32_t col, void* symTabRef, void* stmtListRef,
// void* scopeRef);
TIRESIAS_INIT_NONDETBLOCK (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, m_objects.at(call.parameters(3).uint64_value())
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value()));
2 krennw
break;
}
case serialize::PBStatements::TIRESIAS_INIT_SEQBLOCK :
{
// DLL bool TIRESIAS_INIT_SEQBLOCK(void* context, void* block,
// std::int32_t line, std::int32_t col, void* symTabRef, void* stmtListRef,
// void* scopeRef, void* filterExprRef);
TIRESIAS_INIT_SEQBLOCK (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, m_objects.at(call.parameters(3).uint64_value())
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value())
, m_objects.at(call.parameters(6).uint64_value()));
2 krennw
break;
}
case serialize::PBStatements::TIRESIAS_INIT_PRIOBLOCK :
{
// DLL bool TIRESIAS_INIT_PRIOBLOCK(void* context, void* block,
// std::int32_t line, std::int32_t col, void* symTabRef, void* stmtListRef,
// void* scopeRef);
TIRESIAS_INIT_PRIOBLOCK (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, m_objects.at(call.parameters(3).uint64_value())
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value()));
2 krennw
break;
}
case serialize::PBStatements::TIRESIAS_INIT_GUARDEDCOMMAND :
{
// DLL bool TIRESIAS_INIT_GUARDEDCOMMAND(void* context,
// void* stmt, std::int32_t line, std::int32_t pos, void* scopeRef,
// void* guardExprRef, void* bodyRef);
TIRESIAS_INIT_GUARDEDCOMMAND (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, m_objects.at(call.parameters(3).uint64_value())
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value()));
2 krennw
break;
}
case serialize::PBStatements::TIRESIAS_INIT_ASSIGNMENT :
{
// DLL bool TIRESIAS_INIT_ASSIGNMENT(void* context, void* stmt,
// std::int32_t line, std::int32_t pos, void* scopeRef, void* nonDetExprRef,
// void* placeExprListRef, void* valueExprListRef,
// void* symTabRef);
TIRESIAS_INIT_ASSIGNMENT (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, m_objects.at(call.parameters(3).uint64_value())
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value())
, m_objects.at(call.parameters(6).uint64_value())
, m_objects.at(call.parameters(7).uint64_value()));
2 krennw
break;
}
case serialize::PBStatements::TIRESIAS_INIT_CALL :
{
// DLL bool TIRESIAS_INIT_CALL(void* context, void* stmt,
// std::int32_t line, std::int32_t pos, void* callExprRef);
TIRESIAS_INIT_CALL (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, m_objects.at(call.parameters(3).uint64_value()));
2 krennw
break;
}
default:
m_context->logError("Unknown value for enum PBStatements.");
abort();
}
}

/**
* Calls to functions that initialize the various subtypes of Expression.
* */
void ProtoBufAstTraversal::expression(const serialize::PBFunctionCall& call){
switch (call.expression()) {
case serialize::PBExpressions::TIRESIAS_INIT_TYPEEXPRESSION :
{
// DLL bool TIRESIAS_INIT_TYPEEXPRESSION(void* context,
// void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
// void* callTargetsIdentifierListRef, void* symbTabRef);
TIRESIAS_INIT_TYPEEXPRESSION (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, m_objects.at(call.parameters(3).uint64_value())
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value()));
2 krennw
break;
}
case serialize::PBExpressions::TIRESIAS_INIT_IDENTIFIEREXPRESSION :
{
// DLL bool TIRESIAS_INIT_IDENTIFIEREXPRESSION(void* context,
// void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
// void* callTargetsIdentifierListRef, void* symbTabRef,
// void* identifierRef, bool isSelf);
TIRESIAS_INIT_IDENTIFIEREXPRESSION (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, m_objects.at(call.parameters(3).uint64_value())
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value())
, m_objects.at(call.parameters(6).uint64_value())
, call.parameters(7).bool_value());
2 krennw
break;
}
case serialize::PBExpressions::TIRESIAS_INIT_UNARYEXPRESSION :
{
// DLL bool TIRESIAS_INIT_UNARYEXPRESSION(void* context,
// void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
// void* callTargetsIdentifierListRef, void* symbTabRef,
// void* child);
TIRESIAS_INIT_UNARYEXPRESSION (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, m_objects.at(call.parameters(3).uint64_value())
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value())
, m_objects.at(call.parameters(6).uint64_value()));
2 krennw
break;
}
case serialize::PBExpressions::TIRESIAS_INIT_BINARYEXPRESSION :
{
// DLL bool TIRESIAS_INIT_BINARYEXPRESSION(void* context,
// void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
// void* callTargetsIdentifierListRef, void* symbTabRef,
// void* left, void* right);
TIRESIAS_INIT_BINARYEXPRESSION (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, m_objects.at(call.parameters(3).uint64_value())
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value())
, m_objects.at(call.parameters(6).uint64_value())
, m_objects.at(call.parameters(7).uint64_value()));
2 krennw
break;
}
case serialize::PBExpressions::TIRESIAS_INIT_TERNARYEXPRESSION :
{
// DLL bool TIRESIAS_INIT_TERNARYEXPRESSION(void* context,
// void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
// void* callTargetsIdentifierListRef, void* symbTabRef,
// void* left, void* mid, void* right, void* defScopeRef);
TIRESIAS_INIT_TERNARYEXPRESSION (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, m_objects.at(call.parameters(3).uint64_value())
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value())
, m_objects.at(call.parameters(6).uint64_value())
, m_objects.at(call.parameters(7).uint64_value())
, m_objects.at(call.parameters(8).uint64_value())
, m_objects.at(call.parameters(9).uint64_value()));
2 krennw
break;
}
case serialize::PBExpressions::TIRESIAS_INIT_INTVALUEEXPRESSION :
{
// DLL bool TIRESIAS_INIT_INTVALUEEXPRESSION(void* context,
// void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
// void* callTargetsIdentifierListRef, void* symbTabRef,
// std::int32_t value);
TIRESIAS_INIT_INTVALUEEXPRESSION (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, m_objects.at(call.parameters(3).uint64_value())
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value())
, call.parameters(6).int32_value());
2 krennw
break;
}
case serialize::PBExpressions::TIRESIAS_INIT_BOOLVALUEEXPRESSION :
{
// DLL bool TIRESIAS_INIT_BOOLVALUEEXPRESSION(void* context,
// void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
// void* callTargetsIdentifierListRef, void* symbTabRef,
// bool value);
TIRESIAS_INIT_BOOLVALUEEXPRESSION (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, m_objects.at(call.parameters(3).uint64_value())
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value())
, call.parameters(6).bool_value());
2 krennw
break;
}
case serialize::PBExpressions::TIRESIAS_INIT_REFVALUEEXPRESSION :
{
// DLL bool TIRESIAS_INIT_REFVALUEEXPRESSION(void* context,
// void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
// void* callTargetsIdentifierListRef, void* symbTabRef,void* object);
TIRESIAS_INIT_REFVALUEEXPRESSION (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, m_objects.at(call.parameters(3).uint64_value())
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value())
, m_objects.at(call.parameters(6).uint64_value()));
2 krennw
break;
}
case serialize::PBExpressions::TIRESIAS_INIT_LISTCONSTRUCTOR :
{
// DLL bool TIRESIAS_INIT_LISTCONSTRUCTOR(void* context,
// void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
// void* callTargetsIdentifierListRef, void* symbTabRef,
// void* exprList, void* symTab, void* parentScope,
// void* comprehension, bool hasComprehension);
TIRESIAS_INIT_LISTCONSTRUCTOR (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, m_objects.at(call.parameters(3).uint64_value())
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value())
, m_objects.at(call.parameters(6).uint64_value())
, m_objects.at(call.parameters(7).uint64_value())
, m_objects.at(call.parameters(8).uint64_value())
, m_objects.at(call.parameters(9).uint64_value())
, call.parameters(10).bool_value());
2 krennw
break;
}
case serialize::PBExpressions::TIRESIAS_INIT_SETCONSTRUCTOR :
{
// DLL bool TIRESIAS_INIT_SETCONSTRUCTOR(void* context,
// void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
// void* callTargetsIdentifierListRef, void* symbTabRef,
// void* exprList, void* symTab, void* parentScope,
// void* comprehension, bool hasComprehension);
TIRESIAS_INIT_SETCONSTRUCTOR (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, m_objects.at(call.parameters(3).uint64_value())
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value())
, m_objects.at(call.parameters(6).uint64_value())
, m_objects.at(call.parameters(7).uint64_value())
, m_objects.at(call.parameters(8).uint64_value())
, m_objects.at(call.parameters(9).uint64_value())
, call.parameters(10).bool_value());
2 krennw
break;
}
case serialize::PBExpressions::TIRESIAS_INIT_TUPLECONSTRUCTOR :
{
// DLL bool TIRESIAS_INIT_TUPLECONSTRUCTOR(void* context,
// void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
// void* callTargetsIdentifierListRef, void* symbTabRef,
// void* exprList, void* tupleTypeId, bool isMatcher);
TIRESIAS_INIT_TUPLECONSTRUCTOR (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, m_objects.at(call.parameters(3).uint64_value())
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value())
, m_objects.at(call.parameters(6).uint64_value())
, m_objects.at(call.parameters(7).uint64_value())
, call.parameters(8).bool_value());
2 krennw
break;
}
case serialize::PBExpressions::TIRESIAS_INIT_ACCESSEXPRESSION :
{
// DLL bool TIRESIAS_INIT_ACCESSEXPRESSION(void* context,
// void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
// void* callTargetsIdentifierListRef, void* symbTabRef,
// void* left, void* right);
TIRESIAS_INIT_ACCESSEXPRESSION (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, m_objects.at(call.parameters(3).uint64_value())
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value())
, m_objects.at(call.parameters(6).uint64_value())
, m_objects.at(call.parameters(7).uint64_value()));
2 krennw
break;
}
case serialize::PBExpressions::TIRESIAS_INIT_TUPLEMAPACCESSEXPRESSION :
{
// DLL bool TIRESIAS_INIT_TUPLEMAPACCESSEXPRESSION(void* context,
// void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
// void* callTargetsIdentifierListRef, void* symbTabRef,
// void* child, void* argument);
TIRESIAS_INIT_TUPLEMAPACCESSEXPRESSION (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, m_objects.at(call.parameters(3).uint64_value())
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value())
, m_objects.at(call.parameters(6).uint64_value())
, m_objects.at(call.parameters(7).uint64_value()));
2 krennw
break;
}
case serialize::PBExpressions::TIRESIAS_INIT_CALLEXPRESSION :
{
// DLL bool TIRESIAS_INIT_CALLEXPRESSION(void* context,
// void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
// void* callTargetsIdentifierListRef, void* symbTabRef,
// void* child, void* argumentList, void* scopeRef);
TIRESIAS_INIT_CALLEXPRESSION (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, m_objects.at(call.parameters(3).uint64_value())
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value())
, m_objects.at(call.parameters(6).uint64_value())
, m_objects.at(call.parameters(7).uint64_value())
, m_objects.at(call.parameters(8).uint64_value()));
2 krennw
break;
}
case serialize::PBExpressions::TIRESIAS_INIT_QUANTIFIEREXPRESSION :
{
// DLL bool TIRESIAS_INIT_QUANTIFIEREXPRESSION(void* context,
// void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
// void* callTargetsIdentifierListRef, void* symbTabRef,
// void* child, void* symTabRef, void* scopeRef);
TIRESIAS_INIT_QUANTIFIEREXPRESSION (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, m_objects.at(call.parameters(3).uint64_value())
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value())
, m_objects.at(call.parameters(6).uint64_value())
, m_objects.at(call.parameters(7).uint64_value())
, m_objects.at(call.parameters(8).uint64_value()));
2 krennw
break;
}
case serialize::PBExpressions::TIRESIAS_INIT_OBJECTCONSTRUCTOR :
{
// DLL bool TIRESIAS_INIT_OBJECTCONSTRUCTOR(void* context,
// void* expr, std::int32_t line, std::int32_t pos, void* typeRef,
// void* callTargetsIdentifierListRef, void* symbTabRef,
// void* instanceList, std::uint32_t currentInstance, const char* name);
TIRESIAS_INIT_OBJECTCONSTRUCTOR (m_context
5 krennw
, m_objects.at(call.parameters(0).uint64_value())
, call.parameters(1).int32_value()
, call.parameters(2).int32_value()
, m_objects.at(call.parameters(3).uint64_value())
, m_objects.at(call.parameters(4).uint64_value())
, m_objects.at(call.parameters(5).uint64_value())
, m_objects.at(call.parameters(6).uint64_value())
, call.parameters(7).uint32_value()
, call.parameters(8).literal_value().c_str());
2 krennw
break;
}
default:
m_context->logError("Unknown value for enum PBExpressions.");
abort();
}
}

}