1 /* This file is part of Shapes.
3 * Shapes is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
8 * Shapes is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with Shapes. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright 2008 Henrik Tidefelt
25 #include "classtypes.h"
26 #include "charptrless.h"
32 class MemberDeclaration
35 Ast::SourceLocation loc_
;
37 Ast::Expression
* init_
;
38 Ast::MemberMode mode_
;
39 MemberDeclaration( const Ast::SourceLocation
& loc
, const char * id
, Ast::Expression
* init
, const Ast::MemberMode
& mode
);
40 ~MemberDeclaration( );
41 void addModeBits( const Ast::MemberMode
& bits
);
42 void checkModeConsistency( );
49 virtual ~ClassSection( );
52 class MemberSection
: public ClassSection
, public std::list
< Ast::MemberDeclaration
* >
56 virtual ~MemberSection( );
57 void addModeBits( const Ast::MemberMode
& bits
);
60 class PrepareSection
: public ClassSection
62 Ast::SourceLocation loc_
;
64 std::list
< Ast::Node
* > * nodes_
;
65 PrepareSection( const Ast::SourceLocation
& loc
, std::list
< Ast::Node
* > * nodes
);
66 virtual ~PrepareSection( );
69 class AbstractSection
: public ClassSection
72 Ast::SourceLocation loc_
;
73 const std::list
< RefCountPtr
< const char > > * methods_
;
74 AbstractSection( const Ast::SourceLocation
& loc
, const std::list
< RefCountPtr
< const char > > * methods
);
75 virtual ~AbstractSection( );
78 class OverridesSection
: public ClassSection
81 Ast::Expression
* super_
;
82 Ast::MemberSection
* members_
;
83 OverridesSection( Ast::Expression
* super
, Ast::MemberSection
* members
);
84 virtual ~OverridesSection( );
87 class ClassFunction
: public Lang::Function
89 Ast::SourceLocation loc_
;
90 Ast::Expression
* name_
;
91 const Kernel::Formals
* constructorFormals_
;
92 std::list
< const Ast::CallExpr
* > * parentsWithInitArgs_
;
93 PtrOwner_back_Access
< std::list
< Ast::Node
* > > preparations_
;
94 PtrOwner_back_Access
< std::list
< Ast::MemberDeclaration
* > > members_
;
95 PtrOwner_back_Access
< std::list
< Ast::OverridesSection
* > > overrides_
;
96 typedef std::set
< const char *, charPtrLess
> FieldSetType
;
97 FieldSetType publicGetSet_
;
98 FieldSetType publicSetSet_
;
99 FieldSetType protectedGetSet_
;
100 FieldSetType protectedSetSet_
;
101 FieldSetType abstractSet_
;
102 FieldSetType finalSet_
;
103 FieldSetType transformingSet_
;
107 ClassFunction( const Ast::SourceLocation
& loc
, Ast::Expression
* name
, const Kernel::Formals
* constructorFormals
, std::list
< const Ast::CallExpr
* > * parentsWithInitArgs
, Ast::MemberMode classMode
, std::list
< Ast::ClassSection
* > * sections
);
108 virtual ~ClassFunction( );
110 void push_exprs( Ast::ArgListExprs
* args
) const;
112 virtual void call( Kernel::EvalState
* evalState
, Kernel::Arguments
& args
, const Ast::SourceLocation
& callLoc
) const;
114 bool isInPublicGetSet( const char * field
) const;
115 bool isInPublicSetSet( const char * field
) const;
116 bool isInProtectedGetSet( const char * field
) const;
117 bool isInProtectedSetSet( const char * field
) const;
118 bool isInAbstractSet( const char * field
) const;
119 bool isInFinalSet( const char * field
) const;
120 bool isInTransformingSet( const char * field
) const;
122 Lang::Class::MessageMapType
getLocalMessageMap( RefCountPtr
< const Lang::Class
> _myClass
) const;
124 bool isRepeatableBase( ) const;
125 // void bindInitializationArguments( RefCountPtr< const Lang::Class > theClass, Kernel::PassedEnv initEnv, Kernel::Arguments & args ) const;
126 void setupInstance( Kernel::PassedEnv instanceEnv
, Kernel::PassedEnv privateEnv
, Kernel::EvalState
* evalState
, Kernel::PassedEnv initEnv
) const;
127 void prepareInstance( Kernel::EvalState
* evalState
, Kernel::PassedEnv privateEnv
) const;
129 const Ast::SourceLocation
& loc( ) const;
131 virtual void gcMark( Kernel::GCMarkedSet
& marked
){ };
132 virtual bool isTransforming( ) const { return false; }
137 Ast::SourceLocation loc_
;
139 Ast::Expression
* classPart_
;
141 MethodIdExpr( const Ast::SourceLocation
& loc
, Ast::Expression
* classPart
, const char * name
);
145 class PublicMethodReferenceFunction
: public Lang::Function
147 Ast::SourceLocation loc_
;
148 Ast::Expression
* obj_
;
149 Ast::Expression
* methodClass_
;
150 const char * methodName_
;
152 PublicMethodReferenceFunction( const Ast::SourceLocation
& loc
, Ast::Expression
* obj
, MethodIdExpr
* methodId
);
153 ~PublicMethodReferenceFunction( );
154 void push_exprs( Ast::ArgListExprs
* args
) const;
155 virtual void call( Kernel::EvalState
* evalState
, Kernel::Arguments
& args
, const Ast::SourceLocation
& callLoc
) const;
156 virtual void gcMark( Kernel::GCMarkedSet
& marked
){ };
157 virtual bool isTransforming( ) const { return false; }
160 class ProtectedMethodReferenceFunction
: public Lang::Function
162 Ast::SourceLocation loc_
;
163 Ast::SourceLocation selfLoc_
;
164 Ast::Expression
* parent_
;
165 Ast::Expression
* methodClass_
;
166 const char * methodName_
;
167 mutable Kernel::Environment::LexicalKey
** idKey_
;
169 ProtectedMethodReferenceFunction( const Ast::SourceLocation
& loc
, const Ast::SourceLocation
& selfLoc
, Ast::Expression
* parent
, Ast::MethodIdExpr
* methodId
);
170 ~ProtectedMethodReferenceFunction( );
171 void push_exprs( Ast::ArgListExprs
* args
) const;
172 virtual void analyze_impl( Ast::Node
* parent
, Ast::AnalysisEnvironment
* env
, Ast::StateIDSet
* freeStatesDst
);
173 virtual void call( Kernel::EvalState
* evalState
, Kernel::Arguments
& args
, const Ast::SourceLocation
& callLoc
) const;
174 virtual void gcMark( Kernel::GCMarkedSet
& marked
){ };
175 virtual bool isTransforming( ) const { return false; }
178 class ProtectedMemberReferenceFunction
: public Lang::Function
180 Ast::SourceLocation loc_
;
181 Ast::SourceLocation selfLoc_
;
182 Ast::Expression
* parent_
;
183 Ast::SourceLocation idLoc_
;
185 mutable Kernel::Environment::LexicalKey
** idKey_
;
187 ProtectedMemberReferenceFunction( const Ast::SourceLocation
& loc
, const Ast::SourceLocation
& selfLoc
, Ast::Expression
* parent
, const Ast::SourceLocation
& idloc
, const char * id
);
188 ~ProtectedMemberReferenceFunction( );
189 void push_exprs( Ast::ArgListExprs
* args
) const;
190 virtual void analyze_impl( Ast::Node
* parent
, Ast::AnalysisEnvironment
* env
, Ast::StateIDSet
* freeStatesDst
);
191 virtual void call( Kernel::EvalState
* evalState
, Kernel::Arguments
& args
, const Ast::SourceLocation
& callLoc
) const;
192 virtual void gcMark( Kernel::GCMarkedSet
& marked
){ };
193 virtual bool isTransforming( ) const { return false; }
196 class ProtectedMemberInsertionFunction
: public Lang::Function
198 Ast::SourceLocation loc_
;
199 Ast::SourceLocation selfLoc_
;
200 Ast::Expression
* parent_
;
201 Ast::SourceLocation idLoc_
;
203 Ast::Expression
* pieceExpr_
;
204 mutable Kernel::Environment::LexicalKey
** idKey_
;
206 ProtectedMemberInsertionFunction( const Ast::SourceLocation
& loc
, const Ast::SourceLocation
& selfLoc
, Ast::Expression
* parent
, const Ast::SourceLocation
& idloc
, const char * id
, Ast::Expression
* pieceExpr
);
207 ~ProtectedMemberInsertionFunction( );
208 void push_exprs( Ast::ArgListExprs
* args
) const;
209 virtual void analyze_impl( Ast::Node
* parent
, Ast::AnalysisEnvironment
* env
, Ast::StateIDSet
* freeStatesDst
);
210 virtual void call( Kernel::EvalState
* evalState
, Kernel::Arguments
& args
, const Ast::SourceLocation
& callLoc
) const;
211 virtual void gcMark( Kernel::GCMarkedSet
& marked
){ };
212 virtual bool isTransforming( ) const { return false; }