Merge pull request #19 from nspaseski/master
[deliverable/titan.core.git] / compiler2 / SigParam.hh
CommitLineData
970ed795 1///////////////////////////////////////////////////////////////////////////////
3abe9331 2// Copyright (c) 2000-2015 Ericsson Telecom AB
970ed795
EL
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 SIGPARAM_HH_
9#define SIGPARAM_HH_
10
11#include "Setting.hh"
12
13namespace Common {
14
15/**
16 * Signature parameter
17 */
18class SignatureParam : public Node, public Location {
19public:
20 enum param_direction_t { PARAM_IN, PARAM_OUT, PARAM_INOUT };
21private:
22 param_direction_t param_direction;
23 Type *param_type;
24 Identifier *param_id;
25 /** Copy constructor not implemented */
26 SignatureParam(const SignatureParam& p);
27 /** Assignment disabled */
28 SignatureParam& operator=(const SignatureParam& p);
29public:
30 SignatureParam(param_direction_t p_d, Type *p_t, Identifier *p_i);
31 ~SignatureParam();
32 virtual SignatureParam *clone() const;
33 const Identifier& get_id() const { return *param_id; }
34 Type *get_type() const { return param_type; }
35 param_direction_t get_direction() const { return param_direction; }
36 virtual void set_fullname(const string& p_fullname);
37 virtual void set_my_scope(Scope *p_scope);
38 virtual void dump(unsigned level) const;
39};
40
41/**
42 * Signature parameter-list
43 */
44class SignatureParamList : public Node {
45 vector<SignatureParam> params_v;
46 map<string, SignatureParam> params_m;
47 vector<SignatureParam> in_params_v, out_params_v;
48 bool checked;
49private:
50 /** Copy constructor not implemented */
51 SignatureParamList(const SignatureParamList& p);
52 /** Assignment disabled */
53 SignatureParamList& operator=(const SignatureParamList& p);
54public:
55 SignatureParamList()
56 : Node(), params_v(), params_m(), in_params_v(), out_params_v(),
57 checked(false) { }
58 ~SignatureParamList();
59 virtual SignatureParamList *clone() const;
60 virtual void set_fullname(const string& p_fullname);
61 virtual void set_my_scope(Scope *p_scope);
62 void add_param(SignatureParam *p_param);
63 size_t get_nof_params() const { return params_v.size(); }
64 SignatureParam *get_param_byIndex(size_t n) const { return params_v[n]; }
65 /** Returns the number of in/inout parameters. */
66 size_t get_nof_in_params() const;
67 /** Returns the n-th in/inout parameter. */
68 SignatureParam *get_in_param_byIndex(size_t n) const;
69 /** Returns the number of out/inout parameters. */
70 size_t get_nof_out_params() const;
71 /** Returns the n-th out/inout parameter. */
72 SignatureParam *get_out_param_byIndex(size_t n) const;
73 bool has_param_withName(const Identifier& p_name) const;
74 const SignatureParam *get_param_byName(const Identifier& p_name) const;
75
76 void chk(Type *p_signature);
77 virtual void dump(unsigned level) const;
78};
79
80/**
81 * Signature exception-list
82 */
83class SignatureExceptions : public Node, public Location {
84 vector<Type> exc_v;
85 map<string,Type> exc_m;
86private:
87 /** Copy constructor not implemented */
88 SignatureExceptions(const SignatureExceptions& p);
89 /** Assignment disabled */
90 SignatureExceptions& operator=(const SignatureExceptions& p);
91public:
92 SignatureExceptions() : Node(), Location(), exc_v(), exc_m() { }
93 ~SignatureExceptions();
94 SignatureExceptions *clone() const;
95 void add_type(Type *p_type);
96 size_t get_nof_types() const { return exc_v.size(); }
97 Type *get_type_byIndex(size_t n) const { return exc_v[n]; }
98 bool has_type(Type *p_type);
99 /** Returns the number of types that are compatible with * \a p_type. */
100 size_t get_nof_compatible_types(Type *p_type);
101 Type *get_type_byName(const string& p_typename) const
102 { return exc_m[p_typename]; }
103
104 void chk(Type *p_signature);
105 virtual void set_fullname(const string& p_fullname);
106 virtual void set_my_scope(Scope *p_scope);
107 virtual void dump(unsigned level) const;
108};
109
110} /* namespace Common */
111#endif /* SIGPARAM_HH_ */
This page took 0.028624 seconds and 5 git commands to generate.