| 1 | /////////////////////////////////////////////////////////////////////////////// |
| 2 | // Copyright (c) 2000-2014 Ericsson Telecom AB |
| 3 | // All rights reserved. This program and the accompanying materials |
| 4 | // are made available under the terms of the Eclipse Public License v1.0 |
| 5 | // which accompanies this distribution, and is available at |
| 6 | // http://www.eclipse.org/legal/epl-v10.html |
| 7 | /////////////////////////////////////////////////////////////////////////////// |
| 8 | #ifndef _Common_Code_HH |
| 9 | #define _Common_Code_HH |
| 10 | |
| 11 | #include "ttcn3/compiler.h" |
| 12 | |
| 13 | namespace Common { |
| 14 | |
| 15 | /** |
| 16 | * \addtogroup AST |
| 17 | * |
| 18 | * @{ |
| 19 | */ |
| 20 | |
| 21 | /** |
| 22 | * Abstract class for storing Code. |
| 23 | */ |
| 24 | class Code { |
| 25 | public: |
| 26 | |
| 27 | static void init_output(output_struct *output); |
| 28 | static void merge_output(output_struct *dest, output_struct *src); |
| 29 | static void free_output(output_struct *output); |
| 30 | |
| 31 | static void init_cdef(const_def *cdef); |
| 32 | static void merge_cdef(output_struct *dest, const_def *cdef); |
| 33 | static void free_cdef(const_def *cdef); |
| 34 | |
| 35 | static void init_expr(expression_struct *expr); |
| 36 | static void clean_expr(expression_struct *expr); |
| 37 | static void free_expr(expression_struct *expr); |
| 38 | static char* merge_free_expr(char* str, expression_struct *expr, |
| 39 | bool is_block=false); |
| 40 | |
| 41 | /** Appends the C/C++ equivalent of character \a c to \a str. If flag |
| 42 | * \a in_string is true (i.e. the \a c is a part of a string literal) then |
| 43 | * the " character is escaped, otherwise (i.e. the \a c is a character |
| 44 | * constant) ' is escaped. The function uses the standard C escape sequences |
| 45 | * if possible or the octal notation for non-printable characters. */ |
| 46 | static char *translate_character(char *str, char c, bool in_string); |
| 47 | /** Appends the C/C++ equivalent of literal string \a src to \a str. */ |
| 48 | static char *translate_string(char *str, const char *src); |
| 49 | }; |
| 50 | |
| 51 | /** @} end of AST group */ |
| 52 | |
| 53 | } // namespace Common |
| 54 | |
| 55 | #endif // _Common_Code_HH |