1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_IDLC_INC_ASTEXPRESSION_HXX
20 #define INCLUDED_IDLC_INC_ASTEXPRESSION_HXX
22 #include <sal/config.h>
27 #include <boost/optional.hpp>
29 // Enum to define all the different operators to combine expressions
44 NONE
, // No operator (missing)
45 Symbol
// a symbol (function or constant name)
48 // Enum to define expression type
51 ET_short
, // Expression value is short
52 ET_ushort
, // Expression value is unsigned short
53 ET_long
, // Expression value is long
54 ET_ulong
, // Expression value is unsigned long
55 ET_hyper
, // Expression value is hyper (64 bit)
56 ET_uhyper
, // Expression value is unsigned hyper
57 ET_float
, // Expression value is 32-bit float
58 ET_double
, // Expression value is 64-bit float
59 ET_char
, // Expression value is char
60 ET_byte
, // Expression value is byte
61 ET_boolean
, // Expression value is boolean
62 ET_string
, // Expression value is char *
63 ET_any
, // Expression value is any of above
64 ET_void
, // Expression value is void (absent)
65 ET_type
, // Expression value is type
66 ET_none
// Expression value is missing
69 // Structure to describe value of constant expression and its type
74 sal_uInt8 byval
; // Contains byte expression value
75 sal_Int16 sval
; // Contains short expression value
76 sal_uInt16 usval
; // Contains unsigned short expr value
77 sal_Int32 lval
; // Contains long expression value
78 sal_uInt32 ulval
; // Contains unsigned long expr value
79 sal_Int64 hval
; // Contains hyper expression value
80 sal_uInt64 uhval
; // Contains unsigned hyper expr value
81 bool bval
; // Contains boolean expression value
82 float fval
; // Contains 32-bit float expr value
83 double dval
; // Contains 64-bit float expr value
88 const sal_Char
* exprTypeToString(ExprType t
);
90 class AstExpression final
94 AstExpression(ExprComb c
, AstExpression
*pExpr1
, AstExpression
*pExpr2
);
96 AstExpression(sal_Int32 l
);
97 AstExpression(sal_Int32 l
, ExprType et
);
98 AstExpression(sal_Int64 h
);
99 AstExpression(sal_uInt64 uh
);
100 AstExpression(double d
);
101 AstExpression(OString
* scopedName
);
106 AstExprValue
* getExprValue()
107 { return m_exprValue
.get(); }
109 // Evaluation and value coercion
110 bool coerce(ExprType type
);
112 // Evaluate then store value inside this AstExpression
115 // Compare LONG AstExpression values
116 bool compareLong(AstExpression
*pExpr
);
120 // Evaluate different sets of operators
121 std::unique_ptr
<AstExprValue
> eval_bin_op();
122 std::unique_ptr
<AstExprValue
> eval_bit_op();
123 std::unique_ptr
<AstExprValue
> eval_un_op();
124 std::unique_ptr
<AstExprValue
> eval_symbol();
126 ExprComb m_combOperator
;
127 std::unique_ptr
<AstExpression
>
129 std::unique_ptr
<AstExpression
>
131 std::unique_ptr
<AstExprValue
>
133 boost::optional
<OString
>
137 #endif // INCLUDED_IDLC_INC_ASTEXPRESSION_HXX
139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */