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, 2009, 2013, 2014 Henrik Tidefelt
19 #include "shapesexceptions.h"
23 #include "functiontypes.h"
25 using namespace Shapes
;
29 const std::string
Exceptions::additionalLinesPrefix
= "| ";
35 void prefixEachLine( const std::string
& prefix
, std::istream
& src
, std::ostream
& dst
);
36 void prefixEachLine( const std::string
& prefix
, const RefCountPtr
< const char > & src
, std::ostream
& dst
);
40 Exceptions::NotImplemented::NotImplemented( const char * functionality
)
41 : functionality_( functionality
)
44 Exceptions::NotImplemented::~NotImplemented( )
48 Exceptions::NotImplemented::display( std::ostream
& os
) const
50 os
<< "Under construction: " << functionality_
<< " is not implemented." << std::endl
;
53 const char * Exceptions::Exception::locsep
= ": ";
55 Exceptions::Exception::Exception( )
58 Exceptions::Exception::~Exception( )
61 Exceptions::MiscellaneousRequirement::MiscellaneousRequirement( const Ast::SourceLocation
& loc
, RefCountPtr
< const char > msg
)
62 : Exceptions::CatchableError( loc
), msg_( msg
.getPtr( ) ), msgMem_( msg
)
65 Exceptions::MiscellaneousRequirement::MiscellaneousRequirement( const Ast::SourceLocation
& loc
, const char * msg
)
66 : Exceptions::CatchableError( loc
), msg_( msg
), msgMem_( NullPtr
< const char >( ) )
69 Exceptions::MiscellaneousRequirement::MiscellaneousRequirement( RefCountPtr
< const char > msg
)
70 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), msg_( msg
.getPtr( ) ), msgMem_( msg
)
73 Exceptions::MiscellaneousRequirement::MiscellaneousRequirement( const char * msg
)
74 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), msg_( msg
), msgMem_( NullPtr
< const char >( ) )
77 Exceptions::MiscellaneousRequirement::~MiscellaneousRequirement( )
81 Exceptions::MiscellaneousRequirement::display( ostream
& os
) const
83 os
<< "Failed to meet requirement: " << msg_
<< std::endl
;
86 RefCountPtr
< const Lang::Exception
>
87 Exceptions::MiscellaneousRequirement::clone( const Kernel::ContRef
& cont
) const
89 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "misc" ) );
90 std::ostringstream os
;
92 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
94 RefCountPtr
< const Lang::String
>( new Lang::String( "(core, generic)", true ) ),
98 this->exitCode( ) ) );
102 Exceptions::HandlerError::HandlerError( RefCountPtr
< const char > msg
)
103 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), msg_( msg
)
106 Exceptions::HandlerError::HandlerError( const char * msg
)
107 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), msg_( strrefdup( msg
) )
110 Exceptions::HandlerError::~HandlerError( )
114 Exceptions::HandlerError::display( ostream
& os
) const
116 os
<< "Error handler message: " << msg_
<< std::endl
;
119 RefCountPtr
< const Lang::Exception
>
120 Exceptions::HandlerError::clone( const Kernel::ContRef
& cont
) const
122 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "misc" ) );
123 std::ostringstream os
;
125 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
127 RefCountPtr
< const Lang::String
>( new Lang::String( "(default error handler)", true ) ),
131 this->exitCode( ) ) );
135 Exceptions::MiscellaneousStaticInconsistency::MiscellaneousStaticInconsistency( const Ast::SourceLocation
& loc
, RefCountPtr
< const char > msg
)
136 : Exceptions::StaticInconsistency( loc
), msg_( msg
)
139 Exceptions::MiscellaneousStaticInconsistency::~MiscellaneousStaticInconsistency( )
143 Exceptions::MiscellaneousStaticInconsistency::display( ostream
& os
) const
145 os
<< "Misc error: " << msg_
<< std::endl
;
149 Exceptions::ScannerError::ScannerError( const Ast::SourceLocation
& loc
, RefCountPtr
< const char > msg
)
150 : Exceptions::StaticInconsistency( loc
), msg_( msg
)
153 Exceptions::ScannerError::~ScannerError( )
157 Exceptions::ScannerError::display( ostream
& os
) const
159 os
<< "Scanner error: " << msg_
<< std::endl
;
163 Exceptions::ParserError::ParserError( const Ast::SourceLocation
& loc
, RefCountPtr
< const char > msg
, bool justAWarning
)
164 : Exceptions::StaticInconsistency( loc
), msg_( msg
), justAWarning_( justAWarning
)
167 Exceptions::ParserError::~ParserError( )
171 Exceptions::ParserError::display( ostream
& os
) const
173 os
<< "Parser " << ( justAWarning_
? "warning" : "error" ) << ": " << msg_
<< std::endl
;
177 Exceptions::MemberAlsoAbstract::MemberAlsoAbstract( const Ast::SourceLocation
& memberLoc
, const char * id
, const Ast::SourceLocation
& abstractLoc
)
178 : Exceptions::StaticInconsistency( memberLoc
), id_( id
), abstractLoc_( abstractLoc
)
181 Exceptions::MemberAlsoAbstract::~MemberAlsoAbstract( )
185 Exceptions::MemberAlsoAbstract::display( ostream
& os
) const
187 os
<< "The member " << id_
<< " is also declared abstract, at " << abstractLoc_
<< "." << std::endl
;
191 Exceptions::MemberAlreadyDeclared::MemberAlreadyDeclared( const Ast::SourceLocation
& memberLoc
, const char * id
, const Ast::SourceLocation
& oldLoc
)
192 : Exceptions::StaticInconsistency( memberLoc
), id_( id
), oldLoc_( oldLoc
)
195 Exceptions::MemberAlreadyDeclared::~MemberAlreadyDeclared( )
199 Exceptions::MemberAlreadyDeclared::display( ostream
& os
) const
201 os
<< "The member " << id_
<< " has already been declared, at " << oldLoc_
<< "." << std::endl
;
205 Exceptions::PublicGetSetInNonfinalClass::PublicGetSetInNonfinalClass( const Ast::SourceLocation
& memberLoc
, const char * id
)
206 : Exceptions::StaticInconsistency( memberLoc
), id_( id
)
209 Exceptions::PublicGetSetInNonfinalClass::~PublicGetSetInNonfinalClass( )
213 Exceptions::PublicGetSetInNonfinalClass::display( ostream
& os
) const
215 os
<< "Only members of final classes may have the public get or set specifier. Member in question: " << id_
<< "." << std::endl
;
219 Exceptions::TransformingMemberInNonfinalClass::TransformingMemberInNonfinalClass( const Ast::SourceLocation
& memberLoc
, const char * id
)
220 : Exceptions::StaticInconsistency( memberLoc
), id_( id
)
223 Exceptions::TransformingMemberInNonfinalClass::~TransformingMemberInNonfinalClass( )
227 Exceptions::TransformingMemberInNonfinalClass::display( ostream
& os
) const
229 os
<< "Only members of final classes may have the <transforming> specifier. Member in question: " << id_
<< "." << std::endl
;
233 Exceptions::RepeatedFormal::RepeatedFormal( const Ast::SourceLocation
& loc
, const char * id
)
234 : Exceptions::StaticInconsistency( loc
), id_( id
)
237 Exceptions::RepeatedFormal::~RepeatedFormal( )
241 Exceptions::RepeatedFormal::display( ostream
& os
) const
243 os
<< "Repeated formal: " << id_
<< std::endl
;
247 Exceptions::IllegalFreeStates::IllegalFreeStates( const Ast::SourceLocation
& loc
, Ast::StateIDSet
* freeStates
, const char * reason
)
248 : Exceptions::StaticInconsistency( loc
), freeStates_( freeStates
), reason_( reason
)
251 Exceptions::IllegalFreeStates::~IllegalFreeStates( )
255 Exceptions::IllegalFreeStates::display( ostream
& os
) const
257 os
<< "Free states are illegal here (" << reason_
<< "):" ;
258 typedef typeof *freeStates_ SetType
;
259 for( SetType::const_iterator i
= freeStates_
->begin( ); i
!= freeStates_
->end( ); ++i
)
267 Exceptions::FreeStateIsAlsoPassed::FreeStateIsAlsoPassed( const Ast::SourceLocation
& loc
, Ast::StateID stateID
)
268 : Exceptions::StaticInconsistency( loc
), stateID_( stateID
)
271 Exceptions::FreeStateIsAlsoPassed::~FreeStateIsAlsoPassed( )
275 Exceptions::FreeStateIsAlsoPassed::display( ostream
& os
) const
277 os
<< "Non-pure, delayed, expressions may not have free states (state " << stateID_
<< ") which are also passed as state arguments in the same non-pure function application. Please consider forcing immediate evaluation." << std::endl
;
281 Exceptions::RepeatedStateArgument::RepeatedStateArgument( const Ast::SourceLocation
& loc
, const RefCountPtr
< Ast::StateIDSet
> & passedStates
)
282 : Exceptions::StaticInconsistency( loc
), passedStates_( passedStates
)
285 Exceptions::RepeatedStateArgument::~RepeatedStateArgument( )
289 Exceptions::RepeatedStateArgument::display( ostream
& os
) const
291 os
<< "Some of these states are being passed in more than one state argument position:" ;
292 typedef typeof *passedStates_ SetType
;
293 for( SetType::const_iterator i
= passedStates_
->begin( ); i
!= passedStates_
->end( ); ++i
)
301 Exceptions::PassingStateOut::PassingStateOut( const Ast::SourceLocation
& loc
, const char * id
)
302 : Exceptions::StaticInconsistency( loc
), id_( id
)
305 Exceptions::PassingStateOut::~PassingStateOut( )
309 Exceptions::PassingStateOut::display( std::ostream
& os
) const
311 os
<< "States may not be returned, cannot return state " << id_
<< "." << std::endl
;
315 Exceptions::IntroducingExisting::IntroducingExisting( const Ast::SourceLocation
& loc
, const char * id
)
316 : Exceptions::StaticInconsistency( loc
), id_( id
)
319 Exceptions::IntroducingExisting::~IntroducingExisting( )
323 Exceptions::IntroducingExisting::display( std::ostream
& os
) const
325 os
<< "The variable " << id_
<< " is already introduced in this scope." << std::endl
;
329 Exceptions::ExpectedImmediate::ExpectedImmediate( const Ast::SourceLocation
& loc
)
330 : Exceptions::StaticInconsistency( loc
)
333 Exceptions::ExpectedImmediate::~ExpectedImmediate( )
337 Exceptions::ExpectedImmediate::display( std::ostream
& os
) const
339 os
<< "It makes no sense to put a pure expression before the end of a code bracket." << std::endl
;
343 Exceptions::IllegalImperative::IllegalImperative( const Ast::SourceLocation
& loc
)
344 : Exceptions::StaticInconsistency( loc
)
347 Exceptions::IllegalImperative::~IllegalImperative( )
351 Exceptions::IllegalImperative::display( std::ostream
& os
) const
353 os
<< "Imperative expressions are not allowed here." << std::endl
;
357 Exceptions::FreezingUndefined::FreezingUndefined( const Ast::SourceLocation
& loc
, const char * id
)
358 : Exceptions::StaticInconsistency( loc
), id_( id
)
361 Exceptions::FreezingUndefined::~FreezingUndefined( )
365 Exceptions::FreezingUndefined::display( std::ostream
& os
) const
367 os
<< "Internal error: The variable " << id_
<< " is freezed before it was defined. Either this should be caught by during the parse, or it is due to an error in the setup of the initial environment." << std::endl
;
371 Exceptions::FileReadOpenError::FileReadOpenError( const Ast::SourceLocation
& loc
, RefCountPtr
< const char > filename
, const std::string
* sourceDir
, const std::list
< std::string
> * searchPath
, Type type
)
372 : loc_( loc
), filename_( filename
), type_( type
), sourceDir_( sourceDir
), searchPath_( searchPath
)
375 Exceptions::FileReadOpenError::~FileReadOpenError( )
379 Exceptions::FileReadOpenError::display( std::ostream
& os
) const
384 os
<< loc_
<< locsep
<< "Could not open file: " << filename_
;
387 os
<< loc_
<< locsep
<< "Could not stat() file: " << filename_
;
390 if( searchPath_
!= 0 )
392 os
<< " searching \"" ;
393 typedef typeof *searchPath_ ListType
;
394 for( ListType::const_iterator i
= searchPath_
->begin( ); i
!= searchPath_
->end( ); ++i
)
396 if( i
!= searchPath_
->begin( ) )
400 if( sourceDir_
!= 0 && (*i
)[0] != '/' )
412 Exceptions::FileWriteOpenError::FileWriteOpenError( const Ast::SourceLocation
& loc
, RefCountPtr
< const char > filename
, const char * purpose
)
413 : loc_( loc
), filename_( filename
), purpose_( purpose
)
416 Exceptions::FileWriteOpenError::~FileWriteOpenError( )
420 Exceptions::FileWriteOpenError::display( std::ostream
& os
) const
422 os
<< loc_
<< locsep
<< "Could not open " ;
427 os
<< " file for write: " << filename_
;
432 Exceptions::TeXSetupTooLate::TeXSetupTooLate( const Ast::SourceLocation
& loc
)
436 Exceptions::TeXSetupTooLate::~TeXSetupTooLate( )
440 Exceptions::TeXSetupTooLate::display( std::ostream
& os
) const
442 os
<< loc_
<< locsep
<< "It is too late to make modifications to the TeX context." << std::endl
;
446 Exceptions::EmptyFinalPicture::EmptyFinalPicture( )
449 Exceptions::EmptyFinalPicture::~EmptyFinalPicture( )
453 Exceptions::EmptyFinalPicture::display( std::ostream
& os
) const
455 os
<< "Nothing was ever put in the global #" << Lang::CATALOG_ID
<< " or drawn to the global #" << Lang::CANVAS_ID
<< "." << std::endl
;
459 Exceptions::TeXSetupHasChanged::TeXSetupHasChanged( )
460 : Shapes::Exceptions::InternalError( "The TeX context check failed while loading fresh labels." )
463 Exceptions::TeXSetupHasChanged::~TeXSetupHasChanged( )
467 Exceptions::TypeMismatch::TypeMismatch( const Ast::SourceLocation
& loc
, RefCountPtr
< const char > valueType
, RefCountPtr
< const char > expectedType
)
468 : Exceptions::RuntimeError( loc
), hint_( 0 ), valueType_( valueType
), expectedType_( expectedType
)
471 Exceptions::TypeMismatch::TypeMismatch( const Ast::SourceLocation
& loc
, const char * hint
, RefCountPtr
< const char > valueType
, RefCountPtr
< const char > expectedType
)
472 : Exceptions::RuntimeError( loc
), hint_( hint
), valueType_( valueType
), expectedType_( expectedType
)
475 Exceptions::TypeMismatch::~TypeMismatch( )
479 Exceptions::TypeMismatch::display( std::ostream
& os
) const
483 os
<< hint_
<< ": " ;
485 os
<< "Expected a " << expectedType_
<< ", got a " << valueType_
<< "." << std::endl
;
488 Exceptions::ExpectedList::ExpectedList( const Ast::SourceLocation
& loc
, size_t index
, RefCountPtr
< const char > nonListType
)
489 : Exceptions::RuntimeError( loc
), index_( index
), nonListType_( nonListType
)
492 Exceptions::ExpectedList::~ExpectedList( )
496 Exceptions::ExpectedList::display( std::ostream
& os
) const
498 os
<< "Expected a singly linked list, but encountered a " << nonListType_
<< " after " << index_
<< " elements." << std::endl
;
501 Exceptions::PDFVersionError::PDFVersionError( SimplePDF::PDF_Version::Version version
, SimplePDF::PDF_Version::Version required
, const RefCountPtr
< const char > & msg
, bool justAWarning
)
502 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), version_( version
), required_( required
), msgMem_( msg
), msg_( msgMem_
.getPtr( ) ), justAWarning_( justAWarning
)
505 Exceptions::PDFVersionError::PDFVersionError( SimplePDF::PDF_Version::Version version
, SimplePDF::PDF_Version::Version required
, const char * msg
, bool justAWarning
)
506 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), version_( version
), required_( required
), msgMem_( NullPtr
< const char >( ) ), msg_( msg
), justAWarning_( justAWarning
)
509 Exceptions::PDFVersionError::~PDFVersionError( )
513 Exceptions::PDFVersionError::display( std::ostream
& os
) const
515 os
<< SimplePDF::PDF_Version::toString( required_
) << " " << ( justAWarning_
? "warning" : "error" ) << " for target version " << SimplePDF::PDF_Version::toString( version_
) << ": " << msg_
<< std::endl
;
518 RefCountPtr
< const Lang::Exception
>
519 Exceptions::PDFVersionError::clone( const Kernel::ContRef
& cont
) const
521 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "PDF_version" ) );
522 std::ostringstream os
;
524 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
526 RefCountPtr
< const Lang::String
>( new Lang::String( "(core PDF backend)", true ) ),
530 this->exitCode( ) ) );
534 Exceptions::RedefiningLexical::RedefiningLexical( const char * id
)
535 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), id_( id
)
538 Exceptions::RedefiningLexical::~RedefiningLexical( )
542 Exceptions::RedefiningLexical::display( std::ostream
& os
) const
544 os
<< "Redefining " << id_
<< std::endl
;
548 Exceptions::RedefiningDynamic::RedefiningDynamic( const char * id
)
549 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), id_( id
)
552 Exceptions::RedefiningDynamic::~RedefiningDynamic( )
556 Exceptions::RedefiningDynamic::display( std::ostream
& os
) const
558 os
<< "Redefining " << "@" << id_
<< std::endl
;
562 Exceptions::NonObjectMemberAssignment::NonObjectMemberAssignment( const Ast::SourceLocation
& loc
, RefCountPtr
< const char > valueType
)
563 : Exceptions::RuntimeError( loc
), valueType_( valueType
)
566 Exceptions::NonObjectMemberAssignment::~NonObjectMemberAssignment( )
570 Exceptions::NonObjectMemberAssignment::display( std::ostream
& os
) const
572 os
<< "Only object oriented values have fields that can be assigned. This value is of type " << valueType_
<< "." << std::endl
;
576 Exceptions::ElementaryWithout::ElementaryWithout( Kind kind
, Ref ref
, RefCountPtr
< const char > valueType
)
577 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), kind_( kind
), ref_( ref
), valueType_( valueType
)
580 Exceptions::ElementaryWithout::~ElementaryWithout( )
584 Exceptions::ElementaryWithout::display( std::ostream
& os
) const
596 os
<< " is of the elementary type " << valueType_
<< ", which has no " ;
606 os
<< "." << std::endl
;
610 Exceptions::NonExistentPosition::NonExistentPosition( size_t pos
, size_t maxPos
)
611 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), pos_( pos
), maxPos_( maxPos
)
614 Exceptions::NonExistentPosition::~NonExistentPosition( )
618 Exceptions::NonExistentPosition::display( std::ostream
& os
) const
620 os
<< "Referencing field at position " << pos_
<< " is an error since the user struct has only " << maxPos_
<< " ordered fields." << std::endl
;
624 Exceptions::UnaryPrefixNotApplicable::UnaryPrefixNotApplicable( const Ast::SourceLocation
& loc
, const Ast::Expression
* expr
, RefCountPtr
< const char > valueType
)
625 : Exceptions::RuntimeError( loc
), expr_( expr
), valueType_( valueType
), operatorSymbol_( "< ? >" )
628 Exceptions::UnaryPrefixNotApplicable::~UnaryPrefixNotApplicable( )
632 Exceptions::UnaryPrefixNotApplicable::setOperatorSymbol( const char * operatorSymbol
)
634 operatorSymbol_
= operatorSymbol
;
638 Exceptions::UnaryPrefixNotApplicable::display( std::ostream
& os
) const
643 getLoc( ).copy( & os
);
644 os
<< " not defined for " << valueType_
<< " at " << expr_
->loc( ) << "." << std::endl
;
648 os
<< "Operator " << operatorSymbol_
<< " not defined for " << valueType_
<< "." << std::endl
;
653 Exceptions::UnaryPostfixNotApplicable::UnaryPostfixNotApplicable( const Ast::SourceLocation
& loc
, const Ast::Expression
* expr
, RefCountPtr
< const char > valueType
)
654 : Exceptions::RuntimeError( loc
), expr_( expr
), valueType_( valueType
), operatorSymbol_( "< ? >" )
657 Exceptions::UnaryPostfixNotApplicable::~UnaryPostfixNotApplicable( )
661 Exceptions::UnaryPostfixNotApplicable::setOperatorSymbol( const char * operatorSymbol
)
663 operatorSymbol_
= operatorSymbol
;
667 Exceptions::UnaryPostfixNotApplicable::display( std::ostream
& os
) const
672 getLoc( ).copy( & os
);
673 os
<< " not defined for " << valueType_
<< " at " << expr_
->loc( ) << "." << std::endl
;
677 os
<< "Operator " << operatorSymbol_
<< " not defined for " << valueType_
<< "." << std::endl
;
682 Exceptions::BinaryInfixNotApplicable::BinaryInfixNotApplicable( const Ast::SourceLocation
& loc
, const Ast::Expression
* expr1
, RefCountPtr
< const char > valueType1
, const Ast::Expression
* expr2
, RefCountPtr
< const char > valueType2
)
683 : Exceptions::RuntimeError( loc
), expr1_( expr1
), valueType1_( valueType1
), expr2_( expr2
), valueType2_( valueType2
), operatorSymbol_( "< ? >" )
686 Exceptions::BinaryInfixNotApplicable::~BinaryInfixNotApplicable( )
690 Exceptions::BinaryInfixNotApplicable::setOperatorSymbol( const char * operatorSymbol
)
692 operatorSymbol_
= operatorSymbol
;
696 Exceptions::BinaryInfixNotApplicable::display( std::ostream
& os
) const
698 if( expr1_
!= 0 && expr2_
!= 0 )
701 getLoc( ).copy( & os
);
702 os
<< " not defined for (" << valueType1_
<< "," << valueType2_
<< ") at " << expr1_
->loc( ) << ", " << expr2_
->loc( ) << "." << std::endl
;
706 os
<< "Operator " << operatorSymbol_
<< " not defined for (" << valueType1_
<< "," << valueType2_
<< ")." << std::endl
;
711 Exceptions::LookupUnknown::LookupUnknown( const Ast::SourceLocation
& loc
, RefCountPtr
< const char > id
, Type type
)
712 : Exceptions::StaticInconsistency( loc
), id_( id
), type_( type
)
715 Exceptions::LookupUnknown::~LookupUnknown( )
719 Exceptions::LookupUnknown::display( std::ostream
& os
) const
724 os
<< "The variable " << id_
<< " is unbound." << std::endl
;
727 os
<< "There is no state called " << id_
<< " around." << std::endl
;
729 case DYNAMIC_VARIABLE
:
730 os
<< "There is no dynamic variable called " << id_
<< " around." << std::endl
;
733 os
<< "There is no dynamic state called " << id_
<< " around." << std::endl
;
736 os
<< "There is no type called " << id_
<< " around." << std::endl
;
742 Exceptions::StateBeyondFunctionBoundary::StateBeyondFunctionBoundary( const Ast::SourceLocation
& loc
, RefCountPtr
< const char > id
)
743 : Exceptions::StaticInconsistency( loc
), id_( id
)
746 Exceptions::StateBeyondFunctionBoundary::~StateBeyondFunctionBoundary( )
750 Exceptions::StateBeyondFunctionBoundary::display( std::ostream
& os
) const
752 os
<< "The state " << id_
<< " resides outside a function boundary." << std::endl
;
756 Exceptions::IntroducingExistingUnit::IntroducingExistingUnit( const Ast::SourceLocation
& loc
, RefCountPtr
< const char > id
)
757 : Exceptions::StaticInconsistency( loc
), id_( id
)
760 Exceptions::IntroducingExistingUnit::~IntroducingExistingUnit( )
764 Exceptions::IntroducingExistingUnit::display( std::ostream
& os
) const
766 os
<< "Inconsistent definition of the existing unit " << id_
<< "." << std::endl
;
770 Exceptions::LookupUnknownUnit::LookupUnknownUnit( const Ast::SourceLocation
& loc
, RefCountPtr
< const char > id
)
771 : Exceptions::StaticInconsistency( loc
), id_( id
)
774 Exceptions::LookupUnknownUnit::~LookupUnknownUnit( )
778 Exceptions::LookupUnknownUnit::display( std::ostream
& os
) const
780 os
<< "The unit " << id_
<< " is unbound" << std::endl
;
784 Exceptions::OutOfRange::OutOfRange( RefCountPtr
< const char > msg
)
785 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), msg_( msg
.getPtr( ) ), msgMem_( msg
)
788 Exceptions::OutOfRange::OutOfRange( const char * msg
)
789 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), msg_( msg
), msgMem_( NullPtr
< const char >( ) )
792 Exceptions::OutOfRange::OutOfRange( const Ast::SourceLocation
& loc
, RefCountPtr
< const char > msg
)
793 : Exceptions::CatchableError( loc
), msg_( msg
.getPtr( ) ), msgMem_( msg
)
796 Exceptions::OutOfRange::OutOfRange( const Ast::SourceLocation
& loc
, const char * msg
)
797 : Exceptions::CatchableError( loc
), msg_( msg
), msgMem_( NullPtr
< const char >( ) )
800 Exceptions::OutOfRange::~OutOfRange( )
804 Exceptions::OutOfRange::display( std::ostream
& os
) const
806 os
<< "Out-of-range error: " << msg_
<< std::endl
;
809 RefCountPtr
< const Lang::Exception
>
810 Exceptions::OutOfRange::clone( const Kernel::ContRef
& cont
) const
812 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "out_of_range" ) );
813 std::ostringstream os
;
815 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
817 RefCountPtr
< const Lang::String
>( new Lang::String( "(core, generic)", true ) ),
821 this->exitCode( ) ) );
825 Exceptions::FontProblem::FontProblem( const RefCountPtr
< const Lang::Symbol
> & PostScript_name
, RefCountPtr
< const char > msg
, bool justAWarning
)
826 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), PostScript_name_( PostScript_name
), msg_( msg
.getPtr( ) ), msgMem_( msg
), justAWarning_( justAWarning
)
829 Exceptions::FontProblem::FontProblem( const RefCountPtr
< const Lang::Symbol
> & PostScript_name
, const char * msg
, bool justAWarning
)
830 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), PostScript_name_( PostScript_name
), msg_( msg
), msgMem_( NullPtr
< const char >( ) ), justAWarning_( justAWarning
)
833 Exceptions::FontProblem::FontProblem( const RefCountPtr
< const Lang::Symbol
> & PostScript_name
, const Ast::SourceLocation
& loc
, RefCountPtr
< const char > msg
, bool justAWarning
)
834 : Exceptions::CatchableError( loc
), PostScript_name_( PostScript_name
), msg_( msg
.getPtr( ) ), msgMem_( msg
), justAWarning_( justAWarning
)
837 Exceptions::FontProblem::FontProblem( const RefCountPtr
< const Lang::Symbol
> & PostScript_name
, const Ast::SourceLocation
& loc
, const char * msg
, bool justAWarning
)
838 : Exceptions::CatchableError( loc
), PostScript_name_( PostScript_name
), msg_( msg
), msgMem_( NullPtr
< const char >( ) ), justAWarning_( justAWarning
)
841 Exceptions::FontProblem::~FontProblem( )
845 Exceptions::FontProblem::display( std::ostream
& os
) const
847 os
<< "Font " << ( justAWarning_
? "warning" : "error" ) << " using " << PostScript_name_
->name( ) << ": " << msg_
<< std::endl
;
850 RefCountPtr
< const Lang::Exception
>
851 Exceptions::FontProblem::clone( const Kernel::ContRef
& cont
) const
853 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "misc" ) );
854 std::ostringstream os
;
856 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
858 RefCountPtr
< const Lang::String
>( new Lang::String( "(font problem)", true ) ),
862 this->exitCode( ) ) );
866 Exceptions::NonVoidStatement::NonVoidStatement( const Ast::SourceLocation
& loc
, RefCountPtr
< const Lang::Value
> val
)
867 : Exceptions::RuntimeError( loc
), val_( val
)
870 Exceptions::NonVoidStatement::~NonVoidStatement( )
874 Exceptions::NonVoidStatement::display( std::ostream
& os
) const
876 os
<< "No implicit ignore of non-void value (of type " << val_
->getTypeName( ) << ")" << std::endl
;
879 // Exceptions::RuntimeError::RuntimeError( )
880 // : loc_( "< unlocated runtime error >" )
883 Exceptions::RuntimeError::~RuntimeError( )
886 Exceptions::RuntimeError::RuntimeError( const Ast::SourceLocation
& loc
)
890 Exceptions::RuntimeError::RuntimeError( Ast::Expression
* expr
)
891 : loc_( expr
->loc( ) )
894 const Ast::SourceLocation
&
895 Exceptions::RuntimeError::getLoc( ) const
901 Exceptions::CatchableError::CatchableError( const Ast::SourceLocation
& loc
)
902 : Exceptions::RuntimeError( loc
)
905 Exceptions::CatchableError::CatchableError( Ast::Expression
* expr
)
906 : Exceptions::RuntimeError( expr
)
909 Exceptions::CatchableError::~CatchableError( )
913 Exceptions::UncaughtError::UncaughtError( const RefCountPtr
< const Lang::Exception
> & ball
)
914 : Exceptions::RuntimeError( ball
->loc( ) ), ball_( ball
)
917 Exceptions::UncaughtError::~UncaughtError( )
921 Exceptions::UncaughtError::display( std::ostream
& os
) const
923 os
<< "Uncaught error: " ;
928 Interaction::ExitCode
929 Exceptions::UncaughtError::exitCode( ) const
931 return ball_
->exitCode( );
935 Exceptions::UserError::UserError( const RefCountPtr
< const Lang::Symbol
> & kind
, const RefCountPtr
< const Lang::String
> & source
, const RefCountPtr
< const Lang::Value
> & details
, const RefCountPtr
< const char > & message
)
936 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), kind_( kind
), source_( source
), details_( details
), message_( message
)
939 Exceptions::UserError::~UserError( )
943 Exceptions::UserError::display( ostream
& os
) const
947 os
<< " error in " << source_
->val_
<< ": " << message_
<< std::endl
;
950 RefCountPtr
< const Lang::Exception
>
951 Exceptions::UserError::clone( const Kernel::ContRef
& cont
) const
953 std::ostringstream os
;
955 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
961 this->exitCode( ) ) );
965 Exceptions::UserOutOfRange::UserOutOfRange( const RefCountPtr
< const Lang::Symbol
> & kind
, const RefCountPtr
< const Lang::String
> & source
, const RefCountPtr
< const Lang::Integer
> & details
, const RefCountPtr
< const char > & message
)
966 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), kind_( kind
), source_( source
), details_( details
), message_( message
)
969 Exceptions::UserOutOfRange::~UserOutOfRange( )
973 Exceptions::UserOutOfRange::display( ostream
& os
) const
975 os
<< "In " << source_
->val_
<< ", argument " << details_
->val_
976 << ", out-of-range: " << message_
<< std::endl
;
979 RefCountPtr
< const Lang::Exception
>
980 Exceptions::UserOutOfRange::clone( const Kernel::ContRef
& cont
) const
982 std::ostringstream os
;
984 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
990 this->exitCode( ) ) );
994 Exceptions::UserTypeMismatch::UserTypeMismatch( const RefCountPtr
< const Lang::Symbol
> & kind
, const RefCountPtr
< const Lang::String
> & source
, const RefCountPtr
< const Lang::Integer
> & details
, const RefCountPtr
< const char > & expectedType
, const RefCountPtr
< const char > & valueType
)
995 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), kind_( kind
), source_( source
), details_( details
), expectedType_( expectedType
), valueType_( valueType
)
998 Exceptions::UserTypeMismatch::~UserTypeMismatch( )
1002 Exceptions::UserTypeMismatch::display( ostream
& os
) const
1004 os
<< "In " << source_
->val_
<< ", argument " << details_
->val_
1005 << ": expected a " << expectedType_
<< ", got a " << valueType_
<< "." << std::endl
;
1008 RefCountPtr
< const Lang::Exception
>
1009 Exceptions::UserTypeMismatch::clone( const Kernel::ContRef
& cont
) const
1011 std::ostringstream os
;
1013 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
1019 this->exitCode( ) ) );
1023 Exceptions::InternalError::InternalError( const Ast::SourceLocation
& loc
, RefCountPtr
< const char > msg
, bool justAWarning
)
1024 : Exceptions::RuntimeError( loc
), msg_( msg
.getPtr( ) ), msgMem_( msg
), justAWarning_( justAWarning
)
1027 Exceptions::InternalError::InternalError( const Ast::SourceLocation
& loc
, const char * msg
, bool justAWarning
)
1028 : Exceptions::RuntimeError( loc
), msg_( msg
), msgMem_( NullPtr
< const char >( ) ), justAWarning_( justAWarning
)
1031 Exceptions::InternalError::InternalError( RefCountPtr
< const char > msg
, bool justAWarning
)
1032 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), msg_( msg
.getPtr( ) ), msgMem_( msg
), justAWarning_( justAWarning
)
1035 Exceptions::InternalError::InternalError( const char * msg
, bool justAWarning
)
1036 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), msg_( msg
), msgMem_( NullPtr
< const char >( ) ), justAWarning_( justAWarning
)
1039 Exceptions::InternalError::InternalError( const std::ostringstream
& msg
, bool justAWarning
)
1040 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), msg_( strdup( msg
.str( ).c_str( ) ) ), msgMem_( msg_
), justAWarning_( justAWarning
)
1043 Exceptions::InternalError::~InternalError( )
1047 Exceptions::InternalError::display( ostream
& os
) const
1049 os
<< "Internal " << ( justAWarning_
? "warning" : "error" ) << ": " << msg_
<< std::endl
;
1053 Exceptions::ExternalError::ExternalError( RefCountPtr
< const char > msg
, bool justAWarning
)
1054 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), msg_( msg
.getPtr( ) ), msgMem_( msg
), justAWarning_( justAWarning
)
1057 Exceptions::ExternalError::ExternalError( const char * msg
, bool justAWarning
)
1058 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), msg_( msg
), msgMem_( NullPtr
< const char >( ) ), justAWarning_( justAWarning
)
1061 Exceptions::ExternalError::~ExternalError( )
1065 Exceptions::ExternalError::display( ostream
& os
) const
1067 os
<< "External " << ( justAWarning_
? "warning" : "error" ) << ": " << msg_
<< std::endl
;
1070 RefCountPtr
< const Lang::Exception
>
1071 Exceptions::ExternalError::clone( const Kernel::ContRef
& cont
) const
1073 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "external" ) );
1074 std::ostringstream os
;
1076 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
1078 RefCountPtr
< const Lang::String
>( new Lang::String( "(external error)", true ) ),
1082 this->exitCode( ) ) );
1085 Exceptions::ExternalError
*
1086 Exceptions::ExternalError::cloneTyped( ) const
1088 return new Exceptions::ExternalError( msgMem_
);
1091 Exceptions::UserArityMismatch::UserArityMismatch( const Ast::SourceLocation
& callLoc
, const Ast::SourceLocation
& formalsLoc
, size_t functionArity
, size_t callArity
, Type type
)
1092 : Exceptions::RuntimeError( callLoc
), formalsLoc_( formalsLoc
), functionArity_( functionArity
), callArity_( callArity
), type_( type
)
1095 Exceptions::UserArityMismatch::~UserArityMismatch( )
1099 Exceptions::UserArityMismatch::display( std::ostream
& os
) const
1101 os
<< "Function with formals at " << formalsLoc_
<< " expects " << functionArity_
;
1105 os
<< " value arguments" ;
1108 os
<< " state arguments" ;
1111 os
<< ", not " << callArity_
<< std::endl
;
1114 Exceptions::SinkRequired::SinkRequired( const Ast::SourceLocation
& formalsLoc
, size_t formalsArity
, size_t callArity
)
1115 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), formalsLoc_( formalsLoc
), formalsArity_( formalsArity
), callArity_( callArity
)
1118 Exceptions::SinkRequired::~SinkRequired( )
1122 Exceptions::SinkRequired::display( std::ostream
& os
) const
1124 os
<< "Formals at " << formalsLoc_
<< " contains no sink, so passing " << callArity_
<< " ordered arguments is " << callArity_
- formalsArity_
<< " too many." << std::endl
;
1128 Exceptions::NamedFormalMismatch::NamedFormalMismatch( const Ast::SourceLocation
& formalsLoc
, RefCountPtr
< const char > name
, Exceptions::NamedFormalMismatch::Type type
)
1129 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), formalsLoc_( formalsLoc
), name_( name
), type_( type
)
1132 Exceptions::NamedFormalMismatch::~NamedFormalMismatch( )
1136 Exceptions::NamedFormalMismatch::display( std::ostream
& os
) const
1138 os
<< "Function with formals at " << formalsLoc_
<< " has no named ";
1148 os
<< " called " << name_
<< "." << std::endl
;
1152 Exceptions::NamedFormalAlreadySpecified::NamedFormalAlreadySpecified( const Ast::SourceLocation
& formalsLoc
, RefCountPtr
< const char > name
, size_t pos
, Exceptions::NamedFormalAlreadySpecified::Type type
)
1153 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), formalsLoc_( formalsLoc
), name_( name
), pos_( pos
), type_( type
)
1156 Exceptions::NamedFormalAlreadySpecified::~NamedFormalAlreadySpecified( )
1160 Exceptions::NamedFormalAlreadySpecified::display( std::ostream
& os
) const
1162 os
<< "The formal " ;
1172 os
<< " named " << name_
<< ", defined at " << formalsLoc_
<< " is already defined by order, at position " << pos_
<< "." << std::endl
;
1175 Exceptions::MissingArguments::MissingArguments( const Ast::SourceLocation
& callLoc
, const Ast::SourceLocation
& formalsLoc
, std::map
< size_t, RefCountPtr
< const char > > * missingVariables
, std::map
< size_t, RefCountPtr
< const char > > * missingStates
)
1176 : Exceptions::RuntimeError( callLoc
), formalsLoc_( formalsLoc
), missingVariables_( missingVariables
), missingStates_( missingStates
)
1179 Exceptions::MissingArguments::~MissingArguments( )
1183 Exceptions::MissingArguments::display( std::ostream
& os
) const
1185 os
<< "Among the formals at " << formalsLoc_
;
1186 if( missingVariables_
!= NullPtr
< typeof *missingVariables_
>( ) )
1188 os
<< ", the following variables are missing:" ;
1189 typedef typeof *missingVariables_ MapType
;
1190 for( MapType::const_iterator i
= missingVariables_
->begin( ); i
!= missingVariables_
->end( ); ++i
)
1192 if( i
!= missingVariables_
->begin( ) )
1196 os
<< " (" << i
->first
<< ")" << i
->second
.getPtr( ) ;
1199 if( missingStates_
!= NullPtr
< typeof *missingStates_
>( ) )
1202 if( missingVariables_
!= NullPtr
< typeof *missingVariables_
>( ) )
1206 os
<< "the following states are missing:" ;
1207 typedef typeof *missingStates_ MapType
;
1208 for( MapType::const_iterator i
= missingStates_
->begin( ); i
!= missingStates_
->end( ); ++i
)
1210 if( i
!= missingStates_
->begin( ) )
1214 os
<< " (" << i
->first
<< ")" << i
->second
.getPtr( ) ;
1217 os
<< "." << std::endl
;
1221 Exceptions::CoreArityMismatch::CoreArityMismatch( const char * title
, size_t functionArity
, size_t callArity
)
1222 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), title_( title
), titleMem_( NullPtr
< const char >( ) ), functionArityLow_( functionArity
), functionArityHigh_( functionArity
), callArity_( callArity
)
1225 Exceptions::CoreArityMismatch::CoreArityMismatch( const char * title
, size_t functionArityLow
, size_t functionArityHigh
, size_t callArity
)
1226 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), title_( title
), titleMem_( NullPtr
< const char >( ) ), functionArityLow_( functionArityLow
), functionArityHigh_( functionArityHigh
), callArity_( callArity
)
1229 Exceptions::CoreArityMismatch::CoreArityMismatch( const RefCountPtr
< const char > & title
, size_t functionArity
, size_t callArity
)
1230 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), title_( title
.getPtr( ) ), titleMem_( title
), functionArityLow_( functionArity
), functionArityHigh_( functionArity
), callArity_( callArity
)
1233 Exceptions::CoreArityMismatch::CoreArityMismatch( const RefCountPtr
< const char > & title
, size_t functionArityLow
, size_t functionArityHigh
, size_t callArity
)
1234 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), title_( title
.getPtr( ) ), titleMem_( title
), functionArityLow_( functionArityLow
), functionArityHigh_( functionArityHigh
), callArity_( callArity
)
1237 Exceptions::CoreArityMismatch::~CoreArityMismatch( )
1241 Exceptions::CoreArityMismatch::display( std::ostream
& os
) const
1243 if( functionArityLow_
== functionArityHigh_
)
1245 os
<< "Core function " << title_
<< " expects " << functionArityLow_
<< " arguments, not " << callArity_
<< std::endl
;
1249 os
<< "Core function " << title_
<< " expects [" << functionArityLow_
<< ", " << functionArityHigh_
<< "] arguments, not " << callArity_
<< std::endl
;
1254 Exceptions::CoreNoNamedFormals::CoreNoNamedFormals( const char * title
)
1255 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), title_( title
), titleMem_( NullPtr
< const char >( ) )
1258 Exceptions::CoreNoNamedFormals::CoreNoNamedFormals( const RefCountPtr
< const char > & title
)
1259 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), title_( title
.getPtr( ) ), titleMem_( title
)
1262 Exceptions::CoreNoNamedFormals::~CoreNoNamedFormals( )
1266 Exceptions::CoreNoNamedFormals::display( std::ostream
& os
) const
1268 os
<< "Core function " << title_
<< " does not accept named arguments." << std::endl
;
1272 Exceptions::CoreTypeMismatch::CoreTypeMismatch( const Ast::SourceLocation
& callLoc
,
1274 const Ast::SourceLocation
& argLoc
,
1275 RefCountPtr
< const char > valueType
,
1276 RefCountPtr
< const char > expectedType
)
1277 : Exceptions::RuntimeError( callLoc
),
1279 titleMem_( NullPtr
< const char >( ) ),
1281 valueType_( valueType
),
1282 expectedType_( expectedType
)
1285 Exceptions::CoreTypeMismatch::CoreTypeMismatch( const Ast::SourceLocation
& callLoc
,
1286 RefCountPtr
< const char > title
,
1287 const Ast::SourceLocation
& argLoc
,
1288 RefCountPtr
< const char > valueType
,
1289 RefCountPtr
< const char > expectedType
)
1290 : Exceptions::RuntimeError( callLoc
),
1291 title_( title
.getPtr( ) ),
1294 valueType_( valueType
),
1295 expectedType_( expectedType
)
1298 Exceptions::CoreTypeMismatch::CoreTypeMismatch( const Ast::SourceLocation
& callLoc
,
1300 Kernel::Arguments
& args
,
1302 RefCountPtr
< const char > expectedType
)
1303 : Exceptions::RuntimeError( callLoc
),
1305 titleMem_( NullPtr
< const char >( ) ),
1306 argLoc_( args
.getLoc( argNo
) ),
1307 valueType_( args
.getValue( argNo
)->getTypeName( ) ),
1308 expectedType_( expectedType
)
1311 Exceptions::CoreTypeMismatch::CoreTypeMismatch( const Ast::SourceLocation
& callLoc
,
1312 RefCountPtr
< const char > title
,
1313 Kernel::Arguments
& args
,
1315 RefCountPtr
< const char > expectedType
)
1316 : Exceptions::RuntimeError( callLoc
),
1317 title_( title
.getPtr( ) ),
1319 argLoc_( args
.getLoc( argNo
) ),
1320 valueType_( args
.getValue( argNo
)->getTypeName( ) ),
1321 expectedType_( expectedType
)
1324 Exceptions::CoreTypeMismatch::~CoreTypeMismatch( )
1328 Exceptions::CoreTypeMismatch::display( std::ostream
& os
) const
1330 os
<< "Core function " << title_
<< ", argument ";
1331 // if( argName_ != 0 )
1333 // os << "\"" << argName_ << "\" " ;
1335 os
<< "at " << argLoc_
<< ": expected a " << expectedType_
<< ", got a " << valueType_
<< "." << std::endl
;
1339 Exceptions::CoreStateTypeMismatch::CoreStateTypeMismatch( const Ast::SourceLocation
& callLoc
,
1341 const Ast::SourceLocation
& argLoc
,
1342 RefCountPtr
< const char > valueType
,
1343 RefCountPtr
< const char > expectedType
)
1344 : Exceptions::RuntimeError( callLoc
),
1346 titleMem_( NullPtr
< const char >( ) ),
1348 valueType_( valueType
),
1349 expectedType_( expectedType
)
1352 Exceptions::CoreStateTypeMismatch::CoreStateTypeMismatch( const Ast::SourceLocation
& callLoc
,
1353 RefCountPtr
< const char > title
,
1354 const Ast::SourceLocation
& argLoc
,
1355 RefCountPtr
< const char > valueType
,
1356 RefCountPtr
< const char > expectedType
)
1357 : Exceptions::RuntimeError( callLoc
),
1358 title_( title
.getPtr( ) ),
1361 valueType_( valueType
),
1362 expectedType_( expectedType
)
1365 Exceptions::CoreStateTypeMismatch::CoreStateTypeMismatch( const Ast::SourceLocation
& callLoc
,
1367 Kernel::Arguments
& args
,
1369 RefCountPtr
< const char > expectedType
)
1370 : Exceptions::RuntimeError( callLoc
),
1372 titleMem_( NullPtr
< const char >( ) ),
1373 argLoc_( args
.getStateLoc( argNo
) ),
1374 valueType_( args
.getState( argNo
)->getTypeName( ) ),
1375 expectedType_( expectedType
)
1378 Exceptions::CoreStateTypeMismatch::CoreStateTypeMismatch( const Ast::SourceLocation
& callLoc
,
1379 RefCountPtr
< const char > title
,
1380 Kernel::Arguments
& args
,
1382 RefCountPtr
< const char > expectedType
)
1383 : Exceptions::RuntimeError( callLoc
),
1384 title_( title
.getPtr( ) ),
1386 argLoc_( args
.getStateLoc( argNo
) ),
1387 valueType_( args
.getState( argNo
)->getTypeName( ) ),
1388 expectedType_( expectedType
)
1391 Exceptions::CoreStateTypeMismatch::~CoreStateTypeMismatch( )
1395 Exceptions::CoreStateTypeMismatch::display( std::ostream
& os
) const
1397 os
<< "Core function " << title_
<< ", state ";
1398 // if( argName_ != 0 )
1400 // os << "\"" << argName_ << "\" " ;
1402 os
<< "at " << argLoc_
<< ": expected a " << expectedType_
<< ", got a " << valueType_
<< "." << std::endl
;
1406 Exceptions::CoreDynamicTypeMismatch::CoreDynamicTypeMismatch( const Ast::SourceLocation
& callLoc
,
1409 RefCountPtr
< const char > valueType
,
1410 RefCountPtr
< const char > expectedType
)
1411 : Exceptions::RuntimeError( callLoc
),
1413 titleMem_( NullPtr
< const char >( ) ),
1415 idMem_( NullPtr
< const char >( ) ),
1416 valueType_( valueType
),
1417 expectedType_( expectedType
)
1420 Exceptions::CoreDynamicTypeMismatch::~CoreDynamicTypeMismatch( )
1424 Exceptions::CoreDynamicTypeMismatch::display( std::ostream
& os
) const
1426 os
<< "Core function " << title_
<< " encountered a type mismatch in the dynamic variable @" << id_
1427 << ": expected a " << expectedType_
<< ", got a " << valueType_
<< "." << std::endl
;
1430 Exceptions::ContinuationTypeMismatch::ContinuationTypeMismatch( const Kernel::Continuation
* locationCont
,
1431 RefCountPtr
< const char > valueType
,
1432 RefCountPtr
< const char > expectedType
)
1433 : Exceptions::RuntimeError( locationCont
->traceLoc( ) ),
1434 valueType_( valueType
),
1435 expectedType_( expectedType
)
1438 Exceptions::ContinuationTypeMismatch::~ContinuationTypeMismatch( )
1442 Exceptions::ContinuationTypeMismatch::display( std::ostream
& os
) const
1444 os
<< "The continuation expected a " << expectedType_
<< ", got a " << valueType_
<< "." << std::endl
;
1448 Exceptions::CoreOutOfRange::CoreOutOfRange( const Ast::SourceLocation
& callLoc
, const char * title
, Kernel::Arguments
& args
, size_t argNo
, RefCountPtr
< const char > msg
)
1449 : Exceptions::CatchableError( callLoc
), title_( title
), argNo_( argNo
), argLoc_( args
.getLoc( argNo
) ), msg_( msg
.getPtr( ) ), msgMem_( msg
)
1452 Exceptions::CoreOutOfRange::CoreOutOfRange( const Ast::SourceLocation
& callLoc
, const char * title
, Kernel::Arguments
& args
, size_t argNo
, const char * msg
)
1453 : Exceptions::CatchableError( callLoc
), title_( title
), argNo_( argNo
), argLoc_( args
.getLoc( argNo
) ), msg_( msg
), msgMem_( NullPtr
< const char >( ) )
1456 Exceptions::CoreOutOfRange::CoreOutOfRange( const char * title
, Kernel::Arguments
& args
, size_t argNo
, RefCountPtr
< const char > msg
)
1457 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), title_( title
), argNo_( argNo
), argLoc_( args
.getLoc( argNo
) ), msg_( msg
.getPtr( ) ), msgMem_( msg
)
1460 Exceptions::CoreOutOfRange::CoreOutOfRange( const char * title
, Kernel::Arguments
& args
, size_t argNo
, const char * msg
)
1461 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), title_( title
), argNo_( argNo
), argLoc_( args
.getLoc( argNo
) ), msg_( msg
), msgMem_( NullPtr
< const char >( ) )
1464 Exceptions::CoreOutOfRange::~CoreOutOfRange( )
1468 Exceptions::CoreOutOfRange::setMessage( RefCountPtr
< const char > msg
)
1470 msg_
= msg
.getPtr( );
1475 Exceptions::CoreOutOfRange::display( std::ostream
& os
) const
1477 os
<< "Core function " << title_
<< ": " ;
1478 os
<< "Argument at " << argLoc_
<< " is out of range; " << msg_
<< std::endl
;
1481 RefCountPtr
< const Lang::Exception
>
1482 Exceptions::CoreOutOfRange::clone( const Kernel::ContRef
& cont
) const
1484 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "out_of_range" ) );
1485 std::ostringstream os
;
1487 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
1489 RefCountPtr
< const Lang::String
>( new Lang::String( title_
, true ) ),
1490 RefCountPtr
< const Lang::Integer
>( new Lang::Integer( argNo_
) ),
1493 this->exitCode( ) ) );
1496 Exceptions::CoreRequirement::CoreRequirement( RefCountPtr
< const char > msg
, const char * title
, const Ast::SourceLocation
& callLoc
)
1497 : Exceptions::CatchableError( callLoc
), title_( title
), msg_( msg
.getPtr( ) ), msgMem_( msg
)
1500 Exceptions::CoreRequirement::CoreRequirement( const char * msg
, const char * title
, const Ast::SourceLocation
& callLoc
)
1501 : Exceptions::CatchableError( callLoc
), title_( title
), msg_( msg
), msgMem_( NullPtr
< const char >( ) )
1504 Exceptions::CoreRequirement::~CoreRequirement( )
1508 Exceptions::CoreRequirement::display( std::ostream
& os
) const
1510 os
<< "Core function " << title_
<< ": " << msg_
<< std::endl
;
1513 RefCountPtr
< const Lang::Exception
>
1514 Exceptions::CoreRequirement::clone( const Kernel::ContRef
& cont
) const
1516 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "misc" ) );
1517 std::ostringstream os
;
1519 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
1521 RefCountPtr
< const Lang::String
>( new Lang::String( title_
, true ) ),
1525 this->exitCode( ) ) );
1529 Exceptions::BuildRequirement::BuildRequirement( const char * dependency
, const char * title
, const Ast::SourceLocation
& callLoc
)
1530 : Exceptions::CatchableError( callLoc
), title_( title
), dependency_( dependency
)
1533 Exceptions::BuildRequirement::~BuildRequirement( )
1537 Exceptions::BuildRequirement::display( std::ostream
& os
) const
1539 os
<< "Core function stub " << title_
<< ": Shapes was built without " << dependency_
<< ", so this function cannot be called." << std::endl
;
1542 RefCountPtr
< const Lang::Exception
>
1543 Exceptions::BuildRequirement::clone( const Kernel::ContRef
& cont
) const
1545 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "misc" ) );
1546 std::ostringstream os
;
1548 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
1550 RefCountPtr
< const Lang::String
>( new Lang::String( title_
, true ) ),
1554 this->exitCode( ) ) );
1558 Exceptions::TeXLabelError::TeXLabelError( bool quoted
, const char * region
, RefCountPtr
< const char > summary
, RefCountPtr
< const char > details
, const Ast::SourceLocation
& loc
)
1559 : Exceptions::RuntimeError( loc
), strLoc_( loc
), quoted_( quoted
), region_( region
), summary_( summary
), details_( details
)
1562 Exceptions::TeXLabelError::~TeXLabelError( )
1566 Exceptions::TeXLabelError::display( ostream
& os
) const
1570 os
<< "TeX error in " << region_
;
1574 os
<< "Error in TeX " << region_
;
1576 if( ! strLoc_
.isUnknown( ) )
1578 os
<< " at " << strLoc_
;
1591 if( details_
!= NullPtr
< const char >( ) )
1593 Exceptions::prefixEachLine( additionalLinesPrefix
, details_
, os
);
1598 Exceptions::StaticTeXLabelError::StaticTeXLabelError( bool quoted
, const char * region
, RefCountPtr
< const char > summary
, RefCountPtr
< const char > details
, const Ast::SourceLocation
& loc
)
1599 : Exceptions::StaticInconsistency( loc
), quoted_( quoted
), region_( region
), summary_( summary
), details_( details
)
1602 Exceptions::StaticTeXLabelError::~StaticTeXLabelError( )
1606 Exceptions::StaticTeXLabelError::display( ostream
& os
) const
1610 os
<< "TeX error in " << region_
;
1614 os
<< "Error in TeX " << region_
;
1627 if( details_
!= NullPtr
< const char >( ) )
1629 Exceptions::prefixEachLine( additionalLinesPrefix
, details_
, os
);
1634 Exceptions::MultipleDynamicBind::MultipleDynamicBind( const char * id
, const Ast::SourceLocation
& loc
, const Ast::SourceLocation
& prevLoc
)
1635 : Exceptions::RuntimeError( loc
), id_( id
), prevLoc_( prevLoc
)
1638 Exceptions::MultipleDynamicBind::~MultipleDynamicBind( )
1642 Exceptions::MultipleDynamicBind::display( std::ostream
& os
) const
1644 os
<< "This dynamic binding of " << id_
<< " is merged with the conflicting binding at " << prevLoc_
<< "." << std::endl
;
1648 Exceptions::UndefinedEscapeContinuation::UndefinedEscapeContinuation( const char * id
, const Ast::SourceLocation
& loc
)
1649 : Exceptions::RuntimeError( loc
), id_( id
)
1652 Exceptions::UndefinedEscapeContinuation::~UndefinedEscapeContinuation( )
1656 Exceptions::UndefinedEscapeContinuation::display( std::ostream
& os
) const
1658 os
<< "The escape continuation " << id_
<< " was not defined in the dynamic context." << std::endl
;
1662 Exceptions::DeadStateAccess::DeadStateAccess( )
1663 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
)
1666 Exceptions::DeadStateAccess::~DeadStateAccess( )
1670 Exceptions::DeadStateAccess::display( std::ostream
& os
) const
1672 os
<< "Accessing dead state." << std::endl
;
1676 Exceptions::UnFreezable::UnFreezable( )
1677 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
)
1680 Exceptions::UnFreezable::~UnFreezable( )
1684 Exceptions::UnFreezable::display( std::ostream
& os
) const
1686 os
<< "The state cannot be frozen." << std::endl
;
1690 Exceptions::UnPeekable::UnPeekable( )
1691 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
)
1694 Exceptions::UnPeekable::~UnPeekable( )
1698 Exceptions::UnPeekable::display( std::ostream
& os
) const
1700 os
<< "The state cannot be peeked. Consider freezing it." << std::endl
;
1704 Exceptions::UninitializedAccess::UninitializedAccess( )
1705 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
)
1708 Exceptions::UninitializedAccess::~UninitializedAccess( )
1712 Exceptions::UninitializedAccess::display( std::ostream
& os
) const
1714 os
<< "The accessed variable or state has not been initialized yet." << std::endl
;
1718 Exceptions::DtMinError::DtMinError( double dt
)
1719 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), dt_( dt
)
1722 Exceptions::DtMinError::~DtMinError( )
1726 Exceptions::DtMinError::display( std::ostream
& os
) const
1728 os
<< "Path segment too long in relation to arcdelta: dt = " << dt_
<< " < " << Computation::the_dtMin
<< ". Either increase arcdelta, or inhibit this error." << std::endl
;
1731 RefCountPtr
< const Lang::Exception
>
1732 Exceptions::DtMinError::clone( const Kernel::ContRef
& cont
) const
1734 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "dtmin" ) );
1735 std::ostringstream os
;
1737 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
1739 RefCountPtr
< const Lang::String
>( new Lang::String( "(core path computation)", true ) ),
1740 RefCountPtr
< const Lang::Float
>( new Lang::Float( dt_
/ Computation::the_dtMin
) ),
1743 this->exitCode( ) ) );
1747 Exceptions::AffineTransformKillsPlane::AffineTransformKillsPlane( double sigma2
)
1748 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION
), sigma2_( sigma2
)
1751 Exceptions::AffineTransformKillsPlane::~AffineTransformKillsPlane( )
1755 Exceptions::AffineTransformKillsPlane::display( std::ostream
& os
) const
1757 os
<< "When transforming a plane normal, it was found that the affine transform is too singular, with a second largest singular value of " << sigma2_
<< "." << std::endl
;
1760 RefCountPtr
< const Lang::Exception
>
1761 Exceptions::AffineTransformKillsPlane::clone( const Kernel::ContRef
& cont
) const
1763 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "numeric" ) );
1764 std::ostringstream os
;
1766 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
1768 RefCountPtr
< const Lang::String
>( new Lang::String( "(core float triple computation)", true ) ),
1772 this->exitCode( ) ) );
1775 Exceptions::MissingFontMetrics::MissingFontMetrics( RefCountPtr
< const char > fontname
, const std::list
< std::string
> * searchPath
)
1776 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), fontname_( fontname
), searchPath_( searchPath
)
1779 Exceptions::MissingFontMetrics::~MissingFontMetrics( )
1783 Exceptions::MissingFontMetrics::display( std::ostream
& os
) const
1785 os
<< "The font metrics for " << fontname_
<< ", named " << fontname_
<< ".afm, could not be found in {" ;
1786 typedef typeof *searchPath_ ListType
;
1787 for( ListType::const_iterator i
= searchPath_
->begin( ); i
!= searchPath_
->end( ); ++i
)
1791 os
<< " }." << std::endl
;
1795 Exceptions::FontMetricsError::FontMetricsError( const RefCountPtr
< const char > & fontname
, const RefCountPtr
< const char > & message
)
1796 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), fontname_( fontname
), message_( message
)
1799 Exceptions::FontMetricsError::~FontMetricsError( )
1803 Exceptions::FontMetricsError::display( std::ostream
& os
) const
1805 os
<< "There was a problem with the font metrics for " << fontname_
<< ": " << message_
<< std::endl
;
1809 Exceptions::InsertingEmptyPage::InsertingEmptyPage( const Ast::SourceLocation
& loc
)
1810 : Exceptions::CatchableError( loc
)
1813 Exceptions::InsertingEmptyPage::~InsertingEmptyPage( )
1817 Exceptions::InsertingEmptyPage::display( std::ostream
& os
) const
1819 os
<< "Attempt to place empty page in catalog." << std::endl
;
1822 RefCountPtr
< const Lang::Exception
>
1823 Exceptions::InsertingEmptyPage::clone( const Kernel::ContRef
& cont
) const
1825 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "misc" ) );
1826 std::ostringstream os
;
1828 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
1830 RefCountPtr
< const Lang::String
>( new Lang::String( "(core exception)", true ) ),
1834 this->exitCode( ) ) );
1838 Exceptions::InvalidGraphKeyType::InvalidGraphKeyType( )
1839 : Shapes::Exceptions::InternalError( "Graph key was not of type §Symbol or §Integer." )
1842 Exceptions::InvalidGraphKeyType::~InvalidGraphKeyType( )
1845 Exceptions::GraphKeyTypeMismatch::GraphKeyTypeMismatch( const Ast::SourceLocation
& loc
, const char * hint
, RefCountPtr
< const char > valueType
)
1846 : Shapes::Exceptions::TypeMismatch( loc
, hint
, valueType
, expectedType
)
1849 Exceptions::GraphKeyTypeMismatch::~GraphKeyTypeMismatch( )
1852 RefCountPtr
< const char > Exceptions::GraphKeyTypeMismatch::expectedType
= Helpers::typeSetString( Lang::Symbol::staticTypeName( ), Lang::Integer::staticTypeName( ) );
1853 RefCountPtr
< const char > Exceptions::GraphKeyTypeMismatch::expectedTypeOrNode
= Helpers::typeSetString( Lang::Node::staticTypeName( ), Lang::Symbol::staticTypeName( ), Lang::Integer::staticTypeName( ) );
1854 RefCountPtr
< const char > Exceptions::GraphKeyTypeMismatch::expectedTypeOrStructure
= Helpers::typeSetString( Lang::Structure::staticTypeName( ), Lang::Symbol::staticTypeName( ), Lang::Integer::staticTypeName( ) );
1857 Exceptions::InvalidGraphKey::InvalidGraphKey( Type type
)
1858 : Shapes::Exceptions::InternalError( (type
== NODE
) ? "Graph key does not belong to any node in the graph." : "Graph key does not belong to any partition in the graph." )
1861 Exceptions::InvalidGraphKey::~InvalidGraphKey( )
1864 Exceptions::GraphKeyOutOfRange::GraphKeyOutOfRange( Type type
, const Ast::SourceLocation
& callLoc
, const char * title
, Kernel::Arguments
& args
, size_t argNo
)
1865 : Shapes::Exceptions::CoreOutOfRange( callLoc
, title
, args
, argNo
, "" ), type_( type
)
1867 RefCountPtr
< const Lang::Value
> key
= args
.getValue( argNo
);
1868 std::ostringstream oss
;
1872 oss
<< "The node key " ;
1874 oss
<< " does not belong to any node in the graph." ;
1877 oss
<< "The partition key " ;
1879 oss
<< " does not belong to any partition in the graph." ;
1882 setMessage( strrefdup( oss
) );
1885 Exceptions::GraphKeyOutOfRange::~GraphKeyOutOfRange( )
1889 Exceptions::InvalidGraphElement::InvalidGraphElement( Type type
, const Ast::SourceLocation
& loc
)
1890 : Exceptions::CatchableError( loc
), type_( type
)
1893 Exceptions::InvalidGraphElement::~InvalidGraphElement( )
1897 Exceptions::InvalidGraphElement::display( std::ostream
& os
) const
1909 os
<< " does not belong to the graph." << std::endl
;
1912 RefCountPtr
< const Lang::Exception
>
1913 Exceptions::InvalidGraphElement::clone( const Kernel::ContRef
& cont
) const
1915 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "type_mismatch" ) );
1916 std::ostringstream os
;
1918 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
1920 RefCountPtr
< const Lang::String
>( new Lang::String( "(graph operation)", true ) ),
1924 this->exitCode( ) ) );
1927 Exceptions::EdgeTraceError::EdgeTraceError( Type type
, const RefCountPtr
< const Lang::Value
> & edgeKeyFrom
, const RefCountPtr
< const Lang::Value
> & edgeKeyTo
, const RefCountPtr
< const Lang::Value
> & nodeKey
, const Ast::SourceLocation
& loc
)
1928 : Exceptions::CatchableError( loc
), type_( type
), edgeKeyFrom_( edgeKeyFrom
), edgeKeyTo_( edgeKeyTo
), nodeKey_( nodeKey
)
1931 Exceptions::EdgeTraceError::~EdgeTraceError( )
1935 Exceptions::EdgeTraceError::display( std::ostream
& os
) const
1940 os
<< "The undirected edge with node keys " ;
1941 edgeKeyFrom_
->show( os
);
1943 edgeKeyTo_
->show( os
);
1944 os
<< " cannot be traced (or backtraced) from the node with key " ;
1945 nodeKey_
->show( os
);
1946 os
<< "." << std::endl
;
1950 os
<< "The directed edge with source node key " ;
1951 edgeKeyFrom_
->show( os
);
1952 os
<< " and target node key " ;
1953 edgeKeyTo_
->show( os
);
1954 os
<< " cannot be " << ((type_
== TRACE
) ? "traced" : "backtraced") << " from the node with key " ;
1955 nodeKey_
->show( os
);
1956 os
<< "." << std::endl
;
1961 RefCountPtr
< const Lang::Exception
>
1962 Exceptions::EdgeTraceError::clone( const Kernel::ContRef
& cont
) const
1964 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "misc" ) );
1965 std::ostringstream os
;
1967 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
1969 RefCountPtr
< const Lang::String
>( new Lang::String( "(edge tracing)", true ) ),
1973 this->exitCode( ) ) );
1976 Exceptions::GraphDomainError::GraphDomainError( Type type
, bool directed
, const RefCountPtr
< const Lang::Value
> & edgeKeyFrom
, const RefCountPtr
< const Lang::Value
> & edgeKeyTo
, const Ast::SourceLocation
& loc
)
1977 : Exceptions::CatchableError( loc
), type_( type
), directed_( directed
), edgeKeyFrom_( edgeKeyFrom
), edgeKeyTo_( edgeKeyTo
)
1980 Exceptions::GraphDomainError::~GraphDomainError( )
1984 Exceptions::GraphDomainError::display( std::ostream
& os
) const
1987 os
<< "The directed edge from " ;
1988 edgeKeyFrom_
->show( os
);
1990 edgeKeyTo_
->show( os
);
1992 os
<< "The undirected edge between " ;
1993 edgeKeyFrom_
->show( os
);
1995 edgeKeyTo_
->show( os
);
1997 os
<< " is not allowed since the graph domain does not permit " ;
2003 os
<< "undirected" ;
2012 os
<< " edges." << std::endl
;
2015 RefCountPtr
< const Lang::Exception
>
2016 Exceptions::GraphDomainError::clone( const Kernel::ContRef
& cont
) const
2018 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "misc" ) );
2019 std::ostringstream os
;
2021 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
2023 RefCountPtr
< const Lang::String
>( new Lang::String( "(graph domain)", true ) ),
2027 this->exitCode( ) ) );
2031 Exceptions::InvalidGraphPartition::InvalidGraphPartition( const RefCountPtr
< const Lang::Value
> & partition
, const RefCountPtr
< const Lang::SingleList
> & partitions
, const Ast::SourceLocation
& loc
)
2032 : Exceptions::CatchableError( loc
), partition_( partition
), partitions_( partitions
)
2035 Exceptions::InvalidGraphPartition::~InvalidGraphPartition( )
2039 Exceptions::InvalidGraphPartition::display( std::ostream
& os
) const
2041 os
<< "The partition key " ;
2042 partition_
->show( os
);
2043 os
<< " is not among the declared keys: {" ;
2045 typedef const Lang::SingleList ArgType
;
2046 RefCountPtr
< const Lang::SingleListPair
> p
= partitions_
.down_cast
< const Lang::SingleListPair
>( );
2047 while( p
!= NullPtr
< const Lang::SingleListPair
>( ) ){
2048 RefCountPtr
< const Lang::Value
> val
= p
->car_
->getUntyped( );
2051 p
= p
->cdr_
.down_cast
< const Lang::SingleListPair
>( );
2054 os
<< " }." << std::endl
;
2057 RefCountPtr
< const Lang::Exception
>
2058 Exceptions::InvalidGraphPartition::clone( const Kernel::ContRef
& cont
) const
2060 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "misc" ) );
2061 std::ostringstream os
;
2063 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
2065 RefCountPtr
< const Lang::String
>( new Lang::String( "(graph partition)", true ) ),
2069 this->exitCode( ) ) );
2073 Exceptions::GraphPartitionViolation::GraphPartitionViolation( const RefCountPtr
< const Lang::Value
> & sourceKey
, const RefCountPtr
< const Lang::Value
> & targetKey
, const RefCountPtr
< const Lang::Value
> & partition
, const Ast::SourceLocation
& loc
)
2074 : Exceptions::CatchableError( loc
), sourceKey_( sourceKey
), targetKey_( targetKey
), partition_( partition
)
2077 Exceptions::GraphPartitionViolation::~GraphPartitionViolation( )
2081 Exceptions::GraphPartitionViolation::display( std::ostream
& os
) const
2083 os
<< "Edge incident to nodes with keys " ;
2084 sourceKey_
->show( os
);
2086 targetKey_
->show( os
);
2087 os
<< " violates the graph partitioning, with both nodes having the partition key " ;
2088 partition_
->show( os
);
2089 os
<< "." << std::endl
;
2092 RefCountPtr
< const Lang::Exception
>
2093 Exceptions::GraphPartitionViolation::clone( const Kernel::ContRef
& cont
) const
2095 static RefCountPtr
< const Lang::Symbol
> kind( new Lang::Symbol( "misc" ) );
2096 std::ostringstream os
;
2098 return RefCountPtr
< const Lang::Exception
>( new Lang::Exception( this->getLoc( ),
2100 RefCountPtr
< const Lang::String
>( new Lang::String( "(graph partition violation)", true ) ),
2104 this->exitCode( ) ) );
2108 Exceptions::UndefinedCrossRef::UndefinedCrossRef( const Ast::SourceLocation
& loc
, RefCountPtr
< const char > ref
)
2109 : Exceptions::PostCondition( loc
), ref_( ref
)
2112 Exceptions::UndefinedCrossRef::~UndefinedCrossRef( )
2116 Exceptions::UndefinedCrossRef::display( std::ostream
& os
) const
2118 os
<< "The cross reference \"" << ref_
<< "\" is not defined." << std::endl
;
2121 Exceptions::BadSetValueState::BadSetValueState( )
2122 : Exceptions::InternalError( "Setting the value of a variable which is not in the right state." )
2125 Exceptions::BadSetValueState::~BadSetValueState( )
2130 Exceptions::prefixEachLine( const std::string
& prefix
, std::istream
& src
, std::ostream
& dst
)
2133 for( std::getline( src
, line
); ! src
.eof( ); std::getline( src
, line
) )
2135 dst
<< prefix
<< line
<< std::endl
;
2140 Exceptions::prefixEachLine( const std::string
& prefix
, const RefCountPtr
< const char > & src
, std::ostream
& dst
)
2142 std::istringstream
is( src
.getPtr( ) );
2143 Exceptions::prefixEachLine( prefix
, is
, dst
);