1 /* This file is part of Shapes.
3 * Shapes is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
8 * Shapes is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with Shapes. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright 2008 Henrik Tidefelt
19 #include "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( RefCountPtr
< const char > msg
)
62 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), msg_( msg
.getPtr( ) ), msgMem_( msg
)
65 Exceptions::MiscellaneousRequirement::MiscellaneousRequirement( const char * msg
)
66 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), msg_( msg
), msgMem_( NullPtr
< const char >( ) )
69 Exceptions::MiscellaneousRequirement::~MiscellaneousRequirement( )
73 Exceptions::MiscellaneousRequirement::display( ostream
& os
) const
75 os
<< "Failed to meet requirement: " << msg_
<< std::endl
;
79 Exceptions::HandlerError::HandlerError( RefCountPtr
< const char > _msg
)
80 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), msg( _msg
)
83 Exceptions::HandlerError::HandlerError( const char * _msg
)
84 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), msg( strrefdup( _msg
) )
87 Exceptions::HandlerError::~HandlerError( )
91 Exceptions::HandlerError::display( ostream
& os
) const
93 os
<< "Error handler message: " << msg
<< std::endl
;
97 Exceptions::ScannerError::ScannerError( const Ast::SourceLocation
& loc
, RefCountPtr
< const char > _msg
)
98 : Exceptions::StaticInconsistency( loc
), msg( _msg
)
101 Exceptions::ScannerError::~ScannerError( )
105 Exceptions::ScannerError::display( ostream
& os
) const
107 os
<< "Scanner error: " << msg
<< std::endl
;
111 Exceptions::ParserError::ParserError( const Ast::SourceLocation
& loc
, RefCountPtr
< const char > _msg
)
112 : Exceptions::StaticInconsistency( loc
), msg( _msg
)
115 Exceptions::ParserError::~ParserError( )
119 Exceptions::ParserError::display( ostream
& os
) const
121 os
<< "Parser error: " << msg
<< std::endl
;
125 Exceptions::MemberAlsoAbstract::MemberAlsoAbstract( const Ast::SourceLocation
& _memberLoc
, const char * _id
, const Ast::SourceLocation
& _abstractLoc
)
126 : Exceptions::StaticInconsistency( _memberLoc
), memberLoc( _memberLoc
), id( _id
), abstractLoc( _abstractLoc
)
129 Exceptions::MemberAlsoAbstract::~MemberAlsoAbstract( )
133 Exceptions::MemberAlsoAbstract::display( ostream
& os
) const
135 os
<< "The member " << id
<< " is also declared abstract, at " << abstractLoc
<< "." << std::endl
;
139 Exceptions::MemberAlreadyDeclared::MemberAlreadyDeclared( const Ast::SourceLocation
& _memberLoc
, const char * _id
, const Ast::SourceLocation
& _oldLoc
)
140 : Exceptions::StaticInconsistency( _memberLoc
), memberLoc( _memberLoc
), id( _id
), oldLoc( _oldLoc
)
143 Exceptions::MemberAlreadyDeclared::~MemberAlreadyDeclared( )
147 Exceptions::MemberAlreadyDeclared::display( ostream
& os
) const
149 os
<< "The member " << id
<< " has already been declared, at " << oldLoc
<< "." << std::endl
;
153 Exceptions::PublicGetSetInNonfinalClass::PublicGetSetInNonfinalClass( const Ast::SourceLocation
& _memberLoc
, const char * _id
)
154 : Exceptions::StaticInconsistency( _memberLoc
), memberLoc( _memberLoc
), id( _id
)
157 Exceptions::PublicGetSetInNonfinalClass::~PublicGetSetInNonfinalClass( )
161 Exceptions::PublicGetSetInNonfinalClass::display( ostream
& os
) const
163 os
<< "Only members of final classes may have the public get or set specifier. Member in question: " << id
<< "." << std::endl
;
167 Exceptions::TransformingMemberInNonfinalClass::TransformingMemberInNonfinalClass( const Ast::SourceLocation
& _memberLoc
, const char * _id
)
168 : Exceptions::StaticInconsistency( _memberLoc
), memberLoc( _memberLoc
), id( _id
)
171 Exceptions::TransformingMemberInNonfinalClass::~TransformingMemberInNonfinalClass( )
175 Exceptions::TransformingMemberInNonfinalClass::display( ostream
& os
) const
177 os
<< "Only members of final classes may have the <transforming> specifier. Member in question: " << id
<< "." << std::endl
;
181 Exceptions::RepeatedFormal::RepeatedFormal( const Ast::SourceLocation
& loc
, const char * _id
)
182 : Exceptions::StaticInconsistency( loc
), id( _id
)
185 Exceptions::RepeatedFormal::~RepeatedFormal( )
189 Exceptions::RepeatedFormal::display( ostream
& os
) const
191 os
<< "Repeated formal: " << id
<< std::endl
;
195 Exceptions::IllegalFreeStates::IllegalFreeStates( const Ast::SourceLocation
& loc
, Ast::StateIDSet
* freeStates
, const char * reason
)
196 : Exceptions::StaticInconsistency( loc
), freeStates_( freeStates
), reason_( reason
)
199 Exceptions::IllegalFreeStates::~IllegalFreeStates( )
203 Exceptions::IllegalFreeStates::display( ostream
& os
) const
205 os
<< "Free states are illegal here (" << reason_
<< "):" ;
206 typedef typeof *freeStates_ SetType
;
207 for( SetType::const_iterator i
= freeStates_
->begin( ); i
!= freeStates_
->end( ); ++i
)
215 Exceptions::FreeStateIsAlsoPassed::FreeStateIsAlsoPassed( const Ast::SourceLocation
& loc
, Ast::StateID stateID
)
216 : Exceptions::StaticInconsistency( loc
), stateID_( stateID
)
219 Exceptions::FreeStateIsAlsoPassed::~FreeStateIsAlsoPassed( )
223 Exceptions::FreeStateIsAlsoPassed::display( ostream
& os
) const
225 os
<< "Non-pure, delayed, expressions may not have free states which are also passed as state arguments in the same non-pure function application. Please consider forcing immediate evaluation." << std::endl
;
229 Exceptions::RepeatedStateArgument::RepeatedStateArgument( const Ast::SourceLocation
& loc
, const RefCountPtr
< Ast::StateIDSet
> & passedStates
)
230 : Exceptions::StaticInconsistency( loc
), passedStates_( passedStates
)
233 Exceptions::RepeatedStateArgument::~RepeatedStateArgument( )
237 Exceptions::RepeatedStateArgument::display( ostream
& os
) const
239 os
<< "Some of these states are being passed in more than one state argument position:" ;
240 typedef typeof *passedStates_ SetType
;
241 for( SetType::const_iterator i
= passedStates_
->begin( ); i
!= passedStates_
->end( ); ++i
)
249 Exceptions::PassingStateOut::PassingStateOut( const Ast::SourceLocation
& loc
, const char * id
)
250 : Exceptions::StaticInconsistency( loc
), id_( id
)
253 Exceptions::PassingStateOut::~PassingStateOut( )
257 Exceptions::PassingStateOut::display( std::ostream
& os
) const
259 os
<< "States may not be returned." << std::endl
;
263 Exceptions::IntroducingExisting::IntroducingExisting( const Ast::SourceLocation
& _loc
, const char * _id
)
264 : Exceptions::StaticInconsistency( _loc
), loc( _loc
), id( _id
)
267 Exceptions::IntroducingExisting::~IntroducingExisting( )
271 Exceptions::IntroducingExisting::display( std::ostream
& os
) const
273 os
<< "The variable " << id
<< " is already introduced in this scope." << std::endl
;
277 Exceptions::ExpectedImperative::ExpectedImperative( const Ast::SourceLocation
& _loc
)
278 : Exceptions::StaticInconsistency( _loc
), loc( _loc
)
281 Exceptions::ExpectedImperative::~ExpectedImperative( )
285 Exceptions::ExpectedImperative::display( std::ostream
& os
) const
287 os
<< "It makes no sense to put a pure expression before the end of a code bracket." << std::endl
;
291 Exceptions::IllegalImperative::IllegalImperative( const Ast::SourceLocation
& _loc
)
292 : Exceptions::StaticInconsistency( _loc
), loc( _loc
)
295 Exceptions::IllegalImperative::~IllegalImperative( )
299 Exceptions::IllegalImperative::display( std::ostream
& os
) const
301 os
<< "Imperative expressions are not allowed here." << std::endl
;
305 Exceptions::FreezingUndefined::FreezingUndefined( const Ast::SourceLocation
& _loc
, const char * _id
)
306 : Exceptions::StaticInconsistency( _loc
), loc( _loc
), id( _id
)
309 Exceptions::FreezingUndefined::~FreezingUndefined( )
313 Exceptions::FreezingUndefined::display( std::ostream
& os
) const
315 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
;
319 Exceptions::FileReadOpenError::FileReadOpenError( const Ast::SourceLocation
& _loc
, RefCountPtr
< const char > _filename
, const std::string
* sourceDir
, const std::list
< std::string
> * searchPath
, Type _type
)
320 : loc( _loc
), filename( _filename
), type( _type
), sourceDir_( sourceDir
), searchPath_( searchPath
)
323 Exceptions::FileReadOpenError::~FileReadOpenError( )
327 Exceptions::FileReadOpenError::display( std::ostream
& os
) const
332 os
<< loc
<< locsep
<< "Could not open file: " << filename
;
335 os
<< loc
<< locsep
<< "Could not stat() file: " << filename
;
338 os
<< loc
<< locsep
<< "Internal error when displaying FileReadOpenError on file: " << filename
;
340 if( searchPath_
!= 0 )
342 os
<< " searching \"" ;
343 typedef typeof *searchPath_ ListType
;
344 for( ListType::const_iterator i
= searchPath_
->begin( ); i
!= searchPath_
->end( ); ++i
)
346 if( i
!= searchPath_
->begin( ) )
350 if( sourceDir_
!= 0 && (*i
)[0] != '/' )
362 Exceptions::FileWriteOpenError::FileWriteOpenError( const Ast::SourceLocation
& _loc
, RefCountPtr
< const char > _filename
, const char * purpose
)
363 : loc( _loc
), filename( _filename
), purpose_( purpose
)
366 Exceptions::FileWriteOpenError::~FileWriteOpenError( )
370 Exceptions::FileWriteOpenError::display( std::ostream
& os
) const
372 os
<< loc
<< locsep
<< "Could not open " ;
377 os
<< " file for write: " << filename
;
382 Exceptions::TeXSetupTooLate::TeXSetupTooLate( const Ast::SourceLocation
& _loc
)
386 Exceptions::TeXSetupTooLate::~TeXSetupTooLate( )
390 Exceptions::TeXSetupTooLate::display( std::ostream
& os
) const
392 os
<< loc
<< locsep
<< "It is too late to make modifications to the TeX context." << std::endl
;
396 Exceptions::EmptyFinalPicture::EmptyFinalPicture( )
399 Exceptions::EmptyFinalPicture::~EmptyFinalPicture( )
403 Exceptions::EmptyFinalPicture::display( std::ostream
& os
) const
405 os
<< "Nothing was ever put in the global #" << Lang::CATALOG_ID
<< " or drawn to the global #" << Lang::CANVAS_ID
<< "." << std::endl
;
409 Exceptions::TeXSetupHasChanged::TeXSetupHasChanged( )
410 : Shapes::Exceptions::InternalError( "The TeX context check failed while loading fresh labels." )
413 Exceptions::TeXSetupHasChanged::~TeXSetupHasChanged( )
417 Exceptions::TypeMismatch::TypeMismatch( const Ast::SourceLocation
& loc
, RefCountPtr
< const char > _valueType
, RefCountPtr
< const char > _expectedType
)
418 : Exceptions::RuntimeError( loc
), hint_( 0 ), valueType( _valueType
), expectedType( _expectedType
)
421 Exceptions::TypeMismatch::TypeMismatch( const Ast::SourceLocation
& loc
, const char * hint
, RefCountPtr
< const char > _valueType
, RefCountPtr
< const char > _expectedType
)
422 : Exceptions::RuntimeError( loc
), hint_( hint
), valueType( _valueType
), expectedType( _expectedType
)
425 Exceptions::TypeMismatch::~TypeMismatch( )
429 Exceptions::TypeMismatch::display( std::ostream
& os
) const
433 os
<< hint_
<< ": " ;
435 os
<< "Expected a " << expectedType
<< ", got a " << valueType
<< "." << std::endl
;
438 Exceptions::PDFVersionError::PDFVersionError( SimplePDF::PDF_Version::Version version
, SimplePDF::PDF_Version::Version required
, const RefCountPtr
< const char > & msg
)
439 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), version_( version
), required_( required
), msgMem_( msg
), msg_( msgMem_
.getPtr( ) )
442 Exceptions::PDFVersionError::PDFVersionError( SimplePDF::PDF_Version::Version version
, SimplePDF::PDF_Version::Version required
, const char * msg
)
443 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), version_( version
), required_( required
), msgMem_( NullPtr
< const char >( ) ), msg_( msg
)
446 Exceptions::PDFVersionError::~PDFVersionError( )
450 Exceptions::PDFVersionError::display( std::ostream
& os
) const
452 os
<< SimplePDF::PDF_Version::toString( required_
) << " error: " << msg_
<< std::endl
;
456 Exceptions::RedefiningLexical::RedefiningLexical( const char * _id
)
457 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), id( _id
)
460 Exceptions::RedefiningLexical::~RedefiningLexical( )
464 Exceptions::RedefiningLexical::display( std::ostream
& os
) const
466 os
<< "Redefining " << id
<< std::endl
;
470 Exceptions::RedefiningDynamic::RedefiningDynamic( const char * _id
)
471 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), id( _id
)
474 Exceptions::RedefiningDynamic::~RedefiningDynamic( )
478 Exceptions::RedefiningDynamic::display( std::ostream
& os
) const
480 os
<< "Redefining " << "@" << id
<< std::endl
;
484 Exceptions::ConditionTypeMismatch::ConditionTypeMismatch( RefCountPtr
< const char > _valueType
)
485 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), valueType( _valueType
)
488 Exceptions::ConditionTypeMismatch::~ConditionTypeMismatch( )
492 Exceptions::ConditionTypeMismatch::display( std::ostream
& os
) const
494 os
<< "A variable condition check must result in a " << Lang::Boolean::staticTypeName( ) << ", got a " << valueType
<< std::endl
;
498 Exceptions::VariableTypeMismatch::VariableTypeMismatch( const Ast::SourceLocation
& _loc
, RefCountPtr
< const char > _id
, RefCountPtr
< const char > _valueType
, RefCountPtr
< const char > _expectedType
)
499 : Exceptions::RuntimeError( _loc
), id( _id
), valueType( _valueType
), expectedType( _expectedType
)
502 Exceptions::VariableTypeMismatch::~VariableTypeMismatch( )
506 Exceptions::VariableTypeMismatch::display( std::ostream
& os
) const
508 os
<< "The variable " << id
<< " was expected to refer to a " << expectedType
<< ", found a " << valueType
<< std::endl
;
512 Exceptions::NonObjectMemberAssignment::NonObjectMemberAssignment( const Ast::SourceLocation
& _loc
, RefCountPtr
< const char > _valueType
)
513 : Exceptions::RuntimeError( _loc
), valueType( _valueType
)
516 Exceptions::NonObjectMemberAssignment::~NonObjectMemberAssignment( )
520 Exceptions::NonObjectMemberAssignment::display( std::ostream
& os
) const
522 os
<< "Only object oriented values have fields that can be assigned. This value is of type " << valueType
<< "." << std::endl
;
526 Exceptions::ElementaryWithout::ElementaryWithout( Kind kind
, Ref ref
, RefCountPtr
< const char > _valueType
)
527 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), kind_( kind
), ref_( ref
), valueType( _valueType
)
530 Exceptions::ElementaryWithout::~ElementaryWithout( )
534 Exceptions::ElementaryWithout::display( std::ostream
& os
) const
546 os
<< " is of the elementary type " << valueType
<< ", which has no " ;
556 os
<< "." << std::endl
;
560 Exceptions::IllegalFinalReference::IllegalFinalReference( RefCountPtr
< const char > _valueType
, const char * _fieldID
)
561 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), valueType( _valueType
), fieldID( _fieldID
)
564 Exceptions::IllegalFinalReference::~IllegalFinalReference( )
568 Exceptions::IllegalFinalReference::display( std::ostream
& os
) const
570 os
<< "Attempt to access field of non-final class " << valueType
<< " without home class. Use <HomeClass>#" << fieldID
<< " instead." << std::endl
;
574 Exceptions::NonExistentMember::NonExistentMember( RefCountPtr
< const char > _valueType
, const char * _fieldID
)
575 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), valueType( _valueType
), fieldID( _fieldID
)
578 Exceptions::NonExistentMember::~NonExistentMember( )
582 Exceptions::NonExistentMember::display( std::ostream
& os
) const
584 os
<< "Class " << valueType
<< " has no (non-private) field called " << fieldID
<< "." << std::endl
;
588 Exceptions::NonExistentMutator::NonExistentMutator( RefCountPtr
< const char > _valueType
, const char * _mutatorID
)
589 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), valueType( _valueType
), mutatorID( _mutatorID
)
592 Exceptions::NonExistentMutator::~NonExistentMutator( )
596 Exceptions::NonExistentMutator::display( std::ostream
& os
) const
598 os
<< "State type " << valueType
<< " has no mutator called " << mutatorID
<< "." << std::endl
;
602 Exceptions::NonExistentPosition::NonExistentPosition( size_t pos
, size_t maxPos
)
603 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), pos_( pos
), maxPos_( maxPos
)
606 Exceptions::NonExistentPosition::~NonExistentPosition( )
610 Exceptions::NonExistentPosition::display( std::ostream
& os
) const
612 os
<< "Referencing field at position " << pos_
<< " is an error since the user struct has only " << maxPos_
<< " ordered fields." << std::endl
;
616 Exceptions::ProtectedMemberPublicScope::ProtectedMemberPublicScope( RefCountPtr
< const char > _valueType
, const char * _fieldID
)
617 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), valueType( _valueType
), fieldID( _fieldID
)
620 Exceptions::ProtectedMemberPublicScope::~ProtectedMemberPublicScope( )
624 Exceptions::ProtectedMemberPublicScope::display( std::ostream
& os
) const
626 os
<< "Trying to access protected member " << fieldID
<< " of class " << valueType
<< " via public instance." << std::endl
;
630 Exceptions::MemberNotAssignable::MemberNotAssignable( RefCountPtr
< const char > _valueType
, const char * _fieldID
, RefCountPtr
< const char > _scope
)
631 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), valueType( _valueType
), fieldID( _fieldID
), scope( _scope
)
634 Exceptions::MemberNotAssignable::~MemberNotAssignable( )
638 Exceptions::MemberNotAssignable::display( std::ostream
& os
) const
640 os
<< "In " << scope
<< " scope of " << valueType
<< " : The member " << fieldID
<< " is not assignable." << std::endl
;
644 Exceptions::NotApplicable::NotApplicable( )
647 Exceptions::NotApplicable::~NotApplicable( )
651 Exceptions::NotApplicable::display( std::ostream
& os
) const
653 os
<< "An operator was not applicable. It is an internal error that no better error message is given." << std::endl
;
657 Exceptions::UnaryPrefixNotApplicable::UnaryPrefixNotApplicable( const Ast::SourceLocation
& _loc
, const Ast::Expression
* _expr
, RefCountPtr
< const char > _valueType
)
658 : Exceptions::RuntimeError( _loc
), expr( _expr
), valueType( _valueType
), operatorSymbol( "< ? >" )
661 Exceptions::UnaryPrefixNotApplicable::~UnaryPrefixNotApplicable( )
665 Exceptions::UnaryPrefixNotApplicable::setOperatorSymbol( const char * _operatorSymbol
)
667 operatorSymbol
= _operatorSymbol
;
671 Exceptions::UnaryPrefixNotApplicable::display( std::ostream
& os
) const
676 getLoc( ).copy( & os
);
677 os
<< " not defined for " << valueType
<< " at " << expr
->loc( ) << "." << std::endl
;
681 os
<< "Operator " << operatorSymbol
<< " not defined for " << valueType
<< "." << std::endl
;
686 Exceptions::UnaryPostfixNotApplicable::UnaryPostfixNotApplicable( const Ast::SourceLocation
& _loc
, const Ast::Expression
* _expr
, RefCountPtr
< const char > _valueType
)
687 : Exceptions::RuntimeError( _loc
), expr( _expr
), valueType( _valueType
), operatorSymbol( "< ? >" )
690 Exceptions::UnaryPostfixNotApplicable::~UnaryPostfixNotApplicable( )
694 Exceptions::UnaryPostfixNotApplicable::setOperatorSymbol( const char * _operatorSymbol
)
696 operatorSymbol
= _operatorSymbol
;
700 Exceptions::UnaryPostfixNotApplicable::display( std::ostream
& os
) const
705 getLoc( ).copy( & os
);
706 os
<< " not defined for " << valueType
<< " at " << expr
->loc( ) << "." << std::endl
;
710 os
<< "Operator " << operatorSymbol
<< " not defined for " << valueType
<< "." << std::endl
;
715 Exceptions::BinaryInfixNotApplicable::BinaryInfixNotApplicable( const Ast::SourceLocation
& _loc
, const Ast::Expression
* _expr1
, RefCountPtr
< const char > _valueType1
, const Ast::Expression
* _expr2
, RefCountPtr
< const char > _valueType2
)
716 : Exceptions::RuntimeError( _loc
), expr1( _expr1
), valueType1( _valueType1
), expr2( _expr2
), valueType2( _valueType2
), operatorSymbol( "< ? >" )
719 Exceptions::BinaryInfixNotApplicable::~BinaryInfixNotApplicable( )
723 Exceptions::BinaryInfixNotApplicable::setOperatorSymbol( const char * _operatorSymbol
)
725 operatorSymbol
= _operatorSymbol
;
729 Exceptions::BinaryInfixNotApplicable::display( std::ostream
& os
) const
731 if( expr1
!= 0 && expr2
!= 0 )
734 getLoc( ).copy( & os
);
735 os
<< " not defined for (" << valueType1
<< "," << valueType2
<< ") at " << expr1
->loc( ) << ", " << expr2
->loc( ) << "." << std::endl
;
739 os
<< "Operator " << operatorSymbol
<< " not defined for (" << valueType1
<< "," << valueType2
<< ")." << std::endl
;
744 Exceptions::ProhibitedTypeChange::ProhibitedTypeChange( const Ast::SourceLocation
& _loc
, RefCountPtr
< const char > _id
, RefCountPtr
< const char > _oldType
, RefCountPtr
< const char > _newType
)
745 : Exceptions::RuntimeError( _loc
), id( _id
), oldType( _oldType
), newType( _newType
)
748 Exceptions::ProhibitedTypeChange::~ProhibitedTypeChange( )
752 Exceptions::ProhibitedTypeChange::display( std::ostream
& os
) const
754 os
<< "The type of " << id
<< " is locked to " << oldType
<< ", but the new value is of type " << newType
<< "." << std::endl
;
758 Exceptions::LookupUnknown::LookupUnknown( const Ast::SourceLocation
& _loc
, RefCountPtr
< const char > _id
, Type type
)
759 : Exceptions::StaticInconsistency( _loc
), id( _id
), type_( type
)
762 Exceptions::LookupUnknown::~LookupUnknown( )
766 Exceptions::LookupUnknown::display( std::ostream
& os
) const
771 os
<< "The variable " << id
<< " is unbound." << std::endl
;
774 os
<< "There is no state called " << id
<< " around." << std::endl
;
776 case DYNAMIC_VARIABLE
:
777 os
<< "There is no dynamic variable called " << id
<< " around." << std::endl
;
780 os
<< "There is no dynamic state called " << id
<< " around." << std::endl
;
783 os
<< "There is no type called " << id
<< " around." << std::endl
;
791 Exceptions::StateBeyondFunctionBoundary::StateBeyondFunctionBoundary( const Ast::SourceLocation
& _loc
, RefCountPtr
< const char > _id
)
792 : Exceptions::StaticInconsistency( _loc
), id( _id
)
795 Exceptions::StateBeyondFunctionBoundary::~StateBeyondFunctionBoundary( )
799 Exceptions::StateBeyondFunctionBoundary::display( std::ostream
& os
) const
801 os
<< "The state " << id
<< " resides outside a function boundary." << std::endl
;
805 Exceptions::IntroducingExistingUnit::IntroducingExistingUnit( const Ast::SourceLocation
& _loc
, RefCountPtr
< const char > _id
)
806 : Exceptions::StaticInconsistency( _loc
), id( _id
)
809 Exceptions::IntroducingExistingUnit::~IntroducingExistingUnit( )
813 Exceptions::IntroducingExistingUnit::display( std::ostream
& os
) const
815 os
<< "Inconsistent definition of the existing unit " << id
<< "." << std::endl
;
819 Exceptions::LookupUnknownUnit::LookupUnknownUnit( const Ast::SourceLocation
& _loc
, RefCountPtr
< const char > _id
)
820 : Exceptions::StaticInconsistency( _loc
), id( _id
)
823 Exceptions::LookupUnknownUnit::~LookupUnknownUnit( )
827 Exceptions::LookupUnknownUnit::display( std::ostream
& os
) const
829 os
<< "The unit " << id
<< " is unbound" << std::endl
;
833 Exceptions::OutOfRange::OutOfRange( RefCountPtr
< const char > msg
)
834 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), msg_( msg
.getPtr( ) ), msgMem_( msg
)
837 Exceptions::OutOfRange::OutOfRange( const char * msg
)
838 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), msg_( msg
), msgMem_( NullPtr
< const char >( ) )
841 Exceptions::OutOfRange::OutOfRange( const Ast::SourceLocation
& _loc
, RefCountPtr
< const char > msg
)
842 : Exceptions::RuntimeError( _loc
), msg_( msg
.getPtr( ) ), msgMem_( msg
)
845 Exceptions::OutOfRange::OutOfRange( const Ast::SourceLocation
& _loc
, const char * msg
)
846 : Exceptions::RuntimeError( _loc
), msg_( msg
), msgMem_( NullPtr
< const char >( ) )
849 Exceptions::OutOfRange::~OutOfRange( )
853 Exceptions::OutOfRange::display( std::ostream
& os
) const
855 os
<< "Out-of-range error: " << msg_
<< std::endl
;
859 Exceptions::NonVoidStatement::NonVoidStatement( const Ast::SourceLocation
& _loc
, RefCountPtr
< const Lang::Value
> _val
)
860 : Exceptions::RuntimeError( _loc
), val( _val
)
863 Exceptions::NonVoidStatement::~NonVoidStatement( )
867 Exceptions::NonVoidStatement::display( std::ostream
& os
) const
869 os
<< "No implicit ignore of non-void value (of type " << val
->getTypeName( ) << ")" << std::endl
;
872 // Exceptions::RuntimeError::RuntimeError( )
873 // : loc_( "< unlocated runtime error >" )
876 Exceptions::RuntimeError::~RuntimeError( )
879 Exceptions::RuntimeError::RuntimeError( const Ast::SourceLocation
& loc
)
883 Exceptions::RuntimeError::RuntimeError( Ast::Expression
* expr
)
884 : loc_( expr
->loc( ) )
887 const Ast::SourceLocation
&
888 Exceptions::RuntimeError::getLoc( ) const
894 Exceptions::UserError::UserError( RefCountPtr
< const char > _msg
)
895 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), msg( _msg
)
898 Exceptions::UserError::~UserError( )
902 Exceptions::UserError::display( ostream
& os
) const
904 os
<< "User error: " << msg
<< std::endl
;
908 Exceptions::InternalError::InternalError( const Ast::SourceLocation
& loc
, RefCountPtr
< const char > msg
)
909 : Exceptions::RuntimeError( loc
), msg_( msg
.getPtr( ) ), msgMem_( msg
)
912 Exceptions::InternalError::InternalError( const Ast::SourceLocation
& loc
, const char * msg
)
913 : Exceptions::RuntimeError( loc
), msg_( msg
), msgMem_( NullPtr
< const char >( ) )
916 Exceptions::InternalError::InternalError( RefCountPtr
< const char > msg
)
917 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), msg_( msg
.getPtr( ) ), msgMem_( msg
)
920 Exceptions::InternalError::InternalError( const char * msg
)
921 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), msg_( msg
), msgMem_( NullPtr
< const char >( ) )
924 Exceptions::InternalError::InternalError( const std::ostringstream
& msg
)
925 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), msg_( strdup( msg
.str( ).c_str( ) ) ), msgMem_( msg_
)
928 Exceptions::InternalError::~InternalError( )
932 Exceptions::InternalError::display( ostream
& os
) const
934 os
<< "Internal error: " << msg_
<< std::endl
;
938 Exceptions::ExternalError::ExternalError( RefCountPtr
< const char > msg
)
939 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), msg_( msg
.getPtr( ) ), msgMem_( msg
)
942 Exceptions::ExternalError::ExternalError( const char * msg
)
943 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), msg_( msg
), msgMem_( NullPtr
< const char >( ) )
946 Exceptions::ExternalError::~ExternalError( )
950 Exceptions::ExternalError::display( ostream
& os
) const
952 os
<< "External error: " << msg_
<< std::endl
;
955 Exceptions::ExternalError
*
956 Exceptions::ExternalError::clone( ) const
958 return new Exceptions::ExternalError( msgMem_
);
961 Exceptions::UserArityMismatch::UserArityMismatch( const Ast::SourceLocation _formalsLoc
, size_t _functionArity
, size_t _callArity
, Type type
)
962 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), formalsLoc( _formalsLoc
), functionArity( _functionArity
), callArity( _callArity
), type_( type
)
965 Exceptions::UserArityMismatch::~UserArityMismatch( )
969 Exceptions::UserArityMismatch::display( std::ostream
& os
) const
971 os
<< "Function with formals at " << formalsLoc
<< " expects " << functionArity
;
975 os
<< " value arguments" ;
978 os
<< " state arguments" ;
983 os
<< ", not " << callArity
<< std::endl
;
986 Exceptions::SinkRequired::SinkRequired( const Ast::SourceLocation formalsLoc
, size_t formalsArity
, size_t callArity
)
987 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), formalsLoc_( formalsLoc
), formalsArity_( formalsArity
), callArity_( callArity
)
990 Exceptions::SinkRequired::~SinkRequired( )
994 Exceptions::SinkRequired::display( std::ostream
& os
) const
996 os
<< "Formals at " << formalsLoc_
<< " contains no sink, so passing " << callArity_
<< " ordered arguments is " << callArity_
- formalsArity_
<< " too many." << std::endl
;
1000 Exceptions::NamedFormalMismatch::NamedFormalMismatch( const Ast::SourceLocation _formalsLoc
, RefCountPtr
< const char > _name
, Exceptions::NamedFormalMismatch::Type type
)
1001 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), formalsLoc( _formalsLoc
), name( _name
), type_( type
)
1004 Exceptions::NamedFormalMismatch::~NamedFormalMismatch( )
1008 Exceptions::NamedFormalMismatch::display( std::ostream
& os
) const
1010 os
<< "Function with formals at " << formalsLoc
<< " has no named ";
1022 os
<< " called " << name
<< "." << std::endl
;
1026 Exceptions::NamedFormalAlreadySpecified::NamedFormalAlreadySpecified( const Ast::SourceLocation _formalsLoc
, RefCountPtr
< const char > _name
, size_t _pos
, Exceptions::NamedFormalAlreadySpecified::Type type
)
1027 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), formalsLoc( _formalsLoc
), name( _name
), pos( _pos
), type_( type
)
1030 Exceptions::NamedFormalAlreadySpecified::~NamedFormalAlreadySpecified( )
1034 Exceptions::NamedFormalAlreadySpecified::display( std::ostream
& os
) const
1036 os
<< "The formal " ;
1048 os
<< " named " << name
<< ", defined at " << formalsLoc
<< " is already defined by order, at position " << pos
<< "." << std::endl
;
1051 Exceptions::MissingArguments::MissingArguments( const Ast::SourceLocation _formalsLoc
, std::map
< size_t, RefCountPtr
< const char > > * _missingVariables
, std::map
< size_t, RefCountPtr
< const char > > * _missingStates
)
1052 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), formalsLoc( _formalsLoc
), missingVariables( _missingVariables
), missingStates( _missingStates
)
1055 Exceptions::MissingArguments::~MissingArguments( )
1057 if( missingVariables
!= 0 )
1059 delete missingVariables
;
1061 if( missingStates
!= 0 )
1063 delete missingStates
;
1068 Exceptions::MissingArguments::display( std::ostream
& os
) const
1070 os
<< "Among the formals at " << formalsLoc
;
1071 if( missingVariables
!= 0 )
1073 os
<< ", the following variables are missing:" ;
1074 typedef typeof *missingVariables MapType
;
1075 for( MapType::const_iterator i
= missingVariables
->begin( ); i
!= missingVariables
->end( ); ++i
)
1077 if( i
!= missingVariables
->begin( ) )
1081 os
<< " (" << i
->first
<< ")" << i
->second
.getPtr( ) ;
1084 if( missingStates
!= 0 )
1087 if( missingVariables
!= 0 )
1091 os
<< "the following states are missing:" ;
1092 typedef typeof *missingStates MapType
;
1093 for( MapType::const_iterator i
= missingStates
->begin( ); i
!= missingStates
->end( ); ++i
)
1095 if( i
!= missingStates
->begin( ) )
1099 os
<< " (" << i
->first
<< ")" << i
->second
.getPtr( ) ;
1102 os
<< "." << std::endl
;
1106 Exceptions::CoreArityMismatch::CoreArityMismatch( const char * _title
, size_t _functionArity
, size_t _callArity
)
1107 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), title( _title
), titleMem( NullPtr
< const char >( ) ), functionArityLow( _functionArity
), functionArityHigh( _functionArity
), callArity( _callArity
)
1110 Exceptions::CoreArityMismatch::CoreArityMismatch( const char * _title
, size_t _functionArityLow
, size_t _functionArityHigh
, size_t _callArity
)
1111 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), title( _title
), titleMem( NullPtr
< const char >( ) ), functionArityLow( _functionArityLow
), functionArityHigh( _functionArityHigh
), callArity( _callArity
)
1114 Exceptions::CoreArityMismatch::CoreArityMismatch( const RefCountPtr
< const char > & _title
, size_t _functionArity
, size_t _callArity
)
1115 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), title( _title
.getPtr( ) ), titleMem( _title
), functionArityLow( _functionArity
), functionArityHigh( _functionArity
), callArity( _callArity
)
1118 Exceptions::CoreArityMismatch::CoreArityMismatch( const RefCountPtr
< const char > & _title
, size_t _functionArityLow
, size_t _functionArityHigh
, size_t _callArity
)
1119 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), title( _title
.getPtr( ) ), titleMem( _title
), functionArityLow( _functionArityLow
), functionArityHigh( _functionArityHigh
), callArity( _callArity
)
1122 Exceptions::CoreArityMismatch::~CoreArityMismatch( )
1126 Exceptions::CoreArityMismatch::display( std::ostream
& os
) const
1128 if( functionArityLow
== functionArityHigh
)
1130 os
<< "Core function " << title
<< " expects " << functionArityLow
<< " arguments, not " << callArity
<< std::endl
;
1134 os
<< "Core function " << title
<< " expects [" << functionArityLow
<< ", " << functionArityHigh
<< "] arguments, not " << callArity
<< std::endl
;
1139 Exceptions::CoreNoNamedFormals::CoreNoNamedFormals( const char * _title
)
1140 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), title( _title
), titleMem( NullPtr
< const char >( ) )
1143 Exceptions::CoreNoNamedFormals::CoreNoNamedFormals( const RefCountPtr
< const char > & _title
)
1144 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), title( _title
.getPtr( ) ), titleMem( _title
)
1147 Exceptions::CoreNoNamedFormals::~CoreNoNamedFormals( )
1151 Exceptions::CoreNoNamedFormals::display( std::ostream
& os
) const
1153 os
<< "Core function " << title
<< " does not accept named arguments." << std::endl
;
1157 Exceptions::CoreTypeMismatch::CoreTypeMismatch( const Ast::SourceLocation
& callLoc
,
1159 const Ast::SourceLocation
& argLoc
,
1160 RefCountPtr
< const char > valueType
,
1161 RefCountPtr
< const char > expectedType
)
1162 : Exceptions::RuntimeError( callLoc
),
1164 titleMem_( NullPtr
< const char >( ) ),
1166 valueType_( valueType
),
1167 expectedType_( expectedType
)
1170 Exceptions::CoreTypeMismatch::CoreTypeMismatch( const Ast::SourceLocation
& callLoc
,
1171 RefCountPtr
< const char > title
,
1172 const Ast::SourceLocation
& argLoc
,
1173 RefCountPtr
< const char > valueType
,
1174 RefCountPtr
< const char > expectedType
)
1175 : Exceptions::RuntimeError( callLoc
),
1176 title_( title
.getPtr( ) ),
1179 valueType_( valueType
),
1180 expectedType_( expectedType
)
1183 Exceptions::CoreTypeMismatch::CoreTypeMismatch( const Ast::SourceLocation
& callLoc
,
1185 Kernel::Arguments
& args
,
1187 RefCountPtr
< const char > expectedType
)
1188 : Exceptions::RuntimeError( callLoc
),
1190 titleMem_( NullPtr
< const char >( ) ),
1191 argLoc_( args
.getLoc( argNo
) ),
1192 valueType_( args
.getValue( argNo
)->getTypeName( ) ),
1193 expectedType_( expectedType
)
1196 Exceptions::CoreTypeMismatch::CoreTypeMismatch( const Ast::SourceLocation
& callLoc
,
1197 RefCountPtr
< const char > title
,
1198 Kernel::Arguments
& args
,
1200 RefCountPtr
< const char > expectedType
)
1201 : Exceptions::RuntimeError( callLoc
),
1202 title_( title
.getPtr( ) ),
1204 argLoc_( args
.getLoc( argNo
) ),
1205 valueType_( args
.getValue( argNo
)->getTypeName( ) ),
1206 expectedType_( expectedType
)
1209 Exceptions::CoreTypeMismatch::~CoreTypeMismatch( )
1213 Exceptions::CoreTypeMismatch::display( std::ostream
& os
) const
1215 os
<< "Core function " << title_
<< ", argument ";
1216 // if( argName_ != 0 )
1218 // os << "\"" << argName_ << "\" " ;
1220 os
<< "at " << argLoc_
<< ": expected a " << expectedType_
<< ", got a " << valueType_
<< "." << std::endl
;
1224 Exceptions::CoreStateTypeMismatch::CoreStateTypeMismatch( const Ast::SourceLocation
& callLoc
,
1226 const Ast::SourceLocation
& argLoc
,
1227 RefCountPtr
< const char > valueType
,
1228 RefCountPtr
< const char > expectedType
)
1229 : Exceptions::RuntimeError( callLoc
),
1231 titleMem_( NullPtr
< const char >( ) ),
1233 valueType_( valueType
),
1234 expectedType_( expectedType
)
1237 Exceptions::CoreStateTypeMismatch::CoreStateTypeMismatch( const Ast::SourceLocation
& callLoc
,
1238 RefCountPtr
< const char > title
,
1239 const Ast::SourceLocation
& argLoc
,
1240 RefCountPtr
< const char > valueType
,
1241 RefCountPtr
< const char > expectedType
)
1242 : Exceptions::RuntimeError( callLoc
),
1243 title_( title
.getPtr( ) ),
1246 valueType_( valueType
),
1247 expectedType_( expectedType
)
1250 Exceptions::CoreStateTypeMismatch::CoreStateTypeMismatch( const Ast::SourceLocation
& callLoc
,
1252 Kernel::Arguments
& args
,
1254 RefCountPtr
< const char > expectedType
)
1255 : Exceptions::RuntimeError( callLoc
),
1257 titleMem_( NullPtr
< const char >( ) ),
1258 argLoc_( args
.getStateLoc( argNo
) ),
1259 valueType_( args
.getState( argNo
)->getTypeName( ) ),
1260 expectedType_( expectedType
)
1263 Exceptions::CoreStateTypeMismatch::CoreStateTypeMismatch( const Ast::SourceLocation
& callLoc
,
1264 RefCountPtr
< const char > title
,
1265 Kernel::Arguments
& args
,
1267 RefCountPtr
< const char > expectedType
)
1268 : Exceptions::RuntimeError( callLoc
),
1269 title_( title
.getPtr( ) ),
1271 argLoc_( args
.getStateLoc( argNo
) ),
1272 valueType_( args
.getState( argNo
)->getTypeName( ) ),
1273 expectedType_( expectedType
)
1276 Exceptions::CoreStateTypeMismatch::~CoreStateTypeMismatch( )
1280 Exceptions::CoreStateTypeMismatch::display( std::ostream
& os
) const
1282 os
<< "Core function " << title_
<< ", state ";
1283 // if( argName_ != 0 )
1285 // os << "\"" << argName_ << "\" " ;
1287 os
<< "at " << argLoc_
<< ": expected a " << expectedType_
<< ", got a " << valueType_
<< "." << std::endl
;
1291 Exceptions::CoreDynamicTypeMismatch::CoreDynamicTypeMismatch( const Ast::SourceLocation
& callLoc
,
1294 RefCountPtr
< const char > valueType
,
1295 RefCountPtr
< const char > expectedType
)
1296 : Exceptions::RuntimeError( callLoc
),
1298 titleMem_( NullPtr
< const char >( ) ),
1300 idMem_( NullPtr
< const char >( ) ),
1301 valueType_( valueType
),
1302 expectedType_( expectedType
)
1305 Exceptions::CoreDynamicTypeMismatch::~CoreDynamicTypeMismatch( )
1309 Exceptions::CoreDynamicTypeMismatch::display( std::ostream
& os
) const
1311 os
<< "Core function " << title_
<< " encountered a type mismatch in the dynamic variable @" << id_
1312 << ": expected a " << expectedType_
<< ", got a " << valueType_
<< "." << std::endl
;
1315 Exceptions::ContinuationTypeMismatch::ContinuationTypeMismatch( const Kernel::Continuation
* locationCont
,
1316 RefCountPtr
< const char > valueType
,
1317 RefCountPtr
< const char > expectedType
)
1318 : Exceptions::RuntimeError( locationCont
->traceLoc( ) ),
1319 valueType_( valueType
),
1320 expectedType_( expectedType
)
1323 Exceptions::ContinuationTypeMismatch::~ContinuationTypeMismatch( )
1327 Exceptions::ContinuationTypeMismatch::display( std::ostream
& os
) const
1329 os
<< "The continuation expected a " << expectedType_
<< ", got a " << valueType_
<< "." << std::endl
;
1333 Exceptions::EmptyApplication::EmptyApplication( )
1334 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
)
1337 Exceptions::EmptyApplication::~EmptyApplication( )
1341 Exceptions::EmptyApplication::display( std::ostream
& os
) const
1343 os
<< "Empty application." << std::endl
;
1347 Exceptions::CoreOutOfRange::CoreOutOfRange( const char * _title
, Kernel::Arguments
& args
, size_t argNo
, RefCountPtr
< const char > msg
)
1348 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), title( _title
), argLoc_( args
.getLoc( argNo
) ), msg_( msg
.getPtr( ) ), msgMem_( msg
)
1351 Exceptions::CoreOutOfRange::CoreOutOfRange( const char * _title
, Kernel::Arguments
& args
, size_t argNo
, const char * msg
)
1352 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), title( _title
), argLoc_( args
.getLoc( argNo
) ), msg_( msg
), msgMem_( NullPtr
< const char >( ) )
1355 Exceptions::CoreOutOfRange::~CoreOutOfRange( )
1359 Exceptions::CoreOutOfRange::display( std::ostream
& os
) const
1361 os
<< "Core function " << title
<< ": ";
1362 os
<< "Argument at " << argLoc_
<< " is out of range; " << msg_
<< std::endl
;
1365 Exceptions::CoreRequirement::CoreRequirement( RefCountPtr
< const char > msg
, const char * _title
, const Ast::SourceLocation
& callLoc
)
1366 : Exceptions::RuntimeError( callLoc
), title( _title
), msg_( msg
.getPtr( ) ), msgMem_( msg
)
1369 Exceptions::CoreRequirement::CoreRequirement( const char * msg
, const char * _title
, const Ast::SourceLocation
& callLoc
)
1370 : Exceptions::RuntimeError( callLoc
), title( _title
), msg_( msg
), msgMem_( NullPtr
< const char >( ) )
1373 Exceptions::CoreRequirement::~CoreRequirement( )
1377 Exceptions::CoreRequirement::display( std::ostream
& os
) const
1379 os
<< "Core function " << title
<< ": " << msg_
<< std::endl
;
1383 Exceptions::TeXLabelError::TeXLabelError( bool quoted
, const char * region
, RefCountPtr
< const char > summary
, RefCountPtr
< const char > details
, const Ast::SourceLocation
& loc
)
1384 : Exceptions::RuntimeError( loc
), strLoc_( loc
), quoted_( quoted
), region_( region
), summary_( summary
), details_( details
)
1387 Exceptions::TeXLabelError::~TeXLabelError( )
1391 Exceptions::TeXLabelError::display( ostream
& os
) const
1395 os
<< "TeX error in " << region_
;
1399 os
<< "Error in TeX " << region_
;
1401 if( ! strLoc_
.isUnknown( ) )
1403 os
<< " at " << strLoc_
;
1416 if( details_
!= NullPtr
< const char >( ) )
1418 Exceptions::prefixEachLine( additionalLinesPrefix
, details_
, os
);
1423 Exceptions::StaticTeXLabelError::StaticTeXLabelError( bool quoted
, const char * region
, RefCountPtr
< const char > summary
, RefCountPtr
< const char > details
, const Ast::SourceLocation
& loc
)
1424 : Exceptions::StaticInconsistency( loc
), quoted_( quoted
), region_( region
), summary_( summary
), details_( details
)
1427 Exceptions::StaticTeXLabelError::~StaticTeXLabelError( )
1431 Exceptions::StaticTeXLabelError::display( ostream
& os
) const
1435 os
<< "TeX error in " << region_
;
1439 os
<< "Error in TeX " << region_
;
1452 if( details_
!= NullPtr
< const char >( ) )
1454 Exceptions::prefixEachLine( additionalLinesPrefix
, details_
, os
);
1459 Exceptions::InstantiatingAbstractClass::InstantiatingAbstractClass( RefCountPtr
< const Lang::Class
> _cls
)
1460 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), cls( _cls
)
1463 Exceptions::InstantiatingAbstractClass::~InstantiatingAbstractClass( )
1467 Exceptions::InstantiatingAbstractClass::display( ostream
& os
) const
1469 os
<< "Trying to instantiate abstract class: " << cls
->getPrettyName( ) << std::endl
;
1473 Exceptions::FailedToDeclareClassAbstract::FailedToDeclareClassAbstract( RefCountPtr
< const Lang::Class
> _cls
, const Shapes::Ast::ClassFunction
* _classExpr
)
1474 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), cls( _cls
), classExpr( _classExpr
)
1477 Exceptions::FailedToDeclareClassAbstract::~FailedToDeclareClassAbstract( )
1481 Exceptions::FailedToDeclareClassAbstract::display( ostream
& os
) const
1483 os
<< classExpr
->loc( ) << " " << "Class " << cls
->getPrettyName( ) << " has abstract methods but is not declared abstract: " ;
1484 cls
->showAbstractSet( os
);
1489 Exceptions::RepeatedImmediateParent::RepeatedImmediateParent( RefCountPtr
< const Lang::Class
> _cls
, RefCountPtr
< const Lang::Class
> _parent
)
1490 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), cls( _cls
), parent( _parent
)
1493 Exceptions::RepeatedImmediateParent::~RepeatedImmediateParent( )
1497 Exceptions::RepeatedImmediateParent::display( ostream
& os
) const
1499 os
<< "When creating the class " << cls
->getPrettyName( ) << ", the following class is a repeated immediate parent: " << parent
->getPrettyName( ) << std::endl
;
1503 Exceptions::OverridingNonParent::OverridingNonParent( RefCountPtr
< const Lang::Class
> _cls
, RefCountPtr
< const Lang::Class
> _parent
)
1504 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), cls( _cls
), parent( _parent
)
1507 Exceptions::OverridingNonParent::~OverridingNonParent( )
1511 Exceptions::OverridingNonParent::display( ostream
& os
) const
1513 os
<< "The class " << cls
->getPrettyName( ) << " cannot override methods from the class " << parent
->getPrettyName( ) << ", since the latter is not a parent of the former." << std::endl
;
1517 Exceptions::InheritingFinal::InheritingFinal( RefCountPtr
< const Lang::Class
> _cls
, RefCountPtr
< const Lang::Class
> _parent
)
1518 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), cls( _cls
), parent( _parent
)
1521 Exceptions::InheritingFinal::~InheritingFinal( )
1525 Exceptions::InheritingFinal::display( ostream
& os
) const
1527 os
<< "When creating the class " << cls
->getPrettyName( ) << ", trying to inherit from final class: " << parent
->getPrettyName( ) << std::endl
;
1531 Exceptions::OverridingUndeclaredMethod::OverridingUndeclaredMethod( RefCountPtr
< const Lang::Class
> _cls
, RefCountPtr
< const Lang::Class
> _parent
, const char * _id
)
1532 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), cls( _cls
), parent( _parent
), id( _id
)
1535 Exceptions::OverridingUndeclaredMethod::~OverridingUndeclaredMethod( )
1539 Exceptions::OverridingUndeclaredMethod::display( ostream
& os
) const
1541 os
<< "In override declaration in class " << cls
->getPrettyName( ) << ": there is no method called " << id
<< " in class " << parent
->getPrettyName( ) << " to override." << std::endl
;
1545 Exceptions::OverridingFinalMethod::OverridingFinalMethod( RefCountPtr
< const Lang::Class
> _cls
, RefCountPtr
< const Lang::Class
> _parent
, const char * _id
)
1546 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), cls( _cls
), parent( _parent
), id( _id
)
1549 Exceptions::OverridingFinalMethod::~OverridingFinalMethod( )
1553 Exceptions::OverridingFinalMethod::display( ostream
& os
) const
1555 os
<< "In override declaration in class " << cls
->getPrettyName( ) << ": The method " << id
<< " in class " << parent
->getPrettyName( ) << " is final." << std::endl
;
1559 Exceptions::IllegalRepeatedBase::IllegalRepeatedBase( RefCountPtr
< const Lang::Class
> _cls
, RefCountPtr
< const Lang::Class
> _parent
)
1560 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), cls( _cls
), parent( _parent
)
1563 Exceptions::IllegalRepeatedBase::~IllegalRepeatedBase( )
1567 Exceptions::IllegalRepeatedBase::display( ostream
& os
) const
1569 os
<< "When creating the class " << cls
->getPrettyName( ) << ", the following repeated base class may not be repeated: " << parent
->getPrettyName( ) << std::endl
;
1573 Exceptions::AmbiguousInheritedMethod::AmbiguousInheritedMethod( RefCountPtr
< const Lang::Class
> _cls
, RefCountPtr
< const char > _id
, std::set
< RefCountPtr
< const Lang::Class
> > _parents
)
1574 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), cls( _cls
), id( _id
), parents( _parents
)
1577 Exceptions::AmbiguousInheritedMethod::~AmbiguousInheritedMethod( )
1581 Exceptions::AmbiguousInheritedMethod::display( ostream
& os
) const
1583 os
<< "In class " << cls
->getPrettyName( ) << ": the method name " << id
<< " is ambiguous, as it is inherited from more than one class:" ;
1584 for( std::set
< RefCountPtr
< const Lang::Class
> >::const_iterator i
= parents
.begin( ); i
!= parents
.end( ); ++i
)
1586 os
<< " " << (*i
)->getPrettyName( ) ;
1592 Exceptions::MisplacedSuperReference::MisplacedSuperReference( const Ast::SourceLocation
& _loc
)
1593 : Exceptions::RuntimeError( _loc
)
1596 Exceptions::MisplacedSuperReference::~MisplacedSuperReference( )
1600 Exceptions::MisplacedSuperReference::display( std::ostream
& os
) const
1602 os
<< "Misplaced reference to parent instance." << std::endl
;
1606 Exceptions::SuperReferenceClassNotParent::SuperReferenceClassNotParent( RefCountPtr
< const Lang::Class
> _cls
, RefCountPtr
< const Lang::Class
> _parent
)
1607 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), cls( _cls
), parent( _parent
)
1610 Exceptions::SuperReferenceClassNotParent::~SuperReferenceClassNotParent( )
1614 Exceptions::SuperReferenceClassNotParent::display( std::ostream
& os
) const
1616 os
<< "When referencing super instance, " << parent
->getPrettyName( ) << " is not a parent of " << cls
->getPrettyName( ) << "." << std::endl
;
1620 Exceptions::NoSuchMethod::NoSuchMethod( RefCountPtr
< const Lang::Class
> _cls
, const Kernel::MethodId
& _method
)
1621 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), cls( _cls
), method( _method
)
1624 Exceptions::NoSuchMethod::~NoSuchMethod( )
1628 Exceptions::NoSuchMethod::display( std::ostream
& os
) const
1630 os
<< "Class " << cls
->getPrettyName( ) << " has no method called " << method
.prettyName( ) << std::endl
;
1634 Exceptions::NoSuchLocalMethod::NoSuchLocalMethod( RefCountPtr
< const Lang::Class
> _cls
, const Kernel::MethodId
& _method
)
1635 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), cls( _cls
), method( _method
)
1638 Exceptions::NoSuchLocalMethod::~NoSuchLocalMethod( )
1642 Exceptions::NoSuchLocalMethod::display( std::ostream
& os
) const
1644 os
<< "Class " << cls
->getPrettyName( ) << " does not itself define the method " << method
.prettyName( ) << std::endl
;
1648 Exceptions::MultipleDynamicBind::MultipleDynamicBind( const char * _id
, const Ast::SourceLocation
& _loc
, const Ast::SourceLocation
& _prevLoc
)
1649 : Exceptions::RuntimeError( _loc
), id( _id
), prevLoc( _prevLoc
)
1652 Exceptions::MultipleDynamicBind::~MultipleDynamicBind( )
1656 Exceptions::MultipleDynamicBind::display( std::ostream
& os
) const
1658 os
<< "This dynamic binding of " << id
<< " is merged with the conflicting binding at " << prevLoc
<< "." << std::endl
;
1662 Exceptions::UndefinedEscapeContinuation::UndefinedEscapeContinuation( const char * _id
, const Ast::SourceLocation
& _loc
)
1663 : Exceptions::RuntimeError( _loc
), id( _id
)
1666 Exceptions::UndefinedEscapeContinuation::~UndefinedEscapeContinuation( )
1670 Exceptions::UndefinedEscapeContinuation::display( std::ostream
& os
) const
1672 os
<< "The escape continuation " << id
<< " was not defined in the dynamic context." << std::endl
;
1676 Exceptions::DeadStateAccess::DeadStateAccess( )
1677 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
)
1680 Exceptions::DeadStateAccess::~DeadStateAccess( )
1684 Exceptions::DeadStateAccess::display( std::ostream
& os
) const
1686 os
<< "Accessing dead state." << std::endl
;
1690 Exceptions::UnFreezable::UnFreezable( )
1691 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
)
1694 Exceptions::UnFreezable::~UnFreezable( )
1698 Exceptions::UnFreezable::display( std::ostream
& os
) const
1700 os
<< "The state cannot be frozen." << std::endl
;
1704 Exceptions::UnPeekable::UnPeekable( )
1705 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
)
1708 Exceptions::UnPeekable::~UnPeekable( )
1712 Exceptions::UnPeekable::display( std::ostream
& os
) const
1714 os
<< "The state cannot be peeked. Consider freezing it." << std::endl
;
1718 Exceptions::UninitializedAccess::UninitializedAccess( )
1719 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
)
1722 Exceptions::UninitializedAccess::~UninitializedAccess( )
1726 Exceptions::UninitializedAccess::display( std::ostream
& os
) const
1728 os
<< "The accessed variable or state has not been initialized yet." << std::endl
;
1732 Exceptions::DtMinError::DtMinError( double _dt
)
1733 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), dt( _dt
)
1736 Exceptions::DtMinError::~DtMinError( )
1740 Exceptions::DtMinError::display( std::ostream
& os
) const
1742 os
<< "Path segment too long in relation to arcdelta: dt = " << dt
<< " < " << Computation::the_dtMin
<< ". Either increase arcdelta, or inhibit this error." << std::endl
;
1746 Exceptions::AffineTransformKillsPlane::AffineTransformKillsPlane( double sigma2
)
1747 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), sigma2_( sigma2
)
1750 Exceptions::AffineTransformKillsPlane::~AffineTransformKillsPlane( )
1754 Exceptions::AffineTransformKillsPlane::display( std::ostream
& os
) const
1756 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
;
1759 Exceptions::MissingFontMetrics::MissingFontMetrics( RefCountPtr
< const char > fontname
, const std::list
< std::string
> * searchPath
)
1760 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), fontname_( fontname
), searchPath_( searchPath
)
1763 Exceptions::MissingFontMetrics::~MissingFontMetrics( )
1767 Exceptions::MissingFontMetrics::display( std::ostream
& os
) const
1769 os
<< "The font metrics for " << fontname_
<< ", named " << fontname_
<< ".afm, could not be found in {" ;
1770 typedef typeof *searchPath_ ListType
;
1771 for( ListType::const_iterator i
= searchPath_
->begin( ); i
!= searchPath_
->end( ); ++i
)
1775 os
<< " }." << std::endl
;
1779 Exceptions::FontMetricsError::FontMetricsError( const RefCountPtr
< const char > & fontname
, const RefCountPtr
< const char > & message
)
1780 : Exceptions::RuntimeError( Ast::THE_UNKNOWN_LOCATION
), fontname_( fontname
), message_( message
)
1783 Exceptions::FontMetricsError::~FontMetricsError( )
1787 Exceptions::FontMetricsError::display( std::ostream
& os
) const
1789 os
<< "There was a problem with the font metrics for " << fontname_
<< ": " << message_
<< std::endl
;
1793 Exceptions::InsertingEmptyPage::InsertingEmptyPage( const Ast::SourceLocation
& loc
)
1794 : Exceptions::RuntimeError( loc
)
1797 Exceptions::InsertingEmptyPage::~InsertingEmptyPage( )
1801 Exceptions::InsertingEmptyPage::display( std::ostream
& os
) const
1803 os
<< "Attempt to place empty page in catalog." << std::endl
;
1807 Exceptions::UndefinedCrossRef::UndefinedCrossRef( const Ast::SourceLocation
& _loc
, RefCountPtr
< const char > ref
)
1808 : Exceptions::PostCondition( _loc
), ref_( ref
)
1811 Exceptions::UndefinedCrossRef::~UndefinedCrossRef( )
1815 Exceptions::UndefinedCrossRef::display( std::ostream
& os
) const
1817 os
<< "The cross reference \"" << ref_
<< "\" is not defined." << std::endl
;
1822 Exceptions::prefixEachLine( const std::string
& prefix
, std::istream
& src
, std::ostream
& dst
)
1825 for( std::getline( src
, line
); ! src
.eof( ); std::getline( src
, line
) )
1827 dst
<< prefix
<< line
<< std::endl
;
1832 Exceptions::prefixEachLine( const std::string
& prefix
, const RefCountPtr
< const char > & src
, std::ostream
& dst
)
1834 std::istringstream
is( src
.getPtr( ) );
1835 Exceptions::prefixEachLine( prefix
, is
, dst
);