本文整理汇总了C++中TRAVdo函数的典型用法代码示例。如果您正苦于以下问题:C++ TRAVdo函数的具体用法?C++ TRAVdo怎么用?C++ TRAVdo使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TRAVdo函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DBUG_ENTER
node *OSbinop (node *arg_node, info *arg_info)
{
DBUG_ENTER("OSbinop");
/*
* Extremely important:
* we must continue to traverse the abstract syntax tree !!
*/
BINOP_LEFT( arg_node) = TRAVdo( BINOP_LEFT( arg_node), arg_info);
BINOP_RIGHT( arg_node) = TRAVdo( BINOP_RIGHT( arg_node), arg_info);
if (BINOP_OP( arg_node) == BO_sub) {
if ((NODE_TYPE( BINOP_LEFT( arg_node)) == N_var)
&& (NODE_TYPE( BINOP_RIGHT( arg_node)) == N_var)
&& STReq( VAR_NAME( BINOP_LEFT( arg_node)), VAR_NAME( BINOP_RIGHT( arg_node)))) {
arg_node = FREEdoFreeTree( arg_node);
arg_node = TBmakeNum( 0);
}
else if ((NODE_TYPE( BINOP_LEFT( arg_node)) == N_num)
&& (NODE_TYPE( BINOP_RIGHT( arg_node)) == N_num)
&& (NUM_VALUE( BINOP_LEFT( arg_node)) == NUM_VALUE( BINOP_RIGHT( arg_node)))) {
arg_node = FREEdoFreeTree( arg_node);
arg_node = TBmakeNum( 0);
}
}
DBUG_RETURN( arg_node);
}
示例2: DBUG_ENTER
node *MDUNPACKdefs( node *arg_node, info *arg_info )
{
node *temp;
DBUG_ENTER("MDUNPACKmodule");
if(DEFS_DEF(arg_node) != NULL) {
DEFS_DEF(arg_node) = TRAVdo(DEFS_DEF(arg_node), arg_info);
}
if(DEFS_NEXT(arg_node) != NULL) {
DEFS_NEXT(arg_node) = TRAVdo(DEFS_NEXT(arg_node), arg_info);
}
if(DEFS_DEF(arg_node) == NULL) {
temp = DEFS_NEXT(arg_node);
FREEdoFreeNode(arg_node);
arg_node = temp;
}
DBUG_RETURN(arg_node);
}
示例3: DBUG_ENTER
/** <!--******************************************************************-->
*
* @fn MERRCODEtagexpr
*
* @brief Sets error code for the node and its sons
*
* @param arg_node TagExpr node to process
* @param arg_info pointer to info structure
*
* @return processed node
*
***************************************************************************/
node *MERRCODEtagexpr( node *arg_node, info *arg_info ){
DBUG_ENTER("MERRCODEtagexpr");
/* Set error code */
NODE_ERRCODE(arg_node)= STRcpy(INFO_ERRCODE(arg_info));
/* Visit sons */
if(TAGEXPR_STAG( arg_node)!= NULL){
TAGEXPR_STAG( arg_node)= TRAVdo( TAGEXPR_STAG( arg_node), arg_info);
}
if(TAGEXPR_BTAG( arg_node)!= NULL){
TAGEXPR_BTAG( arg_node)= TRAVdo( TAGEXPR_BTAG( arg_node), arg_info);
}
if(TAGEXPR_CONDITION( arg_node)!= NULL){
TAGEXPR_CONDITION( arg_node)= TRAVdo( TAGEXPR_CONDITION( arg_node), arg_info);
}
if(TAGEXPR_LEFT( arg_node)!= NULL){
TAGEXPR_LEFT( arg_node)= TRAVdo( TAGEXPR_LEFT( arg_node), arg_info);
}
if(TAGEXPR_RIGHT( arg_node)!= NULL){
TAGEXPR_RIGHT( arg_node)= TRAVdo( TAGEXPR_RIGHT( arg_node), arg_info);
}
/* Return value */
DBUG_RETURN(arg_node);
}
示例4: DBUG_ENTER
node *COPbinop (node *arg_node, info *arg_info)
{
DBUG_ENTER("COPbinop");
switch (BINOP_OP( arg_node)) {
case BO_add:
INFO_ADD( arg_info) = INFO_ADD( arg_info) + 1;
break;
case BO_sub:
INFO_SUB( arg_info) = INFO_SUB( arg_info) + 1;
break;
case BO_mul:
INFO_MUL( arg_info) = INFO_MUL( arg_info) + 1;
break;
case BO_div:
INFO_DIV( arg_info) = INFO_DIV( arg_info) + 1;
break;
case BO_mod:
INFO_MOD( arg_info) = INFO_MOD( arg_info) + 1;
break;
default:
break;
}
/*
* Extremely important:
* we must continue to traverse the abstract syntax tree !!
*/
BINOP_LEFT( arg_node) = TRAVdo( BINOP_LEFT( arg_node), arg_info);
BINOP_RIGHT( arg_node) = TRAVdo( BINOP_RIGHT( arg_node), arg_info);
DBUG_RETURN( arg_node);
}
示例5: DBUG_ENTER
//check parametertypes of funcall and give type of function to info_type
node *CTfuncall(node *arg_node, info *arg_info){
DBUG_ENTER("CTfuncall");
//check parameter types, if there are any
if(FUNCALL_ARGS(arg_node)!=NULL){
node *args = FUNCALL_ARGS(arg_node);
//check param type against expression type
node * param = FUNDEF_PARAMS(FSYMBOL_FUNCTION(FUNCALL_DECL(arg_node)));
EXPRS_EXPRS(args) = TRAVdo(EXPRS_EXPRS(args), arg_info);
type exprtype = INFO_TYPE(arg_info);
type paramtype = PARAM_TYPE(param);
if(exprtype != paramtype){
CTIerrorLine(NODE_LINE(arg_node), "argument type does not match function definition");
}
//keep checking till there are no parameters left
while(EXPRS_NEXT(args)!=NULL){
args = EXPRS_NEXT(args);
param = PARAM_NEXT(param);
EXPRS_EXPRS(args) = TRAVdo(EXPRS_EXPRS(args), arg_info);
exprtype = INFO_TYPE(arg_info);
paramtype = PARAM_TYPE(param);
if(exprtype != paramtype){
CTIerrorLine(NODE_LINE(arg_node), "argument type does not match function definition");
}
}
}
//set info_type to return type of the function
INFO_TYPE(arg_info) = FUNDEF_TYPE(FSYMBOL_FUNCTION(FUNCALL_DECL(arg_node)));
DBUG_RETURN(arg_node);
}
示例6: DBUG_ENTER
node *PREPTCHECKguardpatterns(node *arg_node, info *arg_info)
{
DBUG_ENTER("PREPTCHECKguardpatterns");
/* Store the guardpattern pattern for checks and continue traveling as normal */
INFO_PATTERN(arg_info) = GUARDPATTERNS_ENTRIES(arg_node);
if(GUARDPATTERNS_ENTRIES(arg_node) != NULL) {
GUARDPATTERNS_ENTRIES(arg_node) = TRAVdo(GUARDPATTERNS_ENTRIES(arg_node), arg_info);
}
if(GUARDPATTERNS_CONDITION(arg_node) != NULL) {
if(evaluatesToBoolean(GUARDPATTERNS_CONDITION(arg_node)) == FALSE){
errorExpectingB(arg_node, "if");
}
/* if sentence must have expression that evaluates to boolean value */
INFO_TAGS(arg_info) = 0;
GUARDPATTERNS_CONDITION(arg_node) = TRAVdo(GUARDPATTERNS_CONDITION(arg_node), arg_info);
if(INFO_TAGS(arg_info) == 0) {
warnStaticGuard(arg_node);
}
}
if(GUARDPATTERNS_NEXT(arg_node) != NULL) {
GUARDPATTERNS_NEXT(arg_node) = TRAVdo(GUARDPATTERNS_NEXT(arg_node), arg_info);
}
DBUG_RETURN(arg_node);
}
示例7: DBUG_ENTER
node *MDREMDUPmetadatakeylist( node *arg_node, info *arg_info )
{
node *temp;
DBUG_ENTER("MDREMDUPmetadatakeylist");
if(!INFO_IS_CHECKING(arg_info)) {
/* See if this node has a duplicate */
INFO_IS_CHECKING(arg_info) = TRUE;
INFO_CURRENT(arg_info) = arg_node;
INFO_IS_DUPLICATE(arg_info) = FALSE;
/* Search for duplicate */
if(METADATAKEYLIST_NEXT(arg_node) != NULL) {
METADATAKEYLIST_NEXT(arg_node) = TRAVdo(METADATAKEYLIST_NEXT(arg_node), arg_info);
}
if(INFO_IS_DUPLICATE(arg_info)) {
/* Handle rest of the lsit and then remove this node */
INFO_IS_CHECKING(arg_info) = FALSE;
if(METADATAKEYLIST_NEXT(arg_node) != NULL) {
temp = TRAVdo(METADATAKEYLIST_NEXT(arg_node), arg_info);
}
METADATAKEYLIST_NEXT(arg_node) = NULL;
FREEdoFreeNode(arg_node);
arg_node = temp;
} else {
/* Handle rest of the list */
INFO_IS_CHECKING(arg_info) = FALSE;
if(METADATAKEYLIST_NEXT(arg_node) != NULL) {
METADATAKEYLIST_NEXT(arg_node) = TRAVdo(METADATAKEYLIST_NEXT(arg_node), arg_info);
}
}
} else {
/* Check if this node is a duplicate with the current node */
if(STReq(METADATAKEYLIST_KEY(INFO_CURRENT(arg_info)), METADATAKEYLIST_KEY(arg_node))) {
INFO_IS_DUPLICATE(arg_info) = TRUE;
} else {
if(METADATAKEYLIST_NEXT(arg_node) != NULL) {
METADATAKEYLIST_NEXT(arg_node) = TRAVdo(METADATAKEYLIST_NEXT(arg_node), arg_info);
}
}
}
DBUG_RETURN(arg_node);
}
示例8: CTbinop
//check types of operands of binop and rewrite binop if neccessary
node * CTbinop(node *arg_node, info *arg_info){
DBUG_ENTER("CTbinop");
node *leftexpr = BINOP_LEFT(arg_node);
node *rightexpr = BINOP_RIGHT(arg_node);
//compare types of operands
BINOP_LEFT(arg_node) = TRAVdo(BINOP_LEFT(arg_node), arg_info);
type typeleft = INFO_TYPE(arg_info);
BINOP_RIGHT(arg_node) = TRAVdo(BINOP_RIGHT(arg_node), arg_info);
type typeright = INFO_TYPE(arg_info);
if(typeleft != typeright){
CTIerrorLine(NODE_LINE(arg_node), "Types of left and right expressions of the binop do not match");
}
//check if the right type of operands are used with the right operators
if((BINOP_OP(arg_node) == BO_and || BINOP_OP(arg_node) == BO_or)&&INFO_TYPE(arg_info)!=T_boolean){
CTIerrorLine(NODE_LINE(arg_node), "The used &&(and) or ||(or) operator can only compare two booleans");
}
if((BINOP_OP(arg_node) == BO_lt || BINOP_OP(arg_node) == BO_le ||BINOP_OP(arg_node) == BO_gt || BINOP_OP(arg_node) == BO_ge)
&& INFO_TYPE(arg_info) == T_boolean){
CTIerrorLine(NODE_LINE(arg_node), "The used operator can only compare two integers or floats");
}
if(BINOP_OP(arg_node) == BO_add ||BINOP_OP(arg_node) == BO_mul ||BINOP_OP(arg_node) == BO_sub ||BINOP_OP(arg_node) == BO_div ||
BINOP_OP(arg_node) == BO_mod ){
BINOP_OPTYPE(arg_node) = typeleft;
}
//set info_type to boolean
if(BINOP_OP(arg_node) == BO_lt || BINOP_OP(arg_node) == BO_le ||BINOP_OP(arg_node) == BO_gt || BINOP_OP(arg_node) == BO_ge ||
BINOP_OP(arg_node) == BO_eq || BINOP_OP(arg_node) == BO_ne || BINOP_OP(arg_node) == BO_and || BINOP_OP(arg_node) == BO_or){
INFO_TYPE(arg_info) = T_boolean;
BINOP_OPTYPE(arg_node) = typeleft;
}
else{
BINOP_OPTYPE(arg_node) = typeleft;
}
//rewrite and
if(BINOP_OP(arg_node)==BO_and){
node *then = TBmakeBool(0);
arg_node = TBmakeConditionexpr(leftexpr, then, rightexpr);
}
//rewrite or
else if(BINOP_OP(arg_node) == BO_or){
node *orthen = TBmakeBool(1);
arg_node = TBmakeConditionexpr(leftexpr, rightexpr, orthen);
}
DBUG_RETURN(arg_node);
}
示例9: DBUG_ENTER
node *PPLOCbranchlist( node *arg_node, info *arg_info )
{
DBUG_ENTER("PPLOCbranchlist");
int loc = INFO_LOC(arg_info);
BRANCHLIST_BRANCH(arg_node) = TRAVdo(BRANCHLIST_BRANCH(arg_node), arg_info);
INFO_LOC(arg_info) = loc;
if (BRANCHLIST_NEXT(arg_node) != NULL) {
BRANCHLIST_NEXT(arg_node) = TRAVdo(BRANCHLIST_NEXT(arg_node), arg_info);
}
DBUG_RETURN(arg_node);
}
示例10: PRTassign
node *
PRTassign (node * arg_node, info * arg_info)
{
DBUG_ENTER ("PRTassign");
if (ASSIGN_LET( arg_node) != NULL) {
ASSIGN_LET( arg_node) = TRAVdo( ASSIGN_LET( arg_node), arg_info);
printf( " = ");
}
ASSIGN_EXPR( arg_node) = TRAVdo( ASSIGN_EXPR( arg_node), arg_info);
printf( ";\n");
DBUG_RETURN (arg_node);
}
示例11: PRTerror
node *
PRTerror (node * arg_node, info * arg_info)
{
bool first_error;
DBUG_ENTER ("PRTerror");
if (NODE_ERROR (arg_node) != NULL) {
NODE_ERROR (arg_node) = TRAVdo (NODE_ERROR (arg_node), arg_info);
}
first_error = INFO_FIRSTERROR( arg_info);
if( (global.outfile != NULL)
&& (ERROR_ANYPHASE( arg_node) == global.compiler_anyphase)) {
if ( first_error) {
printf ( "\n/******* BEGIN TREE CORRUPTION ********\n");
INFO_FIRSTERROR( arg_info) = FALSE;
}
printf ( "%s\n", ERROR_MESSAGE( arg_node));
if (ERROR_NEXT (arg_node) != NULL) {
TRAVopt (ERROR_NEXT (arg_node), arg_info);
}
if ( first_error) {
printf ( "******** END TREE CORRUPTION *******/\n");
INFO_FIRSTERROR( arg_info) = TRUE;
}
}
DBUG_RETURN (arg_node);
}
示例12: DBUG_ENTER
node
*PRTdoPrint( node *syntaxtree)
{
info *info;
DBUG_ENTER("PRTdoPrint");
DBUG_ASSERT( (syntaxtree!= NULL), "PRTdoPrint called with empty syntaxtree");
printf( "\n\n------------------------------\n\n");
info = MakeInfo();
TRAVpush( TR_prt);
syntaxtree = TRAVdo( syntaxtree, info);
TRAVpop();
info = FreeInfo(info);
printf( "\n\n------------------------------\n\n");
DBUG_RETURN( syntaxtree);
}