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 2013, 2014 Henrik Tidefelt
26 class CallCont_1
: public Kernel::Continuation
28 const Ast::ArgListExprs
* argList_
;
30 Kernel::StateHandle mutatorSelf_
;
31 Kernel::PassedEnv env_
;
32 Kernel::PassedDyn dyn_
;
33 Kernel::ContRef cont_
;
34 const Ast::SourceLocation
& callLoc_
;
36 CallCont_1( const Ast::SourceLocation
& traceLoc
, const Ast::ArgListExprs
* argList
, bool curry
, Kernel::StateHandle mutatorSelf
, const Kernel::EvalState
& evalState
, const Ast::SourceLocation
& callLoc
);
37 virtual ~CallCont_1( );
38 virtual void takeValue( const RefCountPtr
< const Lang::Value
> & val
, Kernel::EvalState
* evalState
, bool dummy
) const;
39 virtual Kernel::ContRef
up( ) const;
40 virtual RefCountPtr
< const char > description( ) const;
41 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
44 class CallCont_last
: public Kernel::Continuation
46 RefCountPtr
< const Lang::Function
> fun_
;
47 const Ast::ArgListExprs
* argList_
;
49 Kernel::StateHandle mutatorSelf_
;
50 Kernel::PassedEnv env_
;
51 Kernel::PassedDyn dyn_
;
52 Kernel::ContRef cont_
;
54 CallCont_last( const RefCountPtr
< const Lang::Function
> & fun
, const Ast::ArgListExprs
* argList
, bool curry
, Kernel::StateHandle mutatorSelf
, const Kernel::PassedEnv
& env
, const Kernel::PassedDyn
& dyn
, const Kernel::ContRef
& cont
, const Ast::SourceLocation
& callLoc
);
55 virtual ~CallCont_last( );
56 virtual void takeValue( const RefCountPtr
< const Lang::Value
> & valsUntyped
, Kernel::EvalState
* evalState
, bool dummy
) const;
57 virtual Kernel::ContRef
up( ) const;
58 virtual RefCountPtr
< const char > description( ) const;
59 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
62 class CallCont_n
: public Kernel::Continuation
64 RefCountPtr
< const Kernel::CallContInfo
> info_
;
65 Ast::ArgListExprs::ConstIterator pos_
;
66 RefCountPtr
< const Lang::SingleList
> vals_
;
67 bool force_
; /* If false, the argument is immediate but not forced. */
69 CallCont_n( const Ast::SourceLocation
& traceLoc
, const RefCountPtr
< const Kernel::CallContInfo
> & info
, const Ast::ArgListExprs::ConstIterator
& pos
, RefCountPtr
< const Lang::SingleList
> vals
, bool force
);
70 virtual ~CallCont_n( );
71 virtual void takeHandle( Kernel::VariableHandle val
, Kernel::EvalState
* evalState
, bool dummy
) const;
72 virtual Kernel::ContRef
up( ) const;
73 virtual RefCountPtr
< const char > description( ) const;
74 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
77 class CallCont_Structure_last
: public Kernel::Continuation
79 RefCountPtr
< const Lang::Function
> fun_
;
80 const Ast::ArgListExprs
* argList_
;
81 RefCountPtr
< const Lang::SingleList
> values_
;
83 Kernel::PassedEnv env_
;
84 Kernel::PassedDyn dyn_
;
85 Kernel::ContRef cont_
;
87 CallCont_Structure_last( const RefCountPtr
< const Lang::Function
> & fun
, const Ast::ArgListExprs
* argList
, const RefCountPtr
< const Lang::SingleList
> & values
, bool curry
, const Kernel::PassedEnv
& env
, const Kernel::PassedDyn
& dyn
, const Kernel::ContRef
& cont
, const Ast::SourceLocation
& callLoc
);
88 virtual ~CallCont_Structure_last( );
89 virtual void takeValue( const RefCountPtr
< const Lang::Value
> & valDummy
, 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
);
95 class CallCont_Structure_n
: public Kernel::Continuation
97 RefCountPtr
< const Kernel::CallContInfo
> info_
;
98 size_t pos_
; /* Reverse index of first element in rest_. For example, when rest_ contains a single element, pos_ shall be 0. */
99 RefCountPtr
< const Lang::SingleList
> rest_
;
101 CallCont_Structure_n( const Ast::SourceLocation
& traceLoc
, const RefCountPtr
< const Kernel::CallContInfo
> & info
, size_t pos
, RefCountPtr
< const Lang::SingleList
> rest
);
102 virtual ~CallCont_Structure_n( );
103 virtual void takeValue( const RefCountPtr
< const Lang::Value
> & forcedValue
, Kernel::EvalState
* evalState
, bool dummy
) const;
104 virtual Kernel::ContRef
up( ) const;
105 virtual RefCountPtr
< const char > description( ) const;
106 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
109 class UnionCont_last
: public Kernel::Continuation
111 const Ast::ArgListExprs
* argList_
;
112 Kernel::ContRef cont_
;
114 UnionCont_last( const Ast::ArgListExprs
* argList
, const Kernel::ContRef
& cont
, const Ast::SourceLocation
& callLoc
);
115 virtual ~UnionCont_last( );
116 virtual void takeValue( const RefCountPtr
< const Lang::Value
> & valsUntyped
, Kernel::EvalState
* evalState
, bool dummy
) const;
117 virtual Kernel::ContRef
up( ) const;
118 virtual RefCountPtr
< const char > description( ) const;
119 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
122 class SplitCont_1
: public Kernel::Continuation
124 Ast::Expression
* argList_
;
126 Kernel::PassedEnv env_
;
127 Kernel::PassedDyn dyn_
;
128 Kernel::ContRef cont_
;
129 const Ast::SourceLocation
& callLoc_
;
131 SplitCont_1( const Ast::SourceLocation
& traceLoc
, Ast::Expression
* argList
, bool curry
, const Kernel::EvalState
& evalState
, const Ast::SourceLocation
& callLoc
);
132 virtual ~SplitCont_1( );
133 virtual void takeValue( const RefCountPtr
< const Lang::Value
> & val
, Kernel::EvalState
* evalState
, bool dummy
) const;
134 virtual Kernel::ContRef
up( ) const;
135 virtual RefCountPtr
< const char > description( ) const;
136 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
139 class SplitCont_2
: public Kernel::Continuation
141 RefCountPtr
< const Lang::Function
> fun_
;
143 Kernel::PassedEnv env_
;
144 Kernel::PassedDyn dyn_
;
145 Kernel::ContRef cont_
;
147 SplitCont_2( const RefCountPtr
< const Lang::Function
> & fun
, bool curry
, const Kernel::PassedEnv
& env
, const Kernel::PassedDyn
& dyn
, const Kernel::ContRef
& cont
, const Ast::SourceLocation
& callLoc
);
148 virtual ~SplitCont_2( );
149 virtual void takeValue( const RefCountPtr
< const Lang::Value
> & valsUntyped
, Kernel::EvalState
* evalState
, bool dummy
) const;
150 virtual Kernel::ContRef
up( ) const;
151 virtual RefCountPtr
< const char > description( ) const;
152 virtual void gcMark( Kernel::GCMarkedSet
& marked
);