1 /* This file is part of Shapes.
3 * Shapes is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
8 * Shapes is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with Shapes. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright 2008, 2009, 2015 Henrik Tidefelt
21 #include "Shapes_Ast_decls.h"
22 #include "Shapes_Lang_decls.h"
23 #include "Shapes_Kernel_decls.h"
24 #include "Shapes_Exceptions_decls.h"
26 #include "sourcelocation.h"
27 #include "identifier.h"
28 #include "exitcodes.h"
30 #include "simplepdfo.h"
31 #include "strrefdup.h" // this is not needed in this file, but it is convenient to get these declarations for users of this file.
32 #include "pdfversion.h"
47 extern const std::string additionalLinesPrefix
;
53 virtual ~Exception( );
54 virtual void display( std::ostream
& os
) const = 0;
55 virtual Interaction::ExitCode
exitCode( ) const = 0;
56 static const char * locsep
;
59 class NotImplemented
: public Exception
61 const char * functionality
;
63 NotImplemented( const char * _functionality
);
64 virtual ~NotImplemented( );
65 virtual void display( std::ostream
& os
) const;
66 virtual Interaction::ExitCode
exitCode( ) const { return Interaction::EXIT_NOT_IMPLEMENTED
; }
69 class StaticInconsistency
: public Exception
72 Ast::SourceLocation primaryLoc_
;
74 StaticInconsistency( Ast::SourceLocation primaryLoc
) : primaryLoc_( primaryLoc
) { }
75 virtual ~StaticInconsistency( ) { }
76 const Ast::SourceLocation
& loc( ) const { return primaryLoc_
; }
77 virtual Interaction::ExitCode
exitCode( ) const { return Interaction::EXIT_USER_ERROR
; }
80 class PostCondition
: public Exception
83 Ast::SourceLocation primaryLoc_
;
85 PostCondition( Ast::SourceLocation primaryLoc
) : primaryLoc_( primaryLoc
) { }
86 virtual ~PostCondition( ) { }
87 const Ast::SourceLocation
& loc( ) const { return primaryLoc_
; }
88 virtual Interaction::ExitCode
exitCode( ) const { return Interaction::EXIT_USER_ERROR
; }
91 class MiscellaneousStaticInconsistency
: public StaticInconsistency
93 RefCountPtr
< const char > msg_
;
95 MiscellaneousStaticInconsistency( const Ast::SourceLocation
& loc
, RefCountPtr
< const char > msg
);
96 virtual ~MiscellaneousStaticInconsistency( );
97 virtual void display( std::ostream
& os
) const;
100 class NamespaceDirectoryError
: public StaticInconsistency
102 RefCountPtr
< const char > msg_
;
104 NamespaceDirectoryError( const Ast::SourceLocation
& loc
, RefCountPtr
< const char > msg
);
105 virtual ~NamespaceDirectoryError( );
106 virtual void display( std::ostream
& os
) const;
109 class AmbiguousNamespaceDirectory
: public StaticInconsistency
111 std::string previousName_
;
112 std::string currentDir_
;
114 AmbiguousNamespaceDirectory( const std::string
& previousName
, const std::string
& currentDir
);
115 virtual ~AmbiguousNamespaceDirectory( );
116 virtual void display( std::ostream
& os
) const;
119 class NamespaceDirectoryLookupError
: public StaticInconsistency
122 enum Type
{ NOT_FOUND
, WRONG_TYPE
, GLOBAL
};
125 Ast::NamespacePath namespacePath_
;
127 NamespaceDirectoryLookupError( const Ast::SourceLocation
& loc
, Type type
, const Ast::NamespacePath::const_iterator
& nsBegin
, const Ast::NamespacePath::const_iterator
& nsEnd
);
128 NamespaceDirectoryLookupError( Type type
, const Ast::NamespacePath::const_iterator
& nsBegin
, const Ast::NamespacePath::const_iterator
& nsEnd
);
129 virtual ~NamespaceDirectoryLookupError( );
130 virtual void display( std::ostream
& os
) const;
133 class NamespaceDirectoryFileError
: public StaticInconsistency
136 enum Type
{ NOT_FOUND
, WRONG_TYPE
};
139 Ast::NamespacePath namespacePath_
;
140 std::string filename_
;
142 NamespaceDirectoryFileError( const Ast::SourceLocation
& loc
, Type type
, const Ast::NamespacePath
& namespacePath
, const std::string
& filename
);
143 NamespaceDirectoryFileError( Type type
, const Ast::NamespacePath
& namespacePath
, const std::string
& filename
);
144 virtual ~NamespaceDirectoryFileError( );
145 virtual void display( std::ostream
& os
) const;
148 class NamespaceDirectoryInvalidEntries
: public StaticInconsistency
150 RefCountPtr
< const Ast::NamespacePath
> namespacePath_
;
151 std::set
< std::string
> invalidEntries_
;
153 NamespaceDirectoryInvalidEntries( const RefCountPtr
< const Ast::NamespacePath
> & namespacePath
, const std::set
< std::string
> & invalidEntries
);
154 virtual ~NamespaceDirectoryInvalidEntries( );
155 virtual void display( std::ostream
& os
) const;
158 class NamespaceDirectoryCircularOrdering
: public StaticInconsistency
160 RefCountPtr
< const Ast::NamespacePath
> namespacePath_
;
161 std::string cycleEntry_
;
163 NamespaceDirectoryCircularOrdering( const RefCountPtr
< const Ast::NamespacePath
> & namespacePath
, const std::string
& cycleEntry
);
164 virtual ~NamespaceDirectoryCircularOrdering( );
165 virtual void display( std::ostream
& os
) const;
168 class ScannerError
: public StaticInconsistency
170 RefCountPtr
< const char > msg_
;
172 ScannerError( const Ast::SourceLocation
& loc
, RefCountPtr
< const char > msg
);
173 virtual ~ScannerError( );
174 virtual void display( std::ostream
& os
) const;
177 class ParserError
: public StaticInconsistency
179 RefCountPtr
< const char > msg_
;
182 ParserError( const Ast::SourceLocation
& loc
, RefCountPtr
< const char > msg
, bool justAWarning
= false );
183 virtual ~ParserError( );
184 virtual void display( std::ostream
& os
) const;
187 class MemberAlsoAbstract
: public StaticInconsistency
189 Ast::SourceLocation memberLoc
;
191 Ast::SourceLocation abstractLoc
;
193 MemberAlsoAbstract( const Ast::SourceLocation
& _memberLoc
, const char * _id
, const Ast::SourceLocation
& _abstractLoc
);
194 virtual ~MemberAlsoAbstract( );
195 virtual void display( std::ostream
& os
) const;
198 class MemberAlreadyDeclared
: public StaticInconsistency
200 Ast::SourceLocation memberLoc
;
202 Ast::SourceLocation oldLoc
;
204 MemberAlreadyDeclared( const Ast::SourceLocation
& _memberLoc
, const char * _id
, const Ast::SourceLocation
& _oldLoc
);
205 virtual ~MemberAlreadyDeclared( );
206 virtual void display( std::ostream
& os
) const;
209 class PublicGetSetInNonfinalClass
: public StaticInconsistency
211 Ast::SourceLocation memberLoc
;
214 PublicGetSetInNonfinalClass( const Ast::SourceLocation
& _memberLoc
, const char * _id
);
215 virtual ~PublicGetSetInNonfinalClass( );
216 virtual void display( std::ostream
& os
) const;
219 class TransformingMemberInNonfinalClass
: public StaticInconsistency
221 Ast::SourceLocation memberLoc
;
224 TransformingMemberInNonfinalClass( const Ast::SourceLocation
& _memberLoc
, const char * _id
);
225 virtual ~TransformingMemberInNonfinalClass( );
226 virtual void display( std::ostream
& os
) const;
229 class RepeatedFormal
: public StaticInconsistency
233 RepeatedFormal( const Ast::SourceLocation
& Loc
, const char * _id
);
234 virtual ~RepeatedFormal( );
235 virtual void display( std::ostream
& os
) const;
238 class StateUninitializedUse
: public StaticInconsistency
240 const Ast::PlacedIdentifier
* id_
;
241 const Ast::Node
* decl_
;
243 StateUninitializedUse( const Ast::SourceLocation
& loc
, const Ast::PlacedIdentifier
* id
, const Ast::Node
* decl
);
244 virtual ~StateUninitializedUse( );
245 virtual void display( std::ostream
& os
) const;
248 class IllegalFreeStates
: public StaticInconsistency
250 Ast::StateIDSet
* freeStates_
;
251 const char * reason_
;
253 IllegalFreeStates( const Ast::SourceLocation
& loc
, Ast::StateIDSet
* freeStates
, const char * reason
);
254 virtual ~IllegalFreeStates( );
255 virtual void display( std::ostream
& os
) const;
258 class FreeStateIsAlsoPassed
: public StaticInconsistency
260 Ast::StateID stateID_
;
262 FreeStateIsAlsoPassed( const Ast::SourceLocation
& loc
, Ast::StateID stateID
);
263 virtual ~FreeStateIsAlsoPassed( );
264 virtual void display( std::ostream
& os
) const;
267 class RepeatedStateArgument
: public StaticInconsistency
269 RefCountPtr
< Ast::StateIDSet
> passedStates_
;
271 RepeatedStateArgument( const Ast::SourceLocation
& loc
, const RefCountPtr
< Ast::StateIDSet
> & passedStates
);
272 virtual ~RepeatedStateArgument( );
273 virtual void display( std::ostream
& os
) const;
276 class PassingStateOut
: public StaticInconsistency
280 PassingStateOut( const Ast::SourceLocation
& loc
, const char * id
);
281 virtual ~PassingStateOut( );
282 virtual void display( std::ostream
& os
) const;
285 class IntroducingExisting
: public StaticInconsistency
287 Ast::PlacedIdentifier id_
;
289 IntroducingExisting( const Ast::SourceLocation
& loc
, const Ast::PlacedIdentifier
& id
);
290 virtual ~IntroducingExisting( );
291 virtual void display( std::ostream
& os
) const;
294 class NamespaceAliasCollision
: public StaticInconsistency
296 const Ast::IdentifierTree
* tree_
;
299 NamespaceAliasCollision( const Ast::SourceLocation
& loc
, const Ast::IdentifierTree
* tree
, const char * name
);
300 virtual ~NamespaceAliasCollision( );
301 virtual void display( std::ostream
& os
) const;
304 class EncapsulationIntroducingExisting
: public StaticInconsistency
308 EncapsulationIntroducingExisting( const Ast::SourceLocation
& loc
, const char * id
);
309 virtual ~EncapsulationIntroducingExisting( );
310 virtual void display( std::ostream
& os
) const;
313 class EncapsulationNamespaceAliasCollision
: public StaticInconsistency
317 EncapsulationNamespaceAliasCollision( const Ast::SourceLocation
& loc
, const char * id
);
318 virtual ~EncapsulationNamespaceAliasCollision( );
319 virtual void display( std::ostream
& os
) const;
322 class FreezingUndefined
: public StaticInconsistency
324 Ast::PlacedIdentifier id_
;
326 FreezingUndefined( const Ast::SourceLocation
& loc
, const Ast::PlacedIdentifier
& id
);
327 virtual ~FreezingUndefined( );
328 virtual void display( std::ostream
& os
) const;
331 class UndefinedNamespace
: public StaticInconsistency
333 Ast::NamespaceReference id_
;
335 UndefinedNamespace( const Ast::SourceLocation
& loc
, const Ast::NamespaceReference
& id
);
336 virtual ~UndefinedNamespace( );
337 virtual void display( std::ostream
& os
) const;
340 class ExpectedImmediate
: public StaticInconsistency
342 Ast::SourceLocation loc
;
344 ExpectedImmediate( const Ast::SourceLocation
& _loc
);
345 virtual ~ExpectedImmediate( );
346 virtual void display( std::ostream
& os
) const;
349 class IllegalImperative
: public StaticInconsistency
351 Ast::SourceLocation loc
;
353 IllegalImperative( const Ast::SourceLocation
& _loc
);
354 virtual ~IllegalImperative( );
355 virtual void display( std::ostream
& os
) const;
358 class FileReadOpenError
: public Exception
361 enum Type
{ OPEN
, STAT
};
363 Ast::SourceLocation loc
;
364 RefCountPtr
< const char > filename
;
366 const std::string
* sourceDir_
;
367 const std::list
< std::string
> * searchPath_
;
369 FileReadOpenError( const Ast::SourceLocation
& _loc
, RefCountPtr
< const char > _filename
, const std::string
* sourceDir
, const std::list
< std::string
> * searchPath
, Type _type
= OPEN
);
370 virtual ~FileReadOpenError( );
371 virtual void display( std::ostream
& os
) const;
372 virtual Interaction::ExitCode
exitCode( ) const { return Interaction::EXIT_INPUT_FILE_ERROR
; }
375 class FileWriteOpenError
: public Exception
378 Ast::SourceLocation loc
;
379 RefCountPtr
< const char > filename
;
380 const char * purpose_
;
382 FileWriteOpenError( const Ast::SourceLocation
& _loc
, RefCountPtr
< const char > _filename
, const char * purpose
= 0 );
383 virtual ~FileWriteOpenError( );
384 virtual void display( std::ostream
& os
) const;
385 virtual Interaction::ExitCode
exitCode( ) const { return Interaction::EXIT_OUTPUT_FILE_ERROR
; }
388 class TeXSetupTooLate
: public Exception
390 Ast::SourceLocation loc
;
392 TeXSetupTooLate( const Ast::SourceLocation
& _loc
);
393 virtual ~TeXSetupTooLate( );
394 virtual void display( std::ostream
& os
) const;
395 virtual Interaction::ExitCode
exitCode( ) const { return Interaction::EXIT_USER_ERROR
; }
398 class EmptyFinalPicture
: public Exception
401 EmptyFinalPicture( );
402 virtual ~EmptyFinalPicture( );
403 virtual void display( std::ostream
& os
) const;
404 virtual Interaction::ExitCode
exitCode( ) const { return Interaction::EXIT_USER_ERROR
; }
407 class RuntimeError
: public Exception
409 Ast::SourceLocation loc_
;
411 RuntimeError( const Ast::SourceLocation
& loc
);
412 RuntimeError( Ast::Expression
* expr
);
413 const Ast::SourceLocation
& getLoc( ) const;
414 virtual ~RuntimeError( );
415 virtual Interaction::ExitCode
exitCode( ) const { return Interaction::EXIT_USER_ERROR
; } /* This should be overridden when apropriate! */
418 class CatchableError
: public RuntimeError
421 CatchableError( const Ast::SourceLocation
& loc
);
422 CatchableError( Ast::Expression
* expr
);
423 virtual ~CatchableError( );
424 virtual RefCountPtr
< const Lang::Exception
> clone( const Kernel::ContRef
& cont
) const = 0;
427 class UncaughtError
: public RuntimeError
429 RefCountPtr
< const Lang::Exception
> ball_
;
431 UncaughtError( const RefCountPtr
< const Lang::Exception
> & ball
);
432 virtual ~UncaughtError( );
433 virtual void display( std::ostream
& os
) const;
434 virtual Interaction::ExitCode
exitCode( ) const;
435 const RefCountPtr
< const Lang::Exception
> & ball( ) const { return ball_
; }
438 class UserError
: public CatchableError
440 RefCountPtr
< const Lang::Symbol
> kind_
;
441 RefCountPtr
< const Lang::String
> source_
;
442 RefCountPtr
< const Lang::Value
> details_
;
443 RefCountPtr
< const char > message_
;
445 UserError( const RefCountPtr
< const Lang::Symbol
> & kind
, const RefCountPtr
< const Lang::String
> & source
, const RefCountPtr
< const Lang::Value
> & details
, const RefCountPtr
< const char > & message
);
446 virtual ~UserError( );
447 virtual void display( std::ostream
& os
) const;
448 virtual RefCountPtr
< const Lang::Exception
> clone( const Kernel::ContRef
& cont
) const;
449 virtual Interaction::ExitCode
exitCode( ) const { return Interaction::EXIT_USER_DETECTED_ERROR
; }
452 class InternalError
: public RuntimeError
455 RefCountPtr
< const char > msgMem_
;
458 InternalError( const Ast::SourceLocation
& loc
, RefCountPtr
< const char > msg
, bool justAWarning
= false );
459 InternalError( const Ast::SourceLocation
& loc
, const char * msg
, bool justAWarning
= false );
460 InternalError( RefCountPtr
< const char > msg
, bool justAWarning
= false );
461 InternalError( const char * msg
, bool justAWarning
= false );
462 InternalError( const std::ostringstream
& msg
, bool justAWarning
= false );
463 virtual ~InternalError( );
464 virtual void display( std::ostream
& os
) const;
465 virtual Interaction::ExitCode
exitCode( ) const { return Interaction::EXIT_INTERNAL_ERROR
; }
468 class ExternalError
: public CatchableError
471 RefCountPtr
< const char > msgMem_
;
474 ExternalError( RefCountPtr
< const char > msg
, bool justAWarning
= false );
475 ExternalError( const char * msg
, bool justAWarning
= false );
476 virtual ~ExternalError( );
477 virtual void display( std::ostream
& os
) const;
478 virtual RefCountPtr
< const Lang::Exception
> clone( const Kernel::ContRef
& cont
) const;
479 virtual Interaction::ExitCode
exitCode( ) const { return Interaction::EXIT_EXTERNAL_ERROR
; }
480 ExternalError
* cloneTyped( ) const;
483 class TeXSetupHasChanged
: public InternalError
486 TeXSetupHasChanged( );
487 virtual ~TeXSetupHasChanged( );
490 class MiscellaneousRequirement
: public CatchableError
493 RefCountPtr
< const char > msgMem_
;
495 MiscellaneousRequirement( RefCountPtr
< const char > msg
);
496 MiscellaneousRequirement( const char * msg
);
497 virtual ~MiscellaneousRequirement( );
498 virtual void display( std::ostream
& os
) const;
499 virtual RefCountPtr
< const Lang::Exception
> clone( const Kernel::ContRef
& cont
) const;
502 class HandlerError
: public CatchableError
504 RefCountPtr
< const char > msg
;
506 HandlerError( RefCountPtr
< const char > _msg
);
507 HandlerError( const char * _msg
);
508 virtual ~HandlerError( );
509 virtual void display( std::ostream
& os
) const;
510 virtual RefCountPtr
< const Lang::Exception
> clone( const Kernel::ContRef
& cont
) const;
513 class PDFVersionError
: public CatchableError
515 SimplePDF::PDF_Version::Version version_
;
516 SimplePDF::PDF_Version::Version required_
;
517 RefCountPtr
< const char > msgMem_
;
521 PDFVersionError( SimplePDF::PDF_Version::Version version
, SimplePDF::PDF_Version::Version required
, const RefCountPtr
< const char > & msg
, bool justAWarning
= false );
522 PDFVersionError( SimplePDF::PDF_Version::Version version
, SimplePDF::PDF_Version::Version required
, const char * msg
, bool justAWarning
= false );
523 virtual ~PDFVersionError( );
524 virtual void display( std::ostream
& os
) const;
525 virtual RefCountPtr
< const Lang::Exception
> clone( const Kernel::ContRef
& cont
) const;
528 class RedefiningLexical
: public RuntimeError
530 Ast::PlacedIdentifier id
;
532 RedefiningLexical( const Ast::PlacedIdentifier
& _id
);
533 virtual ~RedefiningLexical( );
534 virtual void display( std::ostream
& os
) const;
537 class RedefiningDynamic
: public RuntimeError
539 Ast::PlacedIdentifier id
;
541 RedefiningDynamic( const Ast::PlacedIdentifier
& _id
);
542 virtual ~RedefiningDynamic( );
543 virtual void display( std::ostream
& os
) const;
546 class TypeMismatch
: public RuntimeError
549 RefCountPtr
< const char > valueType
;
550 RefCountPtr
< const char > expectedType
;
552 TypeMismatch( const Ast::SourceLocation
& loc
, const char * hint
, RefCountPtr
< const char > _valueType
, RefCountPtr
< const char > _expectedType
);
553 TypeMismatch( const Ast::SourceLocation
& loc
, RefCountPtr
< const char > _valueType
, RefCountPtr
< const char > _expectedType
);
554 virtual ~TypeMismatch( );
555 virtual void display( std::ostream
& os
) const;
558 class NonObjectMemberAssignment
: public RuntimeError
560 RefCountPtr
< const char > valueType
;
562 NonObjectMemberAssignment( const Ast::SourceLocation
& _loc
, RefCountPtr
< const char > _valueType
);
563 virtual ~NonObjectMemberAssignment( );
564 virtual void display( std::ostream
& os
) const;
567 class ElementaryWithout
: public RuntimeError
570 enum Kind
{ VALUE
, STATE
};
571 enum Ref
{ FIELD
, MUTATOR
};
575 RefCountPtr
< const char > valueType
;
577 ElementaryWithout( Kind kind
, Ref ref
, RefCountPtr
< const char > _valueType
);
578 virtual ~ElementaryWithout( );
579 virtual void display( std::ostream
& os
) const;
582 class NonExistentMember
: public RuntimeError
584 RefCountPtr
< const char > valueType
;
585 const char * fieldID
;
587 NonExistentMember( RefCountPtr
< const char > _valueType
, const char * _fieldID
);
588 virtual ~NonExistentMember( );
589 virtual void display( std::ostream
& os
) const;
592 class NonExistentMutator
: public RuntimeError
594 RefCountPtr
< const char > valueType
;
595 const char * mutatorID
;
597 NonExistentMutator( RefCountPtr
< const char > _valueType
, const char * _mutatorID
);
598 virtual ~NonExistentMutator( );
599 virtual void display( std::ostream
& os
) const;
602 class NonExistentPosition
: public RuntimeError
607 NonExistentPosition( size_t pos
, size_t maxPos
);
608 virtual ~NonExistentPosition( );
609 virtual void display( std::ostream
& os
) const;
612 class UnaryPrefixNotApplicable
: public RuntimeError
614 const Ast::Expression
* expr
;
615 RefCountPtr
< const char > valueType
;
616 const char * operatorSymbol
;
618 UnaryPrefixNotApplicable( const Ast::SourceLocation
& _loc
, const Ast::Expression
* _expr
, RefCountPtr
< const char > _valueType
);
619 virtual ~UnaryPrefixNotApplicable( );
620 void setOperatorSymbol( const char * _operatorSymbol
);
621 virtual void display( std::ostream
& os
) const;
624 class UnaryPostfixNotApplicable
: public RuntimeError
626 const Ast::Expression
* expr
;
627 RefCountPtr
< const char > valueType
;
628 const char * operatorSymbol
;
630 UnaryPostfixNotApplicable( const Ast::SourceLocation
& _loc
, const Ast::Expression
* _expr
, RefCountPtr
< const char > _valueType
);
631 virtual ~UnaryPostfixNotApplicable( );
632 void setOperatorSymbol( const char * _operatorSymbol
);
633 virtual void display( std::ostream
& os
) const;
636 class BinaryInfixNotApplicable
: public RuntimeError
638 const Ast::Expression
* expr1
;
639 RefCountPtr
< const char > valueType1
;
640 const Ast::Expression
* expr2
;
641 RefCountPtr
< const char > valueType2
;
642 const char * operatorSymbol
;
644 BinaryInfixNotApplicable( const Ast::SourceLocation
& _loc
, const Ast::Expression
* _expr1
, RefCountPtr
< const char > _valueType1
, const Ast::Expression
* _expr2
, RefCountPtr
< const char > _valueType2
);
645 virtual ~BinaryInfixNotApplicable( );
646 void setOperatorSymbol( const char * _operatorSymbol
);
647 virtual void display( std::ostream
& os
) const;
650 class LookupUnknown
: public StaticInconsistency
653 Ast::Identifier::Type type_
;
655 LookupUnknown( const Ast::SourceLocation
& loc
, const Ast::Identifier
& id
, Ast::Identifier::Type type
);
656 virtual ~LookupUnknown( );
657 virtual void display( std::ostream
& os
) const;
660 class LookupUnknownPrivateAlias
: public StaticInconsistency
662 Ast::PlacedIdentifier id_
;
663 Ast::Identifier::Type type_
;
665 LookupUnknownPrivateAlias( const Ast::SourceLocation
& loc
, const Ast::PlacedIdentifier
& id
, Ast::Identifier::Type type
);
666 virtual ~LookupUnknownPrivateAlias( );
667 virtual void display( std::ostream
& os
) const;
670 class StateBeyondFunctionBoundary
: public StaticInconsistency
674 StateBeyondFunctionBoundary( const Ast::SourceLocation
& loc
, const Ast::Identifier
& id
);
675 virtual ~StateBeyondFunctionBoundary( );
676 virtual void display( std::ostream
& os
) const;
679 class IntroducingExistingUnit
: public StaticInconsistency
681 RefCountPtr
< const char > id
;
683 IntroducingExistingUnit( const Ast::SourceLocation
& _loc
, RefCountPtr
< const char > _id
);
684 virtual ~IntroducingExistingUnit( );
685 virtual void display( std::ostream
& os
) const;
688 class LookupUnknownUnit
: public StaticInconsistency
690 RefCountPtr
< const char > id
;
692 LookupUnknownUnit( const Ast::SourceLocation
& _loc
, RefCountPtr
< const char > _id
);
693 virtual ~LookupUnknownUnit( );
694 virtual void display( std::ostream
& os
) const;
697 class OutOfRange
: public CatchableError
700 RefCountPtr
< const char > msgMem_
;
702 OutOfRange( RefCountPtr
< const char > msg
);
703 OutOfRange( const char * msg
);
704 OutOfRange( const Ast::SourceLocation
& _loc
, RefCountPtr
< const char > msg
);
705 OutOfRange( const Ast::SourceLocation
& _loc
, const char * msg
);
706 virtual ~OutOfRange( );
707 virtual void display( std::ostream
& os
) const;
708 virtual RefCountPtr
< const Lang::Exception
> clone( const Kernel::ContRef
& cont
) const;
711 class FontProblem
: public CatchableError
713 RefCountPtr
< const Lang::Symbol
> PostScript_name_
;
715 RefCountPtr
< const char > msgMem_
;
718 FontProblem( const RefCountPtr
< const Lang::Symbol
> & PostScript_name
, RefCountPtr
< const char > msg
, bool justAWarning
= false );
719 FontProblem( const RefCountPtr
< const Lang::Symbol
> & PostScript_name
, const char * msg
, bool justAWarning
= false );
720 FontProblem( const RefCountPtr
< const Lang::Symbol
> & PostScript_name
, const Ast::SourceLocation
& _loc
, RefCountPtr
< const char > msg
, bool justAWarning
= false );
721 FontProblem( const RefCountPtr
< const Lang::Symbol
> & PostScript_name
, const Ast::SourceLocation
& _loc
, const char * msg
, bool justAWarning
= false );
722 virtual ~FontProblem( );
723 virtual void display( std::ostream
& os
) const;
724 virtual RefCountPtr
< const Lang::Exception
> clone( const Kernel::ContRef
& cont
) const;
727 class NonVoidStatement
: public RuntimeError
729 RefCountPtr
< const Lang::Value
> val_
;
731 NonVoidStatement( const Ast::SourceLocation
& loc
, RefCountPtr
< const Lang::Value
> val
);
732 virtual ~NonVoidStatement( );
733 virtual void display( std::ostream
& os
) const;
736 class UserArityMismatch
: public RuntimeError
739 enum Type
{ VARIABLE
, STATE
};
741 const Ast::SourceLocation formalsLoc
;
742 const size_t functionArity
;
743 const size_t callArity
;
746 UserArityMismatch( const Ast::SourceLocation _formalsLoc
, size_t _functionArity
, size_t _callArity
, const Type type
);
747 virtual ~UserArityMismatch( );
748 virtual void display( std::ostream
& os
) const;
751 class SinkRequired
: public RuntimeError
754 const Ast::SourceLocation formalsLoc_
;
755 const size_t formalsArity_
;
756 const size_t callArity_
;
758 SinkRequired( const Ast::SourceLocation formalsLoc
, size_t formalsArity
, size_t callArity
);
759 virtual ~SinkRequired( );
760 virtual void display( std::ostream
& os
) const;
763 class NamedFormalMismatch
: public RuntimeError
766 enum Type
{ VARIABLE
, STATE
};
768 const Ast::SourceLocation formalsLoc
;
769 RefCountPtr
< const char > name
;
772 NamedFormalMismatch( const Ast::SourceLocation _formalsLoc
, RefCountPtr
< const char > _name
, Type type
);
773 virtual ~NamedFormalMismatch( );
774 virtual void display( std::ostream
& os
) const;
777 class NamedFormalAlreadySpecified
: public RuntimeError
780 enum Type
{ VARIABLE
, STATE
};
782 const Ast::SourceLocation formalsLoc
;
783 RefCountPtr
< const char > name
;
787 NamedFormalAlreadySpecified( const Ast::SourceLocation _formalsLoc
, RefCountPtr
< const char > _name
, size_t _pos
, Type type
);
788 virtual ~NamedFormalAlreadySpecified( );
789 virtual void display( std::ostream
& os
) const;
792 class MissingArguments
: public RuntimeError
794 const Ast::SourceLocation formalsLoc_
;
795 RefCountPtr
< const std::map
< size_t, RefCountPtr
< const char > > > missingVariables_
;
796 RefCountPtr
< const std::map
< size_t, RefCountPtr
< const char > > > missingStates_
;
798 MissingArguments( const Ast::SourceLocation formalsLoc
, std::map
< size_t, RefCountPtr
< const char > > * missingVariables
, std::map
< size_t, RefCountPtr
< const char > > * missingStates
);
799 ~MissingArguments( );
800 virtual void display( std::ostream
& os
) const;
803 class CoreArityMismatch
: public RuntimeError
806 RefCountPtr
< const char > titleMem
;
807 const size_t functionArityLow
;
808 const size_t functionArityHigh
;
809 const size_t callArity
;
811 CoreArityMismatch( const char * _title
, size_t _functionArity
, size_t _callArity
);
812 CoreArityMismatch( const char * _title
, size_t _functionArityLow
, size_t _functionArityHigh
, size_t _callArity
);
813 CoreArityMismatch( const RefCountPtr
< const char > & _title
, size_t _functionArity
, size_t _callArity
);
814 CoreArityMismatch( const RefCountPtr
< const char > & _title
, size_t _functionArityLow
, size_t _functionArityHigh
, size_t _callArity
);
815 virtual ~CoreArityMismatch( );
816 virtual void display( std::ostream
& os
) const;
819 class CoreNoNamedFormals
: public RuntimeError
822 RefCountPtr
< const char > titleMem
;
824 CoreNoNamedFormals( const char * _title
);
825 CoreNoNamedFormals( const RefCountPtr
< const char > & _title
);
826 virtual ~CoreNoNamedFormals( );
827 virtual void display( std::ostream
& os
) const;
830 class CoreTypeMismatch
: public RuntimeError
833 RefCountPtr
< const char > titleMem_
;
834 const Ast::SourceLocation argLoc_
;
835 RefCountPtr
< const char > valueType_
;
836 RefCountPtr
< const char > expectedType_
;
838 CoreTypeMismatch( const Ast::SourceLocation
& callLoc
,
840 const Ast::SourceLocation
& argLoc
,
841 RefCountPtr
< const char > valueType
,
842 RefCountPtr
< const char > expectedType
);
843 CoreTypeMismatch( const Ast::SourceLocation
& callLoc
,
844 RefCountPtr
< const char > title
,
845 const Ast::SourceLocation
& argLoc
,
846 RefCountPtr
< const char > valueType
,
847 RefCountPtr
< const char > expectedType
);
848 CoreTypeMismatch( const Ast::SourceLocation
& callLoc
,
850 Kernel::Arguments
& args
,
852 RefCountPtr
< const char > expectedType
);
853 CoreTypeMismatch( const Ast::SourceLocation
& callLoc
,
854 RefCountPtr
< const char > title
,
855 Kernel::Arguments
& args
,
857 RefCountPtr
< const char > expectedType
);
858 virtual ~CoreTypeMismatch( );
859 virtual void display( std::ostream
& os
) const;
862 class CoreDynamicTypeMismatch
: public RuntimeError
865 RefCountPtr
< const char > titleMem_
;
866 Ast::PlacedIdentifier id_
;
867 RefCountPtr
< const char > idMem_
;
868 RefCountPtr
< const char > valueType_
;
869 RefCountPtr
< const char > expectedType_
;
871 CoreDynamicTypeMismatch( const Ast::SourceLocation
& callLoc
,
873 const Ast::PlacedIdentifier
& id
,
874 RefCountPtr
< const char > valueType
,
875 RefCountPtr
< const char > expectedType
);
876 virtual ~CoreDynamicTypeMismatch( );
877 virtual void display( std::ostream
& os
) const;
880 class CoreStateTypeMismatch
: public RuntimeError
883 RefCountPtr
< const char > titleMem_
;
884 const Ast::SourceLocation argLoc_
;
885 RefCountPtr
< const char > valueType_
;
886 RefCountPtr
< const char > expectedType_
;
888 CoreStateTypeMismatch( const Ast::SourceLocation
& callLoc
,
890 const Ast::SourceLocation
& argLoc
,
891 RefCountPtr
< const char > valueType
,
892 RefCountPtr
< const char > expectedType
);
893 CoreStateTypeMismatch( const Ast::SourceLocation
& callLoc
,
894 RefCountPtr
< const char > title
,
895 const Ast::SourceLocation
& argLoc
,
896 RefCountPtr
< const char > valueType
,
897 RefCountPtr
< const char > expectedType
);
898 CoreStateTypeMismatch( const Ast::SourceLocation
& callLoc
,
900 Kernel::Arguments
& args
,
902 RefCountPtr
< const char > expectedType
);
903 CoreStateTypeMismatch( const Ast::SourceLocation
& callLoc
,
904 RefCountPtr
< const char > title
,
905 Kernel::Arguments
& args
,
907 RefCountPtr
< const char > expectedType
);
908 virtual ~CoreStateTypeMismatch( );
909 virtual void display( std::ostream
& os
) const;
912 class ContinuationTypeMismatch
: public RuntimeError
914 RefCountPtr
< const char > valueType_
;
915 RefCountPtr
< const char > expectedType_
;
917 ContinuationTypeMismatch( const Kernel::Continuation
* locationCont
,
918 RefCountPtr
< const char > valueType
,
919 RefCountPtr
< const char > expectedType
);
920 virtual ~ContinuationTypeMismatch( );
921 virtual void display( std::ostream
& os
) const;
924 class CoreOutOfRange
: public CatchableError
928 const Ast::SourceLocation argLoc_
;
930 RefCountPtr
< const char > msgMem_
;
932 CoreOutOfRange( const char * title
, Kernel::Arguments
& args
, size_t argNo
, RefCountPtr
< const char > msg
);
933 CoreOutOfRange( const char * title
, Kernel::Arguments
& args
, size_t argNo
, const char * msg
);
934 virtual ~CoreOutOfRange( );
935 virtual void display( std::ostream
& os
) const;
936 virtual RefCountPtr
< const Lang::Exception
> clone( const Kernel::ContRef
& cont
) const;
939 class UserOutOfRange
: public CatchableError
941 RefCountPtr
< const Lang::Symbol
> kind_
;
942 RefCountPtr
< const Lang::String
> source_
;
943 RefCountPtr
< const Lang::Integer
> details_
;
944 RefCountPtr
< const char > message_
;
946 UserOutOfRange( const RefCountPtr
< const Lang::Symbol
> & kind
, const RefCountPtr
< const Lang::String
> & source
, const RefCountPtr
< const Lang::Integer
> & details
, const RefCountPtr
< const char > & message
);
947 virtual ~UserOutOfRange( );
948 virtual void display( std::ostream
& os
) const;
949 virtual RefCountPtr
< const Lang::Exception
> clone( const Kernel::ContRef
& cont
) const;
952 class UserTypeMismatch
: public CatchableError
954 RefCountPtr
< const Lang::Symbol
> kind_
;
955 RefCountPtr
< const Lang::String
> source_
;
956 RefCountPtr
< const Lang::Integer
> details_
;
957 RefCountPtr
< const char > expectedType_
;
958 RefCountPtr
< const char > valueType_
;
960 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
);
961 virtual ~UserTypeMismatch( );
962 virtual void display( std::ostream
& os
) const;
963 virtual RefCountPtr
< const Lang::Exception
> clone( const Kernel::ContRef
& cont
) const;
966 class CoreRequirement
: public CatchableError
970 RefCountPtr
< const char > msgMem_
;
972 CoreRequirement( RefCountPtr
< const char > msg
, const char * title
, const Ast::SourceLocation
& callLoc
);
973 CoreRequirement( const char * msg
, const char * title
, const Ast::SourceLocation
& callLoc
);
974 virtual ~CoreRequirement( );
975 virtual void display( std::ostream
& os
) const;
976 virtual RefCountPtr
< const Lang::Exception
> clone( const Kernel::ContRef
& cont
) const;
979 class BuildRequirement
: public CatchableError
982 const char * dependency_
;
984 BuildRequirement( const char * dependency
, const char * title
, const Ast::SourceLocation
& callLoc
);
985 virtual ~BuildRequirement( );
986 virtual void display( std::ostream
& os
) const;
987 virtual RefCountPtr
< const Lang::Exception
> clone( const Kernel::ContRef
& cont
) const;
990 class TeXLabelError
: public RuntimeError
992 const Ast::SourceLocation strLoc_
;
994 const char * region_
;
995 RefCountPtr
< const char > summary_
;
996 RefCountPtr
< const char > details_
;
998 TeXLabelError( bool quoted
, const char * region
, RefCountPtr
< const char > summary
, RefCountPtr
< const char > details
, const Ast::SourceLocation
& strLoc
);
999 virtual ~TeXLabelError( );
1000 virtual void display( std::ostream
& os
) const;
1001 virtual Interaction::ExitCode
exitCode( ) const { return Interaction::EXIT_TEX_ERROR
; }
1004 class StaticTeXLabelError
: public StaticInconsistency
1007 const char * region_
;
1008 RefCountPtr
< const char > summary_
;
1009 RefCountPtr
< const char > details_
;
1011 StaticTeXLabelError( bool quoted
, const char * region
, RefCountPtr
< const char > summary
, RefCountPtr
< const char > details
, const Ast::SourceLocation
& strLoc
);
1012 virtual ~StaticTeXLabelError( );
1013 virtual void display( std::ostream
& os
) const;
1014 virtual Interaction::ExitCode
exitCode( ) const { return Interaction::EXIT_TEX_ERROR
; }
1017 class MultipleDynamicBind
: public RuntimeError
1019 const Ast::PlacedIdentifier
* id_
;
1020 Ast::SourceLocation prevLoc_
;
1022 MultipleDynamicBind( const Ast::PlacedIdentifier
* id
, const Ast::SourceLocation
& loc
, const Ast::SourceLocation
& prevLoc
);
1023 virtual ~MultipleDynamicBind( );
1024 virtual void display( std::ostream
& os
) const;
1027 class UndefinedEscapeContinuation
: public RuntimeError
1031 UndefinedEscapeContinuation( const char * id
, const Ast::SourceLocation
& loc
);
1032 virtual ~UndefinedEscapeContinuation( );
1033 virtual void display( std::ostream
& os
) const;
1036 class DeadStateAccess
: public RuntimeError
1040 virtual ~DeadStateAccess( );
1041 virtual void display( std::ostream
& os
) const;
1044 class UnFreezable
: public RuntimeError
1048 virtual ~UnFreezable( );
1049 virtual void display( std::ostream
& os
) const;
1052 class UnPeekable
: public RuntimeError
1056 virtual ~UnPeekable( );
1057 virtual void display( std::ostream
& os
) const;
1060 class UninitializedAccess
: public RuntimeError
1063 UninitializedAccess( );
1064 virtual ~UninitializedAccess( );
1065 virtual void display( std::ostream
& os
) const;
1068 class DtMinError
: public CatchableError
1072 DtMinError( double _dt
);
1073 virtual ~DtMinError( );
1074 virtual void display( std::ostream
& os
) const;
1075 virtual RefCountPtr
< const Lang::Exception
> clone( const Kernel::ContRef
& cont
) const;
1076 virtual Interaction::ExitCode
exitCode( ) const { return Interaction::EXIT_TOLERANCE_ERROR
; }
1079 class AffineTransformKillsPlane
: public CatchableError
1083 AffineTransformKillsPlane( double sigma2
);
1084 virtual ~AffineTransformKillsPlane( );
1085 virtual void display( std::ostream
& os
) const;
1086 virtual RefCountPtr
< const Lang::Exception
> clone( const Kernel::ContRef
& cont
) const;
1089 class MissingFontMetrics
: public RuntimeError
1091 RefCountPtr
< const char > fontname_
;
1092 const std::list
< std::string
> * searchPath_
;
1094 MissingFontMetrics( RefCountPtr
< const char > fontname
, const std::list
< std::string
> * searchPath
);
1095 virtual ~MissingFontMetrics( );
1096 virtual void display( std::ostream
& os
) const;
1097 virtual Interaction::ExitCode
exitCode( ) const { return Interaction::EXIT_EXTERNAL_ERROR
; }
1100 class FontMetricsError
: public RuntimeError
1102 RefCountPtr
< const char > fontname_
;
1103 RefCountPtr
< const char > message_
;
1105 FontMetricsError( const RefCountPtr
< const char > & fontname
, const RefCountPtr
< const char > & message
);
1106 virtual ~FontMetricsError( );
1107 virtual void display( std::ostream
& os
) const;
1108 virtual Interaction::ExitCode
exitCode( ) const { return Interaction::EXIT_EXTERNAL_ERROR
; }
1111 class InsertingEmptyPage
: public CatchableError
1114 InsertingEmptyPage( const Ast::SourceLocation
& loc
);
1115 virtual ~InsertingEmptyPage( );
1116 virtual void display( std::ostream
& os
) const;
1117 virtual RefCountPtr
< const Lang::Exception
> clone( const Kernel::ContRef
& cont
) const;
1120 class UndefinedCrossRef
: public PostCondition
1123 RefCountPtr
< const char > ref_
;
1125 UndefinedCrossRef( const Ast::SourceLocation
& _loc
, RefCountPtr
< const char > ref
);
1126 virtual ~UndefinedCrossRef( );
1127 virtual void display( std::ostream
& os
) const;
1130 class InvocationError
: public Exception
1135 InvocationError( const char * msg
, bool justAWarning
= false );
1136 virtual ~InvocationError( );
1137 virtual void display( std::ostream
& os
) const;
1138 virtual Interaction::ExitCode
exitCode( ) const { return Interaction::EXIT_INVOCATION_ERROR
; }
1143 namespace NonLocalExit
1145 // The exceptions in this namespace does not represent ordinary exception conditions in the program.
1146 // Rather, they can be seen as alternative ways for particular functions to return. Thus, the caller
1147 // of such a function shall always take care of any such exceptions, and not let these be passed up.
1148 // For this reason, the classes in this namespace does not inherit from Shapes::Exceptions::Exception.
1150 class NonLocalExitBase
1153 NonLocalExitBase( ){ }
1156 class DynamicBindingNotFound
: public NonLocalExitBase
1159 DynamicBindingNotFound( ){ }
1162 class CrossDirectionOfParallel
: public NonLocalExitBase
1165 CrossDirectionOfParallel( ){ }
1168 class NotThisType
: public NonLocalExitBase