Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

Stmt.cc File Reference

#include "config.h"
#include "Expr.h"
#include "Event.h"
#include "Frame.h"
#include "File.h"
#include "Logger.h"
#include "NetVar.h"
#include "Stmt.h"
#include "Scope.h"
#include "Var.h"
#include "Debug.h"
#include "Traverse.h"

Include dependency graph for Stmt.cc:

Include dependency graph

Go to the source code of this file.

Functions

const char * stmt_name (BroStmtTag t)
 IMPLEMENT_SERIAL (AlarmStmt, SER_ALARM_STMT)
 IMPLEMENT_SERIAL (PrintStmt, SER_PRINT_STMT)
 IMPLEMENT_SERIAL (ExprStmt, SER_EXPR_STMT)
 IMPLEMENT_SERIAL (IfStmt, SER_IF_STMT)
 IMPLEMENT_SERIAL (Case, SER_CASE)
 IMPLEMENT_SERIAL (SwitchStmt, SER_SWITCH_STMT)
 IMPLEMENT_SERIAL (AddStmt, SER_ADD_STMT)
 IMPLEMENT_SERIAL (DelStmt, SER_DEL_STMT)
 IMPLEMENT_SERIAL (EventStmt, SER_EVENT_STMT)
 IMPLEMENT_SERIAL (ForStmt, SER_FOR_STMT)
 IMPLEMENT_SERIAL (NextStmt, SER_NEXT_STMT)
 IMPLEMENT_SERIAL (BreakStmt, SER_BREAK_STMT)
 IMPLEMENT_SERIAL (ReturnStmt, SER_RETURN_STMT)
 IMPLEMENT_SERIAL (StmtList, SER_STMT_LIST)
 IMPLEMENT_SERIAL (EventBodyList, SER_EVENT_BODY_LIST)
 IMPLEMENT_SERIAL (InitStmt, SER_INIT_STMT)
 IMPLEMENT_SERIAL (NullStmt, SER_NULL_STMT)
Stmtsimplify_stmt (Stmt *s)
int same_stmt (const Stmt *s1, const Stmt *s2)

Variables

BroFileprint_stdout = 0


Function Documentation

IMPLEMENT_SERIAL NullStmt  ,
SER_NULL_STMT 
 

IMPLEMENT_SERIAL InitStmt  ,
SER_INIT_STMT 
 

IMPLEMENT_SERIAL EventBodyList  ,
SER_EVENT_BODY_LIST 
 

IMPLEMENT_SERIAL StmtList  ,
SER_STMT_LIST 
 

IMPLEMENT_SERIAL ReturnStmt  ,
SER_RETURN_STMT 
 

IMPLEMENT_SERIAL BreakStmt  ,
SER_BREAK_STMT 
 

IMPLEMENT_SERIAL NextStmt  ,
SER_NEXT_STMT 
 

IMPLEMENT_SERIAL ForStmt  ,
SER_FOR_STMT 
 

IMPLEMENT_SERIAL EventStmt  ,
SER_EVENT_STMT 
 

IMPLEMENT_SERIAL DelStmt  ,
SER_DEL_STMT 
 

IMPLEMENT_SERIAL AddStmt  ,
SER_ADD_STMT 
 

IMPLEMENT_SERIAL SwitchStmt  ,
SER_SWITCH_STMT 
 

IMPLEMENT_SERIAL Case  ,
SER_CASE 
 

IMPLEMENT_SERIAL IfStmt  ,
SER_IF_STMT 
 

IMPLEMENT_SERIAL ExprStmt  ,
SER_EXPR_STMT 
 

IMPLEMENT_SERIAL PrintStmt  ,
SER_PRINT_STMT 
 

IMPLEMENT_SERIAL AlarmStmt  ,
SER_ALARM_STMT 
 

int same_stmt const Stmt s1,
const Stmt s2
 

Definition at line 1692 of file Stmt.cc.

References SwitchStmt::Cases(), error(), IfStmt::FalseBranch(), loop_over_list, ForStmt::LoopBody(), ForStmt::LoopExpr(), ForStmt::LoopVar(), same_expr(), STMT_ADD, STMT_ALARM, STMT_BREAK, STMT_DELETE, STMT_EVENT, STMT_EVENT_BODY_LIST, STMT_EXPR, STMT_FOR, STMT_IF, STMT_INIT, STMT_LIST, STMT_NEXT, STMT_PRINT, STMT_RETURN, STMT_SWITCH, ExprStmt::StmtExpr(), Stmt::Tag(), and IfStmt::TrueBranch().

01693         {
01694         if ( s1 == s2 )
01695                 return 1;
01696 
01697         if ( s1->Tag() != s2->Tag() )
01698                 return 0;
01699 
01700         switch ( s1->Tag() ) {
01701         case STMT_ALARM:
01702         case STMT_PRINT:
01703                 {
01704                 const ListExpr* l1 = ((const ExprListStmt*) s1)->ExprList();
01705                 const ListExpr* l2 = ((const ExprListStmt*) s2)->ExprList();
01706                 return same_expr(l1, l2);
01707                 }
01708 
01709         case STMT_ADD:
01710         case STMT_DELETE:
01711         case STMT_RETURN:
01712         case STMT_EXPR:
01713         case STMT_EVENT:
01714                 {
01715                 const ExprStmt* e1 = (const ExprStmt*) s1;
01716                 const ExprStmt* e2 = (const ExprStmt*) s2;
01717                 return same_expr(e1->StmtExpr(), e2->StmtExpr());
01718                 }
01719 
01720         case STMT_FOR:
01721                 {
01722                 const ForStmt* f1 = (const ForStmt*) s1;
01723                 const ForStmt* f2 = (const ForStmt*) s2;
01724 
01725                 return f1->LoopVar() == f2->LoopVar() &&
01726                         same_expr(f1->LoopExpr(), f2->LoopExpr()) &&
01727                         same_stmt(f1->LoopBody(), f2->LoopBody());
01728                 }
01729 
01730         case STMT_IF:
01731                 {
01732                 const IfStmt* i1 = (const IfStmt*) s1;
01733                 const IfStmt* i2 = (const IfStmt*) s2;
01734 
01735                 if ( ! same_expr(i1->StmtExpr(), i2->StmtExpr()) )
01736                         return 0;
01737 
01738                 if ( i1->TrueBranch() || i2->TrueBranch() )
01739                         {
01740                         if ( ! i1->TrueBranch() || ! i2->TrueBranch() )
01741                                 return 0;
01742                         if ( ! same_stmt(i1->TrueBranch(), i2->TrueBranch()) )
01743                                 return 0;
01744                         }
01745 
01746                 if ( i1->FalseBranch() || i2->FalseBranch() )
01747                         {
01748                         if ( ! i1->FalseBranch() || ! i2->FalseBranch() )
01749                                 return 0;
01750                         if ( ! same_stmt(i1->FalseBranch(), i2->FalseBranch()) )
01751                                 return 0;
01752                         }
01753 
01754                 return 1;
01755                 }
01756 
01757         case STMT_SWITCH:
01758                 {
01759                 const SwitchStmt* sw1 = (const SwitchStmt*) s1;
01760                 const SwitchStmt* sw2 = (const SwitchStmt*) s2;
01761 
01762                 if ( ! same_expr(sw1->StmtExpr(), sw2->StmtExpr()) )
01763                         return 0;
01764 
01765                 const case_list* c1 = sw1->Cases();
01766                 const case_list* c2 = sw1->Cases();
01767 
01768                 if ( c1->length() != c2->length() )
01769                         return 0;
01770 
01771                 loop_over_list(*c1, i)
01772                         {
01773                         if ( ! same_expr((*c1)[i]->Cases(), (*c2)[i]->Cases()) )
01774                                 return 0;
01775                         if ( ! same_stmt((*c1)[i]->Body(), (*c2)[i]->Body()) )
01776                                 return 0;
01777                         }
01778 
01779                 return 1;
01780                 }
01781 
01782         case STMT_LIST:
01783         case STMT_EVENT_BODY_LIST:
01784                 {
01785                 const stmt_list& l1 = ((const StmtList*) s1)->Stmts();
01786                 const stmt_list& l2 = ((const StmtList*) s2)->Stmts();
01787 
01788                 if ( l1.length() != l2.length() )
01789                         return 0;
01790 
01791                 loop_over_list(l1, i)
01792                         if ( ! same_stmt(l1[i], l2[i]) )
01793                                 return 0;
01794 
01795                 return 1;
01796                 }
01797 
01798         case STMT_INIT:
01799                 {
01800                 const id_list* i1 = ((const InitStmt*) s1)->Inits();
01801                 const id_list* i2 = ((const InitStmt*) s2)->Inits();
01802 
01803                 if ( i1->length() != i2->length() )
01804                         return 0;
01805 
01806                 loop_over_list(*i1, i)
01807                         if ( (*i1)[i] != (*i2)[i] )
01808                                 return 0;
01809 
01810                 return 1;
01811                 }
01812 
01813         case STMT_NEXT:
01814         case STMT_BREAK:
01815         case STMT_NULL:
01816                 return 1;
01817 
01818         default:
01819                 error("bad tag in same_stmt()");
01820         }
01821 
01822         return 0;
01823         }

Stmt* simplify_stmt Stmt s  ) 
 

Definition at line 1681 of file Stmt.cc.

References Stmt::Simplify(), and Unref().

Referenced by IfStmt::DoSimplify(), SwitchStmt::DoSimplify(), ForStmt::DoSimplify(), and StmtList::Simplify().

01682         {
01683         for ( Stmt* ss = s->Simplify(); ss != s; ss = s->Simplify() )
01684                 {
01685                 Unref(s);
01686                 s = ss;
01687                 }
01688 
01689         return s;
01690         }

const char* stmt_name BroStmtTag  t  ) 
 

Definition at line 36 of file Stmt.cc.

References int, and NUM_STMTS.

Referenced by Stmt::AddTag().

00037         {
00038         static const char* stmt_names[int(NUM_STMTS)] = {
00039                 "alarm", "print", "event", "expr", "if", "switch",
00040                 "for", "next", "break", "return", "add", "delete",
00041                 "list", "bodylist",
00042                 "<init>",
00043                 "null",
00044         };
00045 
00046         return stmt_names[int(t)];
00047         }


Variable Documentation

BroFile* print_stdout = 0 [static]
 

Definition at line 314 of file Stmt.cc.

Referenced by PrintStmt::DoExec().


Generated on Wed Sep 14 03:05:41 2005 for bro_docs by doxygen 1.3.5