Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ifndef __TLL_SEMANTICS_StackCounter_H__
- #define __TLL_SEMANTICS_StackCounter_H__
- #include "semantics/SemanticProcessor.h"
- #include "nodes/all.h" // automatically generated
- namespace tll {
- namespace semantics {
- class StackCounter : public virtual SemanticProcessor {
- int _num_bytes;
- public:
- StackCounter() : _num_bytes(0){}
- public:
- inline int num_bytes(){
- return _num_bytes;
- }
- public:
- inline ~StackCounter(){}
- public:
- template<typename T> void processSimple(cdk::node::expression::Simple<T> * const node,
- int lvl) {}
- void processInteger(cdk::node::expression::Integer * const node, int lvl){}
- void processDouble(cdk::node::expression::Double * const node, int lvl){}
- void processString(cdk::node::expression::String * const node, int lvl){}
- void processIdentifier(cdk::node::expression::Identifier * const node, int lvl){}
- public:
- void processUnaryExpression(cdk::node::expression::UnaryExpression * const node, int lvl){}
- void processNEG(cdk::node::expression::NEG * const node, int lvl){}
- public:
- void processExpressionTrash(tll::node::expression::ExpressionTrash * const node, int lvl){}
- public:
- void processBinaryExpression(cdk::node::expression::BinaryExpression * const node, int lvl) {}
- void processADD(cdk::node::expression::ADD * const node, int lvl){}
- void processSUB(cdk::node::expression::SUB * const node, int lvl){}
- void processMUL(cdk::node::expression::MUL * const node, int lvl){}
- void processDIV(cdk::node::expression::DIV * const node, int lvl){}
- void processMOD(cdk::node::expression::MOD * const node, int lvl){}
- void processLT(cdk::node::expression::LT * const node, int lvl){}
- void processLE(cdk::node::expression::LE * const node, int lvl){}
- void processGE(cdk::node::expression::GE * const node, int lvl){}
- void processGT(cdk::node::expression::GT * const node, int lvl){}
- void processNE(cdk::node::expression::NE * const node, int lvl){}
- void processEQ(cdk::node::expression::EQ * const node, int lvl){}
- public:
- void processADDRESS(tll::node::expression::ADDRESS * const node, int lvl){}
- void processLAND(tll::node::expression::LAND * const node, int lvl){}
- void processLOR(tll::node::expression::LOR * const node, int lvl){}
- void processMemoryAlloc(tll::node::expression::MemoryAlloc * const node, int lvl){}
- void processPOW(tll::node::expression::POW * const node, int lvl){}
- public:
- void processLeftValue(tll::node::expression::LeftValue * const node, int lvl){}
- void processAssignmentNode(tll::node::expression::AssignmentNode * const node, int lvl){}
- public:
- void processFileNode(tll::node::FileNode * const node, int lvl){
- node->declarations()->accept(this, lvl);
- }
- void processTLLFunctionNode(tll::node::FunctionNode * const node, int lvl){
- _num_bytes += node->type()->size(); // return of this function allocated
- node->body()->accept(this, lvl);
- }
- void processDeclarationNode(tll::node::DeclarationNode * const node, int lvl){
- node->node()->accept(this, lvl);
- }
- public:
- void processVariableInitializationNode(tll::node::VariableInitializationNode * const node, int lvl){
- _num_bytes += node->type()->size();
- }
- void processVariableDefinitionNode(tll::node::VariableDefinitionNode * const node, int lvl){
- _num_bytes += node->type()->size();
- }
- void processVariableDeclarationNode(tll::node::VariableDefinitionNode * const node, int lvl){}
- void processFunctionArgumentsNode(tll::node::FunctionArgumentsNode * const node, int lvl){}
- void processFunctionParametersNode(tll::node::FunctionParametersNode * const node, int lvl){}
- void processFunctionNode(tll::node::FunctionNode * const node, int lvl){
- if(node->type() != NULL)
- _num_bytes += node->type()->size(); // return of this function allocated
- node->body()->accept(this, lvl);
- }
- void processFunctionDeclarationNode(tll::node::FunctionDeclarationNode * const node, int lvl){}
- void processFunctionInvocationNode(tll::node::expression::FunctionInvocationNode * const node, int lvl){}
- void processFunctionRecursiveInvocationNode(tll::node::expression::FunctionRecursiveInvocationNode * const node,
- int lvl){}
- void processFunctionReturnValue(tll::node::expression::FunctionReturnValue * const node, int lvl){}
- public:
- void processBlockInstructionNode(tll::node::BlockInstructionNode * const node, int lvl){
- if(node->declarationsblock() != NULL)
- node->declarationsblock()->accept(this, lvl);
- if(node->instructionsblock() != NULL)
- node->instructionsblock()->accept(this, lvl);
- }
- void processInstructionNode(tll::node::InstructionNode * const node, int lvl){}
- void processIndexationNode(tll::node::expression::IndexationNode * const node, int lvl){}
- void processRead(tll::node::expression::Read * const node, int lvl){}
- void processReadInteger(tll::node::expression::ReadInteger * const node, int lvl){}
- void processPrintNode(tll::node::PrintNode * const node, int lvl){}
- void processPrintlnNode(tll::node::PrintlnNode * const node, int lvl){}
- void processNextInstructionNode(tll::node::NextInstructionNode * const node, int lvl){}
- void processStopInstructionNode(tll::node::StopInstructionNode * const node, int lvl){}
- void processReturnInstructionNode(tll::node::ReturnInstructionNode * const node, int lvl){}
- public:
- void processIfThenElseInstructionNode(tll::node::IfThenElseInstructionNode * const node, int lvl){
- node->thenblock()->accept(this, lvl);
- node->elseblock()->accept(this, lvl);
- }
- void processIfThenInstructionNode(tll::node::IfThenInstructionNode * const node, int lvl){
- node->thenblock()->accept(this, lvl);
- }
- public:
- void processForDoInstructionNode(tll::node::ForDoInstructionNode * const node, int lvl){
- if(node->variablesblock() != NULL)
- node->variablesblock()->accept(this, lvl);
- node->doblock()->accept(this, lvl);
- }
- void processDoUntilElseInstructionNode(tll::node::DoUntilElseInstructionNode * const node, int lvl){
- node->block()->accept(this, lvl);
- if(node->elseblock() != NULL)
- node->elseblock()->accept(this, lvl);
- }
- void processWhileDoElseInstructionNode(tll::node::WhileDoElseInstructionNode * const node, int lvl){
- node->doblock()->accept(this, lvl);
- if(node->elseblock() != NULL)
- node->elseblock()->accept(this, lvl);
- }
- void processNode(cdk::node::Node * const node, int lvl){}
- void processNil(cdk::node::Nil * const node, int lvl){}
- void processData(cdk::node::Data * const node, int lvl){}
- void processComposite(cdk::node::Composite * const node, int lvl){}
- void processLNEG(tll::node::expression::LNEG * const node, int lvl){}
- void processSequence(cdk::node::Sequence * const node, int lvl){
- for (size_t i = 0; i < node->size(); i++) {
- node->node(i)->accept(this, lvl);
- }
- }
- void processReverseSequence(tll::node::ReverseSequence * const node, int lvl){
- for (size_t i = node->size() - 1; i >= 0; i--) {
- node->node(i)->accept(this, lvl);
- }
- }
- }; // class StackCounter
- } // namespace semantics
- }// namespace tll
- #endif
Advertisement
Add Comment
Please, Sign In to add comment