1 | #pragma once
|
---|
2 |
|
---|
3 | #include <string>
|
---|
4 | #include <vector>
|
---|
5 |
|
---|
6 | #include <option.h>
|
---|
7 | #include <Program.h>
|
---|
8 | #include <Type.h>
|
---|
9 |
|
---|
10 | class Parameter : public Type
|
---|
11 | {
|
---|
12 | std::string varName;
|
---|
13 | bool isRef;
|
---|
14 | bool isArray;
|
---|
15 | Subscripts subscripts;
|
---|
16 |
|
---|
17 | std::string initValue;
|
---|
18 |
|
---|
19 | // XMLシリアライズ用
|
---|
20 | private:
|
---|
21 | friend class boost::serialization::access;
|
---|
22 | template<class Archive> void serialize(Archive& ar, const unsigned int version)
|
---|
23 | {
|
---|
24 | trace_for_serialize( "serializing - Parameter" );
|
---|
25 |
|
---|
26 | ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Type );
|
---|
27 | ar & BOOST_SERIALIZATION_NVP( varName );
|
---|
28 | ar & BOOST_SERIALIZATION_NVP( isRef );
|
---|
29 | ar & BOOST_SERIALIZATION_NVP( isArray );
|
---|
30 | ar & BOOST_SERIALIZATION_NVP( subscripts );
|
---|
31 | ar & BOOST_SERIALIZATION_NVP( initValue );
|
---|
32 | }
|
---|
33 |
|
---|
34 | public:
|
---|
35 | Parameter( const std::string &varName, const Type &type, bool isRef = false, const std::string initValue = "" ):
|
---|
36 | Type( type ),
|
---|
37 | varName( varName ),
|
---|
38 | isRef( isRef ),
|
---|
39 | isArray( false ),
|
---|
40 | initValue( initValue )
|
---|
41 | {
|
---|
42 | }
|
---|
43 | Parameter( const Parameter ¶m ):
|
---|
44 | Type( param ),
|
---|
45 | varName( param.varName ),
|
---|
46 | isRef( param.isRef ),
|
---|
47 | isArray( param.isArray ),
|
---|
48 | subscripts( param.subscripts ),
|
---|
49 | initValue( param.initValue )
|
---|
50 | {
|
---|
51 | }
|
---|
52 | Parameter()
|
---|
53 | {
|
---|
54 | }
|
---|
55 | ~Parameter(){}
|
---|
56 |
|
---|
57 | void SetArray( const Subscripts &subscripts ){
|
---|
58 | isArray = true;
|
---|
59 | this->subscripts = subscripts;
|
---|
60 | }
|
---|
61 |
|
---|
62 | const std::string &GetVarName() const
|
---|
63 | {
|
---|
64 | return varName;
|
---|
65 | }
|
---|
66 |
|
---|
67 | bool IsRef() const
|
---|
68 | {
|
---|
69 | return isRef;
|
---|
70 | }
|
---|
71 | bool IsArray(){
|
---|
72 | return isArray;
|
---|
73 | }
|
---|
74 | const Subscripts &GetSubscripts() const
|
---|
75 | {
|
---|
76 | return subscripts;
|
---|
77 | }
|
---|
78 |
|
---|
79 | const std::string &GetInitValue() const
|
---|
80 | {
|
---|
81 | return initValue;
|
---|
82 | }
|
---|
83 |
|
---|
84 | bool Equals( const Parameter ¶m, bool isContravariant ) const;
|
---|
85 | bool Equals( const Types &actualTypeParametersForThisProc, const Parameter ¶m, bool isContravariant ) const;
|
---|
86 | };
|
---|
87 |
|
---|
88 | class Parameters : public std::vector<Parameter *>
|
---|
89 | {
|
---|
90 | // XMLシリアライズ用
|
---|
91 | private:
|
---|
92 | friend class boost::serialization::access;
|
---|
93 | template<class Archive> void serialize(Archive& ar, const unsigned int version)
|
---|
94 | {
|
---|
95 | trace_for_serialize( "serializing - Parameters" );
|
---|
96 |
|
---|
97 | ar & boost::serialization::make_nvp("vector_Parameter", boost::serialization::base_object<std::vector<Parameter *>>(*this));
|
---|
98 | }
|
---|
99 |
|
---|
100 | public:
|
---|
101 |
|
---|
102 | bool Equals( const Parameters ¶ms, bool isContravariant = false ) const;
|
---|
103 | bool Equals( const Types &actualTypeParametersForThisProc, const Parameters ¶ms, bool isContravariant = false ) const;
|
---|
104 |
|
---|
105 | int GetMemorySize() const
|
---|
106 | {
|
---|
107 | return (int)this->size() * PTR_SIZE;
|
---|
108 | }
|
---|
109 |
|
---|
110 | bool Analyze( const char *sourceOfParams, int nowLine );
|
---|
111 |
|
---|
112 | std::string GetString() const;
|
---|
113 | };
|
---|