#ifndef STMT__H_
#define STMT__H_
#include < stdio.h >
#include " Vector.h "
#include " Expression.h "
#include " CodeRepo.h "
typedef struct Stmt_t CStmt;
typedef struct Stmt_VMT ... {
void(*generate)(CStmt*, FILE*);
} CStmt_VMT;
struct Stmt_t ... {
const CStmt_VMT* vmt;
int srcLineNo;
} ;
extern void CStmt_Initialize(CStmt * , int );
extern void CStmt_Generate(CStmt * , FILE * );
#define Stmt_Generate(this,arg)
(((CStmt * ) this ) -> vmt -> generate((CStmt * )( this ),arg))
#endif
#define STMT__H_
#include < stdio.h >
#include " Vector.h "
#include " Expression.h "
#include " CodeRepo.h "
typedef struct Stmt_t CStmt;
typedef struct Stmt_VMT ... {
void(*generate)(CStmt*, FILE*);
} CStmt_VMT;
struct Stmt_t ... {
const CStmt_VMT* vmt;
int srcLineNo;
} ;
extern void CStmt_Initialize(CStmt * , int );
extern void CStmt_Generate(CStmt * , FILE * );
#define Stmt_Generate(this,arg)
(((CStmt * ) this ) -> vmt -> generate((CStmt * )( this ),arg))
#endif
#include
"
Stmt.h
"
static const CStmt_VMT vmt = ... { CStmt_Generate } ;
void CStmt_Initialize(CStmt * this , int no)
... {
((CStmt*)this)->vmt = (const CStmt_VMT*)&vmt;
this->srcLineNo = no;
}
void CStmt_Generate(CStmt * this , FILE * output)
... {
}
static const CStmt_VMT vmt = ... { CStmt_Generate } ;
void CStmt_Initialize(CStmt * this , int no)
... {
((CStmt*)this)->vmt = (const CStmt_VMT*)&vmt;
this->srcLineNo = no;
}
void CStmt_Generate(CStmt * this , FILE * output)
... {
}
#include
"
IfStmt.h
"
extern int subprog;
static const CIfStmt_VMT vmt = ... {CIfStmt_Generate} ;
void CIfStmt_Initialize(CIfStmt * this , int no,CExpression * cond, Vector * ifpart, Vector * elsepart)
... {
CStmt_Initialize((CStmt*)this, no);
((CStmt*)(this))->vmt = (const CStmt_VMT*)&vmt;
this->ifpart = ifpart;
this->elspart = elsepart;
this->condition = cond;
}
void CIfStmt_Generate(CIfStmt * this , FILE * output)
... {
int i;
if(subprog)...{
fprintf(output, "setCursor2 %d ", ((CStmt*)this)->srcLineNo - getRef(((CStmt*)this)->srcLineNo) + 1);
}
else...{
fprintf(output, "setCursor %d ", ((CStmt*)this)->srcLineNo - getRef(((CStmt*)this)->srcLineNo));
}
fprintf(output, "If ");
if(this->condition != NULL)...{
Expression_Generate(this->condition, output);
}
fprintf(output, " Then ");
if(this->ifpart != NULL)...{
for(i = 0; i < size(this->ifpart); i++)...{
Stmt_Generate(elementAt(this->ifpart, i), output);
}
}
if(this->elspart != NULL)...{
fprintf(output, "Else ");
for(i = 0; i < size(this->elspart); i++)...{
Stmt_Generate(elementAt(this->elspart, i), output);
}
}
fprintf(output, "End If ");
}
extern int subprog;
static const CIfStmt_VMT vmt = ... {CIfStmt_Generate} ;
void CIfStmt_Initialize(CIfStmt * this , int no,CExpression * cond, Vector * ifpart, Vector * elsepart)
... {
CStmt_Initialize((CStmt*)this, no);
((CStmt*)(this))->vmt = (const CStmt_VMT*)&vmt;
this->ifpart = ifpart;
this->elspart = elsepart;
this->condition = cond;
}
void CIfStmt_Generate(CIfStmt * this , FILE * output)
... {
int i;
if(subprog)...{
fprintf(output, "setCursor2 %d ", ((CStmt*)this)->srcLineNo - getRef(((CStmt*)this)->srcLineNo) + 1);
}
else...{
fprintf(output, "setCursor %d ", ((CStmt*)this)->srcLineNo - getRef(((CStmt*)this)->srcLineNo));
}
fprintf(output, "If ");
if(this->condition != NULL)...{
Expression_Generate(this->condition, output);
}
fprintf(output, " Then ");
if(this->ifpart != NULL)...{
for(i = 0; i < size(this->ifpart); i++)...{
Stmt_Generate(elementAt(this->ifpart, i), output);
}
}
if(this->elspart != NULL)...{
fprintf(output, "Else ");
for(i = 0; i < size(this->elspart); i++)...{
Stmt_Generate(elementAt(this->elspart, i), output);
}
}
fprintf(output, "End If ");
}