Update suitable examples and tests to use blank mode
[shapes.git] / source / astvar.h
blob18ae2121e8ad8f8aaf4867d96f3cc92c4edeeddc
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
6 * any later version.
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, 2013, 2014, 2015 Henrik Tidefelt
19 #pragma once
21 #include "Shapes_Kernel_decls.h"
23 #include "ast.h"
25 namespace Shapes
27 namespace Ast
30 class SourceLocationMark : public Node
32 public:
33 SourceLocationMark( const Ast::SourceLocation & loc );
34 virtual ~SourceLocationMark( );
36 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
40 class CodeBracket : public Expression
42 std::list< Ast::Node * > * nodes_;
43 Ast::CodeBracket * extends_;
44 std::list< Ast::BindNode * > bindNodes_; /* Subset of nodes_. */
45 public:
46 Ast::IdentifierTree * argumentOrder_;
47 Ast::IdentifierTree * dynamicMap_;
48 Ast::IdentifierTree * stateOrder_;
49 public:
50 CodeBracket( const Ast::SourceLocation & loc, std::list< Ast::Node * > * nodes, Ast::CodeBracket * extends = 0 );
51 virtual ~CodeBracket( );
53 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
54 virtual void eval( Kernel::EvalState * evalState ) const;
56 Kernel::Environment * newEnvironment( Kernel::Environment * parent, const char * debugName = "Bracket" ) const;
57 void eval( Kernel::EvalState * evalState, Kernel::Environment * extendsEnv ) const;
59 void evalAt( const RefCountPtr< const Kernel::CodeBracketContInfo > & info, const std::list< Ast::Node * >::const_iterator & i, Kernel::EvalState * evalState ) const;
61 void setDynamicMap( Ast::IdentifierTree * dynamicMap );
66 namespace Kernel
68 class CodeBracketContInfo
70 public:
71 const Ast::CodeBracket * bracketExpr_;
72 Kernel::PassedEnv env_;
73 Kernel::PassedDyn dyn_;
74 Kernel::ContRef cont_;
76 CodeBracketContInfo( const Ast::CodeBracket * bracketExpr, const Kernel::EvalState & evalState );
77 ~CodeBracketContInfo( );
79 void gcMark( Kernel::GCMarkedSet & marked );
82 class CodeBracketContinuation : public Kernel::Continuation
84 RefCountPtr< const Kernel::CodeBracketContInfo > info_;
85 std::list< Ast::Node * >::const_iterator pos_;
86 public:
87 CodeBracketContinuation( const Ast::SourceLocation & _traceLoc, const RefCountPtr< const Kernel::CodeBracketContInfo > & _info, const std::list< Ast::Node * >::const_iterator & _pos );
88 virtual ~CodeBracketContinuation( );
89 virtual void takeValue( const RefCountPtr< const Lang::Value > & val, Kernel::EvalState * evalState, bool dummy ) const;
90 virtual Kernel::ContRef up( ) const;
91 virtual RefCountPtr< const char > description( ) const;
92 virtual void gcMark( Kernel::GCMarkedSet & marked );
96 class DynamicBindingContinuation : public Kernel::Continuation
98 Kernel::PassedEnv env_;
99 Kernel::Environment::LexicalKey key_;
100 const Ast::DynamicBindingExpression * bindingExpr_;
101 Kernel::ContRef cont_;
102 public:
103 DynamicBindingContinuation( const Ast::SourceLocation & traceLoc, const Kernel::PassedEnv & env, const Kernel::Environment::LexicalKey & key, const Ast::DynamicBindingExpression * bindingExpr, const Kernel::ContRef & cont );
104 virtual ~DynamicBindingContinuation( );
105 virtual void takeHandle( Kernel::VariableHandle val, Kernel::EvalState * evalState, bool dummy ) const;
106 virtual Kernel::ContRef up( ) const;
107 virtual RefCountPtr< const char > description( ) const;
108 virtual void gcMark( Kernel::GCMarkedSet & marked );
111 class WithDynamicContinuation : public Kernel::Continuation
113 Ast::Expression * expr_;
114 Kernel::PassedEnv env_;
115 Kernel::PassedDyn dyn_;
116 Kernel::ContRef cont_;
117 public:
118 WithDynamicContinuation( const Ast::SourceLocation & traceLoc, Ast::Expression * expr, const Kernel::EvalState & evalState );
119 virtual ~WithDynamicContinuation( );
120 virtual void takeValue( const RefCountPtr< const Lang::Value > & val, Kernel::EvalState * evalState, bool dummy ) const;
121 virtual Kernel::ContRef up( ) const;
122 virtual RefCountPtr< const char > description( ) const;
123 virtual void gcMark( Kernel::GCMarkedSet & marked );
126 class AssertStructureContinuation : public Kernel::Continuation
128 Kernel::ContRef cont_;
129 public:
130 AssertStructureContinuation( const Kernel::ContRef & cont, const Ast::SourceLocation & traceLoc );
131 ~AssertStructureContinuation( );
132 virtual void takeValue( const RefCountPtr< const Lang::Value > & val, Kernel::EvalState * evalState, bool dummy ) const;
133 virtual Kernel::ContRef up( ) const;
134 virtual RefCountPtr< const char > description( ) const;
135 virtual void gcMark( Kernel::GCMarkedSet & marked );
138 } /* End of namespace Kernel. */
140 namespace Ast
142 class LexiographicVariable : public Expression
144 const Ast::Identifier * id_;
145 Kernel::Environment::LexicalKey ** idKey_;
146 size_t scope_level_;
147 public:
148 LexiographicVariable( const Ast::SourceLocation & loc, const Ast::Identifier * id, Kernel::Environment::LexicalKey ** idKey );
149 virtual ~LexiographicVariable( );
150 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
151 virtual void eval( Kernel::EvalState * evalState ) const;
153 /* The following function may be called after the expression has been analyzed, to find out what kind of binding that
154 * the variable refers to. Kernel bindings can be fetched without evaluation before the program starts. Prelude and user
155 * top-level bindings need only be evaluated once. Other bindings are harder to analyze, and should be evaluated
156 * each time.
157 * Note that the "level" here refers to the level of the binding, and not the variable expression referring to the binding.
159 * 0 means kernel bindings, 1 means prelude bindings, 2 means user top-level, and 3 or higher means a non-global binding.
161 size_t scope_level( ) const { return scope_level_; }
162 const Ast::Identifier * id( ) const { return id_; }
165 class PrivateAliasVariable : public Expression
167 const Ast::PlacedIdentifier & id_;
168 RefCountPtr< const char > privateName_;
169 Kernel::Environment::LexicalKey * aliasKey_;
170 public:
171 PrivateAliasVariable( const Ast::SourceLocation & loc, const Ast::PlacedIdentifier & id, const RefCountPtr< const char > & privateName );
172 virtual ~PrivateAliasVariable( );
173 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
174 virtual void eval( Kernel::EvalState * evalState ) const;
177 /* Evaluate contained expresion and keep forcing thunks until a value is obtained.
179 * This serves two purposes:
180 * 1) Users may use it to prevent delayed evaluation for efficiency reasons. (The opposite, preventing
181 * forced evaluation, is not possible to express.)
182 * 2) The kernel may use it during the analysis of the program, for example, to prevent delayed
183 * evaluation of expressions with free states.
185 * Compare the immediate_ property, which only prevents delaying the expression itself.
187 * To illustrate, consider the difference between the following brackets:
189 * x: 1 + 1 <-- rhs not immediate
190 * y: x <-- rhs immediate
193 * vs
195 * x: 1 + 1 <-- rhs not immediate
196 * y: !x <-- rhs immediate and forced
200 * In the first program, x is initialized to a thunk since its right hand side is not immediate. When
201 * it comes to y, the right hand side is immediately evaluated, meaning that lookup of x is performed.
202 * The lookup results in the thunk for x, which is then bound to y. When y is returned as the result of
203 * the bracket, the addition 1 + 1 is still a thunk.
205 * In the second program, x is again initialized to a thunk, but when it comes to y, evaluation does not
206 * proceed until a value is obtained. This will cause the thunk 1 + 1 to be forced, and the lookup of x
207 * finally results in the value 2. When y is returned as the result of the bracket, the addition thunk
208 * is already gone, and the result is the value 2.
210 * Since the computation of free states can be (just a little bit) costly, the analysis is not performed
211 * for every single expression -- care must be taken during the analysis to ensure it is set correctly
212 * wherever needed.
214 class Force : public Expression
216 Ast::Expression * expr_;
217 public:
218 Force( const Ast::SourceLocation & loc, Ast::Expression * expr );
219 virtual ~Force( );
220 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
221 virtual void eval( Kernel::EvalState * evalState ) const;
224 class EvalOutsideExpr : public Expression
226 Ast::Expression * expr_;
227 public:
228 EvalOutsideExpr( const Ast::SourceLocation & loc, Ast::Expression * expr );
229 virtual ~EvalOutsideExpr( );
230 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
231 virtual void eval( Kernel::EvalState * evalState ) const;
234 class DefineVariable : public BindNode
236 Ast::Expression * expr_;
237 mutable size_t ** idPos_;
238 public:
239 DefineVariable( const Ast::SourceLocation & idLoc, const Ast::PlacedIdentifier * id, Ast::Expression * expr, size_t ** idPos );
240 virtual ~DefineVariable( );
241 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
242 virtual void initializeEnvironment( Kernel::PassedEnv env, Kernel::PassedDyn dyn ) const;
243 virtual void evalHelper( Kernel::EvalState * evalState ) const;
246 class DefineAlias : public Node
248 const Ast::SourceLocation idLoc_; /* Note: Not a const reference. */
249 const Ast::PlacedIdentifier * id_;
250 Ast::NamespaceReference expansion_;
251 const Ast::SourceLocation expansionLoc_; /* Note: Not a const reference. */
252 public:
253 DefineAlias( const Ast::SourceLocation & idLoc, const Ast::SourceLocation & expansionLoc, const Ast::PlacedIdentifier * id, const Ast::NamespaceReference & expansion );
254 virtual ~DefineAlias( );
255 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
256 const Ast::PlacedIdentifier * id( ) const { return id_; }
257 const Ast::SourceLocation & idLoc( ) const { return idLoc_; }
258 const Ast::NamespaceReference & expansion( ) const { return expansion_; }
259 const Ast::SourceLocation & expansionLoc( ) const { return expansionLoc_; }
262 class LexicalVariableLocationExpr : public Expression
264 public:
265 typedef enum { INDEX, DEPTH, ABSID } Kind;
266 private:
267 const Ast::Identifier * id_;
268 Kind kind_;
269 RefCountPtr< const Lang::Value > value_;
270 public:
271 LexicalVariableLocationExpr( const Ast::SourceLocation & idLoc, const Ast::Identifier * id, Kind kind );
272 virtual ~LexicalVariableLocationExpr( );
273 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
274 virtual void eval( Kernel::EvalState * evalState ) const;
277 class LexicalVariableNameExpr : public Expression
279 RefCountPtr< const Lang::Value > value_;
280 public:
281 LexicalVariableNameExpr( const Ast::SourceLocation & loc );
282 virtual ~LexicalVariableNameExpr( );
283 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
284 virtual void eval( Kernel::EvalState * evalState ) const;
287 class StructSplitReference : public Expression
289 Ast::SourceLocation structLoc_; /* Note: Not a const reference. */
290 size_t ** structPos_;
291 const char * fieldId_;
292 size_t fieldPos_;
293 Ast::Expression * defaultExpr_;
294 public:
295 StructSplitReference( const Ast::SourceLocation & fieldLoc, const char * fieldId, Ast::Expression * defaultExpr );
296 StructSplitReference( const Ast::SourceLocation & fieldLoc, size_t fieldPos, Ast::Expression * defaultExpr );
297 virtual ~StructSplitReference( );
298 void setStruct( const Ast::SourceLocation & structLoc, size_t ** structPos );
299 bool isOrdered( ) const { return fieldId_ == 0; }
300 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
301 virtual void eval( Kernel::EvalState * evalState ) const;
304 class StructSplitSink : public Expression
306 Ast::SourceLocation structLoc_; /* Note: Not a const reference. */
307 size_t ** structPos_;
308 size_t consumedArguments_;
309 public:
310 StructSplitSink( );
311 virtual ~StructSplitSink( );
312 void setStruct( const Ast::SourceLocation & structLoc, size_t ** structPos, size_t consumedArguments );
313 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
314 virtual void eval( Kernel::EvalState * evalState ) const;
317 class AssertNoSinkNeeded : public Assertion
319 size_t orderedCount_;
320 Ast::SourceLocation structLoc_; /* Note: Not a const reference. */
321 size_t ** structPos_;
322 public:
323 AssertNoSinkNeeded( const Ast::SourceLocation & loc, size_t orderedCount, const Ast::SourceLocation & structLoc, size_t ** structPos );
324 virtual ~AssertNoSinkNeeded( );
325 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
326 virtual void eval( Kernel::EvalState * evalState ) const;
329 class SplitDefineVariables
331 static size_t splitVarCount;
332 static PtrOwner_back_Access< std::list< const Ast::PlacedIdentifier * > > mem;
333 const Ast::PlacedIdentifier * splitVarId_;
334 public:
335 std::list< std::pair< Ast::DefineVariable *, Ast::StructSplitReference * > > exprs_;
336 Ast::DefineVariable * sinkDefine_;
337 Ast::StructSplitSink * sinkExpr_;
338 bool seenNamed_;
339 bool seenDefault_;
340 SplitDefineVariables( );
341 Ast::PlacedIdentifier * newSplitVarId( ) const;
344 class StateReference : public Node
346 protected:
347 Node * someParent_; // The inherited parent_ does not make sense for reused nodes. Use this instead.
348 Ast::AnalysisEnvironment * someAnalysisEnv_; // The inherited analysisEnv_ does not make sense for reused nodes. Use this instead.
349 public:
350 StateReference( const Ast::SourceLocation & loc );
351 virtual ~StateReference( );
352 virtual Kernel::StateHandle getHandle( Kernel::PassedEnv env, Kernel::PassedDyn dyn ) const = 0;
355 class LexiographicState : public StateReference
357 const Ast::Identifier * id_;
358 mutable Kernel::Environment::LexicalKey ** idKey_;
359 public:
360 LexiographicState( const Ast::SourceLocation & loc, const Ast::Identifier * id, Kernel::Environment::LexicalKey ** idKey );
361 virtual ~LexiographicState( );
362 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
363 Kernel::StateHandle getHandle( Kernel::PassedEnv env, Kernel::PassedDyn dyn ) const;
366 class DynamicState : public Ast::StateReference
368 const Ast::Identifier * id_;
369 mutable Kernel::Environment::LexicalKey ** idKey_;
370 public:
371 DynamicState( const Ast::SourceLocation & loc, const Ast::Identifier * id );
372 virtual ~DynamicState( );
373 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
374 Kernel::StateHandle getHandle( Kernel::PassedEnv env, Kernel::PassedDyn dyn ) const;
377 class IntroduceState : public BindNode
379 Ast::Expression * expr_;
380 mutable size_t ** idPos_;
381 Ast::StateID stateID_;
382 public:
383 IntroduceState( const Ast::SourceLocation & idLoc, const Ast::PlacedIdentifier * id, Ast::Expression * expr, size_t ** idPos );
384 virtual ~IntroduceState( );
385 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
386 virtual void initializeEnvironment( Kernel::PassedEnv env, Kernel::PassedDyn dyn ) const;
387 virtual void evalHelper( Kernel::EvalState * evalState ) const;
388 Ast::StateID getStateID( ) const { return stateID_; } /* Make sure analyze_impl has been called first! */
391 class Insertion : public Expression
393 Ast::StateReference * stateRef_;
394 Ast::Expression * expr_;
395 public:
396 Insertion( Ast::StateReference * stateRef, Ast::Expression * expr );
397 virtual ~Insertion( );
398 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
399 virtual void eval( Kernel::EvalState * evalState ) const;
402 class InsertionMutatorCall : public Expression
404 Ast::Expression * expr_;
405 public:
406 InsertionMutatorCall( const Ast::SourceLocation & loc, Ast::Expression * expr );
407 ~InsertionMutatorCall( );
408 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
409 virtual void eval( Kernel::EvalState * evalState ) const;
410 Ast::Expression * getExpr( ) { return expr_; }
413 class Freeze : public Expression
415 const Ast::PlacedIdentifier * id_;
416 mutable size_t ** idPos_;
417 public:
418 Freeze( const Ast::SourceLocation & idLoc, const Ast::PlacedIdentifier * id, size_t ** idPos );
419 virtual ~Freeze( );
420 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
421 virtual void eval( Kernel::EvalState * evalState ) const;
424 class Peek : public Expression
426 Ast::StateReference * stateRef_;
427 public:
428 Peek( const Ast::SourceLocation & idLoc, Ast::StateReference * stateRef );
429 virtual ~Peek( );
430 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
431 virtual void eval( Kernel::EvalState * evalState ) const;
434 class EvalSymbolFunction : public Lang::Function
436 Ast::SourceLocation loc_; /* Note: Not a const reference. */
437 Ast::Expression * expr_;
438 Ast::AnalysisEnvironment * analysisEnv_;
439 RefCountPtr< const Ast::NamespacePath > lexicalPath_;
440 public:
441 EvalSymbolFunction( const Ast::SourceLocation & loc, Ast::Expression * expr, const RefCountPtr< const Ast::NamespacePath > & lexicalPath );
442 virtual ~EvalSymbolFunction( );
443 void push_exprs( Ast::ArgListExprs * args ) const;
444 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
445 virtual void call( Kernel::EvalState * evalState, Kernel::Arguments & args, const Ast::SourceLocation & callLoc ) const;
446 virtual void gcMark( Kernel::GCMarkedSet & marked ){ };
447 virtual bool isTransforming( ) const { return false; }
450 class MemberReferenceFunction : public Lang::Function
452 Ast::SourceLocation loc_; /* Note: Not a const reference. */
453 Ast::Expression * variable_;
454 const char * fieldID_;
455 public:
456 MemberReferenceFunction( const Ast::SourceLocation & loc, Ast::Expression * variable, const char * fieldID );
457 virtual ~MemberReferenceFunction( );
458 void push_exprs( Ast::ArgListExprs * args ) const;
459 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
460 virtual void call( Kernel::EvalState * evalState, Kernel::Arguments & args, const Ast::SourceLocation & callLoc ) const;
461 virtual void gcMark( Kernel::GCMarkedSet & marked ){ };
462 virtual bool isTransforming( ) const { return false; }
465 class MutatorReference : public Ast::Expression
467 Ast::SourceLocation mutatorLoc_; /* Note: Not a const reference. */
468 Ast::StateReference * state_;
469 const char * mutatorID_;
470 public:
471 MutatorReference( const Ast::SourceLocation & mutatorLoc, Ast::StateReference * state, const char * mutatorID );
472 virtual ~MutatorReference( );
473 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
474 virtual void eval( Kernel::EvalState * evalState ) const;
477 class SpecialLength : public Expression
479 double val_;
480 int sort_;
481 public:
482 SpecialLength( const Ast::SourceLocation & loc, double val, int sort );
483 virtual ~SpecialLength( );
484 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
485 virtual void eval( Kernel::EvalState * evalState ) const;
488 class DynamicVariable : public Ast::Expression
490 const Ast::Identifier * id_;
491 mutable Kernel::Environment::LexicalKey ** idKey_;
492 public:
493 DynamicVariable( const Ast::SourceLocation & loc, const Ast::Identifier * id );
494 virtual ~DynamicVariable( );
495 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
496 virtual void eval( Kernel::EvalState * evalState ) const;
499 class DynamicBindingExpression : public Ast::Expression
501 Ast::SourceLocation idLoc_; /* Note: Not a const reference. */
502 const Ast::Identifier * id_;
503 Ast::Expression * expr_;
504 mutable Kernel::Environment::LexicalKey ** idKey_;
505 public:
506 DynamicBindingExpression( const Ast::SourceLocation & idLoc, const Ast::Identifier * id, Ast::Expression * expr, Kernel::Environment::LexicalKey ** idKey );
507 virtual ~DynamicBindingExpression( );
508 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
509 virtual void eval( Kernel::EvalState * evalState ) const;
510 const Ast::SourceLocation & idLoc( ) const { return idLoc_; }
511 const Ast::SourceLocation & exprLoc( ) const { return expr_->loc( ); }
512 const Ast::Identifier * id( ) const { return id_; }
515 class DynamicStateBindingExpression : public Ast::Expression
517 Ast::SourceLocation dstLoc_; /* Note: Not a const reference. */
518 const Ast::Identifier * dstId_;
519 mutable Kernel::Environment::LexicalKey ** dstIdKey_;
520 Ast::StateReference * src_;
521 public:
522 DynamicStateBindingExpression( const Ast::SourceLocation & loc, const Ast::SourceLocation & dstLoc, const Ast::Identifier * dstId, Ast::StateReference * src );
523 virtual ~DynamicStateBindingExpression( );
524 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
525 virtual void eval( Kernel::EvalState * evalState ) const;
528 class WithDynamicExpr : public Ast::Expression
530 Ast::Expression * bindings_;
531 Ast::Expression * expr_;
532 public:
533 WithDynamicExpr( const Ast::SourceLocation & loc, Ast::Expression * bindings, Ast::Expression * expr );
534 virtual ~WithDynamicExpr( );
535 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
536 virtual void eval( Kernel::EvalState * evalState ) const;
539 class DynamicVariableDecl : public BindNode
541 mutable size_t ** idPos_;
542 Ast::Expression * impl_;
543 public:
544 DynamicVariableDecl( const Ast::SourceLocation & loc, const Ast::SourceLocation & idLoc, const Ast::PlacedIdentifier * id, Ast::Expression * filterExpr, Ast::Expression * defaultExpr );
545 virtual ~DynamicVariableDecl( );
546 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
547 virtual void initializeEnvironment( Kernel::PassedEnv env, Kernel::PassedDyn dyn ) const;
548 virtual void evalHelper( Kernel::EvalState * evalState ) const;
551 class DynamicVariableDeclFunction : public Lang::Function
553 const Ast::PlacedIdentifier * id_;
554 Ast::Expression * filterExpr_;
555 Ast::Expression * defaultExpr_;
556 size_t ** idPos_;
557 public:
558 DynamicVariableDeclFunction( const Ast::PlacedIdentifier * id, Ast::Expression * filterExpr, Ast::Expression * defaultExpr, size_t ** idPos );
559 virtual ~DynamicVariableDeclFunction( );
560 void push_exprs( Ast::ArgListExprs * args ) const;
561 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
562 virtual void call( Kernel::EvalState * evalState, Kernel::Arguments & args, const Ast::SourceLocation & callLoc ) const;
563 virtual void gcMark( Kernel::GCMarkedSet & marked ){ };
564 virtual bool isTransforming( ) const { return false; }
567 class DynamicStateDecl : public BindNode
569 mutable size_t ** idPos_;
570 Ast::StateReference * defaultState_;
571 public:
572 DynamicStateDecl( const Ast::SourceLocation & loc, const Ast::SourceLocation & idLoc, const Ast::PlacedIdentifier * id, Ast::StateReference * defaultState, size_t ** idPos );
573 virtual ~DynamicStateDecl( );
574 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
575 virtual void initializeEnvironment( Kernel::PassedEnv env, Kernel::PassedDyn dyn ) const;
576 virtual void evalHelper( Kernel::EvalState * evalState ) const;
579 class DynamicExpression : public Ast::Expression
581 Ast::Expression * expr_;
582 public:
583 DynamicExpression( const Ast::SourceLocation & loc, Ast::Expression * expr );
584 virtual ~DynamicExpression( );
585 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
586 virtual void eval( Kernel::EvalState * evalState ) const;
589 class LexiographicType : public Expression
591 const Ast::Identifier * id_;
592 mutable Kernel::Environment::LexicalKey ** idKey_;
593 public:
594 LexiographicType( const Ast::SourceLocation & loc, const Ast::Identifier * id, Kernel::Environment::LexicalKey ** idKey );
595 virtual ~LexiographicType( );
596 virtual void analyze_impl( Ast::Node * parent, Ast::AnalysisEnvironment * env, Ast::StateIDSet * freeStatesDst );
597 virtual void eval( Kernel::EvalState * evalState ) const;