source: dev/trunk/abdev/BasicCompiler_Common/include/Parameter.h@ 409

Last change on this file since 409 was 402, checked in by dai_9181, 17 years ago

UserProc::SetParamsAndReturnTypeメソッドをリファクタリング
LexicalAnalysis.hのインクルードを除去した

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