123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869(******************************************************************************)(* 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. *)(******************************************************************************)openASTopenASTUtilsmoduleSEnv=StaticEnvlet(|:)=Instrumentation.TypingNoInstr.use_withmoduleInterpConf=structmoduleInstr=Instrumentation.SemanticsNoInstrletunroll=0leterror_handling_time=Error.StaticendmoduleSB=Native.StaticBackendmoduleSI=Interpreter.Make(Native.StaticBackend)(InterpConf)leteval_from~locenve=trySI.eval_exprenvewith|Error.(ASLException{pos_start;pos_end;desc;_})whenpos_start==dummy_pos&&pos_end==dummy_pos->Error.fatal_fromlocdesc(* Begin StaticEval *)letstatic_eval(senv:SEnv.env)(e:expr):literal=letenv=letopenSI.IEnvinletglobal=global_from_staticsenv.global~storage:(Storage.mapSB.v_of_literalsenv.SEnv.global.constant_values)andlocal=local_empty_scoped(SB.Scope.global~init:true)~storage:(Storage.mapSB.v_of_literalsenv.SEnv.local.constant_values)in{global;local}inmatcheval_from~loc:eenvewith|SI.Normal(Native.NV_Literall,_env)->l|:Instrumentation.TypingRule.StaticEval|SI.Normal_|SI.Throwing_->Error.fatal_frome(UnsupportedExpr(Static,e))(* End *)letstatic_eval_to_intenve=matchstatic_evalenvewithL_Intz->Z.to_intz|_->assertfalse