Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file error.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239(******************************************************************************)(* ASLRef *)(******************************************************************************)(*
* SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
* SPDX-License-Identifier: BSD-3-Clause
*)(******************************************************************************)(* Disclaimer: *)(* This material covers both ASLv0 (viz, the existing ASL pseudocode language *)(* which appears in the Arm Architecture Reference Manual) and ASLv1, a new, *)(* experimental, and as yet unreleased version of ASL. *)(* This material is work in progress, more precisely at pre-Alpha quality as *)(* per Arm’s quality standards. *)(* In particular, this means that it would be premature to base any *)(* production tool development on this material. *)(* However, any feedback, question, query and feature request would be most *)(* welcome; those can be sent to Arm’s Architecture Formal Team Lead *)(* Jade Alglave <jade.alglave@arm.com>, or by raising issues or PRs to the *)(* herdtools7 github repository. *)(******************************************************************************)openAST(** Error handling for {!Asllib}. *)typeerror_handling_time=Static|Dynamictypeerror_desc=|BadFieldofstring*ty|MissingFieldofstringlist*ty|BadSlicesoferror_handling_time*slicelist*int|TypeInferenceNeeded|UndefinedIdentifierofidentifier|MismatchedReturnValueofstring|BadArityofidentifier*int*int|UnsupportedBinopofbinop*literal*literal|UnsupportedUnopofunop*literal|UnsupportedExprofexpr|MismatchTypeofstring*type_desclist|NotYetImplementedofstring|ConflictingTypesoftype_desclist*ty|AssertionFailedofexpr|CannotParse|UnknownSymbol|NoCallCandidateofstring*tylist|TooManyCallCandidatesofstring*tylist|BadTypesForBinopofbinop*ty*ty|CircularDeclarationsofstring|UnpureExpressionofexpr|UnreconciliableTypesofty*ty|AssignToImmutableofstring|AlreadyDeclaredIdentifierofstring|BadReturnStmtoftyoption|UnexpectedSideEffectofstring|UncaughtExceptionofstring|OverlappingSlicesofslicelist|BadLDIofAST.local_decl_item|BadRecursiveDeclsofidentifierlist|UnrespectedParserInvariant|ConstrainedIntegerExpectedofty|ParameterWithoutDeclofidentifier|BaseValueEmptyTypeoftytypeerror=error_descannotatedexceptionASLExceptionoferrortype'aresult=('a,error)Result.tletfatale=raise(ASLExceptione)letfatal_frompose=fatal(ASTUtils.add_pos_frompose)letfatal_herepos_startpos_ende=fatal(ASTUtils.annotatedepos_startpos_end)letfatal_unknown_pose=fatal(ASTUtils.add_dummy_pose)letinterceptf()=tryOk(f())withASLExceptione->Erroreleterror_handling_time_to_string=function|Static->"Static"|Dynamic->"Dynamic"letpp_error=letopenFormatinletopenPPinletpp_comma_listpp_eltfli=pp_print_list~pp_sep:(funf()->fprintff",@ ")pp_eltfliinletpp_type_descfty=pp_tyf(ASTUtils.add_dummy_posty)infunfe->pp_open_vboxf0;ife.pos_end!=Lexing.dummy_pos&&e.pos_start!=Lexing.dummy_posthenfprintff"@[<h>%a:@]@ "pp_pose;pp_open_hovboxf2;(matche.descwith|UnsupportedBinop(op,v1,v2)->fprintff"ASL Execution error: Illegal application of operator %s for values@ \
%a@ and %a."(binop_to_stringop)pp_literalv1pp_literalv2|UnsupportedUnop(op,v)->fprintff"ASL Execution error: Illegal application of operator %s for value@ \
%a."(unop_to_stringop)pp_literalv|UnsupportedExpre->fprintff"ASL Error: Unsupported expression %a."pp_expre|MismatchType(v,[ty])->fprintff"ASL Execution error: Mismatch type:@ value %s does not belong to \
type %a."vpp_type_descty|MismatchType(v,li)->fprintff"ASL Execution error: Mismatch type:@ value %s@ does not subtype any \
of those types:@ %a"v(pp_comma_listpp_type_desc)li|BadField(s,ty)->fprintff"ASL Error: There are no field '%s'@ on type %a."spp_tyty|MissingField(fields,ty)->fprintff"ASL Error: Fields mismatch for creating a value of type %a@ -- \
Passed fields are:@ %a"pp_tyty(pp_print_list~pp_sep:pp_print_spacepp_print_string)fields|BadSlices(t,slices,length)->fprintff"ASL %s error: Cannot extract from bitvector of length %d slices %a."(error_handling_time_to_stringt)lengthpp_slice_listslices|TypeInferenceNeeded->pp_print_textf"ASL Internal error: Interpreter blocked. Type inference needed."|UndefinedIdentifiers->fprintff"ASL Error: Undefined identifier:@ '%s'"s|MismatchedReturnValues->fprintff"ASL Error: Mismatched use of return value from call to '%s'"s|BadArity(name,expected,provided)->fprintff"ASL Error: Arity error while calling '%s':@ %d arguments expected \
and %d provided"nameexpectedprovided|NotYetImplementeds->pp_print_textf@@"ASL Internal error: Not yet implemented: "^s|ConflictingTypes([expected],provided)->fprintff"ASL Typing error:@ a subtype of@ %a@ was expected,@ provided %a."pp_type_descexpectedpp_typrovided|ConflictingTypes(expected,provided)->fprintff"ASL Typing error:@ %a does@ not@ subtype@ any@ of:@ %a."pp_typrovided(pp_comma_listpp_type_desc)expected|AssertionFailede->fprintff"ASL Execution error: Assertion failed:@ %a"pp_expre|CannotParse->pp_print_stringf"ASL Error: Cannot parse."|UnknownSymbol->pp_print_stringf"ASL Error: Unknown symbol."|NoCallCandidate(name,types)->fprintff"ASL Typing error: No subprogram declaration matches the \
invocation:@ %s(%a)"name(pp_comma_listpp_ty)types|TooManyCallCandidates(name,types)->fprintff"ASL Typing error: Too many subprogram declaration match the \
invocation:@ %s(%a)"name(pp_comma_listpp_ty)types|BadTypesForBinop(op,t1,t2)->fprintff"ASL Typing error: Illegal application of operator %s on types@ %a@ \
and %a"(binop_to_stringop)pp_tyt1pp_tyt2|CircularDeclarationsx->fprintff"ASL Evaluation error: circular definition of constants, including \
%S."x|UnpureExpressione->fprintff"ASL Typing error:@ a pure expression was expected,@ found@ %a"pp_expre|UnreconciliableTypes(t1,t2)->fprintff"ASL Typing error:@ cannot@ find@ a@ common@ ancestor@ to@ those@ \
two@ types@ %a@ and@ %a."pp_tyt1pp_tyt2|AssignToImmutablex->fprintff"ASL Typing error:@ cannot@ assign@ to@ immutable@ storage@ %S."x|AlreadyDeclaredIdentifierx->fprintff"ASL Typing error:@ cannot@ declare@ already@ declared@ element@ %S."x|BadReturnStmtNone->fprintff"ASL Typing error:@ cannot@ return@ something@ from@ a@ procedure."|UnexpectedSideEffects->fprintff"Unexpected side-effect: %s"s|UncaughtExceptions->fprintff"Uncaught exception: %s"s|OverlappingSlicesslices->fprintff"ASL Typing error:@ overlapping slices@ @[%a@]."pp_slice_listslices|BadLDIldi->fprintff"Unsupported declaration:@ @[%a@]."pp_local_decl_itemldi|BadRecursiveDeclsdecls->fprintff"ASL Typing error:@ multiple recursive declarations:@ @[%a@]"(pp_comma_list(funf->fprintff"%S"))decls|UnrespectedParserInvariant->fprintff"Parser invariant broke."|ConstrainedIntegerExpectedt->fprintff"ASL Typing error:@ constrained@ integer@ expected,@ provided@ %a"pp_tyt|ParameterWithoutDecls->fprintff"ASL Typing error:@ explicit@ parameter@ %S@ does@ not@ have@ a@ \
corresponding@ defining@ argument"s|BaseValueEmptyTypet->fprintff"ASL Execution error: base value of empty type %a"pp_tyt|BadReturnStmt(Somet)->fprintff"ASL Typing error:@ cannot@ return@ nothing@ from@ a@ function,@ an@ \
expression@ of@ type@ %a@ is@ expected."pp_tyt);pp_close_boxf();pp_close_boxf()leterror_to_string=Format.asprintf"%a"pp_errorleteprintln=Format.eprintf"@[<2>%a@]@."pp_errorlet()=Printexc.register_printer@@function|ASLExceptione->Some(error_to_stringe)|_->None