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
19 #include "shapestypes.h"
20 #include "shapesexceptions.h"
23 #include "angleselect.h"
27 #include "methodbase.h"
29 using namespace Shapes
;
37 class SingleListMethod_foldl
: public Lang::MethodBase
< Lang::SingleList
>
40 SingleListMethod_foldl( RefCountPtr
< const Lang::SingleList
> _self
, const Ast::FileID
* fullMethodID
);
41 virtual ~SingleListMethod_foldl( );
42 virtual void call( Kernel::EvalState
* evalState
, Kernel::Arguments
& args
, const Ast::SourceLocation
& callLoc
) const;
43 static const char * staticFieldID( ) { return "foldl"; }
46 class SingleListMethod_foldr
: public Lang::MethodBase
< Lang::SingleList
>
49 SingleListMethod_foldr( RefCountPtr
< const Lang::SingleList
> _self
, const Ast::FileID
* fullMethodID
);
50 virtual ~SingleListMethod_foldr( );
51 virtual void call( Kernel::EvalState
* evalState
, Kernel::Arguments
& args
, const Ast::SourceLocation
& callLoc
) const;
52 static const char * staticFieldID( ) { return "foldr"; }
55 class SingleListMethod_foldsl
: public Lang::MethodBase
< Lang::SingleList
>
58 SingleListMethod_foldsl( RefCountPtr
< const Lang::SingleList
> _self
, const Ast::FileID
* fullMethodID
);
59 virtual ~SingleListMethod_foldsl( );
60 virtual void call( Kernel::EvalState
* evalState
, Kernel::Arguments
& args
, const Ast::SourceLocation
& callLoc
) const;
61 static const char * staticFieldID( ) { return "foldsl"; }
64 class SingleListMethod_foldsr
: public Lang::MethodBase
< Lang::SingleList
>
67 SingleListMethod_foldsr( RefCountPtr
< const Lang::SingleList
> _self
, const Ast::FileID
* fullMethodID
);
68 virtual ~SingleListMethod_foldsr( );
69 virtual void call( Kernel::EvalState
* evalState
, Kernel::Arguments
& args
, const Ast::SourceLocation
& callLoc
) const;
70 static const char * staticFieldID( ) { return "foldsr"; }
77 Lang::SingleList::SingleList( )
80 Lang::SingleList::~SingleList( )
84 SingleList_register_methods( Lang::SystemFinalClass
* dstClass
)
86 dstClass
->registerMethod( new Kernel::MethodFactory
< Lang::SingleList
, Lang::SingleListMethod_foldl
>( ) );
87 dstClass
->registerMethod( new Kernel::MethodFactory
< Lang::SingleList
, Lang::SingleListMethod_foldr
>( ) );
88 dstClass
->registerMethod( new Kernel::MethodFactory
< Lang::SingleList
, Lang::SingleListMethod_foldsl
>( ) );
89 dstClass
->registerMethod( new Kernel::MethodFactory
< Lang::SingleList
, Lang::SingleListMethod_foldsr
>( ) );
92 RefCountPtr
< const Lang::Class
> Lang::SingleList::TypeID( new Lang::SystemFinalClass( strrefdup( "SingleList" ), SingleList_register_methods
) );
93 TYPEINFOIMPL( SingleList
);
95 Kernel::VariableHandle
96 Lang::SingleList::getField( const char * fieldId
, const RefCountPtr
< const Lang::Value
> & selfRef
) const
98 return TypeID
->getMethod( selfRef
, fieldId
); /* This will throw if there is no such method. */
107 class SingleFoldLCont
: public Kernel::Continuation
109 RefCountPtr
< const Lang::SingleList
> cdr_
;
110 RefCountPtr
< const Lang::Function
> op_
;
111 Kernel::PassedDyn dyn_
;
112 Kernel::ContRef cont_
;
114 SingleFoldLCont( const RefCountPtr
< const Lang::SingleList
> & cdr
, const RefCountPtr
< const Lang::Function
> & op
, const Kernel::PassedDyn
& dyn
, Kernel::ContRef cont
, const Ast::SourceLocation
& traceLoc
)
115 : Kernel::Continuation( traceLoc
), cdr_( cdr
), op_( op
), dyn_( dyn
), cont_( cont
)
117 virtual ~SingleFoldLCont( ) { }
118 virtual void takeHandle( Kernel::VariableHandle val
, Kernel::EvalState
* evalState
, bool dummy
) const
120 evalState
->dyn_
= dyn_
;
121 evalState
->cont_
= cont_
;
122 cdr_
->foldl( evalState
, op_
, val
, traceLoc_
);
124 virtual Kernel::ContRef
up( ) const
128 virtual RefCountPtr
< const char > description( ) const
130 return strrefdup( "singly linked list's foldl" );
132 virtual void gcMark( Kernel::GCMarkedSet
& marked
)
134 const_cast< Lang::SingleList
* >( cdr_
.getPtr( ) )->gcMark( marked
);
135 const_cast< Lang::Function
* >( op_
.getPtr( ) )->gcMark( marked
);
136 dyn_
->gcMark( marked
);
137 cont_
->gcMark( marked
);
141 class SingleFoldRCont
: public Kernel::Continuation
143 Kernel::VariableHandle car_
;
144 RefCountPtr
< const Lang::Function
> op_
;
145 Kernel::PassedDyn dyn_
;
146 Kernel::ContRef cont_
;
148 SingleFoldRCont( const Kernel::VariableHandle
& car
, const RefCountPtr
< const Lang::Function
> & op
, const Kernel::PassedDyn
& dyn
, Kernel::ContRef cont
, const Ast::SourceLocation
& traceLoc
)
149 : Kernel::Continuation( traceLoc
), car_( car
), op_( op
), dyn_( dyn
), cont_( cont
)
151 virtual ~SingleFoldRCont( ) { }
152 virtual void takeHandle( Kernel::VariableHandle val
, Kernel::EvalState
* evalState
, bool dummy
) const
154 evalState
->dyn_
= dyn_
;
155 evalState
->cont_
= cont_
;
156 op_
->call( op_
, evalState
, val
, car_
, traceLoc_
);
158 virtual Kernel::ContRef
up( ) const
162 virtual RefCountPtr
< const char > description( ) const
164 return strrefdup( "singly linked list's foldr" );
166 virtual void gcMark( Kernel::GCMarkedSet
& marked
)
168 car_
->gcMark( marked
);
169 const_cast< Lang::Function
* >( op_
.getPtr( ) )->gcMark( marked
);
170 dyn_
->gcMark( marked
);
171 cont_
->gcMark( marked
);
175 class SingleFoldSLCont
: public Kernel::Continuation
177 RefCountPtr
< const Lang::SingleList
> cdr_
;
178 RefCountPtr
< const Lang::Function
> op_
;
179 Kernel::StateHandle state_
;
180 Kernel::PassedDyn dyn_
;
181 Kernel::ContRef cont_
;
183 SingleFoldSLCont( const RefCountPtr
< const Lang::SingleList
> & cdr
, const RefCountPtr
< const Lang::Function
> & op
, Kernel::StateHandle state
, const Kernel::PassedDyn
& dyn
, Kernel::ContRef cont
, const Ast::SourceLocation
& traceLoc
)
184 : Kernel::Continuation( traceLoc
), cdr_( cdr
), op_( op
), state_( state
), dyn_( dyn
), cont_( cont
)
186 virtual ~SingleFoldSLCont( ) { }
187 virtual void takeHandle( Kernel::VariableHandle val
, Kernel::EvalState
* evalState
, bool dummy
) const
189 evalState
->dyn_
= dyn_
;
190 evalState
->cont_
= cont_
;
191 cdr_
->foldsl( evalState
, op_
, val
, state_
, traceLoc_
);
193 virtual Kernel::ContRef
up( ) const
197 virtual RefCountPtr
< const char > description( ) const
199 return strrefdup( "singly linked list's foldsl" );
201 virtual void gcMark( Kernel::GCMarkedSet
& marked
)
203 const_cast< Lang::SingleList
* >( cdr_
.getPtr( ) )->gcMark( marked
);
204 const_cast< Lang::Function
* >( op_
.getPtr( ) )->gcMark( marked
);
205 state_
->gcMark( marked
);
206 dyn_
->gcMark( marked
);
207 cont_
->gcMark( marked
);
211 class SingleFoldSRCont
: public Kernel::Continuation
213 Kernel::VariableHandle car_
;
214 RefCountPtr
< const Lang::Function
> op_
;
215 Kernel::StateHandle state_
;
216 Kernel::PassedDyn dyn_
;
217 Kernel::ContRef cont_
;
219 SingleFoldSRCont( const Kernel::VariableHandle
& car
, const RefCountPtr
< const Lang::Function
> & op
, Kernel::StateHandle state
, const Kernel::PassedDyn
& dyn
, Kernel::ContRef cont
, const Ast::SourceLocation
& traceLoc
)
220 : Kernel::Continuation( traceLoc
), car_( car
), op_( op
), state_( state
),dyn_( dyn
), cont_( cont
)
222 virtual ~SingleFoldSRCont( ) { }
223 virtual void takeHandle( Kernel::VariableHandle val
, Kernel::EvalState
* evalState
, bool dummy
) const
225 evalState
->dyn_
= dyn_
;
226 evalState
->cont_
= cont_
;
227 op_
->call( op_
, evalState
, val
, car_
, state_
, traceLoc_
);
229 virtual Kernel::ContRef
up( ) const
233 virtual RefCountPtr
< const char > description( ) const
235 return strrefdup( "singly linked list's foldsr" );
237 virtual void gcMark( Kernel::GCMarkedSet
& marked
)
239 car_
->gcMark( marked
);
240 const_cast< Lang::Function
* >( op_
.getPtr( ) )->gcMark( marked
);
241 state_
->gcMark( marked
);
242 dyn_
->gcMark( marked
);
243 cont_
->gcMark( marked
);
251 Lang::SingleListPair::SingleListPair( const Kernel::VariableHandle
& car
, const RefCountPtr
< const Lang::SingleList
> & cdr
)
252 : car_( car
), cdr_( cdr
)
255 Lang::SingleListPair::~SingleListPair( )
259 Lang::SingleListPair::isNull( ) const
265 Lang::SingleListPair::foldl( Kernel::EvalState
* evalState
, const RefCountPtr
< const Lang::Function
> & op
, const Kernel::VariableHandle
& nullResult
, const Ast::SourceLocation
& callLoc
) const
267 evalState
->cont_
= Kernel::ContRef( new Kernel::SingleFoldLCont( cdr_
, op
, evalState
->dyn_
, evalState
->cont_
, callLoc
) );
269 op
->call( op
, evalState
, nullResult
, car_
, callLoc
);
273 Lang::SingleListPair::foldr( Kernel::EvalState
* evalState
, const RefCountPtr
< const Lang::Function
> & op
, const Kernel::VariableHandle
& nullResult
, const Ast::SourceLocation
& callLoc
) const
275 evalState
->cont_
= Kernel::ContRef( new Kernel::SingleFoldRCont( car_
, op
, evalState
->dyn_
, evalState
->cont_
, callLoc
) );
277 cdr_
->foldr( evalState
, op
, nullResult
, callLoc
);
281 Lang::SingleListPair::foldsl( Kernel::EvalState
* evalState
, const RefCountPtr
< const Lang::Function
> & op
, const Kernel::VariableHandle
& nullResult
, Kernel::StateHandle state
, const Ast::SourceLocation
& callLoc
) const
283 evalState
->cont_
= Kernel::ContRef( new Kernel::SingleFoldSLCont( cdr_
, op
, state
, evalState
->dyn_
, evalState
->cont_
, callLoc
) );
285 op
->call( op
, evalState
, nullResult
, car_
, state
, callLoc
);
289 Lang::SingleListPair::foldsr( Kernel::EvalState
* evalState
, const RefCountPtr
< const Lang::Function
> & op
, const Kernel::VariableHandle
& nullResult
, Kernel::StateHandle state
, const Ast::SourceLocation
& callLoc
) const
291 evalState
->cont_
= Kernel::ContRef( new Kernel::SingleFoldSRCont( car_
, op
, state
, evalState
->dyn_
, evalState
->cont_
, callLoc
) );
293 cdr_
->foldsr( evalState
, op
, nullResult
, state
, callLoc
);
297 Lang::SingleListPair::gcMark( Kernel::GCMarkedSet
& marked
)
299 car_
->gcMark( marked
);
300 const_cast< Lang::SingleList
* >( cdr_
.getPtr( ) )->gcMark( marked
);
303 Lang::SingleListNull::SingleListNull( )
306 Lang::SingleListNull::~SingleListNull( )
310 Lang::SingleListNull::isNull( ) const
316 Lang::SingleListNull::foldl( Kernel::EvalState
* evalState
, const RefCountPtr
< const Lang::Function
> & op
, const Kernel::VariableHandle
& nullResult
, const Ast::SourceLocation
& callLoc
) const
318 Kernel::ContRef cont
= evalState
->cont_
;
319 cont
->takeHandle( nullResult
,
324 Lang::SingleListNull::foldr( Kernel::EvalState
* evalState
, const RefCountPtr
< const Lang::Function
> & op
, const Kernel::VariableHandle
& nullResult
, const Ast::SourceLocation
& callLoc
) const
326 Kernel::ContRef cont
= evalState
->cont_
;
327 cont
->takeHandle( nullResult
,
332 Lang::SingleListNull::foldsl( Kernel::EvalState
* evalState
, const RefCountPtr
< const Lang::Function
> & op
, const Kernel::VariableHandle
& nullResult
, Kernel::StateHandle state
, const Ast::SourceLocation
& callLoc
) const
334 Kernel::ContRef cont
= evalState
->cont_
;
335 cont
->takeHandle( nullResult
,
340 Lang::SingleListNull::foldsr( Kernel::EvalState
* evalState
, const RefCountPtr
< const Lang::Function
> & op
, const Kernel::VariableHandle
& nullResult
, Kernel::StateHandle state
, const Ast::SourceLocation
& callLoc
) const
342 Kernel::ContRef cont
= evalState
->cont_
;
343 cont
->takeHandle( nullResult
,
348 Lang::ConsPair::ConsPair( const Kernel::VariableHandle
& car
, const Kernel::VariableHandle
& cdr
)
349 : car_( car
), cdr_( cdr
)
352 Lang::ConsPair::~ConsPair( )
355 RefCountPtr
< const Lang::Class
> Lang::ConsPair::TypeID( new Lang::SystemFinalClass( strrefdup( "ConsPair" ) ) );
356 TYPEINFOIMPL( ConsPair
);
359 Lang::ConsPair::show( std::ostream
& os
) const
361 os
<< "< a lazy pair >" ;
364 Kernel::VariableHandle
365 Lang::ConsPair::getField( const char * fieldID
, const RefCountPtr
< const Lang::Value
> & selfRef
) const
367 if( strcmp( fieldID
, "car" ) == 0 )
371 if( strcmp( fieldID
, "cdr" ) == 0 )
375 throw Exceptions::NonExistentMember( getTypeName( ), fieldID
);
379 Lang::ConsPair::gcMark( Kernel::GCMarkedSet
& marked
)
381 car_
->gcMark( marked
);
382 cdr_
->gcMark( marked
);
386 Lang::SingleListMethod_foldl::SingleListMethod_foldl( RefCountPtr
< const Lang::SingleList
> self
, const Ast::FileID
* fullMethodID
)
387 : Lang::MethodBase
< class_type
>( self
, fullMethodID
, false )
389 formals_
->appendEvaluatedCoreFormal( "op", Kernel::THE_SLOT_VARIABLE
, true );
390 formals_
->appendEvaluatedCoreFormal( "nullRes", Kernel::THE_SLOT_VARIABLE
, false );
393 Lang::SingleListMethod_foldl::~SingleListMethod_foldl( )
397 Lang::SingleListMethod_foldl::call( Kernel::EvalState
* evalState
, Kernel::Arguments
& args
, const Ast::SourceLocation
& callLoc
) const
399 args
.applyDefaults( );
401 self_
->foldl( evalState
,
402 Helpers::down_cast_CoreArgument
< const Lang::Function
>( title_
, args
, 0, callLoc
),
407 Lang::SingleListMethod_foldr::SingleListMethod_foldr( RefCountPtr
< const Lang::SingleList
> self
, const Ast::FileID
* fullMethodID
)
408 : Lang::MethodBase
< class_type
>( self
, fullMethodID
, false )
410 formals_
->appendEvaluatedCoreFormal( "op", Kernel::THE_SLOT_VARIABLE
, true );
411 formals_
->appendEvaluatedCoreFormal( "nullRes", Kernel::THE_SLOT_VARIABLE
, false );
414 Lang::SingleListMethod_foldr::~SingleListMethod_foldr( )
418 Lang::SingleListMethod_foldr::call( Kernel::EvalState
* evalState
, Kernel::Arguments
& args
, const Ast::SourceLocation
& callLoc
) const
420 args
.applyDefaults( );
422 self_
->foldr( evalState
,
423 Helpers::down_cast_CoreArgument
< const Lang::Function
>( title_
, args
, 0, callLoc
),
428 Lang::SingleListMethod_foldsl::SingleListMethod_foldsl( RefCountPtr
< const Lang::SingleList
> self
, const Ast::FileID
* fullMethodID
)
429 : Lang::MethodBase
< class_type
>( self
, fullMethodID
, false )
431 formals_
->appendEvaluatedCoreFormal( "op", Kernel::THE_SLOT_VARIABLE
, true );
432 formals_
->appendEvaluatedCoreFormal( "nullRes", Kernel::THE_SLOT_VARIABLE
, false );
433 formals_
->appendCoreStateFormal( "state" );
436 Lang::SingleListMethod_foldsl::~SingleListMethod_foldsl( )
440 Lang::SingleListMethod_foldsl::call( Kernel::EvalState
* evalState
, Kernel::Arguments
& args
, const Ast::SourceLocation
& callLoc
) const
442 args
.applyDefaults( );
444 self_
->foldsl( evalState
,
445 Helpers::down_cast_CoreArgument
< const Lang::Function
>( title_
, args
, 0, callLoc
),
451 Lang::SingleListMethod_foldsr::SingleListMethod_foldsr( RefCountPtr
< const Lang::SingleList
> self
, const Ast::FileID
* fullMethodID
)
452 : Lang::MethodBase
< class_type
>( self
, fullMethodID
, false )
454 formals_
->appendEvaluatedCoreFormal( "op", Kernel::THE_SLOT_VARIABLE
, true );
455 formals_
->appendEvaluatedCoreFormal( "nullRes", Kernel::THE_SLOT_VARIABLE
, false );
456 formals_
->appendCoreStateFormal( "state" );
459 Lang::SingleListMethod_foldsr::~SingleListMethod_foldsr( )
463 Lang::SingleListMethod_foldsr::call( Kernel::EvalState
* evalState
, Kernel::Arguments
& args
, const Ast::SourceLocation
& callLoc
) const
465 args
.applyDefaults( );
467 self_
->foldsr( evalState
,
468 Helpers::down_cast_CoreArgument
< const Lang::Function
>( title_
, args
, 0, callLoc
),
475 Lang::Structure::Structure( const Ast::ArgListExprs
* argList
, const RefCountPtr
< const Lang::SingleList
> & values
, bool argListOwner
)
476 : argListOwner_( argListOwner
), argList_( argList
), values_( values
)
479 Lang::Structure::~Structure( )
487 RefCountPtr
< const Lang::Class
> Lang::Structure::TypeID( new Lang::SystemFinalClass( strrefdup( "Union" ) ) );
488 TYPEINFOIMPL( Structure
);
490 Kernel::VariableHandle
491 Lang::Structure::getField( const char * fieldID
, const RefCountPtr
< const Lang::Value
> & selfRef
) const
493 return argList_
->findNamed( values_
, fieldID
);
496 Kernel::VariableHandle
497 Lang::Structure::getPosition( size_t pos
, const RefCountPtr
< const Lang::Value
> & selfRef
) const
499 return argList_
->getOrdered( values_
, pos
);
502 RefCountPtr
< const Lang::Structure
>
503 Lang::Structure::getSink( size_t consumedArguments
) const
505 if( argList_
->orderedExprs_
->size( ) <= consumedArguments
)
507 return Lang::THE_EMPTY_STRUCT
;
510 static std::vector
< const Ast::ArgListExprs
* > argLists
;
511 size_t resSize
= argList_
->orderedExprs_
->size( ) - consumedArguments
;
512 if( resSize
>= argLists
.size( ) )
514 argLists
.reserve( resSize
+ 1 );
515 while( argLists
.size( ) <= resSize
)
517 argLists
.push_back( new Ast::ArgListExprs( argLists
.size( ) ) );
521 RefCountPtr
< const Lang::SingleList
> resValues
= values_
;
524 for( size_t i
= 0; i
< consumedArguments
; ++i
)
526 resValues
= Helpers::try_cast_CoreArgument
< const Lang::SingleListPair
>( resValues
)->cdr_
;
529 catch( const NonLocalExit::NotThisType
& ball
)
531 throw Exceptions::InternalError( "When constructing the sink, there was not enough arguments." );
533 return RefCountPtr
< const Lang::Structure
>( new Lang::Structure( argLists
[ resSize
], resValues
, false ) );
537 Lang::Structure::gcMark( Kernel::GCMarkedSet
& marked
)
539 const_cast< Lang::SingleList
* >( values_
.getPtr( ) )->gcMark( marked
);
543 Kernel::StructureFactory::StructureFactory( const std::list
< const char * > & fields
)
548 Kernel::StructureFactory::StructureFactory( const char * field1
)
550 std::list
< const char * > fields
;
551 fields
.push_back( field1
);
555 Kernel::StructureFactory::StructureFactory( const char * field1
, const char * field2
)
557 std::list
< const char * > fields
;
558 fields
.push_back( field1
);
559 fields
.push_back( field2
);
563 Kernel::StructureFactory::StructureFactory( const char * field1
, const char * field2
, const char * field3
)
565 std::list
< const char * > fields
;
566 fields
.push_back( field1
);
567 fields
.push_back( field2
);
568 fields
.push_back( field3
);
572 Kernel::StructureFactory::StructureFactory( const char * field1
, const char * field2
, const char * field3
, const char * field4
)
574 std::list
< const char * > fields
;
575 fields
.push_back( field1
);
576 fields
.push_back( field2
);
577 fields
.push_back( field3
);
578 fields
.push_back( field4
);
583 Kernel::StructureFactory::init( const std::list
< const char * > & fields
)
585 Ast::ArgListExprs
* tmp
= new Ast::ArgListExprs( false );
586 typedef typeof fields ListType
;
587 for( ListType::const_iterator i
= fields
.begin( ); i
!= fields
.end( ); ++i
)
589 (*tmp
->namedExprs_
)[ *i
] = 0;
590 typedef typeof values_ MapType
;
591 values_
.insert( MapType::value_type( *i
, Kernel::THE_VOID_VARIABLE
) );
597 Kernel::StructureFactory::clear( )
599 typedef typeof values_ MapType
;
600 for( MapType::iterator i
= values_
.begin( ); i
!= values_
.end( ); ++i
)
602 i
->second
= Kernel::THE_VOID_VARIABLE
;
607 Kernel::StructureFactory::set( const char * field
, const Kernel::VariableHandle
& value
)
609 typedef typeof values_ MapType
;
610 MapType::iterator i
= values_
.find( field
);
611 if( i
== values_
.end( ) )
613 throw Exceptions::InternalError( "Kernel::StructureFactory::set: Field was not declared." );
618 RefCountPtr
< const Lang::Structure
>
619 Kernel::StructureFactory::build( )
621 RefCountPtr
< const Lang::SingleList
> tmp
= Lang::THE_CONS_NULL
;
622 typedef typeof values_ MapType
;
623 for( MapType::iterator i
= values_
.begin( ); i
!= values_
.end( ); ++i
)
625 tmp
= RefCountPtr
< const Lang::SingleList
>( new Lang::SingleListPair( i
->second
, tmp
) );
627 return RefCountPtr
< const Lang::Structure
>( new Lang::Structure( argList_
, tmp
) );
631 Kernel::UnnamedStructureFactory::UnnamedStructureFactory( )
634 RefCountPtr
< const Lang::Structure
>
635 Kernel::UnnamedStructureFactory::build( const RefCountPtr
< const Lang::SingleList
> & values
) const
637 /* Here we use that argLists_ is mutable, so that we can extend it with more entries as needed. */
639 for( RefCountPtr
< const Lang::SingleList
> tmp
= values
; ! tmp
->isNull( ); tmp
= dynamic_cast< const Lang::SingleListPair
* >( tmp
.getPtr( ) )->cdr_
, ++sz
)
641 typedef typeof argLists_ MapType
;
642 MapType::iterator i
= argLists_
.find( sz
);
643 const Ast::ArgListExprs
* argList
= 0;
644 if( i
== argLists_
.end( ) )
646 Ast::ArgListExprs
* tmp
= new Ast::ArgListExprs( false );
647 for( size_t i
= 0; i
< sz
; ++i
)
649 tmp
->orderedExprs_
->push_back( 0 );
652 argLists_
.insert( MapType::value_type( sz
, argList
) );
658 return RefCountPtr
< const Lang::Structure
>( new Lang::Structure( argList
, values
) );