diff options
Diffstat (limited to 'idlc/source/astexpression.cxx')
-rw-r--r-- | idlc/source/astexpression.cxx | 146 |
1 files changed, 73 insertions, 73 deletions
diff --git a/idlc/source/astexpression.cxx b/idlc/source/astexpression.cxx index 394bb848bdd1..fd9628663e2d 100644 --- a/idlc/source/astexpression.cxx +++ b/idlc/source/astexpression.cxx @@ -2,7 +2,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -36,9 +36,9 @@ #include <limits.h> #include <float.h> -#undef MAXCHAR +#undef MAXCHAR #define MAXCHAR 127 -#undef MINCHAR +#undef MINCHAR #define MINCHAR -128 using namespace ::rtl; @@ -51,8 +51,8 @@ AstExpression::AstExpression(ExprComb c, AstExpression *pExpr1, AstExpression *p , m_pSymbolicName(NULL) { fillDefinitionDetails(); - -} + +} AstExpression::AstExpression(sal_Int32 l) : m_combOperator(EC_none) @@ -66,9 +66,9 @@ AstExpression::AstExpression(sal_Int32 l) m_exprValue = new AstExprValue(); m_exprValue->et = ET_long; m_exprValue->u.lval = l; -} +} -AstExpression::AstExpression(sal_Int32 l, ExprType et) +AstExpression::AstExpression(sal_Int32 l, ExprType et) : m_combOperator(EC_none) , m_subExpr1(NULL) , m_subExpr2(NULL) @@ -80,9 +80,9 @@ AstExpression::AstExpression(sal_Int32 l, ExprType et) m_exprValue = new AstExprValue(); m_exprValue->et = et; m_exprValue->u.lval = l; -} +} -AstExpression::AstExpression(sal_Int64 h) +AstExpression::AstExpression(sal_Int64 h) : m_combOperator(EC_none) , m_subExpr1(NULL) , m_subExpr2(NULL) @@ -94,9 +94,9 @@ AstExpression::AstExpression(sal_Int64 h) m_exprValue = new AstExprValue(); m_exprValue->et = ET_hyper; m_exprValue->u.hval = h; -} +} -AstExpression::AstExpression(sal_uInt64 uh) +AstExpression::AstExpression(sal_uInt64 uh) : m_combOperator(EC_none) , m_subExpr1(NULL) , m_subExpr2(NULL) @@ -108,9 +108,9 @@ AstExpression::AstExpression(sal_uInt64 uh) m_exprValue = new AstExprValue(); m_exprValue->et = ET_uhyper; m_exprValue->u.uhval = uh; -} +} -AstExpression::AstExpression(double d) +AstExpression::AstExpression(double d) : m_combOperator(EC_none) , m_subExpr1(NULL) , m_subExpr2(NULL) @@ -122,7 +122,7 @@ AstExpression::AstExpression(double d) m_exprValue = new AstExprValue(); m_exprValue->et = ET_double; m_exprValue->u.dval = d; -} +} AstExpression::AstExpression(::rtl::OString* scopedName) : m_combOperator(EC_symbol) @@ -132,8 +132,8 @@ AstExpression::AstExpression(::rtl::OString* scopedName) , m_pSymbolicName(scopedName) { fillDefinitionDetails(); -} - +} + AstExpression::~AstExpression() { if ( m_exprValue ) @@ -144,7 +144,7 @@ AstExpression::~AstExpression() delete m_subExpr2; if ( m_pSymbolicName ) delete m_pSymbolicName; -} +} /* * Perform the coercion from the given AstExprValue to the requested @@ -157,10 +157,10 @@ coerce_value(AstExprValue *ev, ExprType t) if (ev == NULL) return NULL; - switch (t) + switch (t) { case ET_short: - switch (ev->et) + switch (ev->et) { case ET_short: return ev; @@ -219,7 +219,7 @@ coerce_value(AstExprValue *ev, ExprType t) return NULL; } case ET_ushort: - switch (ev->et) + switch (ev->et) { case ET_short: if (ev->u.sval < 0) @@ -278,7 +278,7 @@ coerce_value(AstExprValue *ev, ExprType t) return NULL; } case ET_long: - switch (ev->et) + switch (ev->et) { case ET_short: ev->u.lval = (sal_Int32)ev->u.sval; @@ -333,7 +333,7 @@ coerce_value(AstExprValue *ev, ExprType t) return NULL; } case ET_ulong: - switch (ev->et) + switch (ev->et) { case ET_short: if (ev->u.sval < 0) @@ -390,7 +390,7 @@ coerce_value(AstExprValue *ev, ExprType t) return NULL; } case ET_hyper: - switch (ev->et) + switch (ev->et) { case ET_short: ev->u.hval = (sal_Int64)ev->u.sval; @@ -441,7 +441,7 @@ coerce_value(AstExprValue *ev, ExprType t) return NULL; } case ET_uhyper: - switch (ev->et) + switch (ev->et) { case ET_short: if (ev->u.sval < 0) @@ -496,7 +496,7 @@ coerce_value(AstExprValue *ev, ExprType t) return NULL; } case ET_boolean: - switch (ev->et) + switch (ev->et) { case ET_short: ev->u.bval = (ev->u.sval == 0) ? sal_False : sal_True; @@ -541,7 +541,7 @@ coerce_value(AstExprValue *ev, ExprType t) return NULL; } case ET_float: - switch (ev->et) + switch (ev->et) { case ET_short: ev->u.fval = (float)ev->u.sval; @@ -590,7 +590,7 @@ coerce_value(AstExprValue *ev, ExprType t) return NULL; } case ET_double: - switch (ev->et) + switch (ev->et) { case ET_short: ev->u.dval = (double)ev->u.sval; @@ -637,7 +637,7 @@ coerce_value(AstExprValue *ev, ExprType t) return NULL; } case ET_byte: - switch (ev->et) + switch (ev->et) { case ET_short: if (ev->u.sval < SAL_MIN_INT8 || ev->u.sval > SAL_MAX_UINT8) @@ -706,9 +706,9 @@ coerce_value(AstExprValue *ev, ExprType t) /* * Evaluate the expression with the evaluation kind requested. Supported * evaluation kinds are - * - EK_const: The expression must evaluate to a constant - * - EK_positive_int: The expression must further evaluate to a - * positive integer + * - EK_const: The expression must evaluate to a constant + * - EK_positive_int: The expression must further evaluate to a + * positive integer */ static AstExprValue * eval_kind(AstExprValue *ev, EvalKind ek) @@ -746,7 +746,7 @@ AstExprValue* AstExpression::coerce(ExprType t, sal_Bool bAssign) copy = new AstExprValue; copy->et = m_exprValue->et; - switch (m_exprValue->et) + switch (m_exprValue->et) { case ET_short: copy->u.sval = m_exprValue->u.sval; @@ -788,7 +788,7 @@ AstExprValue* AstExpression::coerce(ExprType t, sal_Bool bAssign) m_exprValue = coerce_value(copy, t); return m_exprValue; } - + return coerce_value(copy, t); } @@ -796,7 +796,7 @@ void AstExpression::evaluate(EvalKind ek) { m_exprValue = eval_internal(ek); m_exprValue = eval_kind(m_exprValue, ek); -} +} sal_Bool AstExpression::operator==(AstExpression *pExpr) { @@ -808,7 +808,7 @@ sal_Bool AstExpression::operator==(AstExpression *pExpr) return sal_False; if (m_exprValue->et != pExpr->getExprValue()->et) return sal_False; - switch (m_exprValue->et) + switch (m_exprValue->et) { case ET_short: return (m_exprValue->u.sval == pExpr->getExprValue()->u.sval) ? sal_True : sal_False; @@ -836,10 +836,10 @@ sal_Bool AstExpression::operator==(AstExpression *pExpr) } return sal_False; -} +} sal_Bool AstExpression::compare(AstExpression *pExpr) -{ +{ if (m_combOperator != pExpr->getCombOperator()) return sal_False; evaluate(EK_const); @@ -848,7 +848,7 @@ sal_Bool AstExpression::compare(AstExpression *pExpr) return sal_False; if (m_exprValue->et != pExpr->getExprValue()->et) return sal_False; - switch (m_exprValue->et) + switch (m_exprValue->et) { case ET_short: return (m_exprValue->u.sval == pExpr->getExprValue()->u.sval) ? sal_True : sal_False; @@ -876,11 +876,11 @@ sal_Bool AstExpression::compare(AstExpression *pExpr) } return sal_False; -} - +} + void AstExpression::fillDefinitionDetails() { - m_pScope = idlc()->scopes()->depth() > 0 ? idlc()->scopes()->top() : NULL; + m_pScope = idlc()->scopes()->depth() > 0 ? idlc()->scopes()->top() : NULL; m_lineNo = idlc()->getLineNumber(); m_fileName = idlc()->getFileName(); } @@ -895,7 +895,7 @@ AstExprValue* AstExpression::eval_internal(EvalKind ek) /* * OK, must evaluate operator */ - switch (m_combOperator) + switch (m_combOperator) { case EC_add: case EC_minus: @@ -924,7 +924,7 @@ AstExprValue* AstExpression::eval_internal(EvalKind ek) } return NULL; -} +} AstExprValue* AstExpression::eval_bin_op(EvalKind ek) { @@ -954,7 +954,7 @@ AstExprValue* AstExpression::eval_bin_op(EvalKind ek) retval = new AstExprValue(); retval->et = eType; - switch (m_combOperator) + switch (m_combOperator) { case EC_mod: if (m_subExpr2->getExprValue()->u.hval == 0) @@ -978,13 +978,13 @@ AstExprValue* AstExpression::eval_bin_op(EvalKind ek) default: return NULL; } - + return retval; -} - +} + AstExprValue* AstExpression::eval_bit_op(EvalKind ek) { - AstExprValue *retval = NULL; + AstExprValue *retval = NULL; if (ek != EK_const && ek != EK_positive_int) return NULL; @@ -1006,7 +1006,7 @@ AstExprValue* AstExpression::eval_bit_op(EvalKind ek) retval = new AstExprValue; retval->et = ET_long; - switch (m_combOperator) + switch (m_combOperator) { case EC_or: retval->u.lval = m_subExpr1->getExprValue()->u.lval | m_subExpr2->getExprValue()->u.lval; @@ -1026,13 +1026,13 @@ AstExprValue* AstExpression::eval_bit_op(EvalKind ek) default: return NULL; } - + return retval; -} - +} + AstExprValue* AstExpression::eval_un_op(EvalKind ek) { - AstExprValue *retval = NULL; + AstExprValue *retval = NULL; if (m_exprValue != NULL) return m_exprValue; @@ -1051,7 +1051,7 @@ AstExprValue* AstExpression::eval_un_op(EvalKind ek) retval = new AstExprValue(); retval->et = ET_double; - switch (m_combOperator) + switch (m_combOperator) { case EC_u_plus: retval->u.lval = m_subExpr1->getExprValue()->u.lval; @@ -1068,20 +1068,20 @@ AstExprValue* AstExpression::eval_un_op(EvalKind ek) default: return NULL; } - + return retval; -} +} AstExprValue* AstExpression::eval_symbol(EvalKind ek) { - AstScope *pScope = 0; - AstDeclaration *pDecl; - AstConstant *pConst; + AstScope *pScope = 0; + AstDeclaration *pDecl; + AstConstant *pConst; /* * Is there a symbol stored? */ - if (m_pSymbolicName == NULL) + if (m_pSymbolicName == NULL) { idlc()->error()->evalError(this); return NULL; @@ -1091,7 +1091,7 @@ AstExprValue* AstExpression::eval_symbol(EvalKind ek) */ if (idlc()->scopes()->depth() > 0) pScope = idlc()->scopes()->topNonNull(); - if ( !pScope ) + if ( !pScope ) { idlc()->error()->lookupError(*m_pSymbolicName); return NULL; @@ -1100,7 +1100,7 @@ AstExprValue* AstExpression::eval_symbol(EvalKind ek) * Do lookup */ pDecl = pScope->lookupByName(*m_pSymbolicName); - if (pDecl == NULL) + if (pDecl == NULL) { idlc()->error()->lookupError(*m_pSymbolicName); return NULL; @@ -1109,7 +1109,7 @@ AstExprValue* AstExpression::eval_symbol(EvalKind ek) * Is it a constant? */ if (pDecl->getNodeType() != NT_const && - pDecl->getNodeType() != NT_enum_val) + pDecl->getNodeType() != NT_enum_val) { idlc()->error()->constantExpected(pDecl, *m_pSymbolicName); return NULL; @@ -1126,7 +1126,7 @@ AstExprValue* AstExpression::eval_symbol(EvalKind ek) return NULL; return pConst->getConstValue()->eval_internal(ek); } - + OString AstExpression::toString() { OString exprStr; @@ -1135,7 +1135,7 @@ OString AstExpression::toString() if ( m_exprValue ) { - switch (m_exprValue->et) + switch (m_exprValue->et) { case ET_short: return OString::valueOf((sal_Int32)m_exprValue->u.sval); @@ -1156,17 +1156,17 @@ OString AstExpression::toString() case ET_byte: return OString::valueOf((sal_Int32)m_exprValue->u.byval); case ET_boolean: - if ( m_exprValue->u.lval == 0) + if ( m_exprValue->u.lval == 0) return OString("FALSE"); else - return OString("TRUE"); + return OString("TRUE"); default: OSL_ASSERT(false); return OString(); } - } + } - switch (m_combOperator) + switch (m_combOperator) { case EC_u_plus: exprStr += OString("+"); @@ -1182,7 +1182,7 @@ OString AstExpression::toString() } if ( m_subExpr1 ) exprStr += m_subExpr1->toString(); - switch (m_combOperator) + switch (m_combOperator) { case EC_add: exprStr += OString(" + "); @@ -1217,17 +1217,17 @@ OString AstExpression::toString() default: break; } - + if ( m_subExpr2 ) exprStr += m_subExpr2->toString(); return exprStr; -} +} // Convert the type of an AST_Expression to a char * const sal_Char* SAL_CALL exprTypeToString(ExprType t) { - switch (t) + switch (t) { case ET_short: return "short"; |