CastExpression::CastExpression(int lno, int ct, Expression *arg) { setKind(ECAST); setLineNo(lno); castTo = ct; setType(0); // set as the default expression type if (arg != NULL) operand = arg; else throw AstException("CastExpression::CastExpression: NULL arg\n"); }
AssignStatement::AssignStatement( int lno, const char *name, Expression *rhs ) { setKind( SASSIGN ); setLineNo( lno ); lhsName = name; entry = NULL; index = NULL; if( rhs != NULL ) expr = rhs; else throw AstException( "AssignStatement::AssignStatement: NULL rhs expression\n" ); }
BinaryExpression::BinaryExpression( int lno, int op, Expression *left, Expression *right ) { setKind( EBINARY ); setLineNo( lno ); oper = op; setType( 0 ); // set as the default expression type if( left != NULL ) leftOperand = left; else throw AstException( "BinaryExpression::BinaryExpression: NULL left operand\n" ); if( right != NULL ) rightOperand = right; else throw AstException( "BinaryExpression::BinaryExpression: NULL right operand\n" ); }
IfStatement::IfStatement( int lno, Expression *e, Statement *ts, Statement *es ) { setKind( SIF ); setLineNo( lno ); if( e != NULL ) expr = e; else throw AstException( "IfStatement::IfStatement: NULL expression\n" ); if( ts != NULL ) thenStmt = ts; else throw AstException( "IfStatement::IfStatement: NULL then statement node\n" ); elseStmt = es; }