Update suitable examples and tests to use blank mode
[shapes.git] / source / shapesexceptions.cc
blob0b72f6e7d7813ce489b39d0f18d41affd1286938
1 /* This file is part of Shapes.
3 * Shapes is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * any later version.
8 * Shapes is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with Shapes. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright 2008, 2009, 2013, 2014 Henrik Tidefelt
19 #include "shapesexceptions.h"
20 #include "ast.h"
21 #include "astclass.h"
22 #include "globals.h"
23 #include "functiontypes.h"
25 using namespace Shapes;
26 using namespace std;
29 const std::string Exceptions::additionalLinesPrefix = "| ";
32 Interaction::MessageString::MessageString( )
33 : msg_( NULL ), msgMem_( NullPtr< const char >( ) )
34 { }
36 Interaction::MessageString::MessageString( const char * msg )
37 : msg_( msg ), msgMem_( NullPtr< const char >( ) )
38 { }
40 Interaction::MessageString::MessageString( const RefCountPtr< const char > & msg )
41 : msg_( msg.getPtr( ) ), msgMem_( msg )
42 { }
44 void
45 Interaction::MessageString::show( std::ostream & os ) const
47 os << msg_ ;
50 void
51 Interaction::MessageString::show( const std::string & eachLinePrefix, std::ostream & os ) const
53 if( null( ) )
54 return;
56 std::istringstream is( msg_ );
57 std::string line;
58 for( std::getline( is, line ); ! is.eof( ); std::getline( is, line ) )
60 os << eachLinePrefix << line << std::endl ;
65 std::ostream &
66 Interaction::operator << ( std::ostream & os, const Interaction::MessageString & self )
68 self.show( os );
69 return os;
73 Exceptions::NotImplemented::NotImplemented( const char * functionality )
74 : functionality_( functionality )
75 { }
77 Exceptions::NotImplemented::~NotImplemented( )
78 { }
80 void
81 Exceptions::NotImplemented::display( std::ostream & os ) const
83 os << "Under construction: " << functionality_ << " is not implemented." << std::endl ;
86 const char * Exceptions::Exception::locsep = ": ";
88 Exceptions::Exception::Exception( )
89 { }
91 Exceptions::Exception::~Exception( )
92 { }
95 Exceptions::MiscellaneousRequirement::MiscellaneousRequirement( const Ast::SourceLocation & loc, const Interaction::MessageString & msg )
96 : Exceptions::CatchableError( loc ), msg_( msg )
97 { }
99 Exceptions::MiscellaneousRequirement::MiscellaneousRequirement( const Interaction::MessageString & msg )
100 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION ), msg_( msg )
103 Exceptions::MiscellaneousRequirement::~MiscellaneousRequirement( )
106 void
107 Exceptions::MiscellaneousRequirement::display( ostream & os ) const
109 os << "Failed to meet requirement: " << msg_ << std::endl ;
112 RefCountPtr< const Lang::Exception >
113 Exceptions::MiscellaneousRequirement::clone( const Kernel::ContRef & cont ) const
115 static RefCountPtr< const Lang::Symbol > kind( new Lang::Symbol( "misc" ) );
116 std::ostringstream os;
117 display( os );
118 return RefCountPtr< const Lang::Exception >( new Lang::Exception( this->getLoc( ),
119 kind,
120 RefCountPtr< const Lang::String >( new Lang::String( "(core, generic)", true ) ),
121 Lang::THE_VOID,
122 strrefdup( os ),
123 cont,
124 this->exitCode( ) ) );
128 Exceptions::HandlerError::HandlerError( const Interaction::MessageString & msg )
129 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION ), msg_( msg )
132 Exceptions::HandlerError::~HandlerError( )
135 void
136 Exceptions::HandlerError::display( ostream & os ) const
138 os << "Error handler message: " << msg_ << std::endl ;
141 RefCountPtr< const Lang::Exception >
142 Exceptions::HandlerError::clone( const Kernel::ContRef & cont ) const
144 static RefCountPtr< const Lang::Symbol > kind( new Lang::Symbol( "misc" ) );
145 std::ostringstream os;
146 display( os );
147 return RefCountPtr< const Lang::Exception >( new Lang::Exception( this->getLoc( ),
148 kind,
149 RefCountPtr< const Lang::String >( new Lang::String( "(default error handler)", true ) ),
150 Lang::THE_VOID,
151 strrefdup( os ),
152 cont,
153 this->exitCode( ) ) );
157 Exceptions::MiscellaneousStaticInconsistency::MiscellaneousStaticInconsistency( const Ast::SourceLocation & loc, const Interaction::MessageString & msg )
158 : Exceptions::StaticInconsistency( loc ), msg_( msg )
161 Exceptions::MiscellaneousStaticInconsistency::~MiscellaneousStaticInconsistency( )
164 void
165 Exceptions::MiscellaneousStaticInconsistency::display( ostream & os ) const
167 os << "Misc error: " << msg_ << std::endl ;
171 Exceptions::NamespaceDirectoryError::NamespaceDirectoryError( const Ast::SourceLocation & loc, const Interaction::MessageString & msg )
172 : Exceptions::StaticInconsistency( loc ), msg_( msg )
175 Exceptions::NamespaceDirectoryError::~NamespaceDirectoryError( )
178 void
179 Exceptions::NamespaceDirectoryError::display( ostream & os ) const
181 os << "Error in namespace directory: " << msg_ << std::endl ;
185 Exceptions::AmbiguousNamespaceDirectory::AmbiguousNamespaceDirectory( const std::string & previousName, const std::string & currentDir )
186 : Exceptions::StaticInconsistency( Ast::THE_UNKNOWN_LOCATION ), previousName_( previousName ), currentDir_( currentDir )
189 Exceptions::AmbiguousNamespaceDirectory::~AmbiguousNamespaceDirectory( )
192 void
193 Exceptions::AmbiguousNamespaceDirectory::display( ostream & os ) const
195 os << "Ambiguous filesystem location of namespace first found at " << previousName_ << ", and later at " << currentDir_ << "." << std::endl ;
199 Exceptions::NamespaceDirectoryLookupError::NamespaceDirectoryLookupError( const Ast::SourceLocation & loc, Type type, const Ast::NamespacePath::const_iterator & nsBegin, const Ast::NamespacePath::const_iterator & nsEnd )
200 : Exceptions::StaticInconsistency( loc ),
201 type_( type )
203 for( Ast::NamespacePath::const_iterator i = nsBegin; i != nsEnd; ++i ){
204 namespacePath_.push_back( *i );
208 Exceptions::NamespaceDirectoryLookupError::NamespaceDirectoryLookupError( Type type, const Ast::NamespacePath::const_iterator & nsBegin, const Ast::NamespacePath::const_iterator & nsEnd )
209 : Exceptions::StaticInconsistency( Ast::THE_UNKNOWN_LOCATION ),
210 type_( type )
212 for( Ast::NamespacePath::const_iterator i = nsBegin; i != nsEnd; ++i ){
213 namespacePath_.push_back( *i );
217 Exceptions::NamespaceDirectoryLookupError::~NamespaceDirectoryLookupError( )
220 void
221 Exceptions::NamespaceDirectoryLookupError::display( ostream & os ) const
223 switch( type_ ){
224 case NOT_FOUND:
225 os << "Unable to locate namespace directory for " ;
226 for( Ast::NamespacePath::const_iterator i = namespacePath_.begin( ); i != namespacePath_.end( ); ++i ){
227 if( ! Ast::SearchContext::isEncapsulationName( *i ) )
228 os << Interaction::NAMESPACE_SEPARATOR << *i ;
230 os << "." << std::endl ;
231 break;
232 case WRONG_TYPE:
233 os << "Encountered non-directory when resolving namespace directory for " ;
234 for( Ast::NamespacePath::const_iterator i = namespacePath_.begin( ); i != namespacePath_.end( ); ++i ){
235 if( ! Ast::SearchContext::isEncapsulationName( *i ) )
236 os << Interaction::NAMESPACE_SEPARATOR << *i ;
238 os << "." << std::endl ;
239 break;
240 case GLOBAL:
241 os << "The global namespace has no corresponding namespace directory." << std::endl ;
242 break;
247 Exceptions::NamespaceDirectoryFileError::NamespaceDirectoryFileError( const Ast::SourceLocation & loc, Type type, const Ast::NamespacePath & namespacePath, const std::string & filename )
248 : Exceptions::StaticInconsistency( loc ),
249 type_( type ),
250 namespacePath_( namespacePath ),
251 filename_( filename )
254 Exceptions::NamespaceDirectoryFileError::NamespaceDirectoryFileError( Type type, const Ast::NamespacePath & namespacePath, const std::string & filename )
255 : Exceptions::StaticInconsistency( Ast::THE_UNKNOWN_LOCATION ),
256 type_( type ),
257 namespacePath_( namespacePath ),
258 filename_( filename )
261 Exceptions::NamespaceDirectoryFileError::~NamespaceDirectoryFileError( )
264 void
265 Exceptions::NamespaceDirectoryFileError::display( ostream & os ) const
267 switch( type_ ){
268 case NOT_FOUND:
269 os << "Could not find " << filename_ << " in the namespace directory of " ;
270 for( Ast::NamespacePath::const_iterator i = namespacePath_.begin( ); i != namespacePath_.end( ); ++i ){
271 if( ! Ast::SearchContext::isEncapsulationName( *i ) )
272 os << Interaction::NAMESPACE_SEPARATOR << *i ;
274 os << "." << std::endl ;
275 break;
276 case WRONG_TYPE:
277 os << "Expected " << filename_ << " to be a Shapes extension file in the namespace directory of " ;
278 for( Ast::NamespacePath::const_iterator i = namespacePath_.begin( ); i != namespacePath_.end( ); ++i ){
279 if( ! Ast::SearchContext::isEncapsulationName( *i ) )
280 os << Interaction::NAMESPACE_SEPARATOR << *i ;
282 os << "." << std::endl ;
283 break;
288 Exceptions::NamespaceDirectoryInvalidEntries::NamespaceDirectoryInvalidEntries( const RefCountPtr< const Ast::NamespacePath > & namespacePath, const std::set< std::string > & invalidEntries )
289 : Exceptions::StaticInconsistency( Ast::THE_UNKNOWN_LOCATION ),
290 namespacePath_( namespacePath ), invalidEntries_( invalidEntries )
293 Exceptions::NamespaceDirectoryInvalidEntries::~NamespaceDirectoryInvalidEntries( )
296 void
297 Exceptions::NamespaceDirectoryInvalidEntries::display( ostream & os ) const
299 os << "Namespace directory of " ;
300 for( Ast::NamespacePath::const_iterator i = namespacePath_->begin( ); i != namespacePath_->end( ); ++i ){
301 if( ! Ast::SearchContext::isEncapsulationName( *i ) )
302 os << Interaction::NAMESPACE_SEPARATOR << *i ;
304 os << " is referring to invalid entries: {" ;
305 typedef typeof invalidEntries_ SetType;
306 for( SetType::const_iterator i = invalidEntries_.begin( ); i != invalidEntries_.end( ); ++i ){
307 os << " " << *i ;
309 os << " }." << std::endl ;
313 Exceptions::NamespaceDirectoryCircularOrdering::NamespaceDirectoryCircularOrdering( const RefCountPtr< const Ast::NamespacePath > & namespacePath, const std::string & cycleEntry )
314 : Exceptions::StaticInconsistency( Ast::THE_UNKNOWN_LOCATION ),
315 namespacePath_( namespacePath ), cycleEntry_( cycleEntry )
318 Exceptions::NamespaceDirectoryCircularOrdering::~NamespaceDirectoryCircularOrdering( )
321 void
322 Exceptions::NamespaceDirectoryCircularOrdering::display( ostream & os ) const
324 os << "Namespace directory has circular order constraints between entries in " ;
325 for( Ast::NamespacePath::const_iterator i = namespacePath_->begin( ); i != namespacePath_->end( ); ++i ){
326 if( ! Ast::SearchContext::isEncapsulationName( *i ) )
327 os << Interaction::NAMESPACE_SEPARATOR << *i ;
329 os << " with " << cycleEntry_ << " appearing on a cycle." << std::endl ;
333 Exceptions::ScannerError::ScannerError( const Ast::SourceLocation & loc, const Interaction::MessageString & msg )
334 : Exceptions::StaticInconsistency( loc ), msg_( msg )
337 Exceptions::ScannerError::~ScannerError( )
340 void
341 Exceptions::ScannerError::display( ostream & os ) const
343 os << "Scanner error: " << msg_ << std::endl ;
347 Exceptions::ParserError::ParserError( const Ast::SourceLocation & loc, const Interaction::MessageString & msg, bool justAWarning )
348 : Exceptions::StaticInconsistency( loc ), msg_( msg ), justAWarning_( justAWarning )
351 Exceptions::ParserError::~ParserError( )
354 void
355 Exceptions::ParserError::display( ostream & os ) const
357 os << "Parser " << ( justAWarning_ ? "warning" : "error" ) << ": " << msg_ << std::endl ;
361 Exceptions::MemberAlsoAbstract::MemberAlsoAbstract( const Ast::SourceLocation & memberLoc, const char * id, const Ast::SourceLocation & abstractLoc )
362 : Exceptions::StaticInconsistency( memberLoc ), id_( id ), abstractLoc_( abstractLoc )
365 Exceptions::MemberAlsoAbstract::~MemberAlsoAbstract( )
368 void
369 Exceptions::MemberAlsoAbstract::display( ostream & os ) const
371 os << "The member " << id_ << " is also declared abstract, at " << abstractLoc_ << "." << std::endl ;
375 Exceptions::MemberAlreadyDeclared::MemberAlreadyDeclared( const Ast::SourceLocation & memberLoc, const char * id, const Ast::SourceLocation & oldLoc )
376 : Exceptions::StaticInconsistency( memberLoc ), id_( id ), oldLoc_( oldLoc )
379 Exceptions::MemberAlreadyDeclared::~MemberAlreadyDeclared( )
382 void
383 Exceptions::MemberAlreadyDeclared::display( ostream & os ) const
385 os << "The member " << id_ << " has already been declared, at " << oldLoc_ << "." << std::endl ;
389 Exceptions::PublicGetSetInNonfinalClass::PublicGetSetInNonfinalClass( const Ast::SourceLocation & memberLoc, const char * id )
390 : Exceptions::StaticInconsistency( memberLoc ), id_( id )
393 Exceptions::PublicGetSetInNonfinalClass::~PublicGetSetInNonfinalClass( )
396 void
397 Exceptions::PublicGetSetInNonfinalClass::display( ostream & os ) const
399 os << "Only members of final classes may have the public get or set specifier. Member in question: " << id_ << "." << std::endl ;
403 Exceptions::TransformingMemberInNonfinalClass::TransformingMemberInNonfinalClass( const Ast::SourceLocation & memberLoc, const char * id )
404 : Exceptions::StaticInconsistency( memberLoc ), id_( id )
407 Exceptions::TransformingMemberInNonfinalClass::~TransformingMemberInNonfinalClass( )
410 void
411 Exceptions::TransformingMemberInNonfinalClass::display( ostream & os ) const
413 os << "Only members of final classes may have the <transforming> specifier. Member in question: " << id_ << "." << std::endl ;
417 Exceptions::RepeatedFormal::RepeatedFormal( const Ast::SourceLocation & loc, const char * id )
418 : Exceptions::StaticInconsistency( loc ), id_( id )
421 Exceptions::RepeatedFormal::~RepeatedFormal( )
424 void
425 Exceptions::RepeatedFormal::display( ostream & os ) const
427 os << "Repeated formal: " << id_ << std::endl ;
431 Exceptions::StateUninitializedUse::StateUninitializedUse( const Ast::SourceLocation & loc, const Ast::PlacedIdentifier * id, const Ast::Node * decl )
432 : Exceptions::StaticInconsistency( loc ), id_( id ), decl_( decl )
435 Exceptions::StateUninitializedUse::~StateUninitializedUse( )
438 void
439 Exceptions::StateUninitializedUse::display( ostream & os ) const
441 os << "Using state " ;
442 id_->show( os, Ast::Identifier::STATE );
443 os << " before its point of declaration at " << decl_->loc( ) << "." << std::endl ;
447 Exceptions::IllegalFreeStates::IllegalFreeStates( const Ast::SourceLocation & loc, Ast::StateIDSet * freeStates, const char * reason )
448 : Exceptions::StaticInconsistency( loc ), freeStates_( freeStates ), reason_( reason )
451 Exceptions::IllegalFreeStates::~IllegalFreeStates( )
454 void
455 Exceptions::IllegalFreeStates::display( ostream & os ) const
457 os << "Free states are illegal here (" << reason_ << "):" ;
458 typedef typeof *freeStates_ SetType;
459 for( SetType::const_iterator i = freeStates_->begin( ); i != freeStates_->end( ); ++i )
461 os << " " << *i ;
463 os << std::endl ;
467 Exceptions::FreeStateIsAlsoPassed::FreeStateIsAlsoPassed( const Ast::SourceLocation & loc, Ast::StateID stateID )
468 : Exceptions::StaticInconsistency( loc ), stateID_( stateID )
471 Exceptions::FreeStateIsAlsoPassed::~FreeStateIsAlsoPassed( )
474 void
475 Exceptions::FreeStateIsAlsoPassed::display( ostream & os ) const
477 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 ;
481 Exceptions::RepeatedStateArgument::RepeatedStateArgument( const Ast::SourceLocation & loc, const RefCountPtr< Ast::StateIDSet > & passedStates )
482 : Exceptions::StaticInconsistency( loc ), passedStates_( passedStates )
485 Exceptions::RepeatedStateArgument::~RepeatedStateArgument( )
488 void
489 Exceptions::RepeatedStateArgument::display( ostream & os ) const
491 os << "Some of these states are being passed in more than one state argument position:" ;
492 typedef typeof *passedStates_ SetType;
493 for( SetType::const_iterator i = passedStates_->begin( ); i != passedStates_->end( ); ++i )
495 os << " " << *i ;
497 os << std::endl ;
501 Exceptions::PassingStateOut::PassingStateOut( const Ast::SourceLocation & loc, const char * id )
502 : Exceptions::StaticInconsistency( loc ), id_( id )
505 Exceptions::PassingStateOut::~PassingStateOut( )
508 void
509 Exceptions::PassingStateOut::display( std::ostream & os ) const
511 os << "States may not be returned, cannot return state " << id_ << "." << std::endl ;
515 Exceptions::IntroducingExisting::IntroducingExisting( const Ast::SourceLocation & loc, const Ast::PlacedIdentifier & id )
516 : Exceptions::StaticInconsistency( loc ), id_( id )
519 Exceptions::IntroducingExisting::~IntroducingExisting( )
522 void
523 Exceptions::IntroducingExisting::display( std::ostream & os ) const
525 os << "The variable " ;
526 id_.show( os, Ast::Identifier::VARIABLE );
527 os << " is already introduced in this scope." << std::endl ;
531 Exceptions::NamespaceAliasCollision::NamespaceAliasCollision( const Ast::SourceLocation & loc, const Ast::IdentifierTree * tree, const char * name )
532 : Exceptions::StaticInconsistency( loc ), tree_( tree ), name_( name )
535 Exceptions::NamespaceAliasCollision::~NamespaceAliasCollision( )
538 void
539 Exceptions::NamespaceAliasCollision::display( std::ostream & os ) const
541 os << "The introduced namespace alias name " ;
542 tree_->showPath( os );
543 os << Interaction::NAMESPACE_SEPARATOR << name_ << " is already in use." << std::endl ;
547 Exceptions::EncapsulationIntroducingExisting::EncapsulationIntroducingExisting( const Ast::SourceLocation & loc, const char * id )
548 : Exceptions::StaticInconsistency( loc ), id_( id )
551 Exceptions::EncapsulationIntroducingExisting::~EncapsulationIntroducingExisting( )
554 void
555 Exceptions::EncapsulationIntroducingExisting::display( std::ostream & os ) const
557 os << "The identifier " << id_ << " cannot be introduced in the encapsulation namespace since the name is occupied in the surrounding namespace." << std::endl ;
561 Exceptions::EncapsulationNamespaceAliasCollision::EncapsulationNamespaceAliasCollision( const Ast::SourceLocation & loc, const char * id )
562 : Exceptions::StaticInconsistency( loc ), id_( id )
565 Exceptions::EncapsulationNamespaceAliasCollision::~EncapsulationNamespaceAliasCollision( )
568 void
569 Exceptions::EncapsulationNamespaceAliasCollision::display( std::ostream & os ) const
571 os << "The namespace " << id_ << " cannot be introduced in the encapsulation namespace since the name is occupied in the surrounding namespace." << std::endl ;
575 Exceptions::ExpectedImmediate::ExpectedImmediate( const Ast::SourceLocation & loc )
576 : Exceptions::StaticInconsistency( loc )
579 Exceptions::ExpectedImmediate::~ExpectedImmediate( )
582 void
583 Exceptions::ExpectedImmediate::display( std::ostream & os ) const
585 os << "It makes no sense to put a pure expression before the end of a code bracket." << std::endl ;
589 Exceptions::IllegalImperative::IllegalImperative( const Ast::SourceLocation & loc )
590 : Exceptions::StaticInconsistency( loc )
593 Exceptions::IllegalImperative::~IllegalImperative( )
596 void
597 Exceptions::IllegalImperative::display( std::ostream & os ) const
599 os << "Imperative expressions are not allowed here." << std::endl ;
603 Exceptions::FreezingUndefined::FreezingUndefined( const Ast::SourceLocation & loc, const Ast::PlacedIdentifier & id )
604 : Exceptions::StaticInconsistency( loc ), id_( id )
607 Exceptions::FreezingUndefined::~FreezingUndefined( )
610 void
611 Exceptions::FreezingUndefined::display( std::ostream & os ) const
613 os << "Internal error: The state " ;
614 id_.show( os, Ast::Identifier::STATE );
615 os << " 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 ;
619 Exceptions::UndefinedNamespace::UndefinedNamespace( const Ast::SourceLocation & loc, const Ast::NamespaceReference & id )
620 : Exceptions::StaticInconsistency( loc ), id_( id )
623 Exceptions::UndefinedNamespace::~UndefinedNamespace( )
626 void
627 Exceptions::UndefinedNamespace::display( std::ostream & os ) const
629 os << "The namespace reference " ;
630 id_.show( os );
631 os << " is not referring to an existing namespace." << std::endl ;
635 Exceptions::FileReadOpenError::FileReadOpenError( const Ast::SourceLocation & loc, RefCountPtr< const char > filename, const std::string * sourceDir, const std::list< std::string > * searchPath, Type type )
636 : loc_( loc ), filename_( filename ), type_( type ), sourceDir_( sourceDir ), searchPath_( searchPath )
639 Exceptions::FileReadOpenError::~FileReadOpenError( )
642 void
643 Exceptions::FileReadOpenError::display( std::ostream & os ) const
645 switch( type_ )
647 case OPEN:
648 os << loc_ << locsep << "Could not open file: " << filename_ ;
649 break;
650 case STAT:
651 os << loc_ << locsep << "Could not stat() file: " << filename_ ;
652 break;
654 if( searchPath_ != 0 )
656 os << " searching \"" ;
657 typedef typeof *searchPath_ ListType;
658 for( ListType::const_iterator i = searchPath_->begin( ); i != searchPath_->end( ); ++i )
660 if( i != searchPath_->begin( ) )
662 os << ":" ;
664 if( sourceDir_ != 0 && (*i)[0] != '/' )
666 os << *sourceDir_ ;
668 os << *i ;
670 os << "\"" ;
672 os << std::endl ;
676 Exceptions::FileWriteOpenError::FileWriteOpenError( const Ast::SourceLocation & loc, RefCountPtr< const char > filename, const char * purpose )
677 : loc_( loc ), filename_( filename ), purpose_( purpose )
680 Exceptions::FileWriteOpenError::~FileWriteOpenError( )
683 void
684 Exceptions::FileWriteOpenError::display( std::ostream & os ) const
686 os << loc_ << locsep << "Could not open " ;
687 if( purpose_ != 0 )
689 os << purpose_ ;
691 os << " file for write: " << filename_ ;
692 os << std::endl ;
696 Exceptions::TeXSetupTooLate::TeXSetupTooLate( const Ast::SourceLocation & loc )
697 : loc_( loc )
700 Exceptions::TeXSetupTooLate::~TeXSetupTooLate( )
703 void
704 Exceptions::TeXSetupTooLate::display( std::ostream & os ) const
706 os << loc_ << locsep << "It is too late to make modifications to the TeX context." << std::endl ;
710 Exceptions::EmptyFinalPicture::EmptyFinalPicture( )
713 Exceptions::EmptyFinalPicture::~EmptyFinalPicture( )
716 void
717 Exceptions::EmptyFinalPicture::display( std::ostream & os ) const
719 os << "Nothing was ever put in the global " ;
720 Lang::CATALOG_ID.show( os, Ast::Identifier::STATE );
721 os << " or drawn to the global " ;
722 Lang::CANVAS_ID.show( os, Ast::Identifier::STATE );
723 os << "." << std::endl ;
727 Exceptions::TeXSetupHasChanged::TeXSetupHasChanged( )
728 : Shapes::Exceptions::InternalError( "The TeX context check failed while loading fresh labels." )
731 Exceptions::TeXSetupHasChanged::~TeXSetupHasChanged( )
735 Exceptions::TypeMismatch::TypeMismatch( const Ast::SourceLocation & loc, RefCountPtr< const char > valueType, RefCountPtr< const char > expectedType )
736 : Exceptions::RuntimeError( loc ), hint_( 0 ), valueType_( valueType ), expectedType_( expectedType )
739 Exceptions::TypeMismatch::TypeMismatch( const Ast::SourceLocation & loc, const char * hint, RefCountPtr< const char > valueType, RefCountPtr< const char > expectedType )
740 : Exceptions::RuntimeError( loc ), hint_( hint ), valueType_( valueType ), expectedType_( expectedType )
743 Exceptions::TypeMismatch::~TypeMismatch( )
746 void
747 Exceptions::TypeMismatch::display( std::ostream & os ) const
749 if( hint_ != 0 )
751 os << hint_ << ": " ;
753 os << "Expected a " << expectedType_ << ", got a " << valueType_ << "." << std::endl ;
756 Exceptions::ExpectedList::ExpectedList( const Ast::SourceLocation & loc, size_t index, RefCountPtr< const char > nonListType )
757 : Exceptions::RuntimeError( loc ), index_( index ), nonListType_( nonListType )
760 Exceptions::ExpectedList::~ExpectedList( )
763 void
764 Exceptions::ExpectedList::display( std::ostream & os ) const
766 os << "Expected a singly linked list, but encountered a " << nonListType_ << " after " << index_ << " elements." << std::endl ;
769 Exceptions::PDFVersionError::PDFVersionError( SimplePDF::PDF_Version::Version version, SimplePDF::PDF_Version::Version required, const Interaction::MessageString & msg, bool justAWarning )
770 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION ), version_( version ), required_( required ), msg_( msg ), justAWarning_( justAWarning )
773 Exceptions::PDFVersionError::~PDFVersionError( )
776 void
777 Exceptions::PDFVersionError::display( std::ostream & os ) const
779 os << SimplePDF::PDF_Version::toString( required_ ) << " " << ( justAWarning_ ? "warning" : "error" ) << " for target version " << SimplePDF::PDF_Version::toString( version_ ) << ": " << msg_ << std::endl ;
782 RefCountPtr< const Lang::Exception >
783 Exceptions::PDFVersionError::clone( const Kernel::ContRef & cont ) const
785 static RefCountPtr< const Lang::Symbol > kind( new Lang::Symbol( "PDF_version" ) );
786 std::ostringstream os;
787 display( os );
788 return RefCountPtr< const Lang::Exception >( new Lang::Exception( this->getLoc( ),
789 kind,
790 RefCountPtr< const Lang::String >( new Lang::String( "(core PDF backend)", true ) ),
791 Lang::THE_VOID,
792 strrefdup( os ),
793 cont,
794 this->exitCode( ) ) );
798 Exceptions::RedefiningLexical::RedefiningLexical( const Ast::PlacedIdentifier & id )
799 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION ), id_( id )
802 Exceptions::RedefiningLexical::~RedefiningLexical( )
805 void
806 Exceptions::RedefiningLexical::display( std::ostream & os ) const
808 os << "Redefining " ;
809 id_.show( os, Ast::Identifier::VARIABLE );
810 os << std::endl ;
814 Exceptions::RedefiningDynamic::RedefiningDynamic( const Ast::PlacedIdentifier & id )
815 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION ), id_( id )
818 Exceptions::RedefiningDynamic::~RedefiningDynamic( )
821 void
822 Exceptions::RedefiningDynamic::display( std::ostream & os ) const
824 os << "Redefining " ;
825 id_.show( os, Ast::Identifier::DYNAMIC_VARIABLE );
826 os << std::endl ;
830 Exceptions::NonObjectMemberAssignment::NonObjectMemberAssignment( const Ast::SourceLocation & loc, RefCountPtr< const char > valueType )
831 : Exceptions::RuntimeError( loc ), valueType_( valueType )
834 Exceptions::NonObjectMemberAssignment::~NonObjectMemberAssignment( )
837 void
838 Exceptions::NonObjectMemberAssignment::display( std::ostream & os ) const
840 os << "Only object oriented values have fields that can be assigned. This value is of type " << valueType_ << "." << std::endl ;
844 Exceptions::ElementaryWithout::ElementaryWithout( Kind kind, Ref ref, RefCountPtr< const char > valueType )
845 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION ), kind_( kind ), ref_( ref ), valueType_( valueType )
848 Exceptions::ElementaryWithout::~ElementaryWithout( )
851 void
852 Exceptions::ElementaryWithout::display( std::ostream & os ) const
854 os << "This " ;
855 switch( kind_ )
857 case VALUE:
858 os << "value" ;
859 break;
860 case STATE:
861 os << "state" ;
862 break;
864 os << " is of the elementary type " << valueType_ << ", which has no " ;
865 switch( ref_ )
867 case FIELD:
868 os << "fields" ;
869 break;
870 case MUTATOR:
871 os << "mutators" ;
872 break;
874 os << "." << std::endl ;
878 Exceptions::NonExistentPosition::NonExistentPosition( size_t pos, size_t maxPos )
879 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION ), pos_( pos ), maxPos_( maxPos )
882 Exceptions::NonExistentPosition::~NonExistentPosition( )
885 void
886 Exceptions::NonExistentPosition::display( std::ostream & os ) const
888 os << "Referencing field at position " << pos_ << " is an error since the user struct has only " << maxPos_ << " ordered fields." << std::endl ;
892 Exceptions::UnaryPrefixNotApplicable::UnaryPrefixNotApplicable( const Ast::SourceLocation & loc, const Ast::Expression * expr, RefCountPtr< const char > valueType )
893 : Exceptions::RuntimeError( loc ), expr_( expr ), valueType_( valueType ), coreLoc_( new Interaction::CharPtrLocation( "< ? >" ) )
896 Exceptions::UnaryPrefixNotApplicable::~UnaryPrefixNotApplicable( )
899 void
900 Exceptions::UnaryPrefixNotApplicable::setCoreLocation( const RefCountPtr< const Interaction::CoreLocation > & coreLoc )
902 coreLoc_ = coreLoc;
905 void
906 Exceptions::UnaryPrefixNotApplicable::display( std::ostream & os ) const
908 if( expr_ != 0 )
910 os << "Operator " ;
911 getLoc( ).copy( & os );
912 os << " not defined for " << valueType_ << " at " << expr_->loc( ) << "." << std::endl ;
914 else
916 os << "Operator " << coreLoc_ << " not defined for " << valueType_ << "." << std::endl ;
921 Exceptions::UnaryPostfixNotApplicable::UnaryPostfixNotApplicable( const Ast::SourceLocation & loc, const Ast::Expression * expr, RefCountPtr< const char > valueType )
922 : Exceptions::RuntimeError( loc ), expr_( expr ), valueType_( valueType ), coreLoc_( new Interaction::CharPtrLocation( "< ? >" ) )
925 Exceptions::UnaryPostfixNotApplicable::~UnaryPostfixNotApplicable( )
928 void
929 Exceptions::UnaryPostfixNotApplicable::setCoreLocation( const RefCountPtr< const Interaction::CoreLocation > & coreLoc )
931 coreLoc_ = coreLoc;
934 void
935 Exceptions::UnaryPostfixNotApplicable::display( std::ostream & os ) const
937 if( expr_ != 0 )
939 os << "Operator " ;
940 getLoc( ).copy( & os );
941 os << " not defined for " << valueType_ << " at " << expr_->loc( ) << "." << std::endl ;
943 else
945 os << "Operator " << coreLoc_ << " not defined for " << valueType_ << "." << std::endl ;
950 Exceptions::BinaryInfixNotApplicable::BinaryInfixNotApplicable( const Ast::SourceLocation & loc, const Ast::Expression * expr1, RefCountPtr< const char > valueType1, const Ast::Expression * expr2, RefCountPtr< const char > valueType2 )
951 : Exceptions::RuntimeError( loc ), expr1_( expr1 ), valueType1_( valueType1 ), expr2_( expr2 ), valueType2_( valueType2 ), coreLoc_( new Interaction::CharPtrLocation( "< ? >" ) )
954 Exceptions::BinaryInfixNotApplicable::~BinaryInfixNotApplicable( )
957 void
958 Exceptions::BinaryInfixNotApplicable::setCoreLocation( const RefCountPtr< const Interaction::CoreLocation > & coreLoc )
960 coreLoc_ = coreLoc;
963 void
964 Exceptions::BinaryInfixNotApplicable::display( std::ostream & os ) const
966 if( expr1_ != 0 && expr2_ != 0 )
968 os << "Operator " ;
969 getLoc( ).copy( & os );
970 os << " not defined for (" << valueType1_ << "," << valueType2_ << ") at " << expr1_->loc( ) << ", " << expr2_->loc( ) << "." << std::endl ;
972 else
974 os << "Operator " << coreLoc_ << " not defined for (" << valueType1_ << "," << valueType2_ << ")." << std::endl ;
979 Exceptions::LookupUnknown::LookupUnknown( const Ast::SourceLocation & loc, const Ast::Identifier & id, Ast::Identifier::Type type )
980 : Exceptions::StaticInconsistency( loc ), id_( id ), type_( type )
983 Exceptions::LookupUnknown::~LookupUnknown( )
986 void
987 Exceptions::LookupUnknown::display( std::ostream & os ) const
989 switch( type_ )
991 case Ast::Identifier::VARIABLE:
992 os << "The variable " ;
993 id_.show( os, type_ );
994 os << " is unbound." << std::endl ;
995 break;
996 case Ast::Identifier::STATE:
997 os << "There is no state called " ;
998 id_.show( os, type_ );
999 os << " around." << std::endl ;
1000 break;
1001 case Ast::Identifier::DYNAMIC_VARIABLE:
1002 os << "There is no dynamic variable called " ;
1003 id_.show( os, type_ );
1004 os << " around." << std::endl ;
1005 break;
1006 case Ast::Identifier::DYNAMIC_STATE:
1007 os << "There is no dynamic state called " ;
1008 id_.show( os, type_ );
1009 os << " around." << std::endl ;
1010 break;
1011 case Ast::Identifier::TYPE:
1012 os << "There is no type called " ;
1013 id_.show( os, type_ );
1014 os << " around." << std::endl ;
1015 break;
1020 Exceptions::LookupUnknownPrivateAlias::LookupUnknownPrivateAlias( const Ast::SourceLocation & loc, const Ast::PlacedIdentifier & id, Ast::Identifier::Type type )
1021 : Exceptions::StaticInconsistency( loc ), id_( id ), type_( type )
1024 Exceptions::LookupUnknownPrivateAlias::~LookupUnknownPrivateAlias( )
1027 void
1028 Exceptions::LookupUnknownPrivateAlias::display( std::ostream & os ) const
1030 os << "There is no alias of " ;
1031 id_.show( os, type_ );
1032 os << " defined in the private namespace." << std::endl ;
1036 Exceptions::StateBeyondFunctionBoundary::StateBeyondFunctionBoundary( const Ast::SourceLocation & loc, const Ast::Identifier & id )
1037 : Exceptions::StaticInconsistency( loc ), id_( id )
1040 Exceptions::StateBeyondFunctionBoundary::~StateBeyondFunctionBoundary( )
1043 void
1044 Exceptions::StateBeyondFunctionBoundary::display( std::ostream & os ) const
1046 os << "The state " ;
1047 id_.show( os, Ast::Identifier::STATE );
1048 os << " resides outside a function boundary." << std::endl ;
1052 Exceptions::IntroducingExistingUnit::IntroducingExistingUnit( const Ast::SourceLocation & loc, RefCountPtr< const char > id )
1053 : Exceptions::StaticInconsistency( loc ), id_( id )
1056 Exceptions::IntroducingExistingUnit::~IntroducingExistingUnit( )
1059 void
1060 Exceptions::IntroducingExistingUnit::display( std::ostream & os ) const
1062 os << "Inconsistent definition of the existing unit " << id_ << "." << std::endl ;
1066 Exceptions::LookupUnknownUnit::LookupUnknownUnit( const Ast::SourceLocation & loc, RefCountPtr< const char > id )
1067 : Exceptions::StaticInconsistency( loc ), id_( id )
1070 Exceptions::LookupUnknownUnit::~LookupUnknownUnit( )
1073 void
1074 Exceptions::LookupUnknownUnit::display( std::ostream & os ) const
1076 os << "The unit " << id_ << " is unbound" << std::endl ;
1080 Exceptions::OutOfRange::OutOfRange( const Interaction::MessageString & msg )
1081 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION ), msg_( msg )
1084 Exceptions::OutOfRange::OutOfRange( const Ast::SourceLocation & loc, const Interaction::MessageString & msg )
1085 : Exceptions::CatchableError( loc ), msg_( msg )
1088 Exceptions::OutOfRange::~OutOfRange( )
1091 void
1092 Exceptions::OutOfRange::display( std::ostream & os ) const
1094 os << "Out-of-range error: " << msg_ << std::endl ;
1097 RefCountPtr< const Lang::Exception >
1098 Exceptions::OutOfRange::clone( const Kernel::ContRef & cont ) const
1100 static RefCountPtr< const Lang::Symbol > kind( new Lang::Symbol( "out_of_range" ) );
1101 std::ostringstream os;
1102 display( os );
1103 return RefCountPtr< const Lang::Exception >( new Lang::Exception( this->getLoc( ),
1104 kind,
1105 RefCountPtr< const Lang::String >( new Lang::String( "(core, generic)", true ) ),
1106 Lang::THE_VOID,
1107 strrefdup( os ),
1108 cont,
1109 this->exitCode( ) ) );
1113 Exceptions::FontProblem::FontProblem( const RefCountPtr< const Lang::Symbol > & PostScript_name, const Interaction::MessageString & msg, bool justAWarning )
1114 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION ), PostScript_name_( PostScript_name ), msg_( msg ), justAWarning_( justAWarning )
1117 Exceptions::FontProblem::FontProblem( const RefCountPtr< const Lang::Symbol > & PostScript_name, const Ast::SourceLocation & loc, const Interaction::MessageString & msg, bool justAWarning )
1118 : Exceptions::CatchableError( loc ), PostScript_name_( PostScript_name ), msg_( msg ), justAWarning_( justAWarning )
1121 Exceptions::FontProblem::~FontProblem( )
1124 void
1125 Exceptions::FontProblem::display( std::ostream & os ) const
1127 os << "Font " << ( justAWarning_ ? "warning" : "error" ) << " using " << PostScript_name_->name( ) << ": " << msg_ << std::endl ;
1130 RefCountPtr< const Lang::Exception >
1131 Exceptions::FontProblem::clone( const Kernel::ContRef & cont ) const
1133 static RefCountPtr< const Lang::Symbol > kind( new Lang::Symbol( "misc" ) );
1134 std::ostringstream os;
1135 display( os );
1136 return RefCountPtr< const Lang::Exception >( new Lang::Exception( this->getLoc( ),
1137 kind,
1138 RefCountPtr< const Lang::String >( new Lang::String( "(font problem)", true ) ),
1139 Lang::THE_VOID,
1140 strrefdup( os ),
1141 cont,
1142 this->exitCode( ) ) );
1146 Exceptions::NonVoidStatement::NonVoidStatement( const Ast::SourceLocation & loc, RefCountPtr< const Lang::Value > val )
1147 : Exceptions::RuntimeError( loc ), val_( val )
1150 Exceptions::NonVoidStatement::~NonVoidStatement( )
1153 void
1154 Exceptions::NonVoidStatement::display( std::ostream & os ) const
1156 os << "No implicit ignore of non-void value (of type " << val_->getTypeName( ) << ")" << std::endl ;
1159 // Exceptions::RuntimeError::RuntimeError( )
1160 // : loc_( "< unlocated runtime error >" )
1161 // { }
1163 Exceptions::RuntimeError::~RuntimeError( )
1166 Exceptions::RuntimeError::RuntimeError( const Ast::SourceLocation & loc )
1167 : loc_( loc )
1170 Exceptions::RuntimeError::RuntimeError( Ast::Expression * expr )
1171 : loc_( expr->loc( ) )
1174 const Ast::SourceLocation &
1175 Exceptions::RuntimeError::getLoc( ) const
1177 return loc_;
1181 Exceptions::CatchableError::CatchableError( const Ast::SourceLocation & loc )
1182 : Exceptions::RuntimeError( loc )
1185 Exceptions::CatchableError::CatchableError( Ast::Expression * expr )
1186 : Exceptions::RuntimeError( expr )
1189 Exceptions::CatchableError::~CatchableError( )
1193 Exceptions::UncaughtError::UncaughtError( const RefCountPtr< const Lang::Exception > & ball )
1194 : Exceptions::RuntimeError( ball->loc( ) ), ball_( ball )
1197 Exceptions::UncaughtError::~UncaughtError( )
1200 void
1201 Exceptions::UncaughtError::display( std::ostream & os ) const
1203 os << "Uncaught error: " ;
1204 ball_->show( os );
1205 os << std::endl ;
1208 Interaction::ExitCode
1209 Exceptions::UncaughtError::exitCode( ) const
1211 return ball_->exitCode( );
1215 Exceptions::UserError::UserError( const RefCountPtr< const Lang::Symbol > & kind, const RefCountPtr< const Lang::String > & source, const RefCountPtr< const Lang::Value > & details, const Interaction::MessageString & message )
1216 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION ), kind_( kind ), source_( source ), details_( details ), message_( message )
1219 Exceptions::UserError::~UserError( )
1222 void
1223 Exceptions::UserError::display( ostream & os ) const
1225 os << "'" ;
1226 kind_->show( os );
1227 os << " error in " << source_->val_ << ": " << message_ << std::endl ;
1230 RefCountPtr< const Lang::Exception >
1231 Exceptions::UserError::clone( const Kernel::ContRef & cont ) const
1233 std::ostringstream os;
1234 display( os );
1235 return RefCountPtr< const Lang::Exception >( new Lang::Exception( this->getLoc( ),
1236 kind_,
1237 source_,
1238 details_,
1239 strrefdup( os ),
1240 cont,
1241 this->exitCode( ) ) );
1245 Exceptions::UserOutOfRange::UserOutOfRange( const RefCountPtr< const Lang::Symbol > & kind, const RefCountPtr< const Lang::String > & source, const RefCountPtr< const Lang::Integer > & details, const Interaction::MessageString & message )
1246 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION ), kind_( kind ), source_( source ), details_( details ), message_( message )
1249 Exceptions::UserOutOfRange::~UserOutOfRange( )
1252 void
1253 Exceptions::UserOutOfRange::display( ostream & os ) const
1255 os << "In " << source_->val_ << ", argument " << details_->val_
1256 << ", out-of-range: " << message_ << std::endl ;
1259 RefCountPtr< const Lang::Exception >
1260 Exceptions::UserOutOfRange::clone( const Kernel::ContRef & cont ) const
1262 std::ostringstream os;
1263 display( os );
1264 return RefCountPtr< const Lang::Exception >( new Lang::Exception( this->getLoc( ),
1265 kind_,
1266 source_,
1267 details_,
1268 strrefdup( os ),
1269 cont,
1270 this->exitCode( ) ) );
1274 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 )
1275 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION ), kind_( kind ), source_( source ), details_( details ), expectedType_( expectedType ), valueType_( valueType )
1278 Exceptions::UserTypeMismatch::~UserTypeMismatch( )
1281 void
1282 Exceptions::UserTypeMismatch::display( ostream & os ) const
1284 os << "In " << source_->val_ << ", argument " << details_->val_
1285 << ": expected a " << expectedType_ << ", got a " << valueType_ << "." << std::endl ;
1288 RefCountPtr< const Lang::Exception >
1289 Exceptions::UserTypeMismatch::clone( const Kernel::ContRef & cont ) const
1291 std::ostringstream os;
1292 display( os );
1293 return RefCountPtr< const Lang::Exception >( new Lang::Exception( this->getLoc( ),
1294 kind_,
1295 source_,
1296 details_,
1297 strrefdup( os ),
1298 cont,
1299 this->exitCode( ) ) );
1303 Exceptions::InternalError::InternalError( const Ast::SourceLocation & loc, const Interaction::MessageString & msg, bool justAWarning )
1304 : Exceptions::RuntimeError( loc ), msg_( msg ), justAWarning_( justAWarning )
1307 Exceptions::InternalError::InternalError( const Interaction::MessageString & msg, bool justAWarning )
1308 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION ), msg_( msg ), justAWarning_( justAWarning )
1311 Exceptions::InternalError::InternalError( const std::ostringstream & msg, bool justAWarning )
1312 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION ), msg_( strdup( msg.str( ).c_str( ) ) ), justAWarning_( justAWarning )
1315 Exceptions::InternalError::~InternalError( )
1318 void
1319 Exceptions::InternalError::display( ostream & os ) const
1321 os << "Internal " << ( justAWarning_ ? "warning" : "error" ) << ": " << msg_ << std::endl ;
1325 Exceptions::ExternalError::ExternalError( const Interaction::MessageString & msg, bool justAWarning )
1326 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION ), msg_( msg ), justAWarning_( justAWarning )
1329 Exceptions::ExternalError::~ExternalError( )
1332 void
1333 Exceptions::ExternalError::display( ostream & os ) const
1335 os << "External " << ( justAWarning_ ? "warning" : "error" ) << ": " << msg_ << std::endl ;
1338 RefCountPtr< const Lang::Exception >
1339 Exceptions::ExternalError::clone( const Kernel::ContRef & cont ) const
1341 static RefCountPtr< const Lang::Symbol > kind( new Lang::Symbol( "external" ) );
1342 std::ostringstream os;
1343 display( os );
1344 return RefCountPtr< const Lang::Exception >( new Lang::Exception( this->getLoc( ),
1345 kind,
1346 RefCountPtr< const Lang::String >( new Lang::String( "(external error)", true ) ),
1347 Lang::THE_VOID,
1348 strrefdup( os ),
1349 cont,
1350 this->exitCode( ) ) );
1353 Exceptions::ExternalError *
1354 Exceptions::ExternalError::cloneTyped( ) const
1356 return new Exceptions::ExternalError( msg_ );
1360 Exceptions::InternalErrorIn::InternalErrorIn( const Ast::PlacedIdentifier & id, const Interaction::MessageString & msg, bool justAWarning )
1361 : Exceptions::InternalError( Ast::THE_UNKNOWN_LOCATION, msg, justAWarning ), id_( id )
1364 Exceptions::InternalErrorIn::~InternalErrorIn( )
1367 void
1368 Exceptions::InternalErrorIn::display( ostream & os ) const
1370 os << "Internal " << ( justAWarning_ ? "warning" : "error" ) << " in " ;
1371 id_.show( os, Ast::Identifier::VARIABLE );
1372 os << ": " << msg_ << std::endl ;
1376 Exceptions::UserArityMismatch::UserArityMismatch( const Ast::SourceLocation & callLoc, const Ast::SourceLocation & formalsLoc, size_t functionArity, size_t callArity, Type type )
1377 : Exceptions::RuntimeError( callLoc ), formalsLoc_( formalsLoc ), functionArity_( functionArity ), callArity_( callArity ), type_( type )
1380 Exceptions::UserArityMismatch::~UserArityMismatch( )
1383 void
1384 Exceptions::UserArityMismatch::display( std::ostream & os ) const
1386 os << "Function with formals at " << formalsLoc_ << " expects " << functionArity_ ;
1387 switch( type_ )
1389 case VARIABLE:
1390 os << " value arguments" ;
1391 break;
1392 case STATE:
1393 os << " state arguments" ;
1394 break;
1396 os << ", not " << callArity_ << std::endl ;
1399 Exceptions::SinkRequired::SinkRequired( const Ast::SourceLocation & formalsLoc, size_t formalsArity, size_t callArity )
1400 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION ), formalsLoc_( formalsLoc ), formalsArity_( formalsArity ), callArity_( callArity )
1403 Exceptions::SinkRequired::~SinkRequired( )
1406 void
1407 Exceptions::SinkRequired::display( std::ostream & os ) const
1409 os << "Formals at " << formalsLoc_ << " contains no sink, so passing " << callArity_ << " ordered arguments is " << callArity_ - formalsArity_ << " too many." << std::endl ;
1413 Exceptions::NamedFormalMismatch::NamedFormalMismatch( const Ast::SourceLocation & formalsLoc, RefCountPtr< const char > name, Exceptions::NamedFormalMismatch::Type type )
1414 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION ), formalsLoc_( formalsLoc ), name_( name ), type_( type )
1417 Exceptions::NamedFormalMismatch::~NamedFormalMismatch( )
1420 void
1421 Exceptions::NamedFormalMismatch::display( std::ostream & os ) const
1423 os << "Function with formals at " << formalsLoc_ << " has no named ";
1424 switch( type_ )
1426 case VARIABLE:
1427 os << "variable" ;
1428 break;
1429 case STATE:
1430 os << "state" ;
1431 break;
1433 os << " called " << name_ << "." << std::endl ;
1437 Exceptions::NamedFormalAlreadySpecified::NamedFormalAlreadySpecified( const Ast::SourceLocation & formalsLoc, RefCountPtr< const char > name, size_t pos, Exceptions::NamedFormalAlreadySpecified::Type type )
1438 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION ), formalsLoc_( formalsLoc ), name_( name ), pos_( pos ), type_( type )
1441 Exceptions::NamedFormalAlreadySpecified::~NamedFormalAlreadySpecified( )
1444 void
1445 Exceptions::NamedFormalAlreadySpecified::display( std::ostream & os ) const
1447 os << "The formal " ;
1448 switch( type_ )
1450 case VARIABLE:
1451 os << "variable" ;
1452 break;
1453 case STATE:
1454 os << "state" ;
1455 break;
1457 os << " named " << name_ << ", defined at " << formalsLoc_ << " is already defined by order, at position " << pos_ << "." << std::endl ;
1460 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 )
1461 : Exceptions::RuntimeError( callLoc ), formalsLoc_( formalsLoc ), missingVariables_( missingVariables ), missingStates_( missingStates )
1464 Exceptions::MissingArguments::~MissingArguments( )
1467 void
1468 Exceptions::MissingArguments::display( std::ostream & os ) const
1470 os << "Among the formals at " << formalsLoc_ ;
1471 if( missingVariables_ != NullPtr< typeof *missingVariables_ >( ) )
1473 os << ", the following variables are missing:" ;
1474 typedef typeof *missingVariables_ MapType;
1475 for( MapType::const_iterator i = missingVariables_->begin( ); i != missingVariables_->end( ); ++i )
1477 if( i != missingVariables_->begin( ) )
1479 os << "," ;
1481 os << " (" << i->first << ")" << i->second.getPtr( ) ;
1484 if( missingStates_ != NullPtr< typeof *missingStates_ >( ) )
1486 os << ", " ;
1487 if( missingVariables_ != NullPtr< typeof *missingVariables_ >( ) )
1489 os << "and " ;
1491 os << "the following states are missing:" ;
1492 typedef typeof *missingStates_ MapType;
1493 for( MapType::const_iterator i = missingStates_->begin( ); i != missingStates_->end( ); ++i )
1495 if( i != missingStates_->begin( ) )
1497 os << "," ;
1499 os << " (" << i->first << ")" << i->second.getPtr( ) ;
1502 os << "." << std::endl ;
1506 Exceptions::CoreArityMismatch::CoreArityMismatch( const RefCountPtr< const Interaction::CoreLocation > & coreLoc, size_t functionArity, size_t callArity )
1507 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION ), coreLoc_( coreLoc ), functionArityLow_( functionArity ), functionArityHigh_( functionArity ), callArity_( callArity )
1510 Exceptions::CoreArityMismatch::CoreArityMismatch( Interaction::CoreLocation * coreLoc, size_t functionArity, size_t callArity )
1511 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION ), coreLoc_( coreLoc ), functionArityLow_( functionArity ), functionArityHigh_( functionArity ), callArity_( callArity )
1514 Exceptions::CoreArityMismatch::CoreArityMismatch( const RefCountPtr< const Interaction::CoreLocation > & coreLoc, size_t functionArityLow, size_t functionArityHigh, size_t callArity )
1515 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION ), coreLoc_( coreLoc ), functionArityLow_( functionArityLow ), functionArityHigh_( functionArityHigh ), callArity_( callArity )
1518 Exceptions::CoreArityMismatch::CoreArityMismatch( const Ast::PlacedIdentifier & coreId, size_t functionArity, size_t callArity )
1519 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION ), coreLoc_( new Interaction::BoundLocation( coreId ) ), functionArityLow_( functionArity ), functionArityHigh_( functionArity ), callArity_( callArity )
1522 Exceptions::CoreArityMismatch::CoreArityMismatch( const Ast::PlacedIdentifier & coreId, size_t functionArityLow, size_t functionArityHigh, size_t callArity )
1523 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION ), coreLoc_( new Interaction::BoundLocation( coreId ) ), functionArityLow_( functionArityLow ), functionArityHigh_( functionArityHigh ), callArity_( callArity )
1526 Exceptions::CoreArityMismatch::CoreArityMismatch( const char * coreSyntax, size_t functionArity, size_t callArity )
1527 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION ), coreLoc_( new Interaction::CharPtrLocation( coreSyntax ) ), functionArityLow_( functionArity ), functionArityHigh_( functionArity ), callArity_( callArity )
1530 Exceptions::CoreArityMismatch::~CoreArityMismatch( )
1533 void
1534 Exceptions::CoreArityMismatch::display( std::ostream & os ) const
1536 if( functionArityLow_ == functionArityHigh_ ){
1537 os << "Core function " << coreLoc_ << " expects " << functionArityLow_ << " arguments, not " << callArity_ << "." << std::endl ;
1538 }else{
1539 os << "Core function " << coreLoc_ << " expects [" << functionArityLow_ << ", " << functionArityHigh_ << "] arguments, not " << callArity_ << "." << std::endl ;
1544 Exceptions::CoreNoNamedFormals::CoreNoNamedFormals( const char * what )
1545 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION ), what_( what )
1548 Exceptions::CoreNoNamedFormals::~CoreNoNamedFormals( )
1551 void
1552 Exceptions::CoreNoNamedFormals::display( std::ostream & os ) const
1554 os << "The core operation " << what_ << " does not accept named arguments." << std::endl ;
1558 Exceptions::CoreTypeMismatch::CoreTypeMismatch( const Ast::SourceLocation & callLoc,
1559 Interaction::CoreLocation * coreLoc,
1560 const Ast::SourceLocation & argLoc,
1561 RefCountPtr< const char > valueType,
1562 RefCountPtr< const char > expectedType )
1563 : Exceptions::RuntimeError( callLoc ),
1564 coreLoc_( coreLoc ),
1565 argLoc_( argLoc ),
1566 valueType_( valueType ),
1567 expectedType_( expectedType )
1570 Exceptions::CoreTypeMismatch::CoreTypeMismatch( const Ast::SourceLocation & callLoc,
1571 const RefCountPtr< const Interaction::CoreLocation > & coreLoc,
1572 Kernel::Arguments & args,
1573 size_t argNo,
1574 RefCountPtr< const char > expectedType )
1575 : Exceptions::RuntimeError( callLoc ),
1576 coreLoc_( coreLoc ),
1577 argLoc_( args.getLoc( argNo ) ),
1578 valueType_( args.getValue( argNo )->getTypeName( ) ),
1579 expectedType_( expectedType )
1582 Exceptions::CoreTypeMismatch::CoreTypeMismatch( const Ast::SourceLocation & callLoc,
1583 Interaction::CoreLocation * coreLoc,
1584 Kernel::Arguments & args,
1585 size_t argNo,
1586 RefCountPtr< const char > expectedType )
1587 : Exceptions::RuntimeError( callLoc ),
1588 coreLoc_( coreLoc ),
1589 argLoc_( args.getLoc( argNo ) ),
1590 valueType_( args.getValue( argNo )->getTypeName( ) ),
1591 expectedType_( expectedType )
1594 Exceptions::CoreTypeMismatch::CoreTypeMismatch( const Ast::SourceLocation & callLoc,
1595 const Ast::PlacedIdentifier & coreId,
1596 Kernel::Arguments & args,
1597 size_t argNo,
1598 RefCountPtr< const char > expectedType )
1599 : Exceptions::RuntimeError( callLoc ),
1600 coreLoc_( new Interaction::BoundLocation( coreId ) ),
1601 argLoc_( args.getLoc( argNo ) ),
1602 valueType_( args.getValue( argNo )->getTypeName( ) ),
1603 expectedType_( expectedType )
1606 Exceptions::CoreTypeMismatch::~CoreTypeMismatch( )
1609 void
1610 Exceptions::CoreTypeMismatch::display( std::ostream & os ) const
1612 if( dynamic_cast< const Interaction::BoundLocation * >( coreLoc_.getPtr( ) ) != NULL ){
1613 os << "Core function " ;
1614 }else{
1615 /* In this case, title_ shouldn't be a function name, but something else, like
1616 * a piece of syntax or a the name of an internal continuation.
1618 os << "In " ;
1620 os << *coreLoc_ << ", argument " ;
1621 // if( argName_ != 0 )
1622 // {
1623 // os << "\"" << argName_ << "\" " ;
1624 // }
1625 os << "at " << argLoc_ << ": expected a " << expectedType_ << ", got a " << valueType_ << "." << std::endl ;
1629 Exceptions::CoreStateTypeMismatch::CoreStateTypeMismatch( const Ast::SourceLocation & callLoc,
1630 const Ast::PlacedIdentifier & coreId,
1631 const Ast::SourceLocation & argLoc,
1632 RefCountPtr< const char > valueType,
1633 RefCountPtr< const char > expectedType )
1634 : Exceptions::RuntimeError( callLoc ),
1635 coreLoc_( new Interaction::BoundLocation( coreId ) ),
1636 argLoc_( argLoc ),
1637 valueType_( valueType ),
1638 expectedType_( expectedType )
1641 Exceptions::CoreStateTypeMismatch::~CoreStateTypeMismatch( )
1644 void
1645 Exceptions::CoreStateTypeMismatch::display( std::ostream & os ) const
1647 os << "Core function " << *coreLoc_ << ", state " ;
1648 // if( argName_ != 0 )
1649 // {
1650 // os << "\"" << argName_ << "\" " ;
1651 // }
1652 os << "at " << argLoc_ << ": expected a " << expectedType_ << ", got a " << valueType_ << "." << std::endl ;
1656 Exceptions::CoreDynamicTypeMismatch::CoreDynamicTypeMismatch( const Ast::SourceLocation & callLoc,
1657 const Ast::PlacedIdentifier & coreId,
1658 const Ast::PlacedIdentifier & id,
1659 RefCountPtr< const char > valueType,
1660 RefCountPtr< const char > expectedType )
1661 : Exceptions::RuntimeError( callLoc ),
1662 coreLoc_( new Interaction::BoundLocation( coreId ) ),
1663 id_( id ),
1664 valueType_( valueType ),
1665 expectedType_( expectedType )
1668 Exceptions::CoreDynamicTypeMismatch::~CoreDynamicTypeMismatch( )
1671 void
1672 Exceptions::CoreDynamicTypeMismatch::display( std::ostream & os ) const
1674 os << "Core function " << *coreLoc_ << " encountered a type mismatch in the dynamic variable " ;
1675 id_.show( os, Ast::Identifier::DYNAMIC_VARIABLE );
1676 os << ": expected a " << expectedType_ << ", got a " << valueType_ << "." << std::endl ;
1679 Exceptions::ContinuationTypeMismatch::ContinuationTypeMismatch( const Kernel::Continuation * locationCont,
1680 RefCountPtr< const char > valueType,
1681 RefCountPtr< const char > expectedType )
1682 : Exceptions::RuntimeError( locationCont->traceLoc( ) ),
1683 valueType_( valueType ),
1684 expectedType_( expectedType )
1687 Exceptions::ContinuationTypeMismatch::~ContinuationTypeMismatch( )
1690 void
1691 Exceptions::ContinuationTypeMismatch::display( std::ostream & os ) const
1693 os << "The continuation expected a " << expectedType_ << ", got a " << valueType_ << "." << std::endl ;
1697 Exceptions::CoreOutOfRange::CoreOutOfRange( const Ast::SourceLocation & callLoc, const Ast::PlacedIdentifier & coreId, Kernel::Arguments & args, size_t argNo, const Interaction::MessageString & msg )
1698 : Exceptions::CatchableError( callLoc ),
1699 coreLoc_( new Interaction::BoundLocation( coreId ) ),
1700 argNo_( argNo ), argLoc_( args.getLoc( argNo ) ), msg_( msg )
1703 Exceptions::CoreOutOfRange::CoreOutOfRange( const Ast::PlacedIdentifier & coreId, Kernel::Arguments & args, size_t argNo, const Interaction::MessageString & msg )
1704 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION ),
1705 coreLoc_( new Interaction::BoundLocation( coreId ) ),
1706 argNo_( argNo ), argLoc_( args.getLoc( argNo ) ), msg_( msg )
1709 Exceptions::CoreOutOfRange::CoreOutOfRange( const Ast::SourceLocation & callLoc, const RefCountPtr< const Interaction::CoreLocation > & coreLoc, Kernel::Arguments & args, size_t argNo, const Interaction::MessageString & msg )
1710 : Exceptions::CatchableError( callLoc ),
1711 coreLoc_( coreLoc ),
1712 argNo_( argNo ), argLoc_( args.getLoc( argNo ) ), msg_( msg )
1715 Exceptions::CoreOutOfRange::CoreOutOfRange( const RefCountPtr< const Interaction::CoreLocation > & coreLoc, Kernel::Arguments & args, size_t argNo, const Interaction::MessageString & msg )
1716 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION ),
1717 coreLoc_( coreLoc ),
1718 argNo_( argNo ), argLoc_( args.getLoc( argNo ) ), msg_( msg )
1721 Exceptions::CoreOutOfRange::CoreOutOfRange( Interaction::CoreLocation * coreLoc, Kernel::Arguments & args, size_t argNo, const Interaction::MessageString & msg )
1722 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION ),
1723 coreLoc_( coreLoc ),
1724 argNo_( argNo ), argLoc_( args.getLoc( argNo ) ), msg_( msg )
1727 Exceptions::CoreOutOfRange::~CoreOutOfRange( )
1730 void
1731 Exceptions::CoreOutOfRange::setMessage( const Interaction::MessageString & msg )
1733 msg_ = msg;
1736 void
1737 Exceptions::CoreOutOfRange::display( std::ostream & os ) const
1739 os << "Core function " << *coreLoc_ << ": " ;
1740 os << "Argument at " << argLoc_ << " is out of range; " << msg_ << std::endl ;
1743 RefCountPtr< const Lang::Exception >
1744 Exceptions::CoreOutOfRange::clone( const Kernel::ContRef & cont ) const
1746 static RefCountPtr< const Lang::Symbol > kind( new Lang::Symbol( "out_of_range" ) );
1747 std::ostringstream os;
1748 display( os );
1749 std::ostringstream osCoreLoc;
1750 osCoreLoc << *coreLoc_ ;
1751 return RefCountPtr< const Lang::Exception >( new Lang::Exception( this->getLoc( ),
1752 kind,
1753 RefCountPtr< const Lang::String >( new Lang::String( strrefdup( osCoreLoc ) ) ),
1754 RefCountPtr< const Lang::Integer >( new Lang::Integer( argNo_ ) ),
1755 strrefdup( os ),
1756 cont,
1757 this->exitCode( ) ) );
1760 Exceptions::CoreRequirement::CoreRequirement( const Interaction::MessageString & msg, const RefCountPtr< const Interaction::CoreLocation > & coreLoc, const Ast::SourceLocation & callLoc )
1761 : Exceptions::CatchableError( callLoc ),
1762 coreLoc_( coreLoc ),
1763 msg_( msg )
1766 Exceptions::CoreRequirement::CoreRequirement( const Interaction::MessageString & msg, Interaction::CoreLocation * coreLoc, const Ast::SourceLocation & callLoc )
1767 : Exceptions::CatchableError( callLoc ),
1768 coreLoc_( coreLoc ),
1769 msg_( msg )
1772 Exceptions::CoreRequirement::CoreRequirement( const Interaction::MessageString & msg, const Ast::PlacedIdentifier & id, const Ast::SourceLocation & callLoc )
1773 : Exceptions::CatchableError( callLoc ),
1774 coreLoc_( new Interaction::BoundLocation( id ) ),
1775 msg_( msg )
1778 Exceptions::CoreRequirement::~CoreRequirement( )
1781 void
1782 Exceptions::CoreRequirement::display( std::ostream & os ) const
1784 os << "Core function " << coreLoc_ << ": " << msg_ << std::endl ;
1787 RefCountPtr< const Lang::Exception >
1788 Exceptions::CoreRequirement::clone( const Kernel::ContRef & cont ) const
1790 static RefCountPtr< const Lang::Symbol > kind( new Lang::Symbol( "misc" ) );
1791 std::ostringstream os;
1792 display( os );
1793 std::ostringstream osCoreLoc;
1794 osCoreLoc << *coreLoc_ ;
1795 return RefCountPtr< const Lang::Exception >( new Lang::Exception( this->getLoc( ),
1796 kind,
1797 RefCountPtr< const Lang::String >( new Lang::String( strrefdup( osCoreLoc ) ) ),
1798 Lang::THE_VOID,
1799 strrefdup( os ),
1800 cont,
1801 this->exitCode( ) ) );
1805 Exceptions::BuildRequirement::BuildRequirement( const char * dependency, const RefCountPtr< const Interaction::CoreLocation > & coreLoc, const Ast::SourceLocation & callLoc )
1806 : Exceptions::CatchableError( callLoc ),
1807 coreLoc_( coreLoc ),
1808 dependency_( dependency )
1811 Exceptions::BuildRequirement::BuildRequirement( const char * dependency, const Ast::PlacedIdentifier & id, const Ast::SourceLocation & callLoc )
1812 : Exceptions::CatchableError( callLoc ),
1813 coreLoc_( new Interaction::BoundLocation( id ) ),
1814 dependency_( dependency )
1817 Exceptions::BuildRequirement::~BuildRequirement( )
1820 void
1821 Exceptions::BuildRequirement::display( std::ostream & os ) const
1823 os << "Core function stub " << coreLoc_ << ": Shapes was built without " << dependency_ << ", so this function cannot be called." << std::endl ;
1826 RefCountPtr< const Lang::Exception >
1827 Exceptions::BuildRequirement::clone( const Kernel::ContRef & cont ) const
1829 static RefCountPtr< const Lang::Symbol > kind( new Lang::Symbol( "misc" ) );
1830 std::ostringstream os;
1831 display( os );
1832 std::ostringstream osCoreLoc;
1833 osCoreLoc << *coreLoc_ ;
1834 return RefCountPtr< const Lang::Exception >( new Lang::Exception( this->getLoc( ),
1835 kind,
1836 RefCountPtr< const Lang::String >( new Lang::String( strrefdup( osCoreLoc ) ) ),
1837 Lang::THE_VOID,
1838 strrefdup( os ),
1839 cont,
1840 this->exitCode( ) ) );
1844 Exceptions::TeXLabelError::TeXLabelError( bool quoted, const char * region, const Interaction::MessageString & summary, const Interaction::MessageString & details, const Ast::SourceLocation & loc )
1845 : Exceptions::RuntimeError( loc ), strLoc_( loc ), quoted_( quoted ), region_( region ), summary_( summary ), details_( details )
1848 Exceptions::TeXLabelError::~TeXLabelError( )
1851 void
1852 Exceptions::TeXLabelError::display( ostream & os ) const
1854 if( quoted_ )
1856 os << "TeX error in " << region_ ;
1858 else
1860 os << "Error in TeX " << region_ ;
1862 if( ! strLoc_.isUnknown( ) )
1864 os << " at " << strLoc_ ;
1866 os << ": " ;
1867 if( quoted_ )
1869 os << "\"" ;
1871 os << summary_ ;
1872 if( quoted_ )
1874 os << "\"" ;
1876 os << std::endl ;
1877 details_.show( additionalLinesPrefix, os );
1881 Exceptions::StaticTeXLabelError::StaticTeXLabelError( bool quoted, const char * region, const Interaction::MessageString & summary, const Interaction::MessageString & details, const Ast::SourceLocation & loc )
1882 : Exceptions::StaticInconsistency( loc ), quoted_( quoted ), region_( region ), summary_( summary ), details_( details )
1885 Exceptions::StaticTeXLabelError::~StaticTeXLabelError( )
1888 void
1889 Exceptions::StaticTeXLabelError::display( ostream & os ) const
1891 if( quoted_ )
1893 os << "TeX error in " << region_ ;
1895 else
1897 os << "Error in TeX " << region_ ;
1899 os << ": " ;
1900 if( quoted_ )
1902 os << "\"" ;
1904 os << summary_ ;
1905 if( quoted_ )
1907 os << "\"" ;
1909 os << std::endl ;
1910 details_.show( additionalLinesPrefix, os );
1914 Exceptions::MultipleDynamicBind::MultipleDynamicBind( const Ast::PlacedIdentifier * id, const Ast::SourceLocation & loc, const Ast::SourceLocation & prevLoc )
1915 : Exceptions::RuntimeError( loc ), id_( id ), prevLoc_( prevLoc )
1918 Exceptions::MultipleDynamicBind::~MultipleDynamicBind( )
1921 void
1922 Exceptions::MultipleDynamicBind::display( std::ostream & os ) const
1924 os << "This dynamic binding of " ;
1925 id_->show( os, Ast::Identifier::DYNAMIC_VARIABLE );
1926 os << " is merged with the conflicting binding at " << prevLoc_ << "." << std::endl ;
1930 Exceptions::UndefinedEscapeContinuation::UndefinedEscapeContinuation( const char * id, const Ast::SourceLocation & loc )
1931 : Exceptions::RuntimeError( loc ), id_( id )
1934 Exceptions::UndefinedEscapeContinuation::~UndefinedEscapeContinuation( )
1937 void
1938 Exceptions::UndefinedEscapeContinuation::display( std::ostream & os ) const
1940 os << "The escape continuation " << id_ << " was not defined in the dynamic context." << std::endl ;
1944 Exceptions::DeadStateAccess::DeadStateAccess( )
1945 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION )
1948 Exceptions::DeadStateAccess::~DeadStateAccess( )
1951 void
1952 Exceptions::DeadStateAccess::display( std::ostream & os ) const
1954 os << "Accessing dead state." << std::endl ;
1958 Exceptions::UnFreezable::UnFreezable( )
1959 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION )
1962 Exceptions::UnFreezable::~UnFreezable( )
1965 void
1966 Exceptions::UnFreezable::display( std::ostream & os ) const
1968 os << "The state cannot be frozen." << std::endl ;
1972 Exceptions::UnPeekable::UnPeekable( )
1973 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION )
1976 Exceptions::UnPeekable::~UnPeekable( )
1979 void
1980 Exceptions::UnPeekable::display( std::ostream & os ) const
1982 os << "The state cannot be peeked. Consider freezing it." << std::endl ;
1986 Exceptions::UninitializedAccess::UninitializedAccess( )
1987 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION )
1990 Exceptions::UninitializedAccess::~UninitializedAccess( )
1993 void
1994 Exceptions::UninitializedAccess::display( std::ostream & os ) const
1996 os << "The accessed variable or state has not been initialized yet." << std::endl ;
2000 Exceptions::DtMinError::DtMinError( double dt )
2001 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION ), dt_( dt )
2004 Exceptions::DtMinError::~DtMinError( )
2007 void
2008 Exceptions::DtMinError::display( std::ostream & os ) const
2010 os << "Path segment too long in relation to arcdelta: dt = " << dt_ << " < " << Computation::the_dtMin << ". Either increase arcdelta, or inhibit this error." << std::endl ;
2013 RefCountPtr< const Lang::Exception >
2014 Exceptions::DtMinError::clone( const Kernel::ContRef & cont ) const
2016 static RefCountPtr< const Lang::Symbol > kind( new Lang::Symbol( "dtmin" ) );
2017 std::ostringstream os;
2018 display( os );
2019 return RefCountPtr< const Lang::Exception >( new Lang::Exception( this->getLoc( ),
2020 kind,
2021 RefCountPtr< const Lang::String >( new Lang::String( "(core path computation)", true ) ),
2022 RefCountPtr< const Lang::Float >( new Lang::Float( dt_ / Computation::the_dtMin ) ),
2023 strrefdup( os ),
2024 cont,
2025 this->exitCode( ) ) );
2029 Exceptions::AffineTransformKillsPlane::AffineTransformKillsPlane( double sigma2 )
2030 : Exceptions::CatchableError( Ast::THE_UNKNOWN_LOCATION ), sigma2_( sigma2 )
2033 Exceptions::AffineTransformKillsPlane::~AffineTransformKillsPlane( )
2036 void
2037 Exceptions::AffineTransformKillsPlane::display( std::ostream & os ) const
2039 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 ;
2042 RefCountPtr< const Lang::Exception >
2043 Exceptions::AffineTransformKillsPlane::clone( const Kernel::ContRef & cont ) const
2045 static RefCountPtr< const Lang::Symbol > kind( new Lang::Symbol( "numeric" ) );
2046 std::ostringstream os;
2047 display( os );
2048 return RefCountPtr< const Lang::Exception >( new Lang::Exception( this->getLoc( ),
2049 kind,
2050 RefCountPtr< const Lang::String >( new Lang::String( "(core float triple computation)", true ) ),
2051 Lang::THE_VOID,
2052 strrefdup( os ),
2053 cont,
2054 this->exitCode( ) ) );
2057 Exceptions::MissingFontMetrics::MissingFontMetrics( RefCountPtr< const char > fontname, const std::list< std::string > * searchPath )
2058 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION ), fontname_( fontname ), searchPath_( searchPath )
2061 Exceptions::MissingFontMetrics::~MissingFontMetrics( )
2064 void
2065 Exceptions::MissingFontMetrics::display( std::ostream & os ) const
2067 os << "The font metrics for " << fontname_ << ", named " << fontname_ << ".afm, could not be found in {" ;
2068 typedef typeof *searchPath_ ListType;
2069 for( ListType::const_iterator i = searchPath_->begin( ); i != searchPath_->end( ); ++i )
2071 os << " " << *i ;
2073 os << " }." << std::endl ;
2077 Exceptions::FontMetricsError::FontMetricsError( const RefCountPtr< const char > & fontname, const Interaction::MessageString & message )
2078 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION ), fontname_( fontname ), message_( message )
2081 Exceptions::FontMetricsError::~FontMetricsError( )
2084 void
2085 Exceptions::FontMetricsError::display( std::ostream & os ) const
2087 os << "There was a problem with the font metrics for " << fontname_ << ": " << message_ << std::endl ;
2091 Exceptions::InsertingEmptyPage::InsertingEmptyPage( const Ast::SourceLocation & loc )
2092 : Exceptions::CatchableError( loc )
2095 Exceptions::InsertingEmptyPage::~InsertingEmptyPage( )
2098 void
2099 Exceptions::InsertingEmptyPage::display( std::ostream & os ) const
2101 os << "Attempt to place empty page in catalog." << std::endl ;
2104 RefCountPtr< const Lang::Exception >
2105 Exceptions::InsertingEmptyPage::clone( const Kernel::ContRef & cont ) const
2107 static RefCountPtr< const Lang::Symbol > kind( new Lang::Symbol( "misc" ) );
2108 std::ostringstream os;
2109 display( os );
2110 return RefCountPtr< const Lang::Exception >( new Lang::Exception( this->getLoc( ),
2111 kind,
2112 RefCountPtr< const Lang::String >( new Lang::String( "(core exception)", true ) ),
2113 Lang::THE_VOID,
2114 strrefdup( os ),
2115 cont,
2116 this->exitCode( ) ) );
2120 Exceptions::InvalidGraphKeyType::InvalidGraphKeyType( )
2121 : Shapes::Exceptions::InternalError( "Graph key was not of type §Symbol or §Integer." )
2124 Exceptions::InvalidGraphKeyType::~InvalidGraphKeyType( )
2127 Exceptions::GraphKeyTypeMismatch::GraphKeyTypeMismatch( const Ast::SourceLocation & loc, const char * hint, RefCountPtr< const char > valueType )
2128 : Shapes::Exceptions::TypeMismatch( loc, hint, valueType, expectedType )
2131 Exceptions::GraphKeyTypeMismatch::~GraphKeyTypeMismatch( )
2134 RefCountPtr< const char > Exceptions::GraphKeyTypeMismatch::expectedType = Helpers::typeSetString( Lang::Symbol::staticTypeName( ), Lang::Integer::staticTypeName( ) );
2135 RefCountPtr< const char > Exceptions::GraphKeyTypeMismatch::expectedTypeOrNode = Helpers::typeSetString( Lang::Node::staticTypeName( ), Lang::Symbol::staticTypeName( ), Lang::Integer::staticTypeName( ) );
2136 RefCountPtr< const char > Exceptions::GraphKeyTypeMismatch::expectedTypeOrStructure = Helpers::typeSetString( Lang::Structure::staticTypeName( ), Lang::Symbol::staticTypeName( ), Lang::Integer::staticTypeName( ) );
2139 Exceptions::InvalidGraphKey::InvalidGraphKey( Type type )
2140 : 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." )
2143 Exceptions::InvalidGraphKey::~InvalidGraphKey( )
2146 Exceptions::GraphKeyOutOfRange::GraphKeyOutOfRange( Type type, const Ast::SourceLocation & callLoc, const Ast::PlacedIdentifier & coreId, Kernel::Arguments & args, size_t argNo )
2147 : Shapes::Exceptions::CoreOutOfRange( callLoc, coreId, args, argNo, "" ), type_( type )
2149 initMessage( args, argNo );
2152 Exceptions::GraphKeyOutOfRange::GraphKeyOutOfRange( Type type, const Ast::SourceLocation & callLoc, const RefCountPtr< const Interaction::CoreLocation > & coreLoc, Kernel::Arguments & args, size_t argNo )
2153 : Shapes::Exceptions::CoreOutOfRange( callLoc, coreLoc, args, argNo, "" ), type_( type )
2155 initMessage( args, argNo );
2158 void
2159 Exceptions::GraphKeyOutOfRange::initMessage( Kernel::Arguments & args, size_t argNo )
2161 RefCountPtr< const Lang::Value > key = args.getValue( argNo );
2162 std::ostringstream oss;
2163 switch( type_ )
2165 case NODE:
2166 oss << "The node key " ;
2167 key->show( oss );
2168 oss << " does not belong to any node in the graph." ;
2169 break;
2170 case PARTITION:
2171 oss << "The partition key " ;
2172 key->show( oss );
2173 oss << " does not belong to any partition in the graph." ;
2174 break;
2176 setMessage( strrefdup( oss ) );
2179 Exceptions::GraphKeyOutOfRange::~GraphKeyOutOfRange( )
2183 Exceptions::InvalidGraphElement::InvalidGraphElement( Type type, const Ast::SourceLocation & loc )
2184 : Exceptions::CatchableError( loc ), type_( type )
2187 Exceptions::InvalidGraphElement::~InvalidGraphElement( )
2190 void
2191 Exceptions::InvalidGraphElement::display( std::ostream & os ) const
2193 os << "The " ;
2194 switch( type_ )
2196 case NODE:
2197 os << "node" ;
2198 break;
2199 case EDGE:
2200 os << "edge" ;
2201 break;
2203 os << " does not belong to the graph." << std::endl ;
2206 RefCountPtr< const Lang::Exception >
2207 Exceptions::InvalidGraphElement::clone( const Kernel::ContRef & cont ) const
2209 static RefCountPtr< const Lang::Symbol > kind( new Lang::Symbol( "type_mismatch" ) );
2210 std::ostringstream os;
2211 display( os );
2212 return RefCountPtr< const Lang::Exception >( new Lang::Exception( this->getLoc( ),
2213 kind,
2214 RefCountPtr< const Lang::String >( new Lang::String( "(graph operation)", true ) ),
2215 Lang::THE_VOID,
2216 strrefdup( os ),
2217 cont,
2218 this->exitCode( ) ) );
2221 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 )
2222 : Exceptions::CatchableError( loc ), type_( type ), edgeKeyFrom_( edgeKeyFrom ), edgeKeyTo_( edgeKeyTo ), nodeKey_( nodeKey )
2225 Exceptions::EdgeTraceError::~EdgeTraceError( )
2228 void
2229 Exceptions::EdgeTraceError::display( std::ostream & os ) const
2231 switch( type_ )
2233 case UNDIRECTED:
2234 os << "The undirected edge with node keys " ;
2235 edgeKeyFrom_->show( os );
2236 os << " and " ;
2237 edgeKeyTo_->show( os );
2238 os << " cannot be traced (or backtraced) from the node with key " ;
2239 nodeKey_->show( os );
2240 os << "." << std::endl ;
2241 break;
2242 case TRACE:
2243 case BACKTRACE:
2244 os << "The directed edge with source node key " ;
2245 edgeKeyFrom_->show( os );
2246 os << " and target node key " ;
2247 edgeKeyTo_->show( os );
2248 os << " cannot be " << ((type_ == TRACE) ? "traced" : "backtraced") << " from the node with key " ;
2249 nodeKey_->show( os );
2250 os << "." << std::endl ;
2251 break;
2255 RefCountPtr< const Lang::Exception >
2256 Exceptions::EdgeTraceError::clone( const Kernel::ContRef & cont ) const
2258 static RefCountPtr< const Lang::Symbol > kind( new Lang::Symbol( "misc" ) );
2259 std::ostringstream os;
2260 display( os );
2261 return RefCountPtr< const Lang::Exception >( new Lang::Exception( this->getLoc( ),
2262 kind,
2263 RefCountPtr< const Lang::String >( new Lang::String( "(edge tracing)", true ) ),
2264 Lang::THE_VOID,
2265 strrefdup( os ),
2266 cont,
2267 this->exitCode( ) ) );
2270 Exceptions::GraphDomainError::GraphDomainError( Type type, bool directed, const RefCountPtr< const Lang::Value > & edgeKeyFrom, const RefCountPtr< const Lang::Value > & edgeKeyTo, const Ast::SourceLocation & loc )
2271 : Exceptions::CatchableError( loc ), type_( type ), directed_( directed ), edgeKeyFrom_( edgeKeyFrom ), edgeKeyTo_( edgeKeyTo )
2274 Exceptions::GraphDomainError::~GraphDomainError( )
2277 void
2278 Exceptions::GraphDomainError::display( std::ostream & os ) const
2280 if( directed_ ){
2281 os << "The directed edge from " ;
2282 edgeKeyFrom_->show( os );
2283 os << " to " ;
2284 edgeKeyTo_->show( os );
2285 }else{
2286 os << "The undirected edge between " ;
2287 edgeKeyFrom_->show( os );
2288 os << " and " ;
2289 edgeKeyTo_->show( os );
2291 os << " is not allowed since the graph domain does not permit " ;
2292 switch( type_ ){
2293 case DIRECTED:
2294 os << "directed" ;
2295 break;
2296 case UNDIRECTED:
2297 os << "undirected" ;
2298 break;
2299 case LOOPS:
2300 os << "loop" ;
2301 break;
2302 case PARALLEL:
2303 os << "parallel" ;
2304 break;
2306 os << " edges." << std::endl ;
2309 RefCountPtr< const Lang::Exception >
2310 Exceptions::GraphDomainError::clone( const Kernel::ContRef & cont ) const
2312 static RefCountPtr< const Lang::Symbol > kind( new Lang::Symbol( "misc" ) );
2313 std::ostringstream os;
2314 display( os );
2315 return RefCountPtr< const Lang::Exception >( new Lang::Exception( this->getLoc( ),
2316 kind,
2317 RefCountPtr< const Lang::String >( new Lang::String( "(graph domain)", true ) ),
2318 Lang::THE_VOID,
2319 strrefdup( os ),
2320 cont,
2321 this->exitCode( ) ) );
2325 Exceptions::InvalidGraphPartition::InvalidGraphPartition( const RefCountPtr< const Lang::Value > & partition, const RefCountPtr< const Lang::SingleList > & partitions, const Ast::SourceLocation & loc )
2326 : Exceptions::CatchableError( loc ), partition_( partition ), partitions_( partitions )
2329 Exceptions::InvalidGraphPartition::~InvalidGraphPartition( )
2332 void
2333 Exceptions::InvalidGraphPartition::display( std::ostream & os ) const
2335 os << "The partition key " ;
2336 partition_->show( os );
2337 os << " is not among the declared keys: {" ;
2339 RefCountPtr< const Lang::SingleListPair > p = partitions_.down_cast< const Lang::SingleListPair >( );
2340 while( p != NullPtr< const Lang::SingleListPair >( ) ){
2341 RefCountPtr< const Lang::Value > val = p->car_->getUntyped( );
2342 os << " " ;
2343 val->show( os );
2344 p = p->cdr_.down_cast< const Lang::SingleListPair >( );
2347 os << " }." << std::endl ;
2350 RefCountPtr< const Lang::Exception >
2351 Exceptions::InvalidGraphPartition::clone( const Kernel::ContRef & cont ) const
2353 static RefCountPtr< const Lang::Symbol > kind( new Lang::Symbol( "misc" ) );
2354 std::ostringstream os;
2355 display( os );
2356 return RefCountPtr< const Lang::Exception >( new Lang::Exception( this->getLoc( ),
2357 kind,
2358 RefCountPtr< const Lang::String >( new Lang::String( "(graph partition)", true ) ),
2359 Lang::THE_VOID,
2360 strrefdup( os ),
2361 cont,
2362 this->exitCode( ) ) );
2366 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 )
2367 : Exceptions::CatchableError( loc ), sourceKey_( sourceKey ), targetKey_( targetKey ), partition_( partition )
2370 Exceptions::GraphPartitionViolation::~GraphPartitionViolation( )
2373 void
2374 Exceptions::GraphPartitionViolation::display( std::ostream & os ) const
2376 os << "Edge incident to nodes with keys " ;
2377 sourceKey_->show( os );
2378 os << " and " ;
2379 targetKey_->show( os );
2380 os << " violates the graph partitioning, with both nodes having the partition key " ;
2381 partition_->show( os );
2382 os << "." << std::endl ;
2385 RefCountPtr< const Lang::Exception >
2386 Exceptions::GraphPartitionViolation::clone( const Kernel::ContRef & cont ) const
2388 static RefCountPtr< const Lang::Symbol > kind( new Lang::Symbol( "misc" ) );
2389 std::ostringstream os;
2390 display( os );
2391 return RefCountPtr< const Lang::Exception >( new Lang::Exception( this->getLoc( ),
2392 kind,
2393 RefCountPtr< const Lang::String >( new Lang::String( "(graph partition violation)", true ) ),
2394 Lang::THE_VOID,
2395 strrefdup( os ),
2396 cont,
2397 this->exitCode( ) ) );
2401 Exceptions::UndefinedCrossRef::UndefinedCrossRef( const Ast::SourceLocation & loc, RefCountPtr< const char > ref )
2402 : Exceptions::PostCondition( loc ), ref_( ref )
2405 Exceptions::UndefinedCrossRef::~UndefinedCrossRef( )
2408 void
2409 Exceptions::UndefinedCrossRef::display( std::ostream & os ) const
2411 os << "The cross reference \"" << ref_ << "\" is not defined." << std::endl ;
2414 Exceptions::BadSetValueState::BadSetValueState( )
2415 : Exceptions::InternalError( "Setting the value of a variable which is not in the right state." )
2418 Exceptions::BadSetValueState::~BadSetValueState( )
2422 Exceptions::InvocationError::InvocationError( const Interaction::MessageString & msg, bool justAWarning )
2423 : msg_( msg ), justAWarning_( justAWarning )
2426 Exceptions::InvocationError::~InvocationError( )
2429 void
2430 Exceptions::InvocationError::display( std::ostream & os ) const
2432 os << "Invocation " << ( justAWarning_ ? "warning" : "error" ) << ": " << msg_ << std::endl ;