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