File: BuiltinSymbolTable.hpp

package info (click to toggle)
fauhdlc 20180504-3.1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 3,064 kB
  • sloc: cpp: 23,188; ansic: 6,077; yacc: 3,764; lex: 763; makefile: 605; python: 412; xml: 403; sh: 61
file content (122 lines) | stat: -rw-r--r-- 3,500 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/* $Id$
 *
 * BuiltinSymbolTable: SymbolTable preloaded with symbols from std.standard.
 *
 * Copyright (C) 2008-2009 FAUmachine Team <info@faumachine.org>.
 * This program is free software. You can redistribute it and/or modify it
 * under the terms of the GNU General Public License, either version 2 of
 * the License, or (at your option) any later version. See COPYING.
 */


#ifndef __BUILTIN_SYMBOL_TABLE_HPP_INCLUDED
#define __BUILTIN_SYMBOL_TABLE_HPP_INCLUDED

#include "frontend/misc/SymbolTable.hpp"

namespace ast {

/** boolean values as represented in the builtin symbol table
 *  note: true is 0 in vhdl
 */
enum vhdl_bool_vals {
	/** integer value of boolean false in VHDL */
	VHDL_FALSE = 0,
	/** integer value of boolean true in VHDL */
	VHDL_TRUE = 1,
};

//! the SymbolTable with predefined internal symbols.
/** This class predefines all symbols from std.standard.
 *  (or at least to the extent the current implementation for the framework
 *   allows).
 */
class BuiltinSymbolTable : public SymbolTable {
public:
	//! c'tor
	BuiltinSymbolTable();

	/** create a new region and push it onto the stack. should be
	 *  called when entering a nested declarative region.
	 *
	 *  If the regionStack has the size 1, it must be a library unit. 
	 *  Hence the library std and the package standard will be made 
	 *  visible.
	 */

	virtual void pushNewRegion(void);

private: 
	/** register all builtins of std.standard.
	 *  Will call addStandardStd to add the actual
	 *  symbols.
	 *
	 */
	void registerBuiltinSymbols(void);

	/** add all symbols of std.standard. SymbolTable needs to 
	 *  have entered the package standard of library std already.
	 *
	 *  @param standardSyms (empty) list to which all declarations
	 *         should get attached to (to be correctly stored in the
	 *         AST).
	 */
	void addStandardStd(std::list<SymbolDeclaration*> &standardSyms);

	/** add all internal attributes to __attributes__ */
	void addAttributes(void);

	/** add time to std.standard.
	 *  @param standardSyms list of package symbols of standard
	 */
	void addStdStandardTime(std::list<SymbolDeclaration*> &standardSyms);

	/** register a physical type unit in std.standard */
	void addPhysUnit(
		std::list<SymbolDeclaration*> &standardSyms,
		std::list<PhysicalTypeUnit*> &units,
		const char *name,
		universal_integer factor,
		const char *refName
	);

	/** add character enumeration literal c to Enumeration element list. 
	 *  @param elems list of enumeration elements 
	 *  @param c character literal
	 */
	static void 
	addEnumChar(std::list<FunctionDeclaration*> &elems, char c);

	/** add string enumeration literal s to Enumeration element list.
	 *  @param elems list of enumeration elements
	 *  @param c string literal.
	 */
	static void 
	addEnumStr(std::list<FunctionDeclaration*> &elems, const char *s);

	/** register the "foreign" attribute
	 *  @param stringT type declaration of "string"
	 *  @param standardSyms list of packages symbols of standard
	 */
	void
	addForeignAttribute(
		const TypeDeclaration *stringT,
		std::list<SymbolDeclaration*> &standardSyms);

	/** register given attribute.
	 *  @param name name of the attribute
	 *  @param stdType return type (in std.standard) of the
	 *         attribute.
	 */
	void
	addAttributeDecl(
		const char *name,
		const char *stdType);

	/** should we import std.standard when registering a LibUnit? */
	bool mayAddStdStandard;
};

}; /* namespace ast */

#endif /* __BUILTIN_SYMBOL_TABLE_HPP_INCLUDED */