From 97fb61d23cf04a909145ecb28946d1297d947ef4 Mon Sep 17 00:00:00 2001
From: Philip Tasche
Date: Mon, 27 May 2024 15:28:58 +0200
Subject: [PATCH 01/23] Made representation of multi-intervals deterministic
Splitting states into certain components if possible to factor out uncertainties into the state space
Ignore indexed variables with negative index
Created the infrastructure for static scanning for relevant variables
---
src/col/vct/col/ast/Deserialize.scala | 7 +-
src/col/vct/col/ast/Node.scala | 4602 +++++++++++++----
src/col/vct/col/ast/Serialize.scala | 9 +-
.../col/ast/declaration/DeclarationImpl.scala | 42 +-
.../ast/declaration/adt/ADTAxiomImpl.scala | 17 +-
.../declaration/adt/ADTDeclarationImpl.scala | 3 +-
.../ast/declaration/adt/ADTFunctionImpl.scala | 25 +-
.../category/AbstractFunctionImpl.scala | 3 +-
.../category/AbstractMethodImpl.scala | 13 +-
.../category/AbstractPredicateImpl.scala | 3 +-
.../declaration/category/ApplicableImpl.scala | 7 +-
.../category/ContractApplicableImpl.scala | 10 +-
.../ast/declaration/category/FieldImpl.scala | 3 +-
.../category/InlineableApplicableImpl.scala | 3 +-
.../declaration/cls/BipComponentImpl.scala | 3 +-
.../declaration/cls/BipConstructorImpl.scala | 3 +-
.../col/ast/declaration/cls/BipDataImpl.scala | 3 +-
.../ast/declaration/cls/BipGuardImpl.scala | 10 +-
.../col/ast/declaration/cls/BipPortImpl.scala | 11 +-
.../cls/BipStatePredicateImpl.scala | 7 +-
.../declaration/cls/BipTransitionImpl.scala | 30 +-
.../cls/ClassDeclarationImpl.scala | 5 +-
.../declaration/cls/InstanceFieldImpl.scala | 5 +-
.../cls/InstanceFunctionImpl.scala | 21 +-
.../declaration/cls/InstanceMethodImpl.scala | 86 +-
.../cls/InstanceOperatorFunctionImpl.scala | 15 +-
.../cls/InstanceOperatorMethodImpl.scala | 16 +-
.../cls/InstancePredicateImpl.scala | 25 +-
.../ast/declaration/cls/RunMethodImpl.scala | 3 +-
.../declaration/cls/VeSUVMainMethodImpl.scala | 6 +-
.../global/AxiomaticDataTypeImpl.scala | 39 +-
.../global/BipPortSynchronizationImpl.scala | 25 +-
.../BipTransitionSynchronizationImpl.scala | 26 +-
.../declaration/global/ChoreographyImpl.scala | 35 +-
.../ast/declaration/global/ClassImpl.scala | 46 +-
.../ast/declaration/global/FunctionImpl.scala | 46 +-
.../global/GlobalDeclarationImpl.scala | 5 +-
.../declaration/global/HeapVariableImpl.scala | 17 +-
.../global/JavaBipGlueContainerImpl.scala | 6 +-
.../ast/declaration/global/ModelImpl.scala | 8 +-
.../global/PVLChoreographyImpl.scala | 9 +-
.../declaration/global/PredicateImpl.scala | 36 +-
.../declaration/global/ProcedureImpl.scala | 62 +-
.../global/ProverFunctionImpl.scala | 3 +-
.../declaration/global/ProverTypeImpl.scala | 3 +-
.../global/SimplificationRuleImpl.scala | 9 +-
.../declaration/model/ModelActionImpl.scala | 18 +-
.../model/ModelDeclarationImpl.scala | 3 +-
.../declaration/model/ModelFieldImpl.scala | 8 +-
.../declaration/model/ModelProcessImpl.scala | 26 +-
.../singular/BipTransitionSignatureImpl.scala | 17 +-
.../declaration/singular/EndpointImpl.scala | 11 +-
.../declaration/singular/LabelDeclImpl.scala | 5 +-
.../singular/ParBlockDeclImpl.scala | 6 +-
.../singular/ParInvariantDeclImpl.scala | 6 +-
.../declaration/singular/SendDeclImpl.scala | 3 +-
.../declaration/singular/VariableImpl.scala | 20 +-
src/col/vct/col/ast/expr/ExprImpl.scala | 34 +-
.../AmbiguousComputationalAndImpl.scala | 5 +-
.../AmbiguousComputationalOrImpl.scala | 5 +-
.../AmbiguousComputationalXorImpl.scala | 5 +-
.../expr/ambiguous/AmbiguousMemberImpl.scala | 33 +-
.../expr/ambiguous/AmbiguousMinusImpl.scala | 12 +-
.../expr/ambiguous/AmbiguousMultImpl.scala | 14 +-
.../ast/expr/ambiguous/AmbiguousOrImpl.scala | 11 +-
.../expr/ambiguous/AmbiguousPlusImpl.scala | 56 +-
.../ambiguous/AmbiguousSubscriptImpl.scala | 46 +-
.../apply/ADTFunctionInvocationImpl.scala | 37 +-
.../col/ast/expr/apply/ActionApplyImpl.scala | 5 +-
.../apply/AnyFunctionInvocationImpl.scala | 5 +-
.../expr/apply/AnyMethodInvocationImpl.scala | 5 +-
.../expr/apply/ApplyAnyPredicateImpl.scala | 5 +-
.../vct/col/ast/expr/apply/ApplyImpl.scala | 5 +-
.../ast/expr/apply/ApplyInlineableImpl.scala | 5 +-
.../CoalesceInstancePredicateApplyImpl.scala | 9 +-
.../expr/apply/FunctionInvocationImpl.scala | 21 +-
.../ast/expr/apply/InstanceApplyImpl.scala | 3 +-
.../InstanceFunctionInvocationImpl.scala | 10 +-
.../apply/InstancePredicateApplyImpl.scala | 8 +-
.../col/ast/expr/apply/InvocationImpl.scala | 5 +-
.../ast/expr/apply/MethodInvocationImpl.scala | 22 +-
.../ast/expr/apply/PredicateApplyImpl.scala | 21 +-
.../expr/apply/ProcedureInvocationImpl.scala | 17 +-
.../col/ast/expr/apply/ProcessApplyImpl.scala | 5 +-
.../apply/ProverFunctionInvocationImpl.scala | 8 +-
.../vct/col/ast/expr/binder/BinderImpl.scala | 5 +-
.../vct/col/ast/expr/binder/ExistsImpl.scala | 24 +-
.../vct/col/ast/expr/binder/ForPermImpl.scala | 22 +-
.../expr/binder/ForPermWithValueImpl.scala | 3 +-
.../vct/col/ast/expr/binder/ForallImpl.scala | 22 +-
src/col/vct/col/ast/expr/binder/LetImpl.scala | 23 +-
.../vct/col/ast/expr/binder/ProductImpl.scala | 3 +-
.../vct/col/ast/expr/binder/StarallImpl.scala | 22 +-
src/col/vct/col/ast/expr/binder/SumImpl.scala | 3 +-
.../ast/expr/bip/BipGuardInvocationImpl.scala | 3 +-
.../expr/bip/BipLocalIncomingDataImpl.scala | 3 +-
.../col/ast/expr/bip/JavaBipGlueImpl.scala | 6 +-
.../expr/context/AmbiguousResultImpl.scala | 74 +-
.../ast/expr/context/AmbiguousThisImpl.scala | 17 +-
.../expr/context/CurrentThreadIdImpl.scala | 5 +-
.../ast/expr/context/GlobalThreadIdImpl.scala | 3 +-
.../ast/expr/context/LocalThreadIdImpl.scala | 3 +-
.../vct/col/ast/expr/context/ResultImpl.scala | 20 +-
.../expr/context/ThisChoreographyImpl.scala | 6 +-
.../expr/context/ThisDeclarationImpl.scala | 9 +-
.../col/ast/expr/context/ThisModelImpl.scala | 5 +-
.../col/ast/expr/context/ThisObjectImpl.scala | 18 +-
.../vct/col/ast/expr/heap/SizeOfImpl.scala | 8 +-
.../ast/expr/heap/alloc/FreePointerImpl.scala | 5 +-
.../ast/expr/heap/alloc/NewArrayImpl.scala | 11 +-
.../ast/expr/heap/alloc/NewObjectImpl.scala | 5 +-
.../expr/heap/alloc/NewPointerArrayImpl.scala | 5 +-
.../col/ast/expr/heap/read/AddrOfImpl.scala | 8 +-
.../expr/heap/read/ArraySubscriptImpl.scala | 5 +-
.../heap/read/DerefHeapVariableImpl.scala | 3 +-
.../col/ast/expr/heap/read/DerefImpl.scala | 8 +-
.../ast/expr/heap/read/DerefPointerImpl.scala | 8 +-
.../ast/expr/heap/read/EndpointNameImpl.scala | 3 +-
.../ast/expr/heap/read/FunctionOfImpl.scala | 6 +-
.../ast/expr/heap/read/HeapDerefImpl.scala | 5 +-
.../col/ast/expr/heap/read/LengthImpl.scala | 8 +-
.../ast/expr/heap/read/ModelDerefImpl.scala | 5 +-
.../col/ast/expr/heap/read/NdIndexImpl.scala | 7 +-
.../col/ast/expr/heap/read/NdLengthImpl.scala | 3 +-
.../expr/heap/read/NdPartialIndexImpl.scala | 8 +-
.../ast/expr/heap/read/PointerAddImpl.scala | 8 +-
.../heap/read/PointerBlockLengthImpl.scala | 5 +-
.../heap/read/PointerBlockOffsetImpl.scala | 3 +-
.../expr/heap/read/PointerLengthImpl.scala | 3 +-
.../expr/heap/read/PointerSubscriptImpl.scala | 5 +-
.../col/ast/expr/heap/read/ValuesImpl.scala | 5 +-
.../expr/literal/build/EitherLeftImpl.scala | 8 +-
.../expr/literal/build/EitherRightImpl.scala | 8 +-
.../expr/literal/build/LiteralBagImpl.scala | 5 +-
.../expr/literal/build/LiteralMapImpl.scala | 9 +-
.../expr/literal/build/LiteralSeqImpl.scala | 5 +-
.../expr/literal/build/LiteralSetImpl.scala | 5 +-
.../expr/literal/build/LiteralTupleImpl.scala | 12 +-
.../literal/build/LiteralVectorImpl.scala | 8 +-
.../expr/literal/build/OptNoneTypedImpl.scala | 5 +-
.../ast/expr/literal/build/OptSomeImpl.scala | 5 +-
.../expr/literal/build/OptSomeTypedImpl.scala | 5 +-
.../ast/expr/literal/build/RangeImpl.scala | 8 +-
.../literal/build/UntypedLiteralBagImpl.scala | 5 +-
.../literal/build/UntypedLiteralSeqImpl.scala | 5 +-
.../literal/build/UntypedLiteralSetImpl.scala | 5 +-
.../expr/literal/constant/AutoValueImpl.scala | 3 +-
.../literal/constant/BooleanValueImpl.scala | 37 +-
.../expr/literal/constant/ConstantImpl.scala | 12 +-
.../literal/constant/ConstantIntImpl.scala | 3 +-
.../literal/constant/EmptyProcessImpl.scala | 5 +-
.../literal/constant/FloatValueImpl.scala | 6 +-
.../expr/literal/constant/NoPermImpl.scala | 5 +-
.../ast/expr/literal/constant/NullImpl.scala | 5 +-
.../expr/literal/constant/OptNoneImpl.scala | 5 +-
.../expr/literal/constant/ReadPermImpl.scala | 14 +-
.../ast/expr/literal/constant/VoidImpl.scala | 5 +-
.../expr/literal/constant/WritePermImpl.scala | 5 +-
.../vct/col/ast/expr/lock/CommittedImpl.scala | 3 +-
src/col/vct/col/ast/expr/lock/HeldImpl.scala | 5 +-
.../vct/col/ast/expr/lock/IdleTokenImpl.scala | 5 +-
.../vct/col/ast/expr/lock/JoinTokenImpl.scala | 5 +-
src/col/vct/col/ast/expr/misc/AnyImpl.scala | 5 +-
.../col/ast/expr/misc/ApplyCoercionImpl.scala | 3 +-
.../vct/col/ast/expr/misc/CharValueImpl.scala | 3 +-
src/col/vct/col/ast/expr/misc/EnumImpl.scala | 14 +-
.../vct/col/ast/expr/misc/EnumUseImpl.scala | 3 +-
.../col/ast/expr/misc/InlinePatternImpl.scala | 19 +-
src/col/vct/col/ast/expr/misc/LocalImpl.scala | 5 +-
src/col/vct/col/ast/expr/misc/OldImpl.scala | 20 +-
.../col/ast/expr/misc/StringValueImpl.scala | 6 +-
.../expr/model/ModelAbstractStateImpl.scala | 10 +-
.../col/ast/expr/model/ModelChooseImpl.scala | 10 +-
.../col/ast/expr/model/ModelCreateImpl.scala | 5 +-
.../col/ast/expr/model/ModelDestroyImpl.scala | 5 +-
.../col/ast/expr/model/ModelMergeImpl.scala | 10 +-
.../vct/col/ast/expr/model/ModelNewImpl.scala | 5 +-
.../col/ast/expr/model/ModelSplitImpl.scala | 10 +-
.../col/ast/expr/model/ModelStateImpl.scala | 9 +-
src/col/vct/col/ast/expr/op/BinExprImpl.scala | 104 +-
src/col/vct/col/ast/expr/op/UnExprImpl.scala | 5 +-
.../vct/col/ast/expr/op/bit/BitAndImpl.scala | 5 +-
.../vct/col/ast/expr/op/bit/BitNotImpl.scala | 11 +-
.../vct/col/ast/expr/op/bit/BitOpImpl.scala | 13 +-
.../vct/col/ast/expr/op/bit/BitOrImpl.scala | 5 +-
.../vct/col/ast/expr/op/bit/BitShlImpl.scala | 5 +-
.../vct/col/ast/expr/op/bit/BitShrImpl.scala | 5 +-
.../vct/col/ast/expr/op/bit/BitUShrImpl.scala | 5 +-
.../vct/col/ast/expr/op/bit/BitXorImpl.scala | 5 +-
.../vct/col/ast/expr/op/bool/AndImpl.scala | 7 +-
.../expr/op/bool/ComputationalAndImpl.scala | 5 +-
.../expr/op/bool/ComputationalOrImpl.scala | 5 +-
.../expr/op/bool/ComputationalXorImpl.scala | 5 +-
.../vct/col/ast/expr/op/bool/NotImpl.scala | 5 +-
src/col/vct/col/ast/expr/op/bool/OrImpl.scala | 5 +-
.../vct/col/ast/expr/op/bool/SelectImpl.scala | 13 +-
.../expr/op/cmp/AmbiguousComparisonImpl.scala | 9 +-
.../col/ast/expr/op/cmp/AmbiguousEqImpl.scala | 3 +-
.../expr/op/cmp/AmbiguousGreaterEqImpl.scala | 5 +-
.../expr/op/cmp/AmbiguousGreaterImpl.scala | 5 +-
.../ast/expr/op/cmp/AmbiguousLessEqImpl.scala | 5 +-
.../ast/expr/op/cmp/AmbiguousLessImpl.scala | 5 +-
.../ast/expr/op/cmp/AmbiguousNeqImpl.scala | 3 +-
.../expr/op/cmp/AmbiguousOrderOpImpl.scala | 3 +-
.../col/ast/expr/op/cmp/ComparisonImpl.scala | 5 +-
src/col/vct/col/ast/expr/op/cmp/EqImpl.scala | 5 +-
.../col/ast/expr/op/cmp/GreaterEqImpl.scala | 3 +-
.../vct/col/ast/expr/op/cmp/GreaterImpl.scala | 3 +-
.../vct/col/ast/expr/op/cmp/LessEqImpl.scala | 3 +-
.../vct/col/ast/expr/op/cmp/LessImpl.scala | 3 +-
.../vct/col/ast/expr/op/cmp/MapCmpImpl.scala | 8 +-
.../col/ast/expr/op/cmp/MapDisjointImpl.scala | 3 +-
.../vct/col/ast/expr/op/cmp/MapEqImpl.scala | 3 +-
src/col/vct/col/ast/expr/op/cmp/NeqImpl.scala | 5 +-
.../vct/col/ast/expr/op/cmp/OrderOpImpl.scala | 5 +-
.../ast/expr/op/cmp/SetComparisonImpl.scala | 5 +-
.../col/ast/expr/op/cmp/SubBagEqImpl.scala | 3 +-
.../vct/col/ast/expr/op/cmp/SubBagImpl.scala | 3 +-
.../col/ast/expr/op/cmp/SubSetEqImpl.scala | 5 +-
.../vct/col/ast/expr/op/cmp/SubSetImpl.scala | 5 +-
.../col/ast/expr/op/cmp/VectorEqImpl.scala | 3 +-
.../col/ast/expr/op/cmp/VectorNeqImpl.scala | 3 +-
.../ast/expr/op/collection/BagAddImpl.scala | 7 +-
.../op/collection/BagLargestCommonImpl.scala | 7 +-
.../op/collection/BagMemberCountImpl.scala | 5 +-
.../ast/expr/op/collection/BagMinusImpl.scala | 7 +-
.../ast/expr/op/collection/ConcatImpl.scala | 9 +-
.../col/ast/expr/op/collection/ConsImpl.scala | 9 +-
.../col/ast/expr/op/collection/DropImpl.scala | 8 +-
.../ast/expr/op/collection/EmptyImpl.scala | 5 +-
.../col/ast/expr/op/collection/HeadImpl.scala | 5 +-
.../expr/op/collection/PermutationImpl.scala | 5 +-
.../ast/expr/op/collection/RemoveAtImpl.scala | 8 +-
.../expr/op/collection/SeqMemberImpl.scala | 15 +-
.../expr/op/collection/SeqSubscriptImpl.scala | 8 +-
.../expr/op/collection/SeqUpdateImpl.scala | 9 +-
.../op/collection/SetIntersectionImpl.scala | 7 +-
.../expr/op/collection/SetMemberImpl.scala | 15 +-
.../ast/expr/op/collection/SetMinusImpl.scala | 7 +-
.../ast/expr/op/collection/SetUnionImpl.scala | 7 +-
.../col/ast/expr/op/collection/SizeImpl.scala | 5 +-
.../ast/expr/op/collection/SliceImpl.scala | 8 +-
.../expr/op/collection/StringConcatImpl.scala | 3 +-
.../col/ast/expr/op/collection/TailImpl.scala | 5 +-
.../col/ast/expr/op/collection/TakeImpl.scala | 8 +-
.../op/collection/VectorSubscriptImpl.scala | 8 +-
.../col/ast/expr/op/either/EitherOpImpl.scala | 5 +-
.../col/ast/expr/op/either/GetLeftImpl.scala | 5 +-
.../col/ast/expr/op/either/GetRightImpl.scala | 5 +-
.../col/ast/expr/op/either/IsLeftImpl.scala | 5 +-
.../col/ast/expr/op/either/IsRightImpl.scala | 5 +-
.../vct/col/ast/expr/op/map/MapConsImpl.scala | 5 +-
.../vct/col/ast/expr/op/map/MapGetImpl.scala | 8 +-
.../col/ast/expr/op/map/MapItemSetImpl.scala | 5 +-
.../col/ast/expr/op/map/MapKeySetImpl.scala | 5 +-
.../col/ast/expr/op/map/MapMemberImpl.scala | 15 +-
.../vct/col/ast/expr/op/map/MapOpImpl.scala | 5 +-
.../col/ast/expr/op/map/MapRemoveImpl.scala | 5 +-
.../col/ast/expr/op/map/MapValueSetImpl.scala | 5 +-
.../ast/expr/op/num/AmbiguousDivImpl.scala | 3 +-
.../op/num/AmbiguousDividingExprImpl.scala | 9 +-
.../ast/expr/op/num/AmbiguousModImpl.scala | 3 +-
.../expr/op/num/AmbiguousTruncDivImpl.scala | 3 +-
.../col/ast/expr/op/num/CastFloatImpl.scala | 3 +-
.../ast/expr/op/num/DividingExprImpl.scala | 5 +-
src/col/vct/col/ast/expr/op/num/ExpImpl.scala | 5 +-
.../col/ast/expr/op/num/FloatDivImpl.scala | 5 +-
.../col/ast/expr/op/num/FloorDivImpl.scala | 5 +-
.../vct/col/ast/expr/op/num/MinusImpl.scala | 5 +-
src/col/vct/col/ast/expr/op/num/ModImpl.scala | 5 +-
.../vct/col/ast/expr/op/num/MultImpl.scala | 5 +-
.../ast/expr/op/num/NumericBinExprImpl.scala | 5 +-
.../vct/col/ast/expr/op/num/PlusImpl.scala | 5 +-
.../vct/col/ast/expr/op/num/RatDivImpl.scala | 5 +-
.../col/ast/expr/op/num/TruncDivImpl.scala | 5 +-
.../col/ast/expr/op/num/TruncModImpl.scala | 5 +-
.../vct/col/ast/expr/op/num/UMinusImpl.scala | 20 +-
.../ast/expr/op/num/VectorBinExprImpl.scala | 5 +-
.../ast/expr/op/num/VectorFloatDivImpl.scala | 3 +-
.../ast/expr/op/num/VectorFloorDivImpl.scala | 3 +-
.../col/ast/expr/op/num/VectorMinusImpl.scala | 3 +-
.../col/ast/expr/op/num/VectorModImpl.scala | 3 +-
.../col/ast/expr/op/num/VectorMultImpl.scala | 3 +-
.../col/ast/expr/op/num/VectorPlusImpl.scala | 3 +-
.../ast/expr/op/num/VectorTruncDivImpl.scala | 3 +-
.../ast/expr/op/num/VectorTruncModImpl.scala | 3 +-
.../col/ast/expr/op/option/OptEmptyImpl.scala | 5 +-
.../col/ast/expr/op/option/OptGetImpl.scala | 5 +-
.../ast/expr/op/option/OptGetOrElseImpl.scala | 11 +-
.../expr/op/process/ProcessChoiceImpl.scala | 5 +-
.../ast/expr/op/process/ProcessParImpl.scala | 5 +-
.../expr/op/process/ProcessSelectImpl.scala | 9 +-
.../ast/expr/op/process/ProcessSeqImpl.scala | 5 +-
.../col/ast/expr/op/tuple/TupGetImpl.scala | 25 +-
.../ast/expr/op/vec/MatrixCompareImpl.scala | 5 +-
.../ast/expr/op/vec/MatrixRepeatImpl.scala | 5 +-
.../col/ast/expr/op/vec/MatrixSumImpl.scala | 5 +-
.../ast/expr/op/vec/VectorCompareImpl.scala | 8 +-
.../ast/expr/op/vec/VectorRepeatImpl.scala | 5 +-
.../col/ast/expr/op/vec/VectorSumImpl.scala | 5 +-
.../ast/expr/resource/ActionPermImpl.scala | 3 +-
.../col/ast/expr/resource/CurPermImpl.scala | 5 +-
.../col/ast/expr/resource/ImpliesImpl.scala | 5 +-
.../col/ast/expr/resource/ModelPermImpl.scala | 5 +-
.../vct/col/ast/expr/resource/PermImpl.scala | 5 +-
.../ast/expr/resource/PermPointerImpl.scala | 5 +-
.../expr/resource/PermPointerIndexImpl.scala | 5 +-
.../col/ast/expr/resource/PointsToImpl.scala | 5 +-
.../expr/resource/PolarityDependentImpl.scala | 10 +-
.../ResourceOfResourceValueImpl.scala | 3 +-
.../ast/expr/resource/ResourceValueImpl.scala | 3 +-
.../expr/resource/ScaleByParBlockImpl.scala | 3 +-
.../vct/col/ast/expr/resource/ScaleImpl.scala | 5 +-
.../vct/col/ast/expr/resource/StarImpl.scala | 15 +-
.../col/ast/expr/resource/UnfoldingImpl.scala | 21 +-
.../ast/expr/resource/ValidArrayImpl.scala | 5 +-
.../ast/expr/resource/ValidMatrixImpl.scala | 5 +-
.../vct/col/ast/expr/resource/ValueImpl.scala | 3 +-
.../vct/col/ast/expr/resource/WandImpl.scala | 15 +-
.../sideeffect/AssignExpressionImpl.scala | 15 +-
.../sideeffect/PostAssignExpressionImpl.scala | 13 +-
.../sideeffect/PreAssignExpressionImpl.scala | 13 +-
.../ast/expr/sideeffect/ScopedExprImpl.scala | 3 +-
.../col/ast/expr/sideeffect/ThenImpl.scala | 5 +-
.../col/ast/expr/sideeffect/WithImpl.scala | 5 +-
src/col/vct/col/ast/expr/type/CastImpl.scala | 15 +-
.../col/ast/expr/type/InstanceOfImpl.scala | 8 +-
.../vct/col/ast/expr/type/SubTypeImpl.scala | 5 +-
.../vct/col/ast/expr/type/SuperTypeImpl.scala | 5 +-
.../ast/expr/type/TypeComparisonImpl.scala | 5 +-
.../vct/col/ast/expr/type/TypeOfImpl.scala | 5 +-
.../vct/col/ast/expr/type/TypeValueImpl.scala | 5 +-
.../AccountedPredicateImpl.scala | 19 +-
.../SplitAccountedPredicateImpl.scala | 3 +-
.../UnitAccountedPredicateImpl.scala | 3 +-
.../family/bipdata/BipIncomingDataImpl.scala | 3 +-
.../family/bipdata/BipOutgoingDataImpl.scala | 8 +-
.../JavaBipGlueAcceptsImpl.scala | 7 +-
.../JavaBipGlueDataWireImpl.scala | 3 +-
.../JavaBipGlueRequiresImpl.scala | 3 +-
.../JavaBipGlueSynchronImpl.scala | 9 +-
.../bipporttype/BipEnforceableImpl.scala | 3 +-
.../family/bipporttype/BipInternalImpl.scala | 3 +-
.../bipporttype/BipSpontaneousImpl.scala | 3 +-
.../family/catchclause/CatchClauseImpl.scala | 6 +-
.../coercion/CoerceBoolResourceImpl.scala | 3 +-
.../coercion/CoerceBoundIntFloatImpl.scala | 3 +-
.../coercion/CoerceBoundIntFracImpl.scala | 3 +-
.../coercion/CoerceBoundIntZFracImpl.scala | 3 +-
.../coercion/CoerceCArrayPointerImpl.scala | 3 +-
.../coercion/CoerceCFloatCIntImpl.scala | 3 +-
.../coercion/CoerceCFloatFloatImpl.scala | 5 +-
.../coercion/CoerceCIntCFloatImpl.scala | 5 +-
.../family/coercion/CoerceCIntIntImpl.scala | 5 +-
.../coercion/CoerceCPPArrayPointerImpl.scala | 5 +-
.../CoerceCPPPrimitiveToColImpl.scala | 7 +-
.../coercion/CoerceCPrimitiveToColImpl.scala | 5 +-
.../coercion/CoerceCVectorVectorImpl.scala | 3 +-
.../coercion/CoerceClassAnyClassImpl.scala | 3 +-
.../CoerceColToCPPPrimitiveImpl.scala | 7 +-
.../coercion/CoerceColToCPrimitiveImpl.scala | 5 +-
.../family/coercion/CoerceFloatRatImpl.scala | 3 +-
.../family/coercion/CoerceFracZFracImpl.scala | 3 +-
.../family/coercion/CoerceIdentityImpl.scala | 3 +-
.../family/coercion/CoerceIntRatImpl.scala | 3 +-
.../CoerceJavaClassAnyClassImpl.scala | 3 +-
.../coercion/CoerceJavaSupportsImpl.scala | 3 +-
.../family/coercion/CoerceJoinUnionImpl.scala | 5 +-
.../family/coercion/CoerceMapBagImpl.scala | 3 +-
.../family/coercion/CoerceMapEitherImpl.scala | 3 +-
.../family/coercion/CoerceMapMapImpl.scala | 3 +-
.../family/coercion/CoerceMapMatrixImpl.scala | 3 +-
.../family/coercion/CoerceMapOptionImpl.scala | 3 +-
.../family/coercion/CoerceMapSeqImpl.scala | 3 +-
.../family/coercion/CoerceMapSetImpl.scala | 3 +-
.../family/coercion/CoerceMapTupleImpl.scala | 3 +-
.../family/coercion/CoerceMapTypeImpl.scala | 3 +-
.../family/coercion/CoerceMapVectorImpl.scala | 3 +-
.../coercion/CoerceNothingSomethingImpl.scala | 3 +-
.../coercion/CoerceNullAnyClassImpl.scala | 3 +-
.../family/coercion/CoerceNullArrayImpl.scala | 3 +-
.../family/coercion/CoerceNullClassImpl.scala | 3 +-
.../family/coercion/CoerceNullEnumImpl.scala | 3 +-
.../coercion/CoerceNullJavaClassImpl.scala | 3 +-
.../coercion/CoerceNullPointerImpl.scala | 3 +-
.../family/coercion/CoerceNullRefImpl.scala | 3 +-
.../family/coercion/CoerceRatZFracImpl.scala | 3 +-
.../CoerceResourceResourceValImpl.scala | 3 +-
.../CoerceResourceValResourceImpl.scala | 3 +-
.../coercion/CoerceSelectUnionImpl.scala | 3 +-
.../coercion/CoerceSomethingAnyImpl.scala | 3 +-
.../CoerceSomethingAnyValueImpl.scala | 3 +-
.../family/coercion/CoerceSupportsImpl.scala | 6 +-
.../coercion/CoerceUnboundIntImpl.scala | 3 +-
.../coercion/CoerceWidenBoundImpl.scala | 5 +-
.../family/coercion/CoerceZFracFracImpl.scala | 3 +-
.../family/coercion/CoerceZFracRatImpl.scala | 3 +-
.../ast/family/coercion/CoercionImpl.scala | 159 +-
.../coercion/CoercionSequenceImpl.scala | 5 +-
.../contract/ApplicableContractImpl.scala | 71 +-
.../ast/family/data/BipGlueAcceptsImpl.scala | 7 +-
.../ast/family/data/BipGlueDataWireImpl.scala | 4 +-
.../ast/family/data/BipGlueRequiresImpl.scala | 7 +-
.../ast/family/data/JavaBipGlueNameImpl.scala | 7 +-
.../decreases/DecreasesClauseAssumeImpl.scala | 6 +-
.../decreases/DecreasesClauseImpl.scala | 3 +-
.../DecreasesClauseNoRecursionImpl.scala | 7 +-
.../decreases/DecreasesClauseTupleImpl.scala | 3 +-
.../ast/family/fieldflag/FieldFlagImpl.scala | 6 +-
.../col/ast/family/fieldflag/FinalImpl.scala | 5 +-
.../family/invoking/InvokingNodeImpl.scala | 3 +-
.../itervariable/IterVariableImpl.scala | 6 +-
.../javavar/JavaVariableDeclarationImpl.scala | 16 +-
.../location/AmbiguousLocationImpl.scala | 3 +-
.../family/location/ArrayLocationImpl.scala | 3 +-
.../family/location/FieldLocationImpl.scala | 9 +-
.../location/HeapVariableLocationImpl.scala | 3 +-
.../location/InLinePatternLocationImpl.scala | 6 +-
.../InstancePredicateLocationImpl.scala | 8 +-
.../ast/family/location/LocationImpl.scala | 21 +-
.../family/location/ModelLocationImpl.scala | 3 +-
.../family/location/PointerLocationImpl.scala | 3 +-
.../location/PredicateLocationImpl.scala | 3 +-
.../location/SilverFieldLocationImpl.scala | 3 +-
.../loopcontract/IterationContractImpl.scala | 5 +-
.../loopcontract/LoopContractImpl.scala | 3 +-
.../loopcontract/LoopInvariantImpl.scala | 13 +-
.../ast/family/parregion/ParBlockImpl.scala | 37 +-
.../family/parregion/ParParallelImpl.scala | 5 +-
.../ast/family/parregion/ParRegionImpl.scala | 8 +-
.../family/parregion/ParSequentialImpl.scala | 5 +-
.../pvlcommunicate/PVLCommunicateImpl.scala | 3 +-
.../pvlcommunicate/PVLEndpointNameImpl.scala | 4 +-
.../ast/family/seqguard/ChorGuardImpl.scala | 3 +-
.../family/seqguard/EndpointGuardImpl.scala | 3 +-
.../family/seqguard/UnpointedGuardImpl.scala | 3 +-
.../col/ast/family/seqrun/ChorRunImpl.scala | 3 +-
.../family/signals/SignalsClauseImpl.scala | 8 +-
.../ast/lang/c/AmbiguousTruncModImpl.scala | 3 +-
.../ast/lang/c/CAbstractDeclarationImpl.scala | 5 +-
.../ast/lang/c/CAlignmentSpecifierImpl.scala | 5 +-
.../c/CAnonymousFunctionDeclaratorImpl.scala | 6 +-
.../col/ast/lang/c/CArrayDeclaratorImpl.scala | 9 +-
src/col/vct/col/ast/lang/c/CAtomicImpl.scala | 5 +-
src/col/vct/col/ast/lang/c/CBoolImpl.scala | 5 +-
src/col/vct/col/ast/lang/c/CCastImpl.scala | 8 +-
src/col/vct/col/ast/lang/c/CCharImpl.scala | 5 +-
src/col/vct/col/ast/lang/c/CConstImpl.scala | 5 +-
.../vct/col/ast/lang/c/CDeclarationImpl.scala | 16 +-
.../lang/c/CDeclarationSpecifierImpl.scala | 5 +-
.../lang/c/CDeclarationStatementImpl.scala | 5 +-
.../vct/col/ast/lang/c/CDeclaratorImpl.scala | 5 +-
src/col/vct/col/ast/lang/c/CDoubleImpl.scala | 7 +-
src/col/vct/col/ast/lang/c/CExprImpl.scala | 5 +-
src/col/vct/col/ast/lang/c/CExternImpl.scala | 5 +-
.../vct/col/ast/lang/c/CFieldAccessImpl.scala | 82 +-
src/col/vct/col/ast/lang/c/CFloatImpl.scala | 7 +-
.../ast/lang/c/CFunctionDefinitionImpl.scala | 9 +-
.../ast/lang/c/CFunctionSpecifierImpl.scala | 5 +-
.../ast/lang/c/CGlobalDeclarationImpl.scala | 8 +-
src/col/vct/col/ast/lang/c/CGotoImpl.scala | 8 +-
.../lang/c/CGpgpuKernelSpecifierImpl.scala | 5 +-
src/col/vct/col/ast/lang/c/CInitImpl.scala | 10 +-
src/col/vct/col/ast/lang/c/CInlineImpl.scala | 5 +-
src/col/vct/col/ast/lang/c/CIntImpl.scala | 5 +-
.../vct/col/ast/lang/c/CInvocationImpl.scala | 57 +-
.../col/ast/lang/c/CLiteralArrayImpl.scala | 8 +-
.../ast/lang/c/CLocalDeclarationImpl.scala | 4 +-
src/col/vct/col/ast/lang/c/CLocalImpl.scala | 68 +-
src/col/vct/col/ast/lang/c/CLongImpl.scala | 5 +-
src/col/vct/col/ast/lang/c/CNameImpl.scala | 5 +-
src/col/vct/col/ast/lang/c/CParamImpl.scala | 5 +-
.../ast/lang/c/CPointerDeclaratorImpl.scala | 5 +-
src/col/vct/col/ast/lang/c/CPointerImpl.scala | 5 +-
.../col/ast/lang/c/CPrimitiveTypeImpl.scala | 5 +-
src/col/vct/col/ast/lang/c/CPureImpl.scala | 5 +-
.../vct/col/ast/lang/c/CRestrictImpl.scala | 5 +-
src/col/vct/col/ast/lang/c/CShortImpl.scala | 5 +-
src/col/vct/col/ast/lang/c/CSignedImpl.scala | 5 +-
.../lang/c/CSpecificationModifierImpl.scala | 5 +-
.../ast/lang/c/CSpecificationTypeImpl.scala | 5 +-
.../vct/col/ast/lang/c/CStatementImpl.scala | 5 +-
src/col/vct/col/ast/lang/c/CStaticImpl.scala | 5 +-
.../lang/c/CStorageClassSpecifierImpl.scala | 5 +-
.../ast/lang/c/CStructDeclarationImpl.scala | 11 +-
.../vct/col/ast/lang/c/CStructDerefImpl.scala | 47 +-
.../lang/c/CStructMemberDeclaratorImpl.scala | 20 +-
.../col/ast/lang/c/CStructSpecifierImpl.scala | 5 +-
src/col/vct/col/ast/lang/c/CTArrayImpl.scala | 4 +-
.../vct/col/ast/lang/c/CTCudaVecImpl.scala | 3 +-
.../vct/col/ast/lang/c/CTPointerImpl.scala | 3 +-
src/col/vct/col/ast/lang/c/CTStructImpl.scala | 8 +-
src/col/vct/col/ast/lang/c/CTVectorImpl.scala | 26 +-
.../col/ast/lang/c/CTranslationUnitImpl.scala | 3 +-
.../col/ast/lang/c/CTypeAttributeImpl.scala | 8 +-
.../lang/c/CTypeExtensionDeclaratorImpl.scala | 5 +-
.../col/ast/lang/c/CTypeExtensionsImpl.scala | 3 +-
src/col/vct/col/ast/lang/c/CTypeImpl.scala | 5 +-
...ypeQualifierDeclarationSpecifierImpl.scala | 6 +-
.../col/ast/lang/c/CTypeQualifierImpl.scala | 5 +-
.../col/ast/lang/c/CTypeSpecifierImpl.scala | 5 +-
.../lang/c/CTypedFunctionDeclaratorImpl.scala | 15 +-
src/col/vct/col/ast/lang/c/CTypedefImpl.scala | 5 +-
.../vct/col/ast/lang/c/CTypedefNameImpl.scala | 5 +-
.../vct/col/ast/lang/c/CUDAKernelImpl.scala | 5 +-
.../vct/col/ast/lang/c/CUnsignedImpl.scala | 5 +-
src/col/vct/col/ast/lang/c/CVoidImpl.scala | 5 +-
.../vct/col/ast/lang/c/CVolatileImpl.scala | 5 +-
.../col/ast/lang/c/TOpenCLVectorImpl.scala | 3 +-
.../lang/cpp/CPPAbstractDeclarationImpl.scala | 5 +-
.../cpp/CPPAddressingDeclaratorImpl.scala | 5 +-
.../col/ast/lang/cpp/CPPAddressingImpl.scala | 5 +-
.../ast/lang/cpp/CPPArrayDeclaratorImpl.scala | 5 +-
.../vct/col/ast/lang/cpp/CPPBoolImpl.scala | 5 +-
.../vct/col/ast/lang/cpp/CPPCharImpl.scala | 5 +-
.../cpp/CPPClassMethodOrFieldAccessImpl.scala | 41 +-
.../col/ast/lang/cpp/CPPDeclarationImpl.scala | 13 +-
.../cpp/CPPDeclarationSpecifierImpl.scala | 6 +-
.../cpp/CPPDeclarationStatementImpl.scala | 5 +-
.../col/ast/lang/cpp/CPPDeclaratorImpl.scala | 5 +-
.../vct/col/ast/lang/cpp/CPPExprImpl.scala | 5 +-
.../lang/cpp/CPPExprOrTypeSpecifierImpl.scala | 12 +-
.../lang/cpp/CPPFunctionDefinitionImpl.scala | 9 +-
.../lang/cpp/CPPGlobalDeclarationImpl.scala | 8 +-
.../vct/col/ast/lang/cpp/CPPInitImpl.scala | 10 +-
.../vct/col/ast/lang/cpp/CPPInlineImpl.scala | 5 +-
src/col/vct/col/ast/lang/cpp/CPPIntImpl.scala | 5 +-
.../col/ast/lang/cpp/CPPInvocationImpl.scala | 56 +-
.../lang/cpp/CPPLambdaDeclaratorImpl.scala | 5 +-
.../lang/cpp/CPPLambdaDefinitionImpl.scala | 9 +-
.../col/ast/lang/cpp/CPPLambdaRefImpl.scala | 5 +-
.../ast/lang/cpp/CPPLifetimeScopeImpl.scala | 5 +-
.../ast/lang/cpp/CPPLiteralArrayImpl.scala | 8 +-
.../lang/cpp/CPPLocalDeclarationImpl.scala | 4 +-
.../vct/col/ast/lang/cpp/CPPLocalImpl.scala | 78 +-
.../vct/col/ast/lang/cpp/CPPLongImpl.scala | 5 +-
.../vct/col/ast/lang/cpp/CPPNameImpl.scala | 5 +-
.../vct/col/ast/lang/cpp/CPPParamImpl.scala | 5 +-
.../vct/col/ast/lang/cpp/CPPPointerImpl.scala | 5 +-
.../ast/lang/cpp/CPPPrimitiveTypeImpl.scala | 5 +-
.../vct/col/ast/lang/cpp/CPPPureImpl.scala | 5 +-
.../col/ast/lang/cpp/CPPReferenceImpl.scala | 5 +-
.../vct/col/ast/lang/cpp/CPPShortImpl.scala | 5 +-
.../vct/col/ast/lang/cpp/CPPSignedImpl.scala | 5 +-
.../cpp/CPPSpecificationModifierImpl.scala | 5 +-
.../lang/cpp/CPPSpecificationTypeImpl.scala | 5 +-
.../col/ast/lang/cpp/CPPStatementImpl.scala | 5 +-
.../vct/col/ast/lang/cpp/CPPTArrayImpl.scala | 4 +-
.../vct/col/ast/lang/cpp/CPPTLambdaImpl.scala | 5 +-
.../ast/lang/cpp/CPPTranslationUnitImpl.scala | 3 +-
.../vct/col/ast/lang/cpp/CPPTypeImpl.scala | 5 +-
.../ast/lang/cpp/CPPTypeSpecifierImpl.scala | 5 +-
.../cpp/CPPTypedFunctionDeclaratorImpl.scala | 16 +-
.../col/ast/lang/cpp/CPPTypedefNameImpl.scala | 15 +-
.../col/ast/lang/cpp/CPPUnsignedImpl.scala | 5 +-
.../vct/col/ast/lang/cpp/CPPVoidImpl.scala | 5 +-
.../col/ast/lang/gpgpu/GPUGlobalImpl.scala | 6 +-
.../vct/col/ast/lang/gpgpu/GPULocalImpl.scala | 5 +-
.../col/ast/lang/gpgpu/GpgpuAtomicImpl.scala | 21 +-
.../col/ast/lang/gpgpu/GpgpuBarrierImpl.scala | 8 +-
.../gpgpu/GpgpuCudaKernelInvocationImpl.scala | 49 +-
.../lang/gpgpu/GpuGlobalMemoryFenceImpl.scala | 6 +-
.../lang/gpgpu/GpuLocalMemoryFenceImpl.scala | 6 +-
.../ast/lang/gpgpu/GpuMemoryFenceImpl.scala | 5 +-
.../lang/gpgpu/GpuZeroMemoryFenceImpl.scala | 3 +-
.../col/ast/lang/gpgpu/OpenCLKernelImpl.scala | 5 +-
.../ast/lang/gpgpu/SharedMemSizeImpl.scala | 5 +-
.../col/ast/lang/java/JavaAbstractImpl.scala | 5 +-
.../ast/lang/java/JavaAnnotationImpl.scala | 28 +-
.../java/JavaAnnotationInterfaceImpl.scala | 5 +-
.../lang/java/JavaAnnotationMethodImpl.scala | 4 +-
.../lang/java/JavaClassDeclarationImpl.scala | 5 +-
.../vct/col/ast/lang/java/JavaClassImpl.scala | 62 +-
.../lang/java/JavaClassOrInterfaceImpl.scala | 46 +-
.../ast/lang/java/JavaConstructorImpl.scala | 23 +-
.../vct/col/ast/lang/java/JavaDerefImpl.scala | 36 +-
.../vct/col/ast/lang/java/JavaExprImpl.scala | 5 +-
.../col/ast/lang/java/JavaFieldsImpl.scala | 5 +-
.../vct/col/ast/lang/java/JavaFinalImpl.scala | 5 +-
.../lang/java/JavaGlobalDeclarationImpl.scala | 5 +-
.../col/ast/lang/java/JavaImportImpl.scala | 17 +-
.../col/ast/lang/java/JavaInlineImpl.scala | 5 +-
.../col/ast/lang/java/JavaInterfaceImpl.scala | 20 +-
.../ast/lang/java/JavaInvocationImpl.scala | 46 +-
.../ast/lang/java/JavaLiteralArrayImpl.scala | 5 +-
.../lang/java/JavaLocalDeclarationImpl.scala | 6 +-
.../JavaLocalDeclarationStatementImpl.scala | 6 +-
.../vct/col/ast/lang/java/JavaLocalImpl.scala | 36 +-
.../col/ast/lang/java/JavaMethodImpl.scala | 30 +-
.../col/ast/lang/java/JavaModifierImpl.scala | 5 +-
.../vct/col/ast/lang/java/JavaNameImpl.scala | 8 +-
.../col/ast/lang/java/JavaNamedTypeImpl.scala | 8 +-
.../col/ast/lang/java/JavaNamespaceImpl.scala | 19 +-
.../col/ast/lang/java/JavaNativeImpl.scala | 5 +-
.../col/ast/lang/java/JavaNewClassImpl.scala | 15 +-
.../lang/java/JavaNewDefaultArrayImpl.scala | 12 +-
.../lang/java/JavaNewLiteralArrayImpl.scala | 8 +-
.../vct/col/ast/lang/java/JavaParamImpl.scala | 3 +-
.../col/ast/lang/java/JavaPrivateImpl.scala | 5 +-
.../col/ast/lang/java/JavaProtectedImpl.scala | 5 +-
.../col/ast/lang/java/JavaPublicImpl.scala | 5 +-
.../vct/col/ast/lang/java/JavaPureImpl.scala | 5 +-
.../java/JavaSharedInitializationImpl.scala | 10 +-
.../col/ast/lang/java/JavaStatementImpl.scala | 5 +-
.../col/ast/lang/java/JavaStaticImpl.scala | 5 +-
.../col/ast/lang/java/JavaStrictFPImpl.scala | 5 +-
.../ast/lang/java/JavaStringValueImpl.scala | 14 +-
.../ast/lang/java/JavaSynchronizedImpl.scala | 5 +-
.../col/ast/lang/java/JavaTClassImpl.scala | 10 +-
.../col/ast/lang/java/JavaTransientImpl.scala | 5 +-
.../vct/col/ast/lang/java/JavaTypeImpl.scala | 5 +-
.../col/ast/lang/java/JavaVolatileImpl.scala | 5 +-
.../col/ast/lang/java/JavaWildcardImpl.scala | 3 +-
.../LlvmAmbiguousFunctionInvocationImpl.scala | 24 +-
.../vct/col/ast/lang/llvm/LlvmExprImpl.scala | 4 +-
.../lang/llvm/LlvmFunctionContractImpl.scala | 4 +-
.../llvm/LlvmFunctionDefinitionImpl.scala | 6 +-
.../llvm/LlvmFunctionInvocationImpl.scala | 7 +-
.../col/ast/lang/llvm/LlvmGlobalImpl.scala | 3 +-
.../vct/col/ast/lang/llvm/LlvmLocalImpl.scala | 3 +-
.../ast/lang/llvm/LlvmLoopContractImpl.scala | 3 +-
.../vct/col/ast/lang/llvm/LlvmLoopImpl.scala | 4 +-
.../ast/lang/llvm/LlvmLoopInvariantImpl.scala | 3 +-
.../ast/lang/llvm/LlvmSpecFunctionImpl.scala | 27 +-
.../lang/pvl/PVLClassDeclarationImpl.scala | 5 +-
.../col/ast/lang/pvl/PVLConstructorImpl.scala | 11 +-
.../vct/col/ast/lang/pvl/PVLDerefImpl.scala | 23 +-
.../vct/col/ast/lang/pvl/PVLExprImpl.scala | 5 +-
.../col/ast/lang/pvl/PVLInvocationImpl.scala | 65 +-
.../vct/col/ast/lang/pvl/PVLLocalImpl.scala | 28 +-
.../col/ast/lang/pvl/PVLNamedTypeImpl.scala | 14 +-
src/col/vct/col/ast/lang/pvl/PVLNewImpl.scala | 10 +-
.../vct/col/ast/lang/pvl/PVLTypeImpl.scala | 5 +-
.../ast/lang/silver/SilverAssignImpl.scala | 5 +-
.../ast/lang/silver/SilverBagSizeImpl.scala | 6 +-
.../lang/silver/SilverCurFieldPermImpl.scala | 8 +-
.../lang/silver/SilverCurPredPermImpl.scala | 5 +-
.../lang/silver/SilverDeclarationImpl.scala | 5 +-
.../col/ast/lang/silver/SilverDerefImpl.scala | 5 +-
.../col/ast/lang/silver/SilverExprImpl.scala | 5 +-
.../lang/silver/SilverFieldAssignImpl.scala | 5 +-
.../col/ast/lang/silver/SilverFieldImpl.scala | 5 +-
.../ast/lang/silver/SilverIntToRatImpl.scala | 3 +-
.../lang/silver/SilverLocalAssignImpl.scala | 5 +-
.../ast/lang/silver/SilverMapSizeImpl.scala | 6 +-
.../ast/lang/silver/SilverNewRefImpl.scala | 10 +-
.../col/ast/lang/silver/SilverNullImpl.scala | 3 +-
...lverPartialADTFunctionInvocationImpl.scala | 19 +-
.../silver/SilverPartialTAxiomaticImpl.scala | 3 +-
.../ast/lang/silver/SilverSeqSizeImpl.scala | 6 +-
.../ast/lang/silver/SilverSetSizeImpl.scala | 6 +-
.../ast/lang/silver/SilverStatementImpl.scala | 5 +-
.../col/ast/lang/silver/SilverTypeImpl.scala | 5 +-
.../SilverUntypedNonemptyLiteralMapImpl.scala | 8 +-
src/col/vct/col/ast/lang/smt/BoogieImpl.scala | 3 +-
.../col/ast/lang/smt/ProverLanguageImpl.scala | 3 +-
src/col/vct/col/ast/lang/smt/SmtLibImpl.scala | 3 +-
.../smt/SmtlibADTFunctionSymbolImpl.scala | 3 +-
.../lang/smt/SmtlibBitvecLiteralImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibBvAddImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibBvAndImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibBvMulImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibBvNegImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibBvNotImpl.scala | 3 +-
.../vct/col/ast/lang/smt/SmtlibBvOrImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibBvShlImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibBvShrImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibBvUDivImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibBvULtImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibBvURemImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibConcatImpl.scala | 7 +-
.../col/ast/lang/smt/SmtlibExtractImpl.scala | 6 +-
.../col/ast/lang/smt/SmtlibFpAbsImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibFpAddImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibFpCastImpl.scala | 6 +-
.../col/ast/lang/smt/SmtlibFpDivImpl.scala | 3 +-
.../vct/col/ast/lang/smt/SmtlibFpEqImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibFpFmaImpl.scala | 3 +-
.../ast/lang/smt/SmtlibFpFromRealImpl.scala | 6 +-
.../ast/lang/smt/SmtlibFpFromSIntImpl.scala | 6 +-
.../ast/lang/smt/SmtlibFpFromUIntImpl.scala | 6 +-
.../col/ast/lang/smt/SmtlibFpGeqImpl.scala | 3 +-
.../vct/col/ast/lang/smt/SmtlibFpGtImpl.scala | 3 +-
.../vct/col/ast/lang/smt/SmtlibFpImpl.scala | 9 +-
.../ast/lang/smt/SmtlibFpIsInfiniteImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibFpIsNaNImpl.scala | 3 +-
.../ast/lang/smt/SmtlibFpIsNegativeImpl.scala | 3 +-
.../ast/lang/smt/SmtlibFpIsNormalImpl.scala | 3 +-
.../ast/lang/smt/SmtlibFpIsPositiveImpl.scala | 3 +-
.../lang/smt/SmtlibFpIsSubnormalImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibFpIsZeroImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibFpLeqImpl.scala | 3 +-
.../vct/col/ast/lang/smt/SmtlibFpLtImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibFpMaxImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibFpMinImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibFpMulImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibFpNegImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibFpRemImpl.scala | 3 +-
.../smt/SmtlibFpRoundToIntegralImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibFpSqrtImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibFpSubImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibFpToRealImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibFpToSIntImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibFpToUIntImpl.scala | 3 +-
.../lang/smt/SmtlibFunctionSymbolImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibIsIntImpl.scala | 3 +-
.../lang/smt/SmtlibLiteralStringImpl.scala | 3 +-
.../vct/col/ast/lang/smt/SmtlibPowImpl.scala | 3 +-
.../smt/SmtlibProverFunctionSymbolImpl.scala | 4 +-
.../vct/col/ast/lang/smt/SmtlibRNAImpl.scala | 3 +-
.../vct/col/ast/lang/smt/SmtlibRNEImpl.scala | 3 +-
.../vct/col/ast/lang/smt/SmtlibRTNImpl.scala | 3 +-
.../vct/col/ast/lang/smt/SmtlibRTPImpl.scala | 3 +-
.../vct/col/ast/lang/smt/SmtlibRTZImpl.scala | 3 +-
.../ast/lang/smt/SmtlibReAllCharImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibReAllImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibReCompImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibReConcatImpl.scala | 3 +-
.../ast/lang/smt/SmtlibReContainsImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibReDiffImpl.scala | 3 +-
.../ast/lang/smt/SmtlibReFromStrImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibReInterImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibReNoneImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibReOptImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibRePlusImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibReRangeImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibReRepeatImpl.scala | 3 +-
.../lang/smt/SmtlibReRepeatRangeImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibReStarImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibReUnionImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibSelectImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibStoreImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibStrAtImpl.scala | 3 +-
.../ast/lang/smt/SmtlibStrConcatImpl.scala | 3 +-
.../ast/lang/smt/SmtlibStrContainsImpl.scala | 3 +-
.../ast/lang/smt/SmtlibStrFromCodeImpl.scala | 3 +-
.../ast/lang/smt/SmtlibStrFromIntImpl.scala | 3 +-
.../ast/lang/smt/SmtlibStrIndexOfImpl.scala | 3 +-
.../ast/lang/smt/SmtlibStrIsDigitImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibStrLenImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibStrLeqImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibStrLtImpl.scala | 3 +-
.../ast/lang/smt/SmtlibStrPrefixOfImpl.scala | 3 +-
.../lang/smt/SmtlibStrReplaceAllImpl.scala | 3 +-
.../ast/lang/smt/SmtlibStrReplaceImpl.scala | 3 +-
.../lang/smt/SmtlibStrReplaceReAllImpl.scala | 3 +-
.../ast/lang/smt/SmtlibStrReplaceReImpl.scala | 3 +-
.../ast/lang/smt/SmtlibStrSuffixOfImpl.scala | 3 +-
.../ast/lang/smt/SmtlibStrToCodeImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibStrToIntImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibSubstrImpl.scala | 3 +-
.../vct/col/ast/lang/smt/SmtlibToFpImpl.scala | 6 +-
.../col/ast/lang/smt/SmtlibToIntImpl.scala | 3 +-
.../col/ast/lang/smt/SmtlibToRealImpl.scala | 3 +-
.../col/ast/lang/smt/TSmtlibArrayImpl.scala | 3 +-
.../ast/lang/smt/TSmtlibBitVectorImpl.scala | 3 +-
.../lang/smt/TSmtlibFloatingPointImpl.scala | 3 +-
.../col/ast/lang/smt/TSmtlibRegLanImpl.scala | 3 +-
.../lang/smt/TSmtlibRoundingModeImpl.scala | 3 +-
.../vct/col/ast/lang/smt/TSmtlibSeqImpl.scala | 3 +-
.../col/ast/lang/smt/TSmtlibStringImpl.scala | 3 +-
.../col/ast/lang/smt/Z3ArrayConstImpl.scala | 3 +-
.../vct/col/ast/lang/smt/Z3ArrayMapImpl.scala | 3 +-
.../ast/lang/smt/Z3ArrayOfFunctionImpl.scala | 8 +-
.../vct/col/ast/lang/smt/Z3BvNandImpl.scala | 3 +-
.../vct/col/ast/lang/smt/Z3BvNorImpl.scala | 3 +-
.../vct/col/ast/lang/smt/Z3BvSModImpl.scala | 3 +-
.../vct/col/ast/lang/smt/Z3BvSRemImpl.scala | 3 +-
.../vct/col/ast/lang/smt/Z3BvSShrImpl.scala | 3 +-
.../vct/col/ast/lang/smt/Z3BvSubImpl.scala | 3 +-
.../vct/col/ast/lang/smt/Z3BvXnorImpl.scala | 3 +-
.../vct/col/ast/lang/smt/Z3SeqAtImpl.scala | 3 +-
.../col/ast/lang/smt/Z3SeqConcatImpl.scala | 3 +-
.../col/ast/lang/smt/Z3SeqContainsImpl.scala | 3 +-
.../vct/col/ast/lang/smt/Z3SeqEmptyImpl.scala | 3 +-
.../col/ast/lang/smt/Z3SeqExtractImpl.scala | 3 +-
.../col/ast/lang/smt/Z3SeqFoldlIImpl.scala | 3 +-
.../vct/col/ast/lang/smt/Z3SeqFoldlImpl.scala | 3 +-
.../vct/col/ast/lang/smt/Z3SeqLenImpl.scala | 3 +-
.../vct/col/ast/lang/smt/Z3SeqMapIImpl.scala | 3 +-
.../vct/col/ast/lang/smt/Z3SeqMapImpl.scala | 3 +-
.../vct/col/ast/lang/smt/Z3SeqNthImpl.scala | 3 +-
.../col/ast/lang/smt/Z3SeqPrefixOfImpl.scala | 3 +-
.../col/ast/lang/smt/Z3SeqReplaceImpl.scala | 3 +-
.../col/ast/lang/smt/Z3SeqSuffixOfImpl.scala | 3 +-
.../vct/col/ast/lang/smt/Z3SeqUnitImpl.scala | 3 +-
.../lang/smt/Z3TransitiveClosureImpl.scala | 3 +-
.../ast/lang/sycl/SYCLAccessModeImpl.scala | 5 +-
.../ast/lang/sycl/SYCLClassDefNameImpl.scala | 14 +-
.../col/ast/lang/sycl/SYCLNDRangeImpl.scala | 21 +-
.../vct/col/ast/lang/sycl/SYCLRangeImpl.scala | 11 +-
.../lang/sycl/SYCLReadOnlyAccessImpl.scala | 5 +-
.../lang/sycl/SYCLReadWriteAccessImpl.scala | 5 +-
.../ast/lang/sycl/SYCLTAccessModeImpl.scala | 8 +-
.../col/ast/lang/sycl/SYCLTAccessorImpl.scala | 137 +-
.../col/ast/lang/sycl/SYCLTBufferImpl.scala | 319 +-
.../col/ast/lang/sycl/SYCLTClassImpl.scala | 5 +-
.../sycl/SYCLTConstructableClassImpl.scala | 10 +-
.../col/ast/lang/sycl/SYCLTEventImpl.scala | 5 +-
.../col/ast/lang/sycl/SYCLTHandlerImpl.scala | 5 +-
.../vct/col/ast/lang/sycl/SYCLTItemImpl.scala | 5 +-
.../lang/sycl/SYCLTLocalAccessorImpl.scala | 41 +-
.../col/ast/lang/sycl/SYCLTNDItemImpl.scala | 5 +-
.../col/ast/lang/sycl/SYCLTNDRangeImpl.scala | 34 +-
.../col/ast/lang/sycl/SYCLTQueueImpl.scala | 5 +-
.../col/ast/lang/sycl/SYCLTRangeImpl.scala | 32 +-
src/col/vct/col/ast/node/NodeFamilyImpl.scala | 9 +-
src/col/vct/col/ast/node/NodeImpl.scala | 205 +-
src/col/vct/col/ast/node/ProgramImpl.scala | 14 +-
.../ast/node/VerificationContextImpl.scala | 4 +-
.../vct/col/ast/node/VerificationImpl.scala | 14 +-
.../vct/col/ast/statement/StatementImpl.scala | 3 +-
.../ExpressionContainerStatementImpl.scala | 3 +-
.../ast/statement/composite/BlockImpl.scala | 8 +-
.../ast/statement/composite/BranchImpl.scala | 7 +-
.../composite/CompositeStatementImpl.scala | 3 +-
.../statement/composite/IndetBranchImpl.scala | 9 +-
.../ast/statement/composite/LoopImpl.scala | 154 +-
.../ast/statement/composite/ModelDoImpl.scala | 9 +-
.../statement/composite/ParAtomicImpl.scala | 8 +-
.../statement/composite/ParBarrierImpl.scala | 11 +-
.../composite/ParInvariantImpl.scala | 9 +-
.../composite/ParStatementImpl.scala | 5 +-
.../statement/composite/RangedForImpl.scala | 10 +-
.../ast/statement/composite/ScopeImpl.scala | 21 +-
.../ast/statement/composite/SwitchImpl.scala | 17 +-
.../composite/SynchronizedImpl.scala | 8 +-
.../composite/TryCatchFinallyImpl.scala | 22 +-
.../statement/composite/VecBlockImpl.scala | 5 +-
.../statement/composite/WandPackageImpl.scala | 5 +-
.../ast/statement/exceptional/BreakImpl.scala | 11 +-
.../statement/exceptional/ContinueImpl.scala | 11 +-
.../ast/statement/exceptional/EvalImpl.scala | 19 +-
.../ExceptionalStatementImpl.scala | 3 +-
.../exceptional/InvocationStatementImpl.scala | 3 +-
.../exceptional/InvokeMethodImpl.scala | 15 +-
.../exceptional/InvokeProcedureImpl.scala | 34 +-
.../statement/exceptional/ReturnImpl.scala | 23 +-
.../ast/statement/exceptional/ThrowImpl.scala | 8 +-
.../nonexecutable/LocalDeclImpl.scala | 14 +-
.../NonExecutableStatementImpl.scala | 3 +-
.../nonexecutable/SpecIgnoreEndImpl.scala | 5 +-
.../nonexecutable/SpecIgnoreStartImpl.scala | 5 +-
.../ast/statement/terminal/AssertImpl.scala | 20 +-
.../ast/statement/terminal/AssignImpl.scala | 33 +-
.../ast/statement/terminal/AssumeImpl.scala | 20 +-
.../col/ast/statement/terminal/CaseImpl.scala | 8 +-
.../ast/statement/terminal/CommitImpl.scala | 11 +-
.../statement/terminal/DefaultCaseImpl.scala | 5 +-
.../ast/statement/terminal/ExhaleImpl.scala | 20 +-
.../ast/statement/terminal/ExtractImpl.scala | 6 +-
.../col/ast/statement/terminal/FoldImpl.scala | 21 +-
.../col/ast/statement/terminal/ForkImpl.scala | 11 +-
.../statement/terminal/FramedProofImpl.scala | 12 +-
.../col/ast/statement/terminal/GotoImpl.scala | 14 +-
.../ast/statement/terminal/HavocImpl.scala | 11 +-
.../ast/statement/terminal/InhaleImpl.scala | 20 +-
.../col/ast/statement/terminal/JoinImpl.scala | 11 +-
.../ast/statement/terminal/LabelImpl.scala | 36 +-
.../col/ast/statement/terminal/LockImpl.scala | 11 +-
.../NormallyCompletingStatementImpl.scala | 3 +-
.../ast/statement/terminal/NotifyImpl.scala | 11 +-
.../col/ast/statement/terminal/RecvImpl.scala | 8 +-
.../ast/statement/terminal/RefuteImpl.scala | 20 +-
.../col/ast/statement/terminal/SendImpl.scala | 10 +-
.../statement/terminal/SwitchCaseImpl.scala | 3 +-
.../ast/statement/terminal/UnfoldImpl.scala | 21 +-
.../ast/statement/terminal/UnlockImpl.scala | 11 +-
.../col/ast/statement/terminal/WaitImpl.scala | 11 +-
.../statement/terminal/WandApplyImpl.scala | 17 +-
.../statement/veymont/ChorBranchImpl.scala | 47 +-
.../ast/statement/veymont/ChorLoopImpl.scala | 48 +-
.../statement/veymont/ChorStatementImpl.scala | 181 +-
.../statement/veymont/CommunicateImpl.scala | 39 +-
.../statement/veymont/CommunicateXImpl.scala | 3 +-
.../veymont/VeyMontAssignExpressionImpl.scala | 3 +-
src/col/vct/col/ast/type/TAnyClassImpl.scala | 3 +-
src/col/vct/col/ast/type/TAnyImpl.scala | 5 +-
src/col/vct/col/ast/type/TAnyValueImpl.scala | 3 +-
src/col/vct/col/ast/type/TArrayImpl.scala | 5 +-
src/col/vct/col/ast/type/TAxiomaticImpl.scala | 13 +-
src/col/vct/col/ast/type/TBagImpl.scala | 5 +-
src/col/vct/col/ast/type/TBoolImpl.scala | 18 +-
.../vct/col/ast/type/TBoundedIntImpl.scala | 5 +-
src/col/vct/col/ast/type/TCFloatImpl.scala | 8 +-
src/col/vct/col/ast/type/TCIntImpl.scala | 5 +-
src/col/vct/col/ast/type/TCharImpl.scala | 5 +-
.../vct/col/ast/type/TChoreographyImpl.scala | 3 +-
src/col/vct/col/ast/type/TClassImpl.scala | 42 +-
src/col/vct/col/ast/type/TEitherImpl.scala | 5 +-
src/col/vct/col/ast/type/TEndpointImpl.scala | 3 +-
src/col/vct/col/ast/type/TFloatImpl.scala | 5 +-
src/col/vct/col/ast/type/TFractionImpl.scala | 5 +-
src/col/vct/col/ast/type/TIntImpl.scala | 5 +-
src/col/vct/col/ast/type/TMapImpl.scala | 5 +-
src/col/vct/col/ast/type/TMatrixImpl.scala | 5 +-
src/col/vct/col/ast/type/TModelImpl.scala | 8 +-
src/col/vct/col/ast/type/TNotAValueImpl.scala | 3 +-
src/col/vct/col/ast/type/TNothingImpl.scala | 5 +-
src/col/vct/col/ast/type/TNullImpl.scala | 5 +-
src/col/vct/col/ast/type/TOptionImpl.scala | 5 +-
src/col/vct/col/ast/type/TPointerImpl.scala | 5 +-
src/col/vct/col/ast/type/TProcessImpl.scala | 5 +-
.../vct/col/ast/type/TProverTypeImpl.scala | 3 +-
src/col/vct/col/ast/type/TRationalImpl.scala | 5 +-
src/col/vct/col/ast/type/TRefImpl.scala | 5 +-
src/col/vct/col/ast/type/TResourceImpl.scala | 5 +-
.../vct/col/ast/type/TResourceValImpl.scala | 3 +-
src/col/vct/col/ast/type/TSeqImpl.scala | 5 +-
src/col/vct/col/ast/type/TSetImpl.scala | 5 +-
src/col/vct/col/ast/type/TStringImpl.scala | 16 +-
src/col/vct/col/ast/type/TTupleImpl.scala | 5 +-
src/col/vct/col/ast/type/TTypeImpl.scala | 5 +-
src/col/vct/col/ast/type/TUnionImpl.scala | 7 +-
src/col/vct/col/ast/type/TVarImpl.scala | 11 +-
src/col/vct/col/ast/type/TVectorImpl.scala | 10 +-
.../col/ast/type/TVeyMontChannelImpl.scala | 8 +-
src/col/vct/col/ast/type/TVoidImpl.scala | 5 +-
src/col/vct/col/ast/type/TZFractionImpl.scala | 5 +-
.../type/typeclass/CompositeTypeImpl.scala | 3 +-
.../ast/type/typeclass/DeclaredTypeImpl.scala | 3 +-
.../ast/type/typeclass/FloatTypeImpl.scala | 93 +-
.../col/ast/type/typeclass/IntTypeImpl.scala | 3 +-
.../ast/type/typeclass/NumericTypeImpl.scala | 3 +-
.../type/typeclass/PrimitiveTypeImpl.scala | 3 +-
.../ast/type/typeclass/SizedTypeImpl.scala | 3 +-
.../vct/col/ast/type/typeclass/TypeImpl.scala | 87 +-
.../vct/col/ast/unsorted/BipGlueImpl.scala | 3 +-
.../col/ast/unsorted/BipPortTypeImpl.scala | 3 +-
.../CFunctionTypeExtensionModifierImpl.scala | 7 +-
.../col/ast/unsorted/ChooseFreshImpl.scala | 6 +-
src/col/vct/col/ast/unsorted/ChooseImpl.scala | 6 +-
.../vct/col/ast/unsorted/ChorPermImpl.scala | 6 +-
.../CoerceDecreasePrecisionImpl.scala | 3 +-
.../CoerceIncreasePrecisionImpl.scala | 3 +-
.../unsorted/CommunicateStatementImpl.scala | 6 +-
.../col/ast/unsorted/ConstructorImpl.scala | 22 +-
.../unsorted/ConstructorInvocationImpl.scala | 22 +-
.../col/ast/unsorted/EnumConstantImpl.scala | 4 +-
.../col/ast/unsorted/InstantiateImpl.scala | 3 +-
.../ast/unsorted/InvokeConstructorImpl.scala | 3 +-
.../ast/unsorted/JavaBipAnnotationImpl.scala | 3 +-
.../ast/unsorted/JavaBipGlueElementImpl.scala | 3 +-
.../vct/col/ast/unsorted/MessageImpl.scala | 3 +-
.../vct/col/ast/unsorted/OperatorImpl.scala | 3 +-
.../ast/unsorted/OperatorLeftPlusImpl.scala | 3 +-
.../ast/unsorted/OperatorRightPlusImpl.scala | 3 +-
.../vct/col/ast/unsorted/PVLBranchImpl.scala | 3 +-
.../unsorted/PVLChannelInvariantImpl.scala | 3 +-
.../col/ast/unsorted/PVLChorPermImpl.scala | 3 +-
.../vct/col/ast/unsorted/PVLChorRunImpl.scala | 3 +-
.../ast/unsorted/PVLChorStatementImpl.scala | 36 +-
.../col/ast/unsorted/PVLEndpointImpl.scala | 3 +-
.../vct/col/ast/unsorted/PVLLoopImpl.scala | 3 +-
.../vct/col/ast/unsorted/PVLMessageImpl.scala | 3 +-
.../col/ast/unsorted/PVLReceiverImpl.scala | 3 +-
.../vct/col/ast/unsorted/PVLSenderImpl.scala | 3 +-
.../vct/col/ast/unsorted/RangeSetImpl.scala | 6 +-
.../vct/col/ast/unsorted/ReceiverImpl.scala | 3 +-
src/col/vct/col/ast/unsorted/SenderImpl.scala | 3 +-
src/col/vct/col/ast/unsorted/TEnumImpl.scala | 3 +-
.../ast/unsorted/TPVLChoreographyImpl.scala | 3 +-
.../unsorted/UnresolvedChorBranchImpl.scala | 3 +-
.../ast/unsorted/UnresolvedChorLoopImpl.scala | 3 +-
.../col/ast/util/CheckFoldUnfoldTarget.scala | 67 +-
src/col/vct/col/ast/util/Declarator.scala | 14 +-
.../ast/util/ExpressionEqualityCheck.scala | 661 ++-
src/col/vct/col/check/Check.scala | 247 +-
src/col/vct/col/compare/Compare.scala | 50 +-
src/col/vct/col/compare/CompareResult.scala | 11 +-
src/col/vct/col/debug/DebugRewriteState.scala | 2 +-
src/col/vct/col/err/ASTStateError.scala | 2 +-
.../err/ContextSensitiveNodeNotResolved.scala | 3 +-
.../col/err/InconsistentSuccessionTypes.scala | 11 +-
src/col/vct/col/err/MistypedRef.scala | 3 +-
src/col/vct/col/err/NotResolved.scala | 5 +-
src/col/vct/col/feature/Feature.scala | 14 +-
src/col/vct/col/feature/FeatureRainbow.scala | 1461 +++---
src/col/vct/col/origin/Blame.scala | 1309 +++--
src/col/vct/col/origin/ExpectedError.scala | 21 +-
.../origin/HideDuringTriggerGeneration.scala | 9 +-
src/col/vct/col/origin/Name.scala | 9 +-
src/col/vct/col/origin/Origin.scala | 423 +-
src/col/vct/col/print/Ctx.scala | 21 +-
src/col/vct/col/print/Doc.scala | 272 +-
src/col/vct/col/print/DocUtil.scala | 91 +-
src/col/vct/col/print/Keywords.scala | 321 +-
src/col/vct/col/print/Namer.scala | 179 +-
src/col/vct/col/ref/DirectRef.scala | 13 +-
src/col/vct/col/ref/LazyRef.scala | 21 +-
src/col/vct/col/ref/Ref.scala | 71 +-
src/col/vct/col/ref/UnresolvedRef.scala | 19 +-
src/col/vct/col/resolve/ResolutionError.scala | 97 +-
src/col/vct/col/resolve/Resolve.scala | 1677 +++---
.../ctx/ReferenceResolutionContext.scala | 79 +-
src/col/vct/col/resolve/ctx/Referrable.scala | 702 ++-
.../resolve/ctx/TypeResolutionContext.scala | 16 +-
src/col/vct/col/resolve/lang/C.scala | 419 +-
src/col/vct/col/resolve/lang/CPP.scala | 354 +-
src/col/vct/col/resolve/lang/Java.scala | 1037 ++--
src/col/vct/col/resolve/lang/LLVM.scala | 23 +-
src/col/vct/col/resolve/lang/PVL.scala | 174 +-
src/col/vct/col/resolve/lang/Spec.scala | 365 +-
src/col/vct/col/resolve/lang/Util.scala | 58 +-
.../vct/col/rewrite/NonLatchingRewriter.scala | 5 +-
src/col/vct/col/rewrite/Rewriter.scala | 3 +-
src/col/vct/col/rewrite/RewriterBuilder.scala | 41 +-
.../vct/col/rewrite/RewriterBuilderArg.scala | 64 +-
.../vct/col/rewrite/SuccessorProvider.scala | 9 +-
.../vct/col/serialize/NodeMessageView.scala | 3 +-
.../vct/col/serialize/SerializeBlame.scala | 7 +-
.../vct/col/serialize/SerializeOrigin.scala | 60 +-
src/col/vct/col/structure/family.scala | 2 +-
.../vct/col/typerules/CoercingRewriter.scala | 2489 +++++----
src/col/vct/col/typerules/CoercionUtils.scala | 717 ++-
src/col/vct/col/typerules/Types.scala | 143 +-
src/col/vct/col/util/AstBuildHelpers.scala | 1112 ++--
.../util/ConstructingSuccessorOfContext.scala | 8 +-
.../col/util/CurrentCheckNodeContext.scala | 8 +-
.../col/util/CurrentCheckProgramContext.scala | 3 +-
.../col/util/CurrentRewriteNodeContext.scala | 8 +-
.../util/CurrentRewriteProgramContext.scala | 3 +-
src/col/vct/col/util/DeclarationBox.scala | 4 +-
src/col/vct/col/util/EqualityMeasure.scala | 26 +-
src/col/vct/col/util/FrozenScopes.scala | 39 +-
src/col/vct/col/util/Scopes.scala | 83 +-
src/col/vct/col/util/Substitute.scala | 60 +-
src/col/vct/col/util/SuccessionMap.scala | 93 +-
src/helpers/scala/meta/ResultStream.scala | 48 +-
.../vct/col/ast/helpers/defn/Constants.scala | 12 +-
.../vct/col/ast/helpers/defn/Naming.scala | 126 +-
.../vct/col/ast/helpers/defn/Proto.scala | 165 +-
.../col/ast/helpers/defn/ProtoNaming.scala | 236 +-
.../vct/col/ast/helpers/defn/Simplify.scala | 166 +-
.../helpers/generator/AbstractRewriter.scala | 16 +-
.../helpers/generator/AllFrozenScopes.scala | 15 +-
.../col/ast/helpers/generator/AllScopes.scala | 24 +-
.../generator/BaseCoercingRewriter.scala | 24 +-
.../generator/BaseNonLatchingRewriter.scala | 16 +-
.../col/ast/helpers/generator/Compare.scala | 115 +-
.../ast/helpers/generator/DeclareFamily.scala | 14 +-
.../ast/helpers/generator/Deserialize.scala | 96 +-
.../helpers/generator/DeserializeFamily.scala | 27 +-
.../col/ast/helpers/generator/ImplTrait.scala | 108 +-
.../col/ast/helpers/generator/MegaCol.scala | 13 +-
.../vct/col/ast/helpers/generator/Ops.scala | 5 +-
.../col/ast/helpers/generator/OpsFamily.scala | 32 +-
.../ast/helpers/generator/ProtoAuxTypes.scala | 27 +-
.../ast/helpers/generator/ProtoFamily.scala | 41 +-
.../col/ast/helpers/generator/ProtoNode.scala | 41 +-
.../col/ast/helpers/generator/Rewrite.scala | 67 +-
.../helpers/generator/RewriteHelpers.scala | 9 +-
.../col/ast/helpers/generator/Serialize.scala | 116 +-
.../col/ast/helpers/generator/Subnodes.scala | 32 +-
.../generator/SuccessorsProvider.scala | 21 +-
src/hre/hre/cache/Cache.scala | 40 +-
src/hre/hre/data/BitString.scala | 87 +-
src/hre/hre/debug/TimeTravel.scala | 37 +-
src/hre/hre/io/InMemoryCachedReadable.scala | 11 +-
src/hre/hre/io/InterruptibleInputStream.scala | 116 +-
src/hre/hre/io/LiteralReadable.scala | 3 +-
src/hre/hre/io/RWFile.scala | 6 +-
src/hre/hre/io/Readable.scala | 29 +-
src/hre/hre/io/ReaderReadable.scala | 8 +-
src/hre/hre/io/Watch.scala | 208 +-
src/hre/hre/io/Writeable.scala | 7 +-
src/hre/hre/log/LogHistory.scala | 8 +-
src/hre/hre/perf/Profile.scala | 72 +-
src/hre/hre/perf/ProfileBuilder.scala | 25 +-
src/hre/hre/perf/ResourceUsage.scala | 43 +-
src/hre/hre/platform/Platform.scala | 18 +-
src/hre/hre/progress/Layout.scala | 131 +-
src/hre/hre/progress/Progress.scala | 124 +-
.../progress/ProgressAwareLogbackLayout.scala | 10 +-
src/hre/hre/progress/ProgressLogicError.scala | 7 +-
src/hre/hre/progress/ProgressRender.scala | 39 +-
src/hre/hre/progress/TaskRegistry.scala | 63 +-
src/hre/hre/progress/task/AbstractTask.scala | 151 +-
.../hre/progress/task/NameSequenceTask.scala | 19 +-
src/hre/hre/progress/task/RootTask.scala | 4 +-
.../hre/progress/task/SimpleNamedTask.scala | 6 +-
.../hre/progress/task/UpdateableTask.scala | 22 +-
src/hre/hre/resource/ResourceUtil.scala | 38 +-
src/hre/hre/stages/Stages.scala | 121 +-
src/hre/hre/util/FuncTools.scala | 10 +-
src/hre/hre/util/Interrupt.scala | 4 +-
src/hre/hre/util/Notifier.scala | 34 +-
src/hre/hre/util/ScopedStack.scala | 10 +-
src/hre/hre/util/Time.scala | 3 +-
src/hre/vct/result/HasContext.scala | 8 +-
src/hre/vct/result/Message.scala | 8 +-
src/hre/vct/result/VerificationError.scala | 24 +-
src/main/vct/cache/Caches.scala | 22 +-
src/main/vct/debug/CrashReport.scala | 42 +-
src/main/vct/importer/JavaLibraryLoader.scala | 29 +-
src/main/vct/importer/PathAdtImporter.scala | 6 +-
src/main/vct/importer/Util.scala | 53 +-
src/main/vct/main/Main.scala | 150 +-
src/main/vct/main/modes/CFG.scala | 5 +-
src/main/vct/main/modes/VeSUV.scala | 5 +-
src/main/vct/main/modes/Verify.scala | 96 +-
src/main/vct/main/modes/VeyMont.scala | 16 +-
src/main/vct/main/stages/Backend.scala | 182 +-
src/main/vct/main/stages/ExpectedErrors.scala | 6 +-
src/main/vct/main/stages/GenerateRASI.scala | 67 +-
src/main/vct/main/stages/Output.scala | 85 +-
src/main/vct/main/stages/Parsing.scala | 105 +-
src/main/vct/main/stages/PrintCFG.scala | 7 +-
src/main/vct/main/stages/Resolution.scala | 108 +-
src/main/vct/main/stages/Stages.scala | 127 +-
src/main/vct/main/stages/Transformation.scala | 581 ++-
src/main/vct/options/BashCompletion.scala | 11 +-
src/main/vct/options/Options.scala | 569 +-
src/main/vct/options/types/Backend.scala | 2 +-
.../vct/options/types/ClassPathEntry.scala | 2 +-
src/main/vct/options/types/PathOrStd.scala | 57 +-
src/main/vct/options/types/ReadEnum.scala | 3 +-
src/main/vct/options/types/Verbosity.scala | 2 +-
src/parsers/vct/parsers/AntlrParser.scala | 151 +-
.../vct/parsers/CollectingErrorListener.scala | 86 +-
src/parsers/vct/parsers/ParseResult.scala | 18 +-
src/parsers/vct/parsers/Parser.scala | 25 +-
.../vct/parsers/ProgressTokenStream.scala | 34 +-
src/parsers/vct/parsers/debug/ATNTools.scala | 143 +-
.../vct/parsers/debug/DebugOptions.scala | 13 +-
src/parsers/vct/parsers/debug/Grammar.scala | 139 +-
.../vct/parsers/debug/ParseAllExamples.scala | 102 +-
.../ProfilingPredictionContextCache.scala | 4 +-
src/parsers/vct/parsers/err/ParseError.scala | 16 +-
.../vct/parsers/parser/ColCPPParser.scala | 73 +-
.../vct/parsers/parser/ColCParser.scala | 73 +-
.../vct/parsers/parser/ColIPPParser.scala | 30 +-
.../vct/parsers/parser/ColIParser.scala | 31 +-
.../vct/parsers/parser/ColJavaParser.scala | 29 +-
.../parser/ColLLVMContractParser.scala | 45 +-
.../vct/parsers/parser/ColLLVMParser.scala | 50 +-
.../vct/parsers/parser/ColPVLParser.scala | 24 +-
.../vct/parsers/transform/BlameProvider.scala | 34 +-
.../vct/parsers/transform/CPPToCol.scala | 3192 +++++++-----
.../vct/parsers/transform/CToCol.scala | 2878 +++++++----
.../vct/parsers/transform/JavaToCol.scala | 3635 ++++++++-----
.../parsers/transform/LLVMContractToCol.scala | 782 +--
.../vct/parsers/transform/PVLToCol.scala | 2830 ++++++----
src/parsers/vct/parsers/transform/ToCol.scala | 234 +-
.../transform/systemctocol/util/Seqs.scala | 3 +-
.../vct/rewrite/ApplyTermRewriter.scala | 400 +-
src/rewrite/vct/rewrite/BranchToIfElse.scala | 29 +-
.../vct/rewrite/CFloatIntCoercion.scala | 69 +-
.../rewrite/CheckContractSatisfiability.scala | 123 +-
.../vct/rewrite/CheckProcessAlgebra.scala | 325 +-
src/rewrite/vct/rewrite/ClassToRef.scala | 655 ++-
.../rewrite/CollectLocalDeclarations.scala | 35 +-
.../vct/rewrite/ConstantifyFinalFields.scala | 195 +-
.../rewrite/DesugarCoalescingOperators.scala | 15 +-
.../rewrite/DesugarCollectionOperators.scala | 20 +-
.../rewrite/DesugarPermissionOperators.scala | 154 +-
src/rewrite/vct/rewrite/Disambiguate.scala | 410 +-
.../vct/rewrite/DisambiguateLocation.scala | 87 +-
.../vct/rewrite/EncodeArrayValues.scala | 625 ++-
src/rewrite/vct/rewrite/EncodeAutoValue.scala | 301 +-
src/rewrite/vct/rewrite/EncodeChar.scala | 19 +-
.../vct/rewrite/EncodeCurrentThread.scala | 164 +-
src/rewrite/vct/rewrite/EncodeExtract.scala | 190 +-
.../vct/rewrite/EncodeForPermWithValue.scala | 41 +-
src/rewrite/vct/rewrite/EncodeForkJoin.scala | 326 +-
.../vct/rewrite/EncodeIntrinsicLock.scala | 224 +-
src/rewrite/vct/rewrite/EncodeNdIndex.scala | 383 +-
.../vct/rewrite/EncodeProofHelpers.scala | 148 +-
src/rewrite/vct/rewrite/EncodeRange.scala | 15 +-
src/rewrite/vct/rewrite/EncodeRangedFor.scala | 119 +-
.../vct/rewrite/EncodeResourceValues.scala | 556 +-
src/rewrite/vct/rewrite/EncodeSendRecv.scala | 142 +-
src/rewrite/vct/rewrite/EncodeString.scala | 39 +-
src/rewrite/vct/rewrite/EnumToDomain.scala | 241 +-
.../vct/rewrite/EvaluationTargetDummy.scala | 94 +-
.../vct/rewrite/ExplicitADTTypeArgs.scala | 77 +-
.../vct/rewrite/ExplicitResourceValues.scala | 28 +-
src/rewrite/vct/rewrite/Explode.scala | 116 +-
.../ExtractInlineQuantifierPatterns.scala | 198 +-
.../vct/rewrite/FilterSpecIgnore.scala | 98 +-
.../vct/rewrite/FinalizeArguments.scala | 91 +-
src/rewrite/vct/rewrite/FloatToRat.scala | 114 +-
.../vct/rewrite/ForLoopToWhileLoop.scala | 34 +-
.../vct/rewrite/GivenYieldsToArgs.scala | 216 +-
.../vct/rewrite/HeapVariableToRef.scala | 69 +-
.../vct/rewrite/InlineApplicables.scala | 429 +-
.../rewrite/IterationContractToParBlock.scala | 115 +-
.../vct/rewrite/MonomorphizeClass.scala | 254 +-
.../MonomorphizeContractApplicables.scala | 142 +-
src/rewrite/vct/rewrite/ParBlockEncoder.scala | 556 +-
.../vct/rewrite/PinCollectionTypes.scala | 32 +-
src/rewrite/vct/rewrite/PinSilverNodes.scala | 78 +-
src/rewrite/vct/rewrite/PrettifyBlocks.scala | 114 +-
.../rewrite/PropagateContextEverywhere.scala | 206 +-
.../vct/rewrite/PureMethodsToFunctions.scala | 243 +-
.../vct/rewrite/QuantifySubscriptAny.scala | 37 +-
src/rewrite/vct/rewrite/ReadToValue.scala | 22 +-
.../vct/rewrite/RefuteToInvertedAssert.scala | 75 +-
.../rewrite/ResolveExpressionSideChecks.scala | 93 +-
.../ResolveExpressionSideEffects.scala | 854 +--
src/rewrite/vct/rewrite/ResolveScale.scala | 83 +-
.../rewrite/RewriteTriggerADTFunctions.scala | 29 +-
.../vct/rewrite/SilverIntRatCoercion.scala | 20 +-
.../rewrite/SimplifyNestedQuantifiers.scala | 1462 +++---
.../rewrite/SimplifyQuantifiedRelations.scala | 300 +-
.../vct/rewrite/SmtlibToProverTypes.scala | 447 +-
src/rewrite/vct/rewrite/TrivialAddrOf.scala | 105 +-
src/rewrite/vct/rewrite/TruncDivMod.scala | 124 +-
.../vct/rewrite/TupledQuantifiers.scala | 35 +-
src/rewrite/vct/rewrite/TypeValues.scala | 19 +-
.../vct/rewrite/UntupledQuantifiers.scala | 80 +-
src/rewrite/vct/rewrite/adt/ImportADT.scala | 161 +-
src/rewrite/vct/rewrite/adt/ImportAny.scala | 54 +-
src/rewrite/vct/rewrite/adt/ImportArray.scala | 139 +-
src/rewrite/vct/rewrite/adt/ImportBag.scala | 200 +-
.../vct/rewrite/adt/ImportEither.scala | 142 +-
src/rewrite/vct/rewrite/adt/ImportFrac.scala | 126 +-
src/rewrite/vct/rewrite/adt/ImportMap.scala | 171 +-
.../vct/rewrite/adt/ImportMapCompat.scala | 67 +-
.../vct/rewrite/adt/ImportNothing.scala | 36 +-
src/rewrite/vct/rewrite/adt/ImportNull.scala | 42 +-
.../vct/rewrite/adt/ImportOption.scala | 101 +-
.../vct/rewrite/adt/ImportPointer.scala | 227 +-
src/rewrite/vct/rewrite/adt/ImportSeq.scala | 226 +-
src/rewrite/vct/rewrite/adt/ImportSet.scala | 191 +-
.../vct/rewrite/adt/ImportSetCompat.scala | 64 +-
src/rewrite/vct/rewrite/adt/ImportTuple.scala | 62 +-
.../vct/rewrite/adt/ImportVector.scala | 502 +-
.../vct/rewrite/adt/ImportViperOrder.scala | 21 +-
src/rewrite/vct/rewrite/adt/ImportVoid.scala | 47 +-
.../rewrite/bip/BipVerificationResults.scala | 224 +-
.../vct/rewrite/bip/ComputeBipGlue.scala | 329 +-
src/rewrite/vct/rewrite/bip/EncodeBip.scala | 866 ++--
.../rewrite/bip/EncodeBipPermissions.scala | 58 +-
.../bip/InstantiateBipSynchronizations.scala | 79 +-
.../vct/rewrite/bip/IsolateBipGlue.scala | 39 +-
.../vct/rewrite/cfg/CFGGenerator.scala | 254 +-
src/rewrite/vct/rewrite/cfg/CFGNode.scala | 5 +-
src/rewrite/vct/rewrite/cfg/CFGPrinter.scala | 25 +-
src/rewrite/vct/rewrite/cfg/Index.scala | 1102 ++--
src/rewrite/vct/rewrite/cfg/Utils.scala | 295 +-
.../rewrite/error/ExcludedByPassOrder.scala | 16 +-
.../vct/rewrite/exc/ContinueToBreak.scala | 62 +-
.../vct/rewrite/exc/EncodeBreakReturn.scala | 231 +-
.../rewrite/exc/EncodeTryThrowSignals.scala | 438 +-
.../rewrite/exc/SpecifyImplicitLabels.scala | 54 +-
.../vct/rewrite/exc/SwitchToGoto.scala | 88 +-
.../vct/rewrite/lang/LangBipToCol.scala | 407 +-
.../vct/rewrite/lang/LangCPPToCol.scala | 2857 +++++++---
src/rewrite/vct/rewrite/lang/LangCToCol.scala | 1784 ++++---
.../vct/rewrite/lang/LangJavaToCol.scala | 707 ++-
.../vct/rewrite/lang/LangLLVMToCol.scala | 205 +-
.../vct/rewrite/lang/LangPVLToCol.scala | 245 +-
.../vct/rewrite/lang/LangSilverToCol.scala | 22 +-
.../vct/rewrite/lang/LangSpecificToCol.scala | 565 +-
.../vct/rewrite/lang/LangTypesToCol.scala | 384 +-
.../vct/rewrite/lang/LangVeyMontToCol.scala | 171 +-
.../vct/rewrite/lang/NoSupportSelfLoop.scala | 20 +-
.../vct/rewrite/lang/ReplaceSYCLTypes.scala | 12 +-
.../vct/rewrite/rasi/AbstractProcess.scala | 497 +-
.../vct/rewrite/rasi/AbstractState.scala | 1169 +++--
.../vct/rewrite/rasi/ConcreteVariable.scala | 348 +-
.../vct/rewrite/rasi/ConstraintMap.scala | 111 +-
.../vct/rewrite/rasi/ConstraintSolver.scala | 513 +-
src/rewrite/vct/rewrite/rasi/Interval.scala | 783 +--
.../vct/rewrite/rasi/RASIConnection.scala | 19 +-
.../vct/rewrite/rasi/RASIGenerator.scala | 143 +-
.../vct/rewrite/rasi/StaticScanner.scala | 93 +-
.../vct/rewrite/rasi/UncertainValue.scala | 459 +-
src/rewrite/vct/rewrite/rasi/Utils.scala | 329 +-
.../vct/rewrite/rasi/VariableSelector.scala | 201 +-
src/rewrite/vct/rewrite/util/Comparison.scala | 72 +-
src/rewrite/vct/rewrite/util/Extract.scala | 121 +-
.../vct/rewrite/util/FreeVariables.scala | 72 +-
.../vct/rewrite/veymont/ChannelInfo.scala | 8 +-
.../veymont/DeduplicateChorGuards.scala | 48 +-
.../vct/rewrite/veymont/EncodeChannels.scala | 280 +-
.../veymont/EncodeChorBranchUnanimity.scala | 169 +-
.../rewrite/veymont/EncodeChoreography.scala | 545 +-
.../EncodeChoreographyParameters.scala | 131 +-
.../veymont/EncodeEndpointInequalities.scala | 133 +-
.../veymont/EncodeUnpointedGuard.scala | 76 +-
.../GenerateChoreographyPermissions.scala | 340 +-
.../veymont/GenerateImplementation.scala | 1079 ++--
.../veymont/InferEndpointContexts.scala | 199 +-
.../ParallelCommExprBuildingBlocks.scala | 10 +-
.../veymont/SpecializeEndpointClasses.scala | 199 +-
.../vct/rewrite/veymont/SplitChorGuards.scala | 96 +-
.../vct/rewrite/veymont/StructureCheck.scala | 117 +-
.../veymont/ThreadBuildingBlocks.scala | 27 +-
.../vct/rewrite/veymont/VeymontContext.scala | 58 +-
.../protobuf/ForwardingByteString.scala | 55 +-
.../google/protobuf/StreamingByteString.scala | 12 +-
.../serialize/LiteralOpaqueMessageBytes.scala | 6 +-
.../vct/serialize/OpaqueMessageBytes.scala | 13 +-
.../StreamingOpaqueMessageBytes.scala | 5 +-
src/viper/viper/api/SilverTreeCompare.scala | 123 +-
.../viper/api/backend/SilverBackend.scala | 594 ++-
.../viper/api/backend/carbon/Carbon.scala | 59 +-
.../backend/silicon/BranchRecordTask.scala | 21 +-
.../api/backend/silicon/CachedExpRender.scala | 6 +-
.../api/backend/silicon/DataRecordTask.scala | 85 +-
.../viper/api/backend/silicon/Silicon.scala | 164 +-
.../backend/silicon/SiliconLogListener.scala | 275 +-
.../viper/api/backend/silicon/Util.scala | 9 +-
.../viper/api/transform/ColSilverParser.scala | 16 +-
.../viper/api/transform/ColToSilver.scala | 1063 ++--
.../transform/SilverParserDummyFrontend.scala | 23 +-
.../viper/api/transform/SilverToCol.scala | 547 +-
1309 files changed, 56723 insertions(+), 31472 deletions(-)
diff --git a/src/col/vct/col/ast/Deserialize.scala b/src/col/vct/col/ast/Deserialize.scala
index dfeb4d3626..f9dcb4f35c 100644
--- a/src/col/vct/col/ast/Deserialize.scala
+++ b/src/col/vct/col/ast/Deserialize.scala
@@ -5,7 +5,8 @@ import vct.col.ast.ops.deserialize.DeserializeProgram
import scala.collection.mutable
object Deserialize {
- def deserializeProgram[G](program: vct.col.ast.serialize.Program, y: scala.Any): Program[G] = {
- DeserializeProgram.deserialize(program, mutable.HashMap())
- }
+ def deserializeProgram[G](
+ program: vct.col.ast.serialize.Program,
+ y: scala.Any,
+ ): Program[G] = { DeserializeProgram.deserialize(program, mutable.HashMap()) }
}
diff --git a/src/col/vct/col/ast/Node.scala b/src/col/vct/col/ast/Node.scala
index a477eb8720..838740745f 100644
--- a/src/col/vct/col/ast/Node.scala
+++ b/src/col/vct/col/ast/Node.scala
@@ -84,1362 +84,3746 @@ import vct.col.resolve.ctx._
import vct.col.resolve.lang.JavaAnnotationData
import vct.col.structure.{family, scopes}
-/** @inheritdoc */ sealed trait Node[G] extends NodeImpl[G]
+/** @inheritdoc */
+sealed trait Node[G] extends NodeImpl[G]
sealed trait NodeFamily[G] extends Node[G] with NodeFamilyImpl[G]
sealed trait Declaration[G] extends Node[G] with DeclarationImpl[G]
-@family final case class Verification[G](tasks: Seq[VerificationContext[G]], expectedErrors: Seq[ExpectedError])(implicit val o: Origin) extends NodeFamily[G] with VerificationImpl[G]
-@family final case class VerificationContext[G](program: Program[G])(implicit val o: Origin) extends NodeFamily[G] with VerificationContextImpl[G]
-
@family
-@scopes[GlobalDeclaration]
+final case class Verification[G](
+ tasks: Seq[VerificationContext[G]],
+ expectedErrors: Seq[ExpectedError],
+)(implicit val o: Origin)
+ extends NodeFamily[G] with VerificationImpl[G]
+@family
+final case class VerificationContext[G](program: Program[G])(
+ implicit val o: Origin
+) extends NodeFamily[G] with VerificationContextImpl[G]
+
+@family @scopes[GlobalDeclaration]
@scopes[ClassDeclaration]
@scopes[ADTDeclaration]
@scopes[ModelDeclaration]
@scopes[EnumConstant]
@scopes[Variable]
-final case class Program[G](declarations: Seq[GlobalDeclaration[G]])(val blame: Blame[UnsafeCoercion])(implicit val o: Origin) extends NodeFamily[G] with ProgramImpl[G]
+final case class Program[G](declarations: Seq[GlobalDeclaration[G]])(
+ val blame: Blame[UnsafeCoercion]
+)(implicit val o: Origin)
+ extends NodeFamily[G] with ProgramImpl[G]
-@family sealed trait Type[G] extends NodeFamily[G] with TypeImpl[G]
+@family
+sealed trait Type[G] extends NodeFamily[G] with TypeImpl[G]
object TNotAValue {
def unapply[G](t: TNotAValue[G]): Some[Referrable[G]] = Some(t.decl.get)
}
-
-final class TNotAValue[G]()(implicit val o: Origin = DiagnosticOrigin) extends Type[G] with TNotAValueImpl[G] {
+final class TNotAValue[G]()(implicit val o: Origin = DiagnosticOrigin)
+ extends Type[G] with TNotAValueImpl[G] {
var decl: Option[Referrable[G]] = None
}
-final case class TUnion[G](types: Seq[Type[G]])(implicit val o: Origin = DiagnosticOrigin) extends Type[G] with TUnionImpl[G]
-final case class TArray[G](element: Type[G])(implicit val o: Origin = DiagnosticOrigin) extends Type[G] with TArrayImpl[G]
-final case class TPointer[G](element: Type[G])(implicit val o: Origin = DiagnosticOrigin) extends Type[G] with TPointerImpl[G]
-final case class TType[G](t: Type[G])(implicit val o: Origin = DiagnosticOrigin) extends Type[G] with TTypeImpl[G]
-final case class TVar[G](ref: Ref[G, Variable[G]])(implicit val o: Origin = DiagnosticOrigin) extends Type[G] with TVarImpl[G]
+final case class TUnion[G](types: Seq[Type[G]])(
+ implicit val o: Origin = DiagnosticOrigin
+) extends Type[G] with TUnionImpl[G]
+final case class TArray[G](element: Type[G])(
+ implicit val o: Origin = DiagnosticOrigin
+) extends Type[G] with TArrayImpl[G]
+final case class TPointer[G](element: Type[G])(
+ implicit val o: Origin = DiagnosticOrigin
+) extends Type[G] with TPointerImpl[G]
+final case class TType[G](t: Type[G])(implicit val o: Origin = DiagnosticOrigin)
+ extends Type[G] with TTypeImpl[G]
+final case class TVar[G](ref: Ref[G, Variable[G]])(
+ implicit val o: Origin = DiagnosticOrigin
+) extends Type[G] with TVarImpl[G]
sealed trait CompositeType[G] extends Type[G] with CompositeTypeImpl[G]
sealed trait SizedType[G] extends CompositeType[G] with SizedTypeImpl[G]
-final case class TSeq[G](element: Type[G])(implicit val o: Origin = DiagnosticOrigin) extends SizedType[G] with TSeqImpl[G]
-final case class TSet[G](element: Type[G])(implicit val o: Origin = DiagnosticOrigin) extends SizedType[G] with TSetImpl[G]
-final case class TBag[G](element: Type[G])(implicit val o: Origin = DiagnosticOrigin) extends SizedType[G] with TBagImpl[G]
-final case class TMap[G](key: Type[G], value: Type[G])(implicit val o: Origin = DiagnosticOrigin) extends SizedType[G] with TMapImpl[G]
-
-final case class TOption[G](element: Type[G])(implicit val o: Origin = DiagnosticOrigin) extends CompositeType[G] with TOptionImpl[G]
-final case class TTuple[G](elements: Seq[Type[G]])(implicit val o: Origin = DiagnosticOrigin) extends CompositeType[G] with TTupleImpl[G]
-final case class TEither[G](left: Type[G], right: Type[G])(implicit val o: Origin = DiagnosticOrigin) extends CompositeType[G] with TEitherImpl[G]
-final case class TMatrix[G](element: Type[G])(implicit val o: Origin = DiagnosticOrigin) extends CompositeType[G] with TMatrixImpl[G]
-final case class TVector[G](size: BigInt, element: Type[G])(implicit val o: Origin = DiagnosticOrigin) extends CompositeType[G] with TVectorImpl[G]
+final case class TSeq[G](element: Type[G])(
+ implicit val o: Origin = DiagnosticOrigin
+) extends SizedType[G] with TSeqImpl[G]
+final case class TSet[G](element: Type[G])(
+ implicit val o: Origin = DiagnosticOrigin
+) extends SizedType[G] with TSetImpl[G]
+final case class TBag[G](element: Type[G])(
+ implicit val o: Origin = DiagnosticOrigin
+) extends SizedType[G] with TBagImpl[G]
+final case class TMap[G](key: Type[G], value: Type[G])(
+ implicit val o: Origin = DiagnosticOrigin
+) extends SizedType[G] with TMapImpl[G]
+
+final case class TOption[G](element: Type[G])(
+ implicit val o: Origin = DiagnosticOrigin
+) extends CompositeType[G] with TOptionImpl[G]
+final case class TTuple[G](elements: Seq[Type[G]])(
+ implicit val o: Origin = DiagnosticOrigin
+) extends CompositeType[G] with TTupleImpl[G]
+final case class TEither[G](left: Type[G], right: Type[G])(
+ implicit val o: Origin = DiagnosticOrigin
+) extends CompositeType[G] with TEitherImpl[G]
+final case class TMatrix[G](element: Type[G])(
+ implicit val o: Origin = DiagnosticOrigin
+) extends CompositeType[G] with TMatrixImpl[G]
+final case class TVector[G](size: BigInt, element: Type[G])(
+ implicit val o: Origin = DiagnosticOrigin
+) extends CompositeType[G] with TVectorImpl[G]
sealed trait PrimitiveType[G] extends Type[G] with PrimitiveTypeImpl[G]
-final case class TAny[G]()(implicit val o: Origin = DiagnosticOrigin) extends PrimitiveType[G] with TAnyImpl[G]
-final case class TNothing[G]()(implicit val o: Origin = DiagnosticOrigin) extends PrimitiveType[G] with TNothingImpl[G]
-final case class TAnyValue[G]()(implicit val o: Origin = DiagnosticOrigin) extends PrimitiveType[G] with TAnyValueImpl[G]
-final case class TVoid[G]()(implicit val o: Origin = DiagnosticOrigin) extends PrimitiveType[G] with TVoidImpl[G]
-final case class TNull[G]()(implicit val o: Origin = DiagnosticOrigin) extends PrimitiveType[G] with TNullImpl[G]
-final case class TBool[G]()(implicit val o: Origin = DiagnosticOrigin) extends PrimitiveType[G] with TBoolImpl[G]
-final case class TResource[G]()(implicit val o: Origin = DiagnosticOrigin) extends PrimitiveType[G] with TResourceImpl[G]
-final case class TResourceVal[G]()(implicit val o: Origin = DiagnosticOrigin) extends PrimitiveType[G] with TResourceValImpl[G]
-final case class TChar[G]()(implicit val o: Origin = DiagnosticOrigin) extends PrimitiveType[G] with TCharImpl[G]
-final case class TString[G]()(implicit val o: Origin = DiagnosticOrigin) extends PrimitiveType[G] with TStringImpl[G]
-final case class TRef[G]()(implicit val o: Origin = DiagnosticOrigin) extends PrimitiveType[G] with TRefImpl[G]
-final case class TProcess[G]()(implicit val o: Origin = DiagnosticOrigin) extends PrimitiveType[G] with TProcessImpl[G]
+final case class TAny[G]()(implicit val o: Origin = DiagnosticOrigin)
+ extends PrimitiveType[G] with TAnyImpl[G]
+final case class TNothing[G]()(implicit val o: Origin = DiagnosticOrigin)
+ extends PrimitiveType[G] with TNothingImpl[G]
+final case class TAnyValue[G]()(implicit val o: Origin = DiagnosticOrigin)
+ extends PrimitiveType[G] with TAnyValueImpl[G]
+final case class TVoid[G]()(implicit val o: Origin = DiagnosticOrigin)
+ extends PrimitiveType[G] with TVoidImpl[G]
+final case class TNull[G]()(implicit val o: Origin = DiagnosticOrigin)
+ extends PrimitiveType[G] with TNullImpl[G]
+final case class TBool[G]()(implicit val o: Origin = DiagnosticOrigin)
+ extends PrimitiveType[G] with TBoolImpl[G]
+final case class TResource[G]()(implicit val o: Origin = DiagnosticOrigin)
+ extends PrimitiveType[G] with TResourceImpl[G]
+final case class TResourceVal[G]()(implicit val o: Origin = DiagnosticOrigin)
+ extends PrimitiveType[G] with TResourceValImpl[G]
+final case class TChar[G]()(implicit val o: Origin = DiagnosticOrigin)
+ extends PrimitiveType[G] with TCharImpl[G]
+final case class TString[G]()(implicit val o: Origin = DiagnosticOrigin)
+ extends PrimitiveType[G] with TStringImpl[G]
+final case class TRef[G]()(implicit val o: Origin = DiagnosticOrigin)
+ extends PrimitiveType[G] with TRefImpl[G]
+final case class TProcess[G]()(implicit val o: Origin = DiagnosticOrigin)
+ extends PrimitiveType[G] with TProcessImpl[G]
sealed trait NumericType[G] extends PrimitiveType[G] with NumericTypeImpl[G]
sealed trait FloatType[G] extends NumericType[G] with FloatTypeImpl[G]
sealed trait IntType[G] extends NumericType[G] with IntTypeImpl[G]
-final case class TInt[G]()(implicit val o: Origin = DiagnosticOrigin) extends IntType[G] with TIntImpl[G]
-final case class TBoundedInt[G](gte: BigInt, lt: BigInt)(implicit val o: Origin = DiagnosticOrigin) extends IntType[G] with TBoundedIntImpl[G]
-final case class TFloat[G](exponent: Int, mantissa: Int)(implicit val o: Origin = DiagnosticOrigin) extends FloatType[G] with TFloatImpl[G]
-final case class TRational[G]()(implicit val o: Origin = DiagnosticOrigin) extends NumericType[G] with TRationalImpl[G]
-final case class TFraction[G]()(implicit val o: Origin = DiagnosticOrigin) extends NumericType[G] with TFractionImpl[G]
-final case class TZFraction[G]()(implicit val o: Origin = DiagnosticOrigin) extends NumericType[G] with TZFractionImpl[G]
+final case class TInt[G]()(implicit val o: Origin = DiagnosticOrigin)
+ extends IntType[G] with TIntImpl[G]
+final case class TBoundedInt[G](gte: BigInt, lt: BigInt)(
+ implicit val o: Origin = DiagnosticOrigin
+) extends IntType[G] with TBoundedIntImpl[G]
+final case class TFloat[G](exponent: Int, mantissa: Int)(
+ implicit val o: Origin = DiagnosticOrigin
+) extends FloatType[G] with TFloatImpl[G]
+final case class TRational[G]()(implicit val o: Origin = DiagnosticOrigin)
+ extends NumericType[G] with TRationalImpl[G]
+final case class TFraction[G]()(implicit val o: Origin = DiagnosticOrigin)
+ extends NumericType[G] with TFractionImpl[G]
+final case class TZFraction[G]()(implicit val o: Origin = DiagnosticOrigin)
+ extends NumericType[G] with TZFractionImpl[G]
sealed trait DeclaredType[G] extends Type[G] with DeclaredTypeImpl[G]
-final case class TModel[G](model: Ref[G, Model[G]])(implicit val o: Origin = DiagnosticOrigin) extends DeclaredType[G] with TModelImpl[G]
-final case class TClass[G](cls: Ref[G, Class[G]], typeArgs: Seq[Type[G]])(implicit val o: Origin = DiagnosticOrigin) extends DeclaredType[G] with TClassImpl[G]
-final case class TAnyClass[G]()(implicit val o: Origin = DiagnosticOrigin) extends DeclaredType[G] with TAnyClassImpl[G]
-final case class TAxiomatic[G](adt: Ref[G, AxiomaticDataType[G]], args: Seq[Type[G]])(implicit val o: Origin = DiagnosticOrigin) extends DeclaredType[G] with TAxiomaticImpl[G]
-final case class TEnum[G](enum: Ref[G, Enum[G]])(implicit val o: Origin = DiagnosticOrigin) extends DeclaredType[G] with TEnumImpl[G]
-final case class TProverType[G](ref: Ref[G, ProverType[G]])(implicit val o: Origin = DiagnosticOrigin) extends DeclaredType[G] with TProverTypeImpl[G]
-final case class TVeyMontChannel[G](channelType: String)(implicit val o: Origin = DiagnosticOrigin) extends DeclaredType[G] with TVeyMontChannelImpl[G]
-
-@family sealed trait ParRegion[G] extends NodeFamily[G] with ParRegionImpl[G]
-final case class ParParallel[G](regions: Seq[ParRegion[G]])(val blame: Blame[ParPreconditionFailed])(implicit val o: Origin) extends ParRegion[G] with ParParallelImpl[G]
-final case class ParSequential[G](regions: Seq[ParRegion[G]])(val blame: Blame[ParPreconditionFailed])(implicit val o: Origin) extends ParRegion[G] with ParSequentialImpl[G]
-@scopes[Variable] @scopes[SendDecl] @scopes[ParBlockDecl] final case class ParBlock[G](decl: ParBlockDecl[G], iters: Seq[IterVariable[G]], context_everywhere: Expr[G], requires: Expr[G], ensures: Expr[G], content: Statement[G])(val blame: Blame[ParBlockFailure])(implicit val o: Origin) extends ParRegion[G] with ParBlockImpl[G]
+final case class TModel[G](model: Ref[G, Model[G]])(
+ implicit val o: Origin = DiagnosticOrigin
+) extends DeclaredType[G] with TModelImpl[G]
+final case class TClass[G](cls: Ref[G, Class[G]], typeArgs: Seq[Type[G]])(
+ implicit val o: Origin = DiagnosticOrigin
+) extends DeclaredType[G] with TClassImpl[G]
+final case class TAnyClass[G]()(implicit val o: Origin = DiagnosticOrigin)
+ extends DeclaredType[G] with TAnyClassImpl[G]
+final case class TAxiomatic[G](
+ adt: Ref[G, AxiomaticDataType[G]],
+ args: Seq[Type[G]],
+)(implicit val o: Origin = DiagnosticOrigin)
+ extends DeclaredType[G] with TAxiomaticImpl[G]
+final case class TEnum[G](enum: Ref[G, Enum[G]])(
+ implicit val o: Origin = DiagnosticOrigin
+) extends DeclaredType[G] with TEnumImpl[G]
+final case class TProverType[G](ref: Ref[G, ProverType[G]])(
+ implicit val o: Origin = DiagnosticOrigin
+) extends DeclaredType[G] with TProverTypeImpl[G]
+final case class TVeyMontChannel[G](channelType: String)(
+ implicit val o: Origin = DiagnosticOrigin
+) extends DeclaredType[G] with TVeyMontChannelImpl[G]
-@family sealed trait LoopContract[G] extends NodeFamily[G] with LoopContractImpl[G]
-final case class LoopInvariant[G](invariant: Expr[G], decreases: Option[DecreasesClause[G]])(val blame: Blame[LoopInvariantFailure])(implicit val o: Origin) extends LoopContract[G] with LoopInvariantImpl[G]
-final case class IterationContract[G](requires: Expr[G], ensures: Expr[G], context_everywhere: Expr[G])(val blame: Blame[ParBlockFailure])(implicit val o: Origin) extends LoopContract[G] with IterationContractImpl[G]
+@family
+sealed trait ParRegion[G] extends NodeFamily[G] with ParRegionImpl[G]
+final case class ParParallel[G](regions: Seq[ParRegion[G]])(
+ val blame: Blame[ParPreconditionFailed]
+)(implicit val o: Origin)
+ extends ParRegion[G] with ParParallelImpl[G]
+final case class ParSequential[G](regions: Seq[ParRegion[G]])(
+ val blame: Blame[ParPreconditionFailed]
+)(implicit val o: Origin)
+ extends ParRegion[G] with ParSequentialImpl[G]
+@scopes[Variable]
+@scopes[SendDecl]
+@scopes[ParBlockDecl]
+final case class ParBlock[G](
+ decl: ParBlockDecl[G],
+ iters: Seq[IterVariable[G]],
+ context_everywhere: Expr[G],
+ requires: Expr[G],
+ ensures: Expr[G],
+ content: Statement[G],
+)(val blame: Blame[ParBlockFailure])(implicit val o: Origin)
+ extends ParRegion[G] with ParBlockImpl[G]
-@family @scopes[Variable] final case class CatchClause[G](decl: Variable[G], body: Statement[G])(implicit val o: Origin) extends NodeFamily[G] with CatchClauseImpl[G]
+@family
+sealed trait LoopContract[G] extends NodeFamily[G] with LoopContractImpl[G]
+final case class LoopInvariant[G](
+ invariant: Expr[G],
+ decreases: Option[DecreasesClause[G]],
+)(val blame: Blame[LoopInvariantFailure])(implicit val o: Origin)
+ extends LoopContract[G] with LoopInvariantImpl[G]
+final case class IterationContract[G](
+ requires: Expr[G],
+ ensures: Expr[G],
+ context_everywhere: Expr[G],
+)(val blame: Blame[ParBlockFailure])(implicit val o: Origin)
+ extends LoopContract[G] with IterationContractImpl[G]
+
+@family @scopes[Variable]
+final case class CatchClause[G](decl: Variable[G], body: Statement[G])(
+ implicit val o: Origin
+) extends NodeFamily[G] with CatchClauseImpl[G]
-@family final case class IterVariable[G](variable: Variable[G], from: Expr[G], to: Expr[G])(implicit val o: Origin) extends NodeFamily[G] with IterVariableImpl[G]
+@family
+final case class IterVariable[G](
+ variable: Variable[G],
+ from: Expr[G],
+ to: Expr[G],
+)(implicit val o: Origin)
+ extends NodeFamily[G] with IterVariableImpl[G]
-@family sealed trait Statement[G] extends NodeFamily[G] with StatementImpl[G]
+@family
+sealed trait Statement[G] extends NodeFamily[G] with StatementImpl[G]
sealed trait PurelySequentialStatement[G] extends Statement[G]
sealed trait ControlContainerStatement[G] extends Statement[G]
-sealed trait ExpressionContainerStatement[G] extends Statement[G] with ExpressionContainerStatementImpl[G]
-
-final case class PVLBranch[G](branches: Seq[(Expr[G], Statement[G])])(val blame: Blame[FrontendIfFailure])(implicit val o: Origin) extends Statement[G] with ControlContainerStatement[G] with PVLBranchImpl[G]
-final case class PVLLoop[G](init: Statement[G], cond: Expr[G], update: Statement[G], contract: LoopContract[G], body: Statement[G])(val blame: Blame[FrontEndLoopFailure])(implicit val o: Origin) extends Statement[G] with ControlContainerStatement[G] with PVLLoopImpl[G]
-
-sealed trait NonExecutableStatement[G] extends Statement[G] with NonExecutableStatementImpl[G]
-final case class LocalDecl[G](local: Variable[G])(implicit val o: Origin) extends NonExecutableStatement[G] with PurelySequentialStatement[G] with LocalDeclImpl[G]
-final case class SpecIgnoreStart[G]()(implicit val o: Origin) extends NonExecutableStatement[G] with PurelySequentialStatement[G] with SpecIgnoreStartImpl[G]
-final case class SpecIgnoreEnd[G]()(implicit val o: Origin) extends NonExecutableStatement[G] with PurelySequentialStatement[G] with SpecIgnoreEndImpl[G]
-
-sealed trait NormallyCompletingStatement[G] extends Statement[G] with NormallyCompletingStatementImpl[G]
-final case class Assign[G](target: Expr[G], value: Expr[G])(val blame: Blame[AssignFailed])(implicit val o: Origin) extends NormallyCompletingStatement[G] with AssignImpl[G]
-final case class Send[G](decl: SendDecl[G], delta: BigInt, res: Expr[G])(val blame: Blame[SendFailed])(implicit val o: Origin) extends NormallyCompletingStatement[G] with ExpressionContainerStatement[G] with SendImpl[G]
-final case class Recv[G](ref: Ref[G, SendDecl[G]])(implicit val o: Origin) extends NormallyCompletingStatement[G] with PurelySequentialStatement[G] with RecvImpl[G]
-sealed trait SwitchCase[G] extends NormallyCompletingStatement[G] with SwitchCaseImpl[G]
-final case class DefaultCase[G]()(implicit val o: Origin) extends SwitchCase[G] with PurelySequentialStatement[G] with DefaultCaseImpl[G]
-final case class Case[G](pattern: Expr[G])(implicit val o: Origin) extends SwitchCase[G] with PurelySequentialStatement[G] with CaseImpl[G]
-final case class Label[G](decl: LabelDecl[G], stat: Statement[G])(implicit val o: Origin) extends NormallyCompletingStatement[G] with ControlContainerStatement[G] with LabelImpl[G]
-final case class Goto[G](lbl: Ref[G, LabelDecl[G]])(implicit val o: Origin) extends NormallyCompletingStatement[G] with GotoImpl[G]
-final case class Exhale[G](res: Expr[G])(val blame: Blame[ExhaleFailed])(implicit val o: Origin) extends NormallyCompletingStatement[G] with ExpressionContainerStatement[G] with ExhaleImpl[G]
-final case class Assert[G](res: Expr[G])(val blame: Blame[AssertFailed])(implicit val o: Origin) extends NormallyCompletingStatement[G] with ExpressionContainerStatement[G] with AssertImpl[G]
-final case class Refute[G](assn: Expr[G])(val blame: Blame[RefuteFailed])(implicit val o: Origin) extends NormallyCompletingStatement[G] with ExpressionContainerStatement[G] with RefuteImpl[G]
-final case class Inhale[G](res: Expr[G])(implicit val o: Origin) extends NormallyCompletingStatement[G] with ExpressionContainerStatement[G] with InhaleImpl[G]
-final case class Assume[G](assn: Expr[G])(implicit val o: Origin) extends NormallyCompletingStatement[G] with ExpressionContainerStatement[G] with AssumeImpl[G]
-final case class Instantiate[G](cls: Ref[G, Class[G]], out: Expr[G])(implicit val o: Origin) extends NormallyCompletingStatement[G] with ExpressionContainerStatement[G] with InstantiateImpl[G]
-final case class Wait[G](obj: Expr[G])(val blame: Blame[UnlockFailure])(implicit val o: Origin) extends NormallyCompletingStatement[G] with ExpressionContainerStatement[G] with WaitImpl[G]
-final case class Notify[G](obj: Expr[G])(val blame: Blame[NotifyFailed])(implicit val o: Origin) extends NormallyCompletingStatement[G] with ExpressionContainerStatement[G] with NotifyImpl[G]
-final case class Fork[G](obj: Expr[G])(val blame: Blame[ForkFailure])(implicit val o: Origin) extends NormallyCompletingStatement[G] with ExpressionContainerStatement[G] with ForkImpl[G]
-final case class Join[G](obj: Expr[G])(val blame: Blame[JoinFailure])(implicit val o: Origin) extends NormallyCompletingStatement[G] with ExpressionContainerStatement[G] with JoinImpl[G]
-final case class Lock[G](obj: Expr[G])(val blame: Blame[LockFailure])(implicit val o: Origin) extends NormallyCompletingStatement[G] with ExpressionContainerStatement[G] with LockImpl[G]
-final case class Unlock[G](obj: Expr[G])(val blame: Blame[UnlockFailure])(implicit val o: Origin) extends NormallyCompletingStatement[G] with ExpressionContainerStatement[G] with UnlockImpl[G]
-final case class Commit[G](obj: Expr[G])(val blame: Blame[CommitFailed])(implicit val o: Origin) extends NormallyCompletingStatement[G] with ExpressionContainerStatement[G] with CommitImpl[G]
-final case class Fold[G](res: Expr[G])(val blame: Blame[FoldFailed])(implicit val o: Origin) extends NormallyCompletingStatement[G] with ExpressionContainerStatement[G] with FoldImpl[G]
-final case class Unfold[G](res: Expr[G])(val blame: Blame[UnfoldFailed])(implicit val o: Origin) extends NormallyCompletingStatement[G] with ExpressionContainerStatement[G] with UnfoldImpl[G]
-final case class WandApply[G](res: Expr[G])(val blame: Blame[WandApplyFailed])(implicit val o: Origin) extends NormallyCompletingStatement[G] with ExpressionContainerStatement[G] with WandApplyImpl[G]
-final case class Havoc[G](loc: Expr[G])(implicit val o: Origin) extends NormallyCompletingStatement[G] with ExpressionContainerStatement[G] with HavocImpl[G]
-final case class FramedProof[G](pre: Expr[G], body: Statement[G], post: Expr[G])(val blame: Blame[FramedProofFailure])(implicit val o: Origin) extends NormallyCompletingStatement[G] with ControlContainerStatement[G] with FramedProofImpl[G]
-final case class Extract[G](contractedStatement: Statement[G])(implicit val o: Origin) extends NormallyCompletingStatement[G] with ControlContainerStatement[G] with ExtractImpl[G]
-
-sealed trait ExceptionalStatement[G] extends Statement[G] with ExceptionalStatementImpl[G]
-final case class Eval[G](expr: Expr[G])(implicit val o: Origin) extends ExceptionalStatement[G] with ControlContainerStatement[G] with EvalImpl[G]
-sealed trait InvocationStatement[G] extends ExceptionalStatement[G] with InvokingNode[G] with InvocationStatementImpl[G]
-final case class InvokeProcedure[G](ref: Ref[G, Procedure[G]], args: Seq[Expr[G]], outArgs: Seq[Expr[G]], typeArgs: Seq[Type[G]], givenMap: Seq[(Ref[G, Variable[G]], Expr[G])], yields: Seq[(Expr[G], Ref[G, Variable[G]])])(val blame: Blame[InvocationFailure])(implicit val o: Origin) extends InvocationStatement[G] with ControlContainerStatement[G] with InvokeProcedureImpl[G]
-final case class InvokeConstructor[G](ref: Ref[G, Constructor[G]], classTypeArgs: Seq[Type[G]], out: Expr[G], args: Seq[Expr[G]], outArgs: Seq[Expr[G]], typeArgs: Seq[Type[G]], givenMap: Seq[(Ref[G, Variable[G]], Expr[G])], yields: Seq[(Expr[G], Ref[G, Variable[G]])])(val blame: Blame[InvocationFailure])(implicit val o: Origin) extends InvocationStatement[G] with ControlContainerStatement[G] with InvokeConstructorImpl[G]
-final case class InvokeMethod[G](obj: Expr[G], ref: Ref[G, InstanceMethod[G]], args: Seq[Expr[G]], outArgs: Seq[Expr[G]], typeArgs: Seq[Type[G]], givenMap: Seq[(Ref[G, Variable[G]], Expr[G])], yields: Seq[(Expr[G], Ref[G, Variable[G]])])(val blame: Blame[InstanceInvocationFailure])(implicit val o: Origin) extends InvocationStatement[G] with InstanceApply[G] with ControlContainerStatement[G] with InvokeMethodImpl[G]
-final case class Return[G](result: Expr[G])(implicit val o: Origin) extends ExceptionalStatement[G] with ExpressionContainerStatement[G] with ReturnImpl[G]
-final case class Throw[G](obj: Expr[G])(val blame: Blame[ThrowNull])(implicit val o: Origin) extends ExceptionalStatement[G] with ExpressionContainerStatement[G] with ThrowImpl[G]
-final case class Break[G](label: Option[Ref[G, LabelDecl[G]]])(implicit val o: Origin) extends ExceptionalStatement[G] with BreakImpl[G]
-final case class Continue[G](label: Option[Ref[G, LabelDecl[G]]])(implicit val o: Origin) extends ExceptionalStatement[G] with ContinueImpl[G]
-
-sealed trait CompositeStatement[G] extends Statement[G] with CompositeStatementImpl[G]
-final case class Block[G](statements: Seq[Statement[G]])(implicit val o: Origin) extends CompositeStatement[G] with ControlContainerStatement[G] with BlockImpl[G]
-@scopes[Variable] @scopes[CLocalDeclaration] @scopes[CPPLocalDeclaration] @scopes[JavaLocalDeclaration] final case class Scope[G](locals: Seq[Variable[G]], body: Statement[G])(implicit val o: Origin) extends CompositeStatement[G] with ControlContainerStatement[G] with ScopeImpl[G]
-final case class Branch[G](branches: Seq[(Expr[G], Statement[G])])(implicit val o: Origin) extends CompositeStatement[G] with ControlContainerStatement[G] with BranchImpl[G]
-final case class IndetBranch[G](branches: Seq[Statement[G]])(implicit val o: Origin) extends CompositeStatement[G] with ControlContainerStatement[G] with IndetBranchImpl[G]
-final case class Switch[G](expr: Expr[G], body: Statement[G])(implicit val o: Origin) extends CompositeStatement[G] with ControlContainerStatement[G] with SwitchImpl[G]
-@scopes[SendDecl] final case class Loop[G](init: Statement[G], cond: Expr[G], update: Statement[G], contract: LoopContract[G], body: Statement[G])(implicit val o: Origin) extends CompositeStatement[G] with ControlContainerStatement[G] with LoopImpl[G]
-@scopes[Variable] final case class RangedFor[G](iter: IterVariable[G], contract: LoopContract[G], body: Statement[G])(implicit val o: Origin) extends CompositeStatement[G] with Declarator[G] with ControlContainerStatement[G] with RangedForImpl[G]
-final case class TryCatchFinally[G](body: Statement[G], after: Statement[G], catches: Seq[CatchClause[G]])(implicit val o: Origin) extends CompositeStatement[G] with ControlContainerStatement[G] with TryCatchFinallyImpl[G]
-final case class Synchronized[G](obj: Expr[G], body: Statement[G])(val blame: Blame[LockRegionFailure])(implicit val o: Origin) extends CompositeStatement[G] with ControlContainerStatement[G] with SynchronizedImpl[G]
-@scopes[ParInvariantDecl] final case class ParInvariant[G](decl: ParInvariantDecl[G], inv: Expr[G], content: Statement[G])(val blame: Blame[ParInvariantNotEstablished])(implicit val o: Origin) extends CompositeStatement[G] with ControlContainerStatement[G] with ParInvariantImpl[G]
-final case class ParAtomic[G](inv: Seq[Ref[G, ParInvariantDecl[G]]], content: Statement[G])(val blame: Blame[ParInvariantNotMaintained])(implicit val o: Origin) extends CompositeStatement[G] with ControlContainerStatement[G] with ParAtomicImpl[G]
-final case class ParBarrier[G](block: Ref[G, ParBlockDecl[G]], invs: Seq[Ref[G, ParInvariantDecl[G]]], requires: Expr[G], ensures: Expr[G], content: Statement[G])(val blame: Blame[ParBarrierFailure])(implicit val o: Origin) extends CompositeStatement[G] with ControlContainerStatement[G] with ParBarrierImpl[G]
-final case class ParStatement[G](impl: ParRegion[G])(implicit val o: Origin) extends CompositeStatement[G] with PurelySequentialStatement[G] with ParStatementImpl[G]
-@scopes[Variable] final case class VecBlock[G](iters: Seq[IterVariable[G]], requires: Expr[G], ensures: Expr[G], content: Statement[G])(implicit val o: Origin) extends CompositeStatement[G] with ControlContainerStatement[G] with VecBlockImpl[G]
-final case class WandPackage[G](res: Expr[G], proof: Statement[G])(val blame: Blame[PackageFailure])(implicit val o: Origin) extends CompositeStatement[G] with ControlContainerStatement[G] with WandPackageImpl[G]
-final case class ModelDo[G](model: Expr[G], perm: Expr[G], after: Expr[G], action: Expr[G], impl: Statement[G])(implicit val o: Origin) extends CompositeStatement[G] with ControlContainerStatement[G] with ModelDoImpl[G]
-
-@family sealed trait GlobalDeclaration[G] extends Declaration[G] with GlobalDeclarationImpl[G]
-final class HeapVariable[G](val t: Type[G])(implicit val o: Origin) extends GlobalDeclaration[G] with HeapVariableImpl[G]
-final class SimplificationRule[G](val axiom: Expr[G])(implicit val o: Origin) extends GlobalDeclaration[G] with SimplificationRuleImpl[G]
-@scopes[Variable] final class AxiomaticDataType[G](val decls: Seq[ADTDeclaration[G]], val typeArgs: Seq[Variable[G]])(implicit val o: Origin) extends GlobalDeclaration[G] with AxiomaticDataTypeImpl[G]
-final class Class[G](val typeArgs: Seq[Variable[G]], val decls: Seq[ClassDeclaration[G]], val supports: Seq[Type[G]], val intrinsicLockInvariant: Expr[G])(implicit val o: Origin) extends GlobalDeclaration[G] with ClassImpl[G]
-final class Model[G](val declarations: Seq[ModelDeclaration[G]])(implicit val o: Origin) extends GlobalDeclaration[G] with Declarator[G] with ModelImpl[G]
-@scopes[LabelDecl] final class Function[G](val returnType: Type[G], val args: Seq[Variable[G]], val typeArgs: Seq[Variable[G]],
- val body: Option[Expr[G]], val contract: ApplicableContract[G], val inline: Boolean = false, val threadLocal: Boolean = false)
- (val blame: Blame[ContractedFailure])(implicit val o: Origin)
- extends GlobalDeclaration[G] with AbstractFunction[G] with FunctionImpl[G]
-@scopes[LabelDecl] final class Procedure[G](val returnType: Type[G],
- val args: Seq[Variable[G]], val outArgs: Seq[Variable[G]], val typeArgs: Seq[Variable[G]],
- val body: Option[Statement[G]],
- val contract: ApplicableContract[G],
- val inline: Boolean = false, val pure: Boolean = false, val vesuv_entry: Boolean = false)
- (val blame: Blame[CallableFailure])(implicit val o: Origin)
- extends GlobalDeclaration[G] with AbstractMethod[G] with ProcedureImpl[G]
-final class VeSUVMainMethod[G](val body: Option[Statement[G]])(val blame: Blame[CallableFailure])(implicit val o: Origin) extends GlobalDeclaration[G] with VeSUVMainMethodImpl[G]
-@scopes[Variable] final class Predicate[G](val args: Seq[Variable[G]], val body: Option[Expr[G]],
- val threadLocal: Boolean = false, val inline: Boolean = false)(implicit val o: Origin)
- extends GlobalDeclaration[G] with AbstractPredicate[G] with PredicateImpl[G]
-final class Enum[G](val constants: Seq[EnumConstant[G]])(implicit val o: Origin) extends GlobalDeclaration[G] with EnumImpl[G]
-@family final class EnumConstant[G]()(implicit val o: Origin) extends Declaration[G] with EnumConstantImpl[G]
-
-final class ProverType[G](val interpretation: Seq[(ProverLanguage[G], String)])(implicit val o: Origin) extends GlobalDeclaration[G] with ProverTypeImpl[G]
-final class ProverFunction[G](val interpretation: Seq[(ProverLanguage[G], String)], val args: Seq[Variable[G]], val returnType: Type[G])(implicit val o: Origin) extends GlobalDeclaration[G] with Applicable[G] with ProverFunctionImpl[G]
-
-@family sealed trait ProverLanguage[G] extends NodeFamily[G] with ProverLanguageImpl[G]
-case class SmtLib[G]()(implicit val o: Origin) extends ProverLanguage[G] with SmtLibImpl[G]
-case class Boogie[G]()(implicit val o: Origin) extends ProverLanguage[G] with BoogieImpl[G]
-
-@family sealed trait ClassDeclaration[G] extends Declaration[G] with ClassDeclarationImpl[G]
-@scopes[LabelDecl] final class InstanceFunction[G](val returnType: Type[G], val args: Seq[Variable[G]], val typeArgs: Seq[Variable[G]],
- val body: Option[Expr[G]], val contract: ApplicableContract[G], val inline: Boolean, val threadLocal: Boolean = false)
- (val blame: Blame[ContractedFailure])(implicit val o: Origin)
- extends ClassDeclaration[G] with AbstractFunction[G] with InstanceFunctionImpl[G]
-@scopes[LabelDecl] final class Constructor[G](val cls: Ref[G, Class[G]], val args: Seq[Variable[G]], val outArgs: Seq[Variable[G]], val typeArgs: Seq[Variable[G]], val body: Option[Statement[G]], val contract: ApplicableContract[G], val inline: Boolean = false)(val blame: Blame[CallableFailure])(implicit val o: Origin) extends ClassDeclaration[G] with AbstractMethod[G] with ConstructorImpl[G]
-@scopes[LabelDecl] final class InstanceMethod[G](val returnType: Type[G],
- val args: Seq[Variable[G]], val outArgs: Seq[Variable[G]], val typeArgs: Seq[Variable[G]],
- val body: Option[Statement[G]],
- val contract: ApplicableContract[G],
- val inline: Boolean = false, val pure: Boolean = false)
- (val blame: Blame[CallableFailure])(implicit val o: Origin)
- extends ClassDeclaration[G] with AbstractMethod[G] with InstanceMethodImpl[G]
-@scopes[Variable] final class InstancePredicate[G](val args: Seq[Variable[G]], val body: Option[Expr[G]],
- val threadLocal: Boolean = false, val inline: Boolean = false)(implicit val o: Origin)
- extends ClassDeclaration[G] with AbstractPredicate[G] with InstancePredicateImpl[G]
-final class InstanceField[G](val t: Type[G], val flags: Seq[FieldFlag[G]])(implicit val o: Origin) extends ClassDeclaration[G] with Field[G] with InstanceFieldImpl[G]
-final class RunMethod[G](val body: Option[Statement[G]], val contract: ApplicableContract[G])(val blame: Blame[CallableFailure])(implicit val o: Origin) extends ClassDeclaration[G] with RunMethodImpl[G]
-final class InstanceOperatorFunction[G](val returnType: Type[G], val operator: Operator[G], val args: Seq[Variable[G]],
- val body: Option[Expr[G]], val contract: ApplicableContract[G],
- val inline: Boolean, val threadLocal: Boolean = false)
- (val blame: Blame[ContractedFailure])(implicit val o: Origin)
- extends ClassDeclaration[G] with AbstractFunction[G] with InstanceOperatorFunctionImpl[G]
-final class InstanceOperatorMethod[G](val returnType: Type[G],
- val operator: Operator[G],
- val args: Seq[Variable[G]],
- val body: Option[Statement[G]],
- val contract: ApplicableContract[G],
- val inline: Boolean = false, val pure: Boolean = false)
- (val blame: Blame[CallableFailure])(implicit val o: Origin)
- extends ClassDeclaration[G] with AbstractMethod[G] with InstanceOperatorMethodImpl[G]
-
-@family sealed trait Operator[G] extends NodeFamily[G] with OperatorImpl[G]
-case class OperatorLeftPlus[G]()(implicit val o: Origin = DiagnosticOrigin) extends Operator[G] with OperatorLeftPlusImpl[G]
-case class OperatorRightPlus[G]()(implicit val o: Origin = DiagnosticOrigin) extends Operator[G] with OperatorRightPlusImpl[G]
-
-@family sealed trait ModelDeclaration[G] extends Declaration[G] with ModelDeclarationImpl[G]
-final class ModelField[G](val t: Type[G])(implicit val o: Origin) extends ModelDeclaration[G] with Field[G] with ModelFieldImpl[G]
-@scopes[Variable] final class ModelProcess[G](val args: Seq[Variable[G]], val impl: Expr[G],
- val requires: Expr[G], val ensures: Expr[G],
- val modifies: Seq[Ref[G, ModelField[G]]], val accessible: Seq[Ref[G, ModelField[G]]])
- (val blame: Blame[PostconditionFailed])
- (implicit val o: Origin) extends ModelDeclaration[G] with Applicable[G] with ModelProcessImpl[G]
-@scopes[Variable] final class ModelAction[G](val args: Seq[Variable[G]],
- val requires: Expr[G], val ensures: Expr[G],
- val modifies: Seq[Ref[G, ModelField[G]]], val accessible: Seq[Ref[G, ModelField[G]]])
- (implicit val o: Origin) extends ModelDeclaration[G] with Applicable[G] with ModelActionImpl[G]
-
-@family sealed trait ADTDeclaration[G] extends Declaration[G] with ADTDeclarationImpl[G]
-final class ADTAxiom[G](val axiom: Expr[G])(implicit val o: Origin) extends ADTDeclaration[G] with ADTAxiomImpl[G]
-@scopes[Variable] final class ADTFunction[G](val args: Seq[Variable[G]], val returnType: Type[G])(implicit val o: Origin) extends Applicable[G] with ADTDeclaration[G] with ADTFunctionImpl[G]
-
-@family final class Variable[G](val t: Type[G])(implicit val o: Origin) extends Declaration[G] with VariableImpl[G]
-@family final class LabelDecl[G]()(implicit val o: Origin) extends Declaration[G] with LabelDeclImpl[G]
-@family final class SendDecl[G]()(implicit val o: Origin) extends Declaration[G] with SendDeclImpl[G]
-@family final class ParBlockDecl[G]()(implicit val o: Origin) extends Declaration[G] with ParBlockDeclImpl[G]
-@family final class ParInvariantDecl[G]()(implicit val o: Origin) extends Declaration[G] with ParInvariantDeclImpl[G]
+sealed trait ExpressionContainerStatement[G]
+ extends Statement[G] with ExpressionContainerStatementImpl[G]
+
+final case class PVLBranch[G](branches: Seq[(Expr[G], Statement[G])])(
+ val blame: Blame[FrontendIfFailure]
+)(implicit val o: Origin)
+ extends Statement[G] with ControlContainerStatement[G] with PVLBranchImpl[G]
+final case class PVLLoop[G](
+ init: Statement[G],
+ cond: Expr[G],
+ update: Statement[G],
+ contract: LoopContract[G],
+ body: Statement[G],
+)(val blame: Blame[FrontEndLoopFailure])(implicit val o: Origin)
+ extends Statement[G] with ControlContainerStatement[G] with PVLLoopImpl[G]
+
+sealed trait NonExecutableStatement[G]
+ extends Statement[G] with NonExecutableStatementImpl[G]
+final case class LocalDecl[G](local: Variable[G])(implicit val o: Origin)
+ extends NonExecutableStatement[G]
+ with PurelySequentialStatement[G]
+ with LocalDeclImpl[G]
+final case class SpecIgnoreStart[G]()(implicit val o: Origin)
+ extends NonExecutableStatement[G]
+ with PurelySequentialStatement[G]
+ with SpecIgnoreStartImpl[G]
+final case class SpecIgnoreEnd[G]()(implicit val o: Origin)
+ extends NonExecutableStatement[G]
+ with PurelySequentialStatement[G]
+ with SpecIgnoreEndImpl[G]
+
+sealed trait NormallyCompletingStatement[G]
+ extends Statement[G] with NormallyCompletingStatementImpl[G]
+final case class Assign[G](target: Expr[G], value: Expr[G])(
+ val blame: Blame[AssignFailed]
+)(implicit val o: Origin)
+ extends NormallyCompletingStatement[G] with AssignImpl[G]
+final case class Send[G](decl: SendDecl[G], delta: BigInt, res: Expr[G])(
+ val blame: Blame[SendFailed]
+)(implicit val o: Origin)
+ extends NormallyCompletingStatement[G]
+ with ExpressionContainerStatement[G]
+ with SendImpl[G]
+final case class Recv[G](ref: Ref[G, SendDecl[G]])(implicit val o: Origin)
+ extends NormallyCompletingStatement[G]
+ with PurelySequentialStatement[G]
+ with RecvImpl[G]
+sealed trait SwitchCase[G]
+ extends NormallyCompletingStatement[G] with SwitchCaseImpl[G]
+final case class DefaultCase[G]()(implicit val o: Origin)
+ extends SwitchCase[G]
+ with PurelySequentialStatement[G]
+ with DefaultCaseImpl[G]
+final case class Case[G](pattern: Expr[G])(implicit val o: Origin)
+ extends SwitchCase[G] with PurelySequentialStatement[G] with CaseImpl[G]
+final case class Label[G](decl: LabelDecl[G], stat: Statement[G])(
+ implicit val o: Origin
+) extends NormallyCompletingStatement[G]
+ with ControlContainerStatement[G]
+ with LabelImpl[G]
+final case class Goto[G](lbl: Ref[G, LabelDecl[G]])(implicit val o: Origin)
+ extends NormallyCompletingStatement[G] with GotoImpl[G]
+final case class Exhale[G](res: Expr[G])(val blame: Blame[ExhaleFailed])(
+ implicit val o: Origin
+) extends NormallyCompletingStatement[G]
+ with ExpressionContainerStatement[G]
+ with ExhaleImpl[G]
+final case class Assert[G](res: Expr[G])(val blame: Blame[AssertFailed])(
+ implicit val o: Origin
+) extends NormallyCompletingStatement[G]
+ with ExpressionContainerStatement[G]
+ with AssertImpl[G]
+final case class Refute[G](assn: Expr[G])(val blame: Blame[RefuteFailed])(
+ implicit val o: Origin
+) extends NormallyCompletingStatement[G]
+ with ExpressionContainerStatement[G]
+ with RefuteImpl[G]
+final case class Inhale[G](res: Expr[G])(implicit val o: Origin)
+ extends NormallyCompletingStatement[G]
+ with ExpressionContainerStatement[G]
+ with InhaleImpl[G]
+final case class Assume[G](assn: Expr[G])(implicit val o: Origin)
+ extends NormallyCompletingStatement[G]
+ with ExpressionContainerStatement[G]
+ with AssumeImpl[G]
+final case class Instantiate[G](cls: Ref[G, Class[G]], out: Expr[G])(
+ implicit val o: Origin
+) extends NormallyCompletingStatement[G]
+ with ExpressionContainerStatement[G]
+ with InstantiateImpl[G]
+final case class Wait[G](obj: Expr[G])(val blame: Blame[UnlockFailure])(
+ implicit val o: Origin
+) extends NormallyCompletingStatement[G]
+ with ExpressionContainerStatement[G]
+ with WaitImpl[G]
+final case class Notify[G](obj: Expr[G])(val blame: Blame[NotifyFailed])(
+ implicit val o: Origin
+) extends NormallyCompletingStatement[G]
+ with ExpressionContainerStatement[G]
+ with NotifyImpl[G]
+final case class Fork[G](obj: Expr[G])(val blame: Blame[ForkFailure])(
+ implicit val o: Origin
+) extends NormallyCompletingStatement[G]
+ with ExpressionContainerStatement[G]
+ with ForkImpl[G]
+final case class Join[G](obj: Expr[G])(val blame: Blame[JoinFailure])(
+ implicit val o: Origin
+) extends NormallyCompletingStatement[G]
+ with ExpressionContainerStatement[G]
+ with JoinImpl[G]
+final case class Lock[G](obj: Expr[G])(val blame: Blame[LockFailure])(
+ implicit val o: Origin
+) extends NormallyCompletingStatement[G]
+ with ExpressionContainerStatement[G]
+ with LockImpl[G]
+final case class Unlock[G](obj: Expr[G])(val blame: Blame[UnlockFailure])(
+ implicit val o: Origin
+) extends NormallyCompletingStatement[G]
+ with ExpressionContainerStatement[G]
+ with UnlockImpl[G]
+final case class Commit[G](obj: Expr[G])(val blame: Blame[CommitFailed])(
+ implicit val o: Origin
+) extends NormallyCompletingStatement[G]
+ with ExpressionContainerStatement[G]
+ with CommitImpl[G]
+final case class Fold[G](res: Expr[G])(val blame: Blame[FoldFailed])(
+ implicit val o: Origin
+) extends NormallyCompletingStatement[G]
+ with ExpressionContainerStatement[G]
+ with FoldImpl[G]
+final case class Unfold[G](res: Expr[G])(val blame: Blame[UnfoldFailed])(
+ implicit val o: Origin
+) extends NormallyCompletingStatement[G]
+ with ExpressionContainerStatement[G]
+ with UnfoldImpl[G]
+final case class WandApply[G](res: Expr[G])(val blame: Blame[WandApplyFailed])(
+ implicit val o: Origin
+) extends NormallyCompletingStatement[G]
+ with ExpressionContainerStatement[G]
+ with WandApplyImpl[G]
+final case class Havoc[G](loc: Expr[G])(implicit val o: Origin)
+ extends NormallyCompletingStatement[G]
+ with ExpressionContainerStatement[G]
+ with HavocImpl[G]
+final case class FramedProof[G](
+ pre: Expr[G],
+ body: Statement[G],
+ post: Expr[G],
+)(val blame: Blame[FramedProofFailure])(implicit val o: Origin)
+ extends NormallyCompletingStatement[G]
+ with ControlContainerStatement[G]
+ with FramedProofImpl[G]
+final case class Extract[G](contractedStatement: Statement[G])(
+ implicit val o: Origin
+) extends NormallyCompletingStatement[G]
+ with ControlContainerStatement[G]
+ with ExtractImpl[G]
+
+sealed trait ExceptionalStatement[G]
+ extends Statement[G] with ExceptionalStatementImpl[G]
+final case class Eval[G](expr: Expr[G])(implicit val o: Origin)
+ extends ExceptionalStatement[G]
+ with ControlContainerStatement[G]
+ with EvalImpl[G]
+sealed trait InvocationStatement[G]
+ extends ExceptionalStatement[G]
+ with InvokingNode[G]
+ with InvocationStatementImpl[G]
+final case class InvokeProcedure[G](
+ ref: Ref[G, Procedure[G]],
+ args: Seq[Expr[G]],
+ outArgs: Seq[Expr[G]],
+ typeArgs: Seq[Type[G]],
+ givenMap: Seq[(Ref[G, Variable[G]], Expr[G])],
+ yields: Seq[(Expr[G], Ref[G, Variable[G]])],
+)(val blame: Blame[InvocationFailure])(implicit val o: Origin)
+ extends InvocationStatement[G]
+ with ControlContainerStatement[G]
+ with InvokeProcedureImpl[G]
+final case class InvokeConstructor[G](
+ ref: Ref[G, Constructor[G]],
+ classTypeArgs: Seq[Type[G]],
+ out: Expr[G],
+ args: Seq[Expr[G]],
+ outArgs: Seq[Expr[G]],
+ typeArgs: Seq[Type[G]],
+ givenMap: Seq[(Ref[G, Variable[G]], Expr[G])],
+ yields: Seq[(Expr[G], Ref[G, Variable[G]])],
+)(val blame: Blame[InvocationFailure])(implicit val o: Origin)
+ extends InvocationStatement[G]
+ with ControlContainerStatement[G]
+ with InvokeConstructorImpl[G]
+final case class InvokeMethod[G](
+ obj: Expr[G],
+ ref: Ref[G, InstanceMethod[G]],
+ args: Seq[Expr[G]],
+ outArgs: Seq[Expr[G]],
+ typeArgs: Seq[Type[G]],
+ givenMap: Seq[(Ref[G, Variable[G]], Expr[G])],
+ yields: Seq[(Expr[G], Ref[G, Variable[G]])],
+)(val blame: Blame[InstanceInvocationFailure])(implicit val o: Origin)
+ extends InvocationStatement[G]
+ with InstanceApply[G]
+ with ControlContainerStatement[G]
+ with InvokeMethodImpl[G]
+final case class Return[G](result: Expr[G])(implicit val o: Origin)
+ extends ExceptionalStatement[G]
+ with ExpressionContainerStatement[G]
+ with ReturnImpl[G]
+final case class Throw[G](obj: Expr[G])(val blame: Blame[ThrowNull])(
+ implicit val o: Origin
+) extends ExceptionalStatement[G]
+ with ExpressionContainerStatement[G]
+ with ThrowImpl[G]
+final case class Break[G](label: Option[Ref[G, LabelDecl[G]]])(
+ implicit val o: Origin
+) extends ExceptionalStatement[G] with BreakImpl[G]
+final case class Continue[G](label: Option[Ref[G, LabelDecl[G]]])(
+ implicit val o: Origin
+) extends ExceptionalStatement[G] with ContinueImpl[G]
+
+sealed trait CompositeStatement[G]
+ extends Statement[G] with CompositeStatementImpl[G]
+final case class Block[G](statements: Seq[Statement[G]])(implicit val o: Origin)
+ extends CompositeStatement[G]
+ with ControlContainerStatement[G]
+ with BlockImpl[G]
+@scopes[Variable]
+@scopes[CLocalDeclaration]
+@scopes[CPPLocalDeclaration]
+@scopes[JavaLocalDeclaration]
+final case class Scope[G](locals: Seq[Variable[G]], body: Statement[G])(
+ implicit val o: Origin
+) extends CompositeStatement[G]
+ with ControlContainerStatement[G]
+ with ScopeImpl[G]
+final case class Branch[G](branches: Seq[(Expr[G], Statement[G])])(
+ implicit val o: Origin
+) extends CompositeStatement[G]
+ with ControlContainerStatement[G]
+ with BranchImpl[G]
+final case class IndetBranch[G](branches: Seq[Statement[G]])(
+ implicit val o: Origin
+) extends CompositeStatement[G]
+ with ControlContainerStatement[G]
+ with IndetBranchImpl[G]
+final case class Switch[G](expr: Expr[G], body: Statement[G])(
+ implicit val o: Origin
+) extends CompositeStatement[G]
+ with ControlContainerStatement[G]
+ with SwitchImpl[G]
+@scopes[SendDecl]
+final case class Loop[G](
+ init: Statement[G],
+ cond: Expr[G],
+ update: Statement[G],
+ contract: LoopContract[G],
+ body: Statement[G],
+)(implicit val o: Origin)
+ extends CompositeStatement[G]
+ with ControlContainerStatement[G]
+ with LoopImpl[G]
+@scopes[Variable]
+final case class RangedFor[G](
+ iter: IterVariable[G],
+ contract: LoopContract[G],
+ body: Statement[G],
+)(implicit val o: Origin)
+ extends CompositeStatement[G]
+ with Declarator[G]
+ with ControlContainerStatement[G]
+ with RangedForImpl[G]
+final case class TryCatchFinally[G](
+ body: Statement[G],
+ after: Statement[G],
+ catches: Seq[CatchClause[G]],
+)(implicit val o: Origin)
+ extends CompositeStatement[G]
+ with ControlContainerStatement[G]
+ with TryCatchFinallyImpl[G]
+final case class Synchronized[G](obj: Expr[G], body: Statement[G])(
+ val blame: Blame[LockRegionFailure]
+)(implicit val o: Origin)
+ extends CompositeStatement[G]
+ with ControlContainerStatement[G]
+ with SynchronizedImpl[G]
+@scopes[ParInvariantDecl]
+final case class ParInvariant[G](
+ decl: ParInvariantDecl[G],
+ inv: Expr[G],
+ content: Statement[G],
+)(val blame: Blame[ParInvariantNotEstablished])(implicit val o: Origin)
+ extends CompositeStatement[G]
+ with ControlContainerStatement[G]
+ with ParInvariantImpl[G]
+final case class ParAtomic[G](
+ inv: Seq[Ref[G, ParInvariantDecl[G]]],
+ content: Statement[G],
+)(val blame: Blame[ParInvariantNotMaintained])(implicit val o: Origin)
+ extends CompositeStatement[G]
+ with ControlContainerStatement[G]
+ with ParAtomicImpl[G]
+final case class ParBarrier[G](
+ block: Ref[G, ParBlockDecl[G]],
+ invs: Seq[Ref[G, ParInvariantDecl[G]]],
+ requires: Expr[G],
+ ensures: Expr[G],
+ content: Statement[G],
+)(val blame: Blame[ParBarrierFailure])(implicit val o: Origin)
+ extends CompositeStatement[G]
+ with ControlContainerStatement[G]
+ with ParBarrierImpl[G]
+final case class ParStatement[G](impl: ParRegion[G])(implicit val o: Origin)
+ extends CompositeStatement[G]
+ with PurelySequentialStatement[G]
+ with ParStatementImpl[G]
+@scopes[Variable]
+final case class VecBlock[G](
+ iters: Seq[IterVariable[G]],
+ requires: Expr[G],
+ ensures: Expr[G],
+ content: Statement[G],
+)(implicit val o: Origin)
+ extends CompositeStatement[G]
+ with ControlContainerStatement[G]
+ with VecBlockImpl[G]
+final case class WandPackage[G](res: Expr[G], proof: Statement[G])(
+ val blame: Blame[PackageFailure]
+)(implicit val o: Origin)
+ extends CompositeStatement[G]
+ with ControlContainerStatement[G]
+ with WandPackageImpl[G]
+final case class ModelDo[G](
+ model: Expr[G],
+ perm: Expr[G],
+ after: Expr[G],
+ action: Expr[G],
+ impl: Statement[G],
+)(implicit val o: Origin)
+ extends CompositeStatement[G]
+ with ControlContainerStatement[G]
+ with ModelDoImpl[G]
+
+@family
+sealed trait GlobalDeclaration[G]
+ extends Declaration[G] with GlobalDeclarationImpl[G]
+final class HeapVariable[G](val t: Type[G])(implicit val o: Origin)
+ extends GlobalDeclaration[G] with HeapVariableImpl[G]
+final class SimplificationRule[G](val axiom: Expr[G])(implicit val o: Origin)
+ extends GlobalDeclaration[G] with SimplificationRuleImpl[G]
+@scopes[Variable]
+final class AxiomaticDataType[G](
+ val decls: Seq[ADTDeclaration[G]],
+ val typeArgs: Seq[Variable[G]],
+)(implicit val o: Origin)
+ extends GlobalDeclaration[G] with AxiomaticDataTypeImpl[G]
+final class Class[G](
+ val typeArgs: Seq[Variable[G]],
+ val decls: Seq[ClassDeclaration[G]],
+ val supports: Seq[Type[G]],
+ val intrinsicLockInvariant: Expr[G],
+)(implicit val o: Origin)
+ extends GlobalDeclaration[G] with ClassImpl[G]
+final class Model[G](val declarations: Seq[ModelDeclaration[G]])(
+ implicit val o: Origin
+) extends GlobalDeclaration[G] with Declarator[G] with ModelImpl[G]
+@scopes[LabelDecl]
+final class Function[G](
+ val returnType: Type[G],
+ val args: Seq[Variable[G]],
+ val typeArgs: Seq[Variable[G]],
+ val body: Option[Expr[G]],
+ val contract: ApplicableContract[G],
+ val inline: Boolean = false,
+ val threadLocal: Boolean = false,
+)(val blame: Blame[ContractedFailure])(implicit val o: Origin)
+ extends GlobalDeclaration[G] with AbstractFunction[G] with FunctionImpl[G]
+@scopes[LabelDecl]
+final class Procedure[G](
+ val returnType: Type[G],
+ val args: Seq[Variable[G]],
+ val outArgs: Seq[Variable[G]],
+ val typeArgs: Seq[Variable[G]],
+ val body: Option[Statement[G]],
+ val contract: ApplicableContract[G],
+ val inline: Boolean = false,
+ val pure: Boolean = false,
+ val vesuv_entry: Boolean = false,
+)(val blame: Blame[CallableFailure])(implicit val o: Origin)
+ extends GlobalDeclaration[G] with AbstractMethod[G] with ProcedureImpl[G]
+final class VeSUVMainMethod[G](val body: Option[Statement[G]])(
+ val blame: Blame[CallableFailure]
+)(implicit val o: Origin)
+ extends GlobalDeclaration[G] with VeSUVMainMethodImpl[G]
+@scopes[Variable]
+final class Predicate[G](
+ val args: Seq[Variable[G]],
+ val body: Option[Expr[G]],
+ val threadLocal: Boolean = false,
+ val inline: Boolean = false,
+)(implicit val o: Origin)
+ extends GlobalDeclaration[G] with AbstractPredicate[G] with PredicateImpl[G]
+final class Enum[G](val constants: Seq[EnumConstant[G]])(implicit val o: Origin)
+ extends GlobalDeclaration[G] with EnumImpl[G]
+@family
+final class EnumConstant[G]()(implicit val o: Origin)
+ extends Declaration[G] with EnumConstantImpl[G]
+
+final class ProverType[G](val interpretation: Seq[(ProverLanguage[G], String)])(
+ implicit val o: Origin
+) extends GlobalDeclaration[G] with ProverTypeImpl[G]
+final class ProverFunction[G](
+ val interpretation: Seq[(ProverLanguage[G], String)],
+ val args: Seq[Variable[G]],
+ val returnType: Type[G],
+)(implicit val o: Origin)
+ extends GlobalDeclaration[G] with Applicable[G] with ProverFunctionImpl[G]
+
+@family
+sealed trait ProverLanguage[G] extends NodeFamily[G] with ProverLanguageImpl[G]
+case class SmtLib[G]()(implicit val o: Origin)
+ extends ProverLanguage[G] with SmtLibImpl[G]
+case class Boogie[G]()(implicit val o: Origin)
+ extends ProverLanguage[G] with BoogieImpl[G]
+
+@family
+sealed trait ClassDeclaration[G]
+ extends Declaration[G] with ClassDeclarationImpl[G]
+@scopes[LabelDecl]
+final class InstanceFunction[G](
+ val returnType: Type[G],
+ val args: Seq[Variable[G]],
+ val typeArgs: Seq[Variable[G]],
+ val body: Option[Expr[G]],
+ val contract: ApplicableContract[G],
+ val inline: Boolean,
+ val threadLocal: Boolean = false,
+)(val blame: Blame[ContractedFailure])(implicit val o: Origin)
+ extends ClassDeclaration[G]
+ with AbstractFunction[G]
+ with InstanceFunctionImpl[G]
+@scopes[LabelDecl]
+final class Constructor[G](
+ val cls: Ref[G, Class[G]],
+ val args: Seq[Variable[G]],
+ val outArgs: Seq[Variable[G]],
+ val typeArgs: Seq[Variable[G]],
+ val body: Option[Statement[G]],
+ val contract: ApplicableContract[G],
+ val inline: Boolean = false,
+)(val blame: Blame[CallableFailure])(implicit val o: Origin)
+ extends ClassDeclaration[G] with AbstractMethod[G] with ConstructorImpl[G]
+@scopes[LabelDecl]
+final class InstanceMethod[G](
+ val returnType: Type[G],
+ val args: Seq[Variable[G]],
+ val outArgs: Seq[Variable[G]],
+ val typeArgs: Seq[Variable[G]],
+ val body: Option[Statement[G]],
+ val contract: ApplicableContract[G],
+ val inline: Boolean = false,
+ val pure: Boolean = false,
+)(val blame: Blame[CallableFailure])(implicit val o: Origin)
+ extends ClassDeclaration[G]
+ with AbstractMethod[G]
+ with InstanceMethodImpl[G]
+@scopes[Variable]
+final class InstancePredicate[G](
+ val args: Seq[Variable[G]],
+ val body: Option[Expr[G]],
+ val threadLocal: Boolean = false,
+ val inline: Boolean = false,
+)(implicit val o: Origin)
+ extends ClassDeclaration[G]
+ with AbstractPredicate[G]
+ with InstancePredicateImpl[G]
+final class InstanceField[G](val t: Type[G], val flags: Seq[FieldFlag[G]])(
+ implicit val o: Origin
+) extends ClassDeclaration[G] with Field[G] with InstanceFieldImpl[G]
+final class RunMethod[G](
+ val body: Option[Statement[G]],
+ val contract: ApplicableContract[G],
+)(val blame: Blame[CallableFailure])(implicit val o: Origin)
+ extends ClassDeclaration[G] with RunMethodImpl[G]
+final class InstanceOperatorFunction[G](
+ val returnType: Type[G],
+ val operator: Operator[G],
+ val args: Seq[Variable[G]],
+ val body: Option[Expr[G]],
+ val contract: ApplicableContract[G],
+ val inline: Boolean,
+ val threadLocal: Boolean = false,
+)(val blame: Blame[ContractedFailure])(implicit val o: Origin)
+ extends ClassDeclaration[G]
+ with AbstractFunction[G]
+ with InstanceOperatorFunctionImpl[G]
+final class InstanceOperatorMethod[G](
+ val returnType: Type[G],
+ val operator: Operator[G],
+ val args: Seq[Variable[G]],
+ val body: Option[Statement[G]],
+ val contract: ApplicableContract[G],
+ val inline: Boolean = false,
+ val pure: Boolean = false,
+)(val blame: Blame[CallableFailure])(implicit val o: Origin)
+ extends ClassDeclaration[G]
+ with AbstractMethod[G]
+ with InstanceOperatorMethodImpl[G]
+
+@family
+sealed trait Operator[G] extends NodeFamily[G] with OperatorImpl[G]
+case class OperatorLeftPlus[G]()(implicit val o: Origin = DiagnosticOrigin)
+ extends Operator[G] with OperatorLeftPlusImpl[G]
+case class OperatorRightPlus[G]()(implicit val o: Origin = DiagnosticOrigin)
+ extends Operator[G] with OperatorRightPlusImpl[G]
+
+@family
+sealed trait ModelDeclaration[G]
+ extends Declaration[G] with ModelDeclarationImpl[G]
+final class ModelField[G](val t: Type[G])(implicit val o: Origin)
+ extends ModelDeclaration[G] with Field[G] with ModelFieldImpl[G]
+@scopes[Variable]
+final class ModelProcess[G](
+ val args: Seq[Variable[G]],
+ val impl: Expr[G],
+ val requires: Expr[G],
+ val ensures: Expr[G],
+ val modifies: Seq[Ref[G, ModelField[G]]],
+ val accessible: Seq[Ref[G, ModelField[G]]],
+)(val blame: Blame[PostconditionFailed])(implicit val o: Origin)
+ extends ModelDeclaration[G] with Applicable[G] with ModelProcessImpl[G]
+@scopes[Variable]
+final class ModelAction[G](
+ val args: Seq[Variable[G]],
+ val requires: Expr[G],
+ val ensures: Expr[G],
+ val modifies: Seq[Ref[G, ModelField[G]]],
+ val accessible: Seq[Ref[G, ModelField[G]]],
+)(implicit val o: Origin)
+ extends ModelDeclaration[G] with Applicable[G] with ModelActionImpl[G]
+
+@family
+sealed trait ADTDeclaration[G] extends Declaration[G] with ADTDeclarationImpl[G]
+final class ADTAxiom[G](val axiom: Expr[G])(implicit val o: Origin)
+ extends ADTDeclaration[G] with ADTAxiomImpl[G]
+@scopes[Variable]
+final class ADTFunction[G](val args: Seq[Variable[G]], val returnType: Type[G])(
+ implicit val o: Origin
+) extends Applicable[G] with ADTDeclaration[G] with ADTFunctionImpl[G]
+
+@family
+final class Variable[G](val t: Type[G])(implicit val o: Origin)
+ extends Declaration[G] with VariableImpl[G]
+@family
+final class LabelDecl[G]()(implicit val o: Origin)
+ extends Declaration[G] with LabelDeclImpl[G]
+@family
+final class SendDecl[G]()(implicit val o: Origin)
+ extends Declaration[G] with SendDeclImpl[G]
+@family
+final class ParBlockDecl[G]()(implicit val o: Origin)
+ extends Declaration[G] with ParBlockDeclImpl[G]
+@family
+final class ParInvariantDecl[G]()(implicit val o: Origin)
+ extends Declaration[G] with ParInvariantDeclImpl[G]
sealed trait Applicable[G] extends ApplicableImpl[G] with Declaration[G]
-sealed trait InlineableApplicable[G] extends Applicable[G] with InlineableApplicableImpl[G]
-sealed trait AbstractPredicate[G] extends InlineableApplicable[G] with AbstractPredicateImpl[G]
-sealed trait ContractApplicable[G] extends InlineableApplicable[G] with ContractApplicableImpl[G]
-sealed trait AbstractFunction[G] extends ContractApplicable[G] with AbstractFunctionImpl[G]
-sealed trait AbstractMethod[G] extends ContractApplicable[G] with AbstractMethodImpl[G]
+sealed trait InlineableApplicable[G]
+ extends Applicable[G] with InlineableApplicableImpl[G]
+sealed trait AbstractPredicate[G]
+ extends InlineableApplicable[G] with AbstractPredicateImpl[G]
+sealed trait ContractApplicable[G]
+ extends InlineableApplicable[G] with ContractApplicableImpl[G]
+sealed trait AbstractFunction[G]
+ extends ContractApplicable[G] with AbstractFunctionImpl[G]
+sealed trait AbstractMethod[G]
+ extends ContractApplicable[G] with AbstractMethodImpl[G]
sealed trait Field[G] extends FieldImpl[G]
-@family @scopes[Variable] final case class SignalsClause[G](binding: Variable[G], assn: Expr[G])(implicit val o: Origin) extends NodeFamily[G] with SignalsClauseImpl[G]
-
-@family sealed trait DecreasesClause[G] extends NodeFamily[G] with DecreasesClauseImpl[G]
-final case class DecreasesClauseAssume[G]()(implicit val o: Origin) extends DecreasesClause[G] with DecreasesClauseAssumeImpl[G]
-final case class DecreasesClauseNoRecursion[G]()(implicit val o: Origin) extends DecreasesClause[G] with DecreasesClauseNoRecursionImpl[G]
-final case class DecreasesClauseTuple[G](exprs: Seq[Expr[G]])(implicit val o: Origin) extends DecreasesClause[G] with DecreasesClauseTupleImpl[G]
-
-@family final case class ApplicableContract[G](requires: AccountedPredicate[G], ensures: AccountedPredicate[G], contextEverywhere: Expr[G],
- signals: Seq[SignalsClause[G]], givenArgs: Seq[Variable[G]], yieldsArgs: Seq[Variable[G]], decreases: Option[DecreasesClause[G]])
- (val blame: Blame[NontrivialUnsatisfiable])(implicit val o: Origin) extends NodeFamily[G] with ApplicableContractImpl[G]
-
-/** @inheritdoc */ @family sealed trait AccountedPredicate[G] extends NodeFamily[G] with AccountedPredicateImpl[G]
-case class UnitAccountedPredicate[G](pred: Expr[G])(implicit val o: Origin) extends AccountedPredicate[G] with UnitAccountedPredicateImpl[G]
-case class SplitAccountedPredicate[G](left: AccountedPredicate[G], right: AccountedPredicate[G])(implicit val o: Origin) extends AccountedPredicate[G] with SplitAccountedPredicateImpl[G]
-
-@family sealed trait FieldFlag[G] extends NodeFamily[G] with FieldFlagImpl[G]
-final case class Final[G]()(implicit val o: Origin) extends FieldFlag[G] with FinalImpl[G]
-
-@family sealed trait Coercion[G] extends NodeFamily[G] with CoercionImpl[G]
-final case class CoerceIdentity[G](source: Type[G])(implicit val o: Origin) extends Coercion[G] with CoerceIdentityImpl[G]
-final case class CoercionSequence[G](coercions: Seq[Coercion[G]])(implicit val o: Origin) extends Coercion[G] with CoercionSequenceImpl[G]
-
-final case class CoerceNothingSomething[G](target: Type[G])(implicit val o: Origin) extends Coercion[G] with CoerceNothingSomethingImpl[G]
-final case class CoerceSomethingAny[G](source: Type[G])(implicit val o: Origin) extends Coercion[G] with CoerceSomethingAnyImpl[G]
-final case class CoerceSomethingAnyValue[G](source: Type[G])(implicit val o: Origin) extends Coercion[G] with CoerceSomethingAnyValueImpl[G]
-
-final case class CoerceJoinUnion[G](inner: Seq[Coercion[G]], source: Seq[Type[G]], target: Type[G])(implicit val o: Origin) extends Coercion[G] with CoerceJoinUnionImpl[G]
-final case class CoerceSelectUnion[G](inner: Coercion[G], source: Type[G], targetAlts: Seq[Type[G]], index: Int)(implicit val o: Origin) extends Coercion[G] with CoerceSelectUnionImpl[G]
-
-final case class CoerceBoolResource[G]()(implicit val o: Origin) extends Coercion[G] with CoerceBoolResourceImpl[G]
-final case class CoerceResourceResourceVal[G]()(implicit val o: Origin) extends Coercion[G] with CoerceResourceResourceValImpl[G]
-final case class CoerceResourceValResource[G]()(implicit val o: Origin) extends Coercion[G] with CoerceResourceValResourceImpl[G]
-
-final case class CoerceNullRef[G]()(implicit val o: Origin) extends Coercion[G] with CoerceNullRefImpl[G]
-final case class CoerceNullArray[G](arrayElementType: Type[G])(implicit val o: Origin) extends Coercion[G] with CoerceNullArrayImpl[G]
-final case class CoerceNullClass[G](targetClass: Ref[G, Class[G]], typeArgs: Seq[Type[G]])(implicit val o: Origin) extends Coercion[G] with CoerceNullClassImpl[G]
-final case class CoerceNullJavaClass[G](targetClass: Ref[G, JavaClassOrInterface[G]])(implicit val o: Origin) extends Coercion[G] with CoerceNullJavaClassImpl[G]
-final case class CoerceNullAnyClass[G]()(implicit val o: Origin) extends Coercion[G] with CoerceNullAnyClassImpl[G]
-final case class CoerceNullPointer[G](pointerElementType: Type[G])(implicit val o: Origin) extends Coercion[G] with CoerceNullPointerImpl[G]
-final case class CoerceNullEnum[G](targetEnum: Ref[G, Enum[G]])(implicit val o: Origin) extends Coercion[G] with CoerceNullEnumImpl[G]
-
-final case class CoerceCArrayPointer[G](elementType: Type[G])(implicit val o: Origin) extends Coercion[G] with CoerceCArrayPointerImpl[G]
-final case class CoerceCPPArrayPointer[G](elementType: Type[G])(implicit val o: Origin) extends Coercion[G] with CoerceCPPArrayPointerImpl[G]
-final case class CoerceCVectorVector[G](size: BigInt, elementType: Type[G])(implicit val o: Origin) extends Coercion[G] with CoerceCVectorVectorImpl[G]
-
-final case class CoerceFracZFrac[G]()(implicit val o: Origin) extends Coercion[G] with CoerceFracZFracImpl[G]
-final case class CoerceZFracRat[G]()(implicit val o: Origin) extends Coercion[G] with CoerceZFracRatImpl[G]
-final case class CoerceFloatRat[G](source: Type[G])(implicit val o: Origin) extends Coercion[G] with CoerceFloatRatImpl[G]
-final case class CoerceCFloatCInt[G](source: Type[G])(implicit val o: Origin) extends Coercion[G] with CoerceCFloatCIntImpl[G]
-final case class CoerceCIntCFloat[G](target: Type[G])(implicit val o: Origin) extends Coercion[G] with CoerceCIntCFloatImpl[G]
-final case class CoerceCIntInt[G]()(implicit val o: Origin) extends Coercion[G] with CoerceCIntIntImpl[G]
-final case class CoerceCFloatFloat[G](source: Type[G], target: Type[G])(implicit val o: Origin) extends Coercion[G] with CoerceCFloatFloatImpl[G]
-final case class CoerceIntRat[G]()(implicit val o: Origin) extends Coercion[G] with CoerceIntRatImpl[G]
-
-final case class CoerceIncreasePrecision[G](source: Type[G], target: Type[G])(implicit val o: Origin) extends Coercion[G] with CoerceIncreasePrecisionImpl[G]
-final case class CoerceDecreasePrecision[G](source: Type[G], target: Type[G])(implicit val o: Origin) extends Coercion[G] with CoerceDecreasePrecisionImpl[G]
-
-final case class CoerceWidenBound[G](source: Type[G], target: Type[G])(implicit val o: Origin) extends Coercion[G] with CoerceWidenBoundImpl[G]
-final case class CoerceUnboundInt[G](source: Type[G], target: Type[G])(implicit val o: Origin) extends Coercion[G] with CoerceUnboundIntImpl[G]
-
-final case class CoerceBoundIntFrac[G]()(implicit val o: Origin) extends Coercion[G] with CoerceBoundIntFracImpl[G]
-final case class CoerceBoundIntZFrac[G](source: Type[G])(implicit val o: Origin) extends Coercion[G] with CoerceBoundIntZFracImpl[G]
-final case class CoerceBoundIntFloat[G](source: Type[G], target: Type[G])(implicit val o: Origin) extends Coercion[G] with CoerceBoundIntFloatImpl[G]
-
-final case class CoerceSupports[G](sourceClass: Ref[G, Class[G]], targetClass: Ref[G, Class[G]])(implicit val o: Origin) extends Coercion[G] with CoerceSupportsImpl[G]
-final case class CoerceJavaSupports[G](sourceClass: Ref[G, JavaClassOrInterface[G]], targetClass: Ref[G, JavaClassOrInterface[G]])(implicit val o: Origin) extends Coercion[G] with CoerceJavaSupportsImpl[G]
-final case class CoerceClassAnyClass[G](sourceClass: Ref[G, Class[G]], typeArgs: Seq[Type[G]])(implicit val o: Origin) extends Coercion[G] with CoerceClassAnyClassImpl[G]
-final case class CoerceJavaClassAnyClass[G](sourceClass: Ref[G, JavaClassOrInterface[G]])(implicit val o: Origin) extends Coercion[G] with CoerceJavaClassAnyClassImpl[G]
-
-final case class CoerceCPrimitiveToCol[G](source: Type[G], target: Type[G])(implicit val o: Origin) extends Coercion[G] with CoerceCPrimitiveToColImpl[G]
-final case class CoerceColToCPrimitive[G](source: Type[G], target: Type[G])(implicit val o: Origin) extends Coercion[G] with CoerceColToCPrimitiveImpl[G]
-
-final case class CoerceCPPPrimitiveToCol[G](source: Type[G], target: Type[G])(implicit val o: Origin) extends Coercion[G] with CoerceCPPPrimitiveToColImpl[G]
-final case class CoerceColToCPPPrimitive[G](source: Type[G], target: Type[G])(implicit val o: Origin) extends Coercion[G] with CoerceColToCPPPrimitiveImpl[G]
-
-final case class CoerceMapOption[G](inner: Coercion[G], sourceOptionElement: Type[G], targetOptionElement: Type[G])(implicit val o: Origin) extends Coercion[G] with CoerceMapOptionImpl[G]
-final case class CoerceMapTuple[G](inner: Seq[Coercion[G]], sourceTypes: Seq[Type[G]], targetTypes: Seq[Type[G]])(implicit val o: Origin) extends Coercion[G] with CoerceMapTupleImpl[G]
-final case class CoerceMapEither[G](inner: (Coercion[G], Coercion[G]), sourceTypes: (Type[G], Type[G]), targetTypes: (Type[G], Type[G]))(implicit val o: Origin) extends Coercion[G] with CoerceMapEitherImpl[G]
-final case class CoerceMapSeq[G](inner: Coercion[G], sourceSeqElement: Type[G], targetSeqElement: Type[G])(implicit val o: Origin) extends Coercion[G] with CoerceMapSeqImpl[G]
-final case class CoerceMapSet[G](inner: Coercion[G], sourceSetElement: Type[G], targetSetElement: Type[G])(implicit val o: Origin) extends Coercion[G] with CoerceMapSetImpl[G]
-final case class CoerceMapVector[G](inner: Coercion[G], sourceVectorElement: Type[G], targetVectorElement: Type[G], size: BigInt)(implicit val o: Origin) extends Coercion[G] with CoerceMapVectorImpl[G]
-final case class CoerceMapBag[G](inner: Coercion[G], sourceBagElement: Type[G], targetBagElement: Type[G])(implicit val o: Origin) extends Coercion[G] with CoerceMapBagImpl[G]
-final case class CoerceMapMatrix[G](inner: Coercion[G], sourceMatrixElement: Type[G], targetMatrixElement: Type[G])(implicit val o: Origin) extends Coercion[G] with CoerceMapMatrixImpl[G]
-final case class CoerceMapMap[G](inner: Coercion[G], sourceTypes: (Type[G], Type[G]), targetTypes: (Type[G], Type[G]))(implicit val o: Origin) extends Coercion[G] with CoerceMapMapImpl[G]
-final case class CoerceMapType[G](inner: Coercion[G], sourceBound: Type[G], targetBound: Type[G])(implicit val o: Origin) extends Coercion[G] with CoerceMapTypeImpl[G]
-
-final case class CoerceRatZFrac[G]()(implicit val o: Origin) extends Coercion[G] with CoerceRatZFracImpl[G]
-final case class CoerceZFracFrac[G]()(implicit val o: Origin) extends Coercion[G] with CoerceZFracFracImpl[G]
-
-@family sealed trait Expr[G] extends NodeFamily[G] with ExprImpl[G]
+@family @scopes[Variable]
+final case class SignalsClause[G](binding: Variable[G], assn: Expr[G])(
+ implicit val o: Origin
+) extends NodeFamily[G] with SignalsClauseImpl[G]
+
+@family
+sealed trait DecreasesClause[G]
+ extends NodeFamily[G] with DecreasesClauseImpl[G]
+final case class DecreasesClauseAssume[G]()(implicit val o: Origin)
+ extends DecreasesClause[G] with DecreasesClauseAssumeImpl[G]
+final case class DecreasesClauseNoRecursion[G]()(implicit val o: Origin)
+ extends DecreasesClause[G] with DecreasesClauseNoRecursionImpl[G]
+final case class DecreasesClauseTuple[G](exprs: Seq[Expr[G]])(
+ implicit val o: Origin
+) extends DecreasesClause[G] with DecreasesClauseTupleImpl[G]
+
+@family
+final case class ApplicableContract[G](
+ requires: AccountedPredicate[G],
+ ensures: AccountedPredicate[G],
+ contextEverywhere: Expr[G],
+ signals: Seq[SignalsClause[G]],
+ givenArgs: Seq[Variable[G]],
+ yieldsArgs: Seq[Variable[G]],
+ decreases: Option[DecreasesClause[G]],
+)(val blame: Blame[NontrivialUnsatisfiable])(implicit val o: Origin)
+ extends NodeFamily[G] with ApplicableContractImpl[G]
+
+/** @inheritdoc */
+@family
+sealed trait AccountedPredicate[G]
+ extends NodeFamily[G] with AccountedPredicateImpl[G]
+case class UnitAccountedPredicate[G](pred: Expr[G])(implicit val o: Origin)
+ extends AccountedPredicate[G] with UnitAccountedPredicateImpl[G]
+case class SplitAccountedPredicate[G](
+ left: AccountedPredicate[G],
+ right: AccountedPredicate[G],
+)(implicit val o: Origin)
+ extends AccountedPredicate[G] with SplitAccountedPredicateImpl[G]
+
+@family
+sealed trait FieldFlag[G] extends NodeFamily[G] with FieldFlagImpl[G]
+final case class Final[G]()(implicit val o: Origin)
+ extends FieldFlag[G] with FinalImpl[G]
+
+@family
+sealed trait Coercion[G] extends NodeFamily[G] with CoercionImpl[G]
+final case class CoerceIdentity[G](source: Type[G])(implicit val o: Origin)
+ extends Coercion[G] with CoerceIdentityImpl[G]
+final case class CoercionSequence[G](coercions: Seq[Coercion[G]])(
+ implicit val o: Origin
+) extends Coercion[G] with CoercionSequenceImpl[G]
+
+final case class CoerceNothingSomething[G](target: Type[G])(
+ implicit val o: Origin
+) extends Coercion[G] with CoerceNothingSomethingImpl[G]
+final case class CoerceSomethingAny[G](source: Type[G])(implicit val o: Origin)
+ extends Coercion[G] with CoerceSomethingAnyImpl[G]
+final case class CoerceSomethingAnyValue[G](source: Type[G])(
+ implicit val o: Origin
+) extends Coercion[G] with CoerceSomethingAnyValueImpl[G]
+
+final case class CoerceJoinUnion[G](
+ inner: Seq[Coercion[G]],
+ source: Seq[Type[G]],
+ target: Type[G],
+)(implicit val o: Origin)
+ extends Coercion[G] with CoerceJoinUnionImpl[G]
+final case class CoerceSelectUnion[G](
+ inner: Coercion[G],
+ source: Type[G],
+ targetAlts: Seq[Type[G]],
+ index: Int,
+)(implicit val o: Origin)
+ extends Coercion[G] with CoerceSelectUnionImpl[G]
+
+final case class CoerceBoolResource[G]()(implicit val o: Origin)
+ extends Coercion[G] with CoerceBoolResourceImpl[G]
+final case class CoerceResourceResourceVal[G]()(implicit val o: Origin)
+ extends Coercion[G] with CoerceResourceResourceValImpl[G]
+final case class CoerceResourceValResource[G]()(implicit val o: Origin)
+ extends Coercion[G] with CoerceResourceValResourceImpl[G]
+
+final case class CoerceNullRef[G]()(implicit val o: Origin)
+ extends Coercion[G] with CoerceNullRefImpl[G]
+final case class CoerceNullArray[G](arrayElementType: Type[G])(
+ implicit val o: Origin
+) extends Coercion[G] with CoerceNullArrayImpl[G]
+final case class CoerceNullClass[G](
+ targetClass: Ref[G, Class[G]],
+ typeArgs: Seq[Type[G]],
+)(implicit val o: Origin)
+ extends Coercion[G] with CoerceNullClassImpl[G]
+final case class CoerceNullJavaClass[G](
+ targetClass: Ref[G, JavaClassOrInterface[G]]
+)(implicit val o: Origin)
+ extends Coercion[G] with CoerceNullJavaClassImpl[G]
+final case class CoerceNullAnyClass[G]()(implicit val o: Origin)
+ extends Coercion[G] with CoerceNullAnyClassImpl[G]
+final case class CoerceNullPointer[G](pointerElementType: Type[G])(
+ implicit val o: Origin
+) extends Coercion[G] with CoerceNullPointerImpl[G]
+final case class CoerceNullEnum[G](targetEnum: Ref[G, Enum[G]])(
+ implicit val o: Origin
+) extends Coercion[G] with CoerceNullEnumImpl[G]
+
+final case class CoerceCArrayPointer[G](elementType: Type[G])(
+ implicit val o: Origin
+) extends Coercion[G] with CoerceCArrayPointerImpl[G]
+final case class CoerceCPPArrayPointer[G](elementType: Type[G])(
+ implicit val o: Origin
+) extends Coercion[G] with CoerceCPPArrayPointerImpl[G]
+final case class CoerceCVectorVector[G](size: BigInt, elementType: Type[G])(
+ implicit val o: Origin
+) extends Coercion[G] with CoerceCVectorVectorImpl[G]
+
+final case class CoerceFracZFrac[G]()(implicit val o: Origin)
+ extends Coercion[G] with CoerceFracZFracImpl[G]
+final case class CoerceZFracRat[G]()(implicit val o: Origin)
+ extends Coercion[G] with CoerceZFracRatImpl[G]
+final case class CoerceFloatRat[G](source: Type[G])(implicit val o: Origin)
+ extends Coercion[G] with CoerceFloatRatImpl[G]
+final case class CoerceCFloatCInt[G](source: Type[G])(implicit val o: Origin)
+ extends Coercion[G] with CoerceCFloatCIntImpl[G]
+final case class CoerceCIntCFloat[G](target: Type[G])(implicit val o: Origin)
+ extends Coercion[G] with CoerceCIntCFloatImpl[G]
+final case class CoerceCIntInt[G]()(implicit val o: Origin)
+ extends Coercion[G] with CoerceCIntIntImpl[G]
+final case class CoerceCFloatFloat[G](source: Type[G], target: Type[G])(
+ implicit val o: Origin
+) extends Coercion[G] with CoerceCFloatFloatImpl[G]
+final case class CoerceIntRat[G]()(implicit val o: Origin)
+ extends Coercion[G] with CoerceIntRatImpl[G]
+
+final case class CoerceIncreasePrecision[G](source: Type[G], target: Type[G])(
+ implicit val o: Origin
+) extends Coercion[G] with CoerceIncreasePrecisionImpl[G]
+final case class CoerceDecreasePrecision[G](source: Type[G], target: Type[G])(
+ implicit val o: Origin
+) extends Coercion[G] with CoerceDecreasePrecisionImpl[G]
+
+final case class CoerceWidenBound[G](source: Type[G], target: Type[G])(
+ implicit val o: Origin
+) extends Coercion[G] with CoerceWidenBoundImpl[G]
+final case class CoerceUnboundInt[G](source: Type[G], target: Type[G])(
+ implicit val o: Origin
+) extends Coercion[G] with CoerceUnboundIntImpl[G]
+
+final case class CoerceBoundIntFrac[G]()(implicit val o: Origin)
+ extends Coercion[G] with CoerceBoundIntFracImpl[G]
+final case class CoerceBoundIntZFrac[G](source: Type[G])(implicit val o: Origin)
+ extends Coercion[G] with CoerceBoundIntZFracImpl[G]
+final case class CoerceBoundIntFloat[G](source: Type[G], target: Type[G])(
+ implicit val o: Origin
+) extends Coercion[G] with CoerceBoundIntFloatImpl[G]
+
+final case class CoerceSupports[G](
+ sourceClass: Ref[G, Class[G]],
+ targetClass: Ref[G, Class[G]],
+)(implicit val o: Origin)
+ extends Coercion[G] with CoerceSupportsImpl[G]
+final case class CoerceJavaSupports[G](
+ sourceClass: Ref[G, JavaClassOrInterface[G]],
+ targetClass: Ref[G, JavaClassOrInterface[G]],
+)(implicit val o: Origin)
+ extends Coercion[G] with CoerceJavaSupportsImpl[G]
+final case class CoerceClassAnyClass[G](
+ sourceClass: Ref[G, Class[G]],
+ typeArgs: Seq[Type[G]],
+)(implicit val o: Origin)
+ extends Coercion[G] with CoerceClassAnyClassImpl[G]
+final case class CoerceJavaClassAnyClass[G](
+ sourceClass: Ref[G, JavaClassOrInterface[G]]
+)(implicit val o: Origin)
+ extends Coercion[G] with CoerceJavaClassAnyClassImpl[G]
+
+final case class CoerceCPrimitiveToCol[G](source: Type[G], target: Type[G])(
+ implicit val o: Origin
+) extends Coercion[G] with CoerceCPrimitiveToColImpl[G]
+final case class CoerceColToCPrimitive[G](source: Type[G], target: Type[G])(
+ implicit val o: Origin
+) extends Coercion[G] with CoerceColToCPrimitiveImpl[G]
+
+final case class CoerceCPPPrimitiveToCol[G](source: Type[G], target: Type[G])(
+ implicit val o: Origin
+) extends Coercion[G] with CoerceCPPPrimitiveToColImpl[G]
+final case class CoerceColToCPPPrimitive[G](source: Type[G], target: Type[G])(
+ implicit val o: Origin
+) extends Coercion[G] with CoerceColToCPPPrimitiveImpl[G]
+
+final case class CoerceMapOption[G](
+ inner: Coercion[G],
+ sourceOptionElement: Type[G],
+ targetOptionElement: Type[G],
+)(implicit val o: Origin)
+ extends Coercion[G] with CoerceMapOptionImpl[G]
+final case class CoerceMapTuple[G](
+ inner: Seq[Coercion[G]],
+ sourceTypes: Seq[Type[G]],
+ targetTypes: Seq[Type[G]],
+)(implicit val o: Origin)
+ extends Coercion[G] with CoerceMapTupleImpl[G]
+final case class CoerceMapEither[G](
+ inner: (Coercion[G], Coercion[G]),
+ sourceTypes: (Type[G], Type[G]),
+ targetTypes: (Type[G], Type[G]),
+)(implicit val o: Origin)
+ extends Coercion[G] with CoerceMapEitherImpl[G]
+final case class CoerceMapSeq[G](
+ inner: Coercion[G],
+ sourceSeqElement: Type[G],
+ targetSeqElement: Type[G],
+)(implicit val o: Origin)
+ extends Coercion[G] with CoerceMapSeqImpl[G]
+final case class CoerceMapSet[G](
+ inner: Coercion[G],
+ sourceSetElement: Type[G],
+ targetSetElement: Type[G],
+)(implicit val o: Origin)
+ extends Coercion[G] with CoerceMapSetImpl[G]
+final case class CoerceMapVector[G](
+ inner: Coercion[G],
+ sourceVectorElement: Type[G],
+ targetVectorElement: Type[G],
+ size: BigInt,
+)(implicit val o: Origin)
+ extends Coercion[G] with CoerceMapVectorImpl[G]
+final case class CoerceMapBag[G](
+ inner: Coercion[G],
+ sourceBagElement: Type[G],
+ targetBagElement: Type[G],
+)(implicit val o: Origin)
+ extends Coercion[G] with CoerceMapBagImpl[G]
+final case class CoerceMapMatrix[G](
+ inner: Coercion[G],
+ sourceMatrixElement: Type[G],
+ targetMatrixElement: Type[G],
+)(implicit val o: Origin)
+ extends Coercion[G] with CoerceMapMatrixImpl[G]
+final case class CoerceMapMap[G](
+ inner: Coercion[G],
+ sourceTypes: (Type[G], Type[G]),
+ targetTypes: (Type[G], Type[G]),
+)(implicit val o: Origin)
+ extends Coercion[G] with CoerceMapMapImpl[G]
+final case class CoerceMapType[G](
+ inner: Coercion[G],
+ sourceBound: Type[G],
+ targetBound: Type[G],
+)(implicit val o: Origin)
+ extends Coercion[G] with CoerceMapTypeImpl[G]
+
+final case class CoerceRatZFrac[G]()(implicit val o: Origin)
+ extends Coercion[G] with CoerceRatZFracImpl[G]
+final case class CoerceZFracFrac[G]()(implicit val o: Origin)
+ extends Coercion[G] with CoerceZFracFracImpl[G]
+
+@family
+sealed trait Expr[G] extends NodeFamily[G] with ExprImpl[G]
sealed trait Constant[G] extends Expr[G] with ConstantImpl[G]
sealed trait ConstantInt[G] extends Constant[G] with ConstantIntImpl[G]
-final case class CIntegerValue[G](value: BigInt)(implicit val o: Origin) extends ConstantInt[G] with Expr[G] with CIntegerValueImpl[G]
-final case class IntegerValue[G](value: BigInt)(implicit val o: Origin) extends ConstantInt[G] with Expr[G] with IntegerValueImpl[G]
-final case class BooleanValue[G](value: Boolean)(implicit val o: Origin) extends Constant[G] with BooleanValueImpl[G]
-final case class FloatValue[G](value: BigDecimal, t: Type[G] /* TFloat */)(implicit val o: Origin) extends Constant[G] with FloatValueImpl[G]
-final case class StringValue[G](value: String)(implicit val o: Origin) extends Constant[G] with StringValueImpl[G]
-final case class CharValue[G](value: Int)(implicit val o: Origin) extends Constant[G] with CharValueImpl[G]
-final case class LiteralSeq[G](element: Type[G], values: Seq[Expr[G]])(implicit val o: Origin) extends Expr[G] with LiteralSeqImpl[G]
-final case class LiteralSet[G](element: Type[G], values: Seq[Expr[G]])(implicit val o: Origin) extends Expr[G] with LiteralSetImpl[G]
-final case class LiteralBag[G](element: Type[G], values: Seq[Expr[G]])(implicit val o: Origin) extends Expr[G] with LiteralBagImpl[G]
-final case class LiteralTuple[G](ts: Seq[Type[G]], values: Seq[Expr[G]])(implicit val o: Origin) extends Expr[G] with LiteralTupleImpl[G]
-final case class LiteralMap[G](k: Type[G], v: Type[G], values: Seq[(Expr[G], Expr[G])])(implicit val o: Origin) extends Expr[G] with LiteralMapImpl[G]
-final case class LiteralVector[G](element: Type[G], values: Seq[Expr[G]])(implicit val o: Origin) extends Expr[G] with LiteralVectorImpl[G]
-final case class UntypedLiteralSeq[G](values: Seq[Expr[G]])(implicit val o: Origin) extends Expr[G] with UntypedLiteralSeqImpl[G]
-final case class UntypedLiteralSet[G](values: Seq[Expr[G]])(implicit val o: Origin) extends Expr[G] with UntypedLiteralSetImpl[G]
-final case class UntypedLiteralBag[G](values: Seq[Expr[G]])(implicit val o: Origin) extends Expr[G] with UntypedLiteralBagImpl[G]
-final case class Void[G]()(implicit val o: Origin) extends Expr[G] with VoidImpl[G]
-final case class Null[G]()(implicit val o: Origin) extends Expr[G] with NullImpl[G]
-final case class NoPerm[G]()(implicit val o: Origin) extends Expr[G] with NoPermImpl[G]
-final case class WritePerm[G]()(implicit val o: Origin) extends Expr[G] with WritePermImpl[G]
-final case class OptSome[G](e: Expr[G])(implicit val o: Origin) extends Expr[G] with OptSomeImpl[G]
-final case class OptSomeTyped[G](element: Type[G], e: Expr[G])(implicit val o: Origin) extends Expr[G] with OptSomeTypedImpl[G]
-final case class OptNone[G]()(implicit val o: Origin) extends Expr[G] with OptNoneImpl[G]
-final case class OptNoneTyped[G](element: Type[G])(implicit val o: Origin) extends Expr[G] with OptNoneTypedImpl[G]
-final case class Range[G](from: Expr[G], to: Expr[G])(implicit val o: Origin) extends Expr[G] with RangeImpl[G]
-final case class RangeSet[G](from: Expr[G], to: Expr[G])(implicit val o: Origin) extends Expr[G] with RangeSetImpl[G]
-final case class EitherLeft[G](e: Expr[G])(implicit val o: Origin) extends Expr[G] with EitherLeftImpl[G]
-final case class EitherRight[G](e: Expr[G])(implicit val o: Origin) extends Expr[G] with EitherRightImpl[G]
-final case class MapCons[G](map: Expr[G], k: Expr[G], v: Expr[G])(implicit val o: Origin) extends Expr[G] with MapConsImpl[G]
-
-final case class AmbiguousThis[G]()(implicit val o: Origin) extends Expr[G] with AmbiguousThisImpl[G] {
+final case class CIntegerValue[G](value: BigInt)(implicit val o: Origin)
+ extends ConstantInt[G] with Expr[G] with CIntegerValueImpl[G]
+final case class IntegerValue[G](value: BigInt)(implicit val o: Origin)
+ extends ConstantInt[G] with Expr[G] with IntegerValueImpl[G]
+final case class BooleanValue[G](value: Boolean)(implicit val o: Origin)
+ extends Constant[G] with BooleanValueImpl[G]
+final case class FloatValue[G](value: BigDecimal, t: Type[G] /* TFloat */ )(
+ implicit val o: Origin
+) extends Constant[G] with FloatValueImpl[G]
+final case class StringValue[G](value: String)(implicit val o: Origin)
+ extends Constant[G] with StringValueImpl[G]
+final case class CharValue[G](value: Int)(implicit val o: Origin)
+ extends Constant[G] with CharValueImpl[G]
+final case class LiteralSeq[G](element: Type[G], values: Seq[Expr[G]])(
+ implicit val o: Origin
+) extends Expr[G] with LiteralSeqImpl[G]
+final case class LiteralSet[G](element: Type[G], values: Seq[Expr[G]])(
+ implicit val o: Origin
+) extends Expr[G] with LiteralSetImpl[G]
+final case class LiteralBag[G](element: Type[G], values: Seq[Expr[G]])(
+ implicit val o: Origin
+) extends Expr[G] with LiteralBagImpl[G]
+final case class LiteralTuple[G](ts: Seq[Type[G]], values: Seq[Expr[G]])(
+ implicit val o: Origin
+) extends Expr[G] with LiteralTupleImpl[G]
+final case class LiteralMap[G](
+ k: Type[G],
+ v: Type[G],
+ values: Seq[(Expr[G], Expr[G])],
+)(implicit val o: Origin)
+ extends Expr[G] with LiteralMapImpl[G]
+final case class LiteralVector[G](element: Type[G], values: Seq[Expr[G]])(
+ implicit val o: Origin
+) extends Expr[G] with LiteralVectorImpl[G]
+final case class UntypedLiteralSeq[G](values: Seq[Expr[G]])(
+ implicit val o: Origin
+) extends Expr[G] with UntypedLiteralSeqImpl[G]
+final case class UntypedLiteralSet[G](values: Seq[Expr[G]])(
+ implicit val o: Origin
+) extends Expr[G] with UntypedLiteralSetImpl[G]
+final case class UntypedLiteralBag[G](values: Seq[Expr[G]])(
+ implicit val o: Origin
+) extends Expr[G] with UntypedLiteralBagImpl[G]
+final case class Void[G]()(implicit val o: Origin)
+ extends Expr[G] with VoidImpl[G]
+final case class Null[G]()(implicit val o: Origin)
+ extends Expr[G] with NullImpl[G]
+final case class NoPerm[G]()(implicit val o: Origin)
+ extends Expr[G] with NoPermImpl[G]
+final case class WritePerm[G]()(implicit val o: Origin)
+ extends Expr[G] with WritePermImpl[G]
+final case class OptSome[G](e: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with OptSomeImpl[G]
+final case class OptSomeTyped[G](element: Type[G], e: Expr[G])(
+ implicit val o: Origin
+) extends Expr[G] with OptSomeTypedImpl[G]
+final case class OptNone[G]()(implicit val o: Origin)
+ extends Expr[G] with OptNoneImpl[G]
+final case class OptNoneTyped[G](element: Type[G])(implicit val o: Origin)
+ extends Expr[G] with OptNoneTypedImpl[G]
+final case class Range[G](from: Expr[G], to: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with RangeImpl[G]
+final case class RangeSet[G](from: Expr[G], to: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with RangeSetImpl[G]
+final case class EitherLeft[G](e: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with EitherLeftImpl[G]
+final case class EitherRight[G](e: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with EitherRightImpl[G]
+final case class MapCons[G](map: Expr[G], k: Expr[G], v: Expr[G])(
+ implicit val o: Origin
+) extends Expr[G] with MapConsImpl[G]
+
+final case class AmbiguousThis[G]()(implicit val o: Origin)
+ extends Expr[G] with AmbiguousThisImpl[G] {
var ref: Option[ThisTarget[G]] = None
}
sealed trait ThisDeclaration[G] extends Expr[G] with ThisDeclarationImpl[G]
-final case class ThisObject[G](cls: Ref[G, Class[G]])(implicit val o: Origin) extends ThisDeclaration[G] with ThisObjectImpl[G]
-final case class ThisModel[G](cls: Ref[G, Model[G]])(implicit val o: Origin) extends ThisDeclaration[G] with ThisModelImpl[G]
-final case class ThisChoreography[G](cls: Ref[G, Choreography[G]])(implicit val o: Origin) extends ThisDeclaration[G] with ThisChoreographyImpl[G]
-
-final case class AmbiguousResult[G]()(implicit val o: Origin) extends Expr[G] with AmbiguousResultImpl[G] {
+final case class ThisObject[G](cls: Ref[G, Class[G]])(implicit val o: Origin)
+ extends ThisDeclaration[G] with ThisObjectImpl[G]
+final case class ThisModel[G](cls: Ref[G, Model[G]])(implicit val o: Origin)
+ extends ThisDeclaration[G] with ThisModelImpl[G]
+final case class ThisChoreography[G](cls: Ref[G, Choreography[G]])(
+ implicit val o: Origin
+) extends ThisDeclaration[G] with ThisChoreographyImpl[G]
+
+final case class AmbiguousResult[G]()(implicit val o: Origin)
+ extends Expr[G] with AmbiguousResultImpl[G] {
var ref: Option[ResultTarget[G]] = None
}
-final case class Result[G](applicable: Ref[G, ContractApplicable[G]])(implicit val o: Origin) extends Expr[G] with ResultImpl[G]
-final case class CurrentThreadId[G]()(implicit val o: Origin) extends Expr[G] with CurrentThreadIdImpl[G]
-final case class LocalThreadId[G]()(implicit val o: Origin) extends Expr[G] with LocalThreadIdImpl[G]
-final case class GlobalThreadId[G]()(implicit val o: Origin) extends Expr[G] with GlobalThreadIdImpl[G]
-final case class Any[G]()(val blame: Blame[AnyStarError])(implicit val o: Origin) extends Expr[G] with AnyImpl[G]
-final case class ReadPerm[G]()(implicit val o: Origin) extends Expr[G] with ReadPermImpl[G]
-final case class Values[G](arr: Expr[G], from: Expr[G], to: Expr[G])(val blame: Blame[ArrayValuesError])(implicit val o: Origin) extends Expr[G] with ValuesImpl[G]
+final case class Result[G](applicable: Ref[G, ContractApplicable[G]])(
+ implicit val o: Origin
+) extends Expr[G] with ResultImpl[G]
+final case class CurrentThreadId[G]()(implicit val o: Origin)
+ extends Expr[G] with CurrentThreadIdImpl[G]
+final case class LocalThreadId[G]()(implicit val o: Origin)
+ extends Expr[G] with LocalThreadIdImpl[G]
+final case class GlobalThreadId[G]()(implicit val o: Origin)
+ extends Expr[G] with GlobalThreadIdImpl[G]
+final case class Any[G]()(val blame: Blame[AnyStarError])(
+ implicit val o: Origin
+) extends Expr[G] with AnyImpl[G]
+final case class ReadPerm[G]()(implicit val o: Origin)
+ extends Expr[G] with ReadPermImpl[G]
+final case class Values[G](arr: Expr[G], from: Expr[G], to: Expr[G])(
+ val blame: Blame[ArrayValuesError]
+)(implicit val o: Origin)
+ extends Expr[G] with ValuesImpl[G]
sealed trait MapCmp[G] extends Expr[G] with MapCmpImpl[G]
-final case class MapEq[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends MapCmp[G] with MapEqImpl[G]
-final case class MapDisjoint[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends MapCmp[G] with MapDisjointImpl[G]
+final case class MapEq[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends MapCmp[G] with MapEqImpl[G]
+final case class MapDisjoint[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends MapCmp[G] with MapDisjointImpl[G]
sealed trait MapOp[G] extends Expr[G] with MapOpImpl[G]
-final case class MapKeySet[G](map: Expr[G])(implicit val o: Origin) extends MapOp[G] with MapKeySetImpl[G]
-final case class MapValueSet[G](map: Expr[G])(implicit val o: Origin) extends MapOp[G] with MapValueSetImpl[G]
-final case class MapItemSet[G](map: Expr[G])(implicit val o: Origin) extends MapOp[G] with MapItemSetImpl[G]
-final case class MapRemove[G](map: Expr[G], k: Expr[G])(implicit val o: Origin) extends Expr[G] with MapRemoveImpl[G]
+final case class MapKeySet[G](map: Expr[G])(implicit val o: Origin)
+ extends MapOp[G] with MapKeySetImpl[G]
+final case class MapValueSet[G](map: Expr[G])(implicit val o: Origin)
+ extends MapOp[G] with MapValueSetImpl[G]
+final case class MapItemSet[G](map: Expr[G])(implicit val o: Origin)
+ extends MapOp[G] with MapItemSetImpl[G]
+final case class MapRemove[G](map: Expr[G], k: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with MapRemoveImpl[G]
sealed trait Binder[G] extends Expr[G] with BinderImpl[G]
-@scopes[Variable] final case class Forall[G](bindings: Seq[Variable[G]], triggers: Seq[Seq[Expr[G]]], body: Expr[G])(implicit val o: Origin) extends Binder[G] with ForallImpl[G]
-@scopes[Variable] final case class Starall[G](bindings: Seq[Variable[G]], triggers: Seq[Seq[Expr[G]]], body: Expr[G])(val blame: Blame[ReceiverNotInjective])(implicit val o: Origin) extends Binder[G] with StarallImpl[G]
-@scopes[Variable] final case class Exists[G](bindings: Seq[Variable[G]], triggers: Seq[Seq[Expr[G]]], body: Expr[G])(implicit val o: Origin) extends Binder[G] with ExistsImpl[G]
-@scopes[Variable] final case class Sum[G](bindings: Seq[Variable[G]], condition: Expr[G], main: Expr[G])(implicit val o: Origin) extends Binder[G] with SumImpl[G]
-@scopes[Variable] final case class Product[G](bindings: Seq[Variable[G]], condition: Expr[G], main: Expr[G])(implicit val o: Origin) extends Binder[G] with ProductImpl[G]
-@scopes[Variable] final case class ForPerm[G](bindings: Seq[Variable[G]], loc: Location[G], body: Expr[G])(implicit val o: Origin) extends Binder[G] with ForPermImpl[G]
-@scopes[Variable] final case class ForPermWithValue[G](binding: Variable[G], body: Expr[G])(implicit val o: Origin) extends Binder[G] with ForPermWithValueImpl[G]
-@scopes[Variable] final case class Let[G](binding: Variable[G], value: Expr[G], main: Expr[G])(implicit val o: Origin) extends Binder[G] with LetImpl[G]
-final case class InlinePattern[G](inner: Expr[G], parent: Int = 0, group: Int = 0)(implicit val o: Origin) extends Expr[G] with InlinePatternImpl[G]
-
-@scopes[Variable] final case class ScopedExpr[G](declarations: Seq[Variable[G]], body: Expr[G])(implicit val o: Origin) extends Declarator[G] with Expr[G] with ScopedExprImpl[G]
-
-final case class Local[G](ref: Ref[G, Variable[G]])(implicit val o: Origin) extends Expr[G] with LocalImpl[G]
-final case class EnumUse[G](enum: Ref[G, Enum[G]], const: Ref[G, EnumConstant[G]])(implicit val o: Origin) extends Expr[G] with EnumUseImpl[G]
+@scopes[Variable]
+final case class Forall[G](
+ bindings: Seq[Variable[G]],
+ triggers: Seq[Seq[Expr[G]]],
+ body: Expr[G],
+)(implicit val o: Origin)
+ extends Binder[G] with ForallImpl[G]
+@scopes[Variable]
+final case class Starall[G](
+ bindings: Seq[Variable[G]],
+ triggers: Seq[Seq[Expr[G]]],
+ body: Expr[G],
+)(val blame: Blame[ReceiverNotInjective])(implicit val o: Origin)
+ extends Binder[G] with StarallImpl[G]
+@scopes[Variable]
+final case class Exists[G](
+ bindings: Seq[Variable[G]],
+ triggers: Seq[Seq[Expr[G]]],
+ body: Expr[G],
+)(implicit val o: Origin)
+ extends Binder[G] with ExistsImpl[G]
+@scopes[Variable]
+final case class Sum[G](
+ bindings: Seq[Variable[G]],
+ condition: Expr[G],
+ main: Expr[G],
+)(implicit val o: Origin)
+ extends Binder[G] with SumImpl[G]
+@scopes[Variable]
+final case class Product[G](
+ bindings: Seq[Variable[G]],
+ condition: Expr[G],
+ main: Expr[G],
+)(implicit val o: Origin)
+ extends Binder[G] with ProductImpl[G]
+@scopes[Variable]
+final case class ForPerm[G](
+ bindings: Seq[Variable[G]],
+ loc: Location[G],
+ body: Expr[G],
+)(implicit val o: Origin)
+ extends Binder[G] with ForPermImpl[G]
+@scopes[Variable]
+final case class ForPermWithValue[G](binding: Variable[G], body: Expr[G])(
+ implicit val o: Origin
+) extends Binder[G] with ForPermWithValueImpl[G]
+@scopes[Variable]
+final case class Let[G](binding: Variable[G], value: Expr[G], main: Expr[G])(
+ implicit val o: Origin
+) extends Binder[G] with LetImpl[G]
+final case class InlinePattern[G](
+ inner: Expr[G],
+ parent: Int = 0,
+ group: Int = 0,
+)(implicit val o: Origin)
+ extends Expr[G] with InlinePatternImpl[G]
+
+@scopes[Variable]
+final case class ScopedExpr[G](declarations: Seq[Variable[G]], body: Expr[G])(
+ implicit val o: Origin
+) extends Declarator[G] with Expr[G] with ScopedExprImpl[G]
+
+final case class Local[G](ref: Ref[G, Variable[G]])(implicit val o: Origin)
+ extends Expr[G] with LocalImpl[G]
+final case class EnumUse[G](
+ enum: Ref[G, Enum[G]],
+ const: Ref[G, EnumConstant[G]],
+)(implicit val o: Origin)
+ extends Expr[G] with EnumUseImpl[G]
sealed trait HeapDeref[G] extends Expr[G] with HeapDerefImpl[G]
-final case class DerefHeapVariable[G](ref: Ref[G, HeapVariable[G]])(val blame: Blame[InsufficientPermission])(implicit val o: Origin) extends Expr[G] with HeapDeref[G] with DerefHeapVariableImpl[G]
-final case class Deref[G](obj: Expr[G], ref: Ref[G, InstanceField[G]])(val blame: Blame[InsufficientPermission])(implicit val o: Origin) extends Expr[G] with HeapDeref[G] with DerefImpl[G]
-final case class ModelDeref[G](obj: Expr[G], ref: Ref[G, ModelField[G]])(val blame: Blame[ModelInsufficientPermission])(implicit val o: Origin) extends Expr[G] with ModelDerefImpl[G]
-final case class DerefPointer[G](pointer: Expr[G])(val blame: Blame[PointerDerefError])(implicit val o: Origin) extends Expr[G] with DerefPointerImpl[G]
-final case class PointerAdd[G](pointer: Expr[G], offset: Expr[G])(val blame: Blame[PointerAddError])(implicit val o: Origin) extends Expr[G] with PointerAddImpl[G]
-final case class AddrOf[G](e: Expr[G])(implicit val o: Origin) extends Expr[G] with AddrOfImpl[G]
-final case class FunctionOf[G](binding: Ref[G, Variable[G]], vars: Seq[Ref[G, Variable[G]]])(implicit val o: Origin) extends Expr[G] with FunctionOfImpl[G]
-final case class ApplyCoercion[G](e: Expr[G], coercion: Coercion[G])(implicit val o: Origin) extends Expr[G] with ApplyCoercionImpl[G]
-final case class SizeOf[G](tname: Type[G])(implicit val o: Origin) extends Expr[G] with SizeOfImpl[G]
+final case class DerefHeapVariable[G](ref: Ref[G, HeapVariable[G]])(
+ val blame: Blame[InsufficientPermission]
+)(implicit val o: Origin)
+ extends Expr[G] with HeapDeref[G] with DerefHeapVariableImpl[G]
+final case class Deref[G](obj: Expr[G], ref: Ref[G, InstanceField[G]])(
+ val blame: Blame[InsufficientPermission]
+)(implicit val o: Origin)
+ extends Expr[G] with HeapDeref[G] with DerefImpl[G]
+final case class ModelDeref[G](obj: Expr[G], ref: Ref[G, ModelField[G]])(
+ val blame: Blame[ModelInsufficientPermission]
+)(implicit val o: Origin)
+ extends Expr[G] with ModelDerefImpl[G]
+final case class DerefPointer[G](pointer: Expr[G])(
+ val blame: Blame[PointerDerefError]
+)(implicit val o: Origin)
+ extends Expr[G] with DerefPointerImpl[G]
+final case class PointerAdd[G](pointer: Expr[G], offset: Expr[G])(
+ val blame: Blame[PointerAddError]
+)(implicit val o: Origin)
+ extends Expr[G] with PointerAddImpl[G]
+final case class AddrOf[G](e: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with AddrOfImpl[G]
+final case class FunctionOf[G](
+ binding: Ref[G, Variable[G]],
+ vars: Seq[Ref[G, Variable[G]]],
+)(implicit val o: Origin)
+ extends Expr[G] with FunctionOfImpl[G]
+final case class ApplyCoercion[G](e: Expr[G], coercion: Coercion[G])(
+ implicit val o: Origin
+) extends Expr[G] with ApplyCoercionImpl[G]
+final case class SizeOf[G](tname: Type[G])(implicit val o: Origin)
+ extends Expr[G] with SizeOfImpl[G]
sealed trait Apply[G] extends Expr[G] with ApplyImpl[G]
-final case class ADTFunctionInvocation[G](typeArgs: Option[(Ref[G, AxiomaticDataType[G]], Seq[Type[G]])], ref: Ref[G, ADTFunction[G]], args: Seq[Expr[G]])(implicit val o: Origin) extends Apply[G] with ADTFunctionInvocationImpl[G]
-final case class ProverFunctionInvocation[G](ref: Ref[G, ProverFunction[G]], args: Seq[Expr[G]])(implicit val o: Origin) extends Apply[G] with ProverFunctionInvocationImpl[G]
+final case class ADTFunctionInvocation[G](
+ typeArgs: Option[(Ref[G, AxiomaticDataType[G]], Seq[Type[G]])],
+ ref: Ref[G, ADTFunction[G]],
+ args: Seq[Expr[G]],
+)(implicit val o: Origin)
+ extends Apply[G] with ADTFunctionInvocationImpl[G]
+final case class ProverFunctionInvocation[G](
+ ref: Ref[G, ProverFunction[G]],
+ args: Seq[Expr[G]],
+)(implicit val o: Origin)
+ extends Apply[G] with ProverFunctionInvocationImpl[G]
sealed trait ApplyInlineable[G] extends Apply[G] with ApplyInlineableImpl[G]
sealed trait InstanceApply[G] extends Node[G] with InstanceApplyImpl[G]
-sealed trait ApplyAnyPredicate[G] extends ApplyInlineable[G] with ApplyAnyPredicateImpl[G]
-final case class PredicateApply[G](ref: Ref[G, Predicate[G]], args: Seq[Expr[G]], perm: Expr[G])(implicit val o: Origin) extends ApplyAnyPredicate[G] with PredicateApplyImpl[G]
-final case class InstancePredicateApply[G](obj: Expr[G], ref: Ref[G, InstancePredicate[G]], args: Seq[Expr[G]], perm: Expr[G])(implicit val o: Origin) extends ApplyAnyPredicate[G] with InstanceApply[G] with InstancePredicateApplyImpl[G]
-final case class CoalesceInstancePredicateApply[G](obj: Expr[G], ref: Ref[G, InstancePredicate[G]], args: Seq[Expr[G]], perm: Expr[G])(implicit val o: Origin) extends ApplyAnyPredicate[G] with InstanceApply[G] with CoalesceInstancePredicateApplyImpl[G]
+sealed trait ApplyAnyPredicate[G]
+ extends ApplyInlineable[G] with ApplyAnyPredicateImpl[G]
+final case class PredicateApply[G](
+ ref: Ref[G, Predicate[G]],
+ args: Seq[Expr[G]],
+ perm: Expr[G],
+)(implicit val o: Origin)
+ extends ApplyAnyPredicate[G] with PredicateApplyImpl[G]
+final case class InstancePredicateApply[G](
+ obj: Expr[G],
+ ref: Ref[G, InstancePredicate[G]],
+ args: Seq[Expr[G]],
+ perm: Expr[G],
+)(implicit val o: Origin)
+ extends ApplyAnyPredicate[G]
+ with InstanceApply[G]
+ with InstancePredicateApplyImpl[G]
+final case class CoalesceInstancePredicateApply[G](
+ obj: Expr[G],
+ ref: Ref[G, InstancePredicate[G]],
+ args: Seq[Expr[G]],
+ perm: Expr[G],
+)(implicit val o: Origin)
+ extends ApplyAnyPredicate[G]
+ with InstanceApply[G]
+ with CoalesceInstancePredicateApplyImpl[G]
sealed trait InvokingNode[G] extends Node[G] with InvokingNodeImpl[G]
-sealed trait Invocation[G] extends ApplyInlineable[G] with InvokingNode[G] with InvocationImpl[G]
-
-sealed trait AnyMethodInvocation[G] extends Invocation[G] with AnyMethodInvocationImpl[G]
-final case class ProcedureInvocation[G](ref: Ref[G, Procedure[G]], args: Seq[Expr[G]], outArgs: Seq[Expr[G]], typeArgs: Seq[Type[G]], givenMap: Seq[(Ref[G, Variable[G]], Expr[G])], yields: Seq[(Expr[G], Ref[G, Variable[G]])])(val blame: Blame[InvocationFailure])(implicit val o: Origin) extends AnyMethodInvocation[G] with ProcedureInvocationImpl[G]
-final case class MethodInvocation[G](obj: Expr[G], ref: Ref[G, InstanceMethod[G]], args: Seq[Expr[G]], outArgs: Seq[Expr[G]], typeArgs: Seq[Type[G]], givenMap: Seq[(Ref[G, Variable[G]], Expr[G])], yields: Seq[(Expr[G], Ref[G, Variable[G]])])(val blame: Blame[InstanceInvocationFailure])(implicit val o: Origin) extends AnyMethodInvocation[G] with InstanceApply[G] with MethodInvocationImpl[G]
-final case class ConstructorInvocation[G](ref: Ref[G, Constructor[G]], classTypeArgs: Seq[Type[G]], args: Seq[Expr[G]], outArgs: Seq[Expr[G]], typeArgs: Seq[Type[G]], givenMap: Seq[(Ref[G, Variable[G]], Expr[G])], yields: Seq[(Expr[G], Ref[G, Variable[G]])])(val blame: Blame[InvocationFailure])(implicit val o: Origin) extends AnyMethodInvocation[G] with ConstructorInvocationImpl[G]
-
-sealed trait AnyFunctionInvocation[G] extends Invocation[G] with AnyFunctionInvocationImpl[G]
-final case class FunctionInvocation[G](ref: Ref[G, Function[G]], args: Seq[Expr[G]], typeArgs: Seq[Type[G]], givenMap: Seq[(Ref[G, Variable[G]], Expr[G])], yields: Seq[(Expr[G], Ref[G, Variable[G]])])(val blame: Blame[InvocationFailure])(implicit val o: Origin) extends AnyFunctionInvocation[G] with FunctionInvocationImpl[G]
-final case class InstanceFunctionInvocation[G](obj: Expr[G], ref: Ref[G, InstanceFunction[G]], args: Seq[Expr[G]], typeArgs: Seq[Type[G]], givenMap: Seq[(Ref[G, Variable[G]], Expr[G])], yields: Seq[(Expr[G], Ref[G, Variable[G]])])(val blame: Blame[InstanceInvocationFailure])(implicit val o: Origin) extends AnyFunctionInvocation[G] with InstanceApply[G] with InstanceFunctionInvocationImpl[G]
+sealed trait Invocation[G]
+ extends ApplyInlineable[G] with InvokingNode[G] with InvocationImpl[G]
+
+sealed trait AnyMethodInvocation[G]
+ extends Invocation[G] with AnyMethodInvocationImpl[G]
+final case class ProcedureInvocation[G](
+ ref: Ref[G, Procedure[G]],
+ args: Seq[Expr[G]],
+ outArgs: Seq[Expr[G]],
+ typeArgs: Seq[Type[G]],
+ givenMap: Seq[(Ref[G, Variable[G]], Expr[G])],
+ yields: Seq[(Expr[G], Ref[G, Variable[G]])],
+)(val blame: Blame[InvocationFailure])(implicit val o: Origin)
+ extends AnyMethodInvocation[G] with ProcedureInvocationImpl[G]
+final case class MethodInvocation[G](
+ obj: Expr[G],
+ ref: Ref[G, InstanceMethod[G]],
+ args: Seq[Expr[G]],
+ outArgs: Seq[Expr[G]],
+ typeArgs: Seq[Type[G]],
+ givenMap: Seq[(Ref[G, Variable[G]], Expr[G])],
+ yields: Seq[(Expr[G], Ref[G, Variable[G]])],
+)(val blame: Blame[InstanceInvocationFailure])(implicit val o: Origin)
+ extends AnyMethodInvocation[G]
+ with InstanceApply[G]
+ with MethodInvocationImpl[G]
+final case class ConstructorInvocation[G](
+ ref: Ref[G, Constructor[G]],
+ classTypeArgs: Seq[Type[G]],
+ args: Seq[Expr[G]],
+ outArgs: Seq[Expr[G]],
+ typeArgs: Seq[Type[G]],
+ givenMap: Seq[(Ref[G, Variable[G]], Expr[G])],
+ yields: Seq[(Expr[G], Ref[G, Variable[G]])],
+)(val blame: Blame[InvocationFailure])(implicit val o: Origin)
+ extends AnyMethodInvocation[G] with ConstructorInvocationImpl[G]
+
+sealed trait AnyFunctionInvocation[G]
+ extends Invocation[G] with AnyFunctionInvocationImpl[G]
+final case class FunctionInvocation[G](
+ ref: Ref[G, Function[G]],
+ args: Seq[Expr[G]],
+ typeArgs: Seq[Type[G]],
+ givenMap: Seq[(Ref[G, Variable[G]], Expr[G])],
+ yields: Seq[(Expr[G], Ref[G, Variable[G]])],
+)(val blame: Blame[InvocationFailure])(implicit val o: Origin)
+ extends AnyFunctionInvocation[G] with FunctionInvocationImpl[G]
+final case class InstanceFunctionInvocation[G](
+ obj: Expr[G],
+ ref: Ref[G, InstanceFunction[G]],
+ args: Seq[Expr[G]],
+ typeArgs: Seq[Type[G]],
+ givenMap: Seq[(Ref[G, Variable[G]], Expr[G])],
+ yields: Seq[(Expr[G], Ref[G, Variable[G]])],
+)(val blame: Blame[InstanceInvocationFailure])(implicit val o: Origin)
+ extends AnyFunctionInvocation[G]
+ with InstanceApply[G]
+ with InstanceFunctionInvocationImpl[G]
sealed trait UnExpr[G] extends Expr[G] with UnExprImpl[G]
-final case class UMinus[G](arg: Expr[G])(implicit val o: Origin) extends UnExpr[G] with UMinusImpl[G]
-final case class BitNot[G](arg: Expr[G])(implicit val o: Origin) extends UnExpr[G] with BitNotImpl[G]
-final case class Not[G](arg: Expr[G])(implicit val o: Origin) extends UnExpr[G] with NotImpl[G]
+final case class UMinus[G](arg: Expr[G])(implicit val o: Origin)
+ extends UnExpr[G] with UMinusImpl[G]
+final case class BitNot[G](arg: Expr[G])(implicit val o: Origin)
+ extends UnExpr[G] with BitNotImpl[G]
+final case class Not[G](arg: Expr[G])(implicit val o: Origin)
+ extends UnExpr[G] with NotImpl[G]
sealed trait BinExpr[G] extends Expr[G] with BinExprImpl[G]
sealed trait NumericBinExpr[G] extends BinExpr[G] with NumericBinExprImpl[G]
sealed trait DividingExpr[G] extends Expr[G] with DividingExprImpl[G]
-final case class AmbiguousMult[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends BinExpr[G] with AmbiguousMultImpl[G]
-final case class AmbiguousPlus[G](left: Expr[G], right: Expr[G])(val blame: Blame[FrontendAdditiveError])(implicit val o: Origin) extends BinExpr[G] with AmbiguousPlusImpl[G]
-final case class AmbiguousMinus[G](left: Expr[G], right: Expr[G])(val blame: Blame[FrontendAdditiveError])(implicit val o: Origin) extends BinExpr[G] with AmbiguousMinusImpl[G]
-final case class AmbiguousOr[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends BinExpr[G] with AmbiguousOrImpl[G]
-
-sealed trait AmbiguousDividingExpr[G] extends DividingExpr[G] with BinExpr[G] with AmbiguousDividingExprImpl[G]
-final case class AmbiguousDiv[G](left: Expr[G], right: Expr[G])(val blame: Blame[DivByZero])(implicit val o: Origin) extends BinExpr[G] with AmbiguousDividingExpr[G] with AmbiguousDivImpl[G]
-final case class AmbiguousMod[G](left: Expr[G], right: Expr[G])(val blame: Blame[DivByZero])(implicit val o: Origin) extends BinExpr[G] with AmbiguousDividingExpr[G] with AmbiguousModImpl[G]
-final case class AmbiguousTruncDiv[G](left: Expr[G], right: Expr[G])(val blame: Blame[DivByZero])(implicit val o: Origin) extends BinExpr[G] with AmbiguousDividingExpr[G] with AmbiguousTruncDivImpl[G]
-final case class AmbiguousTruncMod[G](left: Expr[G], right: Expr[G])(val blame: Blame[DivByZero])(implicit val o: Origin) extends BinExpr[G] with AmbiguousDividingExpr[G] with AmbiguousTruncModImpl[G]
+final case class AmbiguousMult[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends BinExpr[G] with AmbiguousMultImpl[G]
+final case class AmbiguousPlus[G](left: Expr[G], right: Expr[G])(
+ val blame: Blame[FrontendAdditiveError]
+)(implicit val o: Origin)
+ extends BinExpr[G] with AmbiguousPlusImpl[G]
+final case class AmbiguousMinus[G](left: Expr[G], right: Expr[G])(
+ val blame: Blame[FrontendAdditiveError]
+)(implicit val o: Origin)
+ extends BinExpr[G] with AmbiguousMinusImpl[G]
+final case class AmbiguousOr[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends BinExpr[G] with AmbiguousOrImpl[G]
+
+sealed trait AmbiguousDividingExpr[G]
+ extends DividingExpr[G] with BinExpr[G] with AmbiguousDividingExprImpl[G]
+final case class AmbiguousDiv[G](left: Expr[G], right: Expr[G])(
+ val blame: Blame[DivByZero]
+)(implicit val o: Origin)
+ extends BinExpr[G] with AmbiguousDividingExpr[G] with AmbiguousDivImpl[G]
+final case class AmbiguousMod[G](left: Expr[G], right: Expr[G])(
+ val blame: Blame[DivByZero]
+)(implicit val o: Origin)
+ extends BinExpr[G] with AmbiguousDividingExpr[G] with AmbiguousModImpl[G]
+final case class AmbiguousTruncDiv[G](left: Expr[G], right: Expr[G])(
+ val blame: Blame[DivByZero]
+)(implicit val o: Origin)
+ extends BinExpr[G]
+ with AmbiguousDividingExpr[G]
+ with AmbiguousTruncDivImpl[G]
+final case class AmbiguousTruncMod[G](left: Expr[G], right: Expr[G])(
+ val blame: Blame[DivByZero]
+)(implicit val o: Origin)
+ extends BinExpr[G]
+ with AmbiguousDividingExpr[G]
+ with AmbiguousTruncModImpl[G]
sealed trait BitOp[G] extends BinExpr[G] with BitOpImpl[G]
-final case class AmbiguousComputationalOr[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends BitOp[G] with AmbiguousComputationalOrImpl[G]
-final case class AmbiguousComputationalXor[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends BitOp[G] with AmbiguousComputationalXorImpl[G]
-final case class AmbiguousComputationalAnd[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends BitOp[G] with AmbiguousComputationalAndImpl[G]
-
-final case class ComputationalOr[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends BinExpr[G] with ComputationalOrImpl[G]
-final case class ComputationalXor[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends BinExpr[G] with ComputationalXorImpl[G]
-final case class ComputationalAnd[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends BinExpr[G] with ComputationalAndImpl[G]
-
-final case class Exp[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends NumericBinExpr[G] with ExpImpl[G]
-final case class Plus[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends NumericBinExpr[G] with PlusImpl[G]
-final case class Minus[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends NumericBinExpr[G] with MinusImpl[G]
-final case class Mult[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends NumericBinExpr[G] with MultImpl[G]
-final case class RatDiv[G](left: Expr[G], right: Expr[G])(val blame: Blame[DivByZero])(implicit val o: Origin) extends BinExpr[G] with DividingExpr[G] with RatDivImpl[G]
-final case class FloatDiv[G](left: Expr[G], right: Expr[G])(val blame: Blame[DivByZero])(implicit val o: Origin) extends BinExpr[G] with DividingExpr[G] with FloatDivImpl[G]
-final case class FloorDiv[G](left: Expr[G], right: Expr[G])(val blame: Blame[DivByZero])(implicit val o: Origin) extends BinExpr[G] with DividingExpr[G] with FloorDivImpl[G]
-final case class Mod[G](left: Expr[G], right: Expr[G])(val blame: Blame[DivByZero])(implicit val o: Origin) extends BinExpr[G] with DividingExpr[G] with ModImpl[G]
-final case class TruncDiv[G](left: Expr[G], right: Expr[G])(val blame: Blame[DivByZero])(implicit val o: Origin) extends BinExpr[G] with DividingExpr[G] with TruncDivImpl[G]
-final case class TruncMod[G](left: Expr[G], right: Expr[G])(val blame: Blame[DivByZero])(implicit val o: Origin) extends BinExpr[G] with DividingExpr[G] with TruncModImpl[G]
+final case class AmbiguousComputationalOr[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends BitOp[G] with AmbiguousComputationalOrImpl[G]
+final case class AmbiguousComputationalXor[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends BitOp[G] with AmbiguousComputationalXorImpl[G]
+final case class AmbiguousComputationalAnd[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends BitOp[G] with AmbiguousComputationalAndImpl[G]
+
+final case class ComputationalOr[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends BinExpr[G] with ComputationalOrImpl[G]
+final case class ComputationalXor[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends BinExpr[G] with ComputationalXorImpl[G]
+final case class ComputationalAnd[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends BinExpr[G] with ComputationalAndImpl[G]
+
+final case class Exp[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends NumericBinExpr[G] with ExpImpl[G]
+final case class Plus[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends NumericBinExpr[G] with PlusImpl[G]
+final case class Minus[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends NumericBinExpr[G] with MinusImpl[G]
+final case class Mult[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends NumericBinExpr[G] with MultImpl[G]
+final case class RatDiv[G](left: Expr[G], right: Expr[G])(
+ val blame: Blame[DivByZero]
+)(implicit val o: Origin)
+ extends BinExpr[G] with DividingExpr[G] with RatDivImpl[G]
+final case class FloatDiv[G](left: Expr[G], right: Expr[G])(
+ val blame: Blame[DivByZero]
+)(implicit val o: Origin)
+ extends BinExpr[G] with DividingExpr[G] with FloatDivImpl[G]
+final case class FloorDiv[G](left: Expr[G], right: Expr[G])(
+ val blame: Blame[DivByZero]
+)(implicit val o: Origin)
+ extends BinExpr[G] with DividingExpr[G] with FloorDivImpl[G]
+final case class Mod[G](left: Expr[G], right: Expr[G])(
+ val blame: Blame[DivByZero]
+)(implicit val o: Origin)
+ extends BinExpr[G] with DividingExpr[G] with ModImpl[G]
+final case class TruncDiv[G](left: Expr[G], right: Expr[G])(
+ val blame: Blame[DivByZero]
+)(implicit val o: Origin)
+ extends BinExpr[G] with DividingExpr[G] with TruncDivImpl[G]
+final case class TruncMod[G](left: Expr[G], right: Expr[G])(
+ val blame: Blame[DivByZero]
+)(implicit val o: Origin)
+ extends BinExpr[G] with DividingExpr[G] with TruncModImpl[G]
sealed trait VectorBinExpr[G] extends BinExpr[G] with VectorBinExprImpl[G]
-final case class VectorPlus[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends VectorBinExpr[G] with VectorPlusImpl[G]
-final case class VectorMinus[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends VectorBinExpr[G] with VectorMinusImpl[G]
-final case class VectorMult[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends VectorBinExpr[G] with VectorMultImpl[G]
-final case class VectorEq[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends VectorBinExpr[G] with VectorEqImpl[G]
-final case class VectorNeq[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends VectorBinExpr[G] with VectorNeqImpl[G]
-
-sealed trait DividingVectorBinExpr[G] extends VectorBinExpr[G] with DividingExpr[G]
-final case class VectorFloorDiv[G](left: Expr[G], right: Expr[G])(val blame: Blame[DivByZero])(implicit val o: Origin) extends DividingVectorBinExpr[G] with VectorFloorDivImpl[G]
-final case class VectorFloatDiv[G](left: Expr[G], right: Expr[G])(val blame: Blame[DivByZero])(implicit val o: Origin) extends DividingVectorBinExpr[G] with VectorFloatDivImpl[G]
-final case class VectorTruncDiv[G](left: Expr[G], right: Expr[G])(val blame: Blame[DivByZero])(implicit val o: Origin) extends DividingVectorBinExpr[G] with VectorTruncDivImpl[G]
-final case class VectorMod[G](left: Expr[G], right: Expr[G])(val blame: Blame[DivByZero])(implicit val o: Origin) extends DividingVectorBinExpr[G] with VectorModImpl[G]
-final case class VectorTruncMod[G](left: Expr[G], right: Expr[G])(val blame: Blame[DivByZero])(implicit val o: Origin) extends DividingVectorBinExpr[G] with VectorTruncModImpl[G]
-
-final case class StringConcat[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends BinExpr[G] with StringConcatImpl[G]
-
-final case class BitAnd[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends BinExpr[G] with BitAndImpl[G]
-final case class BitOr[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends BinExpr[G] with BitOrImpl[G]
-final case class BitXor[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends BinExpr[G] with BitXorImpl[G]
-final case class BitShl[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends BinExpr[G] with BitShlImpl[G]
-final case class BitShr[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends BinExpr[G] with BitShrImpl[G]
-final case class BitUShr[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends BinExpr[G] with BitUShrImpl[G]
-
-final case class And[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends BinExpr[G] with AndImpl[G]
-final case class Or[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends BinExpr[G] with OrImpl[G]
-final case class Implies[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends BinExpr[G] with ImpliesImpl[G]
-final case class Star[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends Expr[G] with StarImpl[G]
-final case class Wand[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends Expr[G] with WandImpl[G]
-final case class Scale[G](scale: Expr[G], res: Expr[G])(val blame: Blame[ScaleNegative])(implicit val o: Origin) extends Expr[G] with ScaleImpl[G]
-final case class ScaleByParBlock[G](block: Ref[G, ParBlockDecl[G]], res: Expr[G])(implicit val o: Origin) extends Expr[G] with ScaleByParBlockImpl[G]
-final case class PolarityDependent[G](onInhale: Expr[G], onExhale: Expr[G])(implicit val o: Origin) extends Expr[G] with PolarityDependentImpl[G]
-
-final case class Unfolding[G](res: Expr[G], body: Expr[G])(val blame: Blame[UnfoldFailed])(implicit val o: Origin) extends Expr[G] with UnfoldingImpl[G]
-
-@family sealed trait Location[G] extends NodeFamily[G] with LocationImpl[G]
-final case class HeapVariableLocation[G](ref: Ref[G, HeapVariable[G]])(implicit val o: Origin) extends Location[G] with HeapVariableLocationImpl[G]
-final case class FieldLocation[G](obj: Expr[G], field: Ref[G, InstanceField[G]])(implicit val o: Origin) extends Location[G] with FieldLocationImpl[G]
-final case class ModelLocation[G](obj: Expr[G], field: Ref[G, ModelField[G]])(implicit val o: Origin) extends Location[G] with ModelLocationImpl[G]
-final case class SilverFieldLocation[G](obj: Expr[G], field: Ref[G, SilverField[G]])(implicit val o: Origin) extends Location[G] with SilverFieldLocationImpl[G]
-final case class ArrayLocation[G](array: Expr[G], subscript: Expr[G])(val blame: Blame[ArrayLocationError])(implicit val o: Origin) extends Location[G] with ArrayLocationImpl[G]
-final case class PointerLocation[G](pointer: Expr[G])(val blame: Blame[PointerLocationError])(implicit val o: Origin) extends Location[G] with PointerLocationImpl[G]
-final case class PredicateLocation[G](predicate: Ref[G, Predicate[G]], args: Seq[Expr[G]])(implicit val o: Origin) extends Location[G] with PredicateLocationImpl[G]
-final case class InstancePredicateLocation[G](predicate: Ref[G, InstancePredicate[G]], obj: Expr[G], args: Seq[Expr[G]])(implicit val o: Origin) extends Location[G] with InstancePredicateLocationImpl[G]
-final case class AmbiguousLocation[G](expr: Expr[G])(val blame: Blame[PointerLocationError])(implicit val o: Origin) extends Location[G] with AmbiguousLocationImpl[G]
-final case class InLinePatternLocation[G](loc: Location[G], pattern: Expr[G])(implicit val o: Origin) extends Location[G] with InLinePatternLocationImpl[G]
-
-final case class Perm[G](loc: Location[G], perm: Expr[G])(implicit val o: Origin) extends Expr[G] with PermImpl[G]
-final case class PointsTo[G](loc: Location[G], perm: Expr[G], value: Expr[G])(implicit val o: Origin) extends Expr[G] with PointsToImpl[G]
-final case class CurPerm[G](loc: Location[G])(implicit val o: Origin) extends Expr[G] with CurPermImpl[G]
-
-final case class Value[G](loc: Location[G])(implicit val o: Origin) extends Expr[G] with ValueImpl[G]
-final case class AutoValue[G](loc: Location[G])(implicit val o: Origin) extends Expr[G] with AutoValueImpl[G]
-
-final case class ValidArray[G](arr: Expr[G], len: Expr[G])(implicit val o: Origin) extends Expr[G] with ValidArrayImpl[G]
-final case class ValidMatrix[G](mat: Expr[G], w: Expr[G], h: Expr[G])(implicit val o: Origin) extends Expr[G] with ValidMatrixImpl[G]
-
-final case class PermPointer[G](p: Expr[G], len: Expr[G], perm: Expr[G])(implicit val o: Origin) extends Expr[G] with PermPointerImpl[G]
-final case class PermPointerIndex[G](p: Expr[G], idx: Expr[G], perm: Expr[G])(implicit val o: Origin) extends Expr[G] with PermPointerIndexImpl[G]
-
-final case class ResourceOfResourceValue[G](res: Expr[G])(implicit val o: Origin) extends Expr[G] with ResourceOfResourceValueImpl[G]
-final case class ResourceValue[G](res: Expr[G])(implicit val o: Origin) extends Expr[G] with ResourceValueImpl[G]
+final case class VectorPlus[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends VectorBinExpr[G] with VectorPlusImpl[G]
+final case class VectorMinus[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends VectorBinExpr[G] with VectorMinusImpl[G]
+final case class VectorMult[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends VectorBinExpr[G] with VectorMultImpl[G]
+final case class VectorEq[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends VectorBinExpr[G] with VectorEqImpl[G]
+final case class VectorNeq[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends VectorBinExpr[G] with VectorNeqImpl[G]
+
+sealed trait DividingVectorBinExpr[G]
+ extends VectorBinExpr[G] with DividingExpr[G]
+final case class VectorFloorDiv[G](left: Expr[G], right: Expr[G])(
+ val blame: Blame[DivByZero]
+)(implicit val o: Origin)
+ extends DividingVectorBinExpr[G] with VectorFloorDivImpl[G]
+final case class VectorFloatDiv[G](left: Expr[G], right: Expr[G])(
+ val blame: Blame[DivByZero]
+)(implicit val o: Origin)
+ extends DividingVectorBinExpr[G] with VectorFloatDivImpl[G]
+final case class VectorTruncDiv[G](left: Expr[G], right: Expr[G])(
+ val blame: Blame[DivByZero]
+)(implicit val o: Origin)
+ extends DividingVectorBinExpr[G] with VectorTruncDivImpl[G]
+final case class VectorMod[G](left: Expr[G], right: Expr[G])(
+ val blame: Blame[DivByZero]
+)(implicit val o: Origin)
+ extends DividingVectorBinExpr[G] with VectorModImpl[G]
+final case class VectorTruncMod[G](left: Expr[G], right: Expr[G])(
+ val blame: Blame[DivByZero]
+)(implicit val o: Origin)
+ extends DividingVectorBinExpr[G] with VectorTruncModImpl[G]
+
+final case class StringConcat[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends BinExpr[G] with StringConcatImpl[G]
+
+final case class BitAnd[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends BinExpr[G] with BitAndImpl[G]
+final case class BitOr[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends BinExpr[G] with BitOrImpl[G]
+final case class BitXor[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends BinExpr[G] with BitXorImpl[G]
+final case class BitShl[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends BinExpr[G] with BitShlImpl[G]
+final case class BitShr[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends BinExpr[G] with BitShrImpl[G]
+final case class BitUShr[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends BinExpr[G] with BitUShrImpl[G]
+
+final case class And[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends BinExpr[G] with AndImpl[G]
+final case class Or[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends BinExpr[G] with OrImpl[G]
+final case class Implies[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends BinExpr[G] with ImpliesImpl[G]
+final case class Star[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with StarImpl[G]
+final case class Wand[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with WandImpl[G]
+final case class Scale[G](scale: Expr[G], res: Expr[G])(
+ val blame: Blame[ScaleNegative]
+)(implicit val o: Origin)
+ extends Expr[G] with ScaleImpl[G]
+final case class ScaleByParBlock[G](
+ block: Ref[G, ParBlockDecl[G]],
+ res: Expr[G],
+)(implicit val o: Origin)
+ extends Expr[G] with ScaleByParBlockImpl[G]
+final case class PolarityDependent[G](onInhale: Expr[G], onExhale: Expr[G])(
+ implicit val o: Origin
+) extends Expr[G] with PolarityDependentImpl[G]
+
+final case class Unfolding[G](res: Expr[G], body: Expr[G])(
+ val blame: Blame[UnfoldFailed]
+)(implicit val o: Origin)
+ extends Expr[G] with UnfoldingImpl[G]
-sealed trait Comparison[G] extends BinExpr[G] with ComparisonImpl[G]
-sealed trait AmbiguousComparison[G] extends Comparison[G] with AmbiguousComparisonImpl[G]
-final case class AmbiguousEq[G](left: Expr[G], right: Expr[G], vectorInnerType: Type[G])(implicit val o: Origin) extends AmbiguousComparison[G] with AmbiguousEqImpl[G]
-final case class AmbiguousNeq[G](left: Expr[G], right: Expr[G], vectorInnerType: Type[G])(implicit val o: Origin) extends AmbiguousComparison[G] with AmbiguousNeqImpl[G]
+@family
+sealed trait Location[G] extends NodeFamily[G] with LocationImpl[G]
+final case class HeapVariableLocation[G](ref: Ref[G, HeapVariable[G]])(
+ implicit val o: Origin
+) extends Location[G] with HeapVariableLocationImpl[G]
+final case class FieldLocation[G](
+ obj: Expr[G],
+ field: Ref[G, InstanceField[G]],
+)(implicit val o: Origin)
+ extends Location[G] with FieldLocationImpl[G]
+final case class ModelLocation[G](obj: Expr[G], field: Ref[G, ModelField[G]])(
+ implicit val o: Origin
+) extends Location[G] with ModelLocationImpl[G]
+final case class SilverFieldLocation[G](
+ obj: Expr[G],
+ field: Ref[G, SilverField[G]],
+)(implicit val o: Origin)
+ extends Location[G] with SilverFieldLocationImpl[G]
+final case class ArrayLocation[G](array: Expr[G], subscript: Expr[G])(
+ val blame: Blame[ArrayLocationError]
+)(implicit val o: Origin)
+ extends Location[G] with ArrayLocationImpl[G]
+final case class PointerLocation[G](pointer: Expr[G])(
+ val blame: Blame[PointerLocationError]
+)(implicit val o: Origin)
+ extends Location[G] with PointerLocationImpl[G]
+final case class PredicateLocation[G](
+ predicate: Ref[G, Predicate[G]],
+ args: Seq[Expr[G]],
+)(implicit val o: Origin)
+ extends Location[G] with PredicateLocationImpl[G]
+final case class InstancePredicateLocation[G](
+ predicate: Ref[G, InstancePredicate[G]],
+ obj: Expr[G],
+ args: Seq[Expr[G]],
+)(implicit val o: Origin)
+ extends Location[G] with InstancePredicateLocationImpl[G]
+final case class AmbiguousLocation[G](expr: Expr[G])(
+ val blame: Blame[PointerLocationError]
+)(implicit val o: Origin)
+ extends Location[G] with AmbiguousLocationImpl[G]
+final case class InLinePatternLocation[G](loc: Location[G], pattern: Expr[G])(
+ implicit val o: Origin
+) extends Location[G] with InLinePatternLocationImpl[G]
+
+final case class Perm[G](loc: Location[G], perm: Expr[G])(
+ implicit val o: Origin
+) extends Expr[G] with PermImpl[G]
+final case class PointsTo[G](loc: Location[G], perm: Expr[G], value: Expr[G])(
+ implicit val o: Origin
+) extends Expr[G] with PointsToImpl[G]
+final case class CurPerm[G](loc: Location[G])(implicit val o: Origin)
+ extends Expr[G] with CurPermImpl[G]
+
+final case class Value[G](loc: Location[G])(implicit val o: Origin)
+ extends Expr[G] with ValueImpl[G]
+final case class AutoValue[G](loc: Location[G])(implicit val o: Origin)
+ extends Expr[G] with AutoValueImpl[G]
+
+final case class ValidArray[G](arr: Expr[G], len: Expr[G])(
+ implicit val o: Origin
+) extends Expr[G] with ValidArrayImpl[G]
+final case class ValidMatrix[G](mat: Expr[G], w: Expr[G], h: Expr[G])(
+ implicit val o: Origin
+) extends Expr[G] with ValidMatrixImpl[G]
+
+final case class PermPointer[G](p: Expr[G], len: Expr[G], perm: Expr[G])(
+ implicit val o: Origin
+) extends Expr[G] with PermPointerImpl[G]
+final case class PermPointerIndex[G](p: Expr[G], idx: Expr[G], perm: Expr[G])(
+ implicit val o: Origin
+) extends Expr[G] with PermPointerIndexImpl[G]
+
+final case class ResourceOfResourceValue[G](res: Expr[G])(
+ implicit val o: Origin
+) extends Expr[G] with ResourceOfResourceValueImpl[G]
+final case class ResourceValue[G](res: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with ResourceValueImpl[G]
-final case class Eq[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends Comparison[G] with EqImpl[G]
-final case class Neq[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends Comparison[G] with NeqImpl[G]
+sealed trait Comparison[G] extends BinExpr[G] with ComparisonImpl[G]
+sealed trait AmbiguousComparison[G]
+ extends Comparison[G] with AmbiguousComparisonImpl[G]
+final case class AmbiguousEq[G](
+ left: Expr[G],
+ right: Expr[G],
+ vectorInnerType: Type[G],
+)(implicit val o: Origin)
+ extends AmbiguousComparison[G] with AmbiguousEqImpl[G]
+final case class AmbiguousNeq[G](
+ left: Expr[G],
+ right: Expr[G],
+ vectorInnerType: Type[G],
+)(implicit val o: Origin)
+ extends AmbiguousComparison[G] with AmbiguousNeqImpl[G]
+
+final case class Eq[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends Comparison[G] with EqImpl[G]
+final case class Neq[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends Comparison[G] with NeqImpl[G]
sealed trait OrderOp[G] extends Comparison[G] with OrderOpImpl[G]
sealed trait AmbiguousOrderOp[G] extends OrderOp[G] with AmbiguousOrderOpImpl[G]
-final case class AmbiguousGreater[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends AmbiguousOrderOp[G] with AmbiguousGreaterImpl[G]
-final case class AmbiguousLess[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends AmbiguousOrderOp[G] with AmbiguousLessImpl[G]
-final case class AmbiguousGreaterEq[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends AmbiguousOrderOp[G] with AmbiguousGreaterEqImpl[G]
-final case class AmbiguousLessEq[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends AmbiguousOrderOp[G] with AmbiguousLessEqImpl[G]
-
-final case class Greater[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends OrderOp[G] with GreaterImpl[G]
-final case class Less[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends OrderOp[G] with LessImpl[G]
-final case class GreaterEq[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends OrderOp[G] with GreaterEqImpl[G]
-final case class LessEq[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends OrderOp[G] with LessEqImpl[G]
+final case class AmbiguousGreater[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends AmbiguousOrderOp[G] with AmbiguousGreaterImpl[G]
+final case class AmbiguousLess[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends AmbiguousOrderOp[G] with AmbiguousLessImpl[G]
+final case class AmbiguousGreaterEq[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends AmbiguousOrderOp[G] with AmbiguousGreaterEqImpl[G]
+final case class AmbiguousLessEq[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends AmbiguousOrderOp[G] with AmbiguousLessEqImpl[G]
+
+final case class Greater[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends OrderOp[G] with GreaterImpl[G]
+final case class Less[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends OrderOp[G] with LessImpl[G]
+final case class GreaterEq[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends OrderOp[G] with GreaterEqImpl[G]
+final case class LessEq[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends OrderOp[G] with LessEqImpl[G]
sealed trait SetComparison[G] extends OrderOp[G] with SetComparisonImpl[G]
-final case class SubSet[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SetComparison[G] with SubSetImpl[G]
-final case class SubSetEq[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SetComparison[G] with SubSetEqImpl[G]
-final case class SubBag[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SetComparison[G] with SubBagImpl[G]
-final case class SubBagEq[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SetComparison[G] with SubBagEqImpl[G]
-
-final case class Select[G](condition: Expr[G], whenTrue: Expr[G], whenFalse: Expr[G])(implicit val o: Origin) extends Expr[G] with SelectImpl[G]
-final case class NewObject[G](cls: Ref[G, Class[G]])(implicit val o: Origin) extends Expr[G] with NewObjectImpl[G]
-final case class NewArray[G](element: Type[G], dims: Seq[Expr[G]], moreDims: Int, initialize: Boolean)(val blame: Blame[ArraySizeError])(implicit val o: Origin) extends Expr[G] with NewArrayImpl[G]
-final case class NewPointerArray[G](element: Type[G], size: Expr[G])(val blame: Blame[ArraySizeError])(implicit val o: Origin) extends Expr[G] with NewPointerArrayImpl[G]
-final case class FreePointer[G](pointer: Expr[G])(val blame: Blame[PointerFreeError])(implicit val o: Origin) extends Expr[G] with FreePointerImpl[G]
-final case class Old[G](expr: Expr[G], at: Option[Ref[G, LabelDecl[G]]])(val blame: Blame[LabelNotReached])(implicit val o: Origin) extends Expr[G] with OldImpl[G]
-final case class AmbiguousSubscript[G](collection: Expr[G], index: Expr[G])(val blame: Blame[FrontendSubscriptError])(implicit val o: Origin) extends Expr[G] with AmbiguousSubscriptImpl[G]
-final case class SeqSubscript[G](seq: Expr[G], index: Expr[G])(val blame: Blame[SeqBoundFailure])(implicit val o: Origin) extends Expr[G] with SeqSubscriptImpl[G]
-final case class VectorSubscript[G](seq: Expr[G], index: Expr[G])(val blame: Blame[VectorBoundFailure])(implicit val o: Origin) extends Expr[G] with VectorSubscriptImpl[G]
-final case class ArraySubscript[G](arr: Expr[G], index: Expr[G])(val blame: Blame[ArraySubscriptError])(implicit val o: Origin) extends Expr[G] with ArraySubscriptImpl[G]
-final case class PointerSubscript[G](pointer: Expr[G], index: Expr[G])(val blame: Blame[PointerSubscriptError])(implicit val o: Origin) extends Expr[G] with PointerSubscriptImpl[G]
-final case class Length[G](arr: Expr[G])(val blame: Blame[ArrayNull])(implicit val o: Origin) extends Expr[G] with LengthImpl[G]
-final case class Size[G](obj: Expr[G])(implicit val o: Origin) extends Expr[G] with SizeImpl[G]
-final case class PointerBlockLength[G](pointer: Expr[G])(val blame: Blame[PointerNull])(implicit val o: Origin) extends Expr[G] with PointerBlockLengthImpl[G]
-final case class PointerBlockOffset[G](pointer: Expr[G])(val blame: Blame[PointerNull])(implicit val o: Origin) extends Expr[G] with PointerBlockOffsetImpl[G]
-final case class PointerLength[G](pointer: Expr[G])(val blame: Blame[PointerNull])(implicit val o: Origin) extends Expr[G] with PointerLengthImpl[G]
-final case class SharedMemSize[G](pointer: Expr[G])(implicit val o: Origin) extends Expr[G] with SharedMemSizeImpl[G]
-final case class NdIndex[G](indices: Seq[Expr[G]], dimensions: Seq[Expr[G]])(implicit val o: Origin) extends Expr[G] with NdIndexImpl[G]
-final case class NdPartialIndex[G](indices: Seq[Expr[G]], linearIndex: Expr[G], dimensions: Seq[Expr[G]])(implicit val o: Origin) extends Expr[G] with NdPartialIndexImpl[G]
-final case class NdLength[G](dimensions: Seq[Expr[G]])(implicit val o: Origin) extends Expr[G] with NdLengthImpl[G]
-
-final case class Cons[G](x: Expr[G], xs: Expr[G])(implicit val o: Origin) extends Expr[G] with ConsImpl[G]
-final case class Head[G](xs: Expr[G])(val blame: Blame[SeqBoundFailure])(implicit val o: Origin) extends Expr[G] with HeadImpl[G]
-final case class Tail[G](xs: Expr[G])(implicit val o: Origin) extends Expr[G] with TailImpl[G]
-final case class Drop[G](xs: Expr[G], count: Expr[G])(implicit val o: Origin) extends Expr[G] with DropImpl[G]
-final case class Take[G](xs: Expr[G], count: Expr[G])(implicit val o: Origin) extends Expr[G] with TakeImpl[G]
-final case class Slice[G](xs: Expr[G], from: Expr[G], to: Expr[G])(implicit val o: Origin) extends Expr[G] with SliceImpl[G]
-final case class SeqUpdate[G](xs: Expr[G], i: Expr[G], x: Expr[G])(implicit val o: Origin) extends Expr[G] with SeqUpdateImpl[G]
-final case class Concat[G](xs: Expr[G], ys: Expr[G])(implicit val o: Origin) extends Expr[G] with ConcatImpl[G]
-final case class RemoveAt[G](xs: Expr[G], i: Expr[G])(implicit val o: Origin) extends Expr[G] with RemoveAtImpl[G]
-final case class Empty[G](obj: Expr[G])(implicit val o: Origin) extends Expr[G] with EmptyImpl[G]
-
-final case class SetIntersection[G](xs: Expr[G], ys: Expr[G])(implicit val o: Origin) extends Expr[G] with SetIntersectionImpl[G]
-final case class BagLargestCommon[G](xs: Expr[G], ys: Expr[G])(implicit val o: Origin) extends Expr[G] with BagLargestCommonImpl[G]
-final case class SetMinus[G](xs: Expr[G], ys: Expr[G])(implicit val o: Origin) extends Expr[G] with SetMinusImpl[G]
-final case class BagMinus[G](xs: Expr[G], ys: Expr[G])(implicit val o: Origin) extends Expr[G] with BagMinusImpl[G]
-final case class SetUnion[G](xs: Expr[G], ys: Expr[G])(implicit val o: Origin) extends Expr[G] with SetUnionImpl[G]
-final case class BagAdd[G](xs: Expr[G], ys: Expr[G])(implicit val o: Origin) extends Expr[G] with BagAddImpl[G]
-final case class Choose[G](xs: Expr[G])(val blame: Blame[SetEmpty])(implicit val o: Origin) extends Expr[G] with ChooseImpl[G]
-final case class ChooseFresh[G](xs: Expr[G])(val blame: Blame[SetEmpty])(implicit val o: Origin) extends Expr[G] with ChooseFreshImpl[G]
-
-final case class AmbiguousMember[G](x: Expr[G], xs: Expr[G])(implicit val o: Origin) extends Expr[G] with AmbiguousMemberImpl[G]
-final case class SetMember[G](x: Expr[G], xs: Expr[G])(implicit val o: Origin) extends Expr[G] with SetMemberImpl[G]
-final case class SeqMember[G](x: Expr[G], xs: Expr[G])(implicit val o: Origin) extends Expr[G] with SeqMemberImpl[G]
-final case class MapMember[G](x: Expr[G], xs: Expr[G])(implicit val o: Origin) extends Expr[G] with MapMemberImpl[G]
-final case class BagMemberCount[G](x: Expr[G], xs: Expr[G])(implicit val o: Origin) extends Expr[G] with BagMemberCountImpl[G]
-
-final case class Permutation[G](xs: Expr[G], ys: Expr[G])(implicit val o: Origin) extends Expr[G] with PermutationImpl[G]
-final case class OptEmpty[G](opt: Expr[G])(implicit val o: Origin) extends Expr[G] with OptEmptyImpl[G]
-final case class OptGet[G](opt: Expr[G])(val blame: Blame[OptionNone])(implicit val o: Origin) extends Expr[G] with OptGetImpl[G]
-final case class OptGetOrElse[G](opt: Expr[G], alt: Expr[G])(implicit val o: Origin) extends Expr[G] with OptGetOrElseImpl[G]
-final case class MapGet[G](map: Expr[G], k: Expr[G])(val blame: Blame[MapKeyError])(implicit val o: Origin) extends Expr[G] with MapGetImpl[G]
-final case class TupGet[G](tup: Expr[G], index: Int)(implicit val o: Origin) extends Expr[G] with TupGetImpl[G]
+final case class SubSet[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends SetComparison[G] with SubSetImpl[G]
+final case class SubSetEq[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends SetComparison[G] with SubSetEqImpl[G]
+final case class SubBag[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends SetComparison[G] with SubBagImpl[G]
+final case class SubBagEq[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends SetComparison[G] with SubBagEqImpl[G]
+
+final case class Select[G](
+ condition: Expr[G],
+ whenTrue: Expr[G],
+ whenFalse: Expr[G],
+)(implicit val o: Origin)
+ extends Expr[G] with SelectImpl[G]
+final case class NewObject[G](cls: Ref[G, Class[G]])(implicit val o: Origin)
+ extends Expr[G] with NewObjectImpl[G]
+final case class NewArray[G](
+ element: Type[G],
+ dims: Seq[Expr[G]],
+ moreDims: Int,
+ initialize: Boolean,
+)(val blame: Blame[ArraySizeError])(implicit val o: Origin)
+ extends Expr[G] with NewArrayImpl[G]
+final case class NewPointerArray[G](element: Type[G], size: Expr[G])(
+ val blame: Blame[ArraySizeError]
+)(implicit val o: Origin)
+ extends Expr[G] with NewPointerArrayImpl[G]
+final case class FreePointer[G](pointer: Expr[G])(
+ val blame: Blame[PointerFreeError]
+)(implicit val o: Origin)
+ extends Expr[G] with FreePointerImpl[G]
+final case class Old[G](expr: Expr[G], at: Option[Ref[G, LabelDecl[G]]])(
+ val blame: Blame[LabelNotReached]
+)(implicit val o: Origin)
+ extends Expr[G] with OldImpl[G]
+final case class AmbiguousSubscript[G](collection: Expr[G], index: Expr[G])(
+ val blame: Blame[FrontendSubscriptError]
+)(implicit val o: Origin)
+ extends Expr[G] with AmbiguousSubscriptImpl[G]
+final case class SeqSubscript[G](seq: Expr[G], index: Expr[G])(
+ val blame: Blame[SeqBoundFailure]
+)(implicit val o: Origin)
+ extends Expr[G] with SeqSubscriptImpl[G]
+final case class VectorSubscript[G](seq: Expr[G], index: Expr[G])(
+ val blame: Blame[VectorBoundFailure]
+)(implicit val o: Origin)
+ extends Expr[G] with VectorSubscriptImpl[G]
+final case class ArraySubscript[G](arr: Expr[G], index: Expr[G])(
+ val blame: Blame[ArraySubscriptError]
+)(implicit val o: Origin)
+ extends Expr[G] with ArraySubscriptImpl[G]
+final case class PointerSubscript[G](pointer: Expr[G], index: Expr[G])(
+ val blame: Blame[PointerSubscriptError]
+)(implicit val o: Origin)
+ extends Expr[G] with PointerSubscriptImpl[G]
+final case class Length[G](arr: Expr[G])(val blame: Blame[ArrayNull])(
+ implicit val o: Origin
+) extends Expr[G] with LengthImpl[G]
+final case class Size[G](obj: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with SizeImpl[G]
+final case class PointerBlockLength[G](pointer: Expr[G])(
+ val blame: Blame[PointerNull]
+)(implicit val o: Origin)
+ extends Expr[G] with PointerBlockLengthImpl[G]
+final case class PointerBlockOffset[G](pointer: Expr[G])(
+ val blame: Blame[PointerNull]
+)(implicit val o: Origin)
+ extends Expr[G] with PointerBlockOffsetImpl[G]
+final case class PointerLength[G](pointer: Expr[G])(
+ val blame: Blame[PointerNull]
+)(implicit val o: Origin)
+ extends Expr[G] with PointerLengthImpl[G]
+final case class SharedMemSize[G](pointer: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with SharedMemSizeImpl[G]
+final case class NdIndex[G](indices: Seq[Expr[G]], dimensions: Seq[Expr[G]])(
+ implicit val o: Origin
+) extends Expr[G] with NdIndexImpl[G]
+final case class NdPartialIndex[G](
+ indices: Seq[Expr[G]],
+ linearIndex: Expr[G],
+ dimensions: Seq[Expr[G]],
+)(implicit val o: Origin)
+ extends Expr[G] with NdPartialIndexImpl[G]
+final case class NdLength[G](dimensions: Seq[Expr[G]])(implicit val o: Origin)
+ extends Expr[G] with NdLengthImpl[G]
+
+final case class Cons[G](x: Expr[G], xs: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with ConsImpl[G]
+final case class Head[G](xs: Expr[G])(val blame: Blame[SeqBoundFailure])(
+ implicit val o: Origin
+) extends Expr[G] with HeadImpl[G]
+final case class Tail[G](xs: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with TailImpl[G]
+final case class Drop[G](xs: Expr[G], count: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with DropImpl[G]
+final case class Take[G](xs: Expr[G], count: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with TakeImpl[G]
+final case class Slice[G](xs: Expr[G], from: Expr[G], to: Expr[G])(
+ implicit val o: Origin
+) extends Expr[G] with SliceImpl[G]
+final case class SeqUpdate[G](xs: Expr[G], i: Expr[G], x: Expr[G])(
+ implicit val o: Origin
+) extends Expr[G] with SeqUpdateImpl[G]
+final case class Concat[G](xs: Expr[G], ys: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with ConcatImpl[G]
+final case class RemoveAt[G](xs: Expr[G], i: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with RemoveAtImpl[G]
+final case class Empty[G](obj: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with EmptyImpl[G]
+
+final case class SetIntersection[G](xs: Expr[G], ys: Expr[G])(
+ implicit val o: Origin
+) extends Expr[G] with SetIntersectionImpl[G]
+final case class BagLargestCommon[G](xs: Expr[G], ys: Expr[G])(
+ implicit val o: Origin
+) extends Expr[G] with BagLargestCommonImpl[G]
+final case class SetMinus[G](xs: Expr[G], ys: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with SetMinusImpl[G]
+final case class BagMinus[G](xs: Expr[G], ys: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with BagMinusImpl[G]
+final case class SetUnion[G](xs: Expr[G], ys: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with SetUnionImpl[G]
+final case class BagAdd[G](xs: Expr[G], ys: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with BagAddImpl[G]
+final case class Choose[G](xs: Expr[G])(val blame: Blame[SetEmpty])(
+ implicit val o: Origin
+) extends Expr[G] with ChooseImpl[G]
+final case class ChooseFresh[G](xs: Expr[G])(val blame: Blame[SetEmpty])(
+ implicit val o: Origin
+) extends Expr[G] with ChooseFreshImpl[G]
+
+final case class AmbiguousMember[G](x: Expr[G], xs: Expr[G])(
+ implicit val o: Origin
+) extends Expr[G] with AmbiguousMemberImpl[G]
+final case class SetMember[G](x: Expr[G], xs: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with SetMemberImpl[G]
+final case class SeqMember[G](x: Expr[G], xs: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with SeqMemberImpl[G]
+final case class MapMember[G](x: Expr[G], xs: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with MapMemberImpl[G]
+final case class BagMemberCount[G](x: Expr[G], xs: Expr[G])(
+ implicit val o: Origin
+) extends Expr[G] with BagMemberCountImpl[G]
+
+final case class Permutation[G](xs: Expr[G], ys: Expr[G])(
+ implicit val o: Origin
+) extends Expr[G] with PermutationImpl[G]
+final case class OptEmpty[G](opt: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with OptEmptyImpl[G]
+final case class OptGet[G](opt: Expr[G])(val blame: Blame[OptionNone])(
+ implicit val o: Origin
+) extends Expr[G] with OptGetImpl[G]
+final case class OptGetOrElse[G](opt: Expr[G], alt: Expr[G])(
+ implicit val o: Origin
+) extends Expr[G] with OptGetOrElseImpl[G]
+final case class MapGet[G](map: Expr[G], k: Expr[G])(
+ val blame: Blame[MapKeyError]
+)(implicit val o: Origin)
+ extends Expr[G] with MapGetImpl[G]
+final case class TupGet[G](tup: Expr[G], index: Int)(implicit val o: Origin)
+ extends Expr[G] with TupGetImpl[G]
sealed trait EitherOp[G] extends Expr[G] with EitherOpImpl[G]
-final case class GetLeft[G](either: Expr[G])(val blame: Blame[NotLeft])(implicit val o: Origin) extends EitherOp[G] with GetLeftImpl[G]
-final case class GetRight[G](either: Expr[G])(val blame: Blame[NotRight])(implicit val o: Origin) extends EitherOp[G] with GetRightImpl[G]
-final case class IsLeft[G](either: Expr[G])(implicit val o: Origin) extends EitherOp[G] with Expr[G] with IsLeftImpl[G]
-final case class IsRight[G](either: Expr[G])(implicit val o: Origin) extends EitherOp[G] with Expr[G] with IsRightImpl[G]
-
-final case class VectorSum[G](indices: Expr[G], vec: Expr[G])(implicit val o: Origin) extends Expr[G] with VectorSumImpl[G]
-final case class VectorCompare[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends BinExpr[G] with VectorCompareImpl[G]
-final case class VectorRepeat[G](e: Expr[G])(implicit val o: Origin) extends Expr[G] with VectorRepeatImpl[G]
-final case class MatrixSum[G](indices: Expr[G], mat: Expr[G])(implicit val o: Origin) extends Expr[G] with MatrixSumImpl[G]
-final case class MatrixCompare[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends BinExpr[G] with MatrixCompareImpl[G]
-final case class MatrixRepeat[G](e: Expr[G])(implicit val o: Origin) extends Expr[G] with MatrixRepeatImpl[G]
-
-final case class CastFloat[G](e: Expr[G], t: Type[G] /* TFloat or TInt */)(implicit val o: Origin) extends Expr[G] with CastFloatImpl[G]
-
-final case class TypeValue[G](value: Type[G])(implicit val o: Origin) extends Expr[G] with TypeValueImpl[G]
-final case class TypeOf[G](expr: Expr[G])(implicit val o: Origin) extends Expr[G] with TypeOfImpl[G]
-final case class InstanceOf[G](value: Expr[G], typeValue: Expr[G])(implicit val o: Origin) extends Expr[G] with InstanceOfImpl[G]
-final case class Cast[G](value: Expr[G], typeValue: Expr[G])(implicit val o: Origin) extends Expr[G] with CastImpl[G]
+final case class GetLeft[G](either: Expr[G])(val blame: Blame[NotLeft])(
+ implicit val o: Origin
+) extends EitherOp[G] with GetLeftImpl[G]
+final case class GetRight[G](either: Expr[G])(val blame: Blame[NotRight])(
+ implicit val o: Origin
+) extends EitherOp[G] with GetRightImpl[G]
+final case class IsLeft[G](either: Expr[G])(implicit val o: Origin)
+ extends EitherOp[G] with Expr[G] with IsLeftImpl[G]
+final case class IsRight[G](either: Expr[G])(implicit val o: Origin)
+ extends EitherOp[G] with Expr[G] with IsRightImpl[G]
+
+final case class VectorSum[G](indices: Expr[G], vec: Expr[G])(
+ implicit val o: Origin
+) extends Expr[G] with VectorSumImpl[G]
+final case class VectorCompare[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends BinExpr[G] with VectorCompareImpl[G]
+final case class VectorRepeat[G](e: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with VectorRepeatImpl[G]
+final case class MatrixSum[G](indices: Expr[G], mat: Expr[G])(
+ implicit val o: Origin
+) extends Expr[G] with MatrixSumImpl[G]
+final case class MatrixCompare[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends BinExpr[G] with MatrixCompareImpl[G]
+final case class MatrixRepeat[G](e: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with MatrixRepeatImpl[G]
+
+final case class CastFloat[G](e: Expr[G], t: Type[G] /* TFloat or TInt */ )(
+ implicit val o: Origin
+) extends Expr[G] with CastFloatImpl[G]
+
+final case class TypeValue[G](value: Type[G])(implicit val o: Origin)
+ extends Expr[G] with TypeValueImpl[G]
+final case class TypeOf[G](expr: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with TypeOfImpl[G]
+final case class InstanceOf[G](value: Expr[G], typeValue: Expr[G])(
+ implicit val o: Origin
+) extends Expr[G] with InstanceOfImpl[G]
+final case class Cast[G](value: Expr[G], typeValue: Expr[G])(
+ implicit val o: Origin
+) extends Expr[G] with CastImpl[G]
sealed trait TypeComparison[G] extends Comparison[G] with TypeComparisonImpl[G]
-final case class SubType[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends TypeComparison[G] with SubTypeImpl[G]
-final case class SuperType[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends TypeComparison[G] with SuperTypeImpl[G]
+final case class SubType[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends TypeComparison[G] with SubTypeImpl[G]
+final case class SuperType[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends TypeComparison[G] with SuperTypeImpl[G]
sealed trait AssignExpression[G] extends Expr[G] with AssignExpressionImpl[G]
-final case class PreAssignExpression[G](target: Expr[G], value: Expr[G])(val blame: Blame[AssignFailed])(implicit val o: Origin) extends AssignExpression[G] with PreAssignExpressionImpl[G]
-final case class PostAssignExpression[G](target: Expr[G], value: Expr[G])(val blame: Blame[AssignFailed])(implicit val o: Origin) extends AssignExpression[G] with PostAssignExpressionImpl[G]
-
-final case class With[G](pre: Statement[G], value: Expr[G])(implicit val o: Origin) extends Expr[G] with WithImpl[G]
-final case class Then[G](value: Expr[G], post: Statement[G])(implicit val o: Origin) extends Expr[G] with ThenImpl[G]
-
-final case class Held[G](obj: Expr[G])(implicit val o: Origin) extends Expr[G] with HeldImpl[G]
-final case class Committed[G](obj: Expr[G])(val blame: Blame[LockObjectNull])(implicit val o: Origin) extends Expr[G] with CommittedImpl[G]
-final case class IdleToken[G](thread: Expr[G])(implicit val o: Origin) extends Expr[G] with IdleTokenImpl[G]
-final case class JoinToken[G](thread: Expr[G])(implicit val o: Origin) extends Expr[G] with JoinTokenImpl[G]
-
-final case class EmptyProcess[G]()(implicit val o: Origin) extends Expr[G] with EmptyProcessImpl[G]
-final case class ActionApply[G](action: Ref[G, ModelAction[G]], args: Seq[Expr[G]])(implicit val o: Origin) extends Expr[G] with ActionApplyImpl[G]
-final case class ProcessApply[G](process: Ref[G, ModelProcess[G]], args: Seq[Expr[G]])(implicit val o: Origin) extends Expr[G] with ProcessApplyImpl[G]
-final case class ProcessSeq[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends Expr[G] with ProcessSeqImpl[G]
-final case class ProcessChoice[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends Expr[G] with ProcessChoiceImpl[G]
-final case class ProcessPar[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends Expr[G] with ProcessParImpl[G]
-final case class ProcessSelect[G](cond: Expr[G], whenTrue: Expr[G], whenFalse: Expr[G])(implicit val o: Origin) extends Expr[G] with ProcessSelectImpl[G]
-
-final case class ModelNew[G](ref: Ref[G, Model[G]])(implicit val o: Origin) extends Expr[G] with ModelNewImpl[G]
-
-final case class ModelState[G](model: Expr[G], perm: Expr[G], state: Expr[G])(implicit val o: Origin) extends Expr[G] with ModelStateImpl[G]
-final case class ModelAbstractState[G](model: Expr[G], state: Expr[G])(implicit val o: Origin) extends Expr[G] with ModelAbstractStateImpl[G]
-final case class ModelCreate[G](model: Expr[G], init: Expr[G])(implicit val o: Origin) extends Expr[G] with ModelCreateImpl[G]
-final case class ModelDestroy[G](model: Expr[G])(implicit val o: Origin) extends Expr[G] with ModelDestroyImpl[G]
-final case class ModelSplit[G](model: Expr[G], leftPerm: Expr[G], leftProcess: Expr[G], rightPerm: Expr[G], rightProcess: Expr[G])(implicit val o: Origin) extends Expr[G] with ModelSplitImpl[G]
-final case class ModelMerge[G](model: Expr[G], leftPerm: Expr[G], leftProcess: Expr[G], rightPerm: Expr[G], rightProcess: Expr[G])(implicit val o: Origin) extends Expr[G] with ModelMergeImpl[G]
-final case class ModelChoose[G](model: Expr[G], perm: Expr[G], totalProcess: Expr[G], choice: Expr[G])(implicit val o: Origin) extends Expr[G] with ModelChooseImpl[G]
-
-final case class ModelPerm[G](loc: Expr[G], perm: Expr[G])(implicit val o: Origin) extends Expr[G] with ModelPermImpl[G]
-final case class ActionPerm[G](loc: Expr[G], perm: Expr[G])(implicit val o: Origin) extends Expr[G] with ActionPermImpl[G]
+final case class PreAssignExpression[G](target: Expr[G], value: Expr[G])(
+ val blame: Blame[AssignFailed]
+)(implicit val o: Origin)
+ extends AssignExpression[G] with PreAssignExpressionImpl[G]
+final case class PostAssignExpression[G](target: Expr[G], value: Expr[G])(
+ val blame: Blame[AssignFailed]
+)(implicit val o: Origin)
+ extends AssignExpression[G] with PostAssignExpressionImpl[G]
+
+final case class With[G](pre: Statement[G], value: Expr[G])(
+ implicit val o: Origin
+) extends Expr[G] with WithImpl[G]
+final case class Then[G](value: Expr[G], post: Statement[G])(
+ implicit val o: Origin
+) extends Expr[G] with ThenImpl[G]
+
+final case class Held[G](obj: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with HeldImpl[G]
+final case class Committed[G](obj: Expr[G])(val blame: Blame[LockObjectNull])(
+ implicit val o: Origin
+) extends Expr[G] with CommittedImpl[G]
+final case class IdleToken[G](thread: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with IdleTokenImpl[G]
+final case class JoinToken[G](thread: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with JoinTokenImpl[G]
+
+final case class EmptyProcess[G]()(implicit val o: Origin)
+ extends Expr[G] with EmptyProcessImpl[G]
+final case class ActionApply[G](
+ action: Ref[G, ModelAction[G]],
+ args: Seq[Expr[G]],
+)(implicit val o: Origin)
+ extends Expr[G] with ActionApplyImpl[G]
+final case class ProcessApply[G](
+ process: Ref[G, ModelProcess[G]],
+ args: Seq[Expr[G]],
+)(implicit val o: Origin)
+ extends Expr[G] with ProcessApplyImpl[G]
+final case class ProcessSeq[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends Expr[G] with ProcessSeqImpl[G]
+final case class ProcessChoice[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends Expr[G] with ProcessChoiceImpl[G]
+final case class ProcessPar[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends Expr[G] with ProcessParImpl[G]
+final case class ProcessSelect[G](
+ cond: Expr[G],
+ whenTrue: Expr[G],
+ whenFalse: Expr[G],
+)(implicit val o: Origin)
+ extends Expr[G] with ProcessSelectImpl[G]
+
+final case class ModelNew[G](ref: Ref[G, Model[G]])(implicit val o: Origin)
+ extends Expr[G] with ModelNewImpl[G]
+
+final case class ModelState[G](model: Expr[G], perm: Expr[G], state: Expr[G])(
+ implicit val o: Origin
+) extends Expr[G] with ModelStateImpl[G]
+final case class ModelAbstractState[G](model: Expr[G], state: Expr[G])(
+ implicit val o: Origin
+) extends Expr[G] with ModelAbstractStateImpl[G]
+final case class ModelCreate[G](model: Expr[G], init: Expr[G])(
+ implicit val o: Origin
+) extends Expr[G] with ModelCreateImpl[G]
+final case class ModelDestroy[G](model: Expr[G])(implicit val o: Origin)
+ extends Expr[G] with ModelDestroyImpl[G]
+final case class ModelSplit[G](
+ model: Expr[G],
+ leftPerm: Expr[G],
+ leftProcess: Expr[G],
+ rightPerm: Expr[G],
+ rightProcess: Expr[G],
+)(implicit val o: Origin)
+ extends Expr[G] with ModelSplitImpl[G]
+final case class ModelMerge[G](
+ model: Expr[G],
+ leftPerm: Expr[G],
+ leftProcess: Expr[G],
+ rightPerm: Expr[G],
+ rightProcess: Expr[G],
+)(implicit val o: Origin)
+ extends Expr[G] with ModelMergeImpl[G]
+final case class ModelChoose[G](
+ model: Expr[G],
+ perm: Expr[G],
+ totalProcess: Expr[G],
+ choice: Expr[G],
+)(implicit val o: Origin)
+ extends Expr[G] with ModelChooseImpl[G]
+
+final case class ModelPerm[G](loc: Expr[G], perm: Expr[G])(
+ implicit val o: Origin
+) extends Expr[G] with ModelPermImpl[G]
+final case class ActionPerm[G](loc: Expr[G], perm: Expr[G])(
+ implicit val o: Origin
+) extends Expr[G] with ActionPermImpl[G]
sealed trait SmtlibType[G] extends Type[G]
-case class TSmtlibArray[G](index: Seq[Type[G]], value: Type[G])(implicit val o: Origin = DiagnosticOrigin) extends SmtlibType[G] with TSmtlibArrayImpl[G]
-case class TSmtlibBitVector[G](size: Int)(implicit val o: Origin = DiagnosticOrigin) extends SmtlibType[G] with TSmtlibBitVectorImpl[G]
-case class TSmtlibRoundingMode[G]()(implicit val o: Origin = DiagnosticOrigin) extends SmtlibType[G] with TSmtlibRoundingModeImpl[G]
-case class TSmtlibFloatingPoint[G](exponentBits: Int, mantissaAndSignBits: Int)(implicit val o: Origin = DiagnosticOrigin) extends SmtlibType[G] with TSmtlibFloatingPointImpl[G]
-case class TSmtlibString[G]()(implicit val o: Origin = DiagnosticOrigin) extends SmtlibType[G] with TSmtlibStringImpl[G]
-case class TSmtlibRegLan[G]()(implicit val o: Origin = DiagnosticOrigin) extends SmtlibType[G] with TSmtlibRegLanImpl[G]
+case class TSmtlibArray[G](index: Seq[Type[G]], value: Type[G])(
+ implicit val o: Origin = DiagnosticOrigin
+) extends SmtlibType[G] with TSmtlibArrayImpl[G]
+case class TSmtlibBitVector[G](size: Int)(
+ implicit val o: Origin = DiagnosticOrigin
+) extends SmtlibType[G] with TSmtlibBitVectorImpl[G]
+case class TSmtlibRoundingMode[G]()(implicit val o: Origin = DiagnosticOrigin)
+ extends SmtlibType[G] with TSmtlibRoundingModeImpl[G]
+case class TSmtlibFloatingPoint[G](exponentBits: Int, mantissaAndSignBits: Int)(
+ implicit val o: Origin = DiagnosticOrigin
+) extends SmtlibType[G] with TSmtlibFloatingPointImpl[G]
+case class TSmtlibString[G]()(implicit val o: Origin = DiagnosticOrigin)
+ extends SmtlibType[G] with TSmtlibStringImpl[G]
+case class TSmtlibRegLan[G]()(implicit val o: Origin = DiagnosticOrigin)
+ extends SmtlibType[G] with TSmtlibRegLanImpl[G]
// Non-standard Z3 extensions
-case class TSmtlibSeq[G](element: Type[G])(implicit val o: Origin = DiagnosticOrigin) extends SmtlibType[G] with TSmtlibSeqImpl[G]
+case class TSmtlibSeq[G](element: Type[G])(
+ implicit val o: Origin = DiagnosticOrigin
+) extends SmtlibType[G] with TSmtlibSeqImpl[G]
-@family sealed trait SmtlibFunctionSymbol[G] extends NodeFamily[G] with SmtlibFunctionSymbolImpl[G]
-case class SmtlibADTFunctionSymbol[G](ref: Ref[G, ADTFunction[G]])(implicit val o: Origin) extends SmtlibFunctionSymbol[G] with SmtlibADTFunctionSymbolImpl[G]
-case class SmtlibProverFunctionSymbol[G](ref: Ref[G, ProverFunction[G]])(implicit val o: Origin) extends SmtlibFunctionSymbol[G] with SmtlibProverFunctionSymbolImpl[G]
+@family
+sealed trait SmtlibFunctionSymbol[G]
+ extends NodeFamily[G] with SmtlibFunctionSymbolImpl[G]
+case class SmtlibADTFunctionSymbol[G](ref: Ref[G, ADTFunction[G]])(
+ implicit val o: Origin
+) extends SmtlibFunctionSymbol[G] with SmtlibADTFunctionSymbolImpl[G]
+case class SmtlibProverFunctionSymbol[G](ref: Ref[G, ProverFunction[G]])(
+ implicit val o: Origin
+) extends SmtlibFunctionSymbol[G] with SmtlibProverFunctionSymbolImpl[G]
sealed trait SmtlibExpr[G] extends Expr[G]
-case class SmtlibSelect[G](arr: Expr[G], is: Seq[Expr[G]])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibSelectImpl[G]
-case class SmtlibStore[G](arr: Expr[G], is: Seq[Expr[G]], x: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibStoreImpl[G]
-
-case class SmtlibBitvecLiteral[G](data: BitString)(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibBitvecLiteralImpl[G]
-case class SmtlibConcat[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibConcatImpl[G]
-case class SmtlibExtract[G](inclusiveEndIndexFromRight: Int, startIndexFromRight: Int, bv: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibExtractImpl[G]
-case class SmtlibBvNot[G](bv: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibBvNotImpl[G]
-case class SmtlibBvAnd[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibBvAndImpl[G]
-case class SmtlibBvOr[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibBvOrImpl[G]
-case class SmtlibBvNeg[G](bv: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibBvNegImpl[G]
-case class SmtlibBvAdd[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibBvAddImpl[G]
-case class SmtlibBvMul[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibBvMulImpl[G]
-case class SmtlibBvUDiv[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibBvUDivImpl[G]
-case class SmtlibBvURem[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibBvURemImpl[G]
-case class SmtlibBvShl[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibBvShlImpl[G]
-case class SmtlibBvShr[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibBvShrImpl[G]
-case class SmtlibBvULt[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibBvULtImpl[G]
-
-case class SmtlibRNE[G]()(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibRNEImpl[G]
-case class SmtlibRNA[G]()(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibRNAImpl[G]
-case class SmtlibRTP[G]()(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibRTPImpl[G]
-case class SmtlibRTN[G]()(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibRTNImpl[G]
-case class SmtlibRTZ[G]()(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibRTZImpl[G]
-
-case class SmtlibFp[G](sign: Expr[G], exponent: Expr[G], mantissa: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibFpImpl[G]
-case class SmtlibFpAbs[G](arg: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibFpAbsImpl[G]
-case class SmtlibFpNeg[G](arg: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibFpNegImpl[G]
-case class SmtlibFpAdd[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibFpAddImpl[G]
-case class SmtlibFpSub[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibFpSubImpl[G]
-case class SmtlibFpMul[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibFpMulImpl[G]
-case class SmtlibFpDiv[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibFpDivImpl[G]
-case class SmtlibFpFma[G](left: Expr[G], right: Expr[G], addend: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibFpFmaImpl[G]
-case class SmtlibFpSqrt[G](arg: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibFpSqrtImpl[G]
-case class SmtlibFpRem[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibFpRemImpl[G]
-case class SmtlibFpRoundToIntegral[G](arg: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibFpRoundToIntegralImpl[G]
-case class SmtlibFpMin[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibFpMinImpl[G]
-case class SmtlibFpMax[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibFpMaxImpl[G]
-case class SmtlibFpLeq[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibFpLeqImpl[G]
-case class SmtlibFpLt[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibFpLtImpl[G]
-case class SmtlibFpGeq[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibFpGeqImpl[G]
-case class SmtlibFpGt[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibFpGtImpl[G]
-case class SmtlibFpEq[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibFpEqImpl[G]
-case class SmtlibFpIsNormal[G](arg: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibFpIsNormalImpl[G]
-case class SmtlibFpIsSubnormal[G](arg: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibFpIsSubnormalImpl[G]
-case class SmtlibFpIsZero[G](arg: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibFpIsZeroImpl[G]
-case class SmtlibFpIsInfinite[G](arg: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibFpIsInfiniteImpl[G]
-case class SmtlibFpIsNaN[G](arg: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibFpIsNaNImpl[G]
-case class SmtlibFpIsNegative[G](arg: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibFpIsNegativeImpl[G]
-case class SmtlibFpIsPositive[G](arg: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibFpIsPositiveImpl[G]
-case class SmtlibToFp[G](bv: Expr[G], exponentBits: Int, mantissaAndSignBits: Int)(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibToFpImpl[G]
-case class SmtlibFpCast[G](arg: Expr[G], exponentBits: Int, mantissaAndSignBits: Int)(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibFpCastImpl[G]
-case class SmtlibFpFromReal[G](arg: Expr[G], exponentBits: Int, mantissaAndSignBits: Int)(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibFpFromRealImpl[G]
-case class SmtlibFpFromSInt[G](bv: Expr[G], exponentBits: Int, mantissaAndSignBits: Int)(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibFpFromSIntImpl[G]
-case class SmtlibFpFromUInt[G](bv: Expr[G], exponentBits: Int, mantissaAndSignBits: Int)(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibFpFromUIntImpl[G]
-case class SmtlibFpToReal[G](arg: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibFpToRealImpl[G]
-case class SmtlibFpToSInt[G](arg: Expr[G], bits: Int)(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibFpToSIntImpl[G]
-case class SmtlibFpToUInt[G](arg: Expr[G], bits: Int)(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibFpToUIntImpl[G]
-
-case class SmtlibIsInt[G](arg: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibIsIntImpl[G]
-case class SmtlibToInt[G](arg: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibToIntImpl[G]
-case class SmtlibToReal[G](arg: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibToRealImpl[G]
-case class SmtlibPow[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with BinExpr[G] with SmtlibPowImpl[G]
-
-case class SmtlibLiteralString[G](data: String)(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibLiteralStringImpl[G]
-case class SmtlibStrConcat[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibStrConcatImpl[G]
-case class SmtlibStrLen[G](arg: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibStrLenImpl[G]
-case class SmtlibStrLt[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibStrLtImpl[G]
-case class SmtlibStrLeq[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibStrLeqImpl[G]
-case class SmtlibStrAt[G](str: Expr[G], i: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibStrAtImpl[G]
-case class SmtlibSubstr[G](str: Expr[G], i: Expr[G], n: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibSubstrImpl[G]
-case class SmtlibStrPrefixOf[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibStrPrefixOfImpl[G]
-case class SmtlibStrSuffixOf[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibStrSuffixOfImpl[G]
-case class SmtlibStrContains[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibStrContainsImpl[G]
-case class SmtlibStrIndexOf[G](haystack: Expr[G], needle: Expr[G], fromIndex: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibStrIndexOfImpl[G]
-case class SmtlibStrReplace[G](haystack: Expr[G], needle: Expr[G], replacement: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibStrReplaceImpl[G]
-case class SmtlibStrReplaceAll[G](haystack: Expr[G], needle: Expr[G], replacement: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibStrReplaceAllImpl[G]
-case class SmtlibStrReplaceRe[G](haystack: Expr[G], re: Expr[G], replacement: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibStrReplaceReImpl[G]
-case class SmtlibStrReplaceReAll[G](haystack: Expr[G], re: Expr[G], replacement: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibStrReplaceReAllImpl[G]
-case class SmtlibStrIsDigit[G](arg: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibStrIsDigitImpl[G]
-case class SmtlibStrToCode[G](arg: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibStrToCodeImpl[G]
-case class SmtlibStrFromCode[G](arg: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibStrFromCodeImpl[G]
-case class SmtlibStrToInt[G](arg: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibStrToIntImpl[G]
-case class SmtlibStrFromInt[G](arg: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibStrFromIntImpl[G]
-
-case class SmtlibReFromStr[G](arg: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibReFromStrImpl[G]
-case class SmtlibReContains[G](re: Expr[G], str: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibReContainsImpl[G]
-case class SmtlibReNone[G]()(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibReNoneImpl[G]
-case class SmtlibReAll[G]()(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibReAllImpl[G]
-case class SmtlibReAllChar[G]()(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibReAllCharImpl[G]
-case class SmtlibReConcat[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibReConcatImpl[G]
-case class SmtlibReUnion[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibReUnionImpl[G]
-case class SmtlibReInter[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibReInterImpl[G]
-case class SmtlibReStar[G](arg: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibReStarImpl[G]
-case class SmtlibReComp[G](arg: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibReCompImpl[G]
-case class SmtlibReDiff[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibReDiffImpl[G]
-case class SmtlibRePlus[G](arg: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibRePlusImpl[G]
-case class SmtlibReOpt[G](arg: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibReOptImpl[G]
-case class SmtlibReRange[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibReRangeImpl[G]
-case class SmtlibReRepeat[G](count: Int, arg: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibReRepeatImpl[G]
-case class SmtlibReRepeatRange[G](from: Int, to: Int, arg: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with SmtlibReRepeatRangeImpl[G]
+case class SmtlibSelect[G](arr: Expr[G], is: Seq[Expr[G]])(
+ implicit val o: Origin
+) extends SmtlibExpr[G] with SmtlibSelectImpl[G]
+case class SmtlibStore[G](arr: Expr[G], is: Seq[Expr[G]], x: Expr[G])(
+ implicit val o: Origin
+) extends SmtlibExpr[G] with SmtlibStoreImpl[G]
+
+case class SmtlibBitvecLiteral[G](data: BitString)(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibBitvecLiteralImpl[G]
+case class SmtlibConcat[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends SmtlibExpr[G] with SmtlibConcatImpl[G]
+case class SmtlibExtract[G](
+ inclusiveEndIndexFromRight: Int,
+ startIndexFromRight: Int,
+ bv: Expr[G],
+)(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibExtractImpl[G]
+case class SmtlibBvNot[G](bv: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibBvNotImpl[G]
+case class SmtlibBvAnd[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibBvAndImpl[G]
+case class SmtlibBvOr[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibBvOrImpl[G]
+case class SmtlibBvNeg[G](bv: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibBvNegImpl[G]
+case class SmtlibBvAdd[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibBvAddImpl[G]
+case class SmtlibBvMul[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibBvMulImpl[G]
+case class SmtlibBvUDiv[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends SmtlibExpr[G] with SmtlibBvUDivImpl[G]
+case class SmtlibBvURem[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends SmtlibExpr[G] with SmtlibBvURemImpl[G]
+case class SmtlibBvShl[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibBvShlImpl[G]
+case class SmtlibBvShr[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibBvShrImpl[G]
+case class SmtlibBvULt[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibBvULtImpl[G]
+
+case class SmtlibRNE[G]()(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibRNEImpl[G]
+case class SmtlibRNA[G]()(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibRNAImpl[G]
+case class SmtlibRTP[G]()(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibRTPImpl[G]
+case class SmtlibRTN[G]()(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibRTNImpl[G]
+case class SmtlibRTZ[G]()(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibRTZImpl[G]
+
+case class SmtlibFp[G](sign: Expr[G], exponent: Expr[G], mantissa: Expr[G])(
+ implicit val o: Origin
+) extends SmtlibExpr[G] with SmtlibFpImpl[G]
+case class SmtlibFpAbs[G](arg: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibFpAbsImpl[G]
+case class SmtlibFpNeg[G](arg: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibFpNegImpl[G]
+case class SmtlibFpAdd[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibFpAddImpl[G]
+case class SmtlibFpSub[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibFpSubImpl[G]
+case class SmtlibFpMul[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibFpMulImpl[G]
+case class SmtlibFpDiv[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibFpDivImpl[G]
+case class SmtlibFpFma[G](left: Expr[G], right: Expr[G], addend: Expr[G])(
+ implicit val o: Origin
+) extends SmtlibExpr[G] with SmtlibFpFmaImpl[G]
+case class SmtlibFpSqrt[G](arg: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibFpSqrtImpl[G]
+case class SmtlibFpRem[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibFpRemImpl[G]
+case class SmtlibFpRoundToIntegral[G](arg: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibFpRoundToIntegralImpl[G]
+case class SmtlibFpMin[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibFpMinImpl[G]
+case class SmtlibFpMax[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibFpMaxImpl[G]
+case class SmtlibFpLeq[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibFpLeqImpl[G]
+case class SmtlibFpLt[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibFpLtImpl[G]
+case class SmtlibFpGeq[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibFpGeqImpl[G]
+case class SmtlibFpGt[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibFpGtImpl[G]
+case class SmtlibFpEq[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibFpEqImpl[G]
+case class SmtlibFpIsNormal[G](arg: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibFpIsNormalImpl[G]
+case class SmtlibFpIsSubnormal[G](arg: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibFpIsSubnormalImpl[G]
+case class SmtlibFpIsZero[G](arg: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibFpIsZeroImpl[G]
+case class SmtlibFpIsInfinite[G](arg: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibFpIsInfiniteImpl[G]
+case class SmtlibFpIsNaN[G](arg: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibFpIsNaNImpl[G]
+case class SmtlibFpIsNegative[G](arg: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibFpIsNegativeImpl[G]
+case class SmtlibFpIsPositive[G](arg: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibFpIsPositiveImpl[G]
+case class SmtlibToFp[G](
+ bv: Expr[G],
+ exponentBits: Int,
+ mantissaAndSignBits: Int,
+)(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibToFpImpl[G]
+case class SmtlibFpCast[G](
+ arg: Expr[G],
+ exponentBits: Int,
+ mantissaAndSignBits: Int,
+)(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibFpCastImpl[G]
+case class SmtlibFpFromReal[G](
+ arg: Expr[G],
+ exponentBits: Int,
+ mantissaAndSignBits: Int,
+)(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibFpFromRealImpl[G]
+case class SmtlibFpFromSInt[G](
+ bv: Expr[G],
+ exponentBits: Int,
+ mantissaAndSignBits: Int,
+)(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibFpFromSIntImpl[G]
+case class SmtlibFpFromUInt[G](
+ bv: Expr[G],
+ exponentBits: Int,
+ mantissaAndSignBits: Int,
+)(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibFpFromUIntImpl[G]
+case class SmtlibFpToReal[G](arg: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibFpToRealImpl[G]
+case class SmtlibFpToSInt[G](arg: Expr[G], bits: Int)(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibFpToSIntImpl[G]
+case class SmtlibFpToUInt[G](arg: Expr[G], bits: Int)(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibFpToUIntImpl[G]
+
+case class SmtlibIsInt[G](arg: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibIsIntImpl[G]
+case class SmtlibToInt[G](arg: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibToIntImpl[G]
+case class SmtlibToReal[G](arg: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibToRealImpl[G]
+case class SmtlibPow[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with BinExpr[G] with SmtlibPowImpl[G]
+
+case class SmtlibLiteralString[G](data: String)(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibLiteralStringImpl[G]
+case class SmtlibStrConcat[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends SmtlibExpr[G] with SmtlibStrConcatImpl[G]
+case class SmtlibStrLen[G](arg: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibStrLenImpl[G]
+case class SmtlibStrLt[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibStrLtImpl[G]
+case class SmtlibStrLeq[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends SmtlibExpr[G] with SmtlibStrLeqImpl[G]
+case class SmtlibStrAt[G](str: Expr[G], i: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibStrAtImpl[G]
+case class SmtlibSubstr[G](str: Expr[G], i: Expr[G], n: Expr[G])(
+ implicit val o: Origin
+) extends SmtlibExpr[G] with SmtlibSubstrImpl[G]
+case class SmtlibStrPrefixOf[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends SmtlibExpr[G] with SmtlibStrPrefixOfImpl[G]
+case class SmtlibStrSuffixOf[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends SmtlibExpr[G] with SmtlibStrSuffixOfImpl[G]
+case class SmtlibStrContains[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends SmtlibExpr[G] with SmtlibStrContainsImpl[G]
+case class SmtlibStrIndexOf[G](
+ haystack: Expr[G],
+ needle: Expr[G],
+ fromIndex: Expr[G],
+)(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibStrIndexOfImpl[G]
+case class SmtlibStrReplace[G](
+ haystack: Expr[G],
+ needle: Expr[G],
+ replacement: Expr[G],
+)(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibStrReplaceImpl[G]
+case class SmtlibStrReplaceAll[G](
+ haystack: Expr[G],
+ needle: Expr[G],
+ replacement: Expr[G],
+)(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibStrReplaceAllImpl[G]
+case class SmtlibStrReplaceRe[G](
+ haystack: Expr[G],
+ re: Expr[G],
+ replacement: Expr[G],
+)(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibStrReplaceReImpl[G]
+case class SmtlibStrReplaceReAll[G](
+ haystack: Expr[G],
+ re: Expr[G],
+ replacement: Expr[G],
+)(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibStrReplaceReAllImpl[G]
+case class SmtlibStrIsDigit[G](arg: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibStrIsDigitImpl[G]
+case class SmtlibStrToCode[G](arg: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibStrToCodeImpl[G]
+case class SmtlibStrFromCode[G](arg: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibStrFromCodeImpl[G]
+case class SmtlibStrToInt[G](arg: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibStrToIntImpl[G]
+case class SmtlibStrFromInt[G](arg: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibStrFromIntImpl[G]
+
+case class SmtlibReFromStr[G](arg: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibReFromStrImpl[G]
+case class SmtlibReContains[G](re: Expr[G], str: Expr[G])(
+ implicit val o: Origin
+) extends SmtlibExpr[G] with SmtlibReContainsImpl[G]
+case class SmtlibReNone[G]()(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibReNoneImpl[G]
+case class SmtlibReAll[G]()(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibReAllImpl[G]
+case class SmtlibReAllChar[G]()(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibReAllCharImpl[G]
+case class SmtlibReConcat[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends SmtlibExpr[G] with SmtlibReConcatImpl[G]
+case class SmtlibReUnion[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends SmtlibExpr[G] with SmtlibReUnionImpl[G]
+case class SmtlibReInter[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends SmtlibExpr[G] with SmtlibReInterImpl[G]
+case class SmtlibReStar[G](arg: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibReStarImpl[G]
+case class SmtlibReComp[G](arg: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibReCompImpl[G]
+case class SmtlibReDiff[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends SmtlibExpr[G] with SmtlibReDiffImpl[G]
+case class SmtlibRePlus[G](arg: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibRePlusImpl[G]
+case class SmtlibReOpt[G](arg: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibReOptImpl[G]
+case class SmtlibReRange[G](left: Expr[G], right: Expr[G])(
+ implicit val o: Origin
+) extends SmtlibExpr[G] with SmtlibReRangeImpl[G]
+case class SmtlibReRepeat[G](count: Int, arg: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with SmtlibReRepeatImpl[G]
+case class SmtlibReRepeatRange[G](from: Int, to: Int, arg: Expr[G])(
+ implicit val o: Origin
+) extends SmtlibExpr[G] with SmtlibReRepeatRangeImpl[G]
// Non-standard Z3 extensions
-case class Z3BvSub[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with Z3BvSubImpl[G]
-case class Z3BvSRem[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with Z3BvSRemImpl[G]
-case class Z3BvSMod[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with Z3BvSModImpl[G]
-case class Z3BvSShr[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with Z3BvSShrImpl[G]
-case class Z3BvNand[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with Z3BvNandImpl[G]
-case class Z3BvNor[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with Z3BvNorImpl[G]
-case class Z3BvXnor[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with Z3BvXnorImpl[G]
-
-case class Z3ArrayConst[G](domain: Seq[Type[G]], codomain: Type[G], value: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with Z3ArrayConstImpl[G]
-case class Z3ArrayOfFunction[G](ref: SmtlibFunctionSymbol[G])(implicit val o: Origin) extends SmtlibExpr[G] with Z3ArrayOfFunctionImpl[G]
-case class Z3ArrayMap[G](ref: SmtlibFunctionSymbol[G], args: Seq[Expr[G]])(implicit val o: Origin) extends SmtlibExpr[G] with Z3ArrayMapImpl[G]
-
-case class Z3SeqEmpty[G](elementType: Type[G])(implicit val o: Origin) extends SmtlibExpr[G] with Z3SeqEmptyImpl[G]
-case class Z3SeqUnit[G](arg: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with Z3SeqUnitImpl[G]
-case class Z3SeqConcat[G](left: Expr[G], right: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with Z3SeqConcatImpl[G]
-case class Z3SeqLen[G](arg: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with Z3SeqLenImpl[G]
-case class Z3SeqExtract[G](seq: Expr[G], offset: Expr[G], len: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with Z3SeqExtractImpl[G]
-case class Z3SeqAt[G](seq: Expr[G], offset: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with Z3SeqAtImpl[G]
-case class Z3SeqNth[G](seq: Expr[G], offset: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with Z3SeqNthImpl[G]
-case class Z3SeqContains[G](seq: Expr[G], subseq: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with Z3SeqContainsImpl[G]
-case class Z3SeqPrefixOf[G](pre: Expr[G], subseq: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with Z3SeqPrefixOfImpl[G]
-case class Z3SeqSuffixOf[G](post: Expr[G], seq: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with Z3SeqSuffixOfImpl[G]
-case class Z3SeqReplace[G](haystack: Expr[G], needle: Expr[G], replacement: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with Z3SeqReplaceImpl[G]
-case class Z3SeqMap[G](f: Expr[G], seq: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with Z3SeqMapImpl[G]
-case class Z3SeqMapI[G](f: Expr[G], offset: Expr[G], seq: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with Z3SeqMapIImpl[G]
-case class Z3SeqFoldl[G](f: Expr[G], base: Expr[G], seq: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with Z3SeqFoldlImpl[G]
-case class Z3SeqFoldlI[G](f: Expr[G], offset: Expr[G], base: Expr[G], seq: Expr[G])(implicit val o: Origin) extends SmtlibExpr[G] with Z3SeqFoldlIImpl[G]
-
-case class Z3TransitiveClosure[G](ref: SmtlibFunctionSymbol[G], args: Seq[Expr[G]])(implicit val o: Origin) extends SmtlibExpr[G] with Z3TransitiveClosureImpl[G]
-
-@family sealed trait CDeclarationSpecifier[G] extends NodeFamily[G] with CDeclarationSpecifierImpl[G]
-
-sealed trait CSpecificationModifier[G] extends CDeclarationSpecifier[G] with CSpecificationModifierImpl[G]
-final case class CPure[G]()(implicit val o: Origin) extends CSpecificationModifier[G] with CPureImpl[G]
-final case class CInline[G]()(implicit val o: Origin) extends CSpecificationModifier[G] with CInlineImpl[G]
-
-sealed trait CStorageClassSpecifier[G] extends CDeclarationSpecifier[G] with CStorageClassSpecifierImpl[G]
-final case class CTypedef[G]()(implicit val o: Origin) extends CStorageClassSpecifier[G] with CTypedefImpl[G]
-final case class CExtern[G]()(implicit val o: Origin) extends CStorageClassSpecifier[G] with CExternImpl[G]
-final case class CStatic[G]()(implicit val o: Origin) extends CStorageClassSpecifier[G] with CStaticImpl[G]
-final case class GPULocal[G]()(implicit val o: Origin) extends CStorageClassSpecifier[G] with GPULocalImpl[G]
-final case class GPUGlobal[G]()(implicit val o: Origin) extends CStorageClassSpecifier[G] with GPUGlobalImpl[G]
-
-sealed trait CTypeSpecifier[G] extends CDeclarationSpecifier[G] with CTypeSpecifierImpl[G]
-final case class CVoid[G]()(implicit val o: Origin) extends CTypeSpecifier[G] with CVoidImpl[G]
-final case class CChar[G]()(implicit val o: Origin) extends CTypeSpecifier[G] with CCharImpl[G]
-final case class CShort[G]()(implicit val o: Origin) extends CTypeSpecifier[G] with CShortImpl[G]
-final case class CInt[G]()(implicit val o: Origin) extends CTypeSpecifier[G] with CIntImpl[G]
-final case class CLong[G]()(implicit val o: Origin) extends CTypeSpecifier[G] with CLongImpl[G]
-final case class CFloat[G]()(implicit val o: Origin) extends CTypeSpecifier[G] with CFloatImpl[G]
-final case class CDouble[G]()(implicit val o: Origin) extends CTypeSpecifier[G] with CDoubleImpl[G]
-final case class CSigned[G]()(implicit val o: Origin) extends CTypeSpecifier[G] with CSignedImpl[G]
-final case class CUnsigned[G]()(implicit val o: Origin) extends CTypeSpecifier[G] with CUnsignedImpl[G]
-final case class CBool[G]()(implicit val o: Origin) extends CTypeSpecifier[G] with CBoolImpl[G]
-final case class CTypedefName[G](name: String)(implicit val o: Origin) extends CTypeSpecifier[G] with CTypedefNameImpl[G] {
+case class Z3BvSub[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with Z3BvSubImpl[G]
+case class Z3BvSRem[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with Z3BvSRemImpl[G]
+case class Z3BvSMod[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with Z3BvSModImpl[G]
+case class Z3BvSShr[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with Z3BvSShrImpl[G]
+case class Z3BvNand[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with Z3BvNandImpl[G]
+case class Z3BvNor[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with Z3BvNorImpl[G]
+case class Z3BvXnor[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with Z3BvXnorImpl[G]
+
+case class Z3ArrayConst[G](
+ domain: Seq[Type[G]],
+ codomain: Type[G],
+ value: Expr[G],
+)(implicit val o: Origin)
+ extends SmtlibExpr[G] with Z3ArrayConstImpl[G]
+case class Z3ArrayOfFunction[G](ref: SmtlibFunctionSymbol[G])(
+ implicit val o: Origin
+) extends SmtlibExpr[G] with Z3ArrayOfFunctionImpl[G]
+case class Z3ArrayMap[G](ref: SmtlibFunctionSymbol[G], args: Seq[Expr[G]])(
+ implicit val o: Origin
+) extends SmtlibExpr[G] with Z3ArrayMapImpl[G]
+
+case class Z3SeqEmpty[G](elementType: Type[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with Z3SeqEmptyImpl[G]
+case class Z3SeqUnit[G](arg: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with Z3SeqUnitImpl[G]
+case class Z3SeqConcat[G](left: Expr[G], right: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with Z3SeqConcatImpl[G]
+case class Z3SeqLen[G](arg: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with Z3SeqLenImpl[G]
+case class Z3SeqExtract[G](seq: Expr[G], offset: Expr[G], len: Expr[G])(
+ implicit val o: Origin
+) extends SmtlibExpr[G] with Z3SeqExtractImpl[G]
+case class Z3SeqAt[G](seq: Expr[G], offset: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with Z3SeqAtImpl[G]
+case class Z3SeqNth[G](seq: Expr[G], offset: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with Z3SeqNthImpl[G]
+case class Z3SeqContains[G](seq: Expr[G], subseq: Expr[G])(
+ implicit val o: Origin
+) extends SmtlibExpr[G] with Z3SeqContainsImpl[G]
+case class Z3SeqPrefixOf[G](pre: Expr[G], subseq: Expr[G])(
+ implicit val o: Origin
+) extends SmtlibExpr[G] with Z3SeqPrefixOfImpl[G]
+case class Z3SeqSuffixOf[G](post: Expr[G], seq: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with Z3SeqSuffixOfImpl[G]
+case class Z3SeqReplace[G](
+ haystack: Expr[G],
+ needle: Expr[G],
+ replacement: Expr[G],
+)(implicit val o: Origin)
+ extends SmtlibExpr[G] with Z3SeqReplaceImpl[G]
+case class Z3SeqMap[G](f: Expr[G], seq: Expr[G])(implicit val o: Origin)
+ extends SmtlibExpr[G] with Z3SeqMapImpl[G]
+case class Z3SeqMapI[G](f: Expr[G], offset: Expr[G], seq: Expr[G])(
+ implicit val o: Origin
+) extends SmtlibExpr[G] with Z3SeqMapIImpl[G]
+case class Z3SeqFoldl[G](f: Expr[G], base: Expr[G], seq: Expr[G])(
+ implicit val o: Origin
+) extends SmtlibExpr[G] with Z3SeqFoldlImpl[G]
+case class Z3SeqFoldlI[G](
+ f: Expr[G],
+ offset: Expr[G],
+ base: Expr[G],
+ seq: Expr[G],
+)(implicit val o: Origin)
+ extends SmtlibExpr[G] with Z3SeqFoldlIImpl[G]
+
+case class Z3TransitiveClosure[G](
+ ref: SmtlibFunctionSymbol[G],
+ args: Seq[Expr[G]],
+)(implicit val o: Origin)
+ extends SmtlibExpr[G] with Z3TransitiveClosureImpl[G]
+
+@family
+sealed trait CDeclarationSpecifier[G]
+ extends NodeFamily[G] with CDeclarationSpecifierImpl[G]
+
+sealed trait CSpecificationModifier[G]
+ extends CDeclarationSpecifier[G] with CSpecificationModifierImpl[G]
+final case class CPure[G]()(implicit val o: Origin)
+ extends CSpecificationModifier[G] with CPureImpl[G]
+final case class CInline[G]()(implicit val o: Origin)
+ extends CSpecificationModifier[G] with CInlineImpl[G]
+
+sealed trait CStorageClassSpecifier[G]
+ extends CDeclarationSpecifier[G] with CStorageClassSpecifierImpl[G]
+final case class CTypedef[G]()(implicit val o: Origin)
+ extends CStorageClassSpecifier[G] with CTypedefImpl[G]
+final case class CExtern[G]()(implicit val o: Origin)
+ extends CStorageClassSpecifier[G] with CExternImpl[G]
+final case class CStatic[G]()(implicit val o: Origin)
+ extends CStorageClassSpecifier[G] with CStaticImpl[G]
+final case class GPULocal[G]()(implicit val o: Origin)
+ extends CStorageClassSpecifier[G] with GPULocalImpl[G]
+final case class GPUGlobal[G]()(implicit val o: Origin)
+ extends CStorageClassSpecifier[G] with GPUGlobalImpl[G]
+
+sealed trait CTypeSpecifier[G]
+ extends CDeclarationSpecifier[G] with CTypeSpecifierImpl[G]
+final case class CVoid[G]()(implicit val o: Origin)
+ extends CTypeSpecifier[G] with CVoidImpl[G]
+final case class CChar[G]()(implicit val o: Origin)
+ extends CTypeSpecifier[G] with CCharImpl[G]
+final case class CShort[G]()(implicit val o: Origin)
+ extends CTypeSpecifier[G] with CShortImpl[G]
+final case class CInt[G]()(implicit val o: Origin)
+ extends CTypeSpecifier[G] with CIntImpl[G]
+final case class CLong[G]()(implicit val o: Origin)
+ extends CTypeSpecifier[G] with CLongImpl[G]
+final case class CFloat[G]()(implicit val o: Origin)
+ extends CTypeSpecifier[G] with CFloatImpl[G]
+final case class CDouble[G]()(implicit val o: Origin)
+ extends CTypeSpecifier[G] with CDoubleImpl[G]
+final case class CSigned[G]()(implicit val o: Origin)
+ extends CTypeSpecifier[G] with CSignedImpl[G]
+final case class CUnsigned[G]()(implicit val o: Origin)
+ extends CTypeSpecifier[G] with CUnsignedImpl[G]
+final case class CBool[G]()(implicit val o: Origin)
+ extends CTypeSpecifier[G] with CBoolImpl[G]
+final case class CTypedefName[G](name: String)(implicit val o: Origin)
+ extends CTypeSpecifier[G] with CTypedefNameImpl[G] {
var ref: Option[CTypeNameTarget[G]] = None
}
-final case class CSpecificationType[G](t: Type[G])(implicit val o: Origin) extends CTypeSpecifier[G] with CSpecificationTypeImpl[G]
-final case class CFunctionTypeExtensionModifier[G](extensions: Seq[CTypeExtensions[G]])(implicit val o: Origin) extends CTypeSpecifier[G] with CFunctionTypeExtensionModifierImpl[G]
-
-final case class CStructDeclaration[G](name: Option[String], decl: Seq[CStructMemberDeclarator[G]])(implicit val o: Origin) extends CTypeSpecifier[G] with CStructDeclarationImpl[G]
-final case class CStructSpecifier[G](name: String)(implicit val o: Origin) extends CTypeSpecifier[G] with CStructSpecifierImpl[G] {
+final case class CSpecificationType[G](t: Type[G])(implicit val o: Origin)
+ extends CTypeSpecifier[G] with CSpecificationTypeImpl[G]
+final case class CFunctionTypeExtensionModifier[G](
+ extensions: Seq[CTypeExtensions[G]]
+)(implicit val o: Origin)
+ extends CTypeSpecifier[G] with CFunctionTypeExtensionModifierImpl[G]
+
+final case class CStructDeclaration[G](
+ name: Option[String],
+ decl: Seq[CStructMemberDeclarator[G]],
+)(implicit val o: Origin)
+ extends CTypeSpecifier[G] with CStructDeclarationImpl[G]
+final case class CStructSpecifier[G](name: String)(implicit val o: Origin)
+ extends CTypeSpecifier[G] with CStructSpecifierImpl[G] {
var ref: Option[RefCStruct[G]] = None
}
-@family final case class CStructMemberDeclarator[G](specs: Seq[CDeclarationSpecifier[G]], decls: Seq[CDeclarator[G]])(implicit val o: Origin) extends Declaration[G] with CStructMemberDeclaratorImpl[G]
-
-final case class CTypeQualifierDeclarationSpecifier[G](typeQual: CTypeQualifier[G])(implicit val o: Origin) extends CDeclarationSpecifier[G] with CTypeQualifierDeclarationSpecifierImpl[G]
-
-@family sealed trait CTypeQualifier[G] extends NodeFamily[G] with CTypeQualifierImpl[G]
-final case class CConst[G]()(implicit val o: Origin) extends CTypeQualifier[G] with CConstImpl[G]
-final case class CRestrict[G]()(implicit val o: Origin) extends CTypeQualifier[G] with CRestrictImpl[G]
-final case class CVolatile[G]()(implicit val o: Origin) extends CTypeQualifier[G] with CVolatileImpl[G]
-final case class CAtomic[G]()(implicit val o: Origin) extends CTypeQualifier[G] with CAtomicImpl[G]
-
-sealed trait CFunctionSpecifier[G] extends CDeclarationSpecifier[G] with CFunctionSpecifierImpl[G]
-sealed trait CAlignmentSpecifier[G] extends CDeclarationSpecifier[G] with CAlignmentSpecifierImpl[G]
+@family
+final case class CStructMemberDeclarator[G](
+ specs: Seq[CDeclarationSpecifier[G]],
+ decls: Seq[CDeclarator[G]],
+)(implicit val o: Origin)
+ extends Declaration[G] with CStructMemberDeclaratorImpl[G]
+
+final case class CTypeQualifierDeclarationSpecifier[G](
+ typeQual: CTypeQualifier[G]
+)(implicit val o: Origin)
+ extends CDeclarationSpecifier[G]
+ with CTypeQualifierDeclarationSpecifierImpl[G]
-sealed trait CGpgpuKernelSpecifier[G] extends CDeclarationSpecifier[G] with CGpgpuKernelSpecifierImpl[G]
-final case class CUDAKernel[G]()(val blame: Blame[KernelFailure])(implicit val o: Origin) extends CGpgpuKernelSpecifier[G] with CUDAKernelImpl[G]
-final case class OpenCLKernel[G]()(val blame: Blame[KernelFailure])(implicit val o: Origin) extends CGpgpuKernelSpecifier[G] with OpenCLKernelImpl[G]
+@family
+sealed trait CTypeQualifier[G] extends NodeFamily[G] with CTypeQualifierImpl[G]
+final case class CConst[G]()(implicit val o: Origin)
+ extends CTypeQualifier[G] with CConstImpl[G]
+final case class CRestrict[G]()(implicit val o: Origin)
+ extends CTypeQualifier[G] with CRestrictImpl[G]
+final case class CVolatile[G]()(implicit val o: Origin)
+ extends CTypeQualifier[G] with CVolatileImpl[G]
+final case class CAtomic[G]()(implicit val o: Origin)
+ extends CTypeQualifier[G] with CAtomicImpl[G]
+
+sealed trait CFunctionSpecifier[G]
+ extends CDeclarationSpecifier[G] with CFunctionSpecifierImpl[G]
+sealed trait CAlignmentSpecifier[G]
+ extends CDeclarationSpecifier[G] with CAlignmentSpecifierImpl[G]
+
+sealed trait CGpgpuKernelSpecifier[G]
+ extends CDeclarationSpecifier[G] with CGpgpuKernelSpecifierImpl[G]
+final case class CUDAKernel[G]()(val blame: Blame[KernelFailure])(
+ implicit val o: Origin
+) extends CGpgpuKernelSpecifier[G] with CUDAKernelImpl[G]
+final case class OpenCLKernel[G]()(val blame: Blame[KernelFailure])(
+ implicit val o: Origin
+) extends CGpgpuKernelSpecifier[G] with OpenCLKernelImpl[G]
-@family final case class CPointer[G](qualifiers: Seq[CTypeQualifier[G]])(implicit val o: Origin) extends NodeFamily[G] with CPointerImpl[G]
+@family
+final case class CPointer[G](qualifiers: Seq[CTypeQualifier[G]])(
+ implicit val o: Origin
+) extends NodeFamily[G] with CPointerImpl[G]
-@family final class CParam[G](val specifiers: Seq[CDeclarationSpecifier[G]], val declarator: CDeclarator[G])(implicit val o: Origin) extends Declaration[G] with CParamImpl[G]
+@family
+final class CParam[G](
+ val specifiers: Seq[CDeclarationSpecifier[G]],
+ val declarator: CDeclarator[G],
+)(implicit val o: Origin)
+ extends Declaration[G] with CParamImpl[G]
-@family sealed trait CDeclarator[G] extends NodeFamily[G] with CDeclaratorImpl[G]
-final case class CPointerDeclarator[G](pointers: Seq[CPointer[G]], inner: CDeclarator[G])(implicit val o: Origin) extends CDeclarator[G] with CPointerDeclaratorImpl[G]
-final case class CArrayDeclarator[G](qualifiers: Seq[CTypeQualifier[G]], size: Option[Expr[G]], inner: CDeclarator[G])(val blame: Blame[ArraySizeError])(implicit val o: Origin) extends CDeclarator[G] with CArrayDeclaratorImpl[G]
-final case class CTypeExtensionDeclarator[G](extensions: Seq[CTypeExtensions[G]], inner: CDeclarator[G])(implicit val o: Origin) extends CDeclarator[G] with CTypeExtensionDeclaratorImpl[G]
-final case class CTypedFunctionDeclarator[G](params: Seq[CParam[G]], varargs: Boolean, inner: CDeclarator[G])(implicit val o: Origin) extends CDeclarator[G] with CTypedFunctionDeclaratorImpl[G]
-final case class CAnonymousFunctionDeclarator[G](params: Seq[String], inner: CDeclarator[G])(implicit val o: Origin) extends CDeclarator[G] with CAnonymousFunctionDeclaratorImpl[G]
-final case class CName[G](name: String)(implicit val o: Origin) extends CDeclarator[G] with CNameImpl[G]
+@family
+sealed trait CDeclarator[G] extends NodeFamily[G] with CDeclaratorImpl[G]
+final case class CPointerDeclarator[G](
+ pointers: Seq[CPointer[G]],
+ inner: CDeclarator[G],
+)(implicit val o: Origin)
+ extends CDeclarator[G] with CPointerDeclaratorImpl[G]
+final case class CArrayDeclarator[G](
+ qualifiers: Seq[CTypeQualifier[G]],
+ size: Option[Expr[G]],
+ inner: CDeclarator[G],
+)(val blame: Blame[ArraySizeError])(implicit val o: Origin)
+ extends CDeclarator[G] with CArrayDeclaratorImpl[G]
+final case class CTypeExtensionDeclarator[G](
+ extensions: Seq[CTypeExtensions[G]],
+ inner: CDeclarator[G],
+)(implicit val o: Origin)
+ extends CDeclarator[G] with CTypeExtensionDeclaratorImpl[G]
+final case class CTypedFunctionDeclarator[G](
+ params: Seq[CParam[G]],
+ varargs: Boolean,
+ inner: CDeclarator[G],
+)(implicit val o: Origin)
+ extends CDeclarator[G] with CTypedFunctionDeclaratorImpl[G]
+final case class CAnonymousFunctionDeclarator[G](
+ params: Seq[String],
+ inner: CDeclarator[G],
+)(implicit val o: Origin)
+ extends CDeclarator[G] with CAnonymousFunctionDeclaratorImpl[G]
+final case class CName[G](name: String)(implicit val o: Origin)
+ extends CDeclarator[G] with CNameImpl[G]
-@family sealed trait CTypeExtensions[G] extends NodeFamily[G] with CTypeExtensionsImpl[G]
-final case class CTypeAttribute[G](name: String, args: Seq[Expr[G]])(implicit val o: Origin) extends CTypeExtensions[G] with CTypeAttributeImpl[G]
+@family
+sealed trait CTypeExtensions[G]
+ extends NodeFamily[G] with CTypeExtensionsImpl[G]
+final case class CTypeAttribute[G](name: String, args: Seq[Expr[G]])(
+ implicit val o: Origin
+) extends CTypeExtensions[G] with CTypeAttributeImpl[G]
-@family final case class CInit[G](decl: CDeclarator[G], init: Option[Expr[G]])(implicit val o: Origin) extends NodeFamily[G] with CInitImpl[G] {
+@family
+final case class CInit[G](decl: CDeclarator[G], init: Option[Expr[G]])(
+ implicit val o: Origin
+) extends NodeFamily[G] with CInitImpl[G] {
var ref: Option[RefCFunctionDefinition[G]] = None
}
-@family final case class CDeclaration[G](contract: ApplicableContract[G], kernelInvariant: Expr[G], specs: Seq[CDeclarationSpecifier[G]], inits: Seq[CInit[G]])(implicit val o: Origin) extends NodeFamily[G] with CDeclarationImpl[G]
-
-final class CTranslationUnit[G](val declarations: Seq[GlobalDeclaration[G]])(implicit val o: Origin) extends GlobalDeclaration[G] with Declarator[G] with CTranslationUnitImpl[G]
-
-sealed trait CAbstractDeclaration[G] extends GlobalDeclaration[G] with CAbstractDeclarationImpl[G]
-
-@scopes[CLocalDeclaration] @scopes[CParam] final class CGlobalDeclaration[G](val decl: CDeclaration[G])(implicit val o: Origin) extends CAbstractDeclaration[G] with CGlobalDeclarationImpl[G]
-@family final class CLocalDeclaration[G](val decl: CDeclaration[G])(implicit val o: Origin) extends Declaration[G] with CLocalDeclarationImpl[G]
-@scopes[LabelDecl] @scopes[CLocalDeclaration] @scopes[CParam] final class CFunctionDefinition[G](val contract: ApplicableContract[G], val specs: Seq[CDeclarationSpecifier[G]], val declarator: CDeclarator[G], val body: Statement[G])(val blame: Blame[CallableFailure])(implicit val o: Origin) extends CAbstractDeclaration[G] with CFunctionDefinitionImpl[G] {
+@family
+final case class CDeclaration[G](
+ contract: ApplicableContract[G],
+ kernelInvariant: Expr[G],
+ specs: Seq[CDeclarationSpecifier[G]],
+ inits: Seq[CInit[G]],
+)(implicit val o: Origin)
+ extends NodeFamily[G] with CDeclarationImpl[G]
+
+final class CTranslationUnit[G](val declarations: Seq[GlobalDeclaration[G]])(
+ implicit val o: Origin
+) extends GlobalDeclaration[G] with Declarator[G] with CTranslationUnitImpl[G]
+
+sealed trait CAbstractDeclaration[G]
+ extends GlobalDeclaration[G] with CAbstractDeclarationImpl[G]
+
+@scopes[CLocalDeclaration]
+@scopes[CParam]
+final class CGlobalDeclaration[G](val decl: CDeclaration[G])(
+ implicit val o: Origin
+) extends CAbstractDeclaration[G] with CGlobalDeclarationImpl[G]
+@family
+final class CLocalDeclaration[G](val decl: CDeclaration[G])(
+ implicit val o: Origin
+) extends Declaration[G] with CLocalDeclarationImpl[G]
+@scopes[LabelDecl]
+@scopes[CLocalDeclaration]
+@scopes[CParam]
+final class CFunctionDefinition[G](
+ val contract: ApplicableContract[G],
+ val specs: Seq[CDeclarationSpecifier[G]],
+ val declarator: CDeclarator[G],
+ val body: Statement[G],
+)(val blame: Blame[CallableFailure])(implicit val o: Origin)
+ extends CAbstractDeclaration[G] with CFunctionDefinitionImpl[G] {
var ref: Option[RefCGlobalDeclaration[G]] = None
}
sealed trait CStatement[G] extends Statement[G] with CStatementImpl[G]
-final case class CDeclarationStatement[G](decl: CLocalDeclaration[G])(implicit val o: Origin) extends CStatement[G] with PurelySequentialStatement[G] with CDeclarationStatementImpl[G]
-final case class CGoto[G](label: String)(implicit val o: Origin) extends CStatement[G] with CGotoImpl[G] {
+final case class CDeclarationStatement[G](decl: CLocalDeclaration[G])(
+ implicit val o: Origin
+) extends CStatement[G]
+ with PurelySequentialStatement[G]
+ with CDeclarationStatementImpl[G]
+final case class CGoto[G](label: String)(implicit val o: Origin)
+ extends CStatement[G] with CGotoImpl[G] {
var ref: Option[LabelDecl[G]] = None
}
-@family sealed trait GpuMemoryFence[G] extends NodeFamily[G] with GpuMemoryFenceImpl[G]
-final case class GpuLocalMemoryFence[G]()(implicit val o: Origin) extends GpuMemoryFence[G] with GpuLocalMemoryFenceImpl[G]
-final case class GpuGlobalMemoryFence[G]()(implicit val o: Origin) extends GpuMemoryFence[G] with GpuGlobalMemoryFenceImpl[G]
-final case class GpuZeroMemoryFence[G](value: BigInt)(implicit val o: Origin) extends GpuMemoryFence[G] with GpuZeroMemoryFenceImpl[G]
-
-final case class GpgpuBarrier[G](requires: Expr[G], ensures: Expr[G], specifiers: Seq[GpuMemoryFence[G]])(val blame: Blame[KernelBarrierFailure])(implicit val o: Origin) extends CStatement[G] with GpgpuBarrierImpl[G]
-final case class GpgpuAtomic[G](impl: Statement[G], before: Statement[G], after: Statement[G])(implicit val o: Origin) extends CStatement[G] with GpgpuAtomicImpl[G]
+@family
+sealed trait GpuMemoryFence[G] extends NodeFamily[G] with GpuMemoryFenceImpl[G]
+final case class GpuLocalMemoryFence[G]()(implicit val o: Origin)
+ extends GpuMemoryFence[G] with GpuLocalMemoryFenceImpl[G]
+final case class GpuGlobalMemoryFence[G]()(implicit val o: Origin)
+ extends GpuMemoryFence[G] with GpuGlobalMemoryFenceImpl[G]
+final case class GpuZeroMemoryFence[G](value: BigInt)(implicit val o: Origin)
+ extends GpuMemoryFence[G] with GpuZeroMemoryFenceImpl[G]
+
+final case class GpgpuBarrier[G](
+ requires: Expr[G],
+ ensures: Expr[G],
+ specifiers: Seq[GpuMemoryFence[G]],
+)(val blame: Blame[KernelBarrierFailure])(implicit val o: Origin)
+ extends CStatement[G] with GpgpuBarrierImpl[G]
+final case class GpgpuAtomic[G](
+ impl: Statement[G],
+ before: Statement[G],
+ after: Statement[G],
+)(implicit val o: Origin)
+ extends CStatement[G] with GpgpuAtomicImpl[G]
sealed trait CExpr[G] extends Expr[G] with CExprImpl[G]
-final case class CLocal[G](name: String)(val blame: Blame[DerefInsufficientPermission])(implicit val o: Origin) extends CExpr[G] with CLocalImpl[G] {
+final case class CLocal[G](name: String)(
+ val blame: Blame[DerefInsufficientPermission]
+)(implicit val o: Origin)
+ extends CExpr[G] with CLocalImpl[G] {
var ref: Option[CNameTarget[G]] = None
}
-final case class CInvocation[G](applicable: Expr[G], args: Seq[Expr[G]], givenArgs: Seq[(Ref[G, Variable[G]], Expr[G])], yields: Seq[(Expr[G], Ref[G, Variable[G]])])(val blame: Blame[FrontendInvocationError])(implicit val o: Origin) extends CExpr[G] with CInvocationImpl[G] {
+final case class CInvocation[G](
+ applicable: Expr[G],
+ args: Seq[Expr[G]],
+ givenArgs: Seq[(Ref[G, Variable[G]], Expr[G])],
+ yields: Seq[(Expr[G], Ref[G, Variable[G]])],
+)(val blame: Blame[FrontendInvocationError])(implicit val o: Origin)
+ extends CExpr[G] with CInvocationImpl[G] {
var ref: Option[CInvocationTarget[G]] = None
}
-final case class CFieldAccess[G](obj: Expr[G], field: String)(val blame: Blame[FrontendDerefError])(implicit val o: Origin) extends CExpr[G] with CFieldAccessImpl[G] {
+final case class CFieldAccess[G](obj: Expr[G], field: String)(
+ val blame: Blame[FrontendDerefError]
+)(implicit val o: Origin)
+ extends CExpr[G] with CFieldAccessImpl[G] {
var ref: Option[CDerefTarget[G]] = None
}
-final case class CStructDeref[G](struct: Expr[G], field: String)(val blame: Blame[FrontendDerefError])(implicit val o: Origin) extends CExpr[G] with CStructDerefImpl[G] {
+final case class CStructDeref[G](struct: Expr[G], field: String)(
+ val blame: Blame[FrontendDerefError]
+)(implicit val o: Origin)
+ extends CExpr[G] with CStructDerefImpl[G] {
var ref: Option[CDerefTarget[G]] = None
}
//TODO: Define real blame for a kernel invocation
-final case class GpgpuCudaKernelInvocation[G](kernel: String, blocks: Expr[G], threads: Expr[G], args: Seq[Expr[G]], givenArgs: Seq[(Ref[G, Variable[G]], Expr[G])], yields: Seq[(Expr[G], Ref[G, Variable[G]])])(val blame: Blame[FrontendInvocationError])(implicit val o: Origin) extends CExpr[G] with GpgpuCudaKernelInvocationImpl[G] {
+final case class GpgpuCudaKernelInvocation[G](
+ kernel: String,
+ blocks: Expr[G],
+ threads: Expr[G],
+ args: Seq[Expr[G]],
+ givenArgs: Seq[(Ref[G, Variable[G]], Expr[G])],
+ yields: Seq[(Expr[G], Ref[G, Variable[G]])],
+)(val blame: Blame[FrontendInvocationError])(implicit val o: Origin)
+ extends CExpr[G] with GpgpuCudaKernelInvocationImpl[G] {
var ref: Option[CInvocationTarget[G]] = None
}
-final case class CCast[G](expr: Expr[G], castType: Type[G])(implicit val o: Origin) extends CExpr[G] with CCastImpl[G]
+final case class CCast[G](expr: Expr[G], castType: Type[G])(
+ implicit val o: Origin
+) extends CExpr[G] with CCastImpl[G]
-final case class CLiteralArray[G](exprs: Seq[Expr[G]])(implicit val o: Origin) extends CExpr[G] with CLiteralArrayImpl[G]
+final case class CLiteralArray[G](exprs: Seq[Expr[G]])(implicit val o: Origin)
+ extends CExpr[G] with CLiteralArrayImpl[G]
sealed trait CType[G] extends Type[G] with CTypeImpl[G]
-final case class TCInt[G]()(implicit val o: Origin = DiagnosticOrigin) extends IntType[G] with CType[G] with TCIntImpl[G]
-final case class TCFloat[G](exponent: Int, mantissa: Int)(implicit val o: Origin = DiagnosticOrigin) extends FloatType[G] with CType[G] with TCFloatImpl[G]
-final case class CPrimitiveType[G](specifiers: Seq[CDeclarationSpecifier[G]])(implicit val o: Origin = DiagnosticOrigin) extends CType[G] with CPrimitiveTypeImpl[G]
-final case class CTPointer[G](innerType: Type[G])(implicit val o: Origin = DiagnosticOrigin) extends CType[G] with CTPointerImpl[G]
-final case class CTArray[G](size: Option[Expr[G]], innerType: Type[G])(val blame: Blame[ArraySizeError])(implicit val o: Origin = DiagnosticOrigin) extends CType[G] with CTArrayImpl[G]
-final case class CTStruct[G](ref: Ref[G, CGlobalDeclaration[G]])(implicit val o: Origin = DiagnosticOrigin) extends CType[G] with CTStructImpl[G]
-final case class CTVector[G](size: Expr[G], innerType: Type[G])(implicit val o: Origin = DiagnosticOrigin) extends CType[G] with CTVectorImpl[G]
-final case class TOpenCLVector[G](size: BigInt, innerType: Type[G])(implicit val o: Origin = DiagnosticOrigin) extends CType[G] with TOpenCLVectorImpl[G]
-final case class CTCudaVec[G]()(implicit val o: Origin = DiagnosticOrigin) extends CType[G] with CTCudaVecImpl[G]
-
-@family sealed trait CPPDeclarationSpecifier[G] extends NodeFamily[G] with CPPDeclarationSpecifierImpl[G]
-
-sealed trait CPPSpecificationModifier[G] extends CPPDeclarationSpecifier[G] with CPPSpecificationModifierImpl[G]
-final case class CPPPure[G]()(implicit val o: Origin) extends CPPSpecificationModifier[G] with CPPPureImpl[G]
-final case class CPPInline[G]()(implicit val o: Origin) extends CPPSpecificationModifier[G] with CPPInlineImpl[G]
-
-sealed trait CPPTypeSpecifier[G] extends CPPDeclarationSpecifier[G] with CPPTypeSpecifierImpl[G]
-final case class CPPVoid[G]()(implicit val o: Origin) extends CPPTypeSpecifier[G] with CPPVoidImpl[G]
-final case class CPPChar[G]()(implicit val o: Origin) extends CPPTypeSpecifier[G] with CPPCharImpl[G]
-final case class CPPShort[G]()(implicit val o: Origin) extends CPPTypeSpecifier[G] with CPPShortImpl[G]
-final case class CPPInt[G]()(implicit val o: Origin) extends CPPTypeSpecifier[G] with CPPIntImpl[G]
-final case class CPPLong[G]()(implicit val o: Origin) extends CPPTypeSpecifier[G] with CPPLongImpl[G]
-final case class CPPSigned[G]()(implicit val o: Origin) extends CPPTypeSpecifier[G] with CPPSignedImpl[G]
-final case class CPPUnsigned[G]()(implicit val o: Origin) extends CPPTypeSpecifier[G] with CPPUnsignedImpl[G]
-final case class CPPBool[G]()(implicit val o: Origin) extends CPPTypeSpecifier[G] with CPPBoolImpl[G]
-final case class CPPTypedefName[G](var nestedName: String, genericArgs: Seq[CPPExprOrTypeSpecifier[G]])(implicit val o: Origin) extends CPPTypeSpecifier[G] with CPPTypedefNameImpl[G] {
+final case class TCInt[G]()(implicit val o: Origin = DiagnosticOrigin)
+ extends IntType[G] with CType[G] with TCIntImpl[G]
+final case class TCFloat[G](exponent: Int, mantissa: Int)(
+ implicit val o: Origin = DiagnosticOrigin
+) extends FloatType[G] with CType[G] with TCFloatImpl[G]
+final case class CPrimitiveType[G](specifiers: Seq[CDeclarationSpecifier[G]])(
+ implicit val o: Origin = DiagnosticOrigin
+) extends CType[G] with CPrimitiveTypeImpl[G]
+final case class CTPointer[G](innerType: Type[G])(
+ implicit val o: Origin = DiagnosticOrigin
+) extends CType[G] with CTPointerImpl[G]
+final case class CTArray[G](size: Option[Expr[G]], innerType: Type[G])(
+ val blame: Blame[ArraySizeError]
+)(implicit val o: Origin = DiagnosticOrigin)
+ extends CType[G] with CTArrayImpl[G]
+final case class CTStruct[G](ref: Ref[G, CGlobalDeclaration[G]])(
+ implicit val o: Origin = DiagnosticOrigin
+) extends CType[G] with CTStructImpl[G]
+final case class CTVector[G](size: Expr[G], innerType: Type[G])(
+ implicit val o: Origin = DiagnosticOrigin
+) extends CType[G] with CTVectorImpl[G]
+final case class TOpenCLVector[G](size: BigInt, innerType: Type[G])(
+ implicit val o: Origin = DiagnosticOrigin
+) extends CType[G] with TOpenCLVectorImpl[G]
+final case class CTCudaVec[G]()(implicit val o: Origin = DiagnosticOrigin)
+ extends CType[G] with CTCudaVecImpl[G]
+
+@family
+sealed trait CPPDeclarationSpecifier[G]
+ extends NodeFamily[G] with CPPDeclarationSpecifierImpl[G]
+
+sealed trait CPPSpecificationModifier[G]
+ extends CPPDeclarationSpecifier[G] with CPPSpecificationModifierImpl[G]
+final case class CPPPure[G]()(implicit val o: Origin)
+ extends CPPSpecificationModifier[G] with CPPPureImpl[G]
+final case class CPPInline[G]()(implicit val o: Origin)
+ extends CPPSpecificationModifier[G] with CPPInlineImpl[G]
+
+sealed trait CPPTypeSpecifier[G]
+ extends CPPDeclarationSpecifier[G] with CPPTypeSpecifierImpl[G]
+final case class CPPVoid[G]()(implicit val o: Origin)
+ extends CPPTypeSpecifier[G] with CPPVoidImpl[G]
+final case class CPPChar[G]()(implicit val o: Origin)
+ extends CPPTypeSpecifier[G] with CPPCharImpl[G]
+final case class CPPShort[G]()(implicit val o: Origin)
+ extends CPPTypeSpecifier[G] with CPPShortImpl[G]
+final case class CPPInt[G]()(implicit val o: Origin)
+ extends CPPTypeSpecifier[G] with CPPIntImpl[G]
+final case class CPPLong[G]()(implicit val o: Origin)
+ extends CPPTypeSpecifier[G] with CPPLongImpl[G]
+final case class CPPSigned[G]()(implicit val o: Origin)
+ extends CPPTypeSpecifier[G] with CPPSignedImpl[G]
+final case class CPPUnsigned[G]()(implicit val o: Origin)
+ extends CPPTypeSpecifier[G] with CPPUnsignedImpl[G]
+final case class CPPBool[G]()(implicit val o: Origin)
+ extends CPPTypeSpecifier[G] with CPPBoolImpl[G]
+final case class CPPTypedefName[G](
+ var nestedName: String,
+ genericArgs: Seq[CPPExprOrTypeSpecifier[G]],
+)(implicit val o: Origin)
+ extends CPPTypeSpecifier[G] with CPPTypedefNameImpl[G] {
var ref: Option[CPPTypeNameTarget[G]] = None
}
-final case class CPPSpecificationType[G](t: Type[G])(implicit val o: Origin) extends CPPTypeSpecifier[G] with CPPSpecificationTypeImpl[G]
+final case class CPPSpecificationType[G](t: Type[G])(implicit val o: Origin)
+ extends CPPTypeSpecifier[G] with CPPSpecificationTypeImpl[G]
-@family sealed trait CPPAddressing[G] extends NodeFamily[G] with CPPAddressingImpl[G]
-final case class CPPPointer[G]()(implicit val o: Origin) extends CPPAddressing[G] with CPPPointerImpl[G]
-final case class CPPReference[G]()(implicit val o: Origin) extends CPPAddressing[G] with CPPReferenceImpl[G]
+@family
+sealed trait CPPAddressing[G] extends NodeFamily[G] with CPPAddressingImpl[G]
+final case class CPPPointer[G]()(implicit val o: Origin)
+ extends CPPAddressing[G] with CPPPointerImpl[G]
+final case class CPPReference[G]()(implicit val o: Origin)
+ extends CPPAddressing[G] with CPPReferenceImpl[G]
-@family final class CPPParam[G](val specifiers: Seq[CPPDeclarationSpecifier[G]], val declarator: CPPDeclarator[G])(implicit val o: Origin) extends Declaration[G] with CPPParamImpl[G]
+@family
+final class CPPParam[G](
+ val specifiers: Seq[CPPDeclarationSpecifier[G]],
+ val declarator: CPPDeclarator[G],
+)(implicit val o: Origin)
+ extends Declaration[G] with CPPParamImpl[G]
-@family sealed trait CPPDeclarator[G] extends NodeFamily[G] with CPPDeclaratorImpl[G]
-final case class CPPAddressingDeclarator[G](operators: Seq[CPPAddressing[G]], inner: CPPDeclarator[G])(implicit val o: Origin) extends CPPDeclarator[G] with CPPAddressingDeclaratorImpl[G]
-final case class CPPArrayDeclarator[G](size: Option[Expr[G]], inner: CPPDeclarator[G])(val blame: Blame[ArraySizeError])(implicit val o: Origin) extends CPPDeclarator[G] with CPPArrayDeclaratorImpl[G]
-final case class CPPTypedFunctionDeclarator[G](params: Seq[CPPParam[G]], varargs: Boolean, inner: CPPDeclarator[G])(implicit val o: Origin) extends CPPDeclarator[G] with CPPTypedFunctionDeclaratorImpl[G]
-final case class CPPLambdaDeclarator[G](params: Seq[CPPParam[G]])(implicit val o: Origin) extends CPPDeclarator[G] with CPPLambdaDeclaratorImpl[G]
-final case class CPPName[G](name: String)(implicit val o: Origin) extends CPPDeclarator[G] with CPPNameImpl[G]
+@family
+sealed trait CPPDeclarator[G] extends NodeFamily[G] with CPPDeclaratorImpl[G]
+final case class CPPAddressingDeclarator[G](
+ operators: Seq[CPPAddressing[G]],
+ inner: CPPDeclarator[G],
+)(implicit val o: Origin)
+ extends CPPDeclarator[G] with CPPAddressingDeclaratorImpl[G]
+final case class CPPArrayDeclarator[G](
+ size: Option[Expr[G]],
+ inner: CPPDeclarator[G],
+)(val blame: Blame[ArraySizeError])(implicit val o: Origin)
+ extends CPPDeclarator[G] with CPPArrayDeclaratorImpl[G]
+final case class CPPTypedFunctionDeclarator[G](
+ params: Seq[CPPParam[G]],
+ varargs: Boolean,
+ inner: CPPDeclarator[G],
+)(implicit val o: Origin)
+ extends CPPDeclarator[G] with CPPTypedFunctionDeclaratorImpl[G]
+final case class CPPLambdaDeclarator[G](params: Seq[CPPParam[G]])(
+ implicit val o: Origin
+) extends CPPDeclarator[G] with CPPLambdaDeclaratorImpl[G]
+final case class CPPName[G](name: String)(implicit val o: Origin)
+ extends CPPDeclarator[G] with CPPNameImpl[G]
-@family final case class CPPInit[G](decl: CPPDeclarator[G], init: Option[Expr[G]])(implicit val o: Origin) extends NodeFamily[G] with CPPInitImpl[G] {
+@family
+final case class CPPInit[G](decl: CPPDeclarator[G], init: Option[Expr[G]])(
+ implicit val o: Origin
+) extends NodeFamily[G] with CPPInitImpl[G] {
var ref: Option[RefCPPFunctionDefinition[G]] = None
}
-@family final case class CPPDeclaration[G](contract: ApplicableContract[G], specs: Seq[CPPDeclarationSpecifier[G]], inits: Seq[CPPInit[G]])(implicit val o: Origin) extends NodeFamily[G] with CPPDeclarationImpl[G]
-
-final class CPPTranslationUnit[G](val declarations: Seq[GlobalDeclaration[G]])(implicit val o: Origin) extends GlobalDeclaration[G] with Declarator[G] with CPPTranslationUnitImpl[G]
-
-sealed trait CPPAbstractDeclaration[G] extends GlobalDeclaration[G] with CPPAbstractDeclarationImpl[G]
-
-@scopes[CPPLocalDeclaration] @scopes[CPPParam] final class CPPGlobalDeclaration[G](val decl: CPPDeclaration[G])(implicit val o: Origin) extends CPPAbstractDeclaration[G] with CPPGlobalDeclarationImpl[G]
-@family final class CPPLocalDeclaration[G](val decl: CPPDeclaration[G])(implicit val o: Origin) extends Declaration[G] with CPPLocalDeclarationImpl[G]
-@scopes[LabelDecl] @scopes[CPPLocalDeclaration] @scopes[CPPParam] final class CPPFunctionDefinition[G](val contract: ApplicableContract[G], val specs: Seq[CPPDeclarationSpecifier[G]], val declarator: CPPDeclarator[G], val body: Statement[G])(val blame: Blame[CallableFailure])(implicit val o: Origin) extends GlobalDeclaration[G] with CPPFunctionDefinitionImpl[G] {
+@family
+final case class CPPDeclaration[G](
+ contract: ApplicableContract[G],
+ specs: Seq[CPPDeclarationSpecifier[G]],
+ inits: Seq[CPPInit[G]],
+)(implicit val o: Origin)
+ extends NodeFamily[G] with CPPDeclarationImpl[G]
+
+final class CPPTranslationUnit[G](val declarations: Seq[GlobalDeclaration[G]])(
+ implicit val o: Origin
+) extends GlobalDeclaration[G] with Declarator[G] with CPPTranslationUnitImpl[G]
+
+sealed trait CPPAbstractDeclaration[G]
+ extends GlobalDeclaration[G] with CPPAbstractDeclarationImpl[G]
+
+@scopes[CPPLocalDeclaration]
+@scopes[CPPParam]
+final class CPPGlobalDeclaration[G](val decl: CPPDeclaration[G])(
+ implicit val o: Origin
+) extends CPPAbstractDeclaration[G] with CPPGlobalDeclarationImpl[G]
+@family
+final class CPPLocalDeclaration[G](val decl: CPPDeclaration[G])(
+ implicit val o: Origin
+) extends Declaration[G] with CPPLocalDeclarationImpl[G]
+@scopes[LabelDecl]
+@scopes[CPPLocalDeclaration]
+@scopes[CPPParam]
+final class CPPFunctionDefinition[G](
+ val contract: ApplicableContract[G],
+ val specs: Seq[CPPDeclarationSpecifier[G]],
+ val declarator: CPPDeclarator[G],
+ val body: Statement[G],
+)(val blame: Blame[CallableFailure])(implicit val o: Origin)
+ extends GlobalDeclaration[G] with CPPFunctionDefinitionImpl[G] {
var ref: Option[RefCPPGlobalDeclaration[G]] = None
}
sealed trait CPPStatement[G] extends Statement[G] with CPPStatementImpl[G]
-final case class CPPDeclarationStatement[G](decl: CPPLocalDeclaration[G])(implicit val o: Origin) extends CPPStatement[G] with PurelySequentialStatement[G] with CPPDeclarationStatementImpl[G]
-final case class CPPLifetimeScope[G](body: Statement[G])(implicit val o: Origin) extends CPPStatement[G] with ControlContainerStatement[G] with CPPLifetimeScopeImpl[G]
+final case class CPPDeclarationStatement[G](decl: CPPLocalDeclaration[G])(
+ implicit val o: Origin
+) extends CPPStatement[G]
+ with PurelySequentialStatement[G]
+ with CPPDeclarationStatementImpl[G]
+final case class CPPLifetimeScope[G](body: Statement[G])(implicit val o: Origin)
+ extends CPPStatement[G]
+ with ControlContainerStatement[G]
+ with CPPLifetimeScopeImpl[G]
sealed trait CPPExpr[G] extends Expr[G] with CPPExprImpl[G]
-final case class CPPLocal[G](name: String, genericArgs: Seq[CPPExprOrTypeSpecifier[G]])(val blame: Blame[DerefInsufficientPermission])(implicit val o: Origin) extends CPPExpr[G] with CPPLocalImpl[G] {
+final case class CPPLocal[G](
+ name: String,
+ genericArgs: Seq[CPPExprOrTypeSpecifier[G]],
+)(val blame: Blame[DerefInsufficientPermission])(implicit val o: Origin)
+ extends CPPExpr[G] with CPPLocalImpl[G] {
var ref: Option[CPPNameTarget[G]] = None
}
-final case class CPPClassMethodOrFieldAccess[G](classInstance: Expr[G], methodOrFieldName: String)(val blame: Blame[FrontendDerefError])(implicit val o: Origin) extends CPPExpr[G] with CPPClassMethodOrFieldAccessImpl[G] {
+final case class CPPClassMethodOrFieldAccess[G](
+ classInstance: Expr[G],
+ methodOrFieldName: String,
+)(val blame: Blame[FrontendDerefError])(implicit val o: Origin)
+ extends CPPExpr[G] with CPPClassMethodOrFieldAccessImpl[G] {
var ref: Option[CPPDerefTarget[G]] = None
}
-final case class CPPInvocation[G](applicable: Expr[G], args: Seq[Expr[G]], givenArgs: Seq[(Ref[G, Variable[G]], Expr[G])], yields: Seq[(Expr[G], Ref[G, Variable[G]])])(val blame: Blame[FrontendInvocationError])(implicit val o: Origin) extends CPPExpr[G] with CPPInvocationImpl[G] {
+final case class CPPInvocation[G](
+ applicable: Expr[G],
+ args: Seq[Expr[G]],
+ givenArgs: Seq[(Ref[G, Variable[G]], Expr[G])],
+ yields: Seq[(Expr[G], Ref[G, Variable[G]])],
+)(val blame: Blame[FrontendInvocationError])(implicit val o: Origin)
+ extends CPPExpr[G] with CPPInvocationImpl[G] {
var ref: Option[CPPInvocationTarget[G]] = None
}
-final case class CPPLambdaRef[G]()(implicit val o: Origin) extends CPPExpr[G] with CPPLambdaRefImpl[G]
-final case class CPPLambdaDefinition[G](contract: ApplicableContract[G], declarator: CPPDeclarator[G], body: Statement[G])(val blame: Blame[SYCLKernelLambdaFailure])(implicit val o: Origin) extends CPPExpr[G] with CPPLambdaDefinitionImpl[G]
-
-final case class CPPLiteralArray[G](exprs: Seq[Expr[G]])(implicit val o: Origin) extends CPPExpr[G] with CPPLiteralArrayImpl[G]
+final case class CPPLambdaRef[G]()(implicit val o: Origin)
+ extends CPPExpr[G] with CPPLambdaRefImpl[G]
+final case class CPPLambdaDefinition[G](
+ contract: ApplicableContract[G],
+ declarator: CPPDeclarator[G],
+ body: Statement[G],
+)(val blame: Blame[SYCLKernelLambdaFailure])(implicit val o: Origin)
+ extends CPPExpr[G] with CPPLambdaDefinitionImpl[G]
+
+final case class CPPLiteralArray[G](exprs: Seq[Expr[G]])(implicit val o: Origin)
+ extends CPPExpr[G] with CPPLiteralArrayImpl[G]
sealed trait CPPType[G] extends Type[G] with CPPTypeImpl[G]
-final case class CPPPrimitiveType[G](specifiers: Seq[CPPDeclarationSpecifier[G]])(implicit val o: Origin = DiagnosticOrigin) extends CPPType[G] with CPPPrimitiveTypeImpl[G]
-final case class CPPTArray[G](size: Option[Expr[G]], innerType: Type[G])(val blame: Blame[ArraySizeError])(implicit val o: Origin = DiagnosticOrigin) extends CPPType[G] with CPPTArrayImpl[G]
-final case class CPPTLambda[G]()(implicit val o: Origin) extends CPPType[G] with CPPTLambdaImpl[G]
+final case class CPPPrimitiveType[G](
+ specifiers: Seq[CPPDeclarationSpecifier[G]]
+)(implicit val o: Origin = DiagnosticOrigin)
+ extends CPPType[G] with CPPPrimitiveTypeImpl[G]
+final case class CPPTArray[G](size: Option[Expr[G]], innerType: Type[G])(
+ val blame: Blame[ArraySizeError]
+)(implicit val o: Origin = DiagnosticOrigin)
+ extends CPPType[G] with CPPTArrayImpl[G]
+final case class CPPTLambda[G]()(implicit val o: Origin)
+ extends CPPType[G] with CPPTLambdaImpl[G]
-@family final case class CPPExprOrTypeSpecifier[G](expr: Option[Expr[G]], typeSpec: Option[CPPDeclarationSpecifier[G]])(implicit val o: Origin) extends NodeFamily[G] with CPPExprOrTypeSpecifierImpl[G]
-
-final case class SYCLClassDefName[G](name: String, genericArgs: Seq[CPPExprOrTypeSpecifier[G]])(implicit val o: Origin) extends CPPTypeSpecifier[G] with SYCLClassDefNameImpl[G]
+@family
+final case class CPPExprOrTypeSpecifier[G](
+ expr: Option[Expr[G]],
+ typeSpec: Option[CPPDeclarationSpecifier[G]],
+)(implicit val o: Origin)
+ extends NodeFamily[G] with CPPExprOrTypeSpecifierImpl[G]
+
+final case class SYCLClassDefName[G](
+ name: String,
+ genericArgs: Seq[CPPExprOrTypeSpecifier[G]],
+)(implicit val o: Origin)
+ extends CPPTypeSpecifier[G] with SYCLClassDefNameImpl[G]
sealed trait SYCLTClass[G] extends Type[G] with SYCLTClassImpl[G]
-sealed trait SYCLTConstructableClass[G] extends SYCLTClass[G] with SYCLTConstructableClassImpl[G]
-final case class SYCLTEvent[G]()(implicit val o: Origin) extends SYCLTClass[G] with SYCLTEventImpl[G]
-final case class SYCLTHandler[G]()(implicit val o: Origin) extends SYCLTClass[G] with SYCLTHandlerImpl[G]
-final case class SYCLTQueue[G]()(implicit val o: Origin) extends SYCLTClass[G] with SYCLTQueueImpl[G]
-final case class SYCLTItem[G](dimCount: Int = 1)(implicit val o: Origin) extends SYCLTClass[G] with SYCLTItemImpl[G]
-final case class SYCLTNDItem[G](dimCount: Int = 1)(implicit val o: Origin) extends SYCLTClass[G] with SYCLTNDItemImpl[G]
-final case class SYCLTRange[G](dimCount: Int = 1)(implicit val o: Origin) extends SYCLTConstructableClass[G] with SYCLTRangeImpl[G]
-final case class SYCLTNDRange[G](dimCount: Int = 1)(implicit val o: Origin) extends SYCLTConstructableClass[G] with SYCLTNDRangeImpl[G]
-final case class SYCLTBuffer[G](typ: Type[G] = TBool[G](), dimCount: Int = 1)(implicit val o: Origin) extends SYCLTConstructableClass[G] with SYCLTBufferImpl[G]
-final case class SYCLTAccessor[G](typ: Type[G] = TBool[G](), dimCount: Int = 1, readOnly: Boolean = false)(implicit val o: Origin) extends SYCLTConstructableClass[G] with SYCLTAccessorImpl[G]
-final case class SYCLTLocalAccessor[G](typ: Type[G] = TBool[G](), dimCount: Int = 1)(implicit val o: Origin) extends SYCLTConstructableClass[G] with SYCLTLocalAccessorImpl[G]
-final case class SYCLTAccessMode[G]()(implicit val o: Origin) extends SYCLTClass[G] with SYCLTAccessModeImpl[G]
+sealed trait SYCLTConstructableClass[G]
+ extends SYCLTClass[G] with SYCLTConstructableClassImpl[G]
+final case class SYCLTEvent[G]()(implicit val o: Origin)
+ extends SYCLTClass[G] with SYCLTEventImpl[G]
+final case class SYCLTHandler[G]()(implicit val o: Origin)
+ extends SYCLTClass[G] with SYCLTHandlerImpl[G]
+final case class SYCLTQueue[G]()(implicit val o: Origin)
+ extends SYCLTClass[G] with SYCLTQueueImpl[G]
+final case class SYCLTItem[G](dimCount: Int = 1)(implicit val o: Origin)
+ extends SYCLTClass[G] with SYCLTItemImpl[G]
+final case class SYCLTNDItem[G](dimCount: Int = 1)(implicit val o: Origin)
+ extends SYCLTClass[G] with SYCLTNDItemImpl[G]
+final case class SYCLTRange[G](dimCount: Int = 1)(implicit val o: Origin)
+ extends SYCLTConstructableClass[G] with SYCLTRangeImpl[G]
+final case class SYCLTNDRange[G](dimCount: Int = 1)(implicit val o: Origin)
+ extends SYCLTConstructableClass[G] with SYCLTNDRangeImpl[G]
+final case class SYCLTBuffer[G](typ: Type[G] = TBool[G](), dimCount: Int = 1)(
+ implicit val o: Origin
+) extends SYCLTConstructableClass[G] with SYCLTBufferImpl[G]
+final case class SYCLTAccessor[G](
+ typ: Type[G] = TBool[G](),
+ dimCount: Int = 1,
+ readOnly: Boolean = false,
+)(implicit val o: Origin)
+ extends SYCLTConstructableClass[G] with SYCLTAccessorImpl[G]
+final case class SYCLTLocalAccessor[G](
+ typ: Type[G] = TBool[G](),
+ dimCount: Int = 1,
+)(implicit val o: Origin)
+ extends SYCLTConstructableClass[G] with SYCLTLocalAccessorImpl[G]
+final case class SYCLTAccessMode[G]()(implicit val o: Origin)
+ extends SYCLTClass[G] with SYCLTAccessModeImpl[G]
sealed trait SYCLClassObject[G] extends CPPExpr[G]
-final case class SYCLRange[G](dimensions: Seq[Expr[G]])(implicit val o: Origin) extends SYCLClassObject[G] with SYCLRangeImpl[G]
-final case class SYCLNDRange[G](globalSize: Expr[G], localSize: Expr[G])(implicit val o: Origin) extends SYCLClassObject[G] with SYCLNDRangeImpl[G]
+final case class SYCLRange[G](dimensions: Seq[Expr[G]])(implicit val o: Origin)
+ extends SYCLClassObject[G] with SYCLRangeImpl[G]
+final case class SYCLNDRange[G](globalSize: Expr[G], localSize: Expr[G])(
+ implicit val o: Origin
+) extends SYCLClassObject[G] with SYCLNDRangeImpl[G]
+
+sealed trait SYCLAccessMode[G]
+ extends SYCLClassObject[G] with SYCLAccessModeImpl[G]
+final case class SYCLReadWriteAccess[G]()(implicit val o: Origin)
+ extends SYCLAccessMode[G] with SYCLReadWriteAccessImpl[G]
+final case class SYCLReadOnlyAccess[G]()(implicit val o: Origin)
+ extends SYCLAccessMode[G] with SYCLReadOnlyAccessImpl[G]
-sealed trait SYCLAccessMode[G] extends SYCLClassObject[G] with SYCLAccessModeImpl[G]
-final case class SYCLReadWriteAccess[G]()(implicit val o: Origin) extends SYCLAccessMode[G] with SYCLReadWriteAccessImpl[G]
-final case class SYCLReadOnlyAccess[G]()(implicit val o: Origin) extends SYCLAccessMode[G] with SYCLReadOnlyAccessImpl[G]
-
-@family final case class JavaName[G](names: Seq[String])(implicit val o: Origin) extends NodeFamily[G] with JavaNameImpl[G] {
+@family
+final case class JavaName[G](names: Seq[String])(implicit val o: Origin)
+ extends NodeFamily[G] with JavaNameImpl[G] {
var ref: Option[JavaTypeNameTarget[G]] = None
}
-@family final case class JavaImport[G](isStatic: Boolean, name: JavaName[G], star: Boolean)(implicit val o: Origin) extends NodeFamily[G] with JavaImportImpl[G]
-
-@family sealed trait JavaModifier[G] extends NodeFamily[G] with JavaModifierImpl[G]
-final case class JavaPublic[G]()(implicit val o: Origin) extends JavaModifier[G] with JavaPublicImpl[G]
-final case class JavaProtected[G]()(implicit val o: Origin) extends JavaModifier[G] with JavaProtectedImpl[G]
-final case class JavaPrivate[G]()(implicit val o: Origin) extends JavaModifier[G] with JavaPrivateImpl[G]
-final case class JavaStatic[G]()(implicit val o: Origin) extends JavaModifier[G] with JavaStaticImpl[G]
-final case class JavaAbstract[G]()(implicit val o: Origin) extends JavaModifier[G] with JavaAbstractImpl[G]
-final case class JavaFinal[G]()(implicit val o: Origin) extends JavaModifier[G] with JavaFinalImpl[G]
-final case class JavaStrictFP[G]()(implicit val o: Origin) extends JavaModifier[G] with JavaStrictFPImpl[G]
-final case class JavaNative[G]()(implicit val o: Origin) extends JavaModifier[G] with JavaNativeImpl[G]
-final case class JavaSynchronized[G]()(val blame: Blame[LockRegionFailure])(implicit val o: Origin) extends JavaModifier[G] with JavaSynchronizedImpl[G]
-final case class JavaTransient[G]()(implicit val o: Origin) extends JavaModifier[G] with JavaTransientImpl[G]
-final case class JavaVolatile[G]()(implicit val o: Origin) extends JavaModifier[G] with JavaVolatileImpl[G]
-final case class JavaAnnotation[G](name: Type[G], args: Seq[(String, Expr[G])]
- )(val blame: Blame[JavaAnnotationFailure]
- )(implicit val o: Origin) extends JavaModifier[G] with JavaAnnotationImpl[G] {
+@family
+final case class JavaImport[G](
+ isStatic: Boolean,
+ name: JavaName[G],
+ star: Boolean,
+)(implicit val o: Origin)
+ extends NodeFamily[G] with JavaImportImpl[G]
+
+@family
+sealed trait JavaModifier[G] extends NodeFamily[G] with JavaModifierImpl[G]
+final case class JavaPublic[G]()(implicit val o: Origin)
+ extends JavaModifier[G] with JavaPublicImpl[G]
+final case class JavaProtected[G]()(implicit val o: Origin)
+ extends JavaModifier[G] with JavaProtectedImpl[G]
+final case class JavaPrivate[G]()(implicit val o: Origin)
+ extends JavaModifier[G] with JavaPrivateImpl[G]
+final case class JavaStatic[G]()(implicit val o: Origin)
+ extends JavaModifier[G] with JavaStaticImpl[G]
+final case class JavaAbstract[G]()(implicit val o: Origin)
+ extends JavaModifier[G] with JavaAbstractImpl[G]
+final case class JavaFinal[G]()(implicit val o: Origin)
+ extends JavaModifier[G] with JavaFinalImpl[G]
+final case class JavaStrictFP[G]()(implicit val o: Origin)
+ extends JavaModifier[G] with JavaStrictFPImpl[G]
+final case class JavaNative[G]()(implicit val o: Origin)
+ extends JavaModifier[G] with JavaNativeImpl[G]
+final case class JavaSynchronized[G]()(val blame: Blame[LockRegionFailure])(
+ implicit val o: Origin
+) extends JavaModifier[G] with JavaSynchronizedImpl[G]
+final case class JavaTransient[G]()(implicit val o: Origin)
+ extends JavaModifier[G] with JavaTransientImpl[G]
+final case class JavaVolatile[G]()(implicit val o: Origin)
+ extends JavaModifier[G] with JavaVolatileImpl[G]
+final case class JavaAnnotation[G](name: Type[G], args: Seq[(String, Expr[G])])(
+ val blame: Blame[JavaAnnotationFailure]
+)(implicit val o: Origin)
+ extends JavaModifier[G] with JavaAnnotationImpl[G] {
var data: Option[JavaAnnotationData[G]] = None
}
-final case class JavaPure[G]()(implicit val o: Origin) extends JavaModifier[G] with JavaPureImpl[G]
-final case class JavaInline[G]()(implicit val o: Origin) extends JavaModifier[G] with JavaInlineImpl[G]
-final case class JavaBipAnnotation[G]()(implicit val o: Origin) extends JavaModifier[G] with JavaBipAnnotationImpl[G]
-
-@family final case class JavaVariableDeclaration[G](name: String, moreDims: Int, init: Option[Expr[G]])(implicit val o: Origin) extends NodeFamily[G] with JavaVariableDeclarationImpl[G]
-
-sealed trait JavaGlobalDeclaration[G] extends GlobalDeclaration[G] with JavaGlobalDeclarationImpl[G]
-final class JavaNamespace[G](val pkg: Option[JavaName[G]], val imports: Seq[JavaImport[G]], val declarations: Seq[GlobalDeclaration[G]])(implicit val o: Origin) extends JavaGlobalDeclaration[G] with Declarator[G] with JavaNamespaceImpl[G]
-
-sealed trait JavaClassOrInterface[G] extends JavaGlobalDeclaration[G] with Declarator[G] with JavaClassOrInterfaceImpl[G]
-@scopes[Variable] final class JavaClass[G](val name: String, val modifiers: Seq[JavaModifier[G]], val typeParams: Seq[Variable[G]], val intrinsicLockInvariant: Expr[G], val ext: Type[G], val imp: Seq[Type[G]], val decls: Seq[ClassDeclaration[G]])(val blame: Blame[JavaImplicitConstructorFailure])(implicit val o: Origin) extends JavaClassOrInterface[G] with JavaClassImpl[G]
-@scopes[Variable] final class JavaInterface[G](val name: String, val modifiers: Seq[JavaModifier[G]], val typeParams: Seq[Variable[G]], val ext: Seq[Type[G]], val decls: Seq[ClassDeclaration[G]])(implicit val o: Origin) extends JavaClassOrInterface[G] with JavaInterfaceImpl[G]
-final class JavaAnnotationInterface[G](val name: String, val modifiers: Seq[JavaModifier[G]], val ext: Type[G], val decls: Seq[ClassDeclaration[G]])(implicit val o: Origin) extends JavaClassOrInterface[G] with JavaAnnotationInterfaceImpl[G]
-
-sealed trait JavaClassDeclaration[G] extends ClassDeclaration[G] with JavaClassDeclarationImpl[G]
-final class JavaSharedInitialization[G](val isStatic: Boolean, val initialization: Statement[G])(implicit val o: Origin) extends JavaClassDeclaration[G] with JavaSharedInitializationImpl[G]
-final class JavaFields[G](val modifiers: Seq[JavaModifier[G]], val t: Type[G], val decls: Seq[JavaVariableDeclaration[G]])(implicit val o: Origin) extends JavaClassDeclaration[G] with JavaFieldsImpl[G]
-@scopes[LabelDecl] @scopes[JavaLocalDeclaration] @scopes[JavaParam] final class JavaConstructor[G](val modifiers: Seq[JavaModifier[G]], val name: String, val parameters: Seq[JavaParam[G]], val typeParameters: Seq[Variable[G]], val signals: Seq[Type[G]], val body: Statement[G], val contract: ApplicableContract[G])(val blame: Blame[JavaConstructorFailure])(implicit val o: Origin) extends JavaClassDeclaration[G] with JavaConstructorImpl[G]
-@family final class JavaParam[G](val modifiers: Seq[JavaModifier[G]], val name: String, val t: Type[G])(implicit val o: Origin) extends Declaration[G] with JavaParamImpl[G]
+final case class JavaPure[G]()(implicit val o: Origin)
+ extends JavaModifier[G] with JavaPureImpl[G]
+final case class JavaInline[G]()(implicit val o: Origin)
+ extends JavaModifier[G] with JavaInlineImpl[G]
+final case class JavaBipAnnotation[G]()(implicit val o: Origin)
+ extends JavaModifier[G] with JavaBipAnnotationImpl[G]
-@scopes[LabelDecl] @scopes[JavaLocalDeclaration] @scopes[JavaParam] final class JavaMethod[G](val modifiers: Seq[JavaModifier[G]], val returnType: Type[G], val dims: Int, val name: String, val parameters: Seq[JavaParam[G]], val typeParameters: Seq[Variable[G]], val signals: Seq[Type[G]], val body: Option[Statement[G]], val contract: ApplicableContract[G])(val blame: Blame[CallableFailure])(implicit val o: Origin) extends JavaClassDeclaration[G] with JavaMethodImpl[G]
-@scopes[JavaParam] final class JavaAnnotationMethod[G](val returnType: Type[G], val name: String, val default: Option[Expr[G]])(implicit val o: Origin) extends JavaClassDeclaration[G] with JavaAnnotationMethodImpl[G]
+@family
+final case class JavaVariableDeclaration[G](
+ name: String,
+ moreDims: Int,
+ init: Option[Expr[G]],
+)(implicit val o: Origin)
+ extends NodeFamily[G] with JavaVariableDeclarationImpl[G]
+
+sealed trait JavaGlobalDeclaration[G]
+ extends GlobalDeclaration[G] with JavaGlobalDeclarationImpl[G]
+final class JavaNamespace[G](
+ val pkg: Option[JavaName[G]],
+ val imports: Seq[JavaImport[G]],
+ val declarations: Seq[GlobalDeclaration[G]],
+)(implicit val o: Origin)
+ extends JavaGlobalDeclaration[G]
+ with Declarator[G]
+ with JavaNamespaceImpl[G]
+
+sealed trait JavaClassOrInterface[G]
+ extends JavaGlobalDeclaration[G]
+ with Declarator[G]
+ with JavaClassOrInterfaceImpl[G]
+@scopes[Variable]
+final class JavaClass[G](
+ val name: String,
+ val modifiers: Seq[JavaModifier[G]],
+ val typeParams: Seq[Variable[G]],
+ val intrinsicLockInvariant: Expr[G],
+ val ext: Type[G],
+ val imp: Seq[Type[G]],
+ val decls: Seq[ClassDeclaration[G]],
+)(val blame: Blame[JavaImplicitConstructorFailure])(implicit val o: Origin)
+ extends JavaClassOrInterface[G] with JavaClassImpl[G]
+@scopes[Variable]
+final class JavaInterface[G](
+ val name: String,
+ val modifiers: Seq[JavaModifier[G]],
+ val typeParams: Seq[Variable[G]],
+ val ext: Seq[Type[G]],
+ val decls: Seq[ClassDeclaration[G]],
+)(implicit val o: Origin)
+ extends JavaClassOrInterface[G] with JavaInterfaceImpl[G]
+final class JavaAnnotationInterface[G](
+ val name: String,
+ val modifiers: Seq[JavaModifier[G]],
+ val ext: Type[G],
+ val decls: Seq[ClassDeclaration[G]],
+)(implicit val o: Origin)
+ extends JavaClassOrInterface[G] with JavaAnnotationInterfaceImpl[G]
+
+sealed trait JavaClassDeclaration[G]
+ extends ClassDeclaration[G] with JavaClassDeclarationImpl[G]
+final class JavaSharedInitialization[G](
+ val isStatic: Boolean,
+ val initialization: Statement[G],
+)(implicit val o: Origin)
+ extends JavaClassDeclaration[G] with JavaSharedInitializationImpl[G]
+final class JavaFields[G](
+ val modifiers: Seq[JavaModifier[G]],
+ val t: Type[G],
+ val decls: Seq[JavaVariableDeclaration[G]],
+)(implicit val o: Origin)
+ extends JavaClassDeclaration[G] with JavaFieldsImpl[G]
+@scopes[LabelDecl]
+@scopes[JavaLocalDeclaration]
+@scopes[JavaParam]
+final class JavaConstructor[G](
+ val modifiers: Seq[JavaModifier[G]],
+ val name: String,
+ val parameters: Seq[JavaParam[G]],
+ val typeParameters: Seq[Variable[G]],
+ val signals: Seq[Type[G]],
+ val body: Statement[G],
+ val contract: ApplicableContract[G],
+)(val blame: Blame[JavaConstructorFailure])(implicit val o: Origin)
+ extends JavaClassDeclaration[G] with JavaConstructorImpl[G]
+@family
+final class JavaParam[G](
+ val modifiers: Seq[JavaModifier[G]],
+ val name: String,
+ val t: Type[G],
+)(implicit val o: Origin)
+ extends Declaration[G] with JavaParamImpl[G]
+
+@scopes[LabelDecl]
+@scopes[JavaLocalDeclaration]
+@scopes[JavaParam]
+final class JavaMethod[G](
+ val modifiers: Seq[JavaModifier[G]],
+ val returnType: Type[G],
+ val dims: Int,
+ val name: String,
+ val parameters: Seq[JavaParam[G]],
+ val typeParameters: Seq[Variable[G]],
+ val signals: Seq[Type[G]],
+ val body: Option[Statement[G]],
+ val contract: ApplicableContract[G],
+)(val blame: Blame[CallableFailure])(implicit val o: Origin)
+ extends JavaClassDeclaration[G] with JavaMethodImpl[G]
+@scopes[JavaParam]
+final class JavaAnnotationMethod[G](
+ val returnType: Type[G],
+ val name: String,
+ val default: Option[Expr[G]],
+)(implicit val o: Origin)
+ extends JavaClassDeclaration[G] with JavaAnnotationMethodImpl[G]
-@family final class JavaLocalDeclaration[G](val modifiers: Seq[JavaModifier[G]], val t: Type[G], val decls: Seq[JavaVariableDeclaration[G]])(implicit val o: Origin) extends Declaration[G] with JavaLocalDeclarationImpl[G]
+@family
+final class JavaLocalDeclaration[G](
+ val modifiers: Seq[JavaModifier[G]],
+ val t: Type[G],
+ val decls: Seq[JavaVariableDeclaration[G]],
+)(implicit val o: Origin)
+ extends Declaration[G] with JavaLocalDeclarationImpl[G]
sealed trait JavaStatement[G] extends Statement[G] with JavaStatementImpl[G]
-final case class JavaLocalDeclarationStatement[G](decl: JavaLocalDeclaration[G])(implicit val o: Origin) extends JavaStatement[G] with PurelySequentialStatement[G] with JavaLocalDeclarationStatementImpl[G]
+final case class JavaLocalDeclarationStatement[G](
+ decl: JavaLocalDeclaration[G]
+)(implicit val o: Origin)
+ extends JavaStatement[G]
+ with PurelySequentialStatement[G]
+ with JavaLocalDeclarationStatementImpl[G]
sealed trait JavaType[G] extends Type[G] with JavaTypeImpl[G]
-final case class JavaNamedType[G](names: Seq[(String, Option[Seq[Type[G]]])])(implicit val o: Origin) extends JavaType[G] with JavaNamedTypeImpl[G] {
+final case class JavaNamedType[G](names: Seq[(String, Option[Seq[Type[G]]])])(
+ implicit val o: Origin
+) extends JavaType[G] with JavaNamedTypeImpl[G] {
var ref: Option[JavaTypeNameTarget[G]] = None
}
-final case class JavaTClass[G](ref: Ref[G, JavaClassOrInterface[G]], typeArgs: Seq[Type[G]])(implicit val o: Origin = DiagnosticOrigin) extends JavaType[G] with JavaTClassImpl[G]
+final case class JavaTClass[G](
+ ref: Ref[G, JavaClassOrInterface[G]],
+ typeArgs: Seq[Type[G]],
+)(implicit val o: Origin = DiagnosticOrigin)
+ extends JavaType[G] with JavaTClassImpl[G]
-final case class JavaWildcard[G]()(implicit val o: Origin = DiagnosticOrigin) extends JavaType[G] with JavaWildcardImpl[G]
+final case class JavaWildcard[G]()(implicit val o: Origin = DiagnosticOrigin)
+ extends JavaType[G] with JavaWildcardImpl[G]
sealed trait JavaExpr[G] extends Expr[G] with JavaExprImpl[G]
-final case class JavaLocal[G](name: String)(val blame: Blame[DerefInsufficientPermission])(implicit val o: Origin) extends JavaExpr[G] with JavaLocalImpl[G] {
+final case class JavaLocal[G](name: String)(
+ val blame: Blame[DerefInsufficientPermission]
+)(implicit val o: Origin)
+ extends JavaExpr[G] with JavaLocalImpl[G] {
var ref: Option[JavaNameTarget[G]] = None
}
-final case class JavaDeref[G](obj: Expr[G], field: String)(val blame: Blame[FrontendDerefError])(implicit val o: Origin) extends JavaExpr[G] with JavaDerefImpl[G] {
+final case class JavaDeref[G](obj: Expr[G], field: String)(
+ val blame: Blame[FrontendDerefError]
+)(implicit val o: Origin)
+ extends JavaExpr[G] with JavaDerefImpl[G] {
var ref: Option[JavaDerefTarget[G]] = None
}
-final case class JavaLiteralArray[G](exprs: Seq[Expr[G]])(implicit val o: Origin) extends JavaExpr[G] with JavaLiteralArrayImpl[G] {
+final case class JavaLiteralArray[G](exprs: Seq[Expr[G]])(
+ implicit val o: Origin
+) extends JavaExpr[G] with JavaLiteralArrayImpl[G] {
var typeContext: Option[TArray[G]] = None
}
-final case class JavaInvocation[G](obj: Option[Expr[G]], typeParams: Seq[Type[G]], method: String, arguments: Seq[Expr[G]], givenArgs: Seq[(Ref[G, Variable[G]], Expr[G])], yields: Seq[(Expr[G], Ref[G, Variable[G]])])(val blame: Blame[FrontendInvocationError])(implicit val o: Origin) extends JavaExpr[G] with JavaInvocationImpl[G] {
+final case class JavaInvocation[G](
+ obj: Option[Expr[G]],
+ typeParams: Seq[Type[G]],
+ method: String,
+ arguments: Seq[Expr[G]],
+ givenArgs: Seq[(Ref[G, Variable[G]], Expr[G])],
+ yields: Seq[(Expr[G], Ref[G, Variable[G]])],
+)(val blame: Blame[FrontendInvocationError])(implicit val o: Origin)
+ extends JavaExpr[G] with JavaInvocationImpl[G] {
var ref: Option[JavaInvocationTarget[G]] = None
}
-final case class JavaNewClass[G](args: Seq[Expr[G]], typeArgs: Seq[Type[G]], name: Type[G], givenArgs: Seq[(Ref[G, Variable[G]], Expr[G])], yields: Seq[(Expr[G], Ref[G, Variable[G]])])(val blame: Blame[InvocationFailure])(implicit val o: Origin) extends JavaExpr[G] with JavaNewClassImpl[G] {
+final case class JavaNewClass[G](
+ args: Seq[Expr[G]],
+ typeArgs: Seq[Type[G]],
+ name: Type[G],
+ givenArgs: Seq[(Ref[G, Variable[G]], Expr[G])],
+ yields: Seq[(Expr[G], Ref[G, Variable[G]])],
+)(val blame: Blame[InvocationFailure])(implicit val o: Origin)
+ extends JavaExpr[G] with JavaNewClassImpl[G] {
var ref: Option[JavaConstructorTarget[G]] = None
}
-final case class JavaNewLiteralArray[G](baseType: Type[G], dims: Int, initializer: Expr[G])(val blame: Blame[ArraySizeError])(implicit val o: Origin) extends JavaExpr[G] with JavaNewLiteralArrayImpl[G]
-final case class JavaNewDefaultArray[G](baseType: Type[G], specifiedDims: Seq[Expr[G]], moreDims: Int)(val blame: Blame[ArraySizeError])(implicit val o: Origin) extends JavaExpr[G] with JavaNewDefaultArrayImpl[G]
-final case class JavaStringValue[G](data: String, t: Type[G])(implicit val o: Origin) extends JavaExpr[G] with JavaStringValueImpl[G]
+final case class JavaNewLiteralArray[G](
+ baseType: Type[G],
+ dims: Int,
+ initializer: Expr[G],
+)(val blame: Blame[ArraySizeError])(implicit val o: Origin)
+ extends JavaExpr[G] with JavaNewLiteralArrayImpl[G]
+final case class JavaNewDefaultArray[G](
+ baseType: Type[G],
+ specifiedDims: Seq[Expr[G]],
+ moreDims: Int,
+)(val blame: Blame[ArraySizeError])(implicit val o: Origin)
+ extends JavaExpr[G] with JavaNewDefaultArrayImpl[G]
+final case class JavaStringValue[G](data: String, t: Type[G])(
+ implicit val o: Origin
+) extends JavaExpr[G] with JavaStringValueImpl[G]
+
+final class JavaBipGlueContainer[G](val job: Expr[G])(implicit val o: Origin)
+ extends JavaGlobalDeclaration[G] with JavaBipGlueContainerImpl[G]
+
+final case class JavaBipGlue[G](elems: Seq[JavaBipGlueElement[G]])(
+ val blame: Blame[BipGlueFailure]
+)(implicit val o: Origin)
+ extends JavaExpr[G] with JavaBipGlueImpl[G]
-final class JavaBipGlueContainer[G](val job: Expr[G])(implicit val o: Origin) extends JavaGlobalDeclaration[G] with JavaBipGlueContainerImpl[G]
-
-final case class JavaBipGlue[G](elems: Seq[JavaBipGlueElement[G]])(val blame: Blame[BipGlueFailure])(implicit val o: Origin) extends JavaExpr[G] with JavaBipGlueImpl[G]
-
-@family final case class JavaBipGlueName[G](t: Type[G], e: Expr[G])(implicit val o: Origin) extends NodeFamily[G] with JavaBipGlueNameImpl[G] {
+@family
+final case class JavaBipGlueName[G](t: Type[G], e: Expr[G])(
+ implicit val o: Origin
+) extends NodeFamily[G] with JavaBipGlueNameImpl[G] {
var data: Option[(JavaClass[G], String)] = None
}
-@family sealed trait JavaBipGlueElement[G] extends NodeFamily[G] with JavaBipGlueElementImpl[G]
-final case class JavaBipGlueRequires[G](port: JavaBipGlueName[G], others: Seq[JavaBipGlueName[G]])(implicit val o: Origin) extends JavaBipGlueElement[G] with JavaBipGlueRequiresImpl[G]
-final case class JavaBipGlueAccepts[G](port: JavaBipGlueName[G], others: Seq[JavaBipGlueName[G]])(implicit val o: Origin) extends JavaBipGlueElement[G] with JavaBipGlueAcceptsImpl[G]
-final case class JavaBipGlueSynchron[G](port0: JavaBipGlueName[G], port1: JavaBipGlueName[G])(implicit val o: Origin) extends JavaBipGlueElement[G] with JavaBipGlueSynchronImpl[G]
-final case class JavaBipGlueDataWire[G](dataOut: JavaBipGlueName[G], dataIn: JavaBipGlueName[G])(implicit val o: Origin) extends JavaBipGlueElement[G] with JavaBipGlueDataWireImpl[G]
-
-final class BipGlue[G](val requires: Seq[BipGlueRequires[G]], val accepts: Seq[BipGlueAccepts[G]], val dataWires: Seq[BipGlueDataWire[G]])(val blame: Blame[BipGlueFailure])(implicit val o: Origin) extends GlobalDeclaration[G] with BipGlueImpl[G]
-@family final case class BipGlueRequires[G](port: Ref[G, BipPort[G]], others: Seq[Ref[G, BipPort[G]]])(implicit val o: Origin) extends NodeFamily[G] with BipGlueRequiresImpl[G]
-@family final case class BipGlueAccepts[G](port: Ref[G, BipPort[G]], others: Seq[Ref[G, BipPort[G]]])(implicit val o: Origin) extends NodeFamily[G] with BipGlueAcceptsImpl[G]
-@family final case class BipGlueDataWire[G](dataOut: Ref[G, BipOutgoingData[G]], dataIn: Ref[G, BipIncomingData[G]])(implicit val o: Origin) extends NodeFamily[G] with BipGlueDataWireImpl[G]
+@family
+sealed trait JavaBipGlueElement[G]
+ extends NodeFamily[G] with JavaBipGlueElementImpl[G]
+final case class JavaBipGlueRequires[G](
+ port: JavaBipGlueName[G],
+ others: Seq[JavaBipGlueName[G]],
+)(implicit val o: Origin)
+ extends JavaBipGlueElement[G] with JavaBipGlueRequiresImpl[G]
+final case class JavaBipGlueAccepts[G](
+ port: JavaBipGlueName[G],
+ others: Seq[JavaBipGlueName[G]],
+)(implicit val o: Origin)
+ extends JavaBipGlueElement[G] with JavaBipGlueAcceptsImpl[G]
+final case class JavaBipGlueSynchron[G](
+ port0: JavaBipGlueName[G],
+ port1: JavaBipGlueName[G],
+)(implicit val o: Origin)
+ extends JavaBipGlueElement[G] with JavaBipGlueSynchronImpl[G]
+final case class JavaBipGlueDataWire[G](
+ dataOut: JavaBipGlueName[G],
+ dataIn: JavaBipGlueName[G],
+)(implicit val o: Origin)
+ extends JavaBipGlueElement[G] with JavaBipGlueDataWireImpl[G]
+
+final class BipGlue[G](
+ val requires: Seq[BipGlueRequires[G]],
+ val accepts: Seq[BipGlueAccepts[G]],
+ val dataWires: Seq[BipGlueDataWire[G]],
+)(val blame: Blame[BipGlueFailure])(implicit val o: Origin)
+ extends GlobalDeclaration[G] with BipGlueImpl[G]
+@family
+final case class BipGlueRequires[G](
+ port: Ref[G, BipPort[G]],
+ others: Seq[Ref[G, BipPort[G]]],
+)(implicit val o: Origin)
+ extends NodeFamily[G] with BipGlueRequiresImpl[G]
+@family
+final case class BipGlueAccepts[G](
+ port: Ref[G, BipPort[G]],
+ others: Seq[Ref[G, BipPort[G]]],
+)(implicit val o: Origin)
+ extends NodeFamily[G] with BipGlueAcceptsImpl[G]
+@family
+final case class BipGlueDataWire[G](
+ dataOut: Ref[G, BipOutgoingData[G]],
+ dataIn: Ref[G, BipIncomingData[G]],
+)(implicit val o: Origin)
+ extends NodeFamily[G] with BipGlueDataWireImpl[G]
sealed trait BipData[G] extends ClassDeclaration[G] with BipDataImpl[G]
-final class BipIncomingData[G](val t: Type[G])(implicit val o: Origin) extends BipData[G] with BipIncomingDataImpl[G]
-final class BipOutgoingData[G](val t: Type[G], val body: Statement[G], val pure: Boolean)(val blame: Blame[BipOutgoingDataPreconditionUnsatisfiable])(implicit val o: Origin) extends BipData[G] with BipOutgoingDataImpl[G]
-final case class BipLocalIncomingData[G](ref: Ref[G, BipIncomingData[G]])(implicit val o: Origin) extends Expr[G] with BipLocalIncomingDataImpl[G]
-
-final class BipStatePredicate[G](val expr: Expr[G])(implicit val o: Origin) extends ClassDeclaration[G] with BipStatePredicateImpl[G]
-@family final case class BipTransitionSignature[G](portName: String, sourceStateName: String, targetStateName: String, textualGuard: Option[String])(implicit val o: Origin) extends NodeFamily[G] with BipTransitionSignatureImpl[G]
-final class BipTransition[G](val signature: BipTransitionSignature[G],
- val port: Ref[G, BipPort[G]],
- val source: Ref[G, BipStatePredicate[G]], val target: Ref[G, BipStatePredicate[G]],
- val data: Seq[Ref[G, BipIncomingData[G]]], val guard: Expr[G],
- val requires: Expr[G], val ensures: Expr[G], val body: Statement[G]
- )(val blame: Blame[BipTransitionFailure])(implicit val o: Origin) extends ClassDeclaration[G] with BipTransitionImpl[G]
-final class BipGuard[G](val data: Seq[Ref[G, BipIncomingData[G]]], val body: Statement[G], val pure: Boolean)(val blame: Blame[BipGuardPreconditionUnsatisfiable])(implicit val o: Origin) extends ClassDeclaration[G] with BipGuardImpl[G]
-final case class BipGuardInvocation[G](obj: Expr[G], guard: Ref[G, BipGuard[G]])(implicit val o: Origin) extends Expr[G] with BipGuardInvocationImpl[G]
-final class BipComponent[G](val fqn: Seq[String], val invariant: Expr[G], val initial: Ref[G, BipStatePredicate[G]])(implicit val o: Origin) extends ClassDeclaration[G] with BipComponentImpl[G]
-final class BipConstructor[G](val args: Seq[Variable[G]], val body: Statement[G], val requires: Expr[G])(val blame: Blame[BipConstructorFailure])(implicit val o: Origin) extends ClassDeclaration[G] with Declarator[G] with BipConstructorImpl[G]
-
-final class BipPort[G](val t: BipPortType[G])(implicit val o: Origin) extends ClassDeclaration[G] with BipPortImpl[G]
-@family sealed trait BipPortType[G] extends NodeFamily[G] with BipPortTypeImpl[G]
-final case class BipEnforceable[G]()(implicit val o: Origin = DiagnosticOrigin) extends BipPortType[G] with BipEnforceableImpl[G]
-final case class BipSpontaneous[G]()(implicit val o: Origin = DiagnosticOrigin) extends BipPortType[G] with BipSpontaneousImpl[G]
-final case class BipInternal[G]()(implicit val o: Origin = DiagnosticOrigin) extends BipPortType[G] with BipInternalImpl[G]
-
-final case class BipPortSynchronization[G](ports: Seq[Ref[G, BipPort[G]]], wires: Seq[BipGlueDataWire[G]])(val blame: Blame[BipSynchronizationFailure])(implicit val o: Origin) extends GlobalDeclaration[G] with BipPortSynchronizationImpl[G]
-final case class BipTransitionSynchronization[G](transitions: Seq[Ref[G, BipTransition[G]]], wires: Seq[BipGlueDataWire[G]])(val blame: Blame[BipSynchronizationFailure])(implicit val o: Origin) extends GlobalDeclaration[G] with BipTransitionSynchronizationImpl[G]
-
-@family final class LlvmFunctionContract[G](val value:String, val variableRefs:Seq[(String, Ref[G, Variable[G]])], val invokableRefs:Seq[(String, Ref[G, LlvmCallable[G]])])
- (val blame: Blame[NontrivialUnsatisfiable])
- (implicit val o: Origin) extends NodeFamily[G] with LlvmFunctionContractImpl[G] {
+final class BipIncomingData[G](val t: Type[G])(implicit val o: Origin)
+ extends BipData[G] with BipIncomingDataImpl[G]
+final class BipOutgoingData[G](
+ val t: Type[G],
+ val body: Statement[G],
+ val pure: Boolean,
+)(val blame: Blame[BipOutgoingDataPreconditionUnsatisfiable])(
+ implicit val o: Origin
+) extends BipData[G] with BipOutgoingDataImpl[G]
+final case class BipLocalIncomingData[G](ref: Ref[G, BipIncomingData[G]])(
+ implicit val o: Origin
+) extends Expr[G] with BipLocalIncomingDataImpl[G]
+
+final class BipStatePredicate[G](val expr: Expr[G])(implicit val o: Origin)
+ extends ClassDeclaration[G] with BipStatePredicateImpl[G]
+@family
+final case class BipTransitionSignature[G](
+ portName: String,
+ sourceStateName: String,
+ targetStateName: String,
+ textualGuard: Option[String],
+)(implicit val o: Origin)
+ extends NodeFamily[G] with BipTransitionSignatureImpl[G]
+final class BipTransition[G](
+ val signature: BipTransitionSignature[G],
+ val port: Ref[G, BipPort[G]],
+ val source: Ref[G, BipStatePredicate[G]],
+ val target: Ref[G, BipStatePredicate[G]],
+ val data: Seq[Ref[G, BipIncomingData[G]]],
+ val guard: Expr[G],
+ val requires: Expr[G],
+ val ensures: Expr[G],
+ val body: Statement[G],
+)(val blame: Blame[BipTransitionFailure])(implicit val o: Origin)
+ extends ClassDeclaration[G] with BipTransitionImpl[G]
+final class BipGuard[G](
+ val data: Seq[Ref[G, BipIncomingData[G]]],
+ val body: Statement[G],
+ val pure: Boolean,
+)(val blame: Blame[BipGuardPreconditionUnsatisfiable])(implicit val o: Origin)
+ extends ClassDeclaration[G] with BipGuardImpl[G]
+final case class BipGuardInvocation[G](
+ obj: Expr[G],
+ guard: Ref[G, BipGuard[G]],
+)(implicit val o: Origin)
+ extends Expr[G] with BipGuardInvocationImpl[G]
+final class BipComponent[G](
+ val fqn: Seq[String],
+ val invariant: Expr[G],
+ val initial: Ref[G, BipStatePredicate[G]],
+)(implicit val o: Origin)
+ extends ClassDeclaration[G] with BipComponentImpl[G]
+final class BipConstructor[G](
+ val args: Seq[Variable[G]],
+ val body: Statement[G],
+ val requires: Expr[G],
+)(val blame: Blame[BipConstructorFailure])(implicit val o: Origin)
+ extends ClassDeclaration[G] with Declarator[G] with BipConstructorImpl[G]
+
+final class BipPort[G](val t: BipPortType[G])(implicit val o: Origin)
+ extends ClassDeclaration[G] with BipPortImpl[G]
+@family
+sealed trait BipPortType[G] extends NodeFamily[G] with BipPortTypeImpl[G]
+final case class BipEnforceable[G]()(implicit val o: Origin = DiagnosticOrigin)
+ extends BipPortType[G] with BipEnforceableImpl[G]
+final case class BipSpontaneous[G]()(implicit val o: Origin = DiagnosticOrigin)
+ extends BipPortType[G] with BipSpontaneousImpl[G]
+final case class BipInternal[G]()(implicit val o: Origin = DiagnosticOrigin)
+ extends BipPortType[G] with BipInternalImpl[G]
+
+final case class BipPortSynchronization[G](
+ ports: Seq[Ref[G, BipPort[G]]],
+ wires: Seq[BipGlueDataWire[G]],
+)(val blame: Blame[BipSynchronizationFailure])(implicit val o: Origin)
+ extends GlobalDeclaration[G] with BipPortSynchronizationImpl[G]
+final case class BipTransitionSynchronization[G](
+ transitions: Seq[Ref[G, BipTransition[G]]],
+ wires: Seq[BipGlueDataWire[G]],
+)(val blame: Blame[BipSynchronizationFailure])(implicit val o: Origin)
+ extends GlobalDeclaration[G] with BipTransitionSynchronizationImpl[G]
+
+@family
+final class LlvmFunctionContract[G](
+ val value: String,
+ val variableRefs: Seq[(String, Ref[G, Variable[G]])],
+ val invokableRefs: Seq[(String, Ref[G, LlvmCallable[G]])],
+)(val blame: Blame[NontrivialUnsatisfiable])(implicit val o: Origin)
+ extends NodeFamily[G] with LlvmFunctionContractImpl[G] {
var data: Option[ApplicableContract[G]] = None
}
sealed trait LlvmCallable[G] extends GlobalDeclaration[G]
-@scopes[LabelDecl] final class LlvmFunctionDefinition[G](val returnType: Type[G],
- val args: Seq[Variable[G]],
- val functionBody: Statement[G],
- val contract: LlvmFunctionContract[G],
- val pure: Boolean = false)
- (val blame: Blame[CallableFailure])(implicit val o: Origin)
- extends LlvmCallable[G] with Applicable[G] with LlvmFunctionDefinitionImpl[G]
-@scopes[LabelDecl] final class LlvmSpecFunction[G](val name: String, val returnType: Type[G], val args: Seq[Variable[G]], val typeArgs: Seq[Variable[G]],
- val body: Option[Expr[G]], val contract: ApplicableContract[G], val inline: Boolean = false, val threadLocal: Boolean = false)
- (val blame: Blame[ContractedFailure])(implicit val o: Origin)
- extends LlvmCallable[G] with AbstractFunction[G] with LlvmSpecFunctionImpl[G]
-final case class LlvmFunctionInvocation[G](ref: Ref[G, LlvmFunctionDefinition[G]],
- args: Seq[Expr[G]],
- givenMap: Seq[(Ref[G, Variable[G]], Expr[G])],
- yields: Seq[(Expr[G], Ref[G, Variable[G]])])
- (val blame: Blame[InvocationFailure])(implicit val o: Origin) extends Apply[G] with LlvmFunctionInvocationImpl[G]
-final case class LlvmLoop[G](cond:Expr[G], contract:LlvmLoopContract[G], body:Statement[G])
- (implicit val o: Origin) extends CompositeStatement[G] with LlvmLoopImpl[G]
-@family sealed trait LlvmLoopContract[G] extends NodeFamily[G] with LlvmLoopContractImpl[G]
-final case class LlvmLoopInvariant[G](value:String, references:Seq[(String, Ref[G, Declaration[G]])])
- (val blame: Blame[LoopInvariantFailure])
- (implicit val o: Origin) extends LlvmLoopContract[G] with LlvmLoopInvariantImpl[G]
+@scopes[LabelDecl]
+final class LlvmFunctionDefinition[G](
+ val returnType: Type[G],
+ val args: Seq[Variable[G]],
+ val functionBody: Statement[G],
+ val contract: LlvmFunctionContract[G],
+ val pure: Boolean = false,
+)(val blame: Blame[CallableFailure])(implicit val o: Origin)
+ extends LlvmCallable[G]
+ with Applicable[G]
+ with LlvmFunctionDefinitionImpl[G]
+@scopes[LabelDecl]
+final class LlvmSpecFunction[G](
+ val name: String,
+ val returnType: Type[G],
+ val args: Seq[Variable[G]],
+ val typeArgs: Seq[Variable[G]],
+ val body: Option[Expr[G]],
+ val contract: ApplicableContract[G],
+ val inline: Boolean = false,
+ val threadLocal: Boolean = false,
+)(val blame: Blame[ContractedFailure])(implicit val o: Origin)
+ extends LlvmCallable[G]
+ with AbstractFunction[G]
+ with LlvmSpecFunctionImpl[G]
+final case class LlvmFunctionInvocation[G](
+ ref: Ref[G, LlvmFunctionDefinition[G]],
+ args: Seq[Expr[G]],
+ givenMap: Seq[(Ref[G, Variable[G]], Expr[G])],
+ yields: Seq[(Expr[G], Ref[G, Variable[G]])],
+)(val blame: Blame[InvocationFailure])(implicit val o: Origin)
+ extends Apply[G] with LlvmFunctionInvocationImpl[G]
+final case class LlvmLoop[G](
+ cond: Expr[G],
+ contract: LlvmLoopContract[G],
+ body: Statement[G],
+)(implicit val o: Origin)
+ extends CompositeStatement[G] with LlvmLoopImpl[G]
+@family
+sealed trait LlvmLoopContract[G]
+ extends NodeFamily[G] with LlvmLoopContractImpl[G]
+final case class LlvmLoopInvariant[G](
+ value: String,
+ references: Seq[(String, Ref[G, Declaration[G]])],
+)(val blame: Blame[LoopInvariantFailure])(implicit val o: Origin)
+ extends LlvmLoopContract[G] with LlvmLoopInvariantImpl[G]
sealed trait LlvmExpr[G] extends Expr[G] with LlvmExprImpl[G]
-final case class LlvmLocal[G](name: String)(val blame: Blame[DerefInsufficientPermission])(implicit val o: Origin) extends LlvmExpr[G] with LlvmLocalImpl[G] {
+final case class LlvmLocal[G](name: String)(
+ val blame: Blame[DerefInsufficientPermission]
+)(implicit val o: Origin)
+ extends LlvmExpr[G] with LlvmLocalImpl[G] {
var ref: Option[Ref[G, Variable[G]]] = None
}
-final case class LlvmAmbiguousFunctionInvocation[G](name: String,
- args: Seq[Expr[G]],
- givenMap: Seq[(Ref[G, Variable[G]], Expr[G])],
- yields: Seq[(Expr[G], Ref[G, Variable[G]])])
- (val blame: Blame[InvocationFailure])(implicit val o: Origin) extends LlvmExpr[G] with LlvmAmbiguousFunctionInvocationImpl[G] {
+final case class LlvmAmbiguousFunctionInvocation[G](
+ name: String,
+ args: Seq[Expr[G]],
+ givenMap: Seq[(Ref[G, Variable[G]], Expr[G])],
+ yields: Seq[(Expr[G], Ref[G, Variable[G]])],
+)(val blame: Blame[InvocationFailure])(implicit val o: Origin)
+ extends LlvmExpr[G] with LlvmAmbiguousFunctionInvocationImpl[G] {
var ref: Option[Ref[G, LlvmCallable[G]]] = None
}
-final class LlvmGlobal[G](val value: String)(implicit val o: Origin) extends GlobalDeclaration[G] with LlvmGlobalImpl[G] {
+final class LlvmGlobal[G](val value: String)(implicit val o: Origin)
+ extends GlobalDeclaration[G] with LlvmGlobalImpl[G] {
var data: Option[Seq[GlobalDeclaration[G]]] = None
}
sealed trait PVLType[G] extends Type[G] with PVLTypeImpl[G]
-final case class PVLNamedType[G](name: String, typeArgs: Seq[Type[G]])(implicit val o: Origin = DiagnosticOrigin) extends PVLType[G] with PVLNamedTypeImpl[G] {
+final case class PVLNamedType[G](name: String, typeArgs: Seq[Type[G]])(
+ implicit val o: Origin = DiagnosticOrigin
+) extends PVLType[G] with PVLNamedTypeImpl[G] {
var ref: Option[PVLTypeNameTarget[G]] = None
}
sealed trait PVLExpr[G] extends Expr[G] with PVLExprImpl[G]
-final case class PVLLocal[G](name: String)(val blame: Blame[DerefInsufficientPermission])(implicit val o: Origin) extends PVLExpr[G] with PVLLocalImpl[G] {
+final case class PVLLocal[G](name: String)(
+ val blame: Blame[DerefInsufficientPermission]
+)(implicit val o: Origin)
+ extends PVLExpr[G] with PVLLocalImpl[G] {
var ref: Option[PVLNameTarget[G]] = None
}
-final case class PVLDeref[G](obj: Expr[G], field: String)(val blame: Blame[FrontendDerefError])(implicit val o: Origin) extends PVLExpr[G] with PVLDerefImpl[G] {
+final case class PVLDeref[G](obj: Expr[G], field: String)(
+ val blame: Blame[FrontendDerefError]
+)(implicit val o: Origin)
+ extends PVLExpr[G] with PVLDerefImpl[G] {
var ref: Option[PVLDerefTarget[G]] = None
}
-final case class PVLInvocation[G](obj: Option[Expr[G]], method: String, args: Seq[Expr[G]], typeArgs: Seq[Type[G]], givenMap: Seq[(Ref[G, Variable[G]], Expr[G])], yields: Seq[(Expr[G], Ref[G, Variable[G]])])(val blame: Blame[FrontendInvocationError])(implicit val o: Origin) extends PVLExpr[G] with PVLInvocationImpl[G] {
+final case class PVLInvocation[G](
+ obj: Option[Expr[G]],
+ method: String,
+ args: Seq[Expr[G]],
+ typeArgs: Seq[Type[G]],
+ givenMap: Seq[(Ref[G, Variable[G]], Expr[G])],
+ yields: Seq[(Expr[G], Ref[G, Variable[G]])],
+)(val blame: Blame[FrontendInvocationError])(implicit val o: Origin)
+ extends PVLExpr[G] with PVLInvocationImpl[G] {
var ref: Option[PVLInvocationTarget[G]] = None
}
-final case class PVLNew[G](t: Type[G], typeArgs: Seq[Type[G]], args: Seq[Expr[G]], givenMap: Seq[(Ref[G, Variable[G]], Expr[G])], yields: Seq[(Expr[G], Ref[G, Variable[G]])])(val blame: Blame[InvocationFailure])(implicit val o: Origin) extends PVLExpr[G] with PVLNewImpl[G] {
+final case class PVLNew[G](
+ t: Type[G],
+ typeArgs: Seq[Type[G]],
+ args: Seq[Expr[G]],
+ givenMap: Seq[(Ref[G, Variable[G]], Expr[G])],
+ yields: Seq[(Expr[G], Ref[G, Variable[G]])],
+)(val blame: Blame[InvocationFailure])(implicit val o: Origin)
+ extends PVLExpr[G] with PVLNewImpl[G] {
var ref: Option[PVLConstructorTarget[G]] = None
}
-sealed trait PVLClassDeclaration[G] extends ClassDeclaration[G] with PVLClassDeclarationImpl[G]
-@scopes[LabelDecl] final class PVLConstructor[G](val contract: ApplicableContract[G], val typeArgs: Seq[Variable[G]], val args: Seq[Variable[G]], val body: Option[Statement[G]])(val blame: Blame[ConstructorFailure])(implicit val o: Origin) extends PVLClassDeclaration[G] with PVLConstructorImpl[G]
-
-final case class TChoreography[G](cls: Ref[G, Choreography[G]])(implicit val o: Origin = DiagnosticOrigin) extends DeclaredType[G] with TChoreographyImpl[G]
-final case class TPVLChoreography[G](cls: Ref[G, PVLChoreography[G]])(implicit val o: Origin = DiagnosticOrigin) extends DeclaredType[G] with TPVLChoreographyImpl[G]
-final case class TEndpoint[G](cls: Ref[G, Endpoint[G]])(implicit val o: Origin = DiagnosticOrigin) extends DeclaredType[G] with TEndpointImpl[G]
-
-final class PVLEndpoint[G](val name: String, val cls: Ref[G, Class[G]], val typeArgs: Seq[Type[G]], val args: Seq[Expr[G]])(val blame: Blame[EndpointFailure])(implicit val o: Origin) extends ClassDeclaration[G] with PVLEndpointImpl[G] {
+sealed trait PVLClassDeclaration[G]
+ extends ClassDeclaration[G] with PVLClassDeclarationImpl[G]
+@scopes[LabelDecl]
+final class PVLConstructor[G](
+ val contract: ApplicableContract[G],
+ val typeArgs: Seq[Variable[G]],
+ val args: Seq[Variable[G]],
+ val body: Option[Statement[G]],
+)(val blame: Blame[ConstructorFailure])(implicit val o: Origin)
+ extends PVLClassDeclaration[G] with PVLConstructorImpl[G]
+
+final case class TChoreography[G](cls: Ref[G, Choreography[G]])(
+ implicit val o: Origin = DiagnosticOrigin
+) extends DeclaredType[G] with TChoreographyImpl[G]
+final case class TPVLChoreography[G](cls: Ref[G, PVLChoreography[G]])(
+ implicit val o: Origin = DiagnosticOrigin
+) extends DeclaredType[G] with TPVLChoreographyImpl[G]
+final case class TEndpoint[G](cls: Ref[G, Endpoint[G]])(
+ implicit val o: Origin = DiagnosticOrigin
+) extends DeclaredType[G] with TEndpointImpl[G]
+
+final class PVLEndpoint[G](
+ val name: String,
+ val cls: Ref[G, Class[G]],
+ val typeArgs: Seq[Type[G]],
+ val args: Seq[Expr[G]],
+)(val blame: Blame[EndpointFailure])(implicit val o: Origin)
+ extends ClassDeclaration[G] with PVLEndpointImpl[G] {
var ref: Option[PVLConstructorTarget[G]] = None
}
-final class PVLChoreography[G](val name: String, val declarations: Seq[ClassDeclaration[G]], val contract: ApplicableContract[G], val args: Seq[Variable[G]])(val blame: Blame[SeqCallableFailure])(implicit val o: Origin) extends GlobalDeclaration[G] with PVLChoreographyImpl[G] with Declarator[G]
-final case class PVLChorRun[G](body: Statement[G], contract: ApplicableContract[G])(val blame: Blame[SeqCallableFailure])(implicit val o: Origin) extends ClassDeclaration[G] with PVLChorRunImpl[G]
+final class PVLChoreography[G](
+ val name: String,
+ val declarations: Seq[ClassDeclaration[G]],
+ val contract: ApplicableContract[G],
+ val args: Seq[Variable[G]],
+)(val blame: Blame[SeqCallableFailure])(implicit val o: Origin)
+ extends GlobalDeclaration[G] with PVLChoreographyImpl[G] with Declarator[G]
+final case class PVLChorRun[G](
+ body: Statement[G],
+ contract: ApplicableContract[G],
+)(val blame: Blame[SeqCallableFailure])(implicit val o: Origin)
+ extends ClassDeclaration[G] with PVLChorRunImpl[G]
-@family case class PVLEndpointName[G](name: String)(implicit val o: Origin) extends PVLEndpointNameImpl[G] with NodeFamily[G] {
+@family
+case class PVLEndpointName[G](name: String)(implicit val o: Origin)
+ extends PVLEndpointNameImpl[G] with NodeFamily[G] {
var ref: Option[RefPVLEndpoint[G]] = None
}
// Resolution of invariant can depend on communicate's target/msg through \sender, \receiver, \msg. Therefore, definitions are nested like this,
// to ensure that PVLCommunicate is fully resolved before the invariant is typechecked.
-final case class PVLChannelInvariant[G](comm: Statement[G], inv: Expr[G])(implicit val o: Origin) extends Statement[G] with PVLChannelInvariantImpl[G]
-final case class PVLCommunicate[G](receiver: Option[PVLEndpointName[G]], target: Expr[G], sender: Option[PVLEndpointName[G]], msg: Expr[G])(val blame: Blame[PVLCommunicateFailure])(implicit val o: Origin) extends Statement[G] with PurelySequentialStatement[G] with PVLCommunicateImpl[G] {
+final case class PVLChannelInvariant[G](comm: Statement[G], inv: Expr[G])(
+ implicit val o: Origin
+) extends Statement[G] with PVLChannelInvariantImpl[G]
+final case class PVLCommunicate[G](
+ receiver: Option[PVLEndpointName[G]],
+ target: Expr[G],
+ sender: Option[PVLEndpointName[G]],
+ msg: Expr[G],
+)(val blame: Blame[PVLCommunicateFailure])(implicit val o: Origin)
+ extends Statement[G]
+ with PurelySequentialStatement[G]
+ with PVLCommunicateImpl[G] {
var inferredSender: Option[PVLEndpoint[G]] = None
var inferredReceiver: Option[PVLEndpoint[G]] = None
}
-final case class PVLChorStatement[G](endpoint: Option[PVLEndpointName[G]], inner: Statement[G])(val blame: Blame[ChorStatementFailure])(implicit val o: Origin) extends Statement[G] with PVLChorStatementImpl[G]
-final case class PVLChorPerm[G](endpoint: PVLEndpointName[G], loc: Location[G], perm: Expr[G])(implicit val o: Origin) extends PVLExpr[G] with PVLChorPermImpl[G]
-final case class PVLSender[G]()(implicit val o: Origin) extends Expr[G] with PVLSenderImpl[G] {
+final case class PVLChorStatement[G](
+ endpoint: Option[PVLEndpointName[G]],
+ inner: Statement[G],
+)(val blame: Blame[ChorStatementFailure])(implicit val o: Origin)
+ extends Statement[G] with PVLChorStatementImpl[G]
+final case class PVLChorPerm[G](
+ endpoint: PVLEndpointName[G],
+ loc: Location[G],
+ perm: Expr[G],
+)(implicit val o: Origin)
+ extends PVLExpr[G] with PVLChorPermImpl[G]
+final case class PVLSender[G]()(implicit val o: Origin)
+ extends Expr[G] with PVLSenderImpl[G] {
var ref: Option[PVLCommunicate[G]] = None
}
-final case class PVLReceiver[G]()(implicit val o: Origin) extends Expr[G] with PVLReceiverImpl[G] {
+final case class PVLReceiver[G]()(implicit val o: Origin)
+ extends Expr[G] with PVLReceiverImpl[G] {
var ref: Option[PVLCommunicate[G]] = None
}
-final case class PVLMessage[G]()(implicit val o: Origin) extends Expr[G] with PVLMessageImpl[G] {
+final case class PVLMessage[G]()(implicit val o: Origin)
+ extends Expr[G] with PVLMessageImpl[G] {
var ref: Option[PVLCommunicate[G]] = None
}
+@family
+final class Endpoint[G](
+ val cls: Ref[G, Class[G]],
+ val typeArgs: Seq[Type[G]],
+ val constructor: Ref[G, Constructor[G]],
+ val args: Seq[Expr[G]],
+)(val blame: Blame[EndpointFailure])(implicit val o: Origin)
+ extends Declaration[G] with EndpointImpl[G]
+@scopes[Endpoint]
+final class Choreography[G](
+ val contract: ApplicableContract[G],
+ val params: Seq[Variable[G]],
+ val endpoints: Seq[Endpoint[G]],
+ val preRun: Option[Statement[G]],
+ val run: ChorRun[G],
+ val decls: Seq[ClassDeclaration[G]],
+)(val blame: Blame[SeqCallableFailure])(implicit val o: Origin)
+ extends GlobalDeclaration[G] with ChoreographyImpl[G]
+@family
+final case class ChorRun[G](
+ body: Statement[G],
+ contract: ApplicableContract[G],
+)(val blame: Blame[SeqCallableFailure])(implicit val o: Origin)
+ extends NodeFamily[G] with ChorRunImpl[G]
-@family final class Endpoint[G](val cls: Ref[G, Class[G]], val typeArgs: Seq[Type[G]], val constructor: Ref[G, Constructor[G]], val args: Seq[Expr[G]])(val blame: Blame[EndpointFailure])(implicit val o: Origin) extends Declaration[G] with EndpointImpl[G]
-@scopes[Endpoint] final class Choreography[G](val contract: ApplicableContract[G], val params : Seq[Variable[G]], val endpoints: Seq[Endpoint[G]], val preRun: Option[Statement[G]], val run: ChorRun[G], val decls: Seq[ClassDeclaration[G]])(val blame: Blame[SeqCallableFailure])(implicit val o: Origin) extends GlobalDeclaration[G] with ChoreographyImpl[G]
-@family final case class ChorRun[G](body: Statement[G], contract: ApplicableContract[G])(val blame: Blame[SeqCallableFailure])(implicit val o: Origin) extends NodeFamily[G] with ChorRunImpl[G]
-
-@family final class Communicate[G](val invariant: Expr[G], val receiver: Option[Ref[G, Endpoint[G]]], val target: Expr[G], val sender: Option[Ref[G, Endpoint[G]]], val msg: Expr[G])(val blame: Blame[CommunicateFailure])(implicit val o: Origin) extends Declaration[G] with CommunicateImpl[G]
-@scopes[Communicate] final case class CommunicateStatement[G](inner: Communicate[G])(implicit val o: Origin) extends PurelySequentialStatement[G] with CommunicateStatementImpl[G]
-
-final case class EndpointName[G](ref: Ref[G, Endpoint[G]])(implicit val o: Origin) extends Expr[G] with EndpointNameImpl[G]
-final case class ChorPerm[G](endpoint: Ref[G, Endpoint[G]], loc: Location[G], perm: Expr[G])(implicit val o: Origin) extends Expr[G] with ChorPermImpl[G]
-final case class Sender[G](ref: Ref[G, Communicate[G]])(implicit val o: Origin) extends Expr[G] with SenderImpl[G]
-final case class Receiver[G](ref: Ref[G, Communicate[G]])(implicit val o: Origin) extends Expr[G] with ReceiverImpl[G]
-final case class Message[G](ref: Ref[G, Communicate[G]])(implicit val o: Origin) extends Expr[G] with MessageImpl[G]
-
-final case class UnresolvedChorBranch[G](branches: Seq[(Expr[G], Statement[G])])(val blame: Blame[SeqBranchFailure])(implicit val o: Origin) extends Statement[G] with ControlContainerStatement[G] with UnresolvedChorBranchImpl[G]
-final case class UnresolvedChorLoop[G](cond: Expr[G], contract: LoopContract[G], body: Statement[G])(val blame: Blame[SeqLoopFailure])(implicit val o: Origin) extends Statement[G] with ControlContainerStatement[G] with UnresolvedChorLoopImpl[G]
-
-final case class ChorStatement[G](endpoint: Option[Ref[G, Endpoint[G]]], inner: Statement[G])(val blame: Blame[ChorStatementFailure])(implicit val o: Origin) extends Statement[G] with ChorStatementImpl[G]
-
-@family sealed trait ChorGuard[G] extends NodeFamily[G] with ChorGuardImpl[G]
-final case class EndpointGuard[G](endpoint: Ref[G, Endpoint[G]], condition: Expr[G])(implicit val o: Origin) extends ChorGuard[G] with EndpointGuardImpl[G]
-final case class UnpointedGuard[G](condition: Expr[G])(implicit val o: Origin) extends ChorGuard[G] with UnpointedGuardImpl[G]
-
-final case class ChorBranch[G](guards: Seq[ChorGuard[G]], yes: Statement[G], no: Option[Statement[G]])(val blame: Blame[SeqBranchFailure])(implicit val o: Origin) extends Statement[G] with ControlContainerStatement[G] with ChorBranchImpl[G]
-final case class ChorLoop[G](guards: Seq[ChorGuard[G]], contract: LoopContract[G], body: Statement[G])(val blame: Blame[SeqLoopFailure])(implicit val o: Origin) extends Statement[G] with ControlContainerStatement[G] with ChorLoopImpl[G]
+@family
+final class Communicate[G](
+ val invariant: Expr[G],
+ val receiver: Option[Ref[G, Endpoint[G]]],
+ val target: Expr[G],
+ val sender: Option[Ref[G, Endpoint[G]]],
+ val msg: Expr[G],
+)(val blame: Blame[CommunicateFailure])(implicit val o: Origin)
+ extends Declaration[G] with CommunicateImpl[G]
+@scopes[Communicate]
+final case class CommunicateStatement[G](inner: Communicate[G])(
+ implicit val o: Origin
+) extends PurelySequentialStatement[G] with CommunicateStatementImpl[G]
+
+final case class EndpointName[G](ref: Ref[G, Endpoint[G]])(
+ implicit val o: Origin
+) extends Expr[G] with EndpointNameImpl[G]
+final case class ChorPerm[G](
+ endpoint: Ref[G, Endpoint[G]],
+ loc: Location[G],
+ perm: Expr[G],
+)(implicit val o: Origin)
+ extends Expr[G] with ChorPermImpl[G]
+final case class Sender[G](ref: Ref[G, Communicate[G]])(implicit val o: Origin)
+ extends Expr[G] with SenderImpl[G]
+final case class Receiver[G](ref: Ref[G, Communicate[G]])(
+ implicit val o: Origin
+) extends Expr[G] with ReceiverImpl[G]
+final case class Message[G](ref: Ref[G, Communicate[G]])(implicit val o: Origin)
+ extends Expr[G] with MessageImpl[G]
+
+final case class UnresolvedChorBranch[G](
+ branches: Seq[(Expr[G], Statement[G])]
+)(val blame: Blame[SeqBranchFailure])(implicit val o: Origin)
+ extends Statement[G]
+ with ControlContainerStatement[G]
+ with UnresolvedChorBranchImpl[G]
+final case class UnresolvedChorLoop[G](
+ cond: Expr[G],
+ contract: LoopContract[G],
+ body: Statement[G],
+)(val blame: Blame[SeqLoopFailure])(implicit val o: Origin)
+ extends Statement[G]
+ with ControlContainerStatement[G]
+ with UnresolvedChorLoopImpl[G]
+
+final case class ChorStatement[G](
+ endpoint: Option[Ref[G, Endpoint[G]]],
+ inner: Statement[G],
+)(val blame: Blame[ChorStatementFailure])(implicit val o: Origin)
+ extends Statement[G] with ChorStatementImpl[G]
-final case class VeyMontAssignExpression[G](endpoint: Ref[G, Endpoint[G]], assign: Statement[G])(implicit val o: Origin) extends Statement[G] with ControlContainerStatement[G] with VeyMontAssignExpressionImpl[G]
-final case class CommunicateX[G](receiver: Ref[G, Endpoint[G]], sender: Ref[G, Endpoint[G]], chanType: Type[G], assign: Statement[G])(implicit val o: Origin) extends Statement[G] with ControlContainerStatement[G] with CommunicateXImpl[G]
+@family
+sealed trait ChorGuard[G] extends NodeFamily[G] with ChorGuardImpl[G]
+final case class EndpointGuard[G](
+ endpoint: Ref[G, Endpoint[G]],
+ condition: Expr[G],
+)(implicit val o: Origin)
+ extends ChorGuard[G] with EndpointGuardImpl[G]
+final case class UnpointedGuard[G](condition: Expr[G])(implicit val o: Origin)
+ extends ChorGuard[G] with UnpointedGuardImpl[G]
+
+final case class ChorBranch[G](
+ guards: Seq[ChorGuard[G]],
+ yes: Statement[G],
+ no: Option[Statement[G]],
+)(val blame: Blame[SeqBranchFailure])(implicit val o: Origin)
+ extends Statement[G]
+ with ControlContainerStatement[G]
+ with ChorBranchImpl[G]
+final case class ChorLoop[G](
+ guards: Seq[ChorGuard[G]],
+ contract: LoopContract[G],
+ body: Statement[G],
+)(val blame: Blame[SeqLoopFailure])(implicit val o: Origin)
+ extends Statement[G] with ControlContainerStatement[G] with ChorLoopImpl[G]
+
+final case class VeyMontAssignExpression[G](
+ endpoint: Ref[G, Endpoint[G]],
+ assign: Statement[G],
+)(implicit val o: Origin)
+ extends Statement[G]
+ with ControlContainerStatement[G]
+ with VeyMontAssignExpressionImpl[G]
+final case class CommunicateX[G](
+ receiver: Ref[G, Endpoint[G]],
+ sender: Ref[G, Endpoint[G]],
+ chanType: Type[G],
+ assign: Statement[G],
+)(implicit val o: Origin)
+ extends Statement[G]
+ with ControlContainerStatement[G]
+ with CommunicateXImpl[G]
sealed trait SilverExpr[G] extends Expr[G] with SilverExprImpl[G]
-final case class SilverDeref[G](obj: Expr[G], field: Ref[G, SilverField[G]])(val blame: Blame[InsufficientPermission])(implicit val o: Origin) extends SilverExpr[G] with HeapDeref[G] with SilverDerefImpl[G]
-final case class SilverIntToRat[G](perm: Expr[G])(implicit val o: Origin) extends SilverExpr[G] with SilverIntToRatImpl[G]
-final case class SilverNull[G]()(implicit val o: Origin) extends SilverExpr[G] with SilverNullImpl[G]
-final case class SilverSeqSize[G](seq: Expr[G])(implicit val o: Origin) extends SilverExpr[G] with SilverSeqSizeImpl[G]
-final case class SilverSetSize[G](set: Expr[G])(implicit val o: Origin) extends SilverExpr[G] with SilverSetSizeImpl[G]
-final case class SilverBagSize[G](bag: Expr[G])(implicit val o: Origin) extends SilverExpr[G] with SilverBagSizeImpl[G]
-final case class SilverMapSize[G](map: Expr[G])(implicit val o: Origin) extends SilverExpr[G] with SilverMapSizeImpl[G]
-
-final case class SilverCurFieldPerm[G](obj: Expr[G], field: Ref[G, SilverField[G]])(implicit val o: Origin) extends SilverExpr[G] with SilverCurFieldPermImpl[G]
-final case class SilverCurPredPerm[G](ref: Ref[G, Predicate[G]], args: Seq[Expr[G]])(implicit val o: Origin) extends SilverExpr[G] with SilverCurPredPermImpl[G]
-
-final case class SilverPartialADTFunctionInvocation[G](name: String, args: Seq[Expr[G]], partialTypeArgs: Seq[(Ref[G, Variable[G]], Type[G])])(implicit val o: Origin) extends SilverExpr[G] with SilverPartialADTFunctionInvocationImpl[G] {
+final case class SilverDeref[G](obj: Expr[G], field: Ref[G, SilverField[G]])(
+ val blame: Blame[InsufficientPermission]
+)(implicit val o: Origin)
+ extends SilverExpr[G] with HeapDeref[G] with SilverDerefImpl[G]
+final case class SilverIntToRat[G](perm: Expr[G])(implicit val o: Origin)
+ extends SilverExpr[G] with SilverIntToRatImpl[G]
+final case class SilverNull[G]()(implicit val o: Origin)
+ extends SilverExpr[G] with SilverNullImpl[G]
+final case class SilverSeqSize[G](seq: Expr[G])(implicit val o: Origin)
+ extends SilverExpr[G] with SilverSeqSizeImpl[G]
+final case class SilverSetSize[G](set: Expr[G])(implicit val o: Origin)
+ extends SilverExpr[G] with SilverSetSizeImpl[G]
+final case class SilverBagSize[G](bag: Expr[G])(implicit val o: Origin)
+ extends SilverExpr[G] with SilverBagSizeImpl[G]
+final case class SilverMapSize[G](map: Expr[G])(implicit val o: Origin)
+ extends SilverExpr[G] with SilverMapSizeImpl[G]
+
+final case class SilverCurFieldPerm[G](
+ obj: Expr[G],
+ field: Ref[G, SilverField[G]],
+)(implicit val o: Origin)
+ extends SilverExpr[G] with SilverCurFieldPermImpl[G]
+final case class SilverCurPredPerm[G](
+ ref: Ref[G, Predicate[G]],
+ args: Seq[Expr[G]],
+)(implicit val o: Origin)
+ extends SilverExpr[G] with SilverCurPredPermImpl[G]
+
+final case class SilverPartialADTFunctionInvocation[G](
+ name: String,
+ args: Seq[Expr[G]],
+ partialTypeArgs: Seq[(Ref[G, Variable[G]], Type[G])],
+)(implicit val o: Origin)
+ extends SilverExpr[G] with SilverPartialADTFunctionInvocationImpl[G] {
var ref: Option[(AxiomaticDataType[G], ADTFunction[G])] = None
}
-final case class SilverUntypedNonemptyLiteralMap[G](values: Seq[(Expr[G], Expr[G])])(implicit val o: Origin) extends SilverExpr[G] with SilverUntypedNonemptyLiteralMapImpl[G]
+final case class SilverUntypedNonemptyLiteralMap[G](
+ values: Seq[(Expr[G], Expr[G])]
+)(implicit val o: Origin)
+ extends SilverExpr[G] with SilverUntypedNonemptyLiteralMapImpl[G]
sealed trait SilverStatement[G] extends Statement[G] with SilverStatementImpl[G]
-final case class SilverNewRef[G](v: Ref[G, Variable[G]], fields: Seq[Ref[G, SilverField[G]]])(implicit val o: Origin) extends SilverStatement[G] with PurelySequentialStatement[G] with SilverNewRefImpl[G]
+final case class SilverNewRef[G](
+ v: Ref[G, Variable[G]],
+ fields: Seq[Ref[G, SilverField[G]]],
+)(implicit val o: Origin)
+ extends SilverStatement[G]
+ with PurelySequentialStatement[G]
+ with SilverNewRefImpl[G]
sealed trait SilverAssign[G] extends SilverStatement[G] with SilverAssignImpl[G]
-final case class SilverFieldAssign[G](obj: Expr[G], field: Ref[G, SilverField[G]], value: Expr[G])(val blame: Blame[AssignFailed])(implicit val o: Origin) extends SilverAssign[G] with ExpressionContainerStatement[G] with SilverFieldAssignImpl[G]
-final case class SilverLocalAssign[G](v: Ref[G, Variable[G]], value: Expr[G])(implicit val o: Origin) extends SilverAssign[G] with ExpressionContainerStatement[G] with SilverLocalAssignImpl[G]
-
-sealed trait SilverDeclaration[G] extends GlobalDeclaration[G] with SilverDeclarationImpl[G]
-final class SilverField[G](val t: Type[G])(implicit val o: Origin) extends SilverDeclaration[G] with SilverFieldImpl[G]
+final case class SilverFieldAssign[G](
+ obj: Expr[G],
+ field: Ref[G, SilverField[G]],
+ value: Expr[G],
+)(val blame: Blame[AssignFailed])(implicit val o: Origin)
+ extends SilverAssign[G]
+ with ExpressionContainerStatement[G]
+ with SilverFieldAssignImpl[G]
+final case class SilverLocalAssign[G](v: Ref[G, Variable[G]], value: Expr[G])(
+ implicit val o: Origin
+) extends SilverAssign[G]
+ with ExpressionContainerStatement[G]
+ with SilverLocalAssignImpl[G]
+
+sealed trait SilverDeclaration[G]
+ extends GlobalDeclaration[G] with SilverDeclarationImpl[G]
+final class SilverField[G](val t: Type[G])(implicit val o: Origin)
+ extends SilverDeclaration[G] with SilverFieldImpl[G]
sealed trait SilverType[G] extends Type[G] with SilverTypeImpl[G]
-case class SilverPartialTAxiomatic[G](ref: Ref[G, AxiomaticDataType[G]], partialTypeArgs: Seq[(Ref[G, Variable[G]], Type[G])])(implicit val o: Origin = DiagnosticOrigin) extends SilverType[G] with SilverPartialTAxiomaticImpl[G]
\ No newline at end of file
+case class SilverPartialTAxiomatic[G](
+ ref: Ref[G, AxiomaticDataType[G]],
+ partialTypeArgs: Seq[(Ref[G, Variable[G]], Type[G])],
+)(implicit val o: Origin = DiagnosticOrigin)
+ extends SilverType[G] with SilverPartialTAxiomaticImpl[G]
diff --git a/src/col/vct/col/ast/Serialize.scala b/src/col/vct/col/ast/Serialize.scala
index eb0fc14897..3e907c0e3b 100644
--- a/src/col/vct/col/ast/Serialize.scala
+++ b/src/col/vct/col/ast/Serialize.scala
@@ -2,11 +2,10 @@ package vct.col.ast
object Serialize {
def serialize[G](x: Program[G]): vct.col.ast.serialize.Program = {
- val declarations = x.collect {
- case decl: Declaration[G] => decl
- }.zipWithIndex.map {
- case (decl, id) => decl -> id.toLong
- }.toMap
+ val declarations =
+ x.collect { case decl: Declaration[G] => decl }.zipWithIndex.map {
+ case (decl, id) => decl -> id.toLong
+ }.toMap
x.serializeFamily(declarations)
}
diff --git a/src/col/vct/col/ast/declaration/DeclarationImpl.scala b/src/col/vct/col/ast/declaration/DeclarationImpl.scala
index 0a93d649de..1e1ac5f73c 100644
--- a/src/col/vct/col/ast/declaration/DeclarationImpl.scala
+++ b/src/col/vct/col/ast/declaration/DeclarationImpl.scala
@@ -2,7 +2,13 @@ package vct.col.ast.declaration
import vct.col.ast.node.NodeImpl
import vct.col.ast.{AbstractRewriter, Declaration}
-import vct.col.check.{CheckContext, CheckError, TypeError, TypeErrorExplanation, TypeErrorText}
+import vct.col.check.{
+ CheckContext,
+ CheckError,
+ TypeError,
+ TypeErrorExplanation,
+ TypeErrorText,
+}
import vct.col.debug.{DebugRewriteState, Dropped, NotProcessed}
import vct.col.ref.{DirectRef, Ref}
import vct.col.rewrite.InitialGeneration
@@ -10,30 +16,40 @@ import vct.col.typerules.{CoercingRewriter, NopCoercingRewriter}
import scala.reflect.ClassTag
-trait DeclarationImpl[G] extends NodeImpl[G] { this: Declaration[G] =>
+trait DeclarationImpl[G] extends NodeImpl[G] {
+ this: Declaration[G] =>
var debugRewriteState: DebugRewriteState = NotProcessed
def drop(): Unit = debugRewriteState = Dropped
- def rewriteDefault[G1]()(implicit rw: AbstractRewriter[G, G1]): Declaration[G1]
+ def rewriteDefault[G1]()(
+ implicit rw: AbstractRewriter[G, G1]
+ ): Declaration[G1]
- /**
- * Create a Ref to this declaration. This is often useful in a place where the type of the ref can be directly
- * inferred, e.g. `FunctionInvocation(func.ref, ...)`. The witness to `this.type <:< T` demands that the
- * inferred T at least supports the type of this declaration.
+ /** Create a Ref to this declaration. This is often useful in a place where
+ * the type of the ref can be directly inferred, e.g.
+ * `FunctionInvocation(func.ref, ...)`. The witness to `this.type <:< T`
+ * demands that the inferred T at least supports the type of this
+ * declaration.
*/
- def ref[Decl <: Declaration[G]](implicit tag: ClassTag[Decl], witness: this.type <:< Decl): Ref[G, Decl] = new DirectRef[G, Decl](this)
+ def ref[Decl <: Declaration[G]](
+ implicit tag: ClassTag[Decl],
+ witness: this.type <:< Decl,
+ ): Ref[G, Decl] = new DirectRef[G, Decl](this)
override def check(context: CheckContext[G]): Seq[CheckError] =
try {
- NopCoercingRewriter().coerce(this.asInstanceOf[Declaration[InitialGeneration]])
+ NopCoercingRewriter()
+ .coerce(this.asInstanceOf[Declaration[InitialGeneration]])
Nil
} catch {
case CoercingRewriter.Incoercible(e, t) => Seq(TypeError(e, t))
case CoercingRewriter.IncoercibleText(e, m) => Seq(TypeErrorText(e, m))
- case CoercingRewriter.IncoercibleExplanation(e, m) => Seq(TypeErrorExplanation(e, m))
+ case CoercingRewriter.IncoercibleExplanation(e, m) =>
+ Seq(TypeErrorExplanation(e, m))
}
- override def enterCheckContextDeclarationStack(context: CheckContext[G]): Seq[Declaration[G]] =
- this +: context.declarationStack
-}
\ No newline at end of file
+ override def enterCheckContextDeclarationStack(
+ context: CheckContext[G]
+ ): Seq[Declaration[G]] = this +: context.declarationStack
+}
diff --git a/src/col/vct/col/ast/declaration/adt/ADTAxiomImpl.scala b/src/col/vct/col/ast/declaration/adt/ADTAxiomImpl.scala
index 0d92951f3b..51bd429bb7 100644
--- a/src/col/vct/col/ast/declaration/adt/ADTAxiomImpl.scala
+++ b/src/col/vct/col/ast/declaration/adt/ADTAxiomImpl.scala
@@ -5,11 +5,14 @@ import vct.col.check.{CheckContext, CheckError}
import vct.col.print._
import vct.col.ast.ops.ADTAxiomOps
-trait ADTAxiomImpl[G] extends ADTAxiomOps[G] { this: ADTAxiom[G] =>
- override def check(context: CheckContext[G]): Seq[CheckError] = axiom.checkSubType(TBool())
+trait ADTAxiomImpl[G] extends ADTAxiomOps[G] {
+ this: ADTAxiom[G] =>
+ override def check(context: CheckContext[G]): Seq[CheckError] =
+ axiom.checkSubType(TBool())
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.Silver => Group(Text("axiom") <+> "{" <>> axiom.show <+/> "}")
- case _ => Text("axiom") <+> axiom <> ";"
- }
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.Silver => Group(Text("axiom") <+> "{" <>> axiom.show <+/> "}")
+ case _ => Text("axiom") <+> axiom <> ";"
+ }
+}
diff --git a/src/col/vct/col/ast/declaration/adt/ADTDeclarationImpl.scala b/src/col/vct/col/ast/declaration/adt/ADTDeclarationImpl.scala
index f8d69f2320..ff40cb5b46 100644
--- a/src/col/vct/col/ast/declaration/adt/ADTDeclarationImpl.scala
+++ b/src/col/vct/col/ast/declaration/adt/ADTDeclarationImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.declaration.adt
import vct.col.ast.ADTDeclaration
import vct.col.ast.ops.ADTDeclarationFamilyOps
-trait ADTDeclarationImpl[G] extends ADTDeclarationFamilyOps[G] { this: ADTDeclaration[G] =>
+trait ADTDeclarationImpl[G] extends ADTDeclarationFamilyOps[G] {
+ this: ADTDeclaration[G] =>
}
diff --git a/src/col/vct/col/ast/declaration/adt/ADTFunctionImpl.scala b/src/col/vct/col/ast/declaration/adt/ADTFunctionImpl.scala
index 4eae9a2ccf..4cb1e0273b 100644
--- a/src/col/vct/col/ast/declaration/adt/ADTFunctionImpl.scala
+++ b/src/col/vct/col/ast/declaration/adt/ADTFunctionImpl.scala
@@ -5,11 +5,24 @@ import vct.col.ast.{ADTFunction, Node}
import vct.col.print._
import vct.col.ast.ops.ADTFunctionOps
-trait ADTFunctionImpl[G] extends ApplicableImpl[G] with ADTDeclarationImpl[G] with ADTFunctionOps[G] { this: ADTFunction[G] =>
+trait ADTFunctionImpl[G]
+ extends ApplicableImpl[G]
+ with ADTDeclarationImpl[G]
+ with ADTFunctionOps[G] {
+ this: ADTFunction[G] =>
override def body: Option[Node[G]] = None
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.Silver => Group(Text("function") <+> ctx.name(this) <> "(" <> Doc.args(args) <> "):" <+> returnType)
- case _ => Group(Text("pure") <+> returnType <+> ctx.name (this) <> "(" <> Doc.args(args) <> ");")
- }
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.Silver =>
+ Group(
+ Text("function") <+> ctx.name(this) <> "(" <> Doc.args(args) <>
+ "):" <+> returnType
+ )
+ case _ =>
+ Group(
+ Text("pure") <+> returnType <+> ctx.name(this) <> "(" <>
+ Doc.args(args) <> ");"
+ )
+ }
+}
diff --git a/src/col/vct/col/ast/declaration/category/AbstractFunctionImpl.scala b/src/col/vct/col/ast/declaration/category/AbstractFunctionImpl.scala
index f1084e30e3..80e7dc8aca 100644
--- a/src/col/vct/col/ast/declaration/category/AbstractFunctionImpl.scala
+++ b/src/col/vct/col/ast/declaration/category/AbstractFunctionImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{AbstractFunction, Expr}
import vct.col.check.{CheckContext, CheckError}
import vct.col.origin.{Blame, ContractedFailure}
-trait AbstractFunctionImpl[G] extends ContractApplicableImpl[G] { this: AbstractFunction[G] =>
+trait AbstractFunctionImpl[G] extends ContractApplicableImpl[G] {
+ this: AbstractFunction[G] =>
override def body: Option[Expr[G]]
def threadLocal: Boolean
override def check(context: CheckContext[G]): Seq[CheckError] =
diff --git a/src/col/vct/col/ast/declaration/category/AbstractMethodImpl.scala b/src/col/vct/col/ast/declaration/category/AbstractMethodImpl.scala
index b81c8238da..63b7b6fa9f 100644
--- a/src/col/vct/col/ast/declaration/category/AbstractMethodImpl.scala
+++ b/src/col/vct/col/ast/declaration/category/AbstractMethodImpl.scala
@@ -1,10 +1,19 @@
package vct.col.ast.declaration.category
-import vct.col.ast.{AbstractMethod, Declaration, LabelDecl, LocalDecl, Return, Statement, Variable}
+import vct.col.ast.{
+ AbstractMethod,
+ Declaration,
+ LabelDecl,
+ LocalDecl,
+ Return,
+ Statement,
+ Variable,
+}
import vct.col.check.{CheckContext, CheckError}
import vct.col.origin.{Blame, CallableFailure}
-trait AbstractMethodImpl[G] extends ContractApplicableImpl[G] { this: AbstractMethod[G] =>
+trait AbstractMethodImpl[G] extends ContractApplicableImpl[G] {
+ this: AbstractMethod[G] =>
override def body: Option[Statement[G]]
override def blame: Blame[CallableFailure]
def outArgs: Seq[Variable[G]]
diff --git a/src/col/vct/col/ast/declaration/category/AbstractPredicateImpl.scala b/src/col/vct/col/ast/declaration/category/AbstractPredicateImpl.scala
index ff8322c406..0aa92c8b1f 100644
--- a/src/col/vct/col/ast/declaration/category/AbstractPredicateImpl.scala
+++ b/src/col/vct/col/ast/declaration/category/AbstractPredicateImpl.scala
@@ -2,7 +2,8 @@ package vct.col.ast.declaration.category
import vct.col.ast.{AbstractPredicate, TResource, Type}
-trait AbstractPredicateImpl[G] extends InlineableApplicableImpl[G] { this: AbstractPredicate[G] =>
+trait AbstractPredicateImpl[G] extends InlineableApplicableImpl[G] {
+ this: AbstractPredicate[G] =>
def threadLocal: Boolean
override def returnType: Type[G] = TResource()
}
diff --git a/src/col/vct/col/ast/declaration/category/ApplicableImpl.scala b/src/col/vct/col/ast/declaration/category/ApplicableImpl.scala
index adee5539de..f526d451b9 100644
--- a/src/col/vct/col/ast/declaration/category/ApplicableImpl.scala
+++ b/src/col/vct/col/ast/declaration/category/ApplicableImpl.scala
@@ -5,12 +5,15 @@ import vct.col.ast.util.Declarator
import vct.col.ast.{Applicable, Declaration, Node, Type, Variable}
import vct.col.check.CheckContext
-trait ApplicableImpl[G] extends DeclarationImpl[G] with Declarator[G] { this: Applicable[G] =>
+trait ApplicableImpl[G] extends DeclarationImpl[G] with Declarator[G] {
+ this: Applicable[G] =>
def args: Seq[Variable[G]]
def returnType: Type[G]
def body: Option[Node[G]]
override def declarations: Seq[Declaration[G]] = args
- override def enterCheckContextCurrentApplicable(context: CheckContext[G]): Option[Applicable[G]] = Some(this)
+ override def enterCheckContextCurrentApplicable(
+ context: CheckContext[G]
+ ): Option[Applicable[G]] = Some(this)
}
diff --git a/src/col/vct/col/ast/declaration/category/ContractApplicableImpl.scala b/src/col/vct/col/ast/declaration/category/ContractApplicableImpl.scala
index 694a4255af..d7c31d2747 100644
--- a/src/col/vct/col/ast/declaration/category/ContractApplicableImpl.scala
+++ b/src/col/vct/col/ast/declaration/category/ContractApplicableImpl.scala
@@ -1,10 +1,16 @@
package vct.col.ast.declaration.category
import vct.col.ast.util.Declarator
-import vct.col.ast.{ApplicableContract, ContractApplicable, Declaration, Variable}
+import vct.col.ast.{
+ ApplicableContract,
+ ContractApplicable,
+ Declaration,
+ Variable,
+}
import vct.col.origin.{Blame, ContractedFailure, PostconditionFailed}
-trait ContractApplicableImpl[G] extends InlineableApplicableImpl[G] { this: ContractApplicable[G] =>
+trait ContractApplicableImpl[G] extends InlineableApplicableImpl[G] {
+ this: ContractApplicable[G] =>
def contract: ApplicableContract[G]
def blame: Blame[ContractedFailure]
override def declarations: Seq[Declaration[G]] =
diff --git a/src/col/vct/col/ast/declaration/category/FieldImpl.scala b/src/col/vct/col/ast/declaration/category/FieldImpl.scala
index 72de022c81..fc0809bef0 100644
--- a/src/col/vct/col/ast/declaration/category/FieldImpl.scala
+++ b/src/col/vct/col/ast/declaration/category/FieldImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.declaration.category
import vct.col.ast.{Field, Type}
-trait FieldImpl[G] { this: Field[G] =>
+trait FieldImpl[G] {
+ this: Field[G] =>
def t: Type[G]
}
diff --git a/src/col/vct/col/ast/declaration/category/InlineableApplicableImpl.scala b/src/col/vct/col/ast/declaration/category/InlineableApplicableImpl.scala
index 40a80b42eb..6109259ffe 100644
--- a/src/col/vct/col/ast/declaration/category/InlineableApplicableImpl.scala
+++ b/src/col/vct/col/ast/declaration/category/InlineableApplicableImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.declaration.category
import vct.col.ast.InlineableApplicable
-trait InlineableApplicableImpl[G] extends ApplicableImpl[G] { this: InlineableApplicable[G] =>
+trait InlineableApplicableImpl[G] extends ApplicableImpl[G] {
+ this: InlineableApplicable[G] =>
def inline: Boolean
}
diff --git a/src/col/vct/col/ast/declaration/cls/BipComponentImpl.scala b/src/col/vct/col/ast/declaration/cls/BipComponentImpl.scala
index 3d96e6502f..8b3bb83ed1 100644
--- a/src/col/vct/col/ast/declaration/cls/BipComponentImpl.scala
+++ b/src/col/vct/col/ast/declaration/cls/BipComponentImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.BipComponent
import vct.col.print._
import vct.col.ast.ops.BipComponentOps
-trait BipComponentImpl[G] extends BipComponentOps[G] { this: BipComponent[G] =>
+trait BipComponentImpl[G] extends BipComponentOps[G] {
+ this: BipComponent[G] =>
override def layout(implicit ctx: Ctx): Doc =
Doc.stack(Seq(
Text("/*"),
diff --git a/src/col/vct/col/ast/declaration/cls/BipConstructorImpl.scala b/src/col/vct/col/ast/declaration/cls/BipConstructorImpl.scala
index d823a7b585..16486a91c4 100644
--- a/src/col/vct/col/ast/declaration/cls/BipConstructorImpl.scala
+++ b/src/col/vct/col/ast/declaration/cls/BipConstructorImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.declaration.cls
import vct.col.ast.{BipConstructor, Declaration, Type, Variable}
import vct.col.ast.ops.BipConstructorOps
-trait BipConstructorImpl[G] extends BipConstructorOps[G] { this: BipConstructor[G] =>
+trait BipConstructorImpl[G] extends BipConstructorOps[G] {
+ this: BipConstructor[G] =>
override def declarations: Seq[Declaration[G]] = args
}
diff --git a/src/col/vct/col/ast/declaration/cls/BipDataImpl.scala b/src/col/vct/col/ast/declaration/cls/BipDataImpl.scala
index 67d069e9af..e725faf46b 100644
--- a/src/col/vct/col/ast/declaration/cls/BipDataImpl.scala
+++ b/src/col/vct/col/ast/declaration/cls/BipDataImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.declaration.cls
import vct.col.ast.{BipData, Type}
-trait BipDataImpl[G] { this: BipData[G] =>
+trait BipDataImpl[G] {
+ this: BipData[G] =>
def t: Type[G]
}
diff --git a/src/col/vct/col/ast/declaration/cls/BipGuardImpl.scala b/src/col/vct/col/ast/declaration/cls/BipGuardImpl.scala
index 3d05d99a01..c3ce93c216 100644
--- a/src/col/vct/col/ast/declaration/cls/BipGuardImpl.scala
+++ b/src/col/vct/col/ast/declaration/cls/BipGuardImpl.scala
@@ -4,11 +4,15 @@ import vct.col.ast.BipGuard
import vct.col.print.{Ctx, Doc, Group, Text, Empty}
import vct.col.ast.ops.BipGuardOps
-trait BipGuardImpl[G] extends BipGuardOps[G] { this: BipGuard[G] =>
+trait BipGuardImpl[G] extends BipGuardOps[G] {
+ this: BipGuard[G] =>
override def layout(implicit ctx: Ctx): Doc =
Doc.stack(Seq(
- if(pure) Text("@Pure") else Empty,
+ if (pure)
+ Text("@Pure")
+ else
+ Empty,
Text("@Guard(name =") <+> ctx.name(this) <> ")",
- Text("public boolean") <+> ctx.name(this) <> "()" <+> body.layoutAsBlock
+ Text("public boolean") <+> ctx.name(this) <> "()" <+> body.layoutAsBlock,
))
}
diff --git a/src/col/vct/col/ast/declaration/cls/BipPortImpl.scala b/src/col/vct/col/ast/declaration/cls/BipPortImpl.scala
index c683edbd59..8e15fc18a8 100644
--- a/src/col/vct/col/ast/declaration/cls/BipPortImpl.scala
+++ b/src/col/vct/col/ast/declaration/cls/BipPortImpl.scala
@@ -4,11 +4,10 @@ import vct.col.ast.BipPort
import vct.col.print._
import vct.col.ast.ops.BipPortOps
-trait BipPortImpl[G] extends BipPortOps[G] { this: BipPort[G] =>
+trait BipPortImpl[G] extends BipPortOps[G] {
+ this: BipPort[G] =>
override def layout(implicit ctx: Ctx): Doc =
- Doc.stack(Seq(
- Text("/*"),
- t.show <+> "javaBipPort" <+> ctx.name(this),
- Text("*/"),
- ))
+ Doc.stack(
+ Seq(Text("/*"), t.show <+> "javaBipPort" <+> ctx.name(this), Text("*/"))
+ )
}
diff --git a/src/col/vct/col/ast/declaration/cls/BipStatePredicateImpl.scala b/src/col/vct/col/ast/declaration/cls/BipStatePredicateImpl.scala
index 050361b6f2..47a3049902 100644
--- a/src/col/vct/col/ast/declaration/cls/BipStatePredicateImpl.scala
+++ b/src/col/vct/col/ast/declaration/cls/BipStatePredicateImpl.scala
@@ -4,7 +4,10 @@ import vct.col.ast.BipStatePredicate
import vct.col.print.{Ctx, Doc, Text, Group}
import vct.col.ast.ops.BipStatePredicateOps
-trait BipStatePredicateImpl[G] extends BipStatePredicateOps[G] { this: BipStatePredicate[G] =>
+trait BipStatePredicateImpl[G] extends BipStatePredicateOps[G] {
+ this: BipStatePredicate[G] =>
override def layout(implicit ctx: Ctx): Doc =
- Group(Text("javaBipStatePredicate") <+> ctx.name(this) <+> "{" <>> expr <+/> "}")
+ Group(
+ Text("javaBipStatePredicate") <+> ctx.name(this) <+> "{" <>> expr <+/> "}"
+ )
}
diff --git a/src/col/vct/col/ast/declaration/cls/BipTransitionImpl.scala b/src/col/vct/col/ast/declaration/cls/BipTransitionImpl.scala
index 8c5320ed5b..a89f79b557 100644
--- a/src/col/vct/col/ast/declaration/cls/BipTransitionImpl.scala
+++ b/src/col/vct/col/ast/declaration/cls/BipTransitionImpl.scala
@@ -7,21 +7,29 @@ import vct.col.util.AstBuildHelpers.tt
import scala.util.Try
import vct.col.ast.ops.BipTransitionOps
-trait BipTransitionImpl[G] extends BipTransitionOps[G] { this: BipTransition[G] =>
+trait BipTransitionImpl[G] extends BipTransitionOps[G] {
+ this: BipTransition[G] =>
def layoutAnnotation(implicit ctx: Ctx): Doc =
- Group(Text("@Transition(") <> Doc.args(Seq(
- Text("name =") <+> ctx.name(this),
- Text("source =") <+> ctx.name(source),
- Text("target =") <+> ctx.name(target),
- if (requires == tt[G]) Empty else Text("requires =") <+> requires,
- )) <> ")")
+ Group(
+ Text("@Transition(") <> Doc.args(Seq(
+ Text("name =") <+> ctx.name(this),
+ Text("source =") <+> ctx.name(source),
+ Text("target =") <+> ctx.name(target),
+ if (requires == tt[G])
+ Empty
+ else
+ Text("requires =") <+> requires,
+ )) <> ")"
+ )
def layoutArgs(implicit ctx: Ctx): Doc =
Doc.args(data.map { name =>
- Text("@Data(name =") <+> ctx.name(name) <> ")" <+> Try(name.decl.t).getOrElse(Text("?brokenref?")) <+> ctx.name(name)
+ Text("@Data(name =") <+> ctx.name(name) <> ")" <+> Try(name.decl.t)
+ .getOrElse(Text("?brokenref?")) <+> ctx.name(name)
})
override def layout(implicit ctx: Ctx): Doc =
- layoutAnnotation >
- Group(Text("public void") <+> ctx.name(this) <> "(" <> layoutArgs <> ")") <+> body.layoutAsBlock
-}
\ No newline at end of file
+ layoutAnnotation > Group(
+ Text("public void") <+> ctx.name(this) <> "(" <> layoutArgs <> ")"
+ ) <+> body.layoutAsBlock
+}
diff --git a/src/col/vct/col/ast/declaration/cls/ClassDeclarationImpl.scala b/src/col/vct/col/ast/declaration/cls/ClassDeclarationImpl.scala
index 50fafba2b7..62e939ee09 100644
--- a/src/col/vct/col/ast/declaration/cls/ClassDeclarationImpl.scala
+++ b/src/col/vct/col/ast/declaration/cls/ClassDeclarationImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.declaration.cls
import vct.col.ast.ClassDeclaration
import vct.col.ast.ops.ClassDeclarationFamilyOps
-trait ClassDeclarationImpl[G] extends ClassDeclarationFamilyOps[G] { this: ClassDeclaration[G] =>
+trait ClassDeclarationImpl[G] extends ClassDeclarationFamilyOps[G] {
+ this: ClassDeclaration[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/declaration/cls/InstanceFieldImpl.scala b/src/col/vct/col/ast/declaration/cls/InstanceFieldImpl.scala
index c09a274a08..81fb5ac61d 100644
--- a/src/col/vct/col/ast/declaration/cls/InstanceFieldImpl.scala
+++ b/src/col/vct/col/ast/declaration/cls/InstanceFieldImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{Final, InstanceField}
import vct.col.print._
import vct.col.ast.ops.InstanceFieldOps
-trait InstanceFieldImpl[G] extends InstanceFieldOps[G] { this: InstanceField[G] =>
+trait InstanceFieldImpl[G] extends InstanceFieldOps[G] {
+ this: InstanceField[G] =>
def isFinal = flags.collectFirst { case _: Final[G] => () }.isDefined
override def layout(implicit ctx: Ctx): Doc =
Doc.rspread(flags) <> t.show <+> ctx.name(this) <> ";"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/declaration/cls/InstanceFunctionImpl.scala b/src/col/vct/col/ast/declaration/cls/InstanceFunctionImpl.scala
index aba49e9d52..049cd380ad 100644
--- a/src/col/vct/col/ast/declaration/cls/InstanceFunctionImpl.scala
+++ b/src/col/vct/col/ast/declaration/cls/InstanceFunctionImpl.scala
@@ -6,20 +6,23 @@ import vct.col.print._
import scala.collection.immutable.ListMap
import vct.col.ast.ops.InstanceFunctionOps
-trait InstanceFunctionImpl[G] extends InstanceFunctionOps[G] { this: InstanceFunction[G] =>
- def layoutModifiers(implicit ctx: Ctx): Seq[Doc] = ListMap(
- inline -> "inline",
- threadLocal -> "thread_local",
- ).filter(_._1).values.map(Text).map(Doc.inlineSpec).toSeq
+trait InstanceFunctionImpl[G] extends InstanceFunctionOps[G] {
+ this: InstanceFunction[G] =>
+ def layoutModifiers(implicit ctx: Ctx): Seq[Doc] =
+ ListMap(inline -> "inline", threadLocal -> "thread_local").filter(_._1)
+ .values.map(Text).map(Doc.inlineSpec).toSeq
override def layout(implicit ctx: Ctx): Doc =
Doc.stack(Seq(
contract,
Group(
- Doc.rspread(layoutModifiers) <> Text("pure") <+> returnType <+> ctx.name(this) <>
- (if(typeArgs.nonEmpty) Text("<") <> Doc.args(typeArgs.map(ctx.name).map(Text)) <> ">" else Empty) <>
- "(" <> Doc.args(args) <> ")" <>
+ Doc.rspread(layoutModifiers) <> Text("pure") <+> returnType <+>
+ ctx.name(this) <>
+ (if (typeArgs.nonEmpty)
+ Text("<") <> Doc.args(typeArgs.map(ctx.name).map(Text)) <> ">"
+ else
+ Empty) <> "(" <> Doc.args(args) <> ")" <>
body.map(Text(" =") <>> _ <> ";").getOrElse(Text(";"))
),
))
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/declaration/cls/InstanceMethodImpl.scala b/src/col/vct/col/ast/declaration/cls/InstanceMethodImpl.scala
index d7d944982b..378d7d7600 100644
--- a/src/col/vct/col/ast/declaration/cls/InstanceMethodImpl.scala
+++ b/src/col/vct/col/ast/declaration/cls/InstanceMethodImpl.scala
@@ -2,40 +2,76 @@ package vct.col.ast.declaration.cls
import vct.col.ast.{InstanceMethod, TVoid}
import vct.col.ast.declaration.category.AbstractMethodImpl
-import vct.col.check.{CheckContext, CheckError, SeqProgInstanceMethodArgs, SeqProgInstanceMethodBody, SeqProgInstanceMethodNonVoid, SeqProgInstanceMethodPure}
+import vct.col.check.{
+ CheckContext,
+ CheckError,
+ SeqProgInstanceMethodArgs,
+ SeqProgInstanceMethodBody,
+ SeqProgInstanceMethodNonVoid,
+ SeqProgInstanceMethodPure,
+}
import vct.col.print._
import scala.collection.immutable.ListMap
import vct.col.ast.ops.InstanceMethodOps
-trait InstanceMethodImpl[G] extends ClassDeclarationImpl[G] with AbstractMethodImpl[G] with InstanceMethodOps[G] { this: InstanceMethod[G] =>
- def layoutModifiers(implicit ctx: Ctx): Seq[Doc] = ListMap(
- pure -> "pure",
- inline -> "inline",
- ).filter(_._1).values.map(Text).map(Doc.inlineSpec).toSeq
+trait InstanceMethodImpl[G]
+ extends ClassDeclarationImpl[G]
+ with AbstractMethodImpl[G]
+ with InstanceMethodOps[G] {
+ this: InstanceMethod[G] =>
+ def layoutModifiers(implicit ctx: Ctx): Seq[Doc] =
+ ListMap(pure -> "pure", inline -> "inline").filter(_._1).values.map(Text)
+ .map(Doc.inlineSpec).toSeq
- private def layoutNameAndArgs(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.Java =>
- (if(typeArgs.nonEmpty) Text("<") <> Doc.args(typeArgs.map(ctx.name).map(Text)) <+> Empty else Empty) <>
- ctx.name(this)
- case _ =>
- Text(ctx.name(this)) <> (if(typeArgs.nonEmpty) Text("<") <> Doc.args(typeArgs.map(ctx.name).map(Text)) else Empty)
- }
+ private def layoutNameAndArgs(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.Java =>
+ (if (typeArgs.nonEmpty)
+ Text("<") <> Doc.args(typeArgs.map(ctx.name).map(Text)) <+> Empty
+ else
+ Empty) <> ctx.name(this)
+ case _ =>
+ Text(ctx.name(this)) <>
+ (if (typeArgs.nonEmpty)
+ Text("<") <> Doc.args(typeArgs.map(ctx.name).map(Text))
+ else
+ Empty)
+ }
override def layout(implicit ctx: Ctx): Doc =
Doc.stack(Seq(
contract,
- Group(Group(Doc.rspread(layoutModifiers) <> returnType <+> layoutNameAndArgs) <>
- "(" <> Doc.args(args) <> ")") <>
- (if(outArgs.nonEmpty) Text(" returns") <+> "(" <> Doc.args(outArgs) <> ")" else Empty) <>
- body.map(Text(" ") <> _.layoutAsBlock).getOrElse(Text(";")),
+ Group(
+ Group(
+ Doc.rspread(layoutModifiers) <> returnType <+> layoutNameAndArgs
+ ) <> "(" <> Doc.args(args) <> ")"
+ ) <>
+ (if (outArgs.nonEmpty)
+ Text(" returns") <+> "(" <> Doc.args(outArgs) <> ")"
+ else
+ Empty) <> body.map(Text(" ") <> _.layoutAsBlock).getOrElse(Text(";")),
))
- override def check(context: CheckContext[G]): Seq[CheckError] = context.currentChoreography match {
- case None => Seq()
- case Some(_) => (if(returnType != TVoid[G]()) Seq(SeqProgInstanceMethodNonVoid(this)) else Seq()) ++
- (if(args.nonEmpty) Seq(SeqProgInstanceMethodArgs(this)) else Seq()) ++
- (if(this.body.isEmpty) Seq(SeqProgInstanceMethodBody(this)) else Seq()) ++
- (if(this.pure) Seq(SeqProgInstanceMethodPure(this)) else Seq())
- }
-}
\ No newline at end of file
+ override def check(context: CheckContext[G]): Seq[CheckError] =
+ context.currentChoreography match {
+ case None => Seq()
+ case Some(_) =>
+ (if (returnType != TVoid[G]())
+ Seq(SeqProgInstanceMethodNonVoid(this))
+ else
+ Seq()) ++
+ (if (args.nonEmpty)
+ Seq(SeqProgInstanceMethodArgs(this))
+ else
+ Seq()) ++
+ (if (this.body.isEmpty)
+ Seq(SeqProgInstanceMethodBody(this))
+ else
+ Seq()) ++
+ (if (this.pure)
+ Seq(SeqProgInstanceMethodPure(this))
+ else
+ Seq())
+ }
+}
diff --git a/src/col/vct/col/ast/declaration/cls/InstanceOperatorFunctionImpl.scala b/src/col/vct/col/ast/declaration/cls/InstanceOperatorFunctionImpl.scala
index da565d7b13..4a782f1b66 100644
--- a/src/col/vct/col/ast/declaration/cls/InstanceOperatorFunctionImpl.scala
+++ b/src/col/vct/col/ast/declaration/cls/InstanceOperatorFunctionImpl.scala
@@ -6,20 +6,21 @@ import vct.col.print._
import scala.collection.immutable.ListMap
import vct.col.ast.ops.InstanceOperatorFunctionOps
-trait InstanceOperatorFunctionImpl[G] extends InstanceOperatorFunctionOps[G] { this: InstanceOperatorFunction[G] =>
+trait InstanceOperatorFunctionImpl[G] extends InstanceOperatorFunctionOps[G] {
+ this: InstanceOperatorFunction[G] =>
def typeArgs: Seq[Variable[G]] = Nil
- def layoutModifiers(implicit ctx: Ctx): Seq[Doc] = ListMap(
- inline -> "inline",
- threadLocal -> "thread_local",
- ).filter(_._1).values.map(Text).map(Doc.inlineSpec).toSeq
+ def layoutModifiers(implicit ctx: Ctx): Seq[Doc] =
+ ListMap(inline -> "inline", threadLocal -> "thread_local").filter(_._1)
+ .values.map(Text).map(Doc.inlineSpec).toSeq
override def layout(implicit ctx: Ctx): Doc =
Doc.stack(Seq(
contract,
Group(
- Doc.rspread(layoutModifiers) <> "pure" <+> returnType <+> operator <> "(" <> Doc.args(args) <> ")" <>
- body.map(Text(" =") <>> _ <> ";").getOrElse(Text(";"))
+ Doc.rspread(layoutModifiers) <> "pure" <+> returnType <+> operator <>
+ "(" <> Doc.args(args) <> ")" <> body.map(Text(" =") <>> _ <> ";")
+ .getOrElse(Text(";"))
),
))
}
diff --git a/src/col/vct/col/ast/declaration/cls/InstanceOperatorMethodImpl.scala b/src/col/vct/col/ast/declaration/cls/InstanceOperatorMethodImpl.scala
index bcb3990b9f..54a7dcf80a 100644
--- a/src/col/vct/col/ast/declaration/cls/InstanceOperatorMethodImpl.scala
+++ b/src/col/vct/col/ast/declaration/cls/InstanceOperatorMethodImpl.scala
@@ -6,19 +6,21 @@ import vct.col.print._
import scala.collection.immutable.ListMap
import vct.col.ast.ops.InstanceOperatorMethodOps
-trait InstanceOperatorMethodImpl[G] extends InstanceOperatorMethodOps[G] { this: InstanceOperatorMethod[G] =>
+trait InstanceOperatorMethodImpl[G] extends InstanceOperatorMethodOps[G] {
+ this: InstanceOperatorMethod[G] =>
def typeArgs: Seq[Variable[G]] = Nil
def outArgs: Seq[Variable[G]] = Nil
- def layoutModifiers(implicit ctx: Ctx): Seq[Doc] = ListMap(
- pure -> "pure",
- inline -> "inline",
- ).filter(_._1).values.map(Text).map(Doc.inlineSpec).toSeq
+ def layoutModifiers(implicit ctx: Ctx): Seq[Doc] =
+ ListMap(pure -> "pure", inline -> "inline").filter(_._1).values.map(Text)
+ .map(Doc.inlineSpec).toSeq
override def layout(implicit ctx: Ctx): Doc =
Doc.stack(Seq(
contract,
- Group(Doc.rspread(layoutModifiers) <> returnType.show <+> operator <> "(" <> Doc.args(args) <> ")") <>
- body.map(Text(" ") <> _.layoutAsBlock).getOrElse(Text(";")),
+ Group(
+ Doc.rspread(layoutModifiers) <> returnType.show <+> operator <> "(" <>
+ Doc.args(args) <> ")"
+ ) <> body.map(Text(" ") <> _.layoutAsBlock).getOrElse(Text(";")),
))
}
diff --git a/src/col/vct/col/ast/declaration/cls/InstancePredicateImpl.scala b/src/col/vct/col/ast/declaration/cls/InstancePredicateImpl.scala
index 8452b3c796..61d407826f 100644
--- a/src/col/vct/col/ast/declaration/cls/InstancePredicateImpl.scala
+++ b/src/col/vct/col/ast/declaration/cls/InstancePredicateImpl.scala
@@ -7,14 +7,19 @@ import vct.col.print._
import scala.collection.immutable.ListMap
import vct.col.ast.ops.InstancePredicateOps
-trait InstancePredicateImpl[G] extends ClassDeclarationImpl[G] with AbstractPredicateImpl[G] with InstancePredicateOps[G] { this: InstancePredicate[G] =>
- def layoutModifiers(implicit ctx: Ctx): Seq[Doc] = ListMap(
- inline -> "inline",
- threadLocal -> "thread_local",
- ).filter(_._1).values.map(Text).map(Doc.inlineSpec).toSeq
+trait InstancePredicateImpl[G]
+ extends ClassDeclarationImpl[G]
+ with AbstractPredicateImpl[G]
+ with InstancePredicateOps[G] {
+ this: InstancePredicate[G] =>
+ def layoutModifiers(implicit ctx: Ctx): Seq[Doc] =
+ ListMap(inline -> "inline", threadLocal -> "thread_local").filter(_._1)
+ .values.map(Text).map(Doc.inlineSpec).toSeq
- override def layout(implicit ctx: Ctx): Doc = Group(
- Doc.rspread(layoutModifiers) <> "resource" <+> ctx.name(this) <> "(" <> Doc.args(args) <> ")" <>
- body.map(Text(" =") <>> _ <> ";").getOrElse(Text(";"))
- )
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ Group(
+ Doc.rspread(layoutModifiers) <> "resource" <+> ctx.name(this) <> "(" <>
+ Doc.args(args) <> ")" <> body.map(Text(" =") <>> _ <> ";")
+ .getOrElse(Text(";"))
+ )
+}
diff --git a/src/col/vct/col/ast/declaration/cls/RunMethodImpl.scala b/src/col/vct/col/ast/declaration/cls/RunMethodImpl.scala
index 52503fb5f2..1171331f45 100644
--- a/src/col/vct/col/ast/declaration/cls/RunMethodImpl.scala
+++ b/src/col/vct/col/ast/declaration/cls/RunMethodImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.RunMethod
import vct.col.print._
import vct.col.ast.ops.RunMethodOps
-trait RunMethodImpl[G] extends RunMethodOps[G] { this: RunMethod[G] =>
+trait RunMethodImpl[G] extends RunMethodOps[G] {
+ this: RunMethod[G] =>
override def layout(implicit ctx: Ctx): Doc =
Doc.stack(Seq(
contract.show,
diff --git a/src/col/vct/col/ast/declaration/cls/VeSUVMainMethodImpl.scala b/src/col/vct/col/ast/declaration/cls/VeSUVMainMethodImpl.scala
index e918f0b10f..8bc52ab87e 100644
--- a/src/col/vct/col/ast/declaration/cls/VeSUVMainMethodImpl.scala
+++ b/src/col/vct/col/ast/declaration/cls/VeSUVMainMethodImpl.scala
@@ -4,9 +4,11 @@ import vct.col.ast.VeSUVMainMethod
import vct.col.print.{Ctx, Doc, Empty, Text}
import vct.col.ast.ops.VeSUVMainMethodOps
-trait VeSUVMainMethodImpl[G] extends VeSUVMainMethodOps[G] { this: VeSUVMainMethod[G] =>
+trait VeSUVMainMethodImpl[G] extends VeSUVMainMethodOps[G] {
+ this: VeSUVMainMethod[G] =>
override def layout(implicit ctx: Ctx): Doc =
Doc.stack(Seq(
- Text("vesuv_entry") <> body.map(Empty <+> _.layoutAsBlock).getOrElse(Text(";")),
+ Text("vesuv_entry") <> body.map(Empty <+> _.layoutAsBlock)
+ .getOrElse(Text(";"))
))
}
diff --git a/src/col/vct/col/ast/declaration/global/AxiomaticDataTypeImpl.scala b/src/col/vct/col/ast/declaration/global/AxiomaticDataTypeImpl.scala
index 169393393d..760496bb83 100644
--- a/src/col/vct/col/ast/declaration/global/AxiomaticDataTypeImpl.scala
+++ b/src/col/vct/col/ast/declaration/global/AxiomaticDataTypeImpl.scala
@@ -5,25 +5,32 @@ import vct.col.ast.{AxiomaticDataType, Declaration}
import vct.col.print._
import vct.col.ast.ops.AxiomaticDataTypeOps
-trait AxiomaticDataTypeImpl[G] extends Declarator[G] with AxiomaticDataTypeOps[G] { this: AxiomaticDataType[G] =>
+trait AxiomaticDataTypeImpl[G]
+ extends Declarator[G] with AxiomaticDataTypeOps[G] {
+ this: AxiomaticDataType[G] =>
override def declarations: Seq[Declaration[G]] = decls ++ typeArgs
def layoutSilver(implicit ctx: Ctx): Doc =
- Group(Text("domain") <+> ctx.name(this) <>
- (if(typeArgs.nonEmpty) Text("[") <> Doc.args(typeArgs.map(ctx.name).map(Text)) <> "]" else Empty) <+>
- "{") <>>
- { Doc.stack(decls) } <+/>
- "}"
+ Group(
+ Text("domain") <+> ctx.name(this) <>
+ (if (typeArgs.nonEmpty)
+ Text("[") <> Doc.args(typeArgs.map(ctx.name).map(Text)) <> "]"
+ else
+ Empty) <+> "{"
+ ) <>> { Doc.stack(decls) } <+/> "}"
def layoutSpec(implicit ctx: Ctx): Doc =
- Group(Text("adt") <+> ctx.name(this) <>
- (if(typeArgs.nonEmpty) Text("<") <> Doc.args(typeArgs.map(ctx.name).map(Text)) <> ">" else Empty) <+>
- "{") <>>
- { Doc.stack(decls) } <+/>
- "}"
+ Group(
+ Text("adt") <+> ctx.name(this) <>
+ (if (typeArgs.nonEmpty)
+ Text("<") <> Doc.args(typeArgs.map(ctx.name).map(Text)) <> ">"
+ else
+ Empty) <+> "{"
+ ) <>> { Doc.stack(decls) } <+/> "}"
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.Silver => layoutSilver
- case _ => Doc.spec(Show.lazily(layoutSpec(_)))
- }
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.Silver => layoutSilver
+ case _ => Doc.spec(Show.lazily(layoutSpec(_)))
+ }
+}
diff --git a/src/col/vct/col/ast/declaration/global/BipPortSynchronizationImpl.scala b/src/col/vct/col/ast/declaration/global/BipPortSynchronizationImpl.scala
index f7e8a1dbf1..d03ed204a7 100644
--- a/src/col/vct/col/ast/declaration/global/BipPortSynchronizationImpl.scala
+++ b/src/col/vct/col/ast/declaration/global/BipPortSynchronizationImpl.scala
@@ -4,10 +4,19 @@ import vct.col.ast.BipPortSynchronization
import vct.col.print._
import vct.col.ast.ops.BipPortSynchronizationOps
-trait BipPortSynchronizationImpl[G] extends BipPortSynchronizationOps[G] { this: BipPortSynchronization[G] =>
+trait BipPortSynchronizationImpl[G] extends BipPortSynchronizationOps[G] {
+ this: BipPortSynchronization[G] =>
def summarize: String = {
- val portsTxt = if (ports.isEmpty) "No ports" else ports.map("- " + _.decl.o.getPreferredNameOrElse().camel).mkString("\n")
- val wiresTxt = if (wires.isEmpty) "No wires" else wires.map("- " + _.o.getPreferredNameOrElse().camel).mkString("\n")
+ val portsTxt =
+ if (ports.isEmpty)
+ "No ports"
+ else
+ ports.map("- " + _.decl.o.getPreferredNameOrElse().camel).mkString("\n")
+ val wiresTxt =
+ if (wires.isEmpty)
+ "No wires"
+ else
+ wires.map("- " + _.o.getPreferredNameOrElse().camel).mkString("\n")
s"""=== Port synchronization ===
|Ports:
@@ -17,9 +26,11 @@ trait BipPortSynchronizationImpl[G] extends BipPortSynchronizationOps[G] { this:
}
override def layout(implicit ctx: Ctx): Doc =
- Text("/*") <+/>
- Text("javaBipPortSynchronization {") <>> {
- Text("ports:") <>> Doc.stack(ports.map(ctx.name).map(Text("-") <+> _)) <+/>
- Text("wires:") <>> Doc.stack(wires.map(wire => Text(ctx.name(wire.dataOut)) <+> "->" <+> ctx.name(wire.dataIn)))
+ Text("/*") <+/> Text("javaBipPortSynchronization {") <>> {
+ Text("ports:") <>>
+ Doc.stack(ports.map(ctx.name).map(Text("-") <+> _)) <+/>
+ Text("wires:") <>> Doc.stack(wires.map(wire =>
+ Text(ctx.name(wire.dataOut)) <+> "->" <+> ctx.name(wire.dataIn)
+ ))
} <+/> "*/"
}
diff --git a/src/col/vct/col/ast/declaration/global/BipTransitionSynchronizationImpl.scala b/src/col/vct/col/ast/declaration/global/BipTransitionSynchronizationImpl.scala
index f6d62971d8..541e88f25b 100644
--- a/src/col/vct/col/ast/declaration/global/BipTransitionSynchronizationImpl.scala
+++ b/src/col/vct/col/ast/declaration/global/BipTransitionSynchronizationImpl.scala
@@ -4,10 +4,20 @@ import vct.col.ast.BipTransitionSynchronization
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.BipTransitionSynchronizationOps
-trait BipTransitionSynchronizationImpl[G] extends BipTransitionSynchronizationOps[G] { this: BipTransitionSynchronization[G] =>
+trait BipTransitionSynchronizationImpl[G]
+ extends BipTransitionSynchronizationOps[G] {
+ this: BipTransitionSynchronization[G] =>
def summarize: String = {
- val portsTxt = if (transitions.isEmpty) "No transitions" else transitions.map("- " + _.decl.signature.shortSignature).mkString("\n")
- val wiresTxt = if (wires.isEmpty) "No wires" else wires.map("- " + _.o.getPreferredNameOrElse().camel).mkString("\n")
+ val portsTxt =
+ if (transitions.isEmpty)
+ "No transitions"
+ else
+ transitions.map("- " + _.decl.signature.shortSignature).mkString("\n")
+ val wiresTxt =
+ if (wires.isEmpty)
+ "No wires"
+ else
+ wires.map("- " + _.o.getPreferredNameOrElse().camel).mkString("\n")
s"""=== Transition synchronization ===
|Transition:
@@ -17,9 +27,11 @@ trait BipTransitionSynchronizationImpl[G] extends BipTransitionSynchronizationOp
}
override def layout(implicit ctx: Ctx): Doc =
- Text("/*") <+/>
- Text("javaBipTransitionSynchronization {") <>> {
- Text("transitions:") <>> Doc.stack(transitions.map(ctx.name).map(Text("-") <+> _)) <+/>
- Text("wires:") <>> Doc.stack(wires.map(wire => Text(ctx.name(wire.dataOut)) <+> "->" <+> ctx.name(wire.dataIn)))
+ Text("/*") <+/> Text("javaBipTransitionSynchronization {") <>> {
+ Text("transitions:") <>>
+ Doc.stack(transitions.map(ctx.name).map(Text("-") <+> _)) <+/>
+ Text("wires:") <>> Doc.stack(wires.map(wire =>
+ Text(ctx.name(wire.dataOut)) <+> "->" <+> ctx.name(wire.dataIn)
+ ))
} <+/> "*/"
}
diff --git a/src/col/vct/col/ast/declaration/global/ChoreographyImpl.scala b/src/col/vct/col/ast/declaration/global/ChoreographyImpl.scala
index a80ee15947..6d0e26a1bc 100644
--- a/src/col/vct/col/ast/declaration/global/ChoreographyImpl.scala
+++ b/src/col/vct/col/ast/declaration/global/ChoreographyImpl.scala
@@ -1,7 +1,17 @@
package vct.col.ast.declaration.global
import vct.col.ast.declaration.DeclarationImpl
-import vct.col.ast.{Assign, ChorStatement, Class, Declaration, Endpoint, EndpointGuard, EndpointName, Node, Choreography}
+import vct.col.ast.{
+ Assign,
+ ChorStatement,
+ Class,
+ Declaration,
+ Endpoint,
+ EndpointGuard,
+ EndpointName,
+ Node,
+ Choreography,
+}
import vct.col.ast.util.Declarator
import vct.col.check.{CheckContext, CheckError}
import vct.col.origin.Origin
@@ -20,20 +30,29 @@ object ChoreographyImpl {
})
}
-trait ChoreographyImpl[G] extends DeclarationImpl[G] with Declarator[G] with ChoreographyOps[G] { this: Choreography[G] =>
+trait ChoreographyImpl[G]
+ extends DeclarationImpl[G] with Declarator[G] with ChoreographyOps[G] {
+ this: Choreography[G] =>
override def declarations: Seq[Declaration[G]] = params ++ endpoints ++ decls
override def layout(implicit ctx: Ctx): Doc =
Doc.stack(Seq(
contract,
- Group(Text("seq_program") <+> ctx.name(this) <> "(" <> Doc.args(params) <> ")") <+> "{" <>>
- Doc.stack(endpoints ++ decls :+ preRun.map(preRun => Text("/* preRun */") <+> preRun.show).getOrElse(Empty) :+ run) <+/>
- "}"
+ Group(
+ Text("seq_program") <+> ctx.name(this) <> "(" <> Doc.args(params) <> ")"
+ ) <+> "{" <>> Doc.stack(
+ endpoints ++ decls :+
+ preRun.map(preRun => Text("/* preRun */") <+> preRun.show)
+ .getOrElse(Empty) :+ run
+ ) <+/> "}",
))
- override def enterCheckContextCurrentParticipatingEndpoints(context: CheckContext[G]): Option[Set[Endpoint[G]]] =
+ override def enterCheckContextCurrentParticipatingEndpoints(
+ context: CheckContext[G]
+ ): Option[Set[Endpoint[G]]] =
context.withCurrentParticipatingEndpoints(endpoints)
- override def enterCheckContextCurrentChoreography(context: CheckContext[G]): Option[Choreography[G]] =
- Some(this)
+ override def enterCheckContextCurrentChoreography(
+ context: CheckContext[G]
+ ): Option[Choreography[G]] = Some(this)
}
diff --git a/src/col/vct/col/ast/declaration/global/ClassImpl.scala b/src/col/vct/col/ast/declaration/global/ClassImpl.scala
index 33ae5dfaba..6b26f4e42b 100644
--- a/src/col/vct/col/ast/declaration/global/ClassImpl.scala
+++ b/src/col/vct/col/ast/declaration/global/ClassImpl.scala
@@ -7,15 +7,21 @@ import vct.col.util.AstBuildHelpers.tt
import vct.result.VerificationError.Unreachable
import vct.col.ast.ops.ClassOps
-trait ClassImpl[G] extends Declarator[G] with ClassOps[G] { this: Class[G] =>
- def transSupportArrowsHelper(seen: Set[TClass[G]]): Seq[(TClass[G], TClass[G])] = {
+trait ClassImpl[G] extends Declarator[G] with ClassOps[G] {
+ this: Class[G] =>
+ def transSupportArrowsHelper(
+ seen: Set[TClass[G]]
+ ): Seq[(TClass[G], TClass[G])] = {
val t: TClass[G] = TClass(this.ref, typeArgs.map(v => TVar(v.ref)))
- if(seen.contains(t)) Nil
- else supers.map(sup => (t, sup)) ++
- supers.flatMap(sup => sup.transSupportArrowsHelper(Set(t) ++ seen))
+ if (seen.contains(t))
+ Nil
+ else
+ supers.map(sup => (t, sup)) ++
+ supers.flatMap(sup => sup.transSupportArrowsHelper(Set(t) ++ seen))
}
- def transSupportArrows: Seq[(TClass[G], TClass[G])] = transSupportArrowsHelper(Set.empty)
+ def transSupportArrows: Seq[(TClass[G], TClass[G])] =
+ transSupportArrowsHelper(Set.empty)
def supers: Seq[TClass[G]] = supports.map(_.asClass.get)
@@ -25,14 +31,20 @@ trait ClassImpl[G] extends Declarator[G] with ClassOps[G] { this: Class[G] =>
Text("lock_invariant") <+> intrinsicLockInvariant <> ";" <+/> Empty
override def layout(implicit ctx: Ctx): Doc =
- (if(intrinsicLockInvariant == tt[G]) Empty else Doc.spec(Show.lazily(layoutLockInvariant(_)))) <>
- Group(
- Text("class") <+> ctx.name(this) <>
- (if (typeArgs.nonEmpty) Text("<") <> Doc.args(typeArgs) <> ">" else Empty) <>
- (if(supports.isEmpty) Empty else Text(" implements") <+>
- Doc.args(supports.map(supp => ctx.name(supp.asClass.get.cls)).map(Text))) <+>
- "{"
- ) <>>
- Doc.stack(decls) <+/>
- "}"
-}
\ No newline at end of file
+ (if (intrinsicLockInvariant == tt[G])
+ Empty
+ else
+ Doc.spec(Show.lazily(layoutLockInvariant(_)))) <> Group(
+ Text("class") <+> ctx.name(this) <>
+ (if (typeArgs.nonEmpty)
+ Text("<") <> Doc.args(typeArgs) <> ">"
+ else
+ Empty) <>
+ (if (supports.isEmpty)
+ Empty
+ else
+ Text(" implements") <+> Doc.args(
+ supports.map(supp => ctx.name(supp.asClass.get.cls)).map(Text)
+ )) <+> "{"
+ ) <>> Doc.stack(decls) <+/> "}"
+}
diff --git a/src/col/vct/col/ast/declaration/global/FunctionImpl.scala b/src/col/vct/col/ast/declaration/global/FunctionImpl.scala
index 5650fbef2b..0539ef1366 100644
--- a/src/col/vct/col/ast/declaration/global/FunctionImpl.scala
+++ b/src/col/vct/col/ast/declaration/global/FunctionImpl.scala
@@ -7,31 +7,43 @@ import vct.col.print._
import scala.collection.immutable.ListMap
import vct.col.ast.ops.FunctionOps
-trait FunctionImpl[G] extends GlobalDeclarationImpl[G] with AbstractFunctionImpl[G] with FunctionOps[G] { this: Function[G] =>
+trait FunctionImpl[G]
+ extends GlobalDeclarationImpl[G]
+ with AbstractFunctionImpl[G]
+ with FunctionOps[G] {
+ this: Function[G] =>
def layoutSilver(implicit ctx: Ctx): Doc =
- Group(Text("function") <+> ctx.name(this) <>
- "(" <> Doc.args(args) <> "):" <+> returnType) <+/>
- contract <+/>
- (if(body.nonEmpty) Text("{") <>> body.get <+/> "}" else Empty)
+ Group(
+ Text("function") <+> ctx.name(this) <> "(" <> Doc.args(args) <> "):" <+>
+ returnType
+ ) <+/> contract <+/>
+ (if (body.nonEmpty)
+ Text("{") <>> body.get <+/> "}"
+ else
+ Empty)
- def layoutModifiers(implicit ctx: Ctx): Seq[Doc] = ListMap(
- inline -> "inline",
- threadLocal -> "thread_local",
- ).filter(_._1).values.map(Text).map(Doc.inlineSpec).toSeq
+ def layoutModifiers(implicit ctx: Ctx): Seq[Doc] =
+ ListMap(inline -> "inline", threadLocal -> "thread_local").filter(_._1)
+ .values.map(Text).map(Doc.inlineSpec).toSeq
def layoutSpec(implicit ctx: Ctx): Doc =
Doc.stack(Seq(
contract,
Group(
- Group(Doc.rspread(layoutModifiers) <> "pure" <+> returnType <+> ctx.name(this) <>
- (if(typeArgs.nonEmpty) Text("<") <> Doc.args(typeArgs.map(ctx.name).map(Text)) <> ">" else Empty) <>
- "(" <> Doc.args(args) <> ")") <>
- body.map(Text(" =") <>> _ <> ";").getOrElse(Text(";"))
+ Group(
+ Doc.rspread(layoutModifiers) <> "pure" <+> returnType <+>
+ ctx.name(this) <>
+ (if (typeArgs.nonEmpty)
+ Text("<") <> Doc.args(typeArgs.map(ctx.name).map(Text)) <> ">"
+ else
+ Empty) <> "(" <> Doc.args(args) <> ")"
+ ) <> body.map(Text(" =") <>> _ <> ";").getOrElse(Text(";"))
),
))
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.Silver => layoutSilver
- case _ => Doc.spec(Show.lazily(layoutSpec(_)))
- }
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.Silver => layoutSilver
+ case _ => Doc.spec(Show.lazily(layoutSpec(_)))
+ }
}
diff --git a/src/col/vct/col/ast/declaration/global/GlobalDeclarationImpl.scala b/src/col/vct/col/ast/declaration/global/GlobalDeclarationImpl.scala
index 350df87362..aba131df19 100644
--- a/src/col/vct/col/ast/declaration/global/GlobalDeclarationImpl.scala
+++ b/src/col/vct/col/ast/declaration/global/GlobalDeclarationImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.declaration.global
import vct.col.ast.GlobalDeclaration
import vct.col.ast.ops.GlobalDeclarationFamilyOps
-trait GlobalDeclarationImpl[G] extends GlobalDeclarationFamilyOps[G] { this: GlobalDeclaration[G] =>
+trait GlobalDeclarationImpl[G] extends GlobalDeclarationFamilyOps[G] {
+ this: GlobalDeclaration[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/declaration/global/HeapVariableImpl.scala b/src/col/vct/col/ast/declaration/global/HeapVariableImpl.scala
index 3075d20bd9..a61021641a 100644
--- a/src/col/vct/col/ast/declaration/global/HeapVariableImpl.scala
+++ b/src/col/vct/col/ast/declaration/global/HeapVariableImpl.scala
@@ -4,12 +4,13 @@ import vct.col.ast.HeapVariable
import vct.col.print._
import vct.col.ast.ops.HeapVariableOps
-trait HeapVariableImpl[G] extends HeapVariableOps[G] { this: HeapVariable[G] =>
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.C | Ctx.Cuda | Ctx.OpenCL | Ctx.CPP =>
- val (spec, decl) = t.layoutSplitDeclarator
- spec <+> decl <> ctx.name(this) <> ";"
- case _ =>
- t.show <+> ctx.name(this) <> ";"
- }
+trait HeapVariableImpl[G] extends HeapVariableOps[G] {
+ this: HeapVariable[G] =>
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.C | Ctx.Cuda | Ctx.OpenCL | Ctx.CPP =>
+ val (spec, decl) = t.layoutSplitDeclarator
+ spec <+> decl <> ctx.name(this) <> ";"
+ case _ => t.show <+> ctx.name(this) <> ";"
+ }
}
diff --git a/src/col/vct/col/ast/declaration/global/JavaBipGlueContainerImpl.scala b/src/col/vct/col/ast/declaration/global/JavaBipGlueContainerImpl.scala
index 7d60c1c448..5b2aeb8f45 100644
--- a/src/col/vct/col/ast/declaration/global/JavaBipGlueContainerImpl.scala
+++ b/src/col/vct/col/ast/declaration/global/JavaBipGlueContainerImpl.scala
@@ -4,7 +4,7 @@ import vct.col.ast.JavaBipGlueContainer
import vct.col.print._
import vct.col.ast.ops.JavaBipGlueContainerOps
-trait JavaBipGlueContainerImpl[G] extends JavaBipGlueContainerOps[G] { this: JavaBipGlueContainer[G] =>
- override def layout(implicit ctx: Ctx): Doc =
- job.show
+trait JavaBipGlueContainerImpl[G] extends JavaBipGlueContainerOps[G] {
+ this: JavaBipGlueContainer[G] =>
+ override def layout(implicit ctx: Ctx): Doc = job.show
}
diff --git a/src/col/vct/col/ast/declaration/global/ModelImpl.scala b/src/col/vct/col/ast/declaration/global/ModelImpl.scala
index ec47fc4a69..45de4d2b64 100644
--- a/src/col/vct/col/ast/declaration/global/ModelImpl.scala
+++ b/src/col/vct/col/ast/declaration/global/ModelImpl.scala
@@ -4,7 +4,9 @@ import vct.col.ast.Model
import vct.col.print._
import vct.col.ast.ops.ModelOps
-trait ModelImpl[G] extends ModelOps[G] { this: Model[G] =>
+trait ModelImpl[G] extends ModelOps[G] {
+ this: Model[G] =>
override def layout(implicit ctx: Ctx): Doc =
- Text("model") <+> ctx.name(this) <+> "{" <+/> Doc.stack(declarations) <+/> "}"
-}
\ No newline at end of file
+ Text("model") <+> ctx.name(this) <+> "{" <+/> Doc.stack(declarations) <+/>
+ "}"
+}
diff --git a/src/col/vct/col/ast/declaration/global/PVLChoreographyImpl.scala b/src/col/vct/col/ast/declaration/global/PVLChoreographyImpl.scala
index 5b440598bb..3ccccd1be3 100644
--- a/src/col/vct/col/ast/declaration/global/PVLChoreographyImpl.scala
+++ b/src/col/vct/col/ast/declaration/global/PVLChoreographyImpl.scala
@@ -4,12 +4,13 @@ import vct.col.ast.PVLChoreography
import vct.col.print._
import vct.col.ast.ops.PVLChoreographyOps
-trait PVLChoreographyImpl[G] extends PVLChoreographyOps[G] { this: PVLChoreography[G] =>
+trait PVLChoreographyImpl[G] extends PVLChoreographyOps[G] {
+ this: PVLChoreography[G] =>
override def layout(implicit ctx: Ctx): Doc =
Doc.stack(Seq(
contract,
- Group(Text("seq_program") <+> ctx.name(this) <> "(" <> Doc.args(args) <> ")") <+> "{" <>>
- Doc.stack(declarations) <+/>
- "}"
+ Group(
+ Text("seq_program") <+> ctx.name(this) <> "(" <> Doc.args(args) <> ")"
+ ) <+> "{" <>> Doc.stack(declarations) <+/> "}",
))
}
diff --git a/src/col/vct/col/ast/declaration/global/PredicateImpl.scala b/src/col/vct/col/ast/declaration/global/PredicateImpl.scala
index ee146c6740..f104760c31 100644
--- a/src/col/vct/col/ast/declaration/global/PredicateImpl.scala
+++ b/src/col/vct/col/ast/declaration/global/PredicateImpl.scala
@@ -7,22 +7,32 @@ import vct.col.print._
import scala.collection.immutable.ListMap
import vct.col.ast.ops.PredicateOps
-trait PredicateImpl[G] extends GlobalDeclarationImpl[G] with AbstractPredicateImpl[G] with PredicateOps[G] { this: Predicate[G] =>
+trait PredicateImpl[G]
+ extends GlobalDeclarationImpl[G]
+ with AbstractPredicateImpl[G]
+ with PredicateOps[G] {
+ this: Predicate[G] =>
def layoutSilver(implicit ctx: Ctx): Doc =
Text("predicate") <+> ctx.name(this) <> "(" <> Doc.args(args) <> ")" <>
- (if(body.nonEmpty) Text(" {") <>> body.get <+/> "}" else Empty)
+ (if (body.nonEmpty)
+ Text(" {") <>> body.get <+/> "}"
+ else
+ Empty)
- def layoutModifiers(implicit ctx: Ctx): Seq[Doc] = ListMap(
- inline -> "inline",
- threadLocal -> "thread_local",
- ).filter(_._1).values.map(Text).map(Doc.inlineSpec).toSeq
+ def layoutModifiers(implicit ctx: Ctx): Seq[Doc] =
+ ListMap(inline -> "inline", threadLocal -> "thread_local").filter(_._1)
+ .values.map(Text).map(Doc.inlineSpec).toSeq
def layoutSpec(implicit ctx: Ctx): Doc =
- Group(Doc.rspread(layoutModifiers) <> "resource" <+> ctx.name(this) <> "(" <> Doc.args(args) <> ")" <>
- body.map(Text(" =") <>> _.show).getOrElse(Empty))
+ Group(
+ Doc.rspread(layoutModifiers) <> "resource" <+> ctx.name(this) <> "(" <>
+ Doc.args(args) <> ")" <> body.map(Text(" =") <>> _.show)
+ .getOrElse(Empty)
+ )
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.Silver => layoutSilver
- case _ => Doc.spec(Show.lazily(layoutSpec(_)))
- }
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.Silver => layoutSilver
+ case _ => Doc.spec(Show.lazily(layoutSpec(_)))
+ }
+}
diff --git a/src/col/vct/col/ast/declaration/global/ProcedureImpl.scala b/src/col/vct/col/ast/declaration/global/ProcedureImpl.scala
index 15aaff64cd..f76194e61a 100644
--- a/src/col/vct/col/ast/declaration/global/ProcedureImpl.scala
+++ b/src/col/vct/col/ast/declaration/global/ProcedureImpl.scala
@@ -6,37 +6,57 @@ import vct.col.print._
import scala.collection.immutable.ListMap
import vct.col.ast.ops.ProcedureOps
-trait ProcedureImpl[G] extends ProcedureOps[G] { this: Procedure[G] =>
+trait ProcedureImpl[G] extends ProcedureOps[G] {
+ this: Procedure[G] =>
def layoutSilver(implicit ctx: Ctx): Doc =
- Group(Text("method") <+> ctx.name(this) <> "(" <> Doc.args(args) <> ")" <>
- (if(outArgs.nonEmpty) Text(" returns (") <> Doc.args(typeArgs.map(ctx.name).map(Text)) <> ")" else Empty)) <+/>
- contract <>
- (if(body.nonEmpty) Line <> body.get.layoutAsBlock else Empty)
+ Group(
+ Text("method") <+> ctx.name(this) <> "(" <> Doc.args(args) <> ")" <>
+ (if (outArgs.nonEmpty)
+ Text(" returns (") <> Doc.args(typeArgs.map(ctx.name).map(Text)) <>
+ ")"
+ else
+ Empty)
+ ) <+/> contract <>
+ (if (body.nonEmpty)
+ Line <> body.get.layoutAsBlock
+ else
+ Empty)
def layoutC(implicit ctx: Ctx): Doc = {
val (spec, decl) = returnType.layoutSplitDeclarator
Group(spec <+> decl <> ctx.name(this) <> "(" <> Doc.args(args) <> ")") <>
- (if(body.nonEmpty) Text(" ") <> body.get.layoutAsBlock else Text(";"))
+ (if (body.nonEmpty)
+ Text(" ") <> body.get.layoutAsBlock
+ else
+ Text(";"))
}
- def layoutModifiers(implicit ctx: Ctx): Seq[Doc] = ListMap(
- pure -> "pure",
- inline -> "inline",
- ).filter(_._1).values.map(Text).map(Doc.inlineSpec).toSeq
+ def layoutModifiers(implicit ctx: Ctx): Seq[Doc] =
+ ListMap(pure -> "pure", inline -> "inline").filter(_._1).values.map(Text)
+ .map(Doc.inlineSpec).toSeq
def layoutSpec(implicit ctx: Ctx): Doc =
Doc.stack(Seq(
contract,
- Group(Group(Doc.rspread(layoutModifiers) <> returnType <+> ctx.name(this) <>
- (if (typeArgs.nonEmpty) Text("<") <> Doc.args(typeArgs.map(ctx.name).map(Text)) <> ">" else Empty)) <>
- "(" <> Doc.args(args) <> ")" <>
- (if (outArgs.nonEmpty) Text(" returns") <+> "(" <> Doc.args(outArgs) <> ")" else Empty)) <>
- body.map(Text(" ") <> _.layoutAsBlock).getOrElse(Text(";")),
+ Group(
+ Group(
+ Doc.rspread(layoutModifiers) <> returnType <+> ctx.name(this) <>
+ (if (typeArgs.nonEmpty)
+ Text("<") <> Doc.args(typeArgs.map(ctx.name).map(Text)) <> ">"
+ else
+ Empty)
+ ) <> "(" <> Doc.args(args) <> ")" <>
+ (if (outArgs.nonEmpty)
+ Text(" returns") <+> "(" <> Doc.args(outArgs) <> ")"
+ else
+ Empty)
+ ) <> body.map(Text(" ") <> _.layoutAsBlock).getOrElse(Text(";")),
))
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.Silver => layoutSilver
- case Ctx.C | Ctx.Cuda | Ctx.OpenCL | Ctx.CPP => layoutC
- case Ctx.PVL | Ctx.Java => Doc.spec(Show.lazily(layoutSpec(_)))
- }
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.Silver => layoutSilver
+ case Ctx.C | Ctx.Cuda | Ctx.OpenCL | Ctx.CPP => layoutC
+ case Ctx.PVL | Ctx.Java => Doc.spec(Show.lazily(layoutSpec(_)))
+ }
+}
diff --git a/src/col/vct/col/ast/declaration/global/ProverFunctionImpl.scala b/src/col/vct/col/ast/declaration/global/ProverFunctionImpl.scala
index 685f24e1f2..6dfe2266e5 100644
--- a/src/col/vct/col/ast/declaration/global/ProverFunctionImpl.scala
+++ b/src/col/vct/col/ast/declaration/global/ProverFunctionImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.declaration.global
import vct.col.ast.{Node, ProverFunction}
import vct.col.ast.ops.ProverFunctionOps
-trait ProverFunctionImpl[G] extends ProverFunctionOps[G] { this: ProverFunction[G] =>
+trait ProverFunctionImpl[G] extends ProverFunctionOps[G] {
+ this: ProverFunction[G] =>
override def body: None.type = None
}
diff --git a/src/col/vct/col/ast/declaration/global/ProverTypeImpl.scala b/src/col/vct/col/ast/declaration/global/ProverTypeImpl.scala
index 5f91f54bbd..35f6e05da8 100644
--- a/src/col/vct/col/ast/declaration/global/ProverTypeImpl.scala
+++ b/src/col/vct/col/ast/declaration/global/ProverTypeImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.declaration.global
import vct.col.ast.ProverType
import vct.col.ast.ops.ProverTypeOps
-trait ProverTypeImpl[G] extends ProverTypeOps[G] { this: ProverType[G] =>
+trait ProverTypeImpl[G] extends ProverTypeOps[G] {
+ this: ProverType[G] =>
}
diff --git a/src/col/vct/col/ast/declaration/global/SimplificationRuleImpl.scala b/src/col/vct/col/ast/declaration/global/SimplificationRuleImpl.scala
index 3a5d26bed0..86db148822 100644
--- a/src/col/vct/col/ast/declaration/global/SimplificationRuleImpl.scala
+++ b/src/col/vct/col/ast/declaration/global/SimplificationRuleImpl.scala
@@ -4,9 +4,8 @@ import vct.col.ast.SimplificationRule
import vct.col.print._
import vct.col.ast.ops.SimplificationRuleOps
-trait SimplificationRuleImpl[G] extends SimplificationRuleOps[G] { this: SimplificationRule[G] =>
+trait SimplificationRuleImpl[G] extends SimplificationRuleOps[G] {
+ this: SimplificationRule[G] =>
override def layout(implicit ctx: Ctx): Doc =
- Group(Text("axiom") <+> ctx.name(this) <+> "{" <>>
- { axiom.show } <+/>
- "}")
-}
\ No newline at end of file
+ Group(Text("axiom") <+> ctx.name(this) <+> "{" <>> { axiom.show } <+/> "}")
+}
diff --git a/src/col/vct/col/ast/declaration/model/ModelActionImpl.scala b/src/col/vct/col/ast/declaration/model/ModelActionImpl.scala
index cf4cde99a5..17aed92eea 100644
--- a/src/col/vct/col/ast/declaration/model/ModelActionImpl.scala
+++ b/src/col/vct/col/ast/declaration/model/ModelActionImpl.scala
@@ -5,7 +5,8 @@ import vct.col.check.{CheckContext, CheckError}
import vct.col.print._
import vct.col.ast.ops.ModelActionOps
-trait ModelActionImpl[G] extends ModelActionOps[G] { this: ModelAction[G] =>
+trait ModelActionImpl[G] extends ModelActionOps[G] {
+ this: ModelAction[G] =>
override def returnType: Type[G] = TProcess()
override def body: Option[Node[G]] = None
@@ -14,8 +15,15 @@ trait ModelActionImpl[G] extends ModelActionOps[G] { this: ModelAction[G] =>
override def layout(implicit ctx: Ctx): Doc =
DocUtil.clauses("requires", requires) <+/>
- (if(modifies.nonEmpty) Text("modifies") <+> Doc.args(modifies.map(ctx.name).map(Text)) <> ";" <> Line else Empty) <>
- (if(accessible.nonEmpty) Text("accessible") <+> Doc.args(accessible.map(ctx.name).map(Text)) <> ";" <> Line else Empty) <>
- DocUtil.clauses("ensures", ensures) <+/>
+ (if (modifies.nonEmpty)
+ Text("modifies") <+> Doc.args(modifies.map(ctx.name).map(Text)) <>
+ ";" <> Line
+ else
+ Empty) <>
+ (if (accessible.nonEmpty)
+ Text("accessible") <+> Doc.args(accessible.map(ctx.name).map(Text)) <>
+ ";" <> Line
+ else
+ Empty) <> DocUtil.clauses("ensures", ensures) <+/>
Group(Text("action") <+> ctx.name(this) <> "(" <> Doc.args(args) <> ");")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/declaration/model/ModelDeclarationImpl.scala b/src/col/vct/col/ast/declaration/model/ModelDeclarationImpl.scala
index d286fa6f8d..cd899f0239 100644
--- a/src/col/vct/col/ast/declaration/model/ModelDeclarationImpl.scala
+++ b/src/col/vct/col/ast/declaration/model/ModelDeclarationImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.declaration.model
import vct.col.ast.ModelDeclaration
import vct.col.ast.ops.ModelDeclarationFamilyOps
-trait ModelDeclarationImpl[G] extends ModelDeclarationFamilyOps[G] { this: ModelDeclaration[G] =>
+trait ModelDeclarationImpl[G] extends ModelDeclarationFamilyOps[G] {
+ this: ModelDeclaration[G] =>
}
diff --git a/src/col/vct/col/ast/declaration/model/ModelFieldImpl.scala b/src/col/vct/col/ast/declaration/model/ModelFieldImpl.scala
index 067537c2c6..0bbe23c23d 100644
--- a/src/col/vct/col/ast/declaration/model/ModelFieldImpl.scala
+++ b/src/col/vct/col/ast/declaration/model/ModelFieldImpl.scala
@@ -4,7 +4,7 @@ import vct.col.ast.ModelField
import vct.col.print._
import vct.col.ast.ops.ModelFieldOps
-trait ModelFieldImpl[G] extends ModelFieldOps[G] { this: ModelField[G] =>
- override def layout(implicit ctx: Ctx): Doc =
- t.show <+> ctx.name(this) <> ";"
-}
\ No newline at end of file
+trait ModelFieldImpl[G] extends ModelFieldOps[G] {
+ this: ModelField[G] =>
+ override def layout(implicit ctx: Ctx): Doc = t.show <+> ctx.name(this) <> ";"
+}
diff --git a/src/col/vct/col/ast/declaration/model/ModelProcessImpl.scala b/src/col/vct/col/ast/declaration/model/ModelProcessImpl.scala
index ac093465b9..ab813a41e3 100644
--- a/src/col/vct/col/ast/declaration/model/ModelProcessImpl.scala
+++ b/src/col/vct/col/ast/declaration/model/ModelProcessImpl.scala
@@ -5,16 +5,28 @@ import vct.col.check.{CheckContext, CheckError}
import vct.col.print._
import vct.col.ast.ops.ModelProcessOps
-trait ModelProcessImpl[G] extends ModelProcessOps[G] { this: ModelProcess[G] =>
+trait ModelProcessImpl[G] extends ModelProcessOps[G] {
+ this: ModelProcess[G] =>
override def returnType: Type[G] = TProcess()
override def body: Option[Node[G]] = Some(impl)
override def check(context: CheckContext[G]): Seq[CheckError] =
- impl.checkSubType(TProcess()) ++ requires.checkSubType(TBool()) ++ ensures.checkSubType(TBool())
+ impl.checkSubType(TProcess()) ++ requires.checkSubType(TBool()) ++
+ ensures.checkSubType(TBool())
override def layout(implicit ctx: Ctx): Doc =
DocUtil.clauses("requires", requires) <+/>
- (if (modifies.nonEmpty) Text("modifies") <+> Doc.args(modifies.map(ctx.name).map(Text)) <> ";" <> Line else Empty) <>
- (if (accessible.nonEmpty) Text("accessible") <+> Doc.args(accessible.map(ctx.name).map(Text)) <> ";" <> Line else Empty) <>
- DocUtil.clauses("ensures", ensures) <+/>
- Group(Group(Text("process") <+> ctx.name(this) <> "(" <> Doc.args(args) <> ") =") <+> impl)
-}
\ No newline at end of file
+ (if (modifies.nonEmpty)
+ Text("modifies") <+> Doc.args(modifies.map(ctx.name).map(Text)) <>
+ ";" <> Line
+ else
+ Empty) <>
+ (if (accessible.nonEmpty)
+ Text("accessible") <+> Doc.args(accessible.map(ctx.name).map(Text)) <>
+ ";" <> Line
+ else
+ Empty) <> DocUtil.clauses("ensures", ensures) <+/> Group(
+ Group(
+ Text("process") <+> ctx.name(this) <> "(" <> Doc.args(args) <> ") ="
+ ) <+> impl
+ )
+}
diff --git a/src/col/vct/col/ast/declaration/singular/BipTransitionSignatureImpl.scala b/src/col/vct/col/ast/declaration/singular/BipTransitionSignatureImpl.scala
index ef5885e220..49ca33f1ca 100644
--- a/src/col/vct/col/ast/declaration/singular/BipTransitionSignatureImpl.scala
+++ b/src/col/vct/col/ast/declaration/singular/BipTransitionSignatureImpl.scala
@@ -1,9 +1,18 @@
package vct.col.ast.declaration.singular
import vct.col.ast.BipTransitionSignature
-import vct.col.ast.ops.{BipTransitionSignatureOps, BipTransitionSignatureFamilyOps}
+import vct.col.ast.ops.{
+ BipTransitionSignatureOps,
+ BipTransitionSignatureFamilyOps,
+}
-trait BipTransitionSignatureImpl[G] extends BipTransitionSignatureOps[G] with BipTransitionSignatureFamilyOps[G] { this: BipTransitionSignature[G] =>
- def shortSignature: String = s"($portName, $sourceStateName, $targetStateName${", " + textualGuard.getOrElse("no guard")})"
- def asciiSignature: String = s"port_${portName}_from_${sourceStateName}_to_$targetStateName${textualGuard.map(g => s"_if_guard").getOrElse("")}"
+trait BipTransitionSignatureImpl[G]
+ extends BipTransitionSignatureOps[G]
+ with BipTransitionSignatureFamilyOps[G] {
+ this: BipTransitionSignature[G] =>
+ def shortSignature: String =
+ s"($portName, $sourceStateName, $targetStateName${", " + textualGuard.getOrElse("no guard")})"
+ def asciiSignature: String =
+ s"port_${portName}_from_${sourceStateName}_to_$targetStateName${textualGuard
+ .map(g => s"_if_guard").getOrElse("")}"
}
diff --git a/src/col/vct/col/ast/declaration/singular/EndpointImpl.scala b/src/col/vct/col/ast/declaration/singular/EndpointImpl.scala
index daa413560e..1d2c5b607f 100644
--- a/src/col/vct/col/ast/declaration/singular/EndpointImpl.scala
+++ b/src/col/vct/col/ast/declaration/singular/EndpointImpl.scala
@@ -6,12 +6,17 @@ import vct.col.print._
import vct.col.ast.ops.{EndpointFamilyOps, EndpointOps}
import vct.col.check.{CheckContext, CheckError}
-trait EndpointImpl[G] extends EndpointOps[G] with EndpointFamilyOps[G] with DeclarationImpl[G] { this: Endpoint[G] =>
+trait EndpointImpl[G]
+ extends EndpointOps[G] with EndpointFamilyOps[G] with DeclarationImpl[G] {
+ this: Endpoint[G] =>
override def layout(implicit ctx: Ctx): Doc =
- Group(Text("endpoint") <+> ctx.name(this) <+> "=" <>> { Group(t.show <> "(" <> Doc.args(args) <> ");") })
+ Group(Text("endpoint") <+> ctx.name(this) <+> "=" <>> {
+ Group(t.show <> "(" <> Doc.args(args) <> ");")
+ })
def t: TClass[G] = TClass(cls, typeArgs)
- override def check(ctx: CheckContext[G]): Seq[CheckError] = super.check(ctx) ++ ctx.checkInScope(this, cls)
+ override def check(ctx: CheckContext[G]): Seq[CheckError] =
+ super.check(ctx) ++ ctx.checkInScope(this, cls)
}
diff --git a/src/col/vct/col/ast/declaration/singular/LabelDeclImpl.scala b/src/col/vct/col/ast/declaration/singular/LabelDeclImpl.scala
index accae7b3e7..d55861dfd2 100644
--- a/src/col/vct/col/ast/declaration/singular/LabelDeclImpl.scala
+++ b/src/col/vct/col/ast/declaration/singular/LabelDeclImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.LabelDecl
import vct.col.print._
import vct.col.ast.ops.{LabelDeclOps, LabelDeclFamilyOps}
-trait LabelDeclImpl[G] extends LabelDeclOps[G] with LabelDeclFamilyOps[G] { this: LabelDecl[G] =>
+trait LabelDeclImpl[G] extends LabelDeclOps[G] with LabelDeclFamilyOps[G] {
+ this: LabelDecl[G] =>
override def layout(implicit ctx: Ctx): Doc = Text(ctx.name(this))
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/declaration/singular/ParBlockDeclImpl.scala b/src/col/vct/col/ast/declaration/singular/ParBlockDeclImpl.scala
index 1cd52f9ba1..6fe58a1448 100644
--- a/src/col/vct/col/ast/declaration/singular/ParBlockDeclImpl.scala
+++ b/src/col/vct/col/ast/declaration/singular/ParBlockDeclImpl.scala
@@ -4,6 +4,8 @@ import vct.col.ast.ParBlockDecl
import vct.col.print._
import vct.col.ast.ops.{ParBlockDeclOps, ParBlockDeclFamilyOps}
-trait ParBlockDeclImpl[G] extends ParBlockDeclOps[G] with ParBlockDeclFamilyOps[G] { this: ParBlockDecl[G] =>
+trait ParBlockDeclImpl[G]
+ extends ParBlockDeclOps[G] with ParBlockDeclFamilyOps[G] {
+ this: ParBlockDecl[G] =>
override def layout(implicit ctx: Ctx): Doc = Text(ctx.name(this))
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/declaration/singular/ParInvariantDeclImpl.scala b/src/col/vct/col/ast/declaration/singular/ParInvariantDeclImpl.scala
index 6b14813606..ca31281794 100644
--- a/src/col/vct/col/ast/declaration/singular/ParInvariantDeclImpl.scala
+++ b/src/col/vct/col/ast/declaration/singular/ParInvariantDeclImpl.scala
@@ -4,6 +4,8 @@ import vct.col.ast.ParInvariantDecl
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.{ParInvariantDeclOps, ParInvariantDeclFamilyOps}
-trait ParInvariantDeclImpl[G] extends ParInvariantDeclOps[G] with ParInvariantDeclFamilyOps[G] { this: ParInvariantDecl[G] =>
+trait ParInvariantDeclImpl[G]
+ extends ParInvariantDeclOps[G] with ParInvariantDeclFamilyOps[G] {
+ this: ParInvariantDecl[G] =>
override def layout(implicit ctx: Ctx): Doc = Text(ctx.name(this))
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/declaration/singular/SendDeclImpl.scala b/src/col/vct/col/ast/declaration/singular/SendDeclImpl.scala
index 57a1b64d00..273aee6de9 100644
--- a/src/col/vct/col/ast/declaration/singular/SendDeclImpl.scala
+++ b/src/col/vct/col/ast/declaration/singular/SendDeclImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.SendDecl
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.{SendDeclOps, SendDeclFamilyOps}
-trait SendDeclImpl[G] extends SendDeclOps[G] with SendDeclFamilyOps[G] { this: SendDecl[G] =>
+trait SendDeclImpl[G] extends SendDeclOps[G] with SendDeclFamilyOps[G] {
+ this: SendDecl[G] =>
override def layout(implicit ctx: Ctx): Doc = Text(ctx.name(this))
}
diff --git a/src/col/vct/col/ast/declaration/singular/VariableImpl.scala b/src/col/vct/col/ast/declaration/singular/VariableImpl.scala
index 81fb5d6417..de51f9efe6 100644
--- a/src/col/vct/col/ast/declaration/singular/VariableImpl.scala
+++ b/src/col/vct/col/ast/declaration/singular/VariableImpl.scala
@@ -4,12 +4,14 @@ import vct.col.ast.Variable
import vct.col.print._
import vct.col.ast.ops.{VariableOps, VariableFamilyOps}
-trait VariableImpl[G] extends VariableOps[G] with VariableFamilyOps[G] { this: Variable[G] =>
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.C | Ctx.Cuda | Ctx.OpenCL | Ctx.CPP =>
- val (spec, decl) = t.layoutSplitDeclarator
- spec <+> decl <> ctx.name(this)
- case Ctx.PVL | Ctx.Java => t.show <+> ctx.name(this)
- case Ctx.Silver => Text(ctx.name(this)) <> ":" <+> t
- }
-}
\ No newline at end of file
+trait VariableImpl[G] extends VariableOps[G] with VariableFamilyOps[G] {
+ this: Variable[G] =>
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.C | Ctx.Cuda | Ctx.OpenCL | Ctx.CPP =>
+ val (spec, decl) = t.layoutSplitDeclarator
+ spec <+> decl <> ctx.name(this)
+ case Ctx.PVL | Ctx.Java => t.show <+> ctx.name(this)
+ case Ctx.Silver => Text(ctx.name(this)) <> ":" <+> t
+ }
+}
diff --git a/src/col/vct/col/ast/expr/ExprImpl.scala b/src/col/vct/col/ast/expr/ExprImpl.scala
index ef7494c9b3..a7d670d791 100644
--- a/src/col/vct/col/ast/expr/ExprImpl.scala
+++ b/src/col/vct/col/ast/expr/ExprImpl.scala
@@ -7,7 +7,8 @@ import vct.col.print._
import vct.col.typerules.CoercionUtils
import vct.col.ast.ops.ExprFamilyOps
-trait ExprImpl[G] extends NodeFamilyImpl[G] with ExprFamilyOps[G] { this: Expr[G] =>
+trait ExprImpl[G] extends NodeFamilyImpl[G] with ExprFamilyOps[G] {
+ this: Expr[G] =>
def checkSubType(other: Type[G]): Seq[CheckError] =
CoercionUtils.getCoercion(t, other) match {
case Some(_) => Nil
@@ -16,27 +17,36 @@ trait ExprImpl[G] extends NodeFamilyImpl[G] with ExprFamilyOps[G] { this: Expr[G
def t: Type[G]
- private def unfold(node: Expr[G])(matchFunc: PartialFunction[Expr[G], Seq[Expr[G]]]): Seq[Expr[G]] =
+ private def unfold(
+ node: Expr[G]
+ )(matchFunc: PartialFunction[Expr[G], Seq[Expr[G]]]): Seq[Expr[G]] =
matchFunc.lift(node) match {
case Some(value) => value.flatMap(unfold(_)(matchFunc))
case None => Seq(node)
}
- def unfoldStar: Seq[Expr[G]] = unfold(this) { case Star(left, right) => Seq(left, right) }
- def unfoldProcessPar: Seq[Expr[G]] = unfold(this) { case ProcessPar(l, r) => Seq(l, r) }
+ def unfoldStar: Seq[Expr[G]] =
+ unfold(this) { case Star(left, right) => Seq(left, right) }
+ def unfoldProcessPar: Seq[Expr[G]] =
+ unfold(this) { case ProcessPar(l, r) => Seq(l, r) }
def precedence: Int = Precedence.UNKNOWN
def bind(precedence: Int)(implicit ctx: Ctx): Doc =
- if(this.precedence >= precedence) show
- else Text("(") <> show <> ")"
+ if (this.precedence >= precedence)
+ show
+ else
+ Text("(") <> show <> ")"
def assoc(other: Expr[_])(implicit ctx: Ctx): Doc = other.bind(precedence)
- def nassoc(other: Expr[_])(implicit ctx: Ctx): Doc = other.bind(precedence-1)
+ def nassoc(other: Expr[_])(implicit ctx: Ctx): Doc =
+ other.bind(precedence - 1)
- def lassoc(left: Expr[_], op: String, right: Expr[_])(implicit ctx: Ctx): Doc =
- Group(assoc(left) <+> op <+/> nassoc(right))
+ def lassoc(left: Expr[_], op: String, right: Expr[_])(
+ implicit ctx: Ctx
+ ): Doc = Group(assoc(left) <+> op <+/> nassoc(right))
- def rassoc(left: Expr[_], op: String, right: Expr[_])(implicit ctx: Ctx): Doc =
- Group(nassoc(left) <+> op <+/> assoc(right))
-}
\ No newline at end of file
+ def rassoc(left: Expr[_], op: String, right: Expr[_])(
+ implicit ctx: Ctx
+ ): Doc = Group(nassoc(left) <+> op <+/> assoc(right))
+}
diff --git a/src/col/vct/col/ast/expr/ambiguous/AmbiguousComputationalAndImpl.scala b/src/col/vct/col/ast/expr/ambiguous/AmbiguousComputationalAndImpl.scala
index fda25becfa..02d3a1f62c 100644
--- a/src/col/vct/col/ast/expr/ambiguous/AmbiguousComputationalAndImpl.scala
+++ b/src/col/vct/col/ast/expr/ambiguous/AmbiguousComputationalAndImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.AmbiguousComputationalAnd
import vct.col.print._
import vct.col.ast.ops.AmbiguousComputationalAndOps
-trait AmbiguousComputationalAndImpl[G] extends AmbiguousComputationalAndOps[G] { this: AmbiguousComputationalAnd[G] =>
+trait AmbiguousComputationalAndImpl[G] extends AmbiguousComputationalAndOps[G] {
+ this: AmbiguousComputationalAnd[G] =>
override def precedence: Int = Precedence.BIT_AND
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "&", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/ambiguous/AmbiguousComputationalOrImpl.scala b/src/col/vct/col/ast/expr/ambiguous/AmbiguousComputationalOrImpl.scala
index f390dc13ad..b8e88ab440 100644
--- a/src/col/vct/col/ast/expr/ambiguous/AmbiguousComputationalOrImpl.scala
+++ b/src/col/vct/col/ast/expr/ambiguous/AmbiguousComputationalOrImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.AmbiguousComputationalOr
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.AmbiguousComputationalOrOps
-trait AmbiguousComputationalOrImpl[G] extends AmbiguousComputationalOrOps[G] { this: AmbiguousComputationalOr[G] =>
+trait AmbiguousComputationalOrImpl[G] extends AmbiguousComputationalOrOps[G] {
+ this: AmbiguousComputationalOr[G] =>
override def precedence: Int = Precedence.BIT_OR
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "|", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/ambiguous/AmbiguousComputationalXorImpl.scala b/src/col/vct/col/ast/expr/ambiguous/AmbiguousComputationalXorImpl.scala
index bb45d900f5..5456b8fb23 100644
--- a/src/col/vct/col/ast/expr/ambiguous/AmbiguousComputationalXorImpl.scala
+++ b/src/col/vct/col/ast/expr/ambiguous/AmbiguousComputationalXorImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.AmbiguousComputationalXor
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.AmbiguousComputationalXorOps
-trait AmbiguousComputationalXorImpl[G] extends AmbiguousComputationalXorOps[G] { this: AmbiguousComputationalXor[G] =>
+trait AmbiguousComputationalXorImpl[G] extends AmbiguousComputationalXorOps[G] {
+ this: AmbiguousComputationalXor[G] =>
override def precedence: Int = Precedence.BIT_XOR
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "^", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/ambiguous/AmbiguousMemberImpl.scala b/src/col/vct/col/ast/expr/ambiguous/AmbiguousMemberImpl.scala
index 63d681dc62..8e6394f706 100644
--- a/src/col/vct/col/ast/expr/ambiguous/AmbiguousMemberImpl.scala
+++ b/src/col/vct/col/ast/expr/ambiguous/AmbiguousMemberImpl.scala
@@ -5,20 +5,37 @@ import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.typerules.CoercionUtils
import vct.col.ast.ops.AmbiguousMemberOps
-trait AmbiguousMemberImpl[G] extends AmbiguousMemberOps[G] { this: AmbiguousMember[G] =>
+trait AmbiguousMemberImpl[G] extends AmbiguousMemberOps[G] {
+ this: AmbiguousMember[G] =>
def isSeqOp: Boolean = CoercionUtils.getAnySeqCoercion(xs.t).isDefined
def isSetOp: Boolean = CoercionUtils.getAnySetCoercion(xs.t).isDefined
def isMapOp: Boolean = CoercionUtils.getAnyMapCoercion(xs.t).isDefined
def isBagOp: Boolean = CoercionUtils.getAnyBagCoercion(xs.t).isDefined
def collectionElementType: Type[G] =
- if(isSeqOp) xs.t.asSeq.get.element
- else if(isSetOp) xs.t.asSet.get.element
- else if(isBagOp) xs.t.asBag.get.element
- else xs.t.asMap.get.key
+ if (isSeqOp)
+ xs.t.asSeq.get.element
+ else if (isSetOp)
+ xs.t.asSet.get.element
+ else if (isBagOp)
+ xs.t.asBag.get.element
+ else
+ xs.t.asMap.get.key
- override lazy val t: Type[G] = if(isBagOp) TInt() else TBool()
+ override lazy val t: Type[G] =
+ if (isBagOp)
+ TInt()
+ else
+ TBool()
override def precedence: Int = Precedence.PVL_CONTAINS
- override def layout(implicit ctx: Ctx): Doc = lassoc(x, if(ctx.syntax == Ctx.Silver) "in" else "\\in", xs)
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ lassoc(
+ x,
+ if (ctx.syntax == Ctx.Silver)
+ "in"
+ else
+ "\\in",
+ xs,
+ )
+}
diff --git a/src/col/vct/col/ast/expr/ambiguous/AmbiguousMinusImpl.scala b/src/col/vct/col/ast/expr/ambiguous/AmbiguousMinusImpl.scala
index 567e0dbd64..b025bb5638 100644
--- a/src/col/vct/col/ast/expr/ambiguous/AmbiguousMinusImpl.scala
+++ b/src/col/vct/col/ast/expr/ambiguous/AmbiguousMinusImpl.scala
@@ -5,12 +5,16 @@ import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.typerules.{CoercionUtils, Types}
import vct.col.ast.ops.AmbiguousMinusOps
-trait AmbiguousMinusImpl[G] extends AmbiguousMinusOps[G] { this: AmbiguousMinus[G] =>
+trait AmbiguousMinusImpl[G] extends AmbiguousMinusOps[G] {
+ this: AmbiguousMinus[G] =>
override lazy val t: Type[G] = {
- if(isSetOp || isBagOp || isVectorOp) Types.leastCommonSuperType(left.t, right.t)
- else if(isPointerOp) left.t
- else getNumericType
+ if (isSetOp || isBagOp || isVectorOp)
+ Types.leastCommonSuperType(left.t, right.t)
+ else if (isPointerOp)
+ left.t
+ else
+ getNumericType
}
override def precedence: Int = Precedence.ADDITIVE
diff --git a/src/col/vct/col/ast/expr/ambiguous/AmbiguousMultImpl.scala b/src/col/vct/col/ast/expr/ambiguous/AmbiguousMultImpl.scala
index f4d924a9dc..9b5911fba6 100644
--- a/src/col/vct/col/ast/expr/ambiguous/AmbiguousMultImpl.scala
+++ b/src/col/vct/col/ast/expr/ambiguous/AmbiguousMultImpl.scala
@@ -5,12 +5,16 @@ import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.typerules.{CoercionUtils, Types}
import vct.col.ast.ops.AmbiguousMultOps
-trait AmbiguousMultImpl[G] extends AmbiguousMultOps[G] { this: AmbiguousMult[G] =>
+trait AmbiguousMultImpl[G] extends AmbiguousMultOps[G] {
+ this: AmbiguousMult[G] =>
override lazy val t: Type[G] =
- if (isVectorOp) Types.leastCommonSuperType(left.t, right.t)
- else if(isProcessOp) TProcess()
- else getNumericType
+ if (isVectorOp)
+ Types.leastCommonSuperType(left.t, right.t)
+ else if (isProcessOp)
+ TProcess()
+ else
+ getNumericType
override def precedence: Int = Precedence.MULTIPLICATIVE
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "*", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/ambiguous/AmbiguousOrImpl.scala b/src/col/vct/col/ast/expr/ambiguous/AmbiguousOrImpl.scala
index 6ac94ecc56..b60df088b8 100644
--- a/src/col/vct/col/ast/expr/ambiguous/AmbiguousOrImpl.scala
+++ b/src/col/vct/col/ast/expr/ambiguous/AmbiguousOrImpl.scala
@@ -5,9 +5,14 @@ import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.typerules.CoercionUtils
import vct.col.ast.ops.AmbiguousOrOps
-trait AmbiguousOrImpl[G] extends AmbiguousOrOps[G] { this: AmbiguousOr[G] =>
- override lazy val t: Type[G] = if(isProcessOp) TProcess() else TBool()
+trait AmbiguousOrImpl[G] extends AmbiguousOrOps[G] {
+ this: AmbiguousOr[G] =>
+ override lazy val t: Type[G] =
+ if (isProcessOp)
+ TProcess()
+ else
+ TBool()
override def precedence: Int = Precedence.OR
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "||", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/ambiguous/AmbiguousPlusImpl.scala b/src/col/vct/col/ast/expr/ambiguous/AmbiguousPlusImpl.scala
index ba7daae607..8a227e7898 100644
--- a/src/col/vct/col/ast/expr/ambiguous/AmbiguousPlusImpl.scala
+++ b/src/col/vct/col/ast/expr/ambiguous/AmbiguousPlusImpl.scala
@@ -7,20 +7,32 @@ import vct.col.typerules.{CoercionUtils, Types}
import vct.result.VerificationError.Unreachable
import vct.col.ast.ops.AmbiguousPlusOps
-trait AmbiguousPlusImpl[G] extends AmbiguousPlusOps[G] { this: AmbiguousPlus[G] =>
+trait AmbiguousPlusImpl[G] extends AmbiguousPlusOps[G] {
+ this: AmbiguousPlus[G] =>
- def getValidOperatorsOf(operator: Operator[G]): Option[Seq[ContractApplicable[G]]] = {
- val subject = if(operator == OperatorLeftPlus[G]()) left else right
- val decls = subject.t match {
- case TClass(Ref(cls), _) => cls.decls
- case JavaTClass(Ref(cls), _) => cls.decls
- case _ => return None
- }
+ def getValidOperatorsOf(
+ operator: Operator[G]
+ ): Option[Seq[ContractApplicable[G]]] = {
+ val subject =
+ if (operator == OperatorLeftPlus[G]())
+ left
+ else
+ right
+ val decls =
+ subject.t match {
+ case TClass(Ref(cls), _) => cls.decls
+ case JavaTClass(Ref(cls), _) => cls.decls
+ case _ => return None
+ }
Some(decls.collect {
- case m: InstanceOperatorMethod[G] if m.operator == operator
- && CoercionUtils.getCoercion(right.t, m.args.head.t).isDefined => m
- case f: InstanceOperatorFunction[G] if f.operator == operator
- && CoercionUtils.getCoercion(right.t, f.args.head.t).isDefined => f
+ case m: InstanceOperatorMethod[G]
+ if m.operator == operator &&
+ CoercionUtils.getCoercion(right.t, m.args.head.t).isDefined =>
+ m
+ case f: InstanceOperatorFunction[G]
+ if f.operator == operator &&
+ CoercionUtils.getCoercion(right.t, f.args.head.t).isDefined =>
+ f
})
}
@@ -38,14 +50,20 @@ trait AmbiguousPlusImpl[G] extends AmbiguousPlusOps[G] { this: AmbiguousPlus[G]
.orElse(getCustomPlusType(OperatorRightPlus[G]()))
override lazy val t: Type[G] = {
- if(isProcessOp) TProcess()
- else if(isSeqOp || isBagOp || isSetOp || isVectorOp) Types.leastCommonSuperType(left.t, right.t)
- else if(isPointerOp) left.t
- else if(isStringOp) TString()
- else if(getCustomPlusOpType().isDefined) getCustomPlusOpType().get
- else getNumericType
+ if (isProcessOp)
+ TProcess()
+ else if (isSeqOp || isBagOp || isSetOp || isVectorOp)
+ Types.leastCommonSuperType(left.t, right.t)
+ else if (isPointerOp)
+ left.t
+ else if (isStringOp)
+ TString()
+ else if (getCustomPlusOpType().isDefined)
+ getCustomPlusOpType().get
+ else
+ getNumericType
}
override def precedence: Int = Precedence.ADDITIVE
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "+", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/ambiguous/AmbiguousSubscriptImpl.scala b/src/col/vct/col/ast/expr/ambiguous/AmbiguousSubscriptImpl.scala
index fa37731f0b..b74c29e42c 100644
--- a/src/col/vct/col/ast/expr/ambiguous/AmbiguousSubscriptImpl.scala
+++ b/src/col/vct/col/ast/expr/ambiguous/AmbiguousSubscriptImpl.scala
@@ -6,26 +6,42 @@ import vct.col.typerules.CoercionUtils
import vct.result.VerificationError.Unreachable
import vct.col.ast.ops.AmbiguousSubscriptOps
-trait AmbiguousSubscriptImpl[G] extends AmbiguousSubscriptOps[G] { this: AmbiguousSubscript[G] =>
+trait AmbiguousSubscriptImpl[G] extends AmbiguousSubscriptOps[G] {
+ this: AmbiguousSubscript[G] =>
def isSeqOp: Boolean = CoercionUtils.getAnySeqCoercion(collection.t).isDefined
- def isVectorOp: Boolean = CoercionUtils.getAnyVectorCoercion(collection.t).isDefined
- def isArrayOp: Boolean = CoercionUtils.getAnyArrayCoercion(collection.t).isDefined
- def isCArrayOp: Boolean = CoercionUtils.getAnyCArrayCoercion(collection.t).isDefined
- def isCPPArrayOp: Boolean = CoercionUtils.getAnyCPPArrayCoercion(collection.t).isDefined
- def isPointerOp: Boolean = CoercionUtils.getAnyPointerCoercion(collection.t).isDefined
+ def isVectorOp: Boolean =
+ CoercionUtils.getAnyVectorCoercion(collection.t).isDefined
+ def isArrayOp: Boolean =
+ CoercionUtils.getAnyArrayCoercion(collection.t).isDefined
+ def isCArrayOp: Boolean =
+ CoercionUtils.getAnyCArrayCoercion(collection.t).isDefined
+ def isCPPArrayOp: Boolean =
+ CoercionUtils.getAnyCPPArrayCoercion(collection.t).isDefined
+ def isPointerOp: Boolean =
+ CoercionUtils.getAnyPointerCoercion(collection.t).isDefined
def isMapOp: Boolean = CoercionUtils.getAnyMapCoercion(collection.t).isDefined
override lazy val t: Type[G] =
- if (isSeqOp) collection.t.asSeq.get.element
- else if (isVectorOp) collection.t.asVector.get.element
- else if (isArrayOp) collection.t.asArray.get.element
- else if (isCArrayOp) collection.t.asCArray.get.innerType
- else if (isCPPArrayOp) collection.t.asCPPArray.get.innerType
- else if (isPointerOp) collection.t.asPointer.get.element
- else if (isMapOp) collection.t.asMap.get.value
- else throw Unreachable(s"Trying to subscript ($this) a non subscriptable variable with type ${collection.t}")
+ if (isSeqOp)
+ collection.t.asSeq.get.element
+ else if (isVectorOp)
+ collection.t.asVector.get.element
+ else if (isArrayOp)
+ collection.t.asArray.get.element
+ else if (isCArrayOp)
+ collection.t.asCArray.get.innerType
+ else if (isCPPArrayOp)
+ collection.t.asCPPArray.get.innerType
+ else if (isPointerOp)
+ collection.t.asPointer.get.element
+ else if (isMapOp)
+ collection.t.asMap.get.value
+ else
+ throw Unreachable(
+ s"Trying to subscript ($this) a non subscriptable variable with type ${collection.t}"
+ )
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Group(assoc(collection) <> "[" <> Doc.arg(index) <> "]")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/apply/ADTFunctionInvocationImpl.scala b/src/col/vct/col/ast/expr/apply/ADTFunctionInvocationImpl.scala
index b22c9f2198..917bae2def 100644
--- a/src/col/vct/col/ast/expr/apply/ADTFunctionInvocationImpl.scala
+++ b/src/col/vct/col/ast/expr/apply/ADTFunctionInvocationImpl.scala
@@ -5,7 +5,8 @@ import vct.col.print._
import vct.col.ref.Ref
import vct.col.ast.ops.ADTFunctionInvocationOps
-trait ADTFunctionInvocationImpl[G] extends ADTFunctionInvocationOps[G] { this: ADTFunctionInvocation[G] =>
+trait ADTFunctionInvocationImpl[G] extends ADTFunctionInvocationOps[G] {
+ this: ADTFunctionInvocation[G] =>
override def ref: Ref[G, _ <: ADTFunction[G]]
override lazy val t: Type[G] =
typeArgs match {
@@ -14,24 +15,28 @@ trait ADTFunctionInvocationImpl[G] extends ADTFunctionInvocationOps[G] { this: A
case None => ref.decl.returnType
}
- def layoutSpec(implicit ctx: Ctx): Doc = typeArgs match {
- case None => layoutSilver // will not be resolvable anyway
- case Some((adt, typeArgs)) =>
- Group(
+ def layoutSpec(implicit ctx: Ctx): Doc =
+ typeArgs match {
+ case None => layoutSilver // will not be resolvable anyway
+ case Some((adt, typeArgs)) =>
Group(
- Text(ctx.name(adt)) <>
- (if(typeArgs.nonEmpty) Text("<") <> Doc.args(typeArgs) <> ">" else Empty) <>
- "." <> ctx.name(ref) <> "("
- ) <> Doc.args(args) <> ")"
- )
- }
+ Group(
+ Text(ctx.name(adt)) <>
+ (if (typeArgs.nonEmpty)
+ Text("<") <> Doc.args(typeArgs) <> ">"
+ else
+ Empty) <> "." <> ctx.name(ref) <> "("
+ ) <> Doc.args(args) <> ")"
+ )
+ }
def layoutSilver(implicit ctx: Ctx): Doc =
Group(Text(ctx.name(ref)) <> "(" <> Doc.args(args) <> ")")
override def precedence: Int = Precedence.POSTFIX
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.Silver => layoutSilver
- case _ => layoutSpec
- }
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.Silver => layoutSilver
+ case _ => layoutSpec
+ }
+}
diff --git a/src/col/vct/col/ast/expr/apply/ActionApplyImpl.scala b/src/col/vct/col/ast/expr/apply/ActionApplyImpl.scala
index 1d98b32f01..31b8e912e3 100644
--- a/src/col/vct/col/ast/expr/apply/ActionApplyImpl.scala
+++ b/src/col/vct/col/ast/expr/apply/ActionApplyImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{ActionApply, TProcess, Type}
import vct.col.print.{Ctx, Doc, Precedence, Text, Group}
import vct.col.ast.ops.ActionApplyOps
-trait ActionApplyImpl[G] extends ActionApplyOps[G] { this: ActionApply[G] =>
+trait ActionApplyImpl[G] extends ActionApplyOps[G] {
+ this: ActionApply[G] =>
override def t: Type[G] = TProcess()
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Group(Text(ctx.name(action)) <> "(" <> Doc.args(args) <> ")")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/apply/AnyFunctionInvocationImpl.scala b/src/col/vct/col/ast/expr/apply/AnyFunctionInvocationImpl.scala
index fd0d481cba..8f15ab4867 100644
--- a/src/col/vct/col/ast/expr/apply/AnyFunctionInvocationImpl.scala
+++ b/src/col/vct/col/ast/expr/apply/AnyFunctionInvocationImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.expr.apply
import vct.col.ast.{AbstractFunction, AnyFunctionInvocation}
import vct.col.ref.Ref
-trait AnyFunctionInvocationImpl[G] { this: AnyFunctionInvocation[G] =>
+trait AnyFunctionInvocationImpl[G] {
+ this: AnyFunctionInvocation[G] =>
override def ref: Ref[G, _ <: AbstractFunction[G]]
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/apply/AnyMethodInvocationImpl.scala b/src/col/vct/col/ast/expr/apply/AnyMethodInvocationImpl.scala
index d6307d9c0f..63bce7b4f0 100644
--- a/src/col/vct/col/ast/expr/apply/AnyMethodInvocationImpl.scala
+++ b/src/col/vct/col/ast/expr/apply/AnyMethodInvocationImpl.scala
@@ -3,7 +3,8 @@ package vct.col.ast.expr.apply
import vct.col.ast.{AbstractMethod, AnyMethodInvocation, Expr}
import vct.col.ref.Ref
-trait AnyMethodInvocationImpl[G] { this: AnyMethodInvocation[G] =>
+trait AnyMethodInvocationImpl[G] {
+ this: AnyMethodInvocation[G] =>
override def ref: Ref[G, _ <: AbstractMethod[G]]
def outArgs: Seq[Expr[G]]
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/apply/ApplyAnyPredicateImpl.scala b/src/col/vct/col/ast/expr/apply/ApplyAnyPredicateImpl.scala
index 99063b0708..6a2478e367 100644
--- a/src/col/vct/col/ast/expr/apply/ApplyAnyPredicateImpl.scala
+++ b/src/col/vct/col/ast/expr/apply/ApplyAnyPredicateImpl.scala
@@ -3,7 +3,8 @@ package vct.col.ast.expr.apply
import vct.col.ast.{AbstractPredicate, ApplyAnyPredicate, Expr}
import vct.col.ref.Ref
-trait ApplyAnyPredicateImpl[G] { this: ApplyAnyPredicate[G] =>
+trait ApplyAnyPredicateImpl[G] {
+ this: ApplyAnyPredicate[G] =>
override def ref: Ref[G, _ <: AbstractPredicate[G]]
def perm: Expr[G]
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/apply/ApplyImpl.scala b/src/col/vct/col/ast/expr/apply/ApplyImpl.scala
index e4a68f19aa..ba9d78a3fa 100644
--- a/src/col/vct/col/ast/expr/apply/ApplyImpl.scala
+++ b/src/col/vct/col/ast/expr/apply/ApplyImpl.scala
@@ -3,9 +3,10 @@ package vct.col.ast.expr.apply
import vct.col.ast.{Applicable, Apply, Expr, Type}
import vct.col.ref.Ref
-trait ApplyImpl[G] { this: Apply[G] =>
+trait ApplyImpl[G] {
+ this: Apply[G] =>
def ref: Ref[G, _ <: Applicable[G]]
def args: Seq[Expr[G]]
override def t: Type[G] = ref.decl.returnType
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/apply/ApplyInlineableImpl.scala b/src/col/vct/col/ast/expr/apply/ApplyInlineableImpl.scala
index 1156bc07d3..974fe8e047 100644
--- a/src/col/vct/col/ast/expr/apply/ApplyInlineableImpl.scala
+++ b/src/col/vct/col/ast/expr/apply/ApplyInlineableImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.expr.apply
import vct.col.ast.{ApplyInlineable, InlineableApplicable}
import vct.col.ref.Ref
-trait ApplyInlineableImpl[G] { this: ApplyInlineable[G] =>
+trait ApplyInlineableImpl[G] {
+ this: ApplyInlineable[G] =>
override def ref: Ref[G, _ <: InlineableApplicable[G]]
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/apply/CoalesceInstancePredicateApplyImpl.scala b/src/col/vct/col/ast/expr/apply/CoalesceInstancePredicateApplyImpl.scala
index caf7530b63..b0c5c62df1 100644
--- a/src/col/vct/col/ast/expr/apply/CoalesceInstancePredicateApplyImpl.scala
+++ b/src/col/vct/col/ast/expr/apply/CoalesceInstancePredicateApplyImpl.scala
@@ -4,8 +4,13 @@ import vct.col.ast.CoalesceInstancePredicateApply
import vct.col.print._
import vct.col.ast.ops.CoalesceInstancePredicateApplyOps
-trait CoalesceInstancePredicateApplyImpl[G] extends CoalesceInstancePredicateApplyOps[G] { this: CoalesceInstancePredicateApply[G] =>
+trait CoalesceInstancePredicateApplyImpl[G]
+ extends CoalesceInstancePredicateApplyOps[G] {
+ this: CoalesceInstancePredicateApply[G] =>
override def precedence: Int = Precedence.PREFIX
override def layout(implicit ctx: Ctx): Doc =
- Group(Text("[") <> perm <> "]" <> obj.bind(Precedence.POSTFIX) <> "?." <> ctx.name(ref) <> "(" <> Doc.args(args) <> ")")
+ Group(
+ Text("[") <> perm <> "]" <> obj.bind(Precedence.POSTFIX) <> "?." <>
+ ctx.name(ref) <> "(" <> Doc.args(args) <> ")"
+ )
}
diff --git a/src/col/vct/col/ast/expr/apply/FunctionInvocationImpl.scala b/src/col/vct/col/ast/expr/apply/FunctionInvocationImpl.scala
index f0aeef2478..58c8364c52 100644
--- a/src/col/vct/col/ast/expr/apply/FunctionInvocationImpl.scala
+++ b/src/col/vct/col/ast/expr/apply/FunctionInvocationImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{FunctionInvocation, Variable, Type}
import vct.col.print._
import vct.col.ast.ops.FunctionInvocationOps
-trait FunctionInvocationImpl[G] extends FunctionInvocationOps[G] { this: FunctionInvocation[G] =>
+trait FunctionInvocationImpl[G] extends FunctionInvocationOps[G] {
+ this: FunctionInvocation[G] =>
def layoutSilver(implicit ctx: Ctx): Doc =
Group(Text(ctx.name(ref)) <> "(" <> Doc.args(args) <> ")")
@@ -12,16 +13,20 @@ trait FunctionInvocationImpl[G] extends FunctionInvocationOps[G] { this: Functio
Group(
Group(
Text(ctx.name(ref)) <>
- (if(typeArgs.nonEmpty) Text("<") <> Doc.args(typeArgs) <> ">" else Empty) <>
- "("
+ (if (typeArgs.nonEmpty)
+ Text("<") <> Doc.args(typeArgs) <> ">"
+ else
+ Empty) <> "("
) <> Doc.args(args) <> ")" <> DocUtil.givenYields(givenMap, yields)
)
override def precedence: Int = Precedence.POSTFIX
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.Silver => layoutSilver
- case _ => layoutSpec
- }
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.Silver => layoutSilver
+ case _ => layoutSpec
+ }
- override def typeEnv: Map[Variable[G], Type[G]] = ref.decl.typeArgs.zip(typeArgs).toMap
+ override def typeEnv: Map[Variable[G], Type[G]] =
+ ref.decl.typeArgs.zip(typeArgs).toMap
}
diff --git a/src/col/vct/col/ast/expr/apply/InstanceApplyImpl.scala b/src/col/vct/col/ast/expr/apply/InstanceApplyImpl.scala
index 1069eff2f3..b54da17ac6 100644
--- a/src/col/vct/col/ast/expr/apply/InstanceApplyImpl.scala
+++ b/src/col/vct/col/ast/expr/apply/InstanceApplyImpl.scala
@@ -3,7 +3,8 @@ package vct.col.ast.expr.apply
import vct.col.ast.{ClassDeclaration, Expr, InstanceApply}
import vct.col.ref.Ref
-trait InstanceApplyImpl[G] { this: InstanceApply[G] =>
+trait InstanceApplyImpl[G] {
+ this: InstanceApply[G] =>
def ref: Ref[G, _ <: ClassDeclaration[G]]
def obj: Expr[G]
}
diff --git a/src/col/vct/col/ast/expr/apply/InstanceFunctionInvocationImpl.scala b/src/col/vct/col/ast/expr/apply/InstanceFunctionInvocationImpl.scala
index 9cb8e81e06..c200d872c6 100644
--- a/src/col/vct/col/ast/expr/apply/InstanceFunctionInvocationImpl.scala
+++ b/src/col/vct/col/ast/expr/apply/InstanceFunctionInvocationImpl.scala
@@ -4,14 +4,18 @@ import vct.col.ast.{InstanceFunctionInvocation, Variable, Type}
import vct.col.print.{Ctx, Doc, DocUtil, Empty, Group, Precedence, Text}
import vct.col.ast.ops.InstanceFunctionInvocationOps
-trait InstanceFunctionInvocationImpl[G] extends InstanceFunctionInvocationOps[G] { this: InstanceFunctionInvocation[G] =>
+trait InstanceFunctionInvocationImpl[G]
+ extends InstanceFunctionInvocationOps[G] {
+ this: InstanceFunctionInvocation[G] =>
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Group(
Group(
assoc(obj) <> "." <> ctx.name(ref) <>
- (if (typeArgs.nonEmpty) Text("<") <> Doc.args(typeArgs) <> ">" else Empty) <>
- "("
+ (if (typeArgs.nonEmpty)
+ Text("<") <> Doc.args(typeArgs) <> ">"
+ else
+ Empty) <> "("
) <> Doc.args(args) <> ")" <> DocUtil.givenYields(givenMap, yields)
)
diff --git a/src/col/vct/col/ast/expr/apply/InstancePredicateApplyImpl.scala b/src/col/vct/col/ast/expr/apply/InstancePredicateApplyImpl.scala
index 9108c285e0..0af2b57712 100644
--- a/src/col/vct/col/ast/expr/apply/InstancePredicateApplyImpl.scala
+++ b/src/col/vct/col/ast/expr/apply/InstancePredicateApplyImpl.scala
@@ -4,8 +4,12 @@ import vct.col.ast.InstancePredicateApply
import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.ast.ops.InstancePredicateApplyOps
-trait InstancePredicateApplyImpl[G] extends InstancePredicateApplyOps[G] { this: InstancePredicateApply[G] =>
+trait InstancePredicateApplyImpl[G] extends InstancePredicateApplyOps[G] {
+ this: InstancePredicateApply[G] =>
override def precedence: Int = Precedence.PREFIX
override def layout(implicit ctx: Ctx): Doc =
- Group(Text("[") <> perm <> "]" <> obj.bind(Precedence.POSTFIX) <> "." <> ctx.name(ref) <> "(" <> Doc.args(args) <> ")")
+ Group(
+ Text("[") <> perm <> "]" <> obj.bind(Precedence.POSTFIX) <> "." <>
+ ctx.name(ref) <> "(" <> Doc.args(args) <> ")"
+ )
}
diff --git a/src/col/vct/col/ast/expr/apply/InvocationImpl.scala b/src/col/vct/col/ast/expr/apply/InvocationImpl.scala
index 66ce34916b..98b9beada9 100644
--- a/src/col/vct/col/ast/expr/apply/InvocationImpl.scala
+++ b/src/col/vct/col/ast/expr/apply/InvocationImpl.scala
@@ -2,7 +2,8 @@ package vct.col.ast.expr.apply
import vct.col.ast.{Invocation, Type, Variable}
-trait InvocationImpl[G] extends ApplyImpl[G] { this: Invocation[G] =>
+trait InvocationImpl[G] extends ApplyImpl[G] {
+ this: Invocation[G] =>
override def t: Type[G] = super.t.particularize(typeEnv)
def typeEnv: Map[Variable[G], Type[G]]
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/apply/MethodInvocationImpl.scala b/src/col/vct/col/ast/expr/apply/MethodInvocationImpl.scala
index 4b9c90cf07..1dee19db49 100644
--- a/src/col/vct/col/ast/expr/apply/MethodInvocationImpl.scala
+++ b/src/col/vct/col/ast/expr/apply/MethodInvocationImpl.scala
@@ -5,20 +5,26 @@ import vct.col.print.{Ctx, Doc, DocUtil, Empty, Group, Precedence, Text}
import vct.col.ast.ops.MethodInvocationOps
import vct.col.ref.Ref
-trait MethodInvocationImpl[G] extends MethodInvocationOps[G] with InvocationImpl[G] { this: MethodInvocation[G] =>
+trait MethodInvocationImpl[G]
+ extends MethodInvocationOps[G] with InvocationImpl[G] {
+ this: MethodInvocation[G] =>
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Group(
Group(
assoc(obj) <> "." <> ctx.name(ref) <>
- (if (typeArgs.nonEmpty) Text("<") <> Doc.args(typeArgs) <> ">" else Empty) <>
- "("
- ) <> Doc.args(args ++ outArgs) <> ")" <> DocUtil.givenYields(givenMap, yields)
+ (if (typeArgs.nonEmpty)
+ Text("<") <> Doc.args(typeArgs) <> ">"
+ else
+ Empty) <> "("
+ ) <> Doc.args(args ++ outArgs) <> ")" <>
+ DocUtil.givenYields(givenMap, yields)
)
- override def typeEnv: Map[Variable[G], Type[G]] = ref.decl.typeArgs.zip(typeArgs).toMap ++
- // Optionally, if the obj is a class, include its typeenv. Optionality is required because in choreographies method invocations are also
- // used, and choreographies do not have a typeenv (yet). This will be refactored into a separate node in the short term.
- obj.t.asClass.map(_.typeEnv).getOrElse(Map.empty)
+ override def typeEnv: Map[Variable[G], Type[G]] =
+ ref.decl.typeArgs.zip(typeArgs).toMap ++
+ // Optionally, if the obj is a class, include its typeenv. Optionality is required because in choreographies method invocations are also
+ // used, and choreographies do not have a typeenv (yet). This will be refactored into a separate node in the short term.
+ obj.t.asClass.map(_.typeEnv).getOrElse(Map.empty)
}
diff --git a/src/col/vct/col/ast/expr/apply/PredicateApplyImpl.scala b/src/col/vct/col/ast/expr/apply/PredicateApplyImpl.scala
index 4709df1476..52cd8b8c02 100644
--- a/src/col/vct/col/ast/expr/apply/PredicateApplyImpl.scala
+++ b/src/col/vct/col/ast/expr/apply/PredicateApplyImpl.scala
@@ -4,17 +4,24 @@ import vct.col.ast.PredicateApply
import vct.col.print.{Ctx, Doc, DocUtil, Empty, Group, Precedence, Text}
import vct.col.ast.ops.PredicateApplyOps
-trait PredicateApplyImpl[G] extends PredicateApplyOps[G] { this: PredicateApply[G] =>
+trait PredicateApplyImpl[G] extends PredicateApplyOps[G] {
+ this: PredicateApply[G] =>
override def precedence: Int = Precedence.PREFIX
def layoutSilver(implicit ctx: Ctx): Doc =
- Group(Text("acc(") <> ctx.name(ref) <> "(" <> Doc.args(args) <> "), " <> perm <> ")")
+ Group(
+ Text("acc(") <> ctx.name(ref) <> "(" <> Doc.args(args) <> "), " <> perm <>
+ ")"
+ )
def layoutSpec(implicit ctx: Ctx): Doc =
- Group(Text("[") <> perm <> "]" <> ctx.name(ref) <> "(" <> Doc.args(args) <> ")")
+ Group(
+ Text("[") <> perm <> "]" <> ctx.name(ref) <> "(" <> Doc.args(args) <> ")"
+ )
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.Silver => layoutSilver
- case _ => layoutSpec
- }
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.Silver => layoutSilver
+ case _ => layoutSpec
+ }
}
diff --git a/src/col/vct/col/ast/expr/apply/ProcedureInvocationImpl.scala b/src/col/vct/col/ast/expr/apply/ProcedureInvocationImpl.scala
index bd6fc83b87..006115a1ea 100644
--- a/src/col/vct/col/ast/expr/apply/ProcedureInvocationImpl.scala
+++ b/src/col/vct/col/ast/expr/apply/ProcedureInvocationImpl.scala
@@ -4,17 +4,22 @@ import vct.col.ast.{ProcedureInvocation, Type, Variable}
import vct.col.print._
import vct.col.ast.ops.ProcedureInvocationOps
-trait ProcedureInvocationImpl[G] extends ProcedureInvocationOps[G] { this: ProcedureInvocation[G] =>
+trait ProcedureInvocationImpl[G] extends ProcedureInvocationOps[G] {
+ this: ProcedureInvocation[G] =>
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Group(
Group(
Text(ctx.name(ref)) <>
- (if (typeArgs.nonEmpty) Text("<") <> Doc.args(typeArgs) <> ">" else Empty) <>
- "("
- ) <> Doc.args(args ++ outArgs) <> ")" <> DocUtil.givenYields(givenMap, yields)
+ (if (typeArgs.nonEmpty)
+ Text("<") <> Doc.args(typeArgs) <> ">"
+ else
+ Empty) <> "("
+ ) <> Doc.args(args ++ outArgs) <> ")" <>
+ DocUtil.givenYields(givenMap, yields)
)
- override def typeEnv: Map[Variable[G], Type[G]] = ref.decl.typeArgs.zip(typeArgs).toMap
-}
\ No newline at end of file
+ override def typeEnv: Map[Variable[G], Type[G]] =
+ ref.decl.typeArgs.zip(typeArgs).toMap
+}
diff --git a/src/col/vct/col/ast/expr/apply/ProcessApplyImpl.scala b/src/col/vct/col/ast/expr/apply/ProcessApplyImpl.scala
index ee0e9f42b3..d3c822992b 100644
--- a/src/col/vct/col/ast/expr/apply/ProcessApplyImpl.scala
+++ b/src/col/vct/col/ast/expr/apply/ProcessApplyImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{ProcessApply, TProcess, Type}
import vct.col.print._
import vct.col.ast.ops.ProcessApplyOps
-trait ProcessApplyImpl[G] extends ProcessApplyOps[G] { this: ProcessApply[G] =>
+trait ProcessApplyImpl[G] extends ProcessApplyOps[G] {
+ this: ProcessApply[G] =>
override def t: Type[G] = TProcess()
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Group(Text(ctx.name(process)) <> "(" <> Doc.args(args) <> ")")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/apply/ProverFunctionInvocationImpl.scala b/src/col/vct/col/ast/expr/apply/ProverFunctionInvocationImpl.scala
index 843f1b443a..8776f9bf73 100644
--- a/src/col/vct/col/ast/expr/apply/ProverFunctionInvocationImpl.scala
+++ b/src/col/vct/col/ast/expr/apply/ProverFunctionInvocationImpl.scala
@@ -4,12 +4,10 @@ import vct.col.ast.ProverFunctionInvocation
import vct.col.print.{Ctx, Doc, DocUtil, Empty, Group, Precedence, Text}
import vct.col.ast.ops.ProverFunctionInvocationOps
-trait ProverFunctionInvocationImpl[G] extends ProverFunctionInvocationOps[G] { this: ProverFunctionInvocation[G] =>
+trait ProverFunctionInvocationImpl[G] extends ProverFunctionInvocationOps[G] {
+ this: ProverFunctionInvocation[G] =>
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
- Group(
- Text(ctx.name(ref)) <>
- "(" <> Doc.args(args) <> ")"
- )
+ Group(Text(ctx.name(ref)) <> "(" <> Doc.args(args) <> ")")
}
diff --git a/src/col/vct/col/ast/expr/binder/BinderImpl.scala b/src/col/vct/col/ast/expr/binder/BinderImpl.scala
index 0728fc6b06..85e6c39259 100644
--- a/src/col/vct/col/ast/expr/binder/BinderImpl.scala
+++ b/src/col/vct/col/ast/expr/binder/BinderImpl.scala
@@ -3,7 +3,8 @@ package vct.col.ast.expr.binder
import vct.col.ast.util.Declarator
import vct.col.ast.{Binder, Declaration, Variable}
-trait BinderImpl[G] extends Declarator[G] { this: Binder[G] =>
+trait BinderImpl[G] extends Declarator[G] {
+ this: Binder[G] =>
def bindings: Seq[Variable[G]]
override def declarations: Seq[Declaration[G]] = bindings
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/binder/ExistsImpl.scala b/src/col/vct/col/ast/expr/binder/ExistsImpl.scala
index b467d0681e..25b4704572 100644
--- a/src/col/vct/col/ast/expr/binder/ExistsImpl.scala
+++ b/src/col/vct/col/ast/expr/binder/ExistsImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{Exists, TBool, Type}
import vct.col.print._
import vct.col.ast.ops.ExistsOps
-trait ExistsImpl[G] extends ExistsOps[G] { this: Exists[G] =>
+trait ExistsImpl[G] extends ExistsOps[G] {
+ this: Exists[G] =>
override def t: Type[G] = TBool()
def layoutTriggers(implicit ctx: Ctx): Doc =
@@ -13,14 +14,21 @@ trait ExistsImpl[G] extends ExistsOps[G] { this: Exists[G] =>
})(_ <> _)
def layoutSpec(implicit ctx: Ctx): Doc =
- Group(Text("(\\exists") <+> Doc.fold(bindings)(_ <> "," <+> _) <> ";" <>> body > ")")
+ Group(
+ Text("(\\exists") <+> Doc.fold(bindings)(_ <> "," <+> _) <> ";" <>>
+ body > ")"
+ )
def layoutSilver(implicit ctx: Ctx): Doc =
- Group(Text("(exists") <+> Doc.fold(bindings)(_ <> "," <+> _) <+> "::" <> layoutTriggers <>> body > ")")
+ Group(
+ Text("(exists") <+> Doc.fold(bindings)(_ <> "," <+> _) <+> "::" <>
+ layoutTriggers <>> body > ")"
+ )
override def precedence: Int = Precedence.ATOMIC
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.Silver => layoutSilver
- case _ => layoutSpec
- }
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.Silver => layoutSilver
+ case _ => layoutSpec
+ }
+}
diff --git a/src/col/vct/col/ast/expr/binder/ForPermImpl.scala b/src/col/vct/col/ast/expr/binder/ForPermImpl.scala
index 6a5a1be26b..2f5cda10e5 100644
--- a/src/col/vct/col/ast/expr/binder/ForPermImpl.scala
+++ b/src/col/vct/col/ast/expr/binder/ForPermImpl.scala
@@ -4,19 +4,27 @@ import vct.col.ast.{ForPerm, TBool}
import vct.col.print._
import vct.col.ast.ops.ForPermOps
-trait ForPermImpl[G] extends ForPermOps[G] { this: ForPerm[G] =>
+trait ForPermImpl[G] extends ForPermOps[G] {
+ this: ForPerm[G] =>
override def t: TBool[G] = TBool()
def layoutSpec(implicit ctx: Ctx): Doc =
- Group(Text("(\\forperm") <+> Doc.fold(bindings)(_ <> "," <+> _) <+> "\\in" <+> loc <> ";" <>> body.show > ")")
+ Group(
+ Text("(\\forperm") <+> Doc.fold(bindings)(_ <> "," <+> _) <+> "\\in" <+>
+ loc <> ";" <>> body.show > ")"
+ )
// PB: does not need parentheses, so perhaps make precedence depend on ctx
def layoutSilver(implicit ctx: Ctx): Doc =
- Group(Text("(forperm") <+> Doc.fold(bindings)(_ <> "," <+> _) <+> "[" <> loc <> "]" <+> "::" <>> body.show > ")")
+ Group(
+ Text("(forperm") <+> Doc.fold(bindings)(_ <> "," <+> _) <+> "[" <> loc <>
+ "]" <+> "::" <>> body.show > ")"
+ )
override def precedence: Int = Precedence.ATOMIC
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.Silver => layoutSilver
- case _ => layoutSpec
- }
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.Silver => layoutSilver
+ case _ => layoutSpec
+ }
}
diff --git a/src/col/vct/col/ast/expr/binder/ForPermWithValueImpl.scala b/src/col/vct/col/ast/expr/binder/ForPermWithValueImpl.scala
index 9ecde585b5..4df4eb2419 100644
--- a/src/col/vct/col/ast/expr/binder/ForPermWithValueImpl.scala
+++ b/src/col/vct/col/ast/expr/binder/ForPermWithValueImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{ForPermWithValue, TBool, Variable}
import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.ast.ops.ForPermWithValueOps
-trait ForPermWithValueImpl[G] extends ForPermWithValueOps[G] { this: ForPermWithValue[G] =>
+trait ForPermWithValueImpl[G] extends ForPermWithValueOps[G] {
+ this: ForPermWithValue[G] =>
override def bindings: Seq[Variable[G]] = Seq(binding)
override def t: TBool[G] = TBool()
diff --git a/src/col/vct/col/ast/expr/binder/ForallImpl.scala b/src/col/vct/col/ast/expr/binder/ForallImpl.scala
index ca3fc2e559..827f2f3aa1 100644
--- a/src/col/vct/col/ast/expr/binder/ForallImpl.scala
+++ b/src/col/vct/col/ast/expr/binder/ForallImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{Forall, TBool, Type}
import vct.col.print._
import vct.col.ast.ops.ForallOps
-trait ForallImpl[G] extends ForallOps[G] { this: Forall[G] =>
+trait ForallImpl[G] extends ForallOps[G] {
+ this: Forall[G] =>
override def t: Type[G] = TBool()
def layoutTriggers(implicit ctx: Ctx): Doc =
@@ -13,14 +14,21 @@ trait ForallImpl[G] extends ForallOps[G] { this: Forall[G] =>
})(_ <> _)
def layoutSpec(implicit ctx: Ctx): Doc =
- Group(Text("(\\forall") <+> Doc.fold(bindings)(_ <> "," <+> _) <> ";" <>> body > ")")
+ Group(
+ Text("(\\forall") <+> Doc.fold(bindings)(_ <> "," <+> _) <> ";" <>>
+ body > ")"
+ )
def layoutSilver(implicit ctx: Ctx): Doc =
- Group(Text("(forall") <+> Doc.fold(bindings)(_ <> "," <+> _) <+> "::" <> layoutTriggers <>> body > ")")
+ Group(
+ Text("(forall") <+> Doc.fold(bindings)(_ <> "," <+> _) <+> "::" <>
+ layoutTriggers <>> body > ")"
+ )
override def precedence: Int = Precedence.ATOMIC
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.Silver => layoutSilver
- case _ => layoutSpec
- }
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.Silver => layoutSilver
+ case _ => layoutSpec
+ }
}
diff --git a/src/col/vct/col/ast/expr/binder/LetImpl.scala b/src/col/vct/col/ast/expr/binder/LetImpl.scala
index 678adb6a7e..65cb9ebfc1 100644
--- a/src/col/vct/col/ast/expr/binder/LetImpl.scala
+++ b/src/col/vct/col/ast/expr/binder/LetImpl.scala
@@ -4,19 +4,26 @@ import vct.col.ast.{Let, Type, Variable}
import vct.col.print._
import vct.col.ast.ops.LetOps
-trait LetImpl[G] extends LetOps[G] { this: Let[G] =>
+trait LetImpl[G] extends LetOps[G] {
+ this: Let[G] =>
override def t: Type[G] = main.t
override def bindings: Seq[Variable[G]] = Seq(binding)
def layoutSpec(implicit ctx: Ctx): Doc =
- Group(Text("(") <> "\\let" <+> binding <+> "=" <+> value <> ";" <>> main > ")")
+ Group(
+ Text("(") <> "\\let" <+> binding <+> "=" <+> value <> ";" <>> main > ")"
+ )
def layoutSilver(implicit ctx: Ctx): Doc =
- Group(Text("(") <> "let" <+> ctx.name(binding) <+> "==" <+> "(" <> value <> ")" <+> "in" <>> main > ")")
+ Group(
+ Text("(") <> "let" <+> ctx.name(binding) <+> "==" <+> "(" <> value <>
+ ")" <+> "in" <>> main > ")"
+ )
override def precedence: Int = Precedence.ATOMIC
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.Silver => layoutSilver
- case _ => layoutSpec
- }
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.Silver => layoutSilver
+ case _ => layoutSpec
+ }
+}
diff --git a/src/col/vct/col/ast/expr/binder/ProductImpl.scala b/src/col/vct/col/ast/expr/binder/ProductImpl.scala
index 15202d802f..9df9946b13 100644
--- a/src/col/vct/col/ast/expr/binder/ProductImpl.scala
+++ b/src/col/vct/col/ast/expr/binder/ProductImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.expr.binder
import vct.col.ast.{Product, TInt, Type}
import vct.col.ast.ops.ProductOps
-trait ProductImpl[G] extends ProductOps[G] { this: Product[G] =>
+trait ProductImpl[G] extends ProductOps[G] {
+ this: Product[G] =>
override def t: Type[G] = TInt()
}
diff --git a/src/col/vct/col/ast/expr/binder/StarallImpl.scala b/src/col/vct/col/ast/expr/binder/StarallImpl.scala
index 7b7d2df873..ceee14f8bb 100644
--- a/src/col/vct/col/ast/expr/binder/StarallImpl.scala
+++ b/src/col/vct/col/ast/expr/binder/StarallImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{Starall, TResource, Type}
import vct.col.print._
import vct.col.ast.ops.StarallOps
-trait StarallImpl[G] extends StarallOps[G] { this: Starall[G] =>
+trait StarallImpl[G] extends StarallOps[G] {
+ this: Starall[G] =>
override def t: Type[G] = TResource()
def layoutTriggers(implicit ctx: Ctx): Doc =
@@ -13,14 +14,21 @@ trait StarallImpl[G] extends StarallOps[G] { this: Starall[G] =>
})(_ <> _)
def layoutSpec(implicit ctx: Ctx): Doc =
- Group(Text("(\\forall*") <+> Doc.fold(bindings)(_ <> "," <+> _) <> ";" <>> body > ")")
+ Group(
+ Text("(\\forall*") <+> Doc.fold(bindings)(_ <> "," <+> _) <> ";" <>>
+ body > ")"
+ )
def layoutSilver(implicit ctx: Ctx): Doc =
- Group(Text("(forall") <+> Doc.fold(bindings)(_ <> "," <+> _) <+> "::" <> layoutTriggers <>> body > ")")
+ Group(
+ Text("(forall") <+> Doc.fold(bindings)(_ <> "," <+> _) <+> "::" <>
+ layoutTriggers <>> body > ")"
+ )
override def precedence: Int = Precedence.ATOMIC
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.Silver => layoutSilver
- case _ => layoutSpec
- }
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.Silver => layoutSilver
+ case _ => layoutSpec
+ }
}
diff --git a/src/col/vct/col/ast/expr/binder/SumImpl.scala b/src/col/vct/col/ast/expr/binder/SumImpl.scala
index eee9600fdd..bf93bbcc9e 100644
--- a/src/col/vct/col/ast/expr/binder/SumImpl.scala
+++ b/src/col/vct/col/ast/expr/binder/SumImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.expr.binder
import vct.col.ast.{Sum, TInt, Type}
import vct.col.ast.ops.SumOps
-trait SumImpl[G] extends SumOps[G] { this: Sum[G] =>
+trait SumImpl[G] extends SumOps[G] {
+ this: Sum[G] =>
override def t: Type[G] = TInt()
}
diff --git a/src/col/vct/col/ast/expr/bip/BipGuardInvocationImpl.scala b/src/col/vct/col/ast/expr/bip/BipGuardInvocationImpl.scala
index 02a8b3cb17..1088898b64 100644
--- a/src/col/vct/col/ast/expr/bip/BipGuardInvocationImpl.scala
+++ b/src/col/vct/col/ast/expr/bip/BipGuardInvocationImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{BipGuardInvocation, TBool, Type}
import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.ast.ops.BipGuardInvocationOps
-trait BipGuardInvocationImpl[G] extends BipGuardInvocationOps[G] { this: BipGuardInvocation[G] =>
+trait BipGuardInvocationImpl[G] extends BipGuardInvocationOps[G] {
+ this: BipGuardInvocation[G] =>
override def t: Type[G] = TBool()
override def precedence: Int = Precedence.POSTFIX
diff --git a/src/col/vct/col/ast/expr/bip/BipLocalIncomingDataImpl.scala b/src/col/vct/col/ast/expr/bip/BipLocalIncomingDataImpl.scala
index 6b6e91721a..6624cf8447 100644
--- a/src/col/vct/col/ast/expr/bip/BipLocalIncomingDataImpl.scala
+++ b/src/col/vct/col/ast/expr/bip/BipLocalIncomingDataImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{BipLocalIncomingData, Type}
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.BipLocalIncomingDataOps
-trait BipLocalIncomingDataImpl[G] extends BipLocalIncomingDataOps[G] { this: BipLocalIncomingData[G] =>
+trait BipLocalIncomingDataImpl[G] extends BipLocalIncomingDataOps[G] {
+ this: BipLocalIncomingData[G] =>
override def t: Type[G] = ref.decl.t
override def layout(implicit ctx: Ctx): Doc = Text(ctx.name(ref))
diff --git a/src/col/vct/col/ast/expr/bip/JavaBipGlueImpl.scala b/src/col/vct/col/ast/expr/bip/JavaBipGlueImpl.scala
index 2f20c2c943..74b367a76f 100644
--- a/src/col/vct/col/ast/expr/bip/JavaBipGlueImpl.scala
+++ b/src/col/vct/col/ast/expr/bip/JavaBipGlueImpl.scala
@@ -4,9 +4,9 @@ import vct.col.ast.{JavaBipGlue, TNotAValue, Type}
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.JavaBipGlueOps
-trait JavaBipGlueImpl[G] extends JavaBipGlueOps[G] { this: JavaBipGlue[G] =>
+trait JavaBipGlueImpl[G] extends JavaBipGlueOps[G] {
+ this: JavaBipGlue[G] =>
override def t: Type[G] = new TNotAValue()
- override def layout(implicit ctx: Ctx): Doc =
- Doc.stack(elems)
+ override def layout(implicit ctx: Ctx): Doc = Doc.stack(elems)
}
diff --git a/src/col/vct/col/ast/expr/context/AmbiguousResultImpl.scala b/src/col/vct/col/ast/expr/context/AmbiguousResultImpl.scala
index 0e92835902..eefa45fd0b 100644
--- a/src/col/vct/col/ast/expr/context/AmbiguousResultImpl.scala
+++ b/src/col/vct/col/ast/expr/context/AmbiguousResultImpl.scala
@@ -9,36 +9,52 @@ import vct.col.resolve.ctx._
import vct.col.resolve.lang.{C, CPP}
import vct.col.ast.ops.AmbiguousResultOps
-trait AmbiguousResultImpl[G] extends NodeFamilyImpl[G] with AmbiguousResultOps[G] { this: AmbiguousResult[G] =>
- override lazy val t: Type[G] = ref.getOrElse(
- throw err.ContextSensitiveNodeNotResolved(this, "'\\result' encountered, but its attached method is not resolved.")) match {
- case RefCFunctionDefinition(decl) =>
- C.typeOrReturnTypeFromDeclaration(decl.specs, decl.declarator)
- case RefCGlobalDeclaration(decls, initIdx) =>
- C.typeOrReturnTypeFromDeclaration(decls.decl.specs, decls.decl.inits(initIdx).decl)
- case RefCPPFunctionDefinition(decl) =>
- CPP.typeOrReturnTypeFromDeclarator(decl.specs, decl.declarator)
- case RefCPPGlobalDeclaration(decls, initIdx) =>
- CPP.typeOrReturnTypeFromDeclarator(decls.decl.specs, decls.decl.inits(initIdx).decl)
- case RefFunction(decl) => decl.returnType
- case RefProcedure(decl) => decl.returnType
- case RefJavaMethod(decl) => decl.returnType
- case RefJavaAnnotationMethod(decl) => decl.returnType
- case RefLlvmFunctionDefinition(decl) => decl.returnType
- case RefLlvmSpecFunction(decl) => decl.returnType
- case RefInstanceFunction(decl) => decl.returnType
- case RefInstanceMethod(decl) => decl.returnType
- case RefInstanceOperatorMethod(decl) => decl.returnType
- case RefInstanceOperatorFunction(decl) => decl.returnType
- }
+trait AmbiguousResultImpl[G]
+ extends NodeFamilyImpl[G] with AmbiguousResultOps[G] {
+ this: AmbiguousResult[G] =>
+ override lazy val t: Type[G] =
+ ref.getOrElse(
+ throw err.ContextSensitiveNodeNotResolved(
+ this,
+ "'\\result' encountered, but its attached method is not resolved.",
+ )
+ ) match {
+ case RefCFunctionDefinition(decl) =>
+ C.typeOrReturnTypeFromDeclaration(decl.specs, decl.declarator)
+ case RefCGlobalDeclaration(decls, initIdx) =>
+ C.typeOrReturnTypeFromDeclaration(
+ decls.decl.specs,
+ decls.decl.inits(initIdx).decl,
+ )
+ case RefCPPFunctionDefinition(decl) =>
+ CPP.typeOrReturnTypeFromDeclarator(decl.specs, decl.declarator)
+ case RefCPPGlobalDeclaration(decls, initIdx) =>
+ CPP.typeOrReturnTypeFromDeclarator(
+ decls.decl.specs,
+ decls.decl.inits(initIdx).decl,
+ )
+ case RefFunction(decl) => decl.returnType
+ case RefProcedure(decl) => decl.returnType
+ case RefJavaMethod(decl) => decl.returnType
+ case RefJavaAnnotationMethod(decl) => decl.returnType
+ case RefLlvmFunctionDefinition(decl) => decl.returnType
+ case RefLlvmSpecFunction(decl) => decl.returnType
+ case RefInstanceFunction(decl) => decl.returnType
+ case RefInstanceMethod(decl) => decl.returnType
+ case RefInstanceOperatorMethod(decl) => decl.returnType
+ case RefInstanceOperatorFunction(decl) => decl.returnType
+ }
override def check(context: CheckContext[G]): Seq[CheckError] =
- if (context.inPostCondition) super.check(context)
- else Seq(ResultOutsidePostcondition(this))
+ if (context.inPostCondition)
+ super.check(context)
+ else
+ Seq(ResultOutsidePostcondition(this))
override def precedence: Int = Precedence.ATOMIC
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.Silver => Text("result")
- case _ => Text("\\result")
- }
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.Silver => Text("result")
+ case _ => Text("\\result")
+ }
+}
diff --git a/src/col/vct/col/ast/expr/context/AmbiguousThisImpl.scala b/src/col/vct/col/ast/expr/context/AmbiguousThisImpl.scala
index cf20a12cca..01b0ab843c 100644
--- a/src/col/vct/col/ast/expr/context/AmbiguousThisImpl.scala
+++ b/src/col/vct/col/ast/expr/context/AmbiguousThisImpl.scala
@@ -6,14 +6,21 @@ import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.resolve.ctx._
import vct.col.ast.ops.AmbiguousThisOps
-trait AmbiguousThisImpl[G] extends AmbiguousThisOps[G] { this: AmbiguousThis[G] =>
+trait AmbiguousThisImpl[G] extends AmbiguousThisOps[G] {
+ this: AmbiguousThis[G] =>
override lazy val t: Type[G] =
ref.getOrElse(
- throw ContextSensitiveNodeNotResolved(this,
- "'this' encountered, but the surrounding class is not resolved.")
+ throw ContextSensitiveNodeNotResolved(
+ this,
+ "'this' encountered, but the surrounding class is not resolved.",
+ )
) match {
case RefJavaClass(decl) => JavaTClass(decl.ref, Nil)
- case RefClass(decl) => TClass(decl.ref, decl.typeArgs.map((v: Variable[G]) => TVar(v.ref[Variable[G]])))
+ case RefClass(decl) =>
+ TClass(
+ decl.ref,
+ decl.typeArgs.map((v: Variable[G]) => TVar(v.ref[Variable[G]])),
+ )
case RefModel(decl) => TModel(decl.ref)
case RefPVLChoreography(decl) => TPVLChoreography(decl.ref)
case RefChoreography(decl) => TChoreography(decl.ref)
@@ -21,4 +28,4 @@ trait AmbiguousThisImpl[G] extends AmbiguousThisOps[G] { this: AmbiguousThis[G]
override def precedence: Int = Precedence.ATOMIC
override def layout(implicit ctx: Ctx): Doc = Text("this")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/context/CurrentThreadIdImpl.scala b/src/col/vct/col/ast/expr/context/CurrentThreadIdImpl.scala
index 55c63a3b9c..eef485849c 100644
--- a/src/col/vct/col/ast/expr/context/CurrentThreadIdImpl.scala
+++ b/src/col/vct/col/ast/expr/context/CurrentThreadIdImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{CurrentThreadId, TInt, Type}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.CurrentThreadIdOps
-trait CurrentThreadIdImpl[G] extends CurrentThreadIdOps[G] { this: CurrentThreadId[G] =>
+trait CurrentThreadIdImpl[G] extends CurrentThreadIdOps[G] {
+ this: CurrentThreadId[G] =>
override def t: Type[G] = TInt()
override def precedence: Int = Precedence.ATOMIC
override def layout(implicit ctx: Ctx): Doc = Text("\\current_thread")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/context/GlobalThreadIdImpl.scala b/src/col/vct/col/ast/expr/context/GlobalThreadIdImpl.scala
index 38ee76fefd..d535d20e87 100644
--- a/src/col/vct/col/ast/expr/context/GlobalThreadIdImpl.scala
+++ b/src/col/vct/col/ast/expr/context/GlobalThreadIdImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{GlobalThreadId, TInt}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.GlobalThreadIdOps
-trait GlobalThreadIdImpl[G] extends GlobalThreadIdOps[G] { this: GlobalThreadId[G] =>
+trait GlobalThreadIdImpl[G] extends GlobalThreadIdOps[G] {
+ this: GlobalThreadId[G] =>
override def t: TInt[G] = TInt()
override def precedence: Int = Precedence.ATOMIC
diff --git a/src/col/vct/col/ast/expr/context/LocalThreadIdImpl.scala b/src/col/vct/col/ast/expr/context/LocalThreadIdImpl.scala
index 46ac95eb0a..1a2fd9dd7b 100644
--- a/src/col/vct/col/ast/expr/context/LocalThreadIdImpl.scala
+++ b/src/col/vct/col/ast/expr/context/LocalThreadIdImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{LocalThreadId, TInt}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.LocalThreadIdOps
-trait LocalThreadIdImpl[G] extends LocalThreadIdOps[G] { this: LocalThreadId[G] =>
+trait LocalThreadIdImpl[G] extends LocalThreadIdOps[G] {
+ this: LocalThreadId[G] =>
override def t: TInt[G] = TInt()
override def precedence: Int = Precedence.ATOMIC
diff --git a/src/col/vct/col/ast/expr/context/ResultImpl.scala b/src/col/vct/col/ast/expr/context/ResultImpl.scala
index fc141dc8fa..f0ef5106d5 100644
--- a/src/col/vct/col/ast/expr/context/ResultImpl.scala
+++ b/src/col/vct/col/ast/expr/context/ResultImpl.scala
@@ -6,16 +6,20 @@ import vct.col.check.{CheckContext, CheckError, ResultOutsidePostcondition}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.ResultOps
-trait ResultImpl[G] extends NodeFamilyImpl[G] with ResultOps[G] { this: Result[G] =>
+trait ResultImpl[G] extends NodeFamilyImpl[G] with ResultOps[G] {
+ this: Result[G] =>
override def t: Type[G] = applicable.decl.returnType
override def check(context: CheckContext[G]): Seq[CheckError] =
- if(context.inPostCondition) super.check(context)
- else Seq(ResultOutsidePostcondition(this))
+ if (context.inPostCondition)
+ super.check(context)
+ else
+ Seq(ResultOutsidePostcondition(this))
override def precedence: Int = Precedence.ATOMIC
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.Silver => Text("result")
- case _ => Text("\\result")
- }
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.Silver => Text("result")
+ case _ => Text("\\result")
+ }
+}
diff --git a/src/col/vct/col/ast/expr/context/ThisChoreographyImpl.scala b/src/col/vct/col/ast/expr/context/ThisChoreographyImpl.scala
index 607b53f9b7..715ad4503f 100644
--- a/src/col/vct/col/ast/expr/context/ThisChoreographyImpl.scala
+++ b/src/col/vct/col/ast/expr/context/ThisChoreographyImpl.scala
@@ -4,9 +4,11 @@ import vct.col.ast.{TAnyClass, TChoreography, ThisChoreography, Type}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.ThisChoreographyOps
-trait ThisChoreographyImpl[G] extends ThisDeclarationImpl[G] with ThisChoreographyOps[G] { this: ThisChoreography[G] =>
+trait ThisChoreographyImpl[G]
+ extends ThisDeclarationImpl[G] with ThisChoreographyOps[G] {
+ this: ThisChoreography[G] =>
override def t: Type[G] = TChoreography(cls)
override def precedence: Int = Precedence.ATOMIC
override def layout(implicit ctx: Ctx): Doc = Text("this")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/context/ThisDeclarationImpl.scala b/src/col/vct/col/ast/expr/context/ThisDeclarationImpl.scala
index 4a471cea89..d6b810604b 100644
--- a/src/col/vct/col/ast/expr/context/ThisDeclarationImpl.scala
+++ b/src/col/vct/col/ast/expr/context/ThisDeclarationImpl.scala
@@ -5,10 +5,13 @@ import vct.col.ast.expr.ExprImpl
import vct.col.check.{CheckContext, CheckError, ThisOutsideScopeError}
import vct.col.ref.Ref
-trait ThisDeclarationImpl[G] extends ExprImpl[G] { this: ThisDeclaration[G] =>
+trait ThisDeclarationImpl[G] extends ExprImpl[G] {
+ this: ThisDeclaration[G] =>
def cls: Ref[G, _ <: Declaration[G]]
override def check(context: CheckContext[G]): Seq[CheckError] =
- if(!context.declarationStack.contains(cls.decl)) super.check(context) ++ Seq(ThisOutsideScopeError(this))
- else super.check(context)
+ if (!context.declarationStack.contains(cls.decl))
+ super.check(context) ++ Seq(ThisOutsideScopeError(this))
+ else
+ super.check(context)
}
diff --git a/src/col/vct/col/ast/expr/context/ThisModelImpl.scala b/src/col/vct/col/ast/expr/context/ThisModelImpl.scala
index c47135fba8..3c0ab8d57d 100644
--- a/src/col/vct/col/ast/expr/context/ThisModelImpl.scala
+++ b/src/col/vct/col/ast/expr/context/ThisModelImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{TModel, ThisModel, Type}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.ThisModelOps
-trait ThisModelImpl[G] extends ThisDeclarationImpl[G] with ThisModelOps[G] { this: ThisModel[G] =>
+trait ThisModelImpl[G] extends ThisDeclarationImpl[G] with ThisModelOps[G] {
+ this: ThisModel[G] =>
override def t: Type[G] = TModel(cls)
override def precedence: Int = Precedence.ATOMIC
override def layout(implicit ctx: Ctx): Doc = Text("this")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/context/ThisObjectImpl.scala b/src/col/vct/col/ast/expr/context/ThisObjectImpl.scala
index f12ed0722a..25e90414f7 100644
--- a/src/col/vct/col/ast/expr/context/ThisObjectImpl.scala
+++ b/src/col/vct/col/ast/expr/context/ThisObjectImpl.scala
@@ -5,14 +5,22 @@ import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.ThisObjectOps
import vct.col.check.{CheckContext, CheckError, ThisInConstructorPre}
-trait ThisObjectImpl[G] extends ThisDeclarationImpl[G] with ThisObjectOps[G] { this: ThisObject[G] =>
- override def t: Type[G] = TClass(cls, cls.decl.typeArgs.map(v => TVar(v.ref[Variable[G]])))
+trait ThisObjectImpl[G] extends ThisDeclarationImpl[G] with ThisObjectOps[G] {
+ this: ThisObject[G] =>
+ override def t: Type[G] =
+ TClass(cls, cls.decl.typeArgs.map(v => TVar(v.ref[Variable[G]])))
override def check(context: CheckContext[G]): Seq[CheckError] = {
- val inConstructor = context.declarationStack.collectFirst { case _: Constructor[G] => () }.nonEmpty
- super.check(context) ++ (if(inConstructor && context.inPreCondition) Seq(ThisInConstructorPre(this)) else Nil)
+ val inConstructor =
+ context.declarationStack.collectFirst { case _: Constructor[G] => () }
+ .nonEmpty
+ super.check(context) ++
+ (if (inConstructor && context.inPreCondition)
+ Seq(ThisInConstructorPre(this))
+ else
+ Nil)
}
override def precedence: Int = Precedence.ATOMIC
override def layout(implicit ctx: Ctx): Doc = Text("this")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/heap/SizeOfImpl.scala b/src/col/vct/col/ast/expr/heap/SizeOfImpl.scala
index 698d3921a4..748fdec6c1 100644
--- a/src/col/vct/col/ast/expr/heap/SizeOfImpl.scala
+++ b/src/col/vct/col/ast/expr/heap/SizeOfImpl.scala
@@ -4,9 +4,9 @@ import vct.col.ast.{SizeOf, TCInt, Type}
import vct.col.print._
import vct.col.ast.ops.SizeOfOps
-trait SizeOfImpl[G] extends SizeOfOps[G] { this: SizeOf[G] =>
+trait SizeOfImpl[G] extends SizeOfOps[G] {
+ this: SizeOf[G] =>
override def t: Type[G] = TCInt()
- override def layout(implicit ctx: Ctx): Doc =
- Text("sizeof(") <> tname <> ")"
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc = Text("sizeof(") <> tname <> ")"
+}
diff --git a/src/col/vct/col/ast/expr/heap/alloc/FreePointerImpl.scala b/src/col/vct/col/ast/expr/heap/alloc/FreePointerImpl.scala
index 77ed121ed1..3988304004 100644
--- a/src/col/vct/col/ast/expr/heap/alloc/FreePointerImpl.scala
+++ b/src/col/vct/col/ast/expr/heap/alloc/FreePointerImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{FreePointer, TVoid, Type}
import vct.col.print._
import vct.col.ast.ops.FreePointerOps
-trait FreePointerImpl[G] extends FreePointerOps[G] { this: FreePointer[G] =>
+trait FreePointerImpl[G] extends FreePointerOps[G] {
+ this: FreePointer[G] =>
override lazy val t: Type[G] = TVoid()
override def layout(implicit ctx: Ctx): Doc =
Text("free") <+> "(" <> pointer <> ")"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/heap/alloc/NewArrayImpl.scala b/src/col/vct/col/ast/expr/heap/alloc/NewArrayImpl.scala
index 532cb8860d..e9d496b278 100644
--- a/src/col/vct/col/ast/expr/heap/alloc/NewArrayImpl.scala
+++ b/src/col/vct/col/ast/expr/heap/alloc/NewArrayImpl.scala
@@ -5,10 +5,13 @@ import vct.col.ast.{NewArray, TArray, Type}
import vct.col.print._
import vct.col.ast.ops.NewArrayOps
-trait NewArrayImpl[G] extends NewArrayOps[G] { this: NewArray[G] =>
- override lazy val t: Type[G] = FuncTools.repeat[Type[G]](TArray(_), dims.size + moreDims, element)
+trait NewArrayImpl[G] extends NewArrayOps[G] {
+ this: NewArray[G] =>
+ override lazy val t: Type[G] = FuncTools
+ .repeat[Type[G]](TArray(_), dims.size + moreDims, element)
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
- Text("new") <+> element <> dims.map(dim => s"[$dim]").mkString <> "[]".repeat(moreDims)
-}
\ No newline at end of file
+ Text("new") <+> element <> dims.map(dim => s"[$dim]").mkString <>
+ "[]".repeat(moreDims)
+}
diff --git a/src/col/vct/col/ast/expr/heap/alloc/NewObjectImpl.scala b/src/col/vct/col/ast/expr/heap/alloc/NewObjectImpl.scala
index 6de0272e86..dbc0fa2953 100644
--- a/src/col/vct/col/ast/expr/heap/alloc/NewObjectImpl.scala
+++ b/src/col/vct/col/ast/expr/heap/alloc/NewObjectImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{NewObject, TClass, Type}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.NewObjectOps
-trait NewObjectImpl[G] extends NewObjectOps[G] { this: NewObject[G] =>
+trait NewObjectImpl[G] extends NewObjectOps[G] {
+ this: NewObject[G] =>
override def t: Type[G] = TClass(cls, Seq())
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Text("new") <+> ctx.name(cls) <> "()"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/heap/alloc/NewPointerArrayImpl.scala b/src/col/vct/col/ast/expr/heap/alloc/NewPointerArrayImpl.scala
index 5286f32ce9..18bd2bfbf8 100644
--- a/src/col/vct/col/ast/expr/heap/alloc/NewPointerArrayImpl.scala
+++ b/src/col/vct/col/ast/expr/heap/alloc/NewPointerArrayImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{NewPointerArray, TPointer, Type}
import vct.col.print._
import vct.col.ast.ops.NewPointerArrayOps
-trait NewPointerArrayImpl[G] extends NewPointerArrayOps[G] { this: NewPointerArray[G] =>
+trait NewPointerArrayImpl[G] extends NewPointerArrayOps[G] {
+ this: NewPointerArray[G] =>
override lazy val t: Type[G] = TPointer(element)
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Text("new") <+> element <> "[" <> size <> "]"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/heap/read/AddrOfImpl.scala b/src/col/vct/col/ast/expr/heap/read/AddrOfImpl.scala
index c96df1970b..90815f30c4 100644
--- a/src/col/vct/col/ast/expr/heap/read/AddrOfImpl.scala
+++ b/src/col/vct/col/ast/expr/heap/read/AddrOfImpl.scala
@@ -4,10 +4,10 @@ import vct.col.ast.{AddrOf, TPointer, Type}
import vct.col.print._
import vct.col.ast.ops.AddrOfOps
-trait AddrOfImpl[G] extends AddrOfOps[G] { this: AddrOf[G] =>
+trait AddrOfImpl[G] extends AddrOfOps[G] {
+ this: AddrOf[G] =>
override def t: Type[G] = TPointer(e.t)
override def precedence: Int = Precedence.PREFIX
- override def layout(implicit ctx: Ctx): Doc =
- Text("&") <> assoc(e)
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc = Text("&") <> assoc(e)
+}
diff --git a/src/col/vct/col/ast/expr/heap/read/ArraySubscriptImpl.scala b/src/col/vct/col/ast/expr/heap/read/ArraySubscriptImpl.scala
index f045531a02..47b3cc9689 100644
--- a/src/col/vct/col/ast/expr/heap/read/ArraySubscriptImpl.scala
+++ b/src/col/vct/col/ast/expr/heap/read/ArraySubscriptImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{ArraySubscript, Type}
import vct.col.print._
import vct.col.ast.ops.ArraySubscriptOps
-trait ArraySubscriptImpl[G] extends ArraySubscriptOps[G] { this: ArraySubscript[G] =>
+trait ArraySubscriptImpl[G] extends ArraySubscriptOps[G] {
+ this: ArraySubscript[G] =>
override lazy val t: Type[G] = arr.t.asArray.get.element
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Group(assoc(arr) <> "[" <> Doc.arg(index) <> "]")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/heap/read/DerefHeapVariableImpl.scala b/src/col/vct/col/ast/expr/heap/read/DerefHeapVariableImpl.scala
index b262ea6955..1c329d35f3 100644
--- a/src/col/vct/col/ast/expr/heap/read/DerefHeapVariableImpl.scala
+++ b/src/col/vct/col/ast/expr/heap/read/DerefHeapVariableImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{DerefHeapVariable, Type}
import vct.col.print._
import vct.col.ast.ops.DerefHeapVariableOps
-trait DerefHeapVariableImpl[G] extends DerefHeapVariableOps[G] { this: DerefHeapVariable[G] =>
+trait DerefHeapVariableImpl[G] extends DerefHeapVariableOps[G] {
+ this: DerefHeapVariable[G] =>
override def t: Type[G] = ref.decl.t
override def precedence: Int = Precedence.ATOMIC
diff --git a/src/col/vct/col/ast/expr/heap/read/DerefImpl.scala b/src/col/vct/col/ast/expr/heap/read/DerefImpl.scala
index fa9d80d9c1..45557b7a0a 100644
--- a/src/col/vct/col/ast/expr/heap/read/DerefImpl.scala
+++ b/src/col/vct/col/ast/expr/heap/read/DerefImpl.scala
@@ -7,16 +7,18 @@ import vct.col.print.{Ctx, Doc, Group, Precedence}
import vct.col.ref.Ref
import vct.col.ast.ops.DerefOps
-trait DerefImpl[G] extends ExprImpl[G] with DerefOps[G] { this: Deref[G] =>
+trait DerefImpl[G] extends ExprImpl[G] with DerefOps[G] {
+ this: Deref[G] =>
override def t: Type[G] =
obj.t.asClass.map(_.instantiate(ref.decl.t)).getOrElse(ref.decl.t)
override def check(context: CheckContext[G]): Seq[CheckError] =
Check.inOrder(
super.check(context),
- obj.t.asClass.get.cls.decl.checkDefines(ref.decl, this))
+ obj.t.asClass.get.cls.decl.checkDefines(ref.decl, this),
+ )
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
assoc(obj) <> "." <> ctx.name(ref)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/heap/read/DerefPointerImpl.scala b/src/col/vct/col/ast/expr/heap/read/DerefPointerImpl.scala
index 814011b198..ab2a387d2c 100644
--- a/src/col/vct/col/ast/expr/heap/read/DerefPointerImpl.scala
+++ b/src/col/vct/col/ast/expr/heap/read/DerefPointerImpl.scala
@@ -4,10 +4,10 @@ import vct.col.ast.{DerefPointer, Type}
import vct.col.print._
import vct.col.ast.ops.DerefPointerOps
-trait DerefPointerImpl[G] extends DerefPointerOps[G] { this: DerefPointer[G] =>
+trait DerefPointerImpl[G] extends DerefPointerOps[G] {
+ this: DerefPointer[G] =>
override def t: Type[G] = pointer.t.asPointer.get.element
override def precedence: Int = Precedence.PREFIX
- override def layout(implicit ctx: Ctx): Doc =
- Text("*") <> assoc(pointer)
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc = Text("*") <> assoc(pointer)
+}
diff --git a/src/col/vct/col/ast/expr/heap/read/EndpointNameImpl.scala b/src/col/vct/col/ast/expr/heap/read/EndpointNameImpl.scala
index 4ab27a9878..97219dd485 100644
--- a/src/col/vct/col/ast/expr/heap/read/EndpointNameImpl.scala
+++ b/src/col/vct/col/ast/expr/heap/read/EndpointNameImpl.scala
@@ -6,7 +6,8 @@ import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.EndpointNameOps
import vct.col.ast.ops.{EndpointNameOps}
-trait EndpointNameImpl[G] extends NodeFamilyImpl[G] with EndpointNameOps[G] { this: EndpointName[G] =>
+trait EndpointNameImpl[G] extends NodeFamilyImpl[G] with EndpointNameOps[G] {
+ this: EndpointName[G] =>
def t: Type[G] = ref.decl.t
override def layout(implicit ctx: Ctx): Doc = Text(ctx.name(ref))
diff --git a/src/col/vct/col/ast/expr/heap/read/FunctionOfImpl.scala b/src/col/vct/col/ast/expr/heap/read/FunctionOfImpl.scala
index da4803ac36..de1e9ba893 100644
--- a/src/col/vct/col/ast/expr/heap/read/FunctionOfImpl.scala
+++ b/src/col/vct/col/ast/expr/heap/read/FunctionOfImpl.scala
@@ -4,10 +4,12 @@ import vct.col.ast.{FunctionOf, Type}
import vct.col.print._
import vct.col.ast.ops.FunctionOfOps
-trait FunctionOfImpl[G] extends FunctionOfOps[G] { this: FunctionOf[G] =>
+trait FunctionOfImpl[G] extends FunctionOfOps[G] {
+ this: FunctionOf[G] =>
override def t: Type[G] = binding.decl.t
override def precedence: Int = Precedence.ATOMIC
override def layout(implicit ctx: Ctx): Doc =
- Text("(") <> ctx.name(binding) <> "!" <> Doc.fold(vars.map(ctx.name(_)).map(Text))(_ <> "," <+> _) <> ")"
+ Text("(") <> ctx.name(binding) <> "!" <>
+ Doc.fold(vars.map(ctx.name(_)).map(Text))(_ <> "," <+> _) <> ")"
}
diff --git a/src/col/vct/col/ast/expr/heap/read/HeapDerefImpl.scala b/src/col/vct/col/ast/expr/heap/read/HeapDerefImpl.scala
index ce7c1fae2b..ec95bcd909 100644
--- a/src/col/vct/col/ast/expr/heap/read/HeapDerefImpl.scala
+++ b/src/col/vct/col/ast/expr/heap/read/HeapDerefImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.expr.heap.read
import vct.col.ast.HeapDeref
-trait HeapDerefImpl[G] { this: HeapDeref[G] =>
+trait HeapDerefImpl[G] {
+ this: HeapDeref[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/heap/read/LengthImpl.scala b/src/col/vct/col/ast/expr/heap/read/LengthImpl.scala
index fb4c837af7..0769087852 100644
--- a/src/col/vct/col/ast/expr/heap/read/LengthImpl.scala
+++ b/src/col/vct/col/ast/expr/heap/read/LengthImpl.scala
@@ -4,10 +4,10 @@ import vct.col.ast.{Length, TInt, Type}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.LengthOps
-trait LengthImpl[G] extends LengthOps[G] { this: Length[G] =>
+trait LengthImpl[G] extends LengthOps[G] {
+ this: Length[G] =>
override def t: Type[G] = TInt()
override def precedence: Int = Precedence.POSTFIX
- override def layout(implicit ctx: Ctx): Doc =
- assoc(arr) <> ".length"
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc = assoc(arr) <> ".length"
+}
diff --git a/src/col/vct/col/ast/expr/heap/read/ModelDerefImpl.scala b/src/col/vct/col/ast/expr/heap/read/ModelDerefImpl.scala
index 2dc7d9416c..7694e7e5cf 100644
--- a/src/col/vct/col/ast/expr/heap/read/ModelDerefImpl.scala
+++ b/src/col/vct/col/ast/expr/heap/read/ModelDerefImpl.scala
@@ -6,7 +6,8 @@ import vct.col.check.{Check, CheckContext, CheckError}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.ModelDerefOps
-trait ModelDerefImpl[G] extends ExprImpl[G] with ModelDerefOps[G] { this: ModelDeref[G] =>
+trait ModelDerefImpl[G] extends ExprImpl[G] with ModelDerefOps[G] {
+ this: ModelDeref[G] =>
override def t: Type[G] = ref.decl.t
override def check(context: CheckContext[G]): Seq[CheckError] = {
Check.inOrder(
@@ -18,4 +19,4 @@ trait ModelDerefImpl[G] extends ExprImpl[G] with ModelDerefOps[G] { this: ModelD
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
assoc(obj) <> "." <> ctx.name(ref)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/heap/read/NdIndexImpl.scala b/src/col/vct/col/ast/expr/heap/read/NdIndexImpl.scala
index b99da15bfe..c106398f6e 100644
--- a/src/col/vct/col/ast/expr/heap/read/NdIndexImpl.scala
+++ b/src/col/vct/col/ast/expr/heap/read/NdIndexImpl.scala
@@ -4,10 +4,13 @@ import vct.col.ast.{NdIndex, TInt}
import vct.col.print._
import vct.col.ast.ops.NdIndexOps
-trait NdIndexImpl[G] extends NdIndexOps[G] { this: NdIndex[G] =>
+trait NdIndexImpl[G] extends NdIndexOps[G] {
+ this: NdIndex[G] =>
override def t: TInt[G] = TInt()
override def precedence: Int = Precedence.ATOMIC
override def layout(implicit ctx: Ctx): Doc =
- Group(Text("\\nd_index(") <> Doc.args(indices.zip(dimensions).map { case (idx, dim) => idx.show <> "," <+> dim }) <> ")")
+ Group(Text("\\nd_index(") <> Doc.args(indices.zip(dimensions).map {
+ case (idx, dim) => idx.show <> "," <+> dim
+ }) <> ")")
}
diff --git a/src/col/vct/col/ast/expr/heap/read/NdLengthImpl.scala b/src/col/vct/col/ast/expr/heap/read/NdLengthImpl.scala
index ecd255872e..643728c2a7 100644
--- a/src/col/vct/col/ast/expr/heap/read/NdLengthImpl.scala
+++ b/src/col/vct/col/ast/expr/heap/read/NdLengthImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{NdLength, TInt}
import vct.col.print._
import vct.col.ast.ops.NdLengthOps
-trait NdLengthImpl[G] extends NdLengthOps[G] { this: NdLength[G] =>
+trait NdLengthImpl[G] extends NdLengthOps[G] {
+ this: NdLength[G] =>
override def t: TInt[G] = TInt()
override def precedence: Int = Precedence.ATOMIC
diff --git a/src/col/vct/col/ast/expr/heap/read/NdPartialIndexImpl.scala b/src/col/vct/col/ast/expr/heap/read/NdPartialIndexImpl.scala
index 89178d740b..d776777282 100644
--- a/src/col/vct/col/ast/expr/heap/read/NdPartialIndexImpl.scala
+++ b/src/col/vct/col/ast/expr/heap/read/NdPartialIndexImpl.scala
@@ -4,10 +4,14 @@ import vct.col.ast.{NdPartialIndex, TBool}
import vct.col.print._
import vct.col.ast.ops.NdPartialIndexOps
-trait NdPartialIndexImpl[G] extends NdPartialIndexOps[G] { this: NdPartialIndex[G] =>
+trait NdPartialIndexImpl[G] extends NdPartialIndexOps[G] {
+ this: NdPartialIndex[G] =>
override def t: TBool[G] = TBool()
override def precedence: Int = Precedence.ATOMIC
override def layout(implicit ctx: Ctx): Doc =
- Group(Text("\\nd_partial_index(") <> Doc.args(indices ++ Seq(linearIndex) ++ dimensions) <> ")")
+ Group(
+ Text("\\nd_partial_index(") <>
+ Doc.args(indices ++ Seq(linearIndex) ++ dimensions) <> ")"
+ )
}
diff --git a/src/col/vct/col/ast/expr/heap/read/PointerAddImpl.scala b/src/col/vct/col/ast/expr/heap/read/PointerAddImpl.scala
index 4c9a619f9b..568944876b 100644
--- a/src/col/vct/col/ast/expr/heap/read/PointerAddImpl.scala
+++ b/src/col/vct/col/ast/expr/heap/read/PointerAddImpl.scala
@@ -4,10 +4,10 @@ import vct.col.ast.{PointerAdd, Type}
import vct.col.print._
import vct.col.ast.ops.PointerAddOps
-trait PointerAddImpl[G] extends PointerAddOps[G] { this: PointerAdd[G] =>
+trait PointerAddImpl[G] extends PointerAddOps[G] {
+ this: PointerAdd[G] =>
override def t: Type[G] = pointer.t
override def precedence: Int = Precedence.ADDITIVE
- override def layout(implicit ctx: Ctx): Doc =
- lassoc(pointer, "+", offset)
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc = lassoc(pointer, "+", offset)
+}
diff --git a/src/col/vct/col/ast/expr/heap/read/PointerBlockLengthImpl.scala b/src/col/vct/col/ast/expr/heap/read/PointerBlockLengthImpl.scala
index 5cd38475cb..6ac977af5c 100644
--- a/src/col/vct/col/ast/expr/heap/read/PointerBlockLengthImpl.scala
+++ b/src/col/vct/col/ast/expr/heap/read/PointerBlockLengthImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{PointerBlockLength, TInt, Type}
import vct.col.print._
import vct.col.ast.ops.PointerBlockLengthOps
-trait PointerBlockLengthImpl[G] extends PointerBlockLengthOps[G] { this: PointerBlockLength[G] =>
+trait PointerBlockLengthImpl[G] extends PointerBlockLengthOps[G] {
+ this: PointerBlockLength[G] =>
override def t: Type[G] = TInt()
override def precedence: Int = Precedence.ATOMIC
override def layout(implicit ctx: Ctx): Doc =
Text("\\pointer_block_length(") <> pointer <> ")"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/heap/read/PointerBlockOffsetImpl.scala b/src/col/vct/col/ast/expr/heap/read/PointerBlockOffsetImpl.scala
index e89b1fe010..ada4def9e9 100644
--- a/src/col/vct/col/ast/expr/heap/read/PointerBlockOffsetImpl.scala
+++ b/src/col/vct/col/ast/expr/heap/read/PointerBlockOffsetImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{PointerBlockOffset, TInt, Type}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.PointerBlockOffsetOps
-trait PointerBlockOffsetImpl[G] extends PointerBlockOffsetOps[G] { this: PointerBlockOffset[G] =>
+trait PointerBlockOffsetImpl[G] extends PointerBlockOffsetOps[G] {
+ this: PointerBlockOffset[G] =>
override def t: Type[G] = TInt()
override def precedence: Int = Precedence.ATOMIC
diff --git a/src/col/vct/col/ast/expr/heap/read/PointerLengthImpl.scala b/src/col/vct/col/ast/expr/heap/read/PointerLengthImpl.scala
index 3703ccf57e..8a8c033cd8 100644
--- a/src/col/vct/col/ast/expr/heap/read/PointerLengthImpl.scala
+++ b/src/col/vct/col/ast/expr/heap/read/PointerLengthImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{PointerLength, TInt, Type}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.PointerLengthOps
-trait PointerLengthImpl[G] extends PointerLengthOps[G] { this: PointerLength[G] =>
+trait PointerLengthImpl[G] extends PointerLengthOps[G] {
+ this: PointerLength[G] =>
override def t: Type[G] = TInt()
override def precedence: Int = Precedence.ATOMIC
diff --git a/src/col/vct/col/ast/expr/heap/read/PointerSubscriptImpl.scala b/src/col/vct/col/ast/expr/heap/read/PointerSubscriptImpl.scala
index b71134d229..9022060f53 100644
--- a/src/col/vct/col/ast/expr/heap/read/PointerSubscriptImpl.scala
+++ b/src/col/vct/col/ast/expr/heap/read/PointerSubscriptImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{PointerSubscript, Type}
import vct.col.print.{Ctx, Doc, Group, Precedence}
import vct.col.ast.ops.PointerSubscriptOps
-trait PointerSubscriptImpl[G] extends PointerSubscriptOps[G] { this: PointerSubscript[G] =>
+trait PointerSubscriptImpl[G] extends PointerSubscriptOps[G] {
+ this: PointerSubscript[G] =>
override def t: Type[G] = pointer.t.asPointer.get.element
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Group(assoc(pointer) <> "[" <> Doc.arg(index) <> "]")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/heap/read/ValuesImpl.scala b/src/col/vct/col/ast/expr/heap/read/ValuesImpl.scala
index 81c33203e2..e118b2073d 100644
--- a/src/col/vct/col/ast/expr/heap/read/ValuesImpl.scala
+++ b/src/col/vct/col/ast/expr/heap/read/ValuesImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{TSeq, Type, Values}
import vct.col.print._
import vct.col.ast.ops.ValuesOps
-trait ValuesImpl[G] extends ValuesOps[G] { this: Values[G] =>
+trait ValuesImpl[G] extends ValuesOps[G] {
+ this: Values[G] =>
override def t: Type[G] = TSeq(arr.t.asArray.get.element)
override def precedence: Int = Precedence.ATOMIC
override def layout(implicit ctx: Ctx): Doc =
Group(Text("\\values(") <> Doc.args(Seq(arr, from, to)) <> ")")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/literal/build/EitherLeftImpl.scala b/src/col/vct/col/ast/expr/literal/build/EitherLeftImpl.scala
index 9393491039..e84ab23e3c 100644
--- a/src/col/vct/col/ast/expr/literal/build/EitherLeftImpl.scala
+++ b/src/col/vct/col/ast/expr/literal/build/EitherLeftImpl.scala
@@ -4,10 +4,10 @@ import vct.col.ast.{EitherLeft, TEither, TNothing, Type}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.EitherLeftOps
-trait EitherLeftImpl[G] extends EitherLeftOps[G] { this: EitherLeft[G] =>
+trait EitherLeftImpl[G] extends EitherLeftOps[G] {
+ this: EitherLeft[G] =>
override def t: Type[G] = TEither(e.t, TNothing())
override def precedence: Int = Precedence.ATOMIC
- override def layout(implicit ctx: Ctx): Doc =
- Text("Left(") <> e <> ")"
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc = Text("Left(") <> e <> ")"
+}
diff --git a/src/col/vct/col/ast/expr/literal/build/EitherRightImpl.scala b/src/col/vct/col/ast/expr/literal/build/EitherRightImpl.scala
index 14867ee0fb..7920490571 100644
--- a/src/col/vct/col/ast/expr/literal/build/EitherRightImpl.scala
+++ b/src/col/vct/col/ast/expr/literal/build/EitherRightImpl.scala
@@ -4,10 +4,10 @@ import vct.col.ast.{EitherRight, TEither, TNothing, Type}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.EitherRightOps
-trait EitherRightImpl[G] extends EitherRightOps[G] { this: EitherRight[G] =>
+trait EitherRightImpl[G] extends EitherRightOps[G] {
+ this: EitherRight[G] =>
override def t: Type[G] = TEither(TNothing(), e.t)
override def precedence: Int = Precedence.ATOMIC
- override def layout(implicit ctx: Ctx): Doc =
- Text("Right(") <> e <> ")"
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc = Text("Right(") <> e <> ")"
+}
diff --git a/src/col/vct/col/ast/expr/literal/build/LiteralBagImpl.scala b/src/col/vct/col/ast/expr/literal/build/LiteralBagImpl.scala
index d97a1ca0d2..28097481d5 100644
--- a/src/col/vct/col/ast/expr/literal/build/LiteralBagImpl.scala
+++ b/src/col/vct/col/ast/expr/literal/build/LiteralBagImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{LiteralBag, TBag, Type}
import vct.col.print._
import vct.col.ast.ops.LiteralBagOps
-trait LiteralBagImpl[G] extends LiteralBagOps[G] { this: LiteralBag[G] =>
+trait LiteralBagImpl[G] extends LiteralBagOps[G] {
+ this: LiteralBag[G] =>
override def t: Type[G] = TBag(element)
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Group(Text("bag<") <> element <> ">{" <> Doc.args(values) <> "}")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/literal/build/LiteralMapImpl.scala b/src/col/vct/col/ast/expr/literal/build/LiteralMapImpl.scala
index 8cd26c8582..adcd87c59f 100644
--- a/src/col/vct/col/ast/expr/literal/build/LiteralMapImpl.scala
+++ b/src/col/vct/col/ast/expr/literal/build/LiteralMapImpl.scala
@@ -4,10 +4,13 @@ import vct.col.ast.{LiteralMap, TMap, Type}
import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.ast.ops.LiteralMapOps
-trait LiteralMapImpl[G] extends LiteralMapOps[G] { this: LiteralMap[G] =>
+trait LiteralMapImpl[G] extends LiteralMapOps[G] {
+ this: LiteralMap[G] =>
override def t: Type[G] = TMap(k, v)
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
- Group(Text("map<") <> k <> "," <+> v <> ">{" <> Doc.args(values.map { case (k, v) => k.show <+> "->" <+> v }) <> "}")
-}
\ No newline at end of file
+ Group(Text("map<") <> k <> "," <+> v <> ">{" <> Doc.args(values.map {
+ case (k, v) => k.show <+> "->" <+> v
+ }) <> "}")
+}
diff --git a/src/col/vct/col/ast/expr/literal/build/LiteralSeqImpl.scala b/src/col/vct/col/ast/expr/literal/build/LiteralSeqImpl.scala
index 203d8c7c39..88f9005511 100644
--- a/src/col/vct/col/ast/expr/literal/build/LiteralSeqImpl.scala
+++ b/src/col/vct/col/ast/expr/literal/build/LiteralSeqImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{LiteralSeq, TSeq, Type}
import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.ast.ops.LiteralSeqOps
-trait LiteralSeqImpl[G] extends LiteralSeqOps[G] { this: LiteralSeq[G] =>
+trait LiteralSeqImpl[G] extends LiteralSeqOps[G] {
+ this: LiteralSeq[G] =>
override def t: Type[G] = TSeq(element)
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Group(Text("seq<") <> element <> ">{" <> Doc.args(values) <> "}")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/literal/build/LiteralSetImpl.scala b/src/col/vct/col/ast/expr/literal/build/LiteralSetImpl.scala
index 0da714cfb4..0bed126d09 100644
--- a/src/col/vct/col/ast/expr/literal/build/LiteralSetImpl.scala
+++ b/src/col/vct/col/ast/expr/literal/build/LiteralSetImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{LiteralSet, TSet, Type}
import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.ast.ops.LiteralSetOps
-trait LiteralSetImpl[G] extends LiteralSetOps[G] { this: LiteralSet[G] =>
+trait LiteralSetImpl[G] extends LiteralSetOps[G] {
+ this: LiteralSet[G] =>
override def t: Type[G] = TSet(element)
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Group(Text("set<") <> element <> ">{" <> Doc.args(values) <> "}")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/literal/build/LiteralTupleImpl.scala b/src/col/vct/col/ast/expr/literal/build/LiteralTupleImpl.scala
index 7f0f574966..1f5612db2e 100644
--- a/src/col/vct/col/ast/expr/literal/build/LiteralTupleImpl.scala
+++ b/src/col/vct/col/ast/expr/literal/build/LiteralTupleImpl.scala
@@ -6,17 +6,15 @@ import vct.col.check.{CheckContext, CheckError, TupleTypeCount}
import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.ast.ops.LiteralTupleOps
-trait LiteralTupleImpl[G] extends ExprImpl[G] with LiteralTupleOps[G] { this: LiteralTuple[G] =>
+trait LiteralTupleImpl[G] extends ExprImpl[G] with LiteralTupleOps[G] {
+ this: LiteralTuple[G] =>
override def t: Type[G] = TTuple(ts)
override def check(context: CheckContext[G]): Seq[CheckError] =
- if(ts.size == values.size) {
- super.check(context)
- } else {
- Seq(TupleTypeCount(this))
- }
+ if (ts.size == values.size) { super.check(context) }
+ else { Seq(TupleTypeCount(this)) }
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Group(Text("tuple<") <> Doc.args(ts) <> ">{" <> Doc.args(values) <> "}")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/literal/build/LiteralVectorImpl.scala b/src/col/vct/col/ast/expr/literal/build/LiteralVectorImpl.scala
index 9dc825fafd..c9da43b649 100644
--- a/src/col/vct/col/ast/expr/literal/build/LiteralVectorImpl.scala
+++ b/src/col/vct/col/ast/expr/literal/build/LiteralVectorImpl.scala
@@ -4,10 +4,14 @@ import vct.col.ast.{LiteralVector, TVector, Type}
import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.ast.ops.LiteralVectorOps
-trait LiteralVectorImpl[G] extends LiteralVectorOps[G] { this: LiteralVector[G] =>
+trait LiteralVectorImpl[G] extends LiteralVectorOps[G] {
+ this: LiteralVector[G] =>
override def t: Type[G] = TVector(values.size, element)()
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
- Group(Text("vector<") <> element <> "," <> values.size.toString <> ">{" <> Doc.args(values) <> "}")
+ Group(
+ Text("vector<") <> element <> "," <> values.size.toString <> ">{" <>
+ Doc.args(values) <> "}"
+ )
}
diff --git a/src/col/vct/col/ast/expr/literal/build/OptNoneTypedImpl.scala b/src/col/vct/col/ast/expr/literal/build/OptNoneTypedImpl.scala
index 25ba7cf7b2..4922d36406 100644
--- a/src/col/vct/col/ast/expr/literal/build/OptNoneTypedImpl.scala
+++ b/src/col/vct/col/ast/expr/literal/build/OptNoneTypedImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{OptNoneTyped, TOption, Type}
import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.ast.ops.OptNoneTypedOps
-trait OptNoneTypedImpl[G] extends OptNoneTypedOps[G] { this: OptNoneTyped[G] =>
+trait OptNoneTypedImpl[G] extends OptNoneTypedOps[G] {
+ this: OptNoneTyped[G] =>
override def t: Type[G] = TOption(element)
override def precedence: Int = Precedence.ATOMIC
override def layout(implicit ctx: Ctx): Doc = Text("None")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/literal/build/OptSomeImpl.scala b/src/col/vct/col/ast/expr/literal/build/OptSomeImpl.scala
index 09e05236bb..d82a611c4a 100644
--- a/src/col/vct/col/ast/expr/literal/build/OptSomeImpl.scala
+++ b/src/col/vct/col/ast/expr/literal/build/OptSomeImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{OptSome, TOption, Type}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.OptSomeOps
-trait OptSomeImpl[G] extends OptSomeOps[G] { this: OptSome[G] =>
+trait OptSomeImpl[G] extends OptSomeOps[G] {
+ this: OptSome[G] =>
override def t: Type[G] = TOption(e.t)
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc = Text("Some(") <> e <> ")"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/literal/build/OptSomeTypedImpl.scala b/src/col/vct/col/ast/expr/literal/build/OptSomeTypedImpl.scala
index 43416c0749..f313582b74 100644
--- a/src/col/vct/col/ast/expr/literal/build/OptSomeTypedImpl.scala
+++ b/src/col/vct/col/ast/expr/literal/build/OptSomeTypedImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{OptSomeTyped, TOption, Type}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.OptSomeTypedOps
-trait OptSomeTypedImpl[G] extends OptSomeTypedOps[G] { this: OptSomeTyped[G] =>
+trait OptSomeTypedImpl[G] extends OptSomeTypedOps[G] {
+ this: OptSomeTyped[G] =>
override def t: Type[G] = TOption(element)
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc = Text("Some(") <> e <> ")"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/literal/build/RangeImpl.scala b/src/col/vct/col/ast/expr/literal/build/RangeImpl.scala
index 818b99e3f9..8b42b7d611 100644
--- a/src/col/vct/col/ast/expr/literal/build/RangeImpl.scala
+++ b/src/col/vct/col/ast/expr/literal/build/RangeImpl.scala
@@ -4,9 +4,11 @@ import vct.col.ast.{Range, TInt, TSeq, Type}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.RangeOps
-trait RangeImpl[G] extends RangeOps[G] { this: Range[G] =>
+trait RangeImpl[G] extends RangeOps[G] {
+ this: Range[G] =>
override def t: Type[G] = TSeq(TInt())
override def precedence: Int = Precedence.ATOMIC
- override def layout(implicit ctx: Ctx): Doc = Text("[") <> from <+> ".." <+> to <> "]"
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ Text("[") <> from <+> ".." <+> to <> "]"
+}
diff --git a/src/col/vct/col/ast/expr/literal/build/UntypedLiteralBagImpl.scala b/src/col/vct/col/ast/expr/literal/build/UntypedLiteralBagImpl.scala
index 58776d72ab..d5b59b3186 100644
--- a/src/col/vct/col/ast/expr/literal/build/UntypedLiteralBagImpl.scala
+++ b/src/col/vct/col/ast/expr/literal/build/UntypedLiteralBagImpl.scala
@@ -5,11 +5,12 @@ import vct.col.print._
import vct.col.typerules.Types
import vct.col.ast.ops.UntypedLiteralBagOps
-trait UntypedLiteralBagImpl[G] extends UntypedLiteralBagOps[G] { this: UntypedLiteralBag[G] =>
+trait UntypedLiteralBagImpl[G] extends UntypedLiteralBagOps[G] {
+ this: UntypedLiteralBag[G] =>
lazy val elementType: Type[G] = Types.leastCommonSuperType(values.map(_.t))
override def t: Type[G] = TBag(elementType)
override def precedence: Int = Precedence.ATOMIC
override def layout(implicit ctx: Ctx): Doc =
Group(Text("b{") <> Doc.args(values) <> "}")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/literal/build/UntypedLiteralSeqImpl.scala b/src/col/vct/col/ast/expr/literal/build/UntypedLiteralSeqImpl.scala
index 77029440c7..7c2522c230 100644
--- a/src/col/vct/col/ast/expr/literal/build/UntypedLiteralSeqImpl.scala
+++ b/src/col/vct/col/ast/expr/literal/build/UntypedLiteralSeqImpl.scala
@@ -5,11 +5,12 @@ import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.typerules.Types
import vct.col.ast.ops.UntypedLiteralSeqOps
-trait UntypedLiteralSeqImpl[G] extends UntypedLiteralSeqOps[G] { this: UntypedLiteralSeq[G] =>
+trait UntypedLiteralSeqImpl[G] extends UntypedLiteralSeqOps[G] {
+ this: UntypedLiteralSeq[G] =>
lazy val elementType: Type[G] = Types.leastCommonSuperType(values.map(_.t))
override def t: Type[G] = TSeq(elementType)
override def precedence: Int = Precedence.ATOMIC
override def layout(implicit ctx: Ctx): Doc =
Group(Text("[") <> Doc.args(values) <> "]")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/literal/build/UntypedLiteralSetImpl.scala b/src/col/vct/col/ast/expr/literal/build/UntypedLiteralSetImpl.scala
index 160ec63280..1d6b39c44f 100644
--- a/src/col/vct/col/ast/expr/literal/build/UntypedLiteralSetImpl.scala
+++ b/src/col/vct/col/ast/expr/literal/build/UntypedLiteralSetImpl.scala
@@ -5,11 +5,12 @@ import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.typerules.Types
import vct.col.ast.ops.UntypedLiteralSetOps
-trait UntypedLiteralSetImpl[G] extends UntypedLiteralSetOps[G] { this: UntypedLiteralSet[G] =>
+trait UntypedLiteralSetImpl[G] extends UntypedLiteralSetOps[G] {
+ this: UntypedLiteralSet[G] =>
lazy val elementType: Type[G] = Types.leastCommonSuperType(values.map(_.t))
override def t: Type[G] = TSet(elementType)
override def precedence: Int = Precedence.ATOMIC
override def layout(implicit ctx: Ctx): Doc =
Group(Text("{") <> Doc.args(values) <> "}")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/literal/constant/AutoValueImpl.scala b/src/col/vct/col/ast/expr/literal/constant/AutoValueImpl.scala
index 3bc59a586a..0c514c4a08 100644
--- a/src/col/vct/col/ast/expr/literal/constant/AutoValueImpl.scala
+++ b/src/col/vct/col/ast/expr/literal/constant/AutoValueImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.ops.AutoValueOps
import vct.col.ast.{AutoValue, TResource, Type}
import vct.col.print._
-trait AutoValueImpl[G] extends AutoValueOps[G] { this: AutoValue[G] =>
+trait AutoValueImpl[G] extends AutoValueOps[G] {
+ this: AutoValue[G] =>
override def t: Type[G] = TResource()
override def layout(implicit ctx: Ctx): Doc = Text("AutoValue(") <> loc <> ")"
diff --git a/src/col/vct/col/ast/expr/literal/constant/BooleanValueImpl.scala b/src/col/vct/col/ast/expr/literal/constant/BooleanValueImpl.scala
index 0a1b97c143..2202095016 100644
--- a/src/col/vct/col/ast/expr/literal/constant/BooleanValueImpl.scala
+++ b/src/col/vct/col/ast/expr/literal/constant/BooleanValueImpl.scala
@@ -4,16 +4,35 @@ import vct.col.ast.{BooleanValue, TBool, Type}
import vct.col.print._
import vct.col.ast.ops.BooleanValueOps
-trait BooleanValueImpl[G] extends BooleanValueOps[G] { this: BooleanValue[G] =>
+trait BooleanValueImpl[G] extends BooleanValueOps[G] {
+ this: BooleanValue[G] =>
override def t: Type[G] = TBool()
- sealed trait LayoutElement[+T] { def textualData: Char }
- case class SharedLayoutElement(textualData: Char) extends LayoutElement[Nothing]
- case class DedicatedLayoutElement[T](resource: T, textualData: Char) extends LayoutElement[T]
- def orderedLayoutFixture: Seq[LayoutElement[Boolean]] = Seq(DedicatedLayoutElement(true, 't'),
- DedicatedLayoutElement(false, 'f'), DedicatedLayoutElement(false, 'a'), DedicatedLayoutElement(true, 'r'),
- DedicatedLayoutElement(true, 'u'), DedicatedLayoutElement(false, 'l'), DedicatedLayoutElement(false, 's'),
- SharedLayoutElement('e'))
+ sealed trait LayoutElement[+T] {
+ def textualData: Char
+ }
+ case class SharedLayoutElement(textualData: Char)
+ extends LayoutElement[Nothing]
+ case class DedicatedLayoutElement[T](resource: T, textualData: Char)
+ extends LayoutElement[T]
+ def orderedLayoutFixture: Seq[LayoutElement[Boolean]] =
+ Seq(
+ DedicatedLayoutElement(true, 't'),
+ DedicatedLayoutElement(false, 'f'),
+ DedicatedLayoutElement(false, 'a'),
+ DedicatedLayoutElement(true, 'r'),
+ DedicatedLayoutElement(true, 'u'),
+ DedicatedLayoutElement(false, 'l'),
+ DedicatedLayoutElement(false, 's'),
+ SharedLayoutElement('e'),
+ )
override def precedence: Int = Precedence.ATOMIC
- override def layout(implicit ctx: Ctx): Doc = Text(orderedLayoutFixture.collect { case e@SharedLayoutElement(_) => e; case e@DedicatedLayoutElement(r, _) if r.toString == value.toString => e }.map(_.textualData).mkString(""))
+ override def layout(implicit ctx: Ctx): Doc =
+ Text(
+ orderedLayoutFixture.collect {
+ case e @ SharedLayoutElement(_) => e;
+ case e @ DedicatedLayoutElement(r, _) if r.toString == value.toString =>
+ e
+ }.map(_.textualData).mkString("")
+ )
}
diff --git a/src/col/vct/col/ast/expr/literal/constant/ConstantImpl.scala b/src/col/vct/col/ast/expr/literal/constant/ConstantImpl.scala
index fef6a6155f..c49837f844 100644
--- a/src/col/vct/col/ast/expr/literal/constant/ConstantImpl.scala
+++ b/src/col/vct/col/ast/expr/literal/constant/ConstantImpl.scala
@@ -2,13 +2,15 @@ package vct.col.ast.expr.literal.constant
import vct.col.ast.Constant
-trait ConstantImpl[G] { this: Constant[G] =>
+trait ConstantImpl[G] {
+ this: Constant[G] =>
def value: Any
- override def equals(obj: scala.Any): Boolean = obj match {
- case const: Constant[_] => this.value == const.value
- case _ => false
- }
+ override def equals(obj: scala.Any): Boolean =
+ obj match {
+ case const: Constant[_] => this.value == const.value
+ case _ => false
+ }
override def hashCode(): Int = value.hashCode()
override def toString: String = value.toString
diff --git a/src/col/vct/col/ast/expr/literal/constant/ConstantIntImpl.scala b/src/col/vct/col/ast/expr/literal/constant/ConstantIntImpl.scala
index 85a0317ac0..0fe3322c01 100644
--- a/src/col/vct/col/ast/expr/literal/constant/ConstantIntImpl.scala
+++ b/src/col/vct/col/ast/expr/literal/constant/ConstantIntImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.expr.literal.constant
import vct.col.ast.ConstantInt
-trait ConstantIntImpl[G] { this: ConstantInt[G] =>
+trait ConstantIntImpl[G] {
+ this: ConstantInt[G] =>
override def value: BigInt
}
diff --git a/src/col/vct/col/ast/expr/literal/constant/EmptyProcessImpl.scala b/src/col/vct/col/ast/expr/literal/constant/EmptyProcessImpl.scala
index cac357548d..1d4284a388 100644
--- a/src/col/vct/col/ast/expr/literal/constant/EmptyProcessImpl.scala
+++ b/src/col/vct/col/ast/expr/literal/constant/EmptyProcessImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{EmptyProcess, TProcess, Type}
import vct.col.print._
import vct.col.ast.ops.EmptyProcessOps
-trait EmptyProcessImpl[G] extends EmptyProcessOps[G] { this: EmptyProcess[G] =>
+trait EmptyProcessImpl[G] extends EmptyProcessOps[G] {
+ this: EmptyProcess[G] =>
override def t: Type[G] = TProcess()
override def precedence: Int = Precedence.ATOMIC
override def layout(implicit ctx: Ctx): Doc = Text("empty")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/literal/constant/FloatValueImpl.scala b/src/col/vct/col/ast/expr/literal/constant/FloatValueImpl.scala
index f02a4e4aba..c488103000 100644
--- a/src/col/vct/col/ast/expr/literal/constant/FloatValueImpl.scala
+++ b/src/col/vct/col/ast/expr/literal/constant/FloatValueImpl.scala
@@ -4,7 +4,9 @@ import vct.col.ast.{FloatValue}
import vct.col.print._
import vct.col.ast.ops.FloatValueOps
-trait FloatValueImpl[G] extends FloatValueOps[G] { this: FloatValue[G] =>
+trait FloatValueImpl[G] extends FloatValueOps[G] {
+ this: FloatValue[G] =>
override def precedence: Int = Precedence.ATOMIC
- override def layout(implicit ctx: Ctx): Doc = Text(value.toString()) // PB: this should change when we reconsider floats.
+ override def layout(implicit ctx: Ctx): Doc =
+ Text(value.toString()) // PB: this should change when we reconsider floats.
}
diff --git a/src/col/vct/col/ast/expr/literal/constant/NoPermImpl.scala b/src/col/vct/col/ast/expr/literal/constant/NoPermImpl.scala
index eeb600bf9e..756ed50519 100644
--- a/src/col/vct/col/ast/expr/literal/constant/NoPermImpl.scala
+++ b/src/col/vct/col/ast/expr/literal/constant/NoPermImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{NoPerm, TBoundedInt, Type}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.NoPermOps
-trait NoPermImpl[G] extends NoPermOps[G] { this: NoPerm[G] =>
+trait NoPermImpl[G] extends NoPermOps[G] {
+ this: NoPerm[G] =>
override def t: Type[G] = TBoundedInt(0, 1)
override def precedence: Int = Precedence.ATOMIC
override def layout(implicit ctx: Ctx): Doc = Text("none")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/literal/constant/NullImpl.scala b/src/col/vct/col/ast/expr/literal/constant/NullImpl.scala
index 56423d7917..c331dea598 100644
--- a/src/col/vct/col/ast/expr/literal/constant/NullImpl.scala
+++ b/src/col/vct/col/ast/expr/literal/constant/NullImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{Null, TNull, Type}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.NullOps
-trait NullImpl[G] extends NullOps[G] { this: Null[G] =>
+trait NullImpl[G] extends NullOps[G] {
+ this: Null[G] =>
override def t: Type[G] = TNull()
override def precedence: Int = Precedence.ATOMIC
override def layout(implicit ctx: Ctx): Doc = Text("null")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/literal/constant/OptNoneImpl.scala b/src/col/vct/col/ast/expr/literal/constant/OptNoneImpl.scala
index d6bacbc8b8..aa4d804b0f 100644
--- a/src/col/vct/col/ast/expr/literal/constant/OptNoneImpl.scala
+++ b/src/col/vct/col/ast/expr/literal/constant/OptNoneImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{OptNone, TNothing, TOption, Type}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.OptNoneOps
-trait OptNoneImpl[G] extends OptNoneOps[G] { this: OptNone[G] =>
+trait OptNoneImpl[G] extends OptNoneOps[G] {
+ this: OptNone[G] =>
override def t: Type[G] = TOption(TNothing())
override def precedence: Int = Precedence.ATOMIC
override def layout(implicit ctx: Ctx): Doc = Text("None")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/literal/constant/ReadPermImpl.scala b/src/col/vct/col/ast/expr/literal/constant/ReadPermImpl.scala
index cc3b3c2a6a..4ac455ba52 100644
--- a/src/col/vct/col/ast/expr/literal/constant/ReadPermImpl.scala
+++ b/src/col/vct/col/ast/expr/literal/constant/ReadPermImpl.scala
@@ -4,12 +4,14 @@ import vct.col.ast.{ReadPerm, TFraction, Type}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.ReadPermOps
-trait ReadPermImpl[G] extends ReadPermOps[G] { this: ReadPerm[G] =>
+trait ReadPermImpl[G] extends ReadPermOps[G] {
+ this: ReadPerm[G] =>
override def t: Type[G] = TFraction()
override def precedence: Int = Precedence.ATOMIC
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.Silver => Text("wildcard")
- case _ => Text("read")
- }
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.Silver => Text("wildcard")
+ case _ => Text("read")
+ }
+}
diff --git a/src/col/vct/col/ast/expr/literal/constant/VoidImpl.scala b/src/col/vct/col/ast/expr/literal/constant/VoidImpl.scala
index d8d7c09e24..ea414f8669 100644
--- a/src/col/vct/col/ast/expr/literal/constant/VoidImpl.scala
+++ b/src/col/vct/col/ast/expr/literal/constant/VoidImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{TVoid, Type, Void}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.VoidOps
-trait VoidImpl[G] extends VoidOps[G] { this: Void[G] =>
+trait VoidImpl[G] extends VoidOps[G] {
+ this: Void[G] =>
override def t: Type[G] = TVoid()
override def precedence: Int = Precedence.ATOMIC
override def layout(implicit ctx: Ctx): Doc = Text("void")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/literal/constant/WritePermImpl.scala b/src/col/vct/col/ast/expr/literal/constant/WritePermImpl.scala
index 49bdc5d76a..5df4c216b2 100644
--- a/src/col/vct/col/ast/expr/literal/constant/WritePermImpl.scala
+++ b/src/col/vct/col/ast/expr/literal/constant/WritePermImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{TBoundedInt, Type, WritePerm}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.WritePermOps
-trait WritePermImpl[G] extends WritePermOps[G] { this: WritePerm[G] =>
+trait WritePermImpl[G] extends WritePermOps[G] {
+ this: WritePerm[G] =>
override def t: Type[G] = TBoundedInt(1, 2)
override def precedence: Int = Precedence.ATOMIC
override def layout(implicit ctx: Ctx): Doc = Text("write")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/lock/CommittedImpl.scala b/src/col/vct/col/ast/expr/lock/CommittedImpl.scala
index 69b31fe929..8681dc7651 100644
--- a/src/col/vct/col/ast/expr/lock/CommittedImpl.scala
+++ b/src/col/vct/col/ast/expr/lock/CommittedImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{Committed, TBool}
import vct.col.print.{Ctx, Doc, Precedence, Text, Group}
import vct.col.ast.ops.CommittedOps
-trait CommittedImpl[G] extends CommittedOps[G] { this: Committed[G] =>
+trait CommittedImpl[G] extends CommittedOps[G] {
+ this: Committed[G] =>
override def t: TBool[G] = TBool()
override def precedence: Int = Precedence.ATOMIC
diff --git a/src/col/vct/col/ast/expr/lock/HeldImpl.scala b/src/col/vct/col/ast/expr/lock/HeldImpl.scala
index 1ca3834813..206ee743e9 100644
--- a/src/col/vct/col/ast/expr/lock/HeldImpl.scala
+++ b/src/col/vct/col/ast/expr/lock/HeldImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{Held, TBool, Type}
import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.ast.ops.HeldOps
-trait HeldImpl[G] extends HeldOps[G] { this: Held[G] =>
+trait HeldImpl[G] extends HeldOps[G] {
+ this: Held[G] =>
override def t: Type[G] = TBool()
override def precedence: Int = Precedence.ATOMIC
override def layout(implicit ctx: Ctx): Doc =
Group(Text("held(") <> Doc.arg(obj) <> ")")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/lock/IdleTokenImpl.scala b/src/col/vct/col/ast/expr/lock/IdleTokenImpl.scala
index 760fab6e4b..9e7113f093 100644
--- a/src/col/vct/col/ast/expr/lock/IdleTokenImpl.scala
+++ b/src/col/vct/col/ast/expr/lock/IdleTokenImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{IdleToken, TResource, Type}
import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.ast.ops.IdleTokenOps
-trait IdleTokenImpl[G] extends IdleTokenOps[G] { this: IdleToken[G] =>
+trait IdleTokenImpl[G] extends IdleTokenOps[G] {
+ this: IdleToken[G] =>
override def t: Type[G] = TResource()
override def precedence: Int = Precedence.ATOMIC
override def layout(implicit ctx: Ctx): Doc =
Group(Text("idle(") <> Doc.arg(thread) <> ")")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/lock/JoinTokenImpl.scala b/src/col/vct/col/ast/expr/lock/JoinTokenImpl.scala
index 2568a6a29a..778f2a04eb 100644
--- a/src/col/vct/col/ast/expr/lock/JoinTokenImpl.scala
+++ b/src/col/vct/col/ast/expr/lock/JoinTokenImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{JoinToken, TResource, Type}
import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.ast.ops.JoinTokenOps
-trait JoinTokenImpl[G] extends JoinTokenOps[G] { this: JoinToken[G] =>
+trait JoinTokenImpl[G] extends JoinTokenOps[G] {
+ this: JoinToken[G] =>
override def t: Type[G] = TResource()
override def precedence: Int = Precedence.ATOMIC
override def layout(implicit ctx: Ctx): Doc =
Group(Text("running(") <> Doc.arg(thread) <> ")")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/misc/AnyImpl.scala b/src/col/vct/col/ast/expr/misc/AnyImpl.scala
index 1f26418813..16ee30c22a 100644
--- a/src/col/vct/col/ast/expr/misc/AnyImpl.scala
+++ b/src/col/vct/col/ast/expr/misc/AnyImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{Any, TInt, Type}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.AnyOps
-trait AnyImpl[G] extends AnyOps[G] { this: Any[G] =>
+trait AnyImpl[G] extends AnyOps[G] {
+ this: Any[G] =>
override def t: Type[G] = TInt()
override def precedence: Int = Precedence.ATOMIC
override def layout(implicit ctx: Ctx): Doc = Text("*")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/misc/ApplyCoercionImpl.scala b/src/col/vct/col/ast/expr/misc/ApplyCoercionImpl.scala
index 3b243715b2..7b47cada25 100644
--- a/src/col/vct/col/ast/expr/misc/ApplyCoercionImpl.scala
+++ b/src/col/vct/col/ast/expr/misc/ApplyCoercionImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.{ApplyCoercion, Type}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.ApplyCoercionOps
-trait ApplyCoercionImpl[G] extends ApplyCoercionOps[G] { this: ApplyCoercion[G] =>
+trait ApplyCoercionImpl[G] extends ApplyCoercionOps[G] {
+ this: ApplyCoercion[G] =>
override def t: Type[G] = coercion.target
}
diff --git a/src/col/vct/col/ast/expr/misc/CharValueImpl.scala b/src/col/vct/col/ast/expr/misc/CharValueImpl.scala
index 3eb1f73e87..94a17592ed 100644
--- a/src/col/vct/col/ast/expr/misc/CharValueImpl.scala
+++ b/src/col/vct/col/ast/expr/misc/CharValueImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{CharValue, TChar, Type}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.CharValueOps
-trait CharValueImpl[G] extends CharValueOps[G] { this: CharValue[G] =>
+trait CharValueImpl[G] extends CharValueOps[G] {
+ this: CharValue[G] =>
def t: Type[G] = TChar()
override def precedence: Int = Precedence.ATOMIC
diff --git a/src/col/vct/col/ast/expr/misc/EnumImpl.scala b/src/col/vct/col/ast/expr/misc/EnumImpl.scala
index f8d54ad460..a117193630 100644
--- a/src/col/vct/col/ast/expr/misc/EnumImpl.scala
+++ b/src/col/vct/col/ast/expr/misc/EnumImpl.scala
@@ -6,11 +6,15 @@ import vct.col.print._
import vct.col.resolve.ctx.RefEnumConstant
import vct.col.ast.ops.EnumOps
-trait EnumImpl[G] extends EnumOps[G] { this: Enum[G] =>
- def getConstant(name: String): Option[RefEnumConstant[G]] = constants.collectFirst {
- case c if c.o.find[SourceName].contains(SourceName(name)) => RefEnumConstant(Some(this), c)
- }
+trait EnumImpl[G] extends EnumOps[G] {
+ this: Enum[G] =>
+ def getConstant(name: String): Option[RefEnumConstant[G]] =
+ constants.collectFirst {
+ case c if c.o.find[SourceName].contains(SourceName(name)) =>
+ RefEnumConstant(Some(this), c)
+ }
override def layout(implicit ctx: Ctx): Doc =
- Text("enum") <+> ctx.name(this) <+> "{" <>> Doc.stack(constants.map(_.show <> ",")) <+/> "}"
+ Text("enum") <+> ctx.name(this) <+> "{" <>>
+ Doc.stack(constants.map(_.show <> ",")) <+/> "}"
}
diff --git a/src/col/vct/col/ast/expr/misc/EnumUseImpl.scala b/src/col/vct/col/ast/expr/misc/EnumUseImpl.scala
index b1fd8b3272..2b7ce97313 100644
--- a/src/col/vct/col/ast/expr/misc/EnumUseImpl.scala
+++ b/src/col/vct/col/ast/expr/misc/EnumUseImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{EnumUse, TEnum, Type}
import vct.col.print._
import vct.col.ast.ops.EnumUseOps
-trait EnumUseImpl[G] extends EnumUseOps[G] { this: EnumUse[G] =>
+trait EnumUseImpl[G] extends EnumUseOps[G] {
+ this: EnumUse[G] =>
override def t: Type[G] = TEnum(enum)
override def precedence: Int = Precedence.POSTFIX
diff --git a/src/col/vct/col/ast/expr/misc/InlinePatternImpl.scala b/src/col/vct/col/ast/expr/misc/InlinePatternImpl.scala
index eb53ab2f2a..f6f4ae72ae 100644
--- a/src/col/vct/col/ast/expr/misc/InlinePatternImpl.scala
+++ b/src/col/vct/col/ast/expr/misc/InlinePatternImpl.scala
@@ -4,13 +4,18 @@ import vct.col.ast.{InlinePattern, Type}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.InlinePatternOps
-trait InlinePatternImpl[G] extends InlinePatternOps[G] { this: InlinePattern[G] =>
+trait InlinePatternImpl[G] extends InlinePatternOps[G] {
+ this: InlinePattern[G] =>
override def t: Type[G] = inner.t
override def precedence: Int = Precedence.ATOMIC
- override def layout(implicit ctx: Ctx): Doc = (parent, group) match {
- case (0, 0) => Text("{:") <+> inner <+> ":}"
- case (parent, 0) => Text("{:") <> "<".repeat(parent) <> ":" <+> inner <+> ":}"
- case (parent, group) => Text("{:") <> "<".repeat(parent) <> group.toString <> ":" <+> inner <+> ":}"
- }
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ (parent, group) match {
+ case (0, 0) => Text("{:") <+> inner <+> ":}"
+ case (parent, 0) =>
+ Text("{:") <> "<".repeat(parent) <> ":" <+> inner <+> ":}"
+ case (parent, group) =>
+ Text("{:") <> "<".repeat(parent) <> group.toString <> ":" <+> inner <+>
+ ":}"
+ }
+}
diff --git a/src/col/vct/col/ast/expr/misc/LocalImpl.scala b/src/col/vct/col/ast/expr/misc/LocalImpl.scala
index 8facf092d9..497ba2404f 100644
--- a/src/col/vct/col/ast/expr/misc/LocalImpl.scala
+++ b/src/col/vct/col/ast/expr/misc/LocalImpl.scala
@@ -6,11 +6,12 @@ import vct.col.check.{CheckContext, CheckError}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.LocalOps
-trait LocalImpl[G] extends ExprImpl[G] with LocalOps[G] { this: Local[G] =>
+trait LocalImpl[G] extends ExprImpl[G] with LocalOps[G] {
+ this: Local[G] =>
override def t: Type[G] = ref.decl.t
override def check(context: CheckContext[G]): Seq[CheckError] =
context.checkInScope(this, ref)
override def precedence: Int = Precedence.ATOMIC
override def layout(implicit ctx: Ctx): Doc = Text(ctx.name(ref))
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/misc/OldImpl.scala b/src/col/vct/col/ast/expr/misc/OldImpl.scala
index d3ea547029..46bf39e6a7 100644
--- a/src/col/vct/col/ast/expr/misc/OldImpl.scala
+++ b/src/col/vct/col/ast/expr/misc/OldImpl.scala
@@ -4,14 +4,18 @@ import vct.col.ast.{Old, Type}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.OldOps
-trait OldImpl[G] extends OldOps[G] { this: Old[G] =>
+trait OldImpl[G] extends OldOps[G] {
+ this: Old[G] =>
override def t: Type[G] = expr.t
override def precedence: Int = Precedence.ATOMIC
- override def layout(implicit ctx: Ctx): Doc = (ctx.syntax, at) match {
- case (Ctx.Silver, None) => Text("old(") <> expr <> ")"
- case (Ctx.Silver, Some(at)) => Text("old[") <> ctx.name(at) <> "](" <> expr <> ")"
- case (_, None) => Text("\\old(") <> expr <> ")"
- case (_, Some(at)) => Text("\\old[") <> ctx.name(at) <> "](" <> expr <> ")"
- }
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ (ctx.syntax, at) match {
+ case (Ctx.Silver, None) => Text("old(") <> expr <> ")"
+ case (Ctx.Silver, Some(at)) =>
+ Text("old[") <> ctx.name(at) <> "](" <> expr <> ")"
+ case (_, None) => Text("\\old(") <> expr <> ")"
+ case (_, Some(at)) =>
+ Text("\\old[") <> ctx.name(at) <> "](" <> expr <> ")"
+ }
+}
diff --git a/src/col/vct/col/ast/expr/misc/StringValueImpl.scala b/src/col/vct/col/ast/expr/misc/StringValueImpl.scala
index ae57cd3a0e..c71ce86bc1 100644
--- a/src/col/vct/col/ast/expr/misc/StringValueImpl.scala
+++ b/src/col/vct/col/ast/expr/misc/StringValueImpl.scala
@@ -4,10 +4,10 @@ import vct.col.ast.{StringValue, TString, Type}
import vct.col.print._
import vct.col.ast.ops.StringValueOps
-trait StringValueImpl[G] extends StringValueOps[G] { this: StringValue[G] =>
+trait StringValueImpl[G] extends StringValueOps[G] {
+ this: StringValue[G] =>
override def t: Type[G] = TString()
override def precedence: Int = Precedence.ATOMIC
- override def layout(implicit ctx: Ctx): Doc =
- Text("\"") <> value <> "\""
+ override def layout(implicit ctx: Ctx): Doc = Text("\"") <> value <> "\""
}
diff --git a/src/col/vct/col/ast/expr/model/ModelAbstractStateImpl.scala b/src/col/vct/col/ast/expr/model/ModelAbstractStateImpl.scala
index 28dee8d607..2cc5c40a01 100644
--- a/src/col/vct/col/ast/expr/model/ModelAbstractStateImpl.scala
+++ b/src/col/vct/col/ast/expr/model/ModelAbstractStateImpl.scala
@@ -4,10 +4,14 @@ import vct.col.ast.{ModelAbstractState, TResource, Type}
import vct.col.print._
import vct.col.ast.ops.ModelAbstractStateOps
-trait ModelAbstractStateImpl[G] extends ModelAbstractStateOps[G] { this: ModelAbstractState[G] =>
+trait ModelAbstractStateImpl[G] extends ModelAbstractStateOps[G] {
+ this: ModelAbstractState[G] =>
override def t: Type[G] = TResource()
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
- Group(assoc(model) <> "." <> "abstractState" <> "(" <> Doc.args(Seq(state)) <> ")")
-}
\ No newline at end of file
+ Group(
+ assoc(model) <> "." <> "abstractState" <> "(" <> Doc.args(Seq(state)) <>
+ ")"
+ )
+}
diff --git a/src/col/vct/col/ast/expr/model/ModelChooseImpl.scala b/src/col/vct/col/ast/expr/model/ModelChooseImpl.scala
index 14257f7861..6639daf2b0 100644
--- a/src/col/vct/col/ast/expr/model/ModelChooseImpl.scala
+++ b/src/col/vct/col/ast/expr/model/ModelChooseImpl.scala
@@ -4,10 +4,14 @@ import vct.col.ast.{ModelChoose, TVoid, Type}
import vct.col.print.{Ctx, Doc, Precedence, Group}
import vct.col.ast.ops.ModelChooseOps
-trait ModelChooseImpl[G] extends ModelChooseOps[G] { this: ModelChoose[G] =>
+trait ModelChooseImpl[G] extends ModelChooseOps[G] {
+ this: ModelChoose[G] =>
override def t: Type[G] = TVoid()
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
- Group(assoc(model) <> "." <> "choose" <> "(" <> Doc.args(Seq(perm, totalProcess)) <> ")")
-}
\ No newline at end of file
+ Group(
+ assoc(model) <> "." <> "choose" <> "(" <>
+ Doc.args(Seq(perm, totalProcess)) <> ")"
+ )
+}
diff --git a/src/col/vct/col/ast/expr/model/ModelCreateImpl.scala b/src/col/vct/col/ast/expr/model/ModelCreateImpl.scala
index faaa0bb646..084f8172b9 100644
--- a/src/col/vct/col/ast/expr/model/ModelCreateImpl.scala
+++ b/src/col/vct/col/ast/expr/model/ModelCreateImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{ModelCreate, TVoid, Type}
import vct.col.print._
import vct.col.ast.ops.ModelCreateOps
-trait ModelCreateImpl[G] extends ModelCreateOps[G] { this: ModelCreate[G] =>
+trait ModelCreateImpl[G] extends ModelCreateOps[G] {
+ this: ModelCreate[G] =>
override def t: Type[G] = TVoid()
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Group(assoc(model) <> "." <> "create" <> "(" <> Doc.args(Seq(init)) <> ")")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/model/ModelDestroyImpl.scala b/src/col/vct/col/ast/expr/model/ModelDestroyImpl.scala
index 3909023f0e..b287424ebc 100644
--- a/src/col/vct/col/ast/expr/model/ModelDestroyImpl.scala
+++ b/src/col/vct/col/ast/expr/model/ModelDestroyImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{ModelDestroy, TVoid, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.ModelDestroyOps
-trait ModelDestroyImpl[G] extends ModelDestroyOps[G] { this: ModelDestroy[G] =>
+trait ModelDestroyImpl[G] extends ModelDestroyOps[G] {
+ this: ModelDestroy[G] =>
override def t: Type[G] = TVoid()
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
assoc(model) <> "." <> "destroy" <> "(" <> ")"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/model/ModelMergeImpl.scala b/src/col/vct/col/ast/expr/model/ModelMergeImpl.scala
index 95af9fcb24..56d1b2d016 100644
--- a/src/col/vct/col/ast/expr/model/ModelMergeImpl.scala
+++ b/src/col/vct/col/ast/expr/model/ModelMergeImpl.scala
@@ -4,10 +4,14 @@ import vct.col.ast.{ModelMerge, TVoid, Type}
import vct.col.print.{Ctx, Doc, Precedence, Group}
import vct.col.ast.ops.ModelMergeOps
-trait ModelMergeImpl[G] extends ModelMergeOps[G] { this: ModelMerge[G] =>
+trait ModelMergeImpl[G] extends ModelMergeOps[G] {
+ this: ModelMerge[G] =>
override def t: Type[G] = TVoid()
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
- Group(assoc(model) <> "." <> "merge" <> "(" <> Doc.args(Seq(leftPerm, leftProcess, rightPerm, rightProcess)) <> ")")
-}
\ No newline at end of file
+ Group(
+ assoc(model) <> "." <> "merge" <> "(" <>
+ Doc.args(Seq(leftPerm, leftProcess, rightPerm, rightProcess)) <> ")"
+ )
+}
diff --git a/src/col/vct/col/ast/expr/model/ModelNewImpl.scala b/src/col/vct/col/ast/expr/model/ModelNewImpl.scala
index 27dbfd3eae..dc635373cb 100644
--- a/src/col/vct/col/ast/expr/model/ModelNewImpl.scala
+++ b/src/col/vct/col/ast/expr/model/ModelNewImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{ModelNew, TModel, Type}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.ModelNewOps
-trait ModelNewImpl[G] extends ModelNewOps[G] { this: ModelNew[G] =>
+trait ModelNewImpl[G] extends ModelNewOps[G] {
+ this: ModelNew[G] =>
override def t: Type[G] = TModel(ref)
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Text(ctx.name(ref)) <> ".create()"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/model/ModelSplitImpl.scala b/src/col/vct/col/ast/expr/model/ModelSplitImpl.scala
index 26ceb8ecfa..f29bb72302 100644
--- a/src/col/vct/col/ast/expr/model/ModelSplitImpl.scala
+++ b/src/col/vct/col/ast/expr/model/ModelSplitImpl.scala
@@ -4,10 +4,14 @@ import vct.col.ast.{ModelSplit, TVoid, Type}
import vct.col.print.{Ctx, Doc, Group, Precedence}
import vct.col.ast.ops.ModelSplitOps
-trait ModelSplitImpl[G] extends ModelSplitOps[G] { this: ModelSplit[G] =>
+trait ModelSplitImpl[G] extends ModelSplitOps[G] {
+ this: ModelSplit[G] =>
override def t: Type[G] = TVoid()
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
- Group(assoc(model) <> "." <> "split" <> "(" <> Doc.args(Seq(leftPerm, leftProcess, rightPerm, rightProcess)) <> ")")
-}
\ No newline at end of file
+ Group(
+ assoc(model) <> "." <> "split" <> "(" <>
+ Doc.args(Seq(leftPerm, leftProcess, rightPerm, rightProcess)) <> ")"
+ )
+}
diff --git a/src/col/vct/col/ast/expr/model/ModelStateImpl.scala b/src/col/vct/col/ast/expr/model/ModelStateImpl.scala
index f444af32f1..eafb02b46a 100644
--- a/src/col/vct/col/ast/expr/model/ModelStateImpl.scala
+++ b/src/col/vct/col/ast/expr/model/ModelStateImpl.scala
@@ -4,10 +4,13 @@ import vct.col.ast.{ModelState, TResource, Type}
import vct.col.print.{Ctx, Doc, Group, Precedence}
import vct.col.ast.ops.ModelStateOps
-trait ModelStateImpl[G] extends ModelStateOps[G] { this: ModelState[G] =>
+trait ModelStateImpl[G] extends ModelStateOps[G] {
+ this: ModelState[G] =>
override def t: Type[G] = TResource()
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
- Group(assoc(model) <> "." <> "state" <> "(" <> Doc.args(Seq(perm, state)) <> ")")
-}
\ No newline at end of file
+ Group(
+ assoc(model) <> "." <> "state" <> "(" <> Doc.args(Seq(perm, state)) <> ")"
+ )
+}
diff --git a/src/col/vct/col/ast/expr/op/BinExprImpl.scala b/src/col/vct/col/ast/expr/op/BinExprImpl.scala
index 623b076275..7bbf539079 100644
--- a/src/col/vct/col/ast/expr/op/BinExprImpl.scala
+++ b/src/col/vct/col/ast/expr/op/BinExprImpl.scala
@@ -1,7 +1,19 @@
package vct.col.ast.expr.op
import vct.col.ast.`type`.typeclass.TFloats.getFloatMax
-import vct.col.ast.{BinExpr, Expr, IntType, TBool, TCInt, TInt, TProcess, TRational, TString, TVector, Type}
+import vct.col.ast.{
+ BinExpr,
+ Expr,
+ IntType,
+ TBool,
+ TCInt,
+ TInt,
+ TProcess,
+ TRational,
+ TString,
+ TVector,
+ Type,
+}
import vct.col.origin.Origin
import vct.col.typerules.{CoercionUtils, Types}
import vct.result.VerificationError
@@ -19,53 +31,79 @@ object BinOperatorTypes {
CoercionUtils.getCoercion(lt, TRational()).isDefined &&
CoercionUtils.getCoercion(rt, TRational()).isDefined
- def isBoolOp[G](lt: Type[G], rt: Type[G]): Boolean = CoercionUtils.getCoercion(lt, TBool()).isDefined &&
- CoercionUtils.getCoercion(rt, TBool()).isDefined
-
- def isStringOp[G](lt: Type[G], rt: Type[G]): Boolean = CoercionUtils.getCoercion(lt, TString()).isDefined
-
- def isBagOp[G](lt: Type[G], rt: Type[G]): Boolean = CoercionUtils.getAnyBagCoercion(lt).isDefined
- def isMapOp[G](lt: Type[G], rt: Type[G]): Boolean = CoercionUtils.getAnyMapCoercion(lt).isDefined
- def isPointerOp[G](lt: Type[G], rt: Type[G]): Boolean = CoercionUtils.getAnyPointerCoercion(lt).isDefined
- def isProcessOp[G](lt: Type[G], rt: Type[G]): Boolean = CoercionUtils.getCoercion(lt, TProcess()).isDefined
- def isSeqOp[G](lt: Type[G], rt: Type[G]): Boolean = CoercionUtils.getAnySeqCoercion(lt).isDefined
- def isSetOp[G](lt: Type[G], rt: Type[G]): Boolean = CoercionUtils.getAnySetCoercion(lt).isDefined
- def isVectorOp[G](lt: Type[G], rt: Type[G]): Boolean = CoercionUtils.getAnyVectorCoercion(lt).isDefined
+ def isBoolOp[G](lt: Type[G], rt: Type[G]): Boolean =
+ CoercionUtils.getCoercion(lt, TBool()).isDefined &&
+ CoercionUtils.getCoercion(rt, TBool()).isDefined
+
+ def isStringOp[G](lt: Type[G], rt: Type[G]): Boolean =
+ CoercionUtils.getCoercion(lt, TString()).isDefined
+
+ def isBagOp[G](lt: Type[G], rt: Type[G]): Boolean =
+ CoercionUtils.getAnyBagCoercion(lt).isDefined
+ def isMapOp[G](lt: Type[G], rt: Type[G]): Boolean =
+ CoercionUtils.getAnyMapCoercion(lt).isDefined
+ def isPointerOp[G](lt: Type[G], rt: Type[G]): Boolean =
+ CoercionUtils.getAnyPointerCoercion(lt).isDefined
+ def isProcessOp[G](lt: Type[G], rt: Type[G]): Boolean =
+ CoercionUtils.getCoercion(lt, TProcess()).isDefined
+ def isSeqOp[G](lt: Type[G], rt: Type[G]): Boolean =
+ CoercionUtils.getAnySeqCoercion(lt).isDefined
+ def isSetOp[G](lt: Type[G], rt: Type[G]): Boolean =
+ CoercionUtils.getAnySetCoercion(lt).isDefined
+ def isVectorOp[G](lt: Type[G], rt: Type[G]): Boolean =
+ CoercionUtils.getAnyVectorCoercion(lt).isDefined
def isVectorIntOp[G](lt: Type[G], rt: Type[G]): Boolean = {
- (for{
+ (for {
(_, TVector(sizeL, eL)) <- CoercionUtils.getAnyVectorCoercion(lt)
(_, TVector(sizeR, eR)) <- CoercionUtils.getAnyVectorCoercion(rt)
- } yield if(sizeL!=sizeR) ??? else isIntOp(eL, eR))
- .getOrElse(false)
+ } yield
+ if (sizeL != sizeR)
+ ???
+ else
+ isIntOp(eL, eR)).getOrElse(false)
}
def getVectorType[G](lt: Type[G], rt: Type[G], o: Origin): TVector[G] = {
- (for{
+ (for {
(_, TVector(sizeL, eL)) <- CoercionUtils.getAnyVectorCoercion(lt)
(_, TVector(sizeR, eR)) <- CoercionUtils.getAnyVectorCoercion(rt)
- } yield if(sizeL!=sizeR) ??? else TVector[G](sizeL, getNumericType(eL, eR, o)))
- .get
+ } yield
+ if (sizeL != sizeR)
+ ???
+ else
+ TVector[G](sizeL, getNumericType(eL, eR, o))).get
}
- def getIntType[G](lt: Type[G], rt: Type[G]): IntType[G] = if(isCIntOp(lt, rt)) TCInt() else TInt()
+ def getIntType[G](lt: Type[G], rt: Type[G]): IntType[G] =
+ if (isCIntOp(lt, rt))
+ TCInt()
+ else
+ TInt()
- case class NumericBinError(lt: Type[_], rt: Type[_], o: Origin) extends VerificationError.UserError {
- override def text: String = o.messageInContext(f"Expected types to numeric, but got: ${lt} and ${rt}")
+ case class NumericBinError(lt: Type[_], rt: Type[_], o: Origin)
+ extends VerificationError.UserError {
+ override def text: String =
+ o.messageInContext(f"Expected types to numeric, but got: ${lt} and ${rt}")
override def code: String = "numericBinError"
}
def getNumericType[G](lt: Type[G], rt: Type[G], o: Origin): Type[G] = {
- if (isCIntOp(lt, rt)) TCInt[G]() else
- if(isIntOp(lt, rt)) TInt[G]() else
- getFloatMax[G](lt, rt) getOrElse (
- if(isRationalOp(lt, rt)) TRational[G]()
- else throw NumericBinError(lt, rt, o)
- )
+ if (isCIntOp(lt, rt))
+ TCInt[G]()
+ else if (isIntOp(lt, rt))
+ TInt[G]()
+ else
+ getFloatMax[G](lt, rt) getOrElse
+ (if (isRationalOp(lt, rt))
+ TRational[G]()
+ else
+ throw NumericBinError(lt, rt, o))
}
}
-trait BinExprImpl[G] { this: BinExpr[G] =>
+trait BinExprImpl[G] {
+ this: BinExpr[G] =>
def left: Expr[G]
def right: Expr[G]
@@ -90,7 +128,9 @@ trait BinExprImpl[G] { this: BinExpr[G] =>
lazy val getIntType: IntType[G] = BinOperatorTypes.getIntType(left.t, right.t)
- lazy val getNumericType: Type[G] = BinOperatorTypes.getNumericType(left.t, right.t, o)
+ lazy val getNumericType: Type[G] = BinOperatorTypes
+ .getNumericType(left.t, right.t, o)
- lazy val getVectorType: TVector[G] = BinOperatorTypes.getVectorType(left.t, right.t, o)
-}
\ No newline at end of file
+ lazy val getVectorType: TVector[G] = BinOperatorTypes
+ .getVectorType(left.t, right.t, o)
+}
diff --git a/src/col/vct/col/ast/expr/op/UnExprImpl.scala b/src/col/vct/col/ast/expr/op/UnExprImpl.scala
index d96b4be8d1..714117a101 100644
--- a/src/col/vct/col/ast/expr/op/UnExprImpl.scala
+++ b/src/col/vct/col/ast/expr/op/UnExprImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.expr.op
import vct.col.ast.{Expr, UnExpr}
-trait UnExprImpl[G] { this: UnExpr[G] =>
+trait UnExprImpl[G] {
+ this: UnExpr[G] =>
def arg: Expr[G]
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/bit/BitAndImpl.scala b/src/col/vct/col/ast/expr/op/bit/BitAndImpl.scala
index 0b23689e17..c90584c2d7 100644
--- a/src/col/vct/col/ast/expr/op/bit/BitAndImpl.scala
+++ b/src/col/vct/col/ast/expr/op/bit/BitAndImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{BitAnd, TInt, Type}
import vct.col.print._
import vct.col.ast.ops.BitAndOps
-trait BitAndImpl[G] extends BitAndOps[G] { this: BitAnd[G] =>
+trait BitAndImpl[G] extends BitAndOps[G] {
+ this: BitAnd[G] =>
override def t: Type[G] = getIntType
override def precedence: Int = Precedence.BIT_AND
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "&", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/bit/BitNotImpl.scala b/src/col/vct/col/ast/expr/op/bit/BitNotImpl.scala
index b6b5157cc1..82393b9126 100644
--- a/src/col/vct/col/ast/expr/op/bit/BitNotImpl.scala
+++ b/src/col/vct/col/ast/expr/op/bit/BitNotImpl.scala
@@ -5,9 +5,14 @@ import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.typerules.CoercionUtils
import vct.col.ast.ops.BitNotOps
-trait BitNotImpl[G] extends BitNotOps[G] { this: BitNot[G] =>
- override def t: Type[G] = if(CoercionUtils.getCoercion(arg.t, TCInt()).isDefined) TCInt() else TInt()
+trait BitNotImpl[G] extends BitNotOps[G] {
+ this: BitNot[G] =>
+ override def t: Type[G] =
+ if (CoercionUtils.getCoercion(arg.t, TCInt()).isDefined)
+ TCInt()
+ else
+ TInt()
override def precedence: Int = Precedence.PREFIX
override def layout(implicit ctx: Ctx): Doc = Text("~") <> assoc(arg)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/bit/BitOpImpl.scala b/src/col/vct/col/ast/expr/op/bit/BitOpImpl.scala
index cde456befa..d5d4aa9d62 100644
--- a/src/col/vct/col/ast/expr/op/bit/BitOpImpl.scala
+++ b/src/col/vct/col/ast/expr/op/bit/BitOpImpl.scala
@@ -3,6 +3,13 @@ package vct.col.ast.expr.op.bit
import vct.col.ast.{BitOp, TBool, TCInt, TInt, Type}
import vct.col.typerules.CoercionUtils
-trait BitOpImpl[G] { this: BitOp[G] =>
- override def t: Type[G] = if(isBoolOp) TBool() else if(isCIntOp) TCInt() else TInt()
-}
\ No newline at end of file
+trait BitOpImpl[G] {
+ this: BitOp[G] =>
+ override def t: Type[G] =
+ if (isBoolOp)
+ TBool()
+ else if (isCIntOp)
+ TCInt()
+ else
+ TInt()
+}
diff --git a/src/col/vct/col/ast/expr/op/bit/BitOrImpl.scala b/src/col/vct/col/ast/expr/op/bit/BitOrImpl.scala
index 5cb3d33e7d..78e85a1846 100644
--- a/src/col/vct/col/ast/expr/op/bit/BitOrImpl.scala
+++ b/src/col/vct/col/ast/expr/op/bit/BitOrImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{BitOr, TInt, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.BitOrOps
-trait BitOrImpl[G] extends BitOrOps[G] { this: BitOr[G] =>
+trait BitOrImpl[G] extends BitOrOps[G] {
+ this: BitOr[G] =>
override def t: Type[G] = getIntType
override def precedence: Int = Precedence.BIT_OR
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "|", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/bit/BitShlImpl.scala b/src/col/vct/col/ast/expr/op/bit/BitShlImpl.scala
index fadb4aa13f..d71d4e2605 100644
--- a/src/col/vct/col/ast/expr/op/bit/BitShlImpl.scala
+++ b/src/col/vct/col/ast/expr/op/bit/BitShlImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{BitShl, TInt, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.BitShlOps
-trait BitShlImpl[G] extends BitShlOps[G] { this: BitShl[G] =>
+trait BitShlImpl[G] extends BitShlOps[G] {
+ this: BitShl[G] =>
override def t: Type[G] = getIntType
override def precedence: Int = Precedence.SHIFT
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "<<", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/bit/BitShrImpl.scala b/src/col/vct/col/ast/expr/op/bit/BitShrImpl.scala
index 19568c7c14..862a6f2d36 100644
--- a/src/col/vct/col/ast/expr/op/bit/BitShrImpl.scala
+++ b/src/col/vct/col/ast/expr/op/bit/BitShrImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{BitShr, TInt, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.BitShrOps
-trait BitShrImpl[G] extends BitShrOps[G] { this: BitShr[G] =>
+trait BitShrImpl[G] extends BitShrOps[G] {
+ this: BitShr[G] =>
override def t: Type[G] = getIntType
override def precedence: Int = Precedence.SHIFT
override def layout(implicit ctx: Ctx): Doc = lassoc(left, ">>", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/bit/BitUShrImpl.scala b/src/col/vct/col/ast/expr/op/bit/BitUShrImpl.scala
index eb5479f80b..8d99e3f208 100644
--- a/src/col/vct/col/ast/expr/op/bit/BitUShrImpl.scala
+++ b/src/col/vct/col/ast/expr/op/bit/BitUShrImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{BitUShr, TInt, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.BitUShrOps
-trait BitUShrImpl[G] extends BitUShrOps[G] { this: BitUShr[G] =>
+trait BitUShrImpl[G] extends BitUShrOps[G] {
+ this: BitUShr[G] =>
override def t: Type[G] = getIntType
override def precedence: Int = Precedence.SHIFT
override def layout(implicit ctx: Ctx): Doc = lassoc(left, ">>>", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/bit/BitXorImpl.scala b/src/col/vct/col/ast/expr/op/bit/BitXorImpl.scala
index 97c5808712..2eb5d362fa 100644
--- a/src/col/vct/col/ast/expr/op/bit/BitXorImpl.scala
+++ b/src/col/vct/col/ast/expr/op/bit/BitXorImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{BitXor, TInt, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.BitXorOps
-trait BitXorImpl[G] extends BitXorOps[G] { this: BitXor[G] =>
+trait BitXorImpl[G] extends BitXorOps[G] {
+ this: BitXor[G] =>
override def t: Type[G] = getIntType
override def precedence: Int = Precedence.BIT_XOR
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "^", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/bool/AndImpl.scala b/src/col/vct/col/ast/expr/op/bool/AndImpl.scala
index 9fe494ec82..ed8dbd804b 100644
--- a/src/col/vct/col/ast/expr/op/bool/AndImpl.scala
+++ b/src/col/vct/col/ast/expr/op/bool/AndImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{And, TBool, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.AndOps
-trait AndImpl[G] extends AndOps[G] { this: And[G] =>
+trait AndImpl[G] extends AndOps[G] {
+ this: And[G] =>
override def t: Type[G] = TBool()
- override def precedence: Int = Precedence.AND-5
+ override def precedence: Int = Precedence.AND - 5
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "&&", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/bool/ComputationalAndImpl.scala b/src/col/vct/col/ast/expr/op/bool/ComputationalAndImpl.scala
index 14b0f078d8..2209ee5d35 100644
--- a/src/col/vct/col/ast/expr/op/bool/ComputationalAndImpl.scala
+++ b/src/col/vct/col/ast/expr/op/bool/ComputationalAndImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{ComputationalAnd, TBool, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.ComputationalAndOps
-trait ComputationalAndImpl[G] extends ComputationalAndOps[G] { this: ComputationalAnd[G] =>
+trait ComputationalAndImpl[G] extends ComputationalAndOps[G] {
+ this: ComputationalAnd[G] =>
override def t: Type[G] = TBool()
override def precedence: Int = Precedence.BIT_AND
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "&", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/bool/ComputationalOrImpl.scala b/src/col/vct/col/ast/expr/op/bool/ComputationalOrImpl.scala
index bcb07e1574..8afe79143c 100644
--- a/src/col/vct/col/ast/expr/op/bool/ComputationalOrImpl.scala
+++ b/src/col/vct/col/ast/expr/op/bool/ComputationalOrImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{ComputationalOr, TBool, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.ComputationalOrOps
-trait ComputationalOrImpl[G] extends ComputationalOrOps[G] { this: ComputationalOr[G] =>
+trait ComputationalOrImpl[G] extends ComputationalOrOps[G] {
+ this: ComputationalOr[G] =>
override def t: Type[G] = TBool()
override def precedence: Int = Precedence.BIT_OR
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "|", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/bool/ComputationalXorImpl.scala b/src/col/vct/col/ast/expr/op/bool/ComputationalXorImpl.scala
index 26631605a5..37ccace6d1 100644
--- a/src/col/vct/col/ast/expr/op/bool/ComputationalXorImpl.scala
+++ b/src/col/vct/col/ast/expr/op/bool/ComputationalXorImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{ComputationalXor, TBool, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.ComputationalXorOps
-trait ComputationalXorImpl[G] extends ComputationalXorOps[G] { this: ComputationalXor[G] =>
+trait ComputationalXorImpl[G] extends ComputationalXorOps[G] {
+ this: ComputationalXor[G] =>
override def t: Type[G] = TBool()
override def precedence: Int = Precedence.BIT_XOR
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "^", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/bool/NotImpl.scala b/src/col/vct/col/ast/expr/op/bool/NotImpl.scala
index 91ef57761a..0fe0c9ea7d 100644
--- a/src/col/vct/col/ast/expr/op/bool/NotImpl.scala
+++ b/src/col/vct/col/ast/expr/op/bool/NotImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{Not, TBool, Type}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.NotOps
-trait NotImpl[G] extends NotOps[G] { this: Not[G] =>
+trait NotImpl[G] extends NotOps[G] {
+ this: Not[G] =>
override def t: Type[G] = TBool()
override def precedence: Int = Precedence.PREFIX
override def layout(implicit ctx: Ctx): Doc = Text("!") <> assoc(arg)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/bool/OrImpl.scala b/src/col/vct/col/ast/expr/op/bool/OrImpl.scala
index 9d205e16ae..31d57df1bf 100644
--- a/src/col/vct/col/ast/expr/op/bool/OrImpl.scala
+++ b/src/col/vct/col/ast/expr/op/bool/OrImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{Or, TBool, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.OrOps
-trait OrImpl[G] extends OrOps[G] { this: Or[G] =>
+trait OrImpl[G] extends OrOps[G] {
+ this: Or[G] =>
override def t: Type[G] = TBool()
override def precedence: Int = Precedence.OR
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "||", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/bool/SelectImpl.scala b/src/col/vct/col/ast/expr/op/bool/SelectImpl.scala
index 5873e75129..c296f7d5ca 100644
--- a/src/col/vct/col/ast/expr/op/bool/SelectImpl.scala
+++ b/src/col/vct/col/ast/expr/op/bool/SelectImpl.scala
@@ -5,11 +5,14 @@ import vct.col.print.{Ctx, Doc, Precedence, Text, Group}
import vct.col.typerules.Types
import vct.col.ast.ops.SelectOps
-trait SelectImpl[G] extends SelectOps[G] { this: Select[G] =>
- override lazy val t: Type[G] =
- Types.leastCommonSuperType(whenTrue.t, whenFalse.t)
+trait SelectImpl[G] extends SelectOps[G] {
+ this: Select[G] =>
+ override lazy val t: Type[G] = Types
+ .leastCommonSuperType(whenTrue.t, whenFalse.t)
override def precedence: Int = Precedence.SELECT
override def layout(implicit ctx: Ctx): Doc =
- Group(nassoc(condition) <>> {Text("?") <+> nassoc(whenTrue)} <>> {Text(":") <+> assoc(whenFalse)})
-}
\ No newline at end of file
+ Group(nassoc(condition) <>> { Text("?") <+> nassoc(whenTrue) } <>> {
+ Text(":") <+> assoc(whenFalse)
+ })
+}
diff --git a/src/col/vct/col/ast/expr/op/cmp/AmbiguousComparisonImpl.scala b/src/col/vct/col/ast/expr/op/cmp/AmbiguousComparisonImpl.scala
index 917a601cf7..eeb247d8f1 100644
--- a/src/col/vct/col/ast/expr/op/cmp/AmbiguousComparisonImpl.scala
+++ b/src/col/vct/col/ast/expr/op/cmp/AmbiguousComparisonImpl.scala
@@ -2,10 +2,15 @@ package vct.col.ast.expr.op.cmp
import vct.col.ast.{AmbiguousComparison, TBool, TVector, Type}
-trait AmbiguousComparisonImpl[G] { this: AmbiguousComparison[G] =>
+trait AmbiguousComparisonImpl[G] {
+ this: AmbiguousComparison[G] =>
// So this is hacky, but in C languages the type of a vector comparison is vector, and here we need to make difference
// Between CInt and Int because of the internal VerCors type checker.
def vectorInnerType: Type[G]
- override def t: Type[G] = if(isVectorOp) TVector[G](getVectorType.size, vectorInnerType) else TBool()
+ override def t: Type[G] =
+ if (isVectorOp)
+ TVector[G](getVectorType.size, vectorInnerType)
+ else
+ TBool()
}
diff --git a/src/col/vct/col/ast/expr/op/cmp/AmbiguousEqImpl.scala b/src/col/vct/col/ast/expr/op/cmp/AmbiguousEqImpl.scala
index 3e07ade35d..d5fcb9d711 100644
--- a/src/col/vct/col/ast/expr/op/cmp/AmbiguousEqImpl.scala
+++ b/src/col/vct/col/ast/expr/op/cmp/AmbiguousEqImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.AmbiguousEq
import vct.col.ast.ops.AmbiguousEqOps
import vct.col.print._
-trait AmbiguousEqImpl[G] extends AmbiguousEqOps[G] { this: AmbiguousEq[G] =>
+trait AmbiguousEqImpl[G] extends AmbiguousEqOps[G] {
+ this: AmbiguousEq[G] =>
override def precedence: Int = Precedence.EQUALITY
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "==", right)
}
diff --git a/src/col/vct/col/ast/expr/op/cmp/AmbiguousGreaterEqImpl.scala b/src/col/vct/col/ast/expr/op/cmp/AmbiguousGreaterEqImpl.scala
index cfc9c62776..cdfa0fedce 100644
--- a/src/col/vct/col/ast/expr/op/cmp/AmbiguousGreaterEqImpl.scala
+++ b/src/col/vct/col/ast/expr/op/cmp/AmbiguousGreaterEqImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.AmbiguousGreaterEq
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.AmbiguousGreaterEqOps
-trait AmbiguousGreaterEqImpl[G] extends AmbiguousGreaterEqOps[G] { this: AmbiguousGreaterEq[G] =>
+trait AmbiguousGreaterEqImpl[G] extends AmbiguousGreaterEqOps[G] {
+ this: AmbiguousGreaterEq[G] =>
override def precedence: Int = Precedence.RELATIONAL
override def layout(implicit ctx: Ctx): Doc = lassoc(left, ">=", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/cmp/AmbiguousGreaterImpl.scala b/src/col/vct/col/ast/expr/op/cmp/AmbiguousGreaterImpl.scala
index 8902be4606..a2a9d9727c 100644
--- a/src/col/vct/col/ast/expr/op/cmp/AmbiguousGreaterImpl.scala
+++ b/src/col/vct/col/ast/expr/op/cmp/AmbiguousGreaterImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.AmbiguousGreater
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.AmbiguousGreaterOps
-trait AmbiguousGreaterImpl[G] extends AmbiguousGreaterOps[G] { this: AmbiguousGreater[G] =>
+trait AmbiguousGreaterImpl[G] extends AmbiguousGreaterOps[G] {
+ this: AmbiguousGreater[G] =>
override def precedence: Int = Precedence.RELATIONAL
override def layout(implicit ctx: Ctx): Doc = lassoc(left, ">", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/cmp/AmbiguousLessEqImpl.scala b/src/col/vct/col/ast/expr/op/cmp/AmbiguousLessEqImpl.scala
index 8aaf7cbfb5..64b24eec75 100644
--- a/src/col/vct/col/ast/expr/op/cmp/AmbiguousLessEqImpl.scala
+++ b/src/col/vct/col/ast/expr/op/cmp/AmbiguousLessEqImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.AmbiguousLessEq
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.AmbiguousLessEqOps
-trait AmbiguousLessEqImpl[G] extends AmbiguousLessEqOps[G] { this: AmbiguousLessEq[G] =>
+trait AmbiguousLessEqImpl[G] extends AmbiguousLessEqOps[G] {
+ this: AmbiguousLessEq[G] =>
override def precedence: Int = Precedence.RELATIONAL
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "<=", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/cmp/AmbiguousLessImpl.scala b/src/col/vct/col/ast/expr/op/cmp/AmbiguousLessImpl.scala
index 2360b8d23a..36df88f02a 100644
--- a/src/col/vct/col/ast/expr/op/cmp/AmbiguousLessImpl.scala
+++ b/src/col/vct/col/ast/expr/op/cmp/AmbiguousLessImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.AmbiguousLess
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.AmbiguousLessOps
-trait AmbiguousLessImpl[G] extends AmbiguousLessOps[G] { this: AmbiguousLess[G] =>
+trait AmbiguousLessImpl[G] extends AmbiguousLessOps[G] {
+ this: AmbiguousLess[G] =>
override def precedence: Int = Precedence.RELATIONAL
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "<", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/cmp/AmbiguousNeqImpl.scala b/src/col/vct/col/ast/expr/op/cmp/AmbiguousNeqImpl.scala
index d6094dfc8b..556e127635 100644
--- a/src/col/vct/col/ast/expr/op/cmp/AmbiguousNeqImpl.scala
+++ b/src/col/vct/col/ast/expr/op/cmp/AmbiguousNeqImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.AmbiguousNeq
import vct.col.ast.ops.AmbiguousNeqOps
import vct.col.print._
-trait AmbiguousNeqImpl[G] extends AmbiguousNeqOps[G] { this: AmbiguousNeq[G] =>
+trait AmbiguousNeqImpl[G] extends AmbiguousNeqOps[G] {
+ this: AmbiguousNeq[G] =>
override def precedence: Int = Precedence.EQUALITY
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "!=", right)
}
diff --git a/src/col/vct/col/ast/expr/op/cmp/AmbiguousOrderOpImpl.scala b/src/col/vct/col/ast/expr/op/cmp/AmbiguousOrderOpImpl.scala
index b13b8a1187..c929f5184c 100644
--- a/src/col/vct/col/ast/expr/op/cmp/AmbiguousOrderOpImpl.scala
+++ b/src/col/vct/col/ast/expr/op/cmp/AmbiguousOrderOpImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.expr.op.cmp
import vct.col.ast.AmbiguousOrderOp
-trait AmbiguousOrderOpImpl[G] { this: AmbiguousOrderOp[G] =>
+trait AmbiguousOrderOpImpl[G] {
+ this: AmbiguousOrderOp[G] =>
}
diff --git a/src/col/vct/col/ast/expr/op/cmp/ComparisonImpl.scala b/src/col/vct/col/ast/expr/op/cmp/ComparisonImpl.scala
index 5c0ba169fc..021ceb4587 100644
--- a/src/col/vct/col/ast/expr/op/cmp/ComparisonImpl.scala
+++ b/src/col/vct/col/ast/expr/op/cmp/ComparisonImpl.scala
@@ -3,7 +3,8 @@ package vct.col.ast.expr.op.cmp
import vct.col.ast.{Comparison, TBool, Type}
import vct.col.typerules.Types
-trait ComparisonImpl[G] { this: Comparison[G] =>
+trait ComparisonImpl[G] {
+ this: Comparison[G] =>
override def t: Type[G] = TBool()
lazy val comparisonType: Type[G] = Types.leastCommonSuperType(left.t, right.t)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/cmp/EqImpl.scala b/src/col/vct/col/ast/expr/op/cmp/EqImpl.scala
index 2198fa8891..cf58cb8771 100644
--- a/src/col/vct/col/ast/expr/op/cmp/EqImpl.scala
+++ b/src/col/vct/col/ast/expr/op/cmp/EqImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.Eq
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.EqOps
-trait EqImpl[G] extends EqOps[G] { this: Eq[G] =>
+trait EqImpl[G] extends EqOps[G] {
+ this: Eq[G] =>
override def precedence: Int = Precedence.EQUALITY
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "==", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/cmp/GreaterEqImpl.scala b/src/col/vct/col/ast/expr/op/cmp/GreaterEqImpl.scala
index c081aae382..9c2acff3a8 100644
--- a/src/col/vct/col/ast/expr/op/cmp/GreaterEqImpl.scala
+++ b/src/col/vct/col/ast/expr/op/cmp/GreaterEqImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.GreaterEq
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.GreaterEqOps
-trait GreaterEqImpl[G] extends GreaterEqOps[G] { this: GreaterEq[G] =>
+trait GreaterEqImpl[G] extends GreaterEqOps[G] {
+ this: GreaterEq[G] =>
override def precedence: Int = Precedence.RELATIONAL
override def layout(implicit ctx: Ctx): Doc = lassoc(left, ">=", right)
}
diff --git a/src/col/vct/col/ast/expr/op/cmp/GreaterImpl.scala b/src/col/vct/col/ast/expr/op/cmp/GreaterImpl.scala
index 29ab741c15..9ecb9702c6 100644
--- a/src/col/vct/col/ast/expr/op/cmp/GreaterImpl.scala
+++ b/src/col/vct/col/ast/expr/op/cmp/GreaterImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.Greater
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.GreaterOps
-trait GreaterImpl[G] extends GreaterOps[G] { this: Greater[G] =>
+trait GreaterImpl[G] extends GreaterOps[G] {
+ this: Greater[G] =>
override def precedence: Int = Precedence.RELATIONAL
override def layout(implicit ctx: Ctx): Doc = lassoc(left, ">", right)
}
diff --git a/src/col/vct/col/ast/expr/op/cmp/LessEqImpl.scala b/src/col/vct/col/ast/expr/op/cmp/LessEqImpl.scala
index 8f69abdca5..127dcf5d6f 100644
--- a/src/col/vct/col/ast/expr/op/cmp/LessEqImpl.scala
+++ b/src/col/vct/col/ast/expr/op/cmp/LessEqImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.LessEq
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.LessEqOps
-trait LessEqImpl[G] extends LessEqOps[G] { this: LessEq[G] =>
+trait LessEqImpl[G] extends LessEqOps[G] {
+ this: LessEq[G] =>
override def precedence: Int = Precedence.RELATIONAL
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "<=", right)
}
diff --git a/src/col/vct/col/ast/expr/op/cmp/LessImpl.scala b/src/col/vct/col/ast/expr/op/cmp/LessImpl.scala
index 8681117b98..c52f6fa84c 100644
--- a/src/col/vct/col/ast/expr/op/cmp/LessImpl.scala
+++ b/src/col/vct/col/ast/expr/op/cmp/LessImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.Less
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.LessOps
-trait LessImpl[G] extends LessOps[G] { this: Less[G] =>
+trait LessImpl[G] extends LessOps[G] {
+ this: Less[G] =>
override def precedence: Int = Precedence.RELATIONAL
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "<", right)
}
diff --git a/src/col/vct/col/ast/expr/op/cmp/MapCmpImpl.scala b/src/col/vct/col/ast/expr/op/cmp/MapCmpImpl.scala
index ed7e3a65b0..522b5b839e 100644
--- a/src/col/vct/col/ast/expr/op/cmp/MapCmpImpl.scala
+++ b/src/col/vct/col/ast/expr/op/cmp/MapCmpImpl.scala
@@ -3,12 +3,16 @@ package vct.col.ast.expr.op.cmp
import vct.col.ast.{Expr, MapCmp, TMap}
import vct.col.typerules.Types
-trait MapCmpImpl[G] { this: MapCmp[G] =>
+trait MapCmpImpl[G] {
+ this: MapCmp[G] =>
def left: Expr[G]
def right: Expr[G]
def leftT: TMap[G] = left.t.asMap.get
def rightT: TMap[G] = right.t.asMap.get
- lazy val commonMapType: TMap[G] = TMap(leftT.key, Types.leastCommonSuperType(leftT.value, rightT.value))
+ lazy val commonMapType: TMap[G] = TMap(
+ leftT.key,
+ Types.leastCommonSuperType(leftT.value, rightT.value),
+ )
}
diff --git a/src/col/vct/col/ast/expr/op/cmp/MapDisjointImpl.scala b/src/col/vct/col/ast/expr/op/cmp/MapDisjointImpl.scala
index a9decb24f7..b08c33898e 100644
--- a/src/col/vct/col/ast/expr/op/cmp/MapDisjointImpl.scala
+++ b/src/col/vct/col/ast/expr/op/cmp/MapDisjointImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{MapDisjoint, TBool, Type}
import vct.col.print.{Ctx, Doc, Precedence, Group}
import vct.col.ast.ops.MapDisjointOps
-trait MapDisjointImpl[G] extends MapDisjointOps[G] { this: MapDisjoint[G] =>
+trait MapDisjointImpl[G] extends MapDisjointOps[G] {
+ this: MapDisjoint[G] =>
override def t: Type[G] = TBool()
override def precedence: Int = Precedence.POSTFIX
diff --git a/src/col/vct/col/ast/expr/op/cmp/MapEqImpl.scala b/src/col/vct/col/ast/expr/op/cmp/MapEqImpl.scala
index bd4670654d..a60d4b6297 100644
--- a/src/col/vct/col/ast/expr/op/cmp/MapEqImpl.scala
+++ b/src/col/vct/col/ast/expr/op/cmp/MapEqImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{MapEq, TBool, Type}
import vct.col.print.{Ctx, Doc, Precedence, Group}
import vct.col.ast.ops.MapEqOps
-trait MapEqImpl[G] extends MapEqOps[G] { this: MapEq[G] =>
+trait MapEqImpl[G] extends MapEqOps[G] {
+ this: MapEq[G] =>
override def t: Type[G] = TBool()
override def precedence: Int = Precedence.POSTFIX
diff --git a/src/col/vct/col/ast/expr/op/cmp/NeqImpl.scala b/src/col/vct/col/ast/expr/op/cmp/NeqImpl.scala
index 8eab1e72bd..fd295ed678 100644
--- a/src/col/vct/col/ast/expr/op/cmp/NeqImpl.scala
+++ b/src/col/vct/col/ast/expr/op/cmp/NeqImpl.scala
@@ -4,8 +4,9 @@ import vct.col.ast.Neq
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.NeqOps
-trait NeqImpl[G] extends NeqOps[G] { this: Neq[G] =>
+trait NeqImpl[G] extends NeqOps[G] {
+ this: Neq[G] =>
override def precedence: Int = Precedence.EQUALITY
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "!=", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/cmp/OrderOpImpl.scala b/src/col/vct/col/ast/expr/op/cmp/OrderOpImpl.scala
index 5f08338a5a..ba9d8f0d7c 100644
--- a/src/col/vct/col/ast/expr/op/cmp/OrderOpImpl.scala
+++ b/src/col/vct/col/ast/expr/op/cmp/OrderOpImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.expr.op.cmp
import vct.col.ast.{OrderOp, TInt}
import vct.col.typerules.CoercionUtils
-trait OrderOpImpl[G] { this: OrderOp[G] =>
+trait OrderOpImpl[G] {
+ this: OrderOp[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/cmp/SetComparisonImpl.scala b/src/col/vct/col/ast/expr/op/cmp/SetComparisonImpl.scala
index d7568645be..1130346a6b 100644
--- a/src/col/vct/col/ast/expr/op/cmp/SetComparisonImpl.scala
+++ b/src/col/vct/col/ast/expr/op/cmp/SetComparisonImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.expr.op.cmp
import vct.col.ast.SetComparison
-trait SetComparisonImpl[G] { this: SetComparison[G] =>
+trait SetComparisonImpl[G] {
+ this: SetComparison[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/cmp/SubBagEqImpl.scala b/src/col/vct/col/ast/expr/op/cmp/SubBagEqImpl.scala
index f862cc59aa..6f3bac4ddb 100644
--- a/src/col/vct/col/ast/expr/op/cmp/SubBagEqImpl.scala
+++ b/src/col/vct/col/ast/expr/op/cmp/SubBagEqImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.SubBagEq
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.SubBagEqOps
-trait SubBagEqImpl[G] extends SubBagEqOps[G] { this: SubBagEq[G] =>
+trait SubBagEqImpl[G] extends SubBagEqOps[G] {
+ this: SubBagEq[G] =>
override def precedence: Int = Precedence.RELATIONAL
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "<=", right)
}
diff --git a/src/col/vct/col/ast/expr/op/cmp/SubBagImpl.scala b/src/col/vct/col/ast/expr/op/cmp/SubBagImpl.scala
index 47168742a8..947c7c8b5b 100644
--- a/src/col/vct/col/ast/expr/op/cmp/SubBagImpl.scala
+++ b/src/col/vct/col/ast/expr/op/cmp/SubBagImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.SubBag
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.SubBagOps
-trait SubBagImpl[G] extends SubBagOps[G] { this: SubBag[G] =>
+trait SubBagImpl[G] extends SubBagOps[G] {
+ this: SubBag[G] =>
override def precedence: Int = Precedence.RELATIONAL
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "<", right)
}
diff --git a/src/col/vct/col/ast/expr/op/cmp/SubSetEqImpl.scala b/src/col/vct/col/ast/expr/op/cmp/SubSetEqImpl.scala
index e7522e0d23..783d97511a 100644
--- a/src/col/vct/col/ast/expr/op/cmp/SubSetEqImpl.scala
+++ b/src/col/vct/col/ast/expr/op/cmp/SubSetEqImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.SubSetEq
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.SubSetEqOps
-trait SubSetEqImpl[G] extends SubSetEqOps[G] { this: SubSetEq[G] =>
+trait SubSetEqImpl[G] extends SubSetEqOps[G] {
+ this: SubSetEq[G] =>
override def precedence: Int = Precedence.RELATIONAL
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "<=", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/cmp/SubSetImpl.scala b/src/col/vct/col/ast/expr/op/cmp/SubSetImpl.scala
index 6592b4c7eb..d136acb275 100644
--- a/src/col/vct/col/ast/expr/op/cmp/SubSetImpl.scala
+++ b/src/col/vct/col/ast/expr/op/cmp/SubSetImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.SubSet
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.SubSetOps
-trait SubSetImpl[G] extends SubSetOps[G] { this: SubSet[G] =>
+trait SubSetImpl[G] extends SubSetOps[G] {
+ this: SubSet[G] =>
override def precedence: Int = Precedence.RELATIONAL
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "<", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/cmp/VectorEqImpl.scala b/src/col/vct/col/ast/expr/op/cmp/VectorEqImpl.scala
index 5ff8775477..5ceb82e116 100644
--- a/src/col/vct/col/ast/expr/op/cmp/VectorEqImpl.scala
+++ b/src/col/vct/col/ast/expr/op/cmp/VectorEqImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{TInt, TVector, Type, VectorEq}
import vct.col.ast.ops.VectorEqOps
import vct.col.print._
-trait VectorEqImpl[G] extends VectorEqOps[G] { this: VectorEq[G] =>
+trait VectorEqImpl[G] extends VectorEqOps[G] {
+ this: VectorEq[G] =>
override def t: Type[G] = TVector[G](getVectorType.size, TInt())
override def precedence: Int = Precedence.EQUALITY
diff --git a/src/col/vct/col/ast/expr/op/cmp/VectorNeqImpl.scala b/src/col/vct/col/ast/expr/op/cmp/VectorNeqImpl.scala
index 887b1db200..1cb3dd2a65 100644
--- a/src/col/vct/col/ast/expr/op/cmp/VectorNeqImpl.scala
+++ b/src/col/vct/col/ast/expr/op/cmp/VectorNeqImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{TInt, TVector, Type, VectorNeq}
import vct.col.ast.ops.VectorNeqOps
import vct.col.print._
-trait VectorNeqImpl[G] extends VectorNeqOps[G] { this: VectorNeq[G] =>
+trait VectorNeqImpl[G] extends VectorNeqOps[G] {
+ this: VectorNeq[G] =>
override def t: Type[G] = TVector[G](getVectorType.size, TInt())
override def precedence: Int = Precedence.EQUALITY
diff --git a/src/col/vct/col/ast/expr/op/collection/BagAddImpl.scala b/src/col/vct/col/ast/expr/op/collection/BagAddImpl.scala
index 0bb09379c2..8c3b6d7848 100644
--- a/src/col/vct/col/ast/expr/op/collection/BagAddImpl.scala
+++ b/src/col/vct/col/ast/expr/op/collection/BagAddImpl.scala
@@ -5,10 +5,13 @@ import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.typerules.Types
import vct.col.ast.ops.BagAddOps
-trait BagAddImpl[G] extends BagAddOps[G] { this: BagAdd[G] =>
+trait BagAddImpl[G] extends BagAddOps[G] {
+ this: BagAdd[G] =>
def xsType: TBag[G] = xs.t.asBag.get
def ysType: TBag[G] = ys.t.asBag.get
- override lazy val t: TBag[G] = TBag(Types.leastCommonSuperType(xsType.element, ysType.element))
+ override lazy val t: TBag[G] = TBag(
+ Types.leastCommonSuperType(xsType.element, ysType.element)
+ )
override def precedence: Int = Precedence.ADDITIVE
override def layout(implicit ctx: Ctx): Doc = lassoc(xs, "+", ys)
diff --git a/src/col/vct/col/ast/expr/op/collection/BagLargestCommonImpl.scala b/src/col/vct/col/ast/expr/op/collection/BagLargestCommonImpl.scala
index ce31252e71..e8003d7405 100644
--- a/src/col/vct/col/ast/expr/op/collection/BagLargestCommonImpl.scala
+++ b/src/col/vct/col/ast/expr/op/collection/BagLargestCommonImpl.scala
@@ -5,10 +5,13 @@ import vct.col.print._
import vct.col.typerules.Types
import vct.col.ast.ops.BagLargestCommonOps
-trait BagLargestCommonImpl[G] extends BagLargestCommonOps[G] { this: BagLargestCommon[G] =>
+trait BagLargestCommonImpl[G] extends BagLargestCommonOps[G] {
+ this: BagLargestCommon[G] =>
def xsType: TBag[G] = xs.t.asBag.get
def ysType: TBag[G] = ys.t.asBag.get
- override lazy val t: TBag[G] = TBag(Types.leastCommonSuperType(xsType.element, ysType.element))
+ override lazy val t: TBag[G] = TBag(
+ Types.leastCommonSuperType(xsType.element, ysType.element)
+ )
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
diff --git a/src/col/vct/col/ast/expr/op/collection/BagMemberCountImpl.scala b/src/col/vct/col/ast/expr/op/collection/BagMemberCountImpl.scala
index 8d12c97d68..ac02b56fe6 100644
--- a/src/col/vct/col/ast/expr/op/collection/BagMemberCountImpl.scala
+++ b/src/col/vct/col/ast/expr/op/collection/BagMemberCountImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{BagMemberCount, TInt, Type}
import vct.col.print.{Ctx, Doc, Group, Precedence}
import vct.col.ast.ops.BagMemberCountOps
-trait BagMemberCountImpl[G] extends BagMemberCountOps[G] { this: BagMemberCount[G] =>
+trait BagMemberCountImpl[G] extends BagMemberCountOps[G] {
+ this: BagMemberCount[G] =>
override def t: Type[G] = TInt()
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Group(assoc(xs) <> ".count(" <> Doc.arg(x) <> ")")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/collection/BagMinusImpl.scala b/src/col/vct/col/ast/expr/op/collection/BagMinusImpl.scala
index d876b28106..42e17505d5 100644
--- a/src/col/vct/col/ast/expr/op/collection/BagMinusImpl.scala
+++ b/src/col/vct/col/ast/expr/op/collection/BagMinusImpl.scala
@@ -5,10 +5,13 @@ import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.typerules.Types
import vct.col.ast.ops.BagMinusOps
-trait BagMinusImpl[G] extends BagMinusOps[G] { this: BagMinus[G] =>
+trait BagMinusImpl[G] extends BagMinusOps[G] {
+ this: BagMinus[G] =>
def xsType: TBag[G] = xs.t.asBag.get
def ysType: TBag[G] = ys.t.asBag.get
- override lazy val t: TBag[G] = TBag(Types.leastCommonSuperType(xsType.element, ysType.element))
+ override lazy val t: TBag[G] = TBag(
+ Types.leastCommonSuperType(xsType.element, ysType.element)
+ )
override def precedence: Int = Precedence.ADDITIVE
override def layout(implicit ctx: Ctx): Doc = lassoc(xs, "-", ys)
diff --git a/src/col/vct/col/ast/expr/op/collection/ConcatImpl.scala b/src/col/vct/col/ast/expr/op/collection/ConcatImpl.scala
index b6336baede..73308857d6 100644
--- a/src/col/vct/col/ast/expr/op/collection/ConcatImpl.scala
+++ b/src/col/vct/col/ast/expr/op/collection/ConcatImpl.scala
@@ -5,12 +5,15 @@ import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.typerules.Types
import vct.col.ast.ops.ConcatOps
-trait ConcatImpl[G] extends ConcatOps[G] { this: Concat[G] =>
+trait ConcatImpl[G] extends ConcatOps[G] {
+ this: Concat[G] =>
def leftType: TSeq[G] = xs.t.asSeq.get
def rightType: TSeq[G] = ys.t.asSeq.get
- override lazy val t: Type[G] = TSeq(Types.leastCommonSuperType(leftType.element, rightType.element))
+ override lazy val t: Type[G] = TSeq(
+ Types.leastCommonSuperType(leftType.element, rightType.element)
+ )
override def precedence: Int = Precedence.ADDITIVE
override def layout(implicit ctx: Ctx): Doc = lassoc(xs, "+", ys)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/collection/ConsImpl.scala b/src/col/vct/col/ast/expr/op/collection/ConsImpl.scala
index 619ddceb98..c1a8afe17e 100644
--- a/src/col/vct/col/ast/expr/op/collection/ConsImpl.scala
+++ b/src/col/vct/col/ast/expr/op/collection/ConsImpl.scala
@@ -5,11 +5,14 @@ import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.typerules.Types
import vct.col.ast.ops.ConsOps
-trait ConsImpl[G] extends ConsOps[G] { this: Cons[G] =>
+trait ConsImpl[G] extends ConsOps[G] {
+ this: Cons[G] =>
def tailType: TSeq[G] = xs.t.asSeq.get
- override lazy val t: TSeq[G] = TSeq(Types.leastCommonSuperType(tailType.element, x.t))
+ override lazy val t: TSeq[G] = TSeq(
+ Types.leastCommonSuperType(tailType.element, x.t)
+ )
override def precedence: Int = Precedence.SEQUENCE
override def layout(implicit ctx: Ctx): Doc = rassoc(x, "::", xs)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/collection/DropImpl.scala b/src/col/vct/col/ast/expr/op/collection/DropImpl.scala
index 27c5f6e1fc..0e3a005a97 100644
--- a/src/col/vct/col/ast/expr/op/collection/DropImpl.scala
+++ b/src/col/vct/col/ast/expr/op/collection/DropImpl.scala
@@ -4,9 +4,11 @@ import vct.col.ast.{Drop, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.DropOps
-trait DropImpl[G] extends DropOps[G] { this: Drop[G] =>
+trait DropImpl[G] extends DropOps[G] {
+ this: Drop[G] =>
override def t: Type[G] = xs.t
override def precedence: Int = Precedence.POSTFIX
- override def layout(implicit ctx: Ctx): Doc = assoc(xs) <> "[" <> count <> "..]"
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ assoc(xs) <> "[" <> count <> "..]"
+}
diff --git a/src/col/vct/col/ast/expr/op/collection/EmptyImpl.scala b/src/col/vct/col/ast/expr/op/collection/EmptyImpl.scala
index 6da225ba9d..57b930fdb4 100644
--- a/src/col/vct/col/ast/expr/op/collection/EmptyImpl.scala
+++ b/src/col/vct/col/ast/expr/op/collection/EmptyImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{Empty, TBool, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.EmptyOps
-trait EmptyImpl[G] extends EmptyOps[G] { this: Empty[G] =>
+trait EmptyImpl[G] extends EmptyOps[G] {
+ this: Empty[G] =>
override def t: Type[G] = TBool()
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc = assoc(obj) <> ".isEmpty"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/collection/HeadImpl.scala b/src/col/vct/col/ast/expr/op/collection/HeadImpl.scala
index 21e3fdabfd..088d3343fa 100644
--- a/src/col/vct/col/ast/expr/op/collection/HeadImpl.scala
+++ b/src/col/vct/col/ast/expr/op/collection/HeadImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{Head, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.HeadOps
-trait HeadImpl[G] extends HeadOps[G] { this: Head[G] =>
+trait HeadImpl[G] extends HeadOps[G] {
+ this: Head[G] =>
override def t: Type[G] = xs.t.asSeq.get.element
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc = assoc(xs) <> ".head"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/collection/PermutationImpl.scala b/src/col/vct/col/ast/expr/op/collection/PermutationImpl.scala
index 4b301d0200..3688afee8a 100644
--- a/src/col/vct/col/ast/expr/op/collection/PermutationImpl.scala
+++ b/src/col/vct/col/ast/expr/op/collection/PermutationImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.expr.op.collection
import vct.col.ast.{Permutation, TBool, Type}
import vct.col.ast.ops.PermutationOps
-trait PermutationImpl[G] extends PermutationOps[G] { this: Permutation[G] =>
+trait PermutationImpl[G] extends PermutationOps[G] {
+ this: Permutation[G] =>
override def t: Type[G] = TBool()
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/collection/RemoveAtImpl.scala b/src/col/vct/col/ast/expr/op/collection/RemoveAtImpl.scala
index 58cf0c1334..5bae02b7ba 100644
--- a/src/col/vct/col/ast/expr/op/collection/RemoveAtImpl.scala
+++ b/src/col/vct/col/ast/expr/op/collection/RemoveAtImpl.scala
@@ -4,9 +4,11 @@ import vct.col.ast.{RemoveAt, Type}
import vct.col.print.{Ctx, Doc, Precedence, Group}
import vct.col.ast.ops.RemoveAtOps
-trait RemoveAtImpl[G] extends RemoveAtOps[G] { this: RemoveAt[G] =>
+trait RemoveAtImpl[G] extends RemoveAtOps[G] {
+ this: RemoveAt[G] =>
override def t: Type[G] = xs.t
override def precedence: Int = Precedence.POSTFIX
- override def layout(implicit ctx: Ctx): Doc = Group(assoc(xs) <> ".removeAt(" <> Doc.arg(i) <> ")")
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ Group(assoc(xs) <> ".removeAt(" <> Doc.arg(i) <> ")")
+}
diff --git a/src/col/vct/col/ast/expr/op/collection/SeqMemberImpl.scala b/src/col/vct/col/ast/expr/op/collection/SeqMemberImpl.scala
index 8aa8efcfdb..1953648748 100644
--- a/src/col/vct/col/ast/expr/op/collection/SeqMemberImpl.scala
+++ b/src/col/vct/col/ast/expr/op/collection/SeqMemberImpl.scala
@@ -4,9 +4,18 @@ import vct.col.ast.{SeqMember, TBool, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.SeqMemberOps
-trait SeqMemberImpl[G] extends SeqMemberOps[G] { this: SeqMember[G] =>
+trait SeqMemberImpl[G] extends SeqMemberOps[G] {
+ this: SeqMember[G] =>
override def t: Type[G] = TBool()
override def precedence: Int = Precedence.RELATIONAL
- override def layout(implicit ctx: Ctx): Doc = lassoc(x, if(ctx.syntax == Ctx.Silver) "in" else "\\in", xs)
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ lassoc(
+ x,
+ if (ctx.syntax == Ctx.Silver)
+ "in"
+ else
+ "\\in",
+ xs,
+ )
+}
diff --git a/src/col/vct/col/ast/expr/op/collection/SeqSubscriptImpl.scala b/src/col/vct/col/ast/expr/op/collection/SeqSubscriptImpl.scala
index f38c647765..8bb2917f82 100644
--- a/src/col/vct/col/ast/expr/op/collection/SeqSubscriptImpl.scala
+++ b/src/col/vct/col/ast/expr/op/collection/SeqSubscriptImpl.scala
@@ -4,9 +4,11 @@ import vct.col.ast.{SeqSubscript, Type}
import vct.col.print.{Ctx, Doc, Precedence, Group}
import vct.col.ast.ops.SeqSubscriptOps
-trait SeqSubscriptImpl[G] extends SeqSubscriptOps[G] { this: SeqSubscript[G] =>
+trait SeqSubscriptImpl[G] extends SeqSubscriptOps[G] {
+ this: SeqSubscript[G] =>
override def t: Type[G] = seq.t.asSeq.get.element
override def precedence: Int = Precedence.POSTFIX
- override def layout(implicit ctx: Ctx): Doc = Group(assoc(seq) <> "[" <> Doc.arg(index) <> "]")
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ Group(assoc(seq) <> "[" <> Doc.arg(index) <> "]")
+}
diff --git a/src/col/vct/col/ast/expr/op/collection/SeqUpdateImpl.scala b/src/col/vct/col/ast/expr/op/collection/SeqUpdateImpl.scala
index 0354028dad..7258b015c9 100644
--- a/src/col/vct/col/ast/expr/op/collection/SeqUpdateImpl.scala
+++ b/src/col/vct/col/ast/expr/op/collection/SeqUpdateImpl.scala
@@ -5,12 +5,15 @@ import vct.col.print._
import vct.col.typerules.Types
import vct.col.ast.ops.SeqUpdateOps
-trait SeqUpdateImpl[G] extends SeqUpdateOps[G] { this: SeqUpdate[G] =>
+trait SeqUpdateImpl[G] extends SeqUpdateOps[G] {
+ this: SeqUpdate[G] =>
def tailType: TSeq[G] = xs.t.asSeq.get
- override lazy val t: TSeq[G] = TSeq(Types.leastCommonSuperType(tailType.element, x.t))
+ override lazy val t: TSeq[G] = TSeq(
+ Types.leastCommonSuperType(tailType.element, x.t)
+ )
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Group(assoc(xs) <> ".update(" <> Doc.args(Seq(i, x)) <> ")")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/collection/SetIntersectionImpl.scala b/src/col/vct/col/ast/expr/op/collection/SetIntersectionImpl.scala
index ed5da86710..e381cc8ca6 100644
--- a/src/col/vct/col/ast/expr/op/collection/SetIntersectionImpl.scala
+++ b/src/col/vct/col/ast/expr/op/collection/SetIntersectionImpl.scala
@@ -5,10 +5,13 @@ import vct.col.print.{Ctx, Doc, Group, Precedence}
import vct.col.typerules.Types
import vct.col.ast.ops.SetIntersectionOps
-trait SetIntersectionImpl[G] extends SetIntersectionOps[G] { this: SetIntersection[G] =>
+trait SetIntersectionImpl[G] extends SetIntersectionOps[G] {
+ this: SetIntersection[G] =>
def xsType: TSet[G] = xs.t.asSet.get
def ysType: TSet[G] = ys.t.asSet.get
- override lazy val t: TSet[G] = TSet(Types.leastCommonSuperType(xsType.element, ysType.element))
+ override lazy val t: TSet[G] = TSet(
+ Types.leastCommonSuperType(xsType.element, ysType.element)
+ )
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
diff --git a/src/col/vct/col/ast/expr/op/collection/SetMemberImpl.scala b/src/col/vct/col/ast/expr/op/collection/SetMemberImpl.scala
index cc0a3972b2..1e39b006d0 100644
--- a/src/col/vct/col/ast/expr/op/collection/SetMemberImpl.scala
+++ b/src/col/vct/col/ast/expr/op/collection/SetMemberImpl.scala
@@ -4,9 +4,18 @@ import vct.col.ast.{SetMember, TBool, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.SetMemberOps
-trait SetMemberImpl[G] extends SetMemberOps[G] { this: SetMember[G] =>
+trait SetMemberImpl[G] extends SetMemberOps[G] {
+ this: SetMember[G] =>
override def t: Type[G] = TBool()
override def precedence: Int = Precedence.RELATIONAL
- override def layout(implicit ctx: Ctx): Doc = lassoc(x, if(ctx.syntax == Ctx.Silver) "in" else "\\in", xs)
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ lassoc(
+ x,
+ if (ctx.syntax == Ctx.Silver)
+ "in"
+ else
+ "\\in",
+ xs,
+ )
+}
diff --git a/src/col/vct/col/ast/expr/op/collection/SetMinusImpl.scala b/src/col/vct/col/ast/expr/op/collection/SetMinusImpl.scala
index 853b8b8246..6349523867 100644
--- a/src/col/vct/col/ast/expr/op/collection/SetMinusImpl.scala
+++ b/src/col/vct/col/ast/expr/op/collection/SetMinusImpl.scala
@@ -5,10 +5,13 @@ import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.typerules.Types
import vct.col.ast.ops.SetMinusOps
-trait SetMinusImpl[G] extends SetMinusOps[G] { this: SetMinus[G] =>
+trait SetMinusImpl[G] extends SetMinusOps[G] {
+ this: SetMinus[G] =>
def xsType: TSet[G] = xs.t.asSet.get
def ysType: TSet[G] = ys.t.asSet.get
- override lazy val t: TSet[G] = TSet(Types.leastCommonSuperType(xsType.element, ysType.element))
+ override lazy val t: TSet[G] = TSet(
+ Types.leastCommonSuperType(xsType.element, ysType.element)
+ )
override def precedence: Int = Precedence.ADDITIVE
override def layout(implicit ctx: Ctx): Doc = lassoc(xs, "-", ys)
diff --git a/src/col/vct/col/ast/expr/op/collection/SetUnionImpl.scala b/src/col/vct/col/ast/expr/op/collection/SetUnionImpl.scala
index 8ff0cc404f..3c044a752e 100644
--- a/src/col/vct/col/ast/expr/op/collection/SetUnionImpl.scala
+++ b/src/col/vct/col/ast/expr/op/collection/SetUnionImpl.scala
@@ -5,10 +5,13 @@ import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.typerules.Types
import vct.col.ast.ops.SetUnionOps
-trait SetUnionImpl[G] extends SetUnionOps[G] { this: SetUnion[G] =>
+trait SetUnionImpl[G] extends SetUnionOps[G] {
+ this: SetUnion[G] =>
def xsType: TSet[G] = xs.t.asSet.get
def ysType: TSet[G] = ys.t.asSet.get
- override lazy val t: TSet[G] = TSet(Types.leastCommonSuperType(xsType.element, ysType.element))
+ override lazy val t: TSet[G] = TSet(
+ Types.leastCommonSuperType(xsType.element, ysType.element)
+ )
override def precedence: Int = Precedence.ADDITIVE
override def layout(implicit ctx: Ctx): Doc = lassoc(xs, "+", ys)
diff --git a/src/col/vct/col/ast/expr/op/collection/SizeImpl.scala b/src/col/vct/col/ast/expr/op/collection/SizeImpl.scala
index fa472599e1..65ad15cd91 100644
--- a/src/col/vct/col/ast/expr/op/collection/SizeImpl.scala
+++ b/src/col/vct/col/ast/expr/op/collection/SizeImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{Size, TInt, Type}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.SizeOps
-trait SizeImpl[G] extends SizeOps[G] { this: Size[G] =>
+trait SizeImpl[G] extends SizeOps[G] {
+ this: Size[G] =>
override def t: Type[G] = TInt()
override def precedence: Int = Precedence.ATOMIC
override def layout(implicit ctx: Ctx): Doc = Text("|") <> obj <> "|"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/collection/SliceImpl.scala b/src/col/vct/col/ast/expr/op/collection/SliceImpl.scala
index f33aa6b3f9..3a8844062f 100644
--- a/src/col/vct/col/ast/expr/op/collection/SliceImpl.scala
+++ b/src/col/vct/col/ast/expr/op/collection/SliceImpl.scala
@@ -4,9 +4,11 @@ import vct.col.ast.{Slice, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.SliceOps
-trait SliceImpl[G] extends SliceOps[G] { this: Slice[G] =>
+trait SliceImpl[G] extends SliceOps[G] {
+ this: Slice[G] =>
override def t: Type[G] = xs.t
override def precedence: Int = Precedence.POSTFIX
- override def layout(implicit ctx: Ctx): Doc = assoc(xs) <> "[" <> from <> ".." <> to <> "]"
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ assoc(xs) <> "[" <> from <> ".." <> to <> "]"
+}
diff --git a/src/col/vct/col/ast/expr/op/collection/StringConcatImpl.scala b/src/col/vct/col/ast/expr/op/collection/StringConcatImpl.scala
index 7fd00b6627..0795312801 100644
--- a/src/col/vct/col/ast/expr/op/collection/StringConcatImpl.scala
+++ b/src/col/vct/col/ast/expr/op/collection/StringConcatImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{StringConcat, TString, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.StringConcatOps
-trait StringConcatImpl[G] extends StringConcatOps[G] { this: StringConcat[G] =>
+trait StringConcatImpl[G] extends StringConcatOps[G] {
+ this: StringConcat[G] =>
override def t: Type[G] = TString()
override def precedence: Int = Precedence.ADDITIVE
diff --git a/src/col/vct/col/ast/expr/op/collection/TailImpl.scala b/src/col/vct/col/ast/expr/op/collection/TailImpl.scala
index 82752c7969..f81d4f5578 100644
--- a/src/col/vct/col/ast/expr/op/collection/TailImpl.scala
+++ b/src/col/vct/col/ast/expr/op/collection/TailImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{Tail, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.TailOps
-trait TailImpl[G] extends TailOps[G] { this: Tail[G] =>
+trait TailImpl[G] extends TailOps[G] {
+ this: Tail[G] =>
override def t: Type[G] = xs.t
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc = assoc(xs) <> ".tail"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/collection/TakeImpl.scala b/src/col/vct/col/ast/expr/op/collection/TakeImpl.scala
index a2fc78c78f..b8088b8b40 100644
--- a/src/col/vct/col/ast/expr/op/collection/TakeImpl.scala
+++ b/src/col/vct/col/ast/expr/op/collection/TakeImpl.scala
@@ -4,9 +4,11 @@ import vct.col.ast.{Take, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.TakeOps
-trait TakeImpl[G] extends TakeOps[G] { this: Take[G] =>
+trait TakeImpl[G] extends TakeOps[G] {
+ this: Take[G] =>
override def t: Type[G] = xs.t
override def precedence: Int = Precedence.POSTFIX
- override def layout(implicit ctx: Ctx): Doc = assoc(xs) <> "[.." <> count <> "]"
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ assoc(xs) <> "[.." <> count <> "]"
+}
diff --git a/src/col/vct/col/ast/expr/op/collection/VectorSubscriptImpl.scala b/src/col/vct/col/ast/expr/op/collection/VectorSubscriptImpl.scala
index c63e387f4c..0bb03f9f91 100644
--- a/src/col/vct/col/ast/expr/op/collection/VectorSubscriptImpl.scala
+++ b/src/col/vct/col/ast/expr/op/collection/VectorSubscriptImpl.scala
@@ -4,9 +4,11 @@ import vct.col.ast.{VectorSubscript, Type}
import vct.col.print.{Ctx, Doc, Precedence, Group}
import vct.col.ast.ops.VectorSubscriptOps
-trait VectorSubscriptImpl[G] extends VectorSubscriptOps[G] { this: VectorSubscript[G] =>
+trait VectorSubscriptImpl[G] extends VectorSubscriptOps[G] {
+ this: VectorSubscript[G] =>
override def t: Type[G] = seq.t.asVector.get.element
override def precedence: Int = Precedence.POSTFIX
- override def layout(implicit ctx: Ctx): Doc = Group(assoc(seq) <> "[" <> Doc.arg(index) <> "]")
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ Group(assoc(seq) <> "[" <> Doc.arg(index) <> "]")
+}
diff --git a/src/col/vct/col/ast/expr/op/either/EitherOpImpl.scala b/src/col/vct/col/ast/expr/op/either/EitherOpImpl.scala
index a0f0b57e17..134bf71305 100644
--- a/src/col/vct/col/ast/expr/op/either/EitherOpImpl.scala
+++ b/src/col/vct/col/ast/expr/op/either/EitherOpImpl.scala
@@ -2,7 +2,8 @@ package vct.col.ast.expr.op.either
import vct.col.ast.{EitherOp, Expr, TEither}
-trait EitherOpImpl[G] { this: EitherOp[G] =>
+trait EitherOpImpl[G] {
+ this: EitherOp[G] =>
def either: Expr[G]
def eitherType: TEither[G] = either.t.asEither.get
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/either/GetLeftImpl.scala b/src/col/vct/col/ast/expr/op/either/GetLeftImpl.scala
index e303dfc1f0..896093da57 100644
--- a/src/col/vct/col/ast/expr/op/either/GetLeftImpl.scala
+++ b/src/col/vct/col/ast/expr/op/either/GetLeftImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{GetLeft, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.GetLeftOps
-trait GetLeftImpl[G] extends GetLeftOps[G] { this: GetLeft[G] =>
+trait GetLeftImpl[G] extends GetLeftOps[G] {
+ this: GetLeft[G] =>
override def t: Type[G] = eitherType.left
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc = assoc(either) <> ".left"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/either/GetRightImpl.scala b/src/col/vct/col/ast/expr/op/either/GetRightImpl.scala
index f1c4baa678..2d3a1d2794 100644
--- a/src/col/vct/col/ast/expr/op/either/GetRightImpl.scala
+++ b/src/col/vct/col/ast/expr/op/either/GetRightImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{GetRight, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.GetRightOps
-trait GetRightImpl[G] extends GetRightOps[G] { this: GetRight[G] =>
+trait GetRightImpl[G] extends GetRightOps[G] {
+ this: GetRight[G] =>
override def t: Type[G] = eitherType.right
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc = assoc(either) <> ".right"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/either/IsLeftImpl.scala b/src/col/vct/col/ast/expr/op/either/IsLeftImpl.scala
index 088a51c4e3..0d129d0cf9 100644
--- a/src/col/vct/col/ast/expr/op/either/IsLeftImpl.scala
+++ b/src/col/vct/col/ast/expr/op/either/IsLeftImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{IsLeft, TBool, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.IsLeftOps
-trait IsLeftImpl[G] extends IsLeftOps[G] { this: IsLeft[G] =>
+trait IsLeftImpl[G] extends IsLeftOps[G] {
+ this: IsLeft[G] =>
override def t: Type[G] = TBool()
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc = assoc(either) <> ".isLeft"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/either/IsRightImpl.scala b/src/col/vct/col/ast/expr/op/either/IsRightImpl.scala
index 6aff088eb1..9500b34684 100644
--- a/src/col/vct/col/ast/expr/op/either/IsRightImpl.scala
+++ b/src/col/vct/col/ast/expr/op/either/IsRightImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{IsRight, TBool, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.IsRightOps
-trait IsRightImpl[G] extends IsRightOps[G] { this: IsRight[G] =>
+trait IsRightImpl[G] extends IsRightOps[G] {
+ this: IsRight[G] =>
override def t: Type[G] = TBool()
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc = assoc(either) <> ".isRight"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/map/MapConsImpl.scala b/src/col/vct/col/ast/expr/op/map/MapConsImpl.scala
index a63d291c4c..8a0150af79 100644
--- a/src/col/vct/col/ast/expr/op/map/MapConsImpl.scala
+++ b/src/col/vct/col/ast/expr/op/map/MapConsImpl.scala
@@ -4,11 +4,12 @@ import vct.col.ast.{MapCons, TMap, Type}
import vct.col.print.{Ctx, Doc, Group, Precedence}
import vct.col.ast.ops.MapConsOps
-trait MapConsImpl[G] extends MapConsOps[G] { this: MapCons[G] =>
+trait MapConsImpl[G] extends MapConsOps[G] {
+ this: MapCons[G] =>
override def t: TMap[G] = tailType
def tailType: TMap[G] = map.t.asMap.get
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Group(assoc(map) <> ".add(" <> Doc.args(Seq(k, v)) <> ")")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/map/MapGetImpl.scala b/src/col/vct/col/ast/expr/op/map/MapGetImpl.scala
index d3ed230aa5..8c92d32959 100644
--- a/src/col/vct/col/ast/expr/op/map/MapGetImpl.scala
+++ b/src/col/vct/col/ast/expr/op/map/MapGetImpl.scala
@@ -4,10 +4,12 @@ import vct.col.ast.{MapGet, TMap, Type}
import vct.col.print.{Ctx, Doc, Group, Precedence}
import vct.col.ast.ops.MapGetOps
-trait MapGetImpl[G] extends MapGetOps[G] { this: MapGet[G] =>
+trait MapGetImpl[G] extends MapGetOps[G] {
+ this: MapGet[G] =>
def mapType: TMap[G] = map.t.asMap.get
override def t: Type[G] = mapType.value
override def precedence: Int = Precedence.POSTFIX
- override def layout(implicit ctx: Ctx): Doc = Group(assoc(map) <> "[" <> Doc.arg(k) <> "]")
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ Group(assoc(map) <> "[" <> Doc.arg(k) <> "]")
+}
diff --git a/src/col/vct/col/ast/expr/op/map/MapItemSetImpl.scala b/src/col/vct/col/ast/expr/op/map/MapItemSetImpl.scala
index 757356f5ba..cf4e434486 100644
--- a/src/col/vct/col/ast/expr/op/map/MapItemSetImpl.scala
+++ b/src/col/vct/col/ast/expr/op/map/MapItemSetImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{MapItemSet, TSet, TTuple, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.MapItemSetOps
-trait MapItemSetImpl[G] extends MapItemSetOps[G] { this: MapItemSet[G] =>
+trait MapItemSetImpl[G] extends MapItemSetOps[G] {
+ this: MapItemSet[G] =>
override def t: Type[G] = TSet(TTuple(Seq(mapType.key, mapType.value)))
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc = assoc(map) <> ".items"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/map/MapKeySetImpl.scala b/src/col/vct/col/ast/expr/op/map/MapKeySetImpl.scala
index 4b296e1171..78a3e78b45 100644
--- a/src/col/vct/col/ast/expr/op/map/MapKeySetImpl.scala
+++ b/src/col/vct/col/ast/expr/op/map/MapKeySetImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{MapKeySet, TSet, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.MapKeySetOps
-trait MapKeySetImpl[G] extends MapKeySetOps[G] { this: MapKeySet[G] =>
+trait MapKeySetImpl[G] extends MapKeySetOps[G] {
+ this: MapKeySet[G] =>
override def t: Type[G] = TSet(mapType.key)
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc = assoc(map) <> ".keys"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/map/MapMemberImpl.scala b/src/col/vct/col/ast/expr/op/map/MapMemberImpl.scala
index f499629328..02d256427b 100644
--- a/src/col/vct/col/ast/expr/op/map/MapMemberImpl.scala
+++ b/src/col/vct/col/ast/expr/op/map/MapMemberImpl.scala
@@ -4,9 +4,18 @@ import vct.col.ast.{MapMember, TBool, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.MapMemberOps
-trait MapMemberImpl[G] extends MapMemberOps[G] { this: MapMember[G] =>
+trait MapMemberImpl[G] extends MapMemberOps[G] {
+ this: MapMember[G] =>
override def t: Type[G] = TBool()
override def precedence: Int = Precedence.RELATIONAL
- override def layout(implicit ctx: Ctx): Doc = lassoc(x, if(ctx.syntax == Ctx.Silver) "in" else "\\in", xs)
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ lassoc(
+ x,
+ if (ctx.syntax == Ctx.Silver)
+ "in"
+ else
+ "\\in",
+ xs,
+ )
+}
diff --git a/src/col/vct/col/ast/expr/op/map/MapOpImpl.scala b/src/col/vct/col/ast/expr/op/map/MapOpImpl.scala
index 6d100edc32..f00a4a88aa 100644
--- a/src/col/vct/col/ast/expr/op/map/MapOpImpl.scala
+++ b/src/col/vct/col/ast/expr/op/map/MapOpImpl.scala
@@ -2,7 +2,8 @@ package vct.col.ast.expr.op.map
import vct.col.ast.{Expr, MapOp, TMap}
-trait MapOpImpl[G] { this: MapOp[G] =>
+trait MapOpImpl[G] {
+ this: MapOp[G] =>
def map: Expr[G]
def mapType: TMap[G] = map.t.asMap.get
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/map/MapRemoveImpl.scala b/src/col/vct/col/ast/expr/op/map/MapRemoveImpl.scala
index 55c1f74462..3e7283afb1 100644
--- a/src/col/vct/col/ast/expr/op/map/MapRemoveImpl.scala
+++ b/src/col/vct/col/ast/expr/op/map/MapRemoveImpl.scala
@@ -4,11 +4,12 @@ import vct.col.ast.{MapRemove, TMap, Type}
import vct.col.print.{Ctx, Doc, Precedence, Group}
import vct.col.ast.ops.MapRemoveOps
-trait MapRemoveImpl[G] extends MapRemoveOps[G] { this: MapRemove[G] =>
+trait MapRemoveImpl[G] extends MapRemoveOps[G] {
+ this: MapRemove[G] =>
def mapType: TMap[G] = map.t.asMap.get
override def t: Type[G] = mapType
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Group(assoc(map) <> ".remove(" <> Doc.arg(k) <> ")")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/map/MapValueSetImpl.scala b/src/col/vct/col/ast/expr/op/map/MapValueSetImpl.scala
index e819b23e62..9f72b99344 100644
--- a/src/col/vct/col/ast/expr/op/map/MapValueSetImpl.scala
+++ b/src/col/vct/col/ast/expr/op/map/MapValueSetImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{MapValueSet, TSet, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.MapValueSetOps
-trait MapValueSetImpl[G] extends MapValueSetOps[G] { this: MapValueSet[G] =>
+trait MapValueSetImpl[G] extends MapValueSetOps[G] {
+ this: MapValueSet[G] =>
override def t: Type[G] = TSet(mapType.value)
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc = assoc(map) <> ".values"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/num/AmbiguousDivImpl.scala b/src/col/vct/col/ast/expr/op/num/AmbiguousDivImpl.scala
index d0f1b1dc18..b4cdce748a 100644
--- a/src/col/vct/col/ast/expr/op/num/AmbiguousDivImpl.scala
+++ b/src/col/vct/col/ast/expr/op/num/AmbiguousDivImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.AmbiguousDiv
import vct.col.ast.ops.AmbiguousDivOps
import vct.col.print._
-trait AmbiguousDivImpl[G] extends AmbiguousDivOps[G] { this: AmbiguousDiv[G] =>
+trait AmbiguousDivImpl[G] extends AmbiguousDivOps[G] {
+ this: AmbiguousDiv[G] =>
override def precedence: Int = Precedence.MULTIPLICATIVE
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "/", right)
}
diff --git a/src/col/vct/col/ast/expr/op/num/AmbiguousDividingExprImpl.scala b/src/col/vct/col/ast/expr/op/num/AmbiguousDividingExprImpl.scala
index 4e796221b5..f8b9ec60b5 100644
--- a/src/col/vct/col/ast/expr/op/num/AmbiguousDividingExprImpl.scala
+++ b/src/col/vct/col/ast/expr/op/num/AmbiguousDividingExprImpl.scala
@@ -4,8 +4,11 @@ import vct.col.ast.expr.op.BinOperatorTypes
import vct.col.ast.{AmbiguousDividingExpr, Type}
import vct.col.typerules.Types
-trait AmbiguousDividingExprImpl[G] { this: AmbiguousDividingExpr[G] =>
+trait AmbiguousDividingExprImpl[G] {
+ this: AmbiguousDividingExpr[G] =>
def t: Type[G] =
- if (isVectorOp) Types.leastCommonSuperType(left.t, right.t)
- else BinOperatorTypes.getNumericType(left.t, right.t, o)
+ if (isVectorOp)
+ Types.leastCommonSuperType(left.t, right.t)
+ else
+ BinOperatorTypes.getNumericType(left.t, right.t, o)
}
diff --git a/src/col/vct/col/ast/expr/op/num/AmbiguousModImpl.scala b/src/col/vct/col/ast/expr/op/num/AmbiguousModImpl.scala
index 43e7a245a1..129b0f0f0a 100644
--- a/src/col/vct/col/ast/expr/op/num/AmbiguousModImpl.scala
+++ b/src/col/vct/col/ast/expr/op/num/AmbiguousModImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.AmbiguousMod
import vct.col.ast.ops.AmbiguousModOps
import vct.col.print._
-trait AmbiguousModImpl[G] extends AmbiguousModOps[G] { this: AmbiguousMod[G] =>
+trait AmbiguousModImpl[G] extends AmbiguousModOps[G] {
+ this: AmbiguousMod[G] =>
override def precedence: Int = Precedence.MULTIPLICATIVE
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "%", right)
}
diff --git a/src/col/vct/col/ast/expr/op/num/AmbiguousTruncDivImpl.scala b/src/col/vct/col/ast/expr/op/num/AmbiguousTruncDivImpl.scala
index 4907216c39..a6de68454d 100644
--- a/src/col/vct/col/ast/expr/op/num/AmbiguousTruncDivImpl.scala
+++ b/src/col/vct/col/ast/expr/op/num/AmbiguousTruncDivImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.AmbiguousTruncDiv
import vct.col.ast.ops.AmbiguousTruncDivOps
import vct.col.print._
-trait AmbiguousTruncDivImpl[G] extends AmbiguousTruncDivOps[G] { this: AmbiguousTruncDiv[G] =>
+trait AmbiguousTruncDivImpl[G] extends AmbiguousTruncDivOps[G] {
+ this: AmbiguousTruncDiv[G] =>
override def precedence: Int = Precedence.MULTIPLICATIVE
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "/", right)
}
diff --git a/src/col/vct/col/ast/expr/op/num/CastFloatImpl.scala b/src/col/vct/col/ast/expr/op/num/CastFloatImpl.scala
index d189b0efbb..129960653a 100644
--- a/src/col/vct/col/ast/expr/op/num/CastFloatImpl.scala
+++ b/src/col/vct/col/ast/expr/op/num/CastFloatImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{CastFloat}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.CastFloatOps
-trait CastFloatImpl[G] extends CastFloatOps[G] { this: CastFloat[G] =>
+trait CastFloatImpl[G] extends CastFloatOps[G] {
+ this: CastFloat[G] =>
override def precedence: Int = Precedence.PREFIX
override def layout(implicit ctx: Ctx): Doc =
Text("(") <> t <> ")" <> assoc(e)
diff --git a/src/col/vct/col/ast/expr/op/num/DividingExprImpl.scala b/src/col/vct/col/ast/expr/op/num/DividingExprImpl.scala
index 4b0b63db83..2cb922de03 100644
--- a/src/col/vct/col/ast/expr/op/num/DividingExprImpl.scala
+++ b/src/col/vct/col/ast/expr/op/num/DividingExprImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.expr.op.num
import vct.col.ast.DividingExpr
import vct.col.origin.{Blame, DivByZero}
-trait DividingExprImpl[G] { this: DividingExpr[G] =>
+trait DividingExprImpl[G] {
+ this: DividingExpr[G] =>
def blame: Blame[DivByZero]
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/num/ExpImpl.scala b/src/col/vct/col/ast/expr/op/num/ExpImpl.scala
index e6be99b254..f1ba8816ba 100644
--- a/src/col/vct/col/ast/expr/op/num/ExpImpl.scala
+++ b/src/col/vct/col/ast/expr/op/num/ExpImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.Exp
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.ExpOps
-trait ExpImpl[G] extends ExpOps[G] { this: Exp[G] =>
+trait ExpImpl[G] extends ExpOps[G] {
+ this: Exp[G] =>
override def precedence: Int = Precedence.PVL_POW
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "^^", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/num/FloatDivImpl.scala b/src/col/vct/col/ast/expr/op/num/FloatDivImpl.scala
index 17b3b8d292..d654189807 100644
--- a/src/col/vct/col/ast/expr/op/num/FloatDivImpl.scala
+++ b/src/col/vct/col/ast/expr/op/num/FloatDivImpl.scala
@@ -5,9 +5,10 @@ import vct.col.ast.{FloatDiv, TInt, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.FloatDivOps
-trait FloatDivImpl[G] extends FloatDivOps[G] { this: FloatDiv[G] =>
+trait FloatDivImpl[G] extends FloatDivOps[G] {
+ this: FloatDiv[G] =>
override def t: Type[G] = TFloats.getFloatMax(left.t, right.t).get
override def precedence: Int = Precedence.MULTIPLICATIVE
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "/", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/num/FloorDivImpl.scala b/src/col/vct/col/ast/expr/op/num/FloorDivImpl.scala
index 31ccaddda1..f7366993af 100644
--- a/src/col/vct/col/ast/expr/op/num/FloorDivImpl.scala
+++ b/src/col/vct/col/ast/expr/op/num/FloorDivImpl.scala
@@ -4,8 +4,9 @@ import vct.col.ast.{FloorDiv, TInt, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.FloorDivOps
-trait FloorDivImpl[G] extends FloorDivOps[G] { this: FloorDiv[G] =>
+trait FloorDivImpl[G] extends FloorDivOps[G] {
+ this: FloorDiv[G] =>
override def t: Type[G] = TInt()
override def precedence: Int = Precedence.MULTIPLICATIVE
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "/", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/num/MinusImpl.scala b/src/col/vct/col/ast/expr/op/num/MinusImpl.scala
index b302369d17..45673d7563 100644
--- a/src/col/vct/col/ast/expr/op/num/MinusImpl.scala
+++ b/src/col/vct/col/ast/expr/op/num/MinusImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.Minus
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.MinusOps
-trait MinusImpl[G] extends MinusOps[G] { this: Minus[G] =>
+trait MinusImpl[G] extends MinusOps[G] {
+ this: Minus[G] =>
override def precedence: Int = Precedence.ADDITIVE
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "-", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/num/ModImpl.scala b/src/col/vct/col/ast/expr/op/num/ModImpl.scala
index e195d8537c..37a1d773ac 100644
--- a/src/col/vct/col/ast/expr/op/num/ModImpl.scala
+++ b/src/col/vct/col/ast/expr/op/num/ModImpl.scala
@@ -4,8 +4,9 @@ import vct.col.ast.{Mod, TInt, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.ModOps
-trait ModImpl[G] extends ModOps[G] { this: Mod[G] =>
+trait ModImpl[G] extends ModOps[G] {
+ this: Mod[G] =>
override def t: Type[G] = TInt()
override def precedence: Int = Precedence.MULTIPLICATIVE
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "%", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/num/MultImpl.scala b/src/col/vct/col/ast/expr/op/num/MultImpl.scala
index 283a60bdb2..2ef0088645 100644
--- a/src/col/vct/col/ast/expr/op/num/MultImpl.scala
+++ b/src/col/vct/col/ast/expr/op/num/MultImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.Mult
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.MultOps
-trait MultImpl[G] extends MultOps[G] { this: Mult[G] =>
+trait MultImpl[G] extends MultOps[G] {
+ this: Mult[G] =>
override def precedence: Int = Precedence.MULTIPLICATIVE
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "*", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/num/NumericBinExprImpl.scala b/src/col/vct/col/ast/expr/op/num/NumericBinExprImpl.scala
index 53a288dd0d..90104452b3 100644
--- a/src/col/vct/col/ast/expr/op/num/NumericBinExprImpl.scala
+++ b/src/col/vct/col/ast/expr/op/num/NumericBinExprImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.expr.op.num
import vct.col.ast.{NumericBinExpr, TInt, TRational, Type}
import vct.col.typerules.CoercionUtils
-trait NumericBinExprImpl[G] { this: NumericBinExpr[G] =>
+trait NumericBinExprImpl[G] {
+ this: NumericBinExpr[G] =>
lazy val t: Type[G] = getNumericType
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/num/PlusImpl.scala b/src/col/vct/col/ast/expr/op/num/PlusImpl.scala
index d0c47b49bf..18dc7fef72 100644
--- a/src/col/vct/col/ast/expr/op/num/PlusImpl.scala
+++ b/src/col/vct/col/ast/expr/op/num/PlusImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.Plus
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.PlusOps
-trait PlusImpl[G] extends PlusOps[G] { this: Plus[G] =>
+trait PlusImpl[G] extends PlusOps[G] {
+ this: Plus[G] =>
override def precedence: Int = Precedence.ADDITIVE
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "+", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/num/RatDivImpl.scala b/src/col/vct/col/ast/expr/op/num/RatDivImpl.scala
index 8f5aabcbdf..65f5786529 100644
--- a/src/col/vct/col/ast/expr/op/num/RatDivImpl.scala
+++ b/src/col/vct/col/ast/expr/op/num/RatDivImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{RatDiv, TRational, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.RatDivOps
-trait RatDivImpl[G] extends RatDivOps[G] { this: RatDiv[G] =>
+trait RatDivImpl[G] extends RatDivOps[G] {
+ this: RatDiv[G] =>
override def t: Type[G] = TRational()
override def precedence: Int = Precedence.MULTIPLICATIVE
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "\\", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/num/TruncDivImpl.scala b/src/col/vct/col/ast/expr/op/num/TruncDivImpl.scala
index 47b9bb9135..7a32431387 100644
--- a/src/col/vct/col/ast/expr/op/num/TruncDivImpl.scala
+++ b/src/col/vct/col/ast/expr/op/num/TruncDivImpl.scala
@@ -4,8 +4,9 @@ import vct.col.ast.{TInt, TruncDiv, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.TruncDivOps
-trait TruncDivImpl[G] extends TruncDivOps[G] { this: TruncDiv[G] =>
+trait TruncDivImpl[G] extends TruncDivOps[G] {
+ this: TruncDiv[G] =>
override def t: Type[G] = TInt()
override def precedence: Int = Precedence.MULTIPLICATIVE
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "/", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/num/TruncModImpl.scala b/src/col/vct/col/ast/expr/op/num/TruncModImpl.scala
index 54e320c48b..71bced78fc 100644
--- a/src/col/vct/col/ast/expr/op/num/TruncModImpl.scala
+++ b/src/col/vct/col/ast/expr/op/num/TruncModImpl.scala
@@ -4,8 +4,9 @@ import vct.col.ast.{TInt, TruncMod, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.TruncModOps
-trait TruncModImpl[G] extends TruncModOps[G] { this: TruncMod[G] =>
+trait TruncModImpl[G] extends TruncModOps[G] {
+ this: TruncMod[G] =>
override def t: Type[G] = TInt()
override def precedence: Int = Precedence.MULTIPLICATIVE
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "%", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/num/UMinusImpl.scala b/src/col/vct/col/ast/expr/op/num/UMinusImpl.scala
index 6de5dd71ec..f3a44e3c11 100644
--- a/src/col/vct/col/ast/expr/op/num/UMinusImpl.scala
+++ b/src/col/vct/col/ast/expr/op/num/UMinusImpl.scala
@@ -1,16 +1,28 @@
package vct.col.ast.expr.op.num
-import vct.col.ast.{CoerceCIntInt, CoerceFloatRat, CoerceUnboundInt, TBoundedInt, TCInt, TInt, TRational, Type, UMinus}
+import vct.col.ast.{
+ CoerceCIntInt,
+ CoerceFloatRat,
+ CoerceUnboundInt,
+ TBoundedInt,
+ TCInt,
+ TInt,
+ TRational,
+ Type,
+ UMinus,
+}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.typerules.CoercionUtils
import vct.col.ast.ops.UMinusOps
-trait UMinusImpl[G] extends UMinusOps[G] { this: UMinus[G] =>
+trait UMinusImpl[G] extends UMinusOps[G] {
+ this: UMinus[G] =>
override def t: Type[G] = {
CoercionUtils.getCoercion(arg.t, TInt())
.orElse(CoercionUtils.getCoercion(arg.t, TRational())) match {
case Some(CoerceCIntInt()) => TCInt()
- case Some(CoerceUnboundInt(TBoundedInt(gte, lt), _)) => TBoundedInt(-lt + 1, -gte + 1)
+ case Some(CoerceUnboundInt(TBoundedInt(gte, lt), _)) =>
+ TBoundedInt(-lt + 1, -gte + 1)
case Some(CoerceFloatRat(source)) => source
case Some(_) => TInt()
case _ => TRational()
@@ -19,4 +31,4 @@ trait UMinusImpl[G] extends UMinusOps[G] { this: UMinus[G] =>
override def precedence: Int = Precedence.PREFIX
override def layout(implicit ctx: Ctx): Doc = Text("-") <> assoc(arg)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/num/VectorBinExprImpl.scala b/src/col/vct/col/ast/expr/op/num/VectorBinExprImpl.scala
index 2d7dad74c3..a7bbb5e8f1 100644
--- a/src/col/vct/col/ast/expr/op/num/VectorBinExprImpl.scala
+++ b/src/col/vct/col/ast/expr/op/num/VectorBinExprImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.expr.op.num
import vct.col.ast.expr.op.BinOperatorTypes
import vct.col.ast.{TVector, Type, VectorBinExpr}
-trait VectorBinExprImpl[G] { this: VectorBinExpr[G] =>
+trait VectorBinExprImpl[G] {
+ this: VectorBinExpr[G] =>
override def t: Type[G] = getVectorType
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/num/VectorFloatDivImpl.scala b/src/col/vct/col/ast/expr/op/num/VectorFloatDivImpl.scala
index afb9db33d5..93abd18703 100644
--- a/src/col/vct/col/ast/expr/op/num/VectorFloatDivImpl.scala
+++ b/src/col/vct/col/ast/expr/op/num/VectorFloatDivImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.VectorFloatDiv
import vct.col.ast.ops.VectorFloatDivOps
import vct.col.print._
-trait VectorFloatDivImpl[G] extends VectorFloatDivOps[G] { this: VectorFloatDiv[G] =>
+trait VectorFloatDivImpl[G] extends VectorFloatDivOps[G] {
+ this: VectorFloatDiv[G] =>
override def precedence: Int = Precedence.MULTIPLICATIVE
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "/", right)
}
diff --git a/src/col/vct/col/ast/expr/op/num/VectorFloorDivImpl.scala b/src/col/vct/col/ast/expr/op/num/VectorFloorDivImpl.scala
index ac56b1577b..4f323e858c 100644
--- a/src/col/vct/col/ast/expr/op/num/VectorFloorDivImpl.scala
+++ b/src/col/vct/col/ast/expr/op/num/VectorFloorDivImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.VectorFloorDiv
import vct.col.ast.ops.VectorFloorDivOps
import vct.col.print._
-trait VectorFloorDivImpl[G] extends VectorFloorDivOps[G] { this: VectorFloorDiv[G] =>
+trait VectorFloorDivImpl[G] extends VectorFloorDivOps[G] {
+ this: VectorFloorDiv[G] =>
override def precedence: Int = Precedence.MULTIPLICATIVE
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "/", right)
}
diff --git a/src/col/vct/col/ast/expr/op/num/VectorMinusImpl.scala b/src/col/vct/col/ast/expr/op/num/VectorMinusImpl.scala
index c2fcceb5fc..08d5435340 100644
--- a/src/col/vct/col/ast/expr/op/num/VectorMinusImpl.scala
+++ b/src/col/vct/col/ast/expr/op/num/VectorMinusImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.VectorMinus
import vct.col.ast.ops.VectorMinusOps
import vct.col.print.{Ctx, Doc, Precedence}
-trait VectorMinusImpl[G] extends VectorMinusOps[G] { this: VectorMinus[G] =>
+trait VectorMinusImpl[G] extends VectorMinusOps[G] {
+ this: VectorMinus[G] =>
override def precedence: Int = Precedence.ADDITIVE
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "-", right)
}
diff --git a/src/col/vct/col/ast/expr/op/num/VectorModImpl.scala b/src/col/vct/col/ast/expr/op/num/VectorModImpl.scala
index 322aee45ca..0a2efd456e 100644
--- a/src/col/vct/col/ast/expr/op/num/VectorModImpl.scala
+++ b/src/col/vct/col/ast/expr/op/num/VectorModImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.VectorMod
import vct.col.ast.ops.VectorModOps
import vct.col.print._
-trait VectorModImpl[G] extends VectorModOps[G] { this: VectorMod[G] =>
+trait VectorModImpl[G] extends VectorModOps[G] {
+ this: VectorMod[G] =>
override def precedence: Int = Precedence.MULTIPLICATIVE
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "%", right)
}
diff --git a/src/col/vct/col/ast/expr/op/num/VectorMultImpl.scala b/src/col/vct/col/ast/expr/op/num/VectorMultImpl.scala
index a331f4ffd7..40d934c1bb 100644
--- a/src/col/vct/col/ast/expr/op/num/VectorMultImpl.scala
+++ b/src/col/vct/col/ast/expr/op/num/VectorMultImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.VectorMult
import vct.col.ast.ops.VectorMultOps
import vct.col.print.{Ctx, Doc, Precedence}
-trait VectorMultImpl[G] extends VectorMultOps[G] { this: VectorMult[G] =>
+trait VectorMultImpl[G] extends VectorMultOps[G] {
+ this: VectorMult[G] =>
override def precedence: Int = Precedence.MULTIPLICATIVE
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "*", right)
}
diff --git a/src/col/vct/col/ast/expr/op/num/VectorPlusImpl.scala b/src/col/vct/col/ast/expr/op/num/VectorPlusImpl.scala
index 67cf38e1a7..da268cf8fc 100644
--- a/src/col/vct/col/ast/expr/op/num/VectorPlusImpl.scala
+++ b/src/col/vct/col/ast/expr/op/num/VectorPlusImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.VectorPlus
import vct.col.ast.ops.VectorPlusOps
import vct.col.print._
-trait VectorPlusImpl[G] extends VectorPlusOps[G] { this: VectorPlus[G] =>
+trait VectorPlusImpl[G] extends VectorPlusOps[G] {
+ this: VectorPlus[G] =>
override def precedence: Int = Precedence.ADDITIVE
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "+", right)
}
diff --git a/src/col/vct/col/ast/expr/op/num/VectorTruncDivImpl.scala b/src/col/vct/col/ast/expr/op/num/VectorTruncDivImpl.scala
index 4240773aba..612517b748 100644
--- a/src/col/vct/col/ast/expr/op/num/VectorTruncDivImpl.scala
+++ b/src/col/vct/col/ast/expr/op/num/VectorTruncDivImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.VectorTruncDiv
import vct.col.ast.ops.VectorTruncDivOps
import vct.col.print._
-trait VectorTruncDivImpl[G] extends VectorTruncDivOps[G] { this: VectorTruncDiv[G] =>
+trait VectorTruncDivImpl[G] extends VectorTruncDivOps[G] {
+ this: VectorTruncDiv[G] =>
override def precedence: Int = Precedence.MULTIPLICATIVE
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "/", right)
}
diff --git a/src/col/vct/col/ast/expr/op/num/VectorTruncModImpl.scala b/src/col/vct/col/ast/expr/op/num/VectorTruncModImpl.scala
index c8cf62d315..29c7f25555 100644
--- a/src/col/vct/col/ast/expr/op/num/VectorTruncModImpl.scala
+++ b/src/col/vct/col/ast/expr/op/num/VectorTruncModImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.VectorTruncMod
import vct.col.ast.ops.VectorTruncModOps
import vct.col.print._
-trait VectorTruncModImpl[G] extends VectorTruncModOps[G] { this: VectorTruncMod[G] =>
+trait VectorTruncModImpl[G] extends VectorTruncModOps[G] {
+ this: VectorTruncMod[G] =>
override def precedence: Int = Precedence.MULTIPLICATIVE
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "%", right)
}
diff --git a/src/col/vct/col/ast/expr/op/option/OptEmptyImpl.scala b/src/col/vct/col/ast/expr/op/option/OptEmptyImpl.scala
index dee799cf01..3c9a843be5 100644
--- a/src/col/vct/col/ast/expr/op/option/OptEmptyImpl.scala
+++ b/src/col/vct/col/ast/expr/op/option/OptEmptyImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{OptEmpty, TBool, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.OptEmptyOps
-trait OptEmptyImpl[G] extends OptEmptyOps[G] { this: OptEmpty[G] =>
+trait OptEmptyImpl[G] extends OptEmptyOps[G] {
+ this: OptEmpty[G] =>
override def t: Type[G] = TBool()
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc = assoc(opt) <> ".isEmpty"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/option/OptGetImpl.scala b/src/col/vct/col/ast/expr/op/option/OptGetImpl.scala
index 826a9fdcff..05f43b2d40 100644
--- a/src/col/vct/col/ast/expr/op/option/OptGetImpl.scala
+++ b/src/col/vct/col/ast/expr/op/option/OptGetImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{OptGet, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.OptGetOps
-trait OptGetImpl[G] extends OptGetOps[G] { this: OptGet[G] =>
+trait OptGetImpl[G] extends OptGetOps[G] {
+ this: OptGet[G] =>
override def t: Type[G] = opt.t.asOption.get.element
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc = assoc(opt) <> ".get"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/option/OptGetOrElseImpl.scala b/src/col/vct/col/ast/expr/op/option/OptGetOrElseImpl.scala
index e8c5a5c277..9005cfc7a2 100644
--- a/src/col/vct/col/ast/expr/op/option/OptGetOrElseImpl.scala
+++ b/src/col/vct/col/ast/expr/op/option/OptGetOrElseImpl.scala
@@ -5,10 +5,13 @@ import vct.col.print.{Ctx, Doc, Precedence, Group}
import vct.col.typerules.Types
import vct.col.ast.ops.OptGetOrElseOps
-trait OptGetOrElseImpl[G] extends OptGetOrElseOps[G] { this: OptGetOrElse[G] =>
+trait OptGetOrElseImpl[G] extends OptGetOrElseOps[G] {
+ this: OptGetOrElse[G] =>
def optionType: TOption[G] = opt.t.asOption.get
- override lazy val t: Type[G] = Types.leastCommonSuperType(optionType.element, alt.t)
+ override lazy val t: Type[G] = Types
+ .leastCommonSuperType(optionType.element, alt.t)
override def precedence: Int = Precedence.POSTFIX
- override def layout(implicit ctx: Ctx): Doc = Group(assoc(opt) <> ".getOrElse(" <> Doc.arg(alt) <> ")")
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ Group(assoc(opt) <> ".getOrElse(" <> Doc.arg(alt) <> ")")
+}
diff --git a/src/col/vct/col/ast/expr/op/process/ProcessChoiceImpl.scala b/src/col/vct/col/ast/expr/op/process/ProcessChoiceImpl.scala
index 80ba86dbb2..8f866d3b9d 100644
--- a/src/col/vct/col/ast/expr/op/process/ProcessChoiceImpl.scala
+++ b/src/col/vct/col/ast/expr/op/process/ProcessChoiceImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{ProcessChoice, TProcess, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.ProcessChoiceOps
-trait ProcessChoiceImpl[G] extends ProcessChoiceOps[G] { this: ProcessChoice[G] =>
+trait ProcessChoiceImpl[G] extends ProcessChoiceOps[G] {
+ this: ProcessChoice[G] =>
override def t: Type[G] = TProcess()
override def precedence: Int = Precedence.ADDITIVE
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "+", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/process/ProcessParImpl.scala b/src/col/vct/col/ast/expr/op/process/ProcessParImpl.scala
index 6bb467779b..c3345bd85b 100644
--- a/src/col/vct/col/ast/expr/op/process/ProcessParImpl.scala
+++ b/src/col/vct/col/ast/expr/op/process/ProcessParImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{ProcessPar, TProcess, Type}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.ProcessParOps
-trait ProcessParImpl[G] extends ProcessParOps[G] { this: ProcessPar[G] =>
+trait ProcessParImpl[G] extends ProcessParOps[G] {
+ this: ProcessPar[G] =>
override def t: Type[G] = TProcess()
override def precedence: Int = Precedence.OR
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "||", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/process/ProcessSelectImpl.scala b/src/col/vct/col/ast/expr/op/process/ProcessSelectImpl.scala
index c0dbc4f9e2..1aed06c9bc 100644
--- a/src/col/vct/col/ast/expr/op/process/ProcessSelectImpl.scala
+++ b/src/col/vct/col/ast/expr/op/process/ProcessSelectImpl.scala
@@ -4,10 +4,13 @@ import vct.col.ast.{ProcessSelect, TProcess, Type}
import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.ast.ops.ProcessSelectOps
-trait ProcessSelectImpl[G] extends ProcessSelectOps[G] { this: ProcessSelect[G] =>
+trait ProcessSelectImpl[G] extends ProcessSelectOps[G] {
+ this: ProcessSelect[G] =>
override def t: Type[G] = TProcess()
override def precedence: Int = Precedence.SELECT
override def layout(implicit ctx: Ctx): Doc =
- Group(nassoc(cond) <>> {Text("?") <+> nassoc(whenTrue)} <>> {Text(":") <+> assoc(whenFalse)})
-}
\ No newline at end of file
+ Group(nassoc(cond) <>> { Text("?") <+> nassoc(whenTrue) } <>> {
+ Text(":") <+> assoc(whenFalse)
+ })
+}
diff --git a/src/col/vct/col/ast/expr/op/process/ProcessSeqImpl.scala b/src/col/vct/col/ast/expr/op/process/ProcessSeqImpl.scala
index 7772c4d825..222c7b4ac9 100644
--- a/src/col/vct/col/ast/expr/op/process/ProcessSeqImpl.scala
+++ b/src/col/vct/col/ast/expr/op/process/ProcessSeqImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{ProcessSeq, TProcess, Type}
import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.ast.ops.ProcessSeqOps
-trait ProcessSeqImpl[G] extends ProcessSeqOps[G] { this: ProcessSeq[G] =>
+trait ProcessSeqImpl[G] extends ProcessSeqOps[G] {
+ this: ProcessSeq[G] =>
override def t: Type[G] = TProcess()
override def precedence: Int = Precedence.MULTIPLICATIVE
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "*", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/tuple/TupGetImpl.scala b/src/col/vct/col/ast/expr/op/tuple/TupGetImpl.scala
index 70222ab345..d66a46a76b 100644
--- a/src/col/vct/col/ast/expr/op/tuple/TupGetImpl.scala
+++ b/src/col/vct/col/ast/expr/op/tuple/TupGetImpl.scala
@@ -7,19 +7,28 @@ import vct.col.check.{CheckContext, CheckError}
import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.ast.ops.TupGetOps
-trait TupGetImpl[G] extends ExprImpl[G] with TupGetOps[G] { this: TupGet[G] =>
+trait TupGetImpl[G] extends ExprImpl[G] with TupGetOps[G] {
+ this: TupGet[G] =>
def tupleType: TTuple[G] = tup.t.asTuple.get
override def t: Type[G] = tupleType.elements(index)
override def check(context: CheckContext[G]): Seq[CheckError] =
super.check(context) match {
- case Nil => if(0 <= index && index < tupleType.elements.size) Nil else Seq(col.check.TypeErrorExplanation(this, "Tuple getter exceeds tuple size"))
+ case Nil =>
+ if (0 <= index && index < tupleType.elements.size)
+ Nil
+ else
+ Seq(
+ col.check
+ .TypeErrorExplanation(this, "Tuple getter exceeds tuple size")
+ )
case some => some
}
override def precedence: Int = Precedence.POSTFIX
- override def layout(implicit ctx: Ctx): Doc = index match {
- case 0 => assoc(tup) <> ".fst"
- case 1 => assoc(tup) <> ".snd"
- case other => assoc(tup) <> "." <> other.toString
- }
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ index match {
+ case 0 => assoc(tup) <> ".fst"
+ case 1 => assoc(tup) <> ".snd"
+ case other => assoc(tup) <> "." <> other.toString
+ }
+}
diff --git a/src/col/vct/col/ast/expr/op/vec/MatrixCompareImpl.scala b/src/col/vct/col/ast/expr/op/vec/MatrixCompareImpl.scala
index 5aefdfc4c7..d6b1e32d2c 100644
--- a/src/col/vct/col/ast/expr/op/vec/MatrixCompareImpl.scala
+++ b/src/col/vct/col/ast/expr/op/vec/MatrixCompareImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.expr.op.vec
import vct.col.ast.{MatrixCompare, TInt, TMatrix, Type}
import vct.col.ast.ops.MatrixCompareOps
-trait MatrixCompareImpl[G] extends MatrixCompareOps[G] { this: MatrixCompare[G] =>
+trait MatrixCompareImpl[G] extends MatrixCompareOps[G] {
+ this: MatrixCompare[G] =>
override def t: Type[G] = TMatrix(TInt())
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/vec/MatrixRepeatImpl.scala b/src/col/vct/col/ast/expr/op/vec/MatrixRepeatImpl.scala
index 5e4deeb816..7946536a35 100644
--- a/src/col/vct/col/ast/expr/op/vec/MatrixRepeatImpl.scala
+++ b/src/col/vct/col/ast/expr/op/vec/MatrixRepeatImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.expr.op.vec
import vct.col.ast.{MatrixRepeat, TMatrix, Type}
import vct.col.ast.ops.MatrixRepeatOps
-trait MatrixRepeatImpl[G] extends MatrixRepeatOps[G] { this: MatrixRepeat[G] =>
+trait MatrixRepeatImpl[G] extends MatrixRepeatOps[G] {
+ this: MatrixRepeat[G] =>
override def t: Type[G] = TMatrix(e.t)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/vec/MatrixSumImpl.scala b/src/col/vct/col/ast/expr/op/vec/MatrixSumImpl.scala
index 94a5e3841d..3cdd7b0451 100644
--- a/src/col/vct/col/ast/expr/op/vec/MatrixSumImpl.scala
+++ b/src/col/vct/col/ast/expr/op/vec/MatrixSumImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.expr.op.vec
import vct.col.ast.{MatrixSum, Type}
import vct.col.ast.ops.MatrixSumOps
-trait MatrixSumImpl[G] extends MatrixSumOps[G] { this: MatrixSum[G] =>
+trait MatrixSumImpl[G] extends MatrixSumOps[G] {
+ this: MatrixSum[G] =>
override def t: Type[G] = mat.t.asMatrix.get.element
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/vec/VectorCompareImpl.scala b/src/col/vct/col/ast/expr/op/vec/VectorCompareImpl.scala
index 3808ac820d..3cb95173f6 100644
--- a/src/col/vct/col/ast/expr/op/vec/VectorCompareImpl.scala
+++ b/src/col/vct/col/ast/expr/op/vec/VectorCompareImpl.scala
@@ -3,6 +3,8 @@ package vct.col.ast.expr.op.vec
import vct.col.ast.{TInt, TSeq, Type, VectorCompare}
import vct.col.ast.ops.VectorCompareOps
-trait VectorCompareImpl[G] extends VectorCompareOps[G] { this: VectorCompare[G] =>
- override def t: Type[G] = TSeq(TInt()) // the results are 0 or 1, mimicking TSeq(TBool())
-}
\ No newline at end of file
+trait VectorCompareImpl[G] extends VectorCompareOps[G] {
+ this: VectorCompare[G] =>
+ override def t: Type[G] =
+ TSeq(TInt()) // the results are 0 or 1, mimicking TSeq(TBool())
+}
diff --git a/src/col/vct/col/ast/expr/op/vec/VectorRepeatImpl.scala b/src/col/vct/col/ast/expr/op/vec/VectorRepeatImpl.scala
index a04df96c81..b954f85099 100644
--- a/src/col/vct/col/ast/expr/op/vec/VectorRepeatImpl.scala
+++ b/src/col/vct/col/ast/expr/op/vec/VectorRepeatImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.expr.op.vec
import vct.col.ast.{TSeq, Type, VectorRepeat}
import vct.col.ast.ops.VectorRepeatOps
-trait VectorRepeatImpl[G] extends VectorRepeatOps[G] { this: VectorRepeat[G] =>
+trait VectorRepeatImpl[G] extends VectorRepeatOps[G] {
+ this: VectorRepeat[G] =>
override def t: Type[G] = TSeq(e.t)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/op/vec/VectorSumImpl.scala b/src/col/vct/col/ast/expr/op/vec/VectorSumImpl.scala
index 7caba5c1c2..c9d5b022aa 100644
--- a/src/col/vct/col/ast/expr/op/vec/VectorSumImpl.scala
+++ b/src/col/vct/col/ast/expr/op/vec/VectorSumImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.expr.op.vec
import vct.col.ast.{Type, VectorSum}
import vct.col.ast.ops.VectorSumOps
-trait VectorSumImpl[G] extends VectorSumOps[G] { this: VectorSum[G] =>
+trait VectorSumImpl[G] extends VectorSumOps[G] {
+ this: VectorSum[G] =>
override def t: Type[G] = vec.t.asSeq.get.element
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/resource/ActionPermImpl.scala b/src/col/vct/col/ast/expr/resource/ActionPermImpl.scala
index 694ab14cfe..812c7135d9 100644
--- a/src/col/vct/col/ast/expr/resource/ActionPermImpl.scala
+++ b/src/col/vct/col/ast/expr/resource/ActionPermImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{ActionPerm, TResource, Type}
import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.ast.ops.ActionPermOps
-trait ActionPermImpl[G] extends ActionPermOps[G] { this: ActionPerm[G] =>
+trait ActionPermImpl[G] extends ActionPermOps[G] {
+ this: ActionPerm[G] =>
override def t: Type[G] = TResource()
override def precedence: Int = Precedence.POSTFIX
diff --git a/src/col/vct/col/ast/expr/resource/CurPermImpl.scala b/src/col/vct/col/ast/expr/resource/CurPermImpl.scala
index 8182cec1ba..9cfcbda1c1 100644
--- a/src/col/vct/col/ast/expr/resource/CurPermImpl.scala
+++ b/src/col/vct/col/ast/expr/resource/CurPermImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{CurPerm, TRational, Type}
import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.ast.ops.CurPermOps
-trait CurPermImpl[G] extends CurPermOps[G] { this: CurPerm[G] =>
+trait CurPermImpl[G] extends CurPermOps[G] {
+ this: CurPerm[G] =>
override def t: Type[G] = TRational()
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Group(Text("perm(") <> Doc.arg(loc) <> ")")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/resource/ImpliesImpl.scala b/src/col/vct/col/ast/expr/resource/ImpliesImpl.scala
index 35532bc114..e400eca5da 100644
--- a/src/col/vct/col/ast/expr/resource/ImpliesImpl.scala
+++ b/src/col/vct/col/ast/expr/resource/ImpliesImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{Implies, Type}
import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.ast.ops.ImpliesOps
-trait ImpliesImpl[G] extends ImpliesOps[G] { this: Implies[G] =>
+trait ImpliesImpl[G] extends ImpliesOps[G] {
+ this: Implies[G] =>
override def t: Type[G] = right.t
override def precedence: Int = Precedence.IMPLIES
override def layout(implicit ctx: Ctx): Doc = rassoc(left, "==>", right)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/resource/ModelPermImpl.scala b/src/col/vct/col/ast/expr/resource/ModelPermImpl.scala
index 924a57216c..3add62bf15 100644
--- a/src/col/vct/col/ast/expr/resource/ModelPermImpl.scala
+++ b/src/col/vct/col/ast/expr/resource/ModelPermImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{ModelPerm, TResource, Type}
import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.ast.ops.ModelPermOps
-trait ModelPermImpl[G] extends ModelPermOps[G] { this: ModelPerm[G] =>
+trait ModelPermImpl[G] extends ModelPermOps[G] {
+ this: ModelPerm[G] =>
override def t: Type[G] = TResource()
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Group(Text("HPerm(") <> Doc.args(Seq(loc, perm)) <> ")")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/resource/PermImpl.scala b/src/col/vct/col/ast/expr/resource/PermImpl.scala
index 53f4c7de66..13ff250499 100644
--- a/src/col/vct/col/ast/expr/resource/PermImpl.scala
+++ b/src/col/vct/col/ast/expr/resource/PermImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{Perm, TResource, Type}
import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.ast.ops.PermOps
-trait PermImpl[G] extends PermOps[G] { this: Perm[G] =>
+trait PermImpl[G] extends PermOps[G] {
+ this: Perm[G] =>
override def t: Type[G] = TResource()
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Group(Text("Perm(") <> Doc.args(Seq(loc, perm)) <> ")")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/resource/PermPointerImpl.scala b/src/col/vct/col/ast/expr/resource/PermPointerImpl.scala
index 25ac78f5f0..dbf6cfc853 100644
--- a/src/col/vct/col/ast/expr/resource/PermPointerImpl.scala
+++ b/src/col/vct/col/ast/expr/resource/PermPointerImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{PermPointer, TResource, Type}
import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.ast.ops.PermPointerOps
-trait PermPointerImpl[G] extends PermPointerOps[G] { this: PermPointer[G] =>
+trait PermPointerImpl[G] extends PermPointerOps[G] {
+ this: PermPointer[G] =>
override def t: Type[G] = TResource()
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Group(Text("\\pointer(") <> Doc.args(Seq(p, len, perm)) <> ")")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/resource/PermPointerIndexImpl.scala b/src/col/vct/col/ast/expr/resource/PermPointerIndexImpl.scala
index cf317d022a..6864571c28 100644
--- a/src/col/vct/col/ast/expr/resource/PermPointerIndexImpl.scala
+++ b/src/col/vct/col/ast/expr/resource/PermPointerIndexImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{PermPointerIndex, TResource, Type}
import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.ast.ops.PermPointerIndexOps
-trait PermPointerIndexImpl[G] extends PermPointerIndexOps[G] { this: PermPointerIndex[G] =>
+trait PermPointerIndexImpl[G] extends PermPointerIndexOps[G] {
+ this: PermPointerIndex[G] =>
override def t: Type[G] = TResource()
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Group(Text("\\pointer_index(") <> Doc.args(Seq(p, idx, perm)) <> ")")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/resource/PointsToImpl.scala b/src/col/vct/col/ast/expr/resource/PointsToImpl.scala
index 762aa55cdf..4e2ce7c1f2 100644
--- a/src/col/vct/col/ast/expr/resource/PointsToImpl.scala
+++ b/src/col/vct/col/ast/expr/resource/PointsToImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{PointsTo, TResource, Type}
import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.ast.ops.PointsToOps
-trait PointsToImpl[G] extends PointsToOps[G] { this: PointsTo[G] =>
+trait PointsToImpl[G] extends PointsToOps[G] {
+ this: PointsTo[G] =>
override def t: Type[G] = TResource()
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Group(Text("PointsTo(") <> Doc.args(Seq(loc, perm, value)) <> ")")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/resource/PolarityDependentImpl.scala b/src/col/vct/col/ast/expr/resource/PolarityDependentImpl.scala
index fab4e9b5a5..8147bc2a6f 100644
--- a/src/col/vct/col/ast/expr/resource/PolarityDependentImpl.scala
+++ b/src/col/vct/col/ast/expr/resource/PolarityDependentImpl.scala
@@ -5,10 +5,14 @@ import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.typerules.Types
import vct.col.ast.ops.PolarityDependentOps
-trait PolarityDependentImpl[G] extends PolarityDependentOps[G] { this: PolarityDependent[G] =>
- override lazy val t: Type[G] = Types.leastCommonSuperType(onInhale.t, onExhale.t)
+trait PolarityDependentImpl[G] extends PolarityDependentOps[G] {
+ this: PolarityDependent[G] =>
+ override lazy val t: Type[G] = Types
+ .leastCommonSuperType(onInhale.t, onExhale.t)
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
- Group(Text("\\polarity_dependent(") <> Doc.args(Seq(onInhale, onExhale)) <> ")")
+ Group(
+ Text("\\polarity_dependent(") <> Doc.args(Seq(onInhale, onExhale)) <> ")"
+ )
}
diff --git a/src/col/vct/col/ast/expr/resource/ResourceOfResourceValueImpl.scala b/src/col/vct/col/ast/expr/resource/ResourceOfResourceValueImpl.scala
index e1a27c4b86..3db3246b8d 100644
--- a/src/col/vct/col/ast/expr/resource/ResourceOfResourceValueImpl.scala
+++ b/src/col/vct/col/ast/expr/resource/ResourceOfResourceValueImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.expr.resource
import vct.col.ast.{ResourceOfResourceValue, TResource}
import vct.col.ast.ops.ResourceOfResourceValueOps
-trait ResourceOfResourceValueImpl[G] extends ResourceOfResourceValueOps[G] { this: ResourceOfResourceValue[G] =>
+trait ResourceOfResourceValueImpl[G] extends ResourceOfResourceValueOps[G] {
+ this: ResourceOfResourceValue[G] =>
override def t: TResource[G] = TResource()
}
diff --git a/src/col/vct/col/ast/expr/resource/ResourceValueImpl.scala b/src/col/vct/col/ast/expr/resource/ResourceValueImpl.scala
index badb7a16e1..c7a15529c7 100644
--- a/src/col/vct/col/ast/expr/resource/ResourceValueImpl.scala
+++ b/src/col/vct/col/ast/expr/resource/ResourceValueImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.expr.resource
import vct.col.ast.{ResourceValue, TResourceVal}
import vct.col.ast.ops.ResourceValueOps
-trait ResourceValueImpl[G] extends ResourceValueOps[G] { this: ResourceValue[G] =>
+trait ResourceValueImpl[G] extends ResourceValueOps[G] {
+ this: ResourceValue[G] =>
override def t: TResourceVal[G] = TResourceVal()
}
diff --git a/src/col/vct/col/ast/expr/resource/ScaleByParBlockImpl.scala b/src/col/vct/col/ast/expr/resource/ScaleByParBlockImpl.scala
index 50d0362e4f..8a94bff1d7 100644
--- a/src/col/vct/col/ast/expr/resource/ScaleByParBlockImpl.scala
+++ b/src/col/vct/col/ast/expr/resource/ScaleByParBlockImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.expr.resource
import vct.col.ast.{ScaleByParBlock, Type}
import vct.col.ast.ops.ScaleByParBlockOps
-trait ScaleByParBlockImpl[G] extends ScaleByParBlockOps[G] { this: ScaleByParBlock[G] =>
+trait ScaleByParBlockImpl[G] extends ScaleByParBlockOps[G] {
+ this: ScaleByParBlock[G] =>
override def t: Type[G] = res.t
}
diff --git a/src/col/vct/col/ast/expr/resource/ScaleImpl.scala b/src/col/vct/col/ast/expr/resource/ScaleImpl.scala
index fc83b3db62..e475d2ebcb 100644
--- a/src/col/vct/col/ast/expr/resource/ScaleImpl.scala
+++ b/src/col/vct/col/ast/expr/resource/ScaleImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{Scale, TResource, Type}
import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.ast.ops.ScaleOps
-trait ScaleImpl[G] extends ScaleOps[G] { this: Scale[G] =>
+trait ScaleImpl[G] extends ScaleOps[G] {
+ this: Scale[G] =>
override def t: Type[G] = TResource()
override def precedence: Int = Precedence.PREFIX
override def layout(implicit ctx: Ctx): Doc =
Text("[") <> scale <> "]" <> assoc(res)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/resource/StarImpl.scala b/src/col/vct/col/ast/expr/resource/StarImpl.scala
index ff6362c210..7193cbac2c 100644
--- a/src/col/vct/col/ast/expr/resource/StarImpl.scala
+++ b/src/col/vct/col/ast/expr/resource/StarImpl.scala
@@ -4,9 +4,18 @@ import vct.col.ast.{Star, TResource, Type}
import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.ast.ops.StarOps
-trait StarImpl[G] extends StarOps[G] { this: Star[G] =>
+trait StarImpl[G] extends StarOps[G] {
+ this: Star[G] =>
override def t: Type[G] = TResource()
override def precedence: Int = Precedence.AND
- override def layout(implicit ctx: Ctx): Doc = lassoc(left, if(ctx.syntax == Ctx.Silver) "&&" else "**", right)
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ lassoc(
+ left,
+ if (ctx.syntax == Ctx.Silver)
+ "&&"
+ else
+ "**",
+ right,
+ )
+}
diff --git a/src/col/vct/col/ast/expr/resource/UnfoldingImpl.scala b/src/col/vct/col/ast/expr/resource/UnfoldingImpl.scala
index eb729b3aed..2f03c33691 100644
--- a/src/col/vct/col/ast/expr/resource/UnfoldingImpl.scala
+++ b/src/col/vct/col/ast/expr/resource/UnfoldingImpl.scala
@@ -6,7 +6,11 @@ import vct.col.ast.{Type, Unfolding}
import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.ast.ops.UnfoldingOps
-trait UnfoldingImpl[G] extends NodeFamilyImpl[G] with CheckFoldUnfoldTarget[G] with UnfoldingOps[G] { this: Unfolding[G] =>
+trait UnfoldingImpl[G]
+ extends NodeFamilyImpl[G]
+ with CheckFoldUnfoldTarget[G]
+ with UnfoldingOps[G] {
+ this: Unfolding[G] =>
override def t: Type[G] = body.t
def layoutPVL(implicit ctx: Ctx): Doc =
@@ -22,10 +26,11 @@ trait UnfoldingImpl[G] extends NodeFamilyImpl[G] with CheckFoldUnfoldTarget[G] w
Group(Text("\\unfolding") <+> assoc(res) <+> "\\in" <>> body)
override def precedence: Int = Precedence.PVL_UNFOLDING
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.PVL => layoutPVL
- case Ctx.Silver => layoutSilver
- case Ctx.Java => layoutJava
- case _ => layoutSpec
- }
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.PVL => layoutPVL
+ case Ctx.Silver => layoutSilver
+ case Ctx.Java => layoutJava
+ case _ => layoutSpec
+ }
+}
diff --git a/src/col/vct/col/ast/expr/resource/ValidArrayImpl.scala b/src/col/vct/col/ast/expr/resource/ValidArrayImpl.scala
index 4a6149a4a1..daf623c4d0 100644
--- a/src/col/vct/col/ast/expr/resource/ValidArrayImpl.scala
+++ b/src/col/vct/col/ast/expr/resource/ValidArrayImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{TBool, Type, ValidArray}
import vct.col.print._
import vct.col.ast.ops.ValidArrayOps
-trait ValidArrayImpl[G] extends ValidArrayOps[G] { this: ValidArray[G] =>
+trait ValidArrayImpl[G] extends ValidArrayOps[G] {
+ this: ValidArray[G] =>
override def t: Type[G] = TBool()
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Group(Text("\\array(") <> Doc.args(Seq(arr, len)) <> ")")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/resource/ValidMatrixImpl.scala b/src/col/vct/col/ast/expr/resource/ValidMatrixImpl.scala
index 7c25f9f21a..fb2317197c 100644
--- a/src/col/vct/col/ast/expr/resource/ValidMatrixImpl.scala
+++ b/src/col/vct/col/ast/expr/resource/ValidMatrixImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{TBool, Type, ValidMatrix}
import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.ast.ops.ValidMatrixOps
-trait ValidMatrixImpl[G] extends ValidMatrixOps[G] { this: ValidMatrix[G] =>
+trait ValidMatrixImpl[G] extends ValidMatrixOps[G] {
+ this: ValidMatrix[G] =>
override def t: Type[G] = TBool()
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Group(Text("\\matrix(") <> Doc.args(Seq(mat, w, h)) <> ")")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/resource/ValueImpl.scala b/src/col/vct/col/ast/expr/resource/ValueImpl.scala
index 42d5a80c78..356b93a728 100644
--- a/src/col/vct/col/ast/expr/resource/ValueImpl.scala
+++ b/src/col/vct/col/ast/expr/resource/ValueImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{TResource, Type, Value}
import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.ast.ops.ValueOps
-trait ValueImpl[G] extends ValueOps[G] { this: Value[G] =>
+trait ValueImpl[G] extends ValueOps[G] {
+ this: Value[G] =>
override def t: Type[G] = TResource()
override def precedence: Int = Precedence.POSTFIX
diff --git a/src/col/vct/col/ast/expr/resource/WandImpl.scala b/src/col/vct/col/ast/expr/resource/WandImpl.scala
index a4a3f6745b..8a85c21d84 100644
--- a/src/col/vct/col/ast/expr/resource/WandImpl.scala
+++ b/src/col/vct/col/ast/expr/resource/WandImpl.scala
@@ -4,9 +4,18 @@ import vct.col.ast.{TResource, Type, Wand}
import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.ast.ops.WandOps
-trait WandImpl[G] extends WandOps[G] { this: Wand[G] =>
+trait WandImpl[G] extends WandOps[G] {
+ this: Wand[G] =>
override def t: Type[G] = TResource()
override def precedence: Int = Precedence.IMPLIES
- override def layout(implicit ctx: Ctx): Doc = rassoc(left, if(ctx.syntax == Ctx.Silver) "--*" else "-*", right)
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ rassoc(
+ left,
+ if (ctx.syntax == Ctx.Silver)
+ "--*"
+ else
+ "-*",
+ right,
+ )
+}
diff --git a/src/col/vct/col/ast/expr/sideeffect/AssignExpressionImpl.scala b/src/col/vct/col/ast/expr/sideeffect/AssignExpressionImpl.scala
index ff699287ff..635ea75b7a 100644
--- a/src/col/vct/col/ast/expr/sideeffect/AssignExpressionImpl.scala
+++ b/src/col/vct/col/ast/expr/sideeffect/AssignExpressionImpl.scala
@@ -4,13 +4,16 @@ import vct.col.ast.expr.ExprImpl
import vct.col.ast.{AssignExpression, Expr, Local}
import vct.col.check.{CheckContext, CheckError}
-trait AssignExpressionImpl[G] extends ExprImpl[G] { this: AssignExpression[G] =>
+trait AssignExpressionImpl[G] extends ExprImpl[G] {
+ this: AssignExpression[G] =>
def target: Expr[G]
def value: Expr[G]
override def check(context: CheckContext[G]): Seq[CheckError] =
- super.check(context) ++ (target match {
- case Local(ref) => context.checkInWriteScope(context.roScopeReason, this, ref)
- case _ => Nil
- })
-}
\ No newline at end of file
+ super.check(context) ++
+ (target match {
+ case Local(ref) =>
+ context.checkInWriteScope(context.roScopeReason, this, ref)
+ case _ => Nil
+ })
+}
diff --git a/src/col/vct/col/ast/expr/sideeffect/PostAssignExpressionImpl.scala b/src/col/vct/col/ast/expr/sideeffect/PostAssignExpressionImpl.scala
index 8e26792d1a..c4fb48a18e 100644
--- a/src/col/vct/col/ast/expr/sideeffect/PostAssignExpressionImpl.scala
+++ b/src/col/vct/col/ast/expr/sideeffect/PostAssignExpressionImpl.scala
@@ -4,10 +4,17 @@ import vct.col.ast.{PostAssignExpression, Type}
import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.ast.ops.PostAssignExpressionOps
-trait PostAssignExpressionImpl[G] extends PostAssignExpressionOps[G] { this: PostAssignExpression[G] =>
+trait PostAssignExpressionImpl[G] extends PostAssignExpressionOps[G] {
+ this: PostAssignExpression[G] =>
override def t: Type[G] = target.t
override def precedence: Int = Precedence.ASSIGN
override def layout(implicit ctx: Ctx): Doc =
- Group(nassoc(target) <+> (if(ctx.syntax == Ctx.Silver) ":=" else "=") <>> assoc(value))
-}
\ No newline at end of file
+ Group(
+ nassoc(target) <+>
+ (if (ctx.syntax == Ctx.Silver)
+ ":="
+ else
+ "=") <>> assoc(value)
+ )
+}
diff --git a/src/col/vct/col/ast/expr/sideeffect/PreAssignExpressionImpl.scala b/src/col/vct/col/ast/expr/sideeffect/PreAssignExpressionImpl.scala
index 7ede8a5ce2..0854de60c6 100644
--- a/src/col/vct/col/ast/expr/sideeffect/PreAssignExpressionImpl.scala
+++ b/src/col/vct/col/ast/expr/sideeffect/PreAssignExpressionImpl.scala
@@ -4,10 +4,17 @@ import vct.col.ast.{PreAssignExpression, Type}
import vct.col.print.{Ctx, Doc, Group, Precedence}
import vct.col.ast.ops.PreAssignExpressionOps
-trait PreAssignExpressionImpl[G] extends PreAssignExpressionOps[G] { this: PreAssignExpression[G] =>
+trait PreAssignExpressionImpl[G] extends PreAssignExpressionOps[G] {
+ this: PreAssignExpression[G] =>
override def t: Type[G] = value.t
override def precedence: Int = Precedence.ASSIGN
override def layout(implicit ctx: Ctx): Doc =
- Group(nassoc(target) <+> (if(ctx.syntax == Ctx.Silver) ":=" else "=") <>> assoc(value))
-}
\ No newline at end of file
+ Group(
+ nassoc(target) <+>
+ (if (ctx.syntax == Ctx.Silver)
+ ":="
+ else
+ "=") <>> assoc(value)
+ )
+}
diff --git a/src/col/vct/col/ast/expr/sideeffect/ScopedExprImpl.scala b/src/col/vct/col/ast/expr/sideeffect/ScopedExprImpl.scala
index 3b72410555..0b891ad529 100644
--- a/src/col/vct/col/ast/expr/sideeffect/ScopedExprImpl.scala
+++ b/src/col/vct/col/ast/expr/sideeffect/ScopedExprImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.expr.sideeffect
import vct.col.ast.{ScopedExpr, Type}
import vct.col.ast.ops.ScopedExprOps
-trait ScopedExprImpl[G] extends ScopedExprOps[G] { this: ScopedExpr[G] =>
+trait ScopedExprImpl[G] extends ScopedExprOps[G] {
+ this: ScopedExpr[G] =>
override def t: Type[G] = body.t
}
diff --git a/src/col/vct/col/ast/expr/sideeffect/ThenImpl.scala b/src/col/vct/col/ast/expr/sideeffect/ThenImpl.scala
index e1e2aab4fa..69e2c3a807 100644
--- a/src/col/vct/col/ast/expr/sideeffect/ThenImpl.scala
+++ b/src/col/vct/col/ast/expr/sideeffect/ThenImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{Then, Type}
import vct.col.print.{Ctx, Doc, Group, Precedence, Show, Text}
import vct.col.ast.ops.ThenOps
-trait ThenImpl[G] extends ThenOps[G] { this: Then[G] =>
+trait ThenImpl[G] extends ThenOps[G] {
+ this: Then[G] =>
override def t: Type[G] = value.t
def layoutEffect(implicit ctx: Ctx): Doc =
@@ -13,4 +14,4 @@ trait ThenImpl[G] extends ThenOps[G] { this: Then[G] =>
override def precedence: Int = Precedence.PVL_WITH_THEN
override def layout(implicit ctx: Ctx): Doc =
Group(assoc(value) <>> Doc.inlineSpec(Show.lazily(layoutEffect(_))))
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/sideeffect/WithImpl.scala b/src/col/vct/col/ast/expr/sideeffect/WithImpl.scala
index 2f51d00e82..7768b92503 100644
--- a/src/col/vct/col/ast/expr/sideeffect/WithImpl.scala
+++ b/src/col/vct/col/ast/expr/sideeffect/WithImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{Type, With}
import vct.col.print.{Ctx, Doc, Group, Precedence, Show, Text}
import vct.col.ast.ops.WithOps
-trait WithImpl[G] extends WithOps[G] { this: With[G] =>
+trait WithImpl[G] extends WithOps[G] {
+ this: With[G] =>
override def t: Type[G] = value.t
def layoutEffect(implicit ctx: Ctx): Doc =
@@ -13,4 +14,4 @@ trait WithImpl[G] extends WithOps[G] { this: With[G] =>
override def precedence: Int = Precedence.PVL_WITH_THEN
override def layout(implicit ctx: Ctx): Doc =
Group(assoc(value) <>> Doc.inlineSpec(Show.lazily(layoutEffect(_))))
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/type/CastImpl.scala b/src/col/vct/col/ast/expr/type/CastImpl.scala
index 69d9cf5c5e..2a151bb951 100644
--- a/src/col/vct/col/ast/expr/type/CastImpl.scala
+++ b/src/col/vct/col/ast/expr/type/CastImpl.scala
@@ -5,13 +5,16 @@ import vct.col.check.UnreachableAfterTypeCheck
import vct.col.print.{Ctx, Doc, Group, Precedence, Show, Text}
import vct.col.ast.ops.CastOps
-trait CastImpl[G] extends CastOps[G] { this: Cast[G] =>
- override def t: Type[G] = typeValue.t match {
- case TType(t) => t
- case _ => throw UnreachableAfterTypeCheck("The cast type is not a type", this)
- }
+trait CastImpl[G] extends CastOps[G] {
+ this: Cast[G] =>
+ override def t: Type[G] =
+ typeValue.t match {
+ case TType(t) => t
+ case _ =>
+ throw UnreachableAfterTypeCheck("The cast type is not a type", this)
+ }
override def precedence: Int = Precedence.PREFIX
override def layout(implicit ctx: Ctx): Doc =
Text("(") <> typeValue <> ")" <> assoc(value)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/type/InstanceOfImpl.scala b/src/col/vct/col/ast/expr/type/InstanceOfImpl.scala
index 0adf092b79..d9bb3740e3 100644
--- a/src/col/vct/col/ast/expr/type/InstanceOfImpl.scala
+++ b/src/col/vct/col/ast/expr/type/InstanceOfImpl.scala
@@ -4,9 +4,11 @@ import vct.col.ast.{InstanceOf, TBool, Type}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.InstanceOfOps
-trait InstanceOfImpl[G] extends InstanceOfOps[G] { this: InstanceOf[G] =>
+trait InstanceOfImpl[G] extends InstanceOfOps[G] {
+ this: InstanceOf[G] =>
override def t: Type[G] = TBool()
override def precedence: Int = Precedence.RELATIONAL
- override def layout(implicit ctx: Ctx): Doc = assoc(value) <+> "instanceof" <+> typeValue
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ assoc(value) <+> "instanceof" <+> typeValue
+}
diff --git a/src/col/vct/col/ast/expr/type/SubTypeImpl.scala b/src/col/vct/col/ast/expr/type/SubTypeImpl.scala
index 9d59541ece..15c623cf64 100644
--- a/src/col/vct/col/ast/expr/type/SubTypeImpl.scala
+++ b/src/col/vct/col/ast/expr/type/SubTypeImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.expr.`type`
import vct.col.ast.SubType
import vct.col.ast.ops.SubTypeOps
-trait SubTypeImpl[G] extends SubTypeOps[G] { this: SubType[G] =>
+trait SubTypeImpl[G] extends SubTypeOps[G] {
+ this: SubType[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/type/SuperTypeImpl.scala b/src/col/vct/col/ast/expr/type/SuperTypeImpl.scala
index cef660506a..650b9adb08 100644
--- a/src/col/vct/col/ast/expr/type/SuperTypeImpl.scala
+++ b/src/col/vct/col/ast/expr/type/SuperTypeImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.expr.`type`
import vct.col.ast.SuperType
import vct.col.ast.ops.SuperTypeOps
-trait SuperTypeImpl[G] extends SuperTypeOps[G] { this: SuperType[G] =>
+trait SuperTypeImpl[G] extends SuperTypeOps[G] {
+ this: SuperType[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/type/TypeComparisonImpl.scala b/src/col/vct/col/ast/expr/type/TypeComparisonImpl.scala
index cb4b51f967..0d43a8a75c 100644
--- a/src/col/vct/col/ast/expr/type/TypeComparisonImpl.scala
+++ b/src/col/vct/col/ast/expr/type/TypeComparisonImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.expr.`type`
import vct.col.ast.TypeComparison
-trait TypeComparisonImpl[G] { this: TypeComparison[G] =>
+trait TypeComparisonImpl[G] {
+ this: TypeComparison[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/type/TypeOfImpl.scala b/src/col/vct/col/ast/expr/type/TypeOfImpl.scala
index d964471faf..6569eb8416 100644
--- a/src/col/vct/col/ast/expr/type/TypeOfImpl.scala
+++ b/src/col/vct/col/ast/expr/type/TypeOfImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{TType, Type, TypeOf}
import vct.col.print.{Ctx, Doc, Precedence, Text, Group}
import vct.col.ast.ops.TypeOfOps
-trait TypeOfImpl[G] extends TypeOfOps[G] { this: TypeOf[G] =>
+trait TypeOfImpl[G] extends TypeOfOps[G] {
+ this: TypeOf[G] =>
override def t: Type[G] = TType(expr.t)
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Group(Text("\\typeof(") <> Doc.arg(expr) <> ")")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/expr/type/TypeValueImpl.scala b/src/col/vct/col/ast/expr/type/TypeValueImpl.scala
index a439303117..f2e64529c3 100644
--- a/src/col/vct/col/ast/expr/type/TypeValueImpl.scala
+++ b/src/col/vct/col/ast/expr/type/TypeValueImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{TType, Type, TypeValue}
import vct.col.print.{Ctx, Doc, Group, Precedence, Text}
import vct.col.ast.ops.TypeValueOps
-trait TypeValueImpl[G] extends TypeValueOps[G] { this: TypeValue[G] =>
+trait TypeValueImpl[G] extends TypeValueOps[G] {
+ this: TypeValue[G] =>
override def t: Type[G] = TType(value)
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Group(Text("\\type(") <> Doc.arg(value) <> ")")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/family/accountedpredicate/AccountedPredicateImpl.scala b/src/col/vct/col/ast/family/accountedpredicate/AccountedPredicateImpl.scala
index 6dab0c779c..b02900fb16 100644
--- a/src/col/vct/col/ast/family/accountedpredicate/AccountedPredicateImpl.scala
+++ b/src/col/vct/col/ast/family/accountedpredicate/AccountedPredicateImpl.scala
@@ -3,13 +3,16 @@ package vct.col.ast.family.accountedpredicate
import vct.col.ast.AccountedPredicate
import vct.col.ast.ops.AccountedPredicateFamilyOps
-/**
- * A tree of assertions that represents the separating conjunction of the flattened tree. Either the tree splits
- * ([[vct.col.ast.SplitAccountedPredicate]]) or it is a leaf ([[vct.col.ast.UnitAccountedPredicate]]) consisting of one
- * expression. If verification of the predicate as a whole fails, additionally a path is returned that indicates the
- * position in the tree that failed via a path. See also [[vct.col.origin.AccountedDirection]],
- * [[vct.col.origin.PostBlameSplit]], [[vct.col.origin.PreBlameSplit]].
- */
-trait AccountedPredicateImpl[G] extends AccountedPredicateFamilyOps[G] { this: AccountedPredicate[G] =>
+/** A tree of assertions that represents the separating conjunction of the
+ * flattened tree. Either the tree splits
+ * ([[vct.col.ast.SplitAccountedPredicate]]) or it is a leaf
+ * ([[vct.col.ast.UnitAccountedPredicate]]) consisting of one expression. If
+ * verification of the predicate as a whole fails, additionally a path is
+ * returned that indicates the position in the tree that failed via a path. See
+ * also [[vct.col.origin.AccountedDirection]],
+ * [[vct.col.origin.PostBlameSplit]], [[vct.col.origin.PreBlameSplit]].
+ */
+trait AccountedPredicateImpl[G] extends AccountedPredicateFamilyOps[G] {
+ this: AccountedPredicate[G] =>
}
diff --git a/src/col/vct/col/ast/family/accountedpredicate/SplitAccountedPredicateImpl.scala b/src/col/vct/col/ast/family/accountedpredicate/SplitAccountedPredicateImpl.scala
index 931bc8528a..a15aa6609a 100644
--- a/src/col/vct/col/ast/family/accountedpredicate/SplitAccountedPredicateImpl.scala
+++ b/src/col/vct/col/ast/family/accountedpredicate/SplitAccountedPredicateImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.accountedpredicate
import vct.col.ast.SplitAccountedPredicate
import vct.col.ast.ops.SplitAccountedPredicateOps
-trait SplitAccountedPredicateImpl[G] extends SplitAccountedPredicateOps[G] { this: SplitAccountedPredicate[G] =>
+trait SplitAccountedPredicateImpl[G] extends SplitAccountedPredicateOps[G] {
+ this: SplitAccountedPredicate[G] =>
}
diff --git a/src/col/vct/col/ast/family/accountedpredicate/UnitAccountedPredicateImpl.scala b/src/col/vct/col/ast/family/accountedpredicate/UnitAccountedPredicateImpl.scala
index ce4a9ac50c..4560cfa7d1 100644
--- a/src/col/vct/col/ast/family/accountedpredicate/UnitAccountedPredicateImpl.scala
+++ b/src/col/vct/col/ast/family/accountedpredicate/UnitAccountedPredicateImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.ops.UnitAccountedPredicateOps
import vct.col.check._
import vct.col.typerules.{CoercionUtils}
-trait UnitAccountedPredicateImpl[G] extends UnitAccountedPredicateOps[G] { this: UnitAccountedPredicate[G] =>
+trait UnitAccountedPredicateImpl[G] extends UnitAccountedPredicateOps[G] {
+ this: UnitAccountedPredicate[G] =>
override def check(context: CheckContext[G]): Seq[CheckError] =
CoercionUtils.getCoercion(pred.t, TResource()) match {
case Some(_) => Nil
diff --git a/src/col/vct/col/ast/family/bipdata/BipIncomingDataImpl.scala b/src/col/vct/col/ast/family/bipdata/BipIncomingDataImpl.scala
index 1364efddcb..92b3e7ce56 100644
--- a/src/col/vct/col/ast/family/bipdata/BipIncomingDataImpl.scala
+++ b/src/col/vct/col/ast/family/bipdata/BipIncomingDataImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.BipIncomingData
import vct.col.print._
import vct.col.ast.ops.BipIncomingDataOps
-trait BipIncomingDataImpl[G] extends BipIncomingDataOps[G] { this: BipIncomingData[G] =>
+trait BipIncomingDataImpl[G] extends BipIncomingDataOps[G] {
+ this: BipIncomingData[G] =>
override def layout(implicit ctx: Ctx): Doc =
Text("/* bipIncomingData") <+> t <+> ctx.name(this) <+> "*/"
}
diff --git a/src/col/vct/col/ast/family/bipdata/BipOutgoingDataImpl.scala b/src/col/vct/col/ast/family/bipdata/BipOutgoingDataImpl.scala
index 6b2d1d362e..092da55f21 100644
--- a/src/col/vct/col/ast/family/bipdata/BipOutgoingDataImpl.scala
+++ b/src/col/vct/col/ast/family/bipdata/BipOutgoingDataImpl.scala
@@ -4,10 +4,14 @@ import vct.col.ast.BipOutgoingData
import vct.col.print._
import vct.col.ast.ops.BipOutgoingDataOps
-trait BipOutgoingDataImpl[G] extends BipOutgoingDataOps[G] { this: BipOutgoingData[G] =>
+trait BipOutgoingDataImpl[G] extends BipOutgoingDataOps[G] {
+ this: BipOutgoingData[G] =>
override def layout(implicit ctx: Ctx): Doc =
Doc.stack(Seq(
- if(pure) Text("@Pure") else Empty,
+ if (pure)
+ Text("@Pure")
+ else
+ Empty,
Text("@Data(name =") <+> ctx.name(this) <> ")",
Text("public") <+> t <+> ctx.name(this) <> "()" <+> body.layoutAsBlock,
))
diff --git a/src/col/vct/col/ast/family/bipglueelement/JavaBipGlueAcceptsImpl.scala b/src/col/vct/col/ast/family/bipglueelement/JavaBipGlueAcceptsImpl.scala
index 95decd28aa..05bfaeee77 100644
--- a/src/col/vct/col/ast/family/bipglueelement/JavaBipGlueAcceptsImpl.scala
+++ b/src/col/vct/col/ast/family/bipglueelement/JavaBipGlueAcceptsImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.JavaBipGlueAccepts
import vct.col.print._
import vct.col.ast.ops.JavaBipGlueAcceptsOps
-trait JavaBipGlueAcceptsImpl[G] extends JavaBipGlueAcceptsOps[G] { this: JavaBipGlueAccepts[G] =>
- override def layout(implicit ctx: Ctx): Doc =
- Group(port.show <> ".accepts(" <> Doc.args(others) <> ");")
+trait JavaBipGlueAcceptsImpl[G] extends JavaBipGlueAcceptsOps[G] {
+ this: JavaBipGlueAccepts[G] =>
+ override def layout(implicit ctx: Ctx): Doc =
+ Group(port.show <> ".accepts(" <> Doc.args(others) <> ");")
}
diff --git a/src/col/vct/col/ast/family/bipglueelement/JavaBipGlueDataWireImpl.scala b/src/col/vct/col/ast/family/bipglueelement/JavaBipGlueDataWireImpl.scala
index 9a2e10b6e5..ee20b6db48 100644
--- a/src/col/vct/col/ast/family/bipglueelement/JavaBipGlueDataWireImpl.scala
+++ b/src/col/vct/col/ast/family/bipglueelement/JavaBipGlueDataWireImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.JavaBipGlueDataWire
import vct.col.print._
import vct.col.ast.ops.JavaBipGlueDataWireOps
-trait JavaBipGlueDataWireImpl[G] extends JavaBipGlueDataWireOps[G] { this: JavaBipGlueDataWire[G] =>
+trait JavaBipGlueDataWireImpl[G] extends JavaBipGlueDataWireOps[G] {
+ this: JavaBipGlueDataWire[G] =>
override def layout(implicit ctx: Ctx): Doc =
Group(dataOut.show <> ".to(" <> Doc.arg(dataIn) <> ");")
}
diff --git a/src/col/vct/col/ast/family/bipglueelement/JavaBipGlueRequiresImpl.scala b/src/col/vct/col/ast/family/bipglueelement/JavaBipGlueRequiresImpl.scala
index 667b27a13a..4fd6e872e4 100644
--- a/src/col/vct/col/ast/family/bipglueelement/JavaBipGlueRequiresImpl.scala
+++ b/src/col/vct/col/ast/family/bipglueelement/JavaBipGlueRequiresImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.JavaBipGlueRequires
import vct.col.print._
import vct.col.ast.ops.JavaBipGlueRequiresOps
-trait JavaBipGlueRequiresImpl[G] extends JavaBipGlueRequiresOps[G] { this: JavaBipGlueRequires[G] =>
+trait JavaBipGlueRequiresImpl[G] extends JavaBipGlueRequiresOps[G] {
+ this: JavaBipGlueRequires[G] =>
override def layout(implicit ctx: Ctx): Doc =
Group(port.show <> ".requires(" <> Doc.args(others) <> ");")
}
diff --git a/src/col/vct/col/ast/family/bipglueelement/JavaBipGlueSynchronImpl.scala b/src/col/vct/col/ast/family/bipglueelement/JavaBipGlueSynchronImpl.scala
index d7f1941a51..6151fd6ae4 100644
--- a/src/col/vct/col/ast/family/bipglueelement/JavaBipGlueSynchronImpl.scala
+++ b/src/col/vct/col/ast/family/bipglueelement/JavaBipGlueSynchronImpl.scala
@@ -4,7 +4,10 @@ import vct.col.ast.JavaBipGlueSynchron
import vct.col.print._
import vct.col.ast.ops.JavaBipGlueSynchronOps
-trait JavaBipGlueSynchronImpl[G] extends JavaBipGlueSynchronOps[G] { this: JavaBipGlueSynchron[G] =>
+trait JavaBipGlueSynchronImpl[G] extends JavaBipGlueSynchronOps[G] {
+ this: JavaBipGlueSynchron[G] =>
override def layout(implicit ctx: Ctx): Doc =
- Group(Text("synchron(") <> Doc.arg(port0) <> ").to(" <> Doc.arg(port1) <> ");")
-}
\ No newline at end of file
+ Group(
+ Text("synchron(") <> Doc.arg(port0) <> ").to(" <> Doc.arg(port1) <> ");"
+ )
+}
diff --git a/src/col/vct/col/ast/family/bipporttype/BipEnforceableImpl.scala b/src/col/vct/col/ast/family/bipporttype/BipEnforceableImpl.scala
index 4c35b1a229..483416448f 100644
--- a/src/col/vct/col/ast/family/bipporttype/BipEnforceableImpl.scala
+++ b/src/col/vct/col/ast/family/bipporttype/BipEnforceableImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.BipEnforceable
import vct.col.print._
import vct.col.ast.ops.BipEnforceableOps
-trait BipEnforceableImpl[G] extends BipEnforceableOps[G] { this: BipEnforceable[G] =>
+trait BipEnforceableImpl[G] extends BipEnforceableOps[G] {
+ this: BipEnforceable[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("enforceable")
}
diff --git a/src/col/vct/col/ast/family/bipporttype/BipInternalImpl.scala b/src/col/vct/col/ast/family/bipporttype/BipInternalImpl.scala
index 991184049b..8f4a233517 100644
--- a/src/col/vct/col/ast/family/bipporttype/BipInternalImpl.scala
+++ b/src/col/vct/col/ast/family/bipporttype/BipInternalImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.BipInternal
import vct.col.print._
import vct.col.ast.ops.BipInternalOps
-trait BipInternalImpl[G] extends BipInternalOps[G] { this: BipInternal[G] =>
+trait BipInternalImpl[G] extends BipInternalOps[G] {
+ this: BipInternal[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("internal")
}
diff --git a/src/col/vct/col/ast/family/bipporttype/BipSpontaneousImpl.scala b/src/col/vct/col/ast/family/bipporttype/BipSpontaneousImpl.scala
index a69ff96b4c..5503b8555f 100644
--- a/src/col/vct/col/ast/family/bipporttype/BipSpontaneousImpl.scala
+++ b/src/col/vct/col/ast/family/bipporttype/BipSpontaneousImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.BipSpontaneous
import vct.col.print._
import vct.col.ast.ops.BipSpontaneousOps
-trait BipSpontaneousImpl[G] extends BipSpontaneousOps[G] { this: BipSpontaneous[G] =>
+trait BipSpontaneousImpl[G] extends BipSpontaneousOps[G] {
+ this: BipSpontaneous[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("spontaneous")
}
diff --git a/src/col/vct/col/ast/family/catchclause/CatchClauseImpl.scala b/src/col/vct/col/ast/family/catchclause/CatchClauseImpl.scala
index 0bd2b4aaae..8c094ea6a1 100644
--- a/src/col/vct/col/ast/family/catchclause/CatchClauseImpl.scala
+++ b/src/col/vct/col/ast/family/catchclause/CatchClauseImpl.scala
@@ -5,9 +5,11 @@ import vct.col.ast.{CatchClause, Declaration}
import vct.col.print._
import vct.col.ast.ops.{CatchClauseOps, CatchClauseFamilyOps}
-trait CatchClauseImpl[G] extends Declarator[G] with CatchClauseOps[G] with CatchClauseFamilyOps[G] { this: CatchClause[G] =>
+trait CatchClauseImpl[G]
+ extends Declarator[G] with CatchClauseOps[G] with CatchClauseFamilyOps[G] {
+ this: CatchClause[G] =>
override def declarations: Seq[Declaration[G]] = Seq(decl)
override def layout(implicit ctx: Ctx): Doc =
Text("catch") <+> "(" <> decl <> ")" <+> body.layoutAsBlock
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceBoolResourceImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceBoolResourceImpl.scala
index 2b0e0746ff..7d3d0f74b3 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceBoolResourceImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceBoolResourceImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceBoolResource, TResource}
import vct.col.ast.ops.CoerceBoolResourceOps
-trait CoerceBoolResourceImpl[G] extends CoerceBoolResourceOps[G] { this: CoerceBoolResource[G] =>
+trait CoerceBoolResourceImpl[G] extends CoerceBoolResourceOps[G] {
+ this: CoerceBoolResource[G] =>
override def target: TResource[G] = TResource()
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceBoundIntFloatImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceBoundIntFloatImpl.scala
index 9fa78412b4..af4fa2322e 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceBoundIntFloatImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceBoundIntFloatImpl.scala
@@ -3,5 +3,6 @@ package vct.col.ast.family.coercion
import vct.col.ast.CoerceBoundIntFloat
import vct.col.ast.ops.CoerceBoundIntFloatOps
-trait CoerceBoundIntFloatImpl[G] extends CoerceBoundIntFloatOps[G] { this: CoerceBoundIntFloat[G] =>
+trait CoerceBoundIntFloatImpl[G] extends CoerceBoundIntFloatOps[G] {
+ this: CoerceBoundIntFloat[G] =>
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceBoundIntFracImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceBoundIntFracImpl.scala
index 6e2870642a..5d66972c16 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceBoundIntFracImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceBoundIntFracImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceBoundIntFrac, TFraction}
import vct.col.ast.ops.CoerceBoundIntFracOps
-trait CoerceBoundIntFracImpl[G] extends CoerceBoundIntFracOps[G] { this: CoerceBoundIntFrac[G] =>
+trait CoerceBoundIntFracImpl[G] extends CoerceBoundIntFracOps[G] {
+ this: CoerceBoundIntFrac[G] =>
override def target: TFraction[G] = TFraction()
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceBoundIntZFracImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceBoundIntZFracImpl.scala
index 1bfadfa895..23871e2e15 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceBoundIntZFracImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceBoundIntZFracImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceBoundIntZFrac, TZFraction}
import vct.col.ast.ops.CoerceBoundIntZFracOps
-trait CoerceBoundIntZFracImpl[G] extends CoerceBoundIntZFracOps[G] { this: CoerceBoundIntZFrac[G] =>
+trait CoerceBoundIntZFracImpl[G] extends CoerceBoundIntZFracOps[G] {
+ this: CoerceBoundIntZFrac[G] =>
override def target: TZFraction[G] = TZFraction()
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceCArrayPointerImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceCArrayPointerImpl.scala
index db72005193..e751398314 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceCArrayPointerImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceCArrayPointerImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceCArrayPointer, TPointer}
import vct.col.ast.ops.CoerceCArrayPointerOps
-trait CoerceCArrayPointerImpl[G] extends CoerceCArrayPointerOps[G] { this: CoerceCArrayPointer[G] =>
+trait CoerceCArrayPointerImpl[G] extends CoerceCArrayPointerOps[G] {
+ this: CoerceCArrayPointer[G] =>
override def target: TPointer[G] = TPointer(elementType)
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceCFloatCIntImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceCFloatCIntImpl.scala
index 44eed6a7fb..ff78955dda 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceCFloatCIntImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceCFloatCIntImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceCFloatCInt, TCInt}
import vct.col.ast.ops.CoerceCFloatCIntOps
-trait CoerceCFloatCIntImpl[G] extends CoerceCFloatCIntOps[G] { this: CoerceCFloatCInt[G] =>
+trait CoerceCFloatCIntImpl[G] extends CoerceCFloatCIntOps[G] {
+ this: CoerceCFloatCInt[G] =>
override def target: TCInt[G] = TCInt()
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceCFloatFloatImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceCFloatFloatImpl.scala
index be08998f3d..c043ce0816 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceCFloatFloatImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceCFloatFloatImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.CoerceCFloatFloat
import vct.col.ast.ops.CoerceCFloatFloatOps
-trait CoerceCFloatFloatImpl[G] extends CoerceCFloatFloatOps[G] { this: CoerceCFloatFloat[G] =>
+trait CoerceCFloatFloatImpl[G] extends CoerceCFloatFloatOps[G] {
+ this: CoerceCFloatFloat[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceCIntCFloatImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceCIntCFloatImpl.scala
index 3c38306850..3a8b9ab067 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceCIntCFloatImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceCIntCFloatImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceCIntCFloat}
import vct.col.ast.ops.CoerceCIntCFloatOps
-trait CoerceCIntCFloatImpl[G] extends CoerceCIntCFloatOps[G] { this: CoerceCIntCFloat[G] =>
+trait CoerceCIntCFloatImpl[G] extends CoerceCIntCFloatOps[G] {
+ this: CoerceCIntCFloat[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceCIntIntImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceCIntIntImpl.scala
index cf7ec8a5df..e79a6e51e2 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceCIntIntImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceCIntIntImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceCIntInt, TInt}
import vct.col.ast.ops.CoerceCIntIntOps
-trait CoerceCIntIntImpl[G] extends CoerceCIntIntOps[G] { this: CoerceCIntInt[G] =>
+trait CoerceCIntIntImpl[G] extends CoerceCIntIntOps[G] {
+ this: CoerceCIntInt[G] =>
override def target: TInt[G] = TInt()
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceCPPArrayPointerImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceCPPArrayPointerImpl.scala
index 087e8dd89e..d7af5e50db 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceCPPArrayPointerImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceCPPArrayPointerImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceCPPArrayPointer, TPointer}
import vct.col.ast.ops.CoerceCPPArrayPointerOps
-trait CoerceCPPArrayPointerImpl[G] extends CoerceCPPArrayPointerOps[G] { this: CoerceCPPArrayPointer[G] =>
+trait CoerceCPPArrayPointerImpl[G] extends CoerceCPPArrayPointerOps[G] {
+ this: CoerceCPPArrayPointer[G] =>
override def target: TPointer[G] = TPointer(elementType)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceCPPPrimitiveToColImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceCPPPrimitiveToColImpl.scala
index 3eee8c2edc..fca53dbb13 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceCPPPrimitiveToColImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceCPPPrimitiveToColImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.CoerceCPPPrimitiveToCol
import vct.col.ast.ops.CoerceCPPPrimitiveToColOps
-trait CoerceCPPPrimitiveToColImpl[G] extends CoerceCPPPrimitiveToColOps[G] { this: CoerceCPPPrimitiveToCol[G] =>
-
-}
\ No newline at end of file
+trait CoerceCPPPrimitiveToColImpl[G] extends CoerceCPPPrimitiveToColOps[G] {
+ this: CoerceCPPPrimitiveToCol[G] =>
+
+}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceCPrimitiveToColImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceCPrimitiveToColImpl.scala
index 9b1520a5ac..0c90f37966 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceCPrimitiveToColImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceCPrimitiveToColImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.CoerceCPrimitiveToCol
import vct.col.ast.ops.CoerceCPrimitiveToColOps
-trait CoerceCPrimitiveToColImpl[G] extends CoerceCPrimitiveToColOps[G] { this: CoerceCPrimitiveToCol[G] =>
-
+trait CoerceCPrimitiveToColImpl[G] extends CoerceCPrimitiveToColOps[G] {
+ this: CoerceCPrimitiveToCol[G] =>
+
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceCVectorVectorImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceCVectorVectorImpl.scala
index 4be1a4fa3d..dfd481114c 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceCVectorVectorImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceCVectorVectorImpl.scala
@@ -3,7 +3,8 @@ package vct.col.ast.family.coercion
import vct.col.ast.ops.CoerceCVectorVectorOps
import vct.col.ast.{CoerceCVectorVector, TVector}
-trait CoerceCVectorVectorImpl[G] extends CoerceCVectorVectorOps[G] { this: CoerceCVectorVector[G] =>
+trait CoerceCVectorVectorImpl[G] extends CoerceCVectorVectorOps[G] {
+ this: CoerceCVectorVector[G] =>
override def target: TVector[G] = TVector(size, elementType)()
// override def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceClassAnyClassImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceClassAnyClassImpl.scala
index 78ddf9490f..6573ccfb82 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceClassAnyClassImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceClassAnyClassImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceClassAnyClass, TAnyClass}
import vct.col.ast.ops.CoerceClassAnyClassOps
-trait CoerceClassAnyClassImpl[G] extends CoerceClassAnyClassOps[G] { this: CoerceClassAnyClass[G] =>
+trait CoerceClassAnyClassImpl[G] extends CoerceClassAnyClassOps[G] {
+ this: CoerceClassAnyClass[G] =>
override def target: TAnyClass[G] = TAnyClass()
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceColToCPPPrimitiveImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceColToCPPPrimitiveImpl.scala
index 5dad91ca51..72f72fb82a 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceColToCPPPrimitiveImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceColToCPPPrimitiveImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.CoerceColToCPPPrimitive
import vct.col.ast.ops.CoerceColToCPPPrimitiveOps
-trait CoerceColToCPPPrimitiveImpl[G] extends CoerceColToCPPPrimitiveOps[G] { this: CoerceColToCPPPrimitive[G] =>
-
-}
\ No newline at end of file
+trait CoerceColToCPPPrimitiveImpl[G] extends CoerceColToCPPPrimitiveOps[G] {
+ this: CoerceColToCPPPrimitive[G] =>
+
+}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceColToCPrimitiveImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceColToCPrimitiveImpl.scala
index 4ac453f954..7685dd8047 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceColToCPrimitiveImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceColToCPrimitiveImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.CoerceColToCPrimitive
import vct.col.ast.ops.CoerceColToCPrimitiveOps
-trait CoerceColToCPrimitiveImpl[G] extends CoerceColToCPrimitiveOps[G] { this: CoerceColToCPrimitive[G] =>
-
+trait CoerceColToCPrimitiveImpl[G] extends CoerceColToCPrimitiveOps[G] {
+ this: CoerceColToCPrimitive[G] =>
+
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceFloatRatImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceFloatRatImpl.scala
index 5a60fb8baa..6adeb2a2aa 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceFloatRatImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceFloatRatImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceFloatRat, TRational}
import vct.col.ast.ops.CoerceFloatRatOps
-trait CoerceFloatRatImpl[G] extends CoerceFloatRatOps[G] { this: CoerceFloatRat[G] =>
+trait CoerceFloatRatImpl[G] extends CoerceFloatRatOps[G] {
+ this: CoerceFloatRat[G] =>
override def target: TRational[G] = TRational()
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceFracZFracImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceFracZFracImpl.scala
index 2bafba86cf..43e9828c1e 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceFracZFracImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceFracZFracImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceFracZFrac, TZFraction}
import vct.col.ast.ops.CoerceFracZFracOps
-trait CoerceFracZFracImpl[G] extends CoerceFracZFracOps[G] { this: CoerceFracZFrac[G] =>
+trait CoerceFracZFracImpl[G] extends CoerceFracZFracOps[G] {
+ this: CoerceFracZFrac[G] =>
override def target: TZFraction[G] = TZFraction()
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceIdentityImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceIdentityImpl.scala
index 9e1a4774ca..f089cb1e96 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceIdentityImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceIdentityImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceIdentity, Type}
import vct.col.ast.ops.CoerceIdentityOps
-trait CoerceIdentityImpl[G] extends CoerceIdentityOps[G] { this: CoerceIdentity[G] =>
+trait CoerceIdentityImpl[G] extends CoerceIdentityOps[G] {
+ this: CoerceIdentity[G] =>
override def target: Type[G] = source
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceIntRatImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceIntRatImpl.scala
index 6d7300dd3a..818e4dc472 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceIntRatImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceIntRatImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceIntRat, TRational}
import vct.col.ast.ops.CoerceIntRatOps
-trait CoerceIntRatImpl[G] extends CoerceIntRatOps[G] { this: CoerceIntRat[G] =>
+trait CoerceIntRatImpl[G] extends CoerceIntRatOps[G] {
+ this: CoerceIntRat[G] =>
override def target: TRational[G] = TRational()
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceJavaClassAnyClassImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceJavaClassAnyClassImpl.scala
index e5f6f9a0bc..8725e9da29 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceJavaClassAnyClassImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceJavaClassAnyClassImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceJavaClassAnyClass, TAnyClass}
import vct.col.ast.ops.CoerceJavaClassAnyClassOps
-trait CoerceJavaClassAnyClassImpl[G] extends CoerceJavaClassAnyClassOps[G] { this: CoerceJavaClassAnyClass[G] =>
+trait CoerceJavaClassAnyClassImpl[G] extends CoerceJavaClassAnyClassOps[G] {
+ this: CoerceJavaClassAnyClass[G] =>
override def target: TAnyClass[G] = TAnyClass()
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceJavaSupportsImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceJavaSupportsImpl.scala
index eb5d626e48..51c1fe8775 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceJavaSupportsImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceJavaSupportsImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceJavaSupports, JavaTClass}
import vct.col.ast.ops.CoerceJavaSupportsOps
-trait CoerceJavaSupportsImpl[G] extends CoerceJavaSupportsOps[G] { this: CoerceJavaSupports[G] =>
+trait CoerceJavaSupportsImpl[G] extends CoerceJavaSupportsOps[G] {
+ this: CoerceJavaSupports[G] =>
override def target: JavaTClass[G] = JavaTClass(targetClass, Nil)
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceJoinUnionImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceJoinUnionImpl.scala
index e82d752f63..834e8b05f7 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceJoinUnionImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceJoinUnionImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.CoerceJoinUnion
import vct.col.ast.ops.CoerceJoinUnionOps
-trait CoerceJoinUnionImpl[G] extends CoerceJoinUnionOps[G] { this: CoerceJoinUnion[G] =>
-
+trait CoerceJoinUnionImpl[G] extends CoerceJoinUnionOps[G] {
+ this: CoerceJoinUnion[G] =>
+
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceMapBagImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceMapBagImpl.scala
index c70d8a7895..692fd79d2a 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceMapBagImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceMapBagImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceMapBag, TBag}
import vct.col.ast.ops.CoerceMapBagOps
-trait CoerceMapBagImpl[G] extends CoerceMapBagOps[G] { this: CoerceMapBag[G] =>
+trait CoerceMapBagImpl[G] extends CoerceMapBagOps[G] {
+ this: CoerceMapBag[G] =>
override def target: TBag[G] = TBag(targetBagElement)
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceMapEitherImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceMapEitherImpl.scala
index fd6b2a910d..ba259431f6 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceMapEitherImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceMapEitherImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceMapEither, TEither}
import vct.col.ast.ops.CoerceMapEitherOps
-trait CoerceMapEitherImpl[G] extends CoerceMapEitherOps[G] { this: CoerceMapEither[G] =>
+trait CoerceMapEitherImpl[G] extends CoerceMapEitherOps[G] {
+ this: CoerceMapEither[G] =>
override def target: TEither[G] = TEither(targetTypes._1, targetTypes._2)
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceMapMapImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceMapMapImpl.scala
index 9550970ebc..eb4c48a75f 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceMapMapImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceMapMapImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceMapMap, TMap}
import vct.col.ast.ops.CoerceMapMapOps
-trait CoerceMapMapImpl[G] extends CoerceMapMapOps[G] { this: CoerceMapMap[G] =>
+trait CoerceMapMapImpl[G] extends CoerceMapMapOps[G] {
+ this: CoerceMapMap[G] =>
def target: TMap[G] = TMap(targetTypes._1, targetTypes._2)
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceMapMatrixImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceMapMatrixImpl.scala
index 4acedcb7fd..9ada3224d4 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceMapMatrixImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceMapMatrixImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceMapMatrix, TMatrix}
import vct.col.ast.ops.CoerceMapMatrixOps
-trait CoerceMapMatrixImpl[G] extends CoerceMapMatrixOps[G] { this: CoerceMapMatrix[G] =>
+trait CoerceMapMatrixImpl[G] extends CoerceMapMatrixOps[G] {
+ this: CoerceMapMatrix[G] =>
override def target: TMatrix[G] = TMatrix(targetMatrixElement)
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceMapOptionImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceMapOptionImpl.scala
index 2de351a2c2..e1e93667bb 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceMapOptionImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceMapOptionImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceMapOption, TOption}
import vct.col.ast.ops.CoerceMapOptionOps
-trait CoerceMapOptionImpl[G] extends CoerceMapOptionOps[G] { this: CoerceMapOption[G] =>
+trait CoerceMapOptionImpl[G] extends CoerceMapOptionOps[G] {
+ this: CoerceMapOption[G] =>
override def target: TOption[G] = TOption(targetOptionElement)
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceMapSeqImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceMapSeqImpl.scala
index 5347be4afc..4d5e460eb6 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceMapSeqImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceMapSeqImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceMapSeq, TSeq}
import vct.col.ast.ops.CoerceMapSeqOps
-trait CoerceMapSeqImpl[G] extends CoerceMapSeqOps[G] { this: CoerceMapSeq[G] =>
+trait CoerceMapSeqImpl[G] extends CoerceMapSeqOps[G] {
+ this: CoerceMapSeq[G] =>
override def target: TSeq[G] = TSeq(targetSeqElement)
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceMapSetImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceMapSetImpl.scala
index e978a13727..f6571f944f 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceMapSetImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceMapSetImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceMapSet, TSet}
import vct.col.ast.ops.CoerceMapSetOps
-trait CoerceMapSetImpl[G] extends CoerceMapSetOps[G] { this: CoerceMapSet[G] =>
+trait CoerceMapSetImpl[G] extends CoerceMapSetOps[G] {
+ this: CoerceMapSet[G] =>
override def target: TSet[G] = TSet(targetSetElement)
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceMapTupleImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceMapTupleImpl.scala
index e7319cb503..23b0595836 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceMapTupleImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceMapTupleImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceMapTuple, TTuple}
import vct.col.ast.ops.CoerceMapTupleOps
-trait CoerceMapTupleImpl[G] extends CoerceMapTupleOps[G] { this: CoerceMapTuple[G] =>
+trait CoerceMapTupleImpl[G] extends CoerceMapTupleOps[G] {
+ this: CoerceMapTuple[G] =>
override def target: TTuple[G] = TTuple(targetTypes)
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceMapTypeImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceMapTypeImpl.scala
index 1f469ead02..3043dc1fe6 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceMapTypeImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceMapTypeImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceMapType, TType}
import vct.col.ast.ops.CoerceMapTypeOps
-trait CoerceMapTypeImpl[G] extends CoerceMapTypeOps[G] { this: CoerceMapType[G] =>
+trait CoerceMapTypeImpl[G] extends CoerceMapTypeOps[G] {
+ this: CoerceMapType[G] =>
def target: TType[G] = TType(targetBound)
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceMapVectorImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceMapVectorImpl.scala
index 60c450bff7..ed91b97a80 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceMapVectorImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceMapVectorImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceMapVector, TVector}
import vct.col.ast.ops.CoerceMapVectorOps
-trait CoerceMapVectorImpl[G] extends CoerceMapVectorOps[G] { this: CoerceMapVector[G] =>
+trait CoerceMapVectorImpl[G] extends CoerceMapVectorOps[G] {
+ this: CoerceMapVector[G] =>
override def target: TVector[G] = TVector(size, targetVectorElement)()
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceNothingSomethingImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceNothingSomethingImpl.scala
index a55ab08c57..61d155e4c3 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceNothingSomethingImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceNothingSomethingImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.CoerceNothingSomething
import vct.col.ast.ops.CoerceNothingSomethingOps
-trait CoerceNothingSomethingImpl[G] extends CoerceNothingSomethingOps[G] { this: CoerceNothingSomething[G] =>
+trait CoerceNothingSomethingImpl[G] extends CoerceNothingSomethingOps[G] {
+ this: CoerceNothingSomething[G] =>
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceNullAnyClassImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceNullAnyClassImpl.scala
index 17a3294fc7..8d0dc38430 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceNullAnyClassImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceNullAnyClassImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceNullAnyClass, TAnyClass}
import vct.col.ast.ops.CoerceNullAnyClassOps
-trait CoerceNullAnyClassImpl[G] extends CoerceNullAnyClassOps[G] { this: CoerceNullAnyClass[G] =>
+trait CoerceNullAnyClassImpl[G] extends CoerceNullAnyClassOps[G] {
+ this: CoerceNullAnyClass[G] =>
override def target: TAnyClass[G] = TAnyClass()
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceNullArrayImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceNullArrayImpl.scala
index 630b811319..020b95e812 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceNullArrayImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceNullArrayImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceNullArray, TArray}
import vct.col.ast.ops.CoerceNullArrayOps
-trait CoerceNullArrayImpl[G] extends CoerceNullArrayOps[G] { this: CoerceNullArray[G] =>
+trait CoerceNullArrayImpl[G] extends CoerceNullArrayOps[G] {
+ this: CoerceNullArray[G] =>
override def target: TArray[G] = TArray(arrayElementType)
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceNullClassImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceNullClassImpl.scala
index d52c5635db..4dc7f0662b 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceNullClassImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceNullClassImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceNullClass, TClass}
import vct.col.ast.ops.CoerceNullClassOps
-trait CoerceNullClassImpl[G] extends CoerceNullClassOps[G] { this: CoerceNullClass[G] =>
+trait CoerceNullClassImpl[G] extends CoerceNullClassOps[G] {
+ this: CoerceNullClass[G] =>
override def target: TClass[G] = TClass(targetClass, typeArgs)
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceNullEnumImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceNullEnumImpl.scala
index c48d08ab69..bcd2744a83 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceNullEnumImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceNullEnumImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceNullEnum, TEnum}
import vct.col.ast.ops.CoerceNullEnumOps
-trait CoerceNullEnumImpl[G] extends CoerceNullEnumOps[G] { this: CoerceNullEnum[G] =>
+trait CoerceNullEnumImpl[G] extends CoerceNullEnumOps[G] {
+ this: CoerceNullEnum[G] =>
override def target: TEnum[G] = TEnum(targetEnum)
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceNullJavaClassImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceNullJavaClassImpl.scala
index 9b775133a3..dcd80d1571 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceNullJavaClassImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceNullJavaClassImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceNullJavaClass, JavaTClass}
import vct.col.ast.ops.CoerceNullJavaClassOps
-trait CoerceNullJavaClassImpl[G] extends CoerceNullJavaClassOps[G] { this: CoerceNullJavaClass[G] =>
+trait CoerceNullJavaClassImpl[G] extends CoerceNullJavaClassOps[G] {
+ this: CoerceNullJavaClass[G] =>
override def target: JavaTClass[G] = JavaTClass(targetClass, Nil)
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceNullPointerImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceNullPointerImpl.scala
index a3738dfc4a..d5ac3ea93b 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceNullPointerImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceNullPointerImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceNullPointer, TPointer}
import vct.col.ast.ops.CoerceNullPointerOps
-trait CoerceNullPointerImpl[G] extends CoerceNullPointerOps[G] { this: CoerceNullPointer[G] =>
+trait CoerceNullPointerImpl[G] extends CoerceNullPointerOps[G] {
+ this: CoerceNullPointer[G] =>
override def target: TPointer[G] = TPointer(pointerElementType)
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceNullRefImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceNullRefImpl.scala
index f2ff5c16ba..d9a7d6e92c 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceNullRefImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceNullRefImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceNullRef, TRef}
import vct.col.ast.ops.CoerceNullRefOps
-trait CoerceNullRefImpl[G] extends CoerceNullRefOps[G] { this: CoerceNullRef[G] =>
+trait CoerceNullRefImpl[G] extends CoerceNullRefOps[G] {
+ this: CoerceNullRef[G] =>
override def target: TRef[G] = TRef()
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceRatZFracImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceRatZFracImpl.scala
index 58299a680c..665c41ec73 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceRatZFracImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceRatZFracImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceRatZFrac, TZFraction}
import vct.col.ast.ops.CoerceRatZFracOps
-trait CoerceRatZFracImpl[G] extends CoerceRatZFracOps[G] { this: CoerceRatZFrac[G] =>
+trait CoerceRatZFracImpl[G] extends CoerceRatZFracOps[G] {
+ this: CoerceRatZFrac[G] =>
override def target: TZFraction[G] = TZFraction()
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceResourceResourceValImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceResourceResourceValImpl.scala
index 2d04793f72..dc07b0716e 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceResourceResourceValImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceResourceResourceValImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceResourceResourceVal, TResourceVal}
import vct.col.ast.ops.CoerceResourceResourceValOps
-trait CoerceResourceResourceValImpl[G] extends CoerceResourceResourceValOps[G] { this: CoerceResourceResourceVal[G] =>
+trait CoerceResourceResourceValImpl[G] extends CoerceResourceResourceValOps[G] {
+ this: CoerceResourceResourceVal[G] =>
override def target: TResourceVal[G] = TResourceVal()
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceResourceValResourceImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceResourceValResourceImpl.scala
index a57254ab1a..faff771482 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceResourceValResourceImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceResourceValResourceImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceResourceValResource, TResource}
import vct.col.ast.ops.CoerceResourceValResourceOps
-trait CoerceResourceValResourceImpl[G] extends CoerceResourceValResourceOps[G] { this: CoerceResourceValResource[G] =>
+trait CoerceResourceValResourceImpl[G] extends CoerceResourceValResourceOps[G] {
+ this: CoerceResourceValResource[G] =>
override def target: TResource[G] = TResource()
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceSelectUnionImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceSelectUnionImpl.scala
index 89b0515215..6eefb54061 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceSelectUnionImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceSelectUnionImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceSelectUnion, TUnion}
import vct.col.ast.ops.CoerceSelectUnionOps
-trait CoerceSelectUnionImpl[G] extends CoerceSelectUnionOps[G] { this: CoerceSelectUnion[G] =>
+trait CoerceSelectUnionImpl[G] extends CoerceSelectUnionOps[G] {
+ this: CoerceSelectUnion[G] =>
override def target: TUnion[G] = TUnion(targetAlts)
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceSomethingAnyImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceSomethingAnyImpl.scala
index ecc2a5bcf6..f5c9c2fcb3 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceSomethingAnyImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceSomethingAnyImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceSomethingAny, Type, TAny}
import vct.col.ast.ops.CoerceSomethingAnyOps
-trait CoerceSomethingAnyImpl[G] extends CoerceSomethingAnyOps[G] { this: CoerceSomethingAny[G] =>
+trait CoerceSomethingAnyImpl[G] extends CoerceSomethingAnyOps[G] {
+ this: CoerceSomethingAny[G] =>
override def target: Type[G] = TAny()
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceSomethingAnyValueImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceSomethingAnyValueImpl.scala
index 0ae84126db..c6eb2f4a7d 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceSomethingAnyValueImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceSomethingAnyValueImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceSomethingAnyValue, TAnyValue, Type}
import vct.col.ast.ops.CoerceSomethingAnyValueOps
-trait CoerceSomethingAnyValueImpl[G] extends CoerceSomethingAnyValueOps[G] { this: CoerceSomethingAnyValue[G] =>
+trait CoerceSomethingAnyValueImpl[G] extends CoerceSomethingAnyValueOps[G] {
+ this: CoerceSomethingAnyValue[G] =>
override def target: Type[G] = TAnyValue()
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceSupportsImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceSupportsImpl.scala
index 3585d774d6..e0ce3a4353 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceSupportsImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceSupportsImpl.scala
@@ -3,7 +3,9 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceSupports, TClass}
import vct.col.ast.ops.CoerceSupportsOps
-trait CoerceSupportsImpl[G] extends CoerceSupportsOps[G] { this: CoerceSupports[G] =>
+trait CoerceSupportsImpl[G] extends CoerceSupportsOps[G] {
+ this: CoerceSupports[G] =>
// TODO (RR): Integrate coercions with generics?
- override def target: TClass[G] = TClass(targetClass, { assert(sourceClass.decl.typeArgs.isEmpty); Seq() })
+ override def target: TClass[G] =
+ TClass(targetClass, { assert(sourceClass.decl.typeArgs.isEmpty); Seq() })
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceUnboundIntImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceUnboundIntImpl.scala
index a92d365b62..90aead95c5 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceUnboundIntImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceUnboundIntImpl.scala
@@ -3,5 +3,6 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceUnboundInt, TInt}
import vct.col.ast.ops.CoerceUnboundIntOps
-trait CoerceUnboundIntImpl[G] extends CoerceUnboundIntOps[G] { this: CoerceUnboundInt[G] =>
+trait CoerceUnboundIntImpl[G] extends CoerceUnboundIntOps[G] {
+ this: CoerceUnboundInt[G] =>
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceWidenBoundImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceWidenBoundImpl.scala
index 3efc9b5d53..949672214b 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceWidenBoundImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceWidenBoundImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.CoerceWidenBound
import vct.col.ast.ops.CoerceWidenBoundOps
-trait CoerceWidenBoundImpl[G] extends CoerceWidenBoundOps[G] { this: CoerceWidenBound[G] =>
-
+trait CoerceWidenBoundImpl[G] extends CoerceWidenBoundOps[G] {
+ this: CoerceWidenBound[G] =>
+
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceZFracFracImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceZFracFracImpl.scala
index 133fb6876a..71c646abd3 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceZFracFracImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceZFracFracImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceZFracFrac, TFraction}
import vct.col.ast.ops.CoerceZFracFracOps
-trait CoerceZFracFracImpl[G] extends CoerceZFracFracOps[G] { this: CoerceZFracFrac[G] =>
+trait CoerceZFracFracImpl[G] extends CoerceZFracFracOps[G] {
+ this: CoerceZFracFrac[G] =>
override def target: TFraction[G] = TFraction()
}
diff --git a/src/col/vct/col/ast/family/coercion/CoerceZFracRatImpl.scala b/src/col/vct/col/ast/family/coercion/CoerceZFracRatImpl.scala
index 5852a5ff6f..cb83cac581 100644
--- a/src/col/vct/col/ast/family/coercion/CoerceZFracRatImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoerceZFracRatImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoerceZFracRat, TRational}
import vct.col.ast.ops.CoerceZFracRatOps
-trait CoerceZFracRatImpl[G] extends CoerceZFracRatOps[G] { this: CoerceZFracRat[G] =>
+trait CoerceZFracRatImpl[G] extends CoerceZFracRatOps[G] {
+ this: CoerceZFracRat[G] =>
override def target: TRational[G] = TRational()
}
diff --git a/src/col/vct/col/ast/family/coercion/CoercionImpl.scala b/src/col/vct/col/ast/family/coercion/CoercionImpl.scala
index 81a7914b52..738aae3fdc 100644
--- a/src/col/vct/col/ast/family/coercion/CoercionImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoercionImpl.scala
@@ -3,84 +3,89 @@ package vct.col.ast.family.coercion
import vct.col.ast._
import vct.col.ast.ops.CoercionFamilyOps
-trait CoercionImpl[G] extends CoercionFamilyOps[G] { this: Coercion[G] =>
+trait CoercionImpl[G] extends CoercionFamilyOps[G] {
+ this: Coercion[G] =>
def target: Type[G]
- def isCPromoting: Boolean = this match {
- case CoerceDecreasePrecision(_, _) => false
- case CoerceCFloatCInt(_) => false
- case CoercionSequence(coercions) => coercions.forall(_.isCPromoting)
- case CoerceJoinUnion(inner, _, _) => inner.forall(_.isPromoting)
- case CoerceSelectUnion(inner, _, _, _) => inner.isPromoting
- case CoerceMapOption(inner, _, _) => inner.isCPromoting
- case CoerceMapTuple(inner, _, _) => inner.forall(_.isCPromoting)
- case CoerceMapEither(inner, _, _) => inner._1.isCPromoting && inner._2.isCPromoting
- case CoerceMapSeq(inner, _, _) => inner.isCPromoting
- case CoerceMapSet(inner, _, _) => inner.isCPromoting
- case CoerceMapVector(inner, _, _, _) => inner.isCPromoting
- case CoerceMapBag(inner, _, _) => inner.isCPromoting
- case CoerceMapMatrix(inner, _, _) => inner.isCPromoting
- case CoerceMapMap(inner, _, _) => inner.isCPromoting
- case CoerceMapType(inner, _, _) => inner.isCPromoting
- case _ => true
- }
+ def isCPromoting: Boolean =
+ this match {
+ case CoerceDecreasePrecision(_, _) => false
+ case CoerceCFloatCInt(_) => false
+ case CoercionSequence(coercions) => coercions.forall(_.isCPromoting)
+ case CoerceJoinUnion(inner, _, _) => inner.forall(_.isPromoting)
+ case CoerceSelectUnion(inner, _, _, _) => inner.isPromoting
+ case CoerceMapOption(inner, _, _) => inner.isCPromoting
+ case CoerceMapTuple(inner, _, _) => inner.forall(_.isCPromoting)
+ case CoerceMapEither(inner, _, _) =>
+ inner._1.isCPromoting && inner._2.isCPromoting
+ case CoerceMapSeq(inner, _, _) => inner.isCPromoting
+ case CoerceMapSet(inner, _, _) => inner.isCPromoting
+ case CoerceMapVector(inner, _, _, _) => inner.isCPromoting
+ case CoerceMapBag(inner, _, _) => inner.isCPromoting
+ case CoerceMapMatrix(inner, _, _) => inner.isCPromoting
+ case CoerceMapMap(inner, _, _) => inner.isCPromoting
+ case CoerceMapType(inner, _, _) => inner.isCPromoting
+ case _ => true
+ }
- def isPromoting: Boolean = this match {
- case CoerceIdentity(_) => true
- case CoercionSequence(coercions) => coercions.forall(_.isPromoting)
- case CoerceNothingSomething(_) => true
- case CoerceSomethingAny(_) => true
- case CoerceSomethingAnyValue(_) => true
- case CoerceJoinUnion(inner, _, _) => inner.forall(_.isPromoting)
- case CoerceSelectUnion(inner, _, _, _) => inner.isPromoting
- case CoerceBoolResource() => true
- case CoerceNullRef() => true
- case CoerceNullArray(_) => true
- case CoerceNullClass(_, _) => true
- case CoerceNullJavaClass(_) => true
- case CoerceNullAnyClass() => true
- case CoerceNullPointer(_) => true
- case CoerceNullEnum(_) => true
- case CoerceFracZFrac() => true
- case CoerceZFracRat() => true
- case CoerceFloatRat(_) => true
- case CoerceIncreasePrecision(_, _) => true
- case CoerceIntRat() => true
- case CoerceWidenBound(_, _) => true
- case CoerceUnboundInt(_, _) => true
- case CoerceBoundIntFrac() => true
- case CoerceBoundIntZFrac(_) => true
- case CoerceSupports(_, _) => true
- case CoerceJavaSupports(_, _) => true
- case CoerceClassAnyClass(_, _) => true
- case CoerceJavaClassAnyClass(_) => true
- case CoerceCPrimitiveToCol(_, _) => true
- case CoerceColToCPrimitive(_, _) => true
- case CoerceCPPPrimitiveToCol(_, _) => true
- case CoerceColToCPPPrimitive(_, _) => true
- case CoerceCPPArrayPointer(_) => true
- case CoerceCArrayPointer(_) => true
- case CoerceCVectorVector(_, _) => true
- case CoerceResourceResourceVal() => true
- case CoerceResourceValResource() => true
- case CoerceMapOption(inner, _, _) => inner.isPromoting
- case CoerceMapTuple(inner, _, _) => inner.forall(_.isPromoting)
- case CoerceMapEither(inner, _, _) => inner._1.isPromoting && inner._2.isPromoting
- case CoerceMapSeq(inner, _, _) => inner.isPromoting
- case CoerceMapSet(inner, _, _) => inner.isPromoting
- case CoerceMapVector(inner, _, _, _) => inner.isPromoting
- case CoerceMapBag(inner, _, _) => inner.isPromoting
- case CoerceMapMatrix(inner, _, _) => inner.isPromoting
- case CoerceMapMap(inner, _, _) => inner.isPromoting
- case CoerceMapType(inner, _, _) => inner.isPromoting
- case CoerceRatZFrac() => false
- case CoerceZFracFrac() => false
- case CoerceBoundIntFloat(_, _) => false
+ def isPromoting: Boolean =
+ this match {
+ case CoerceIdentity(_) => true
+ case CoercionSequence(coercions) => coercions.forall(_.isPromoting)
+ case CoerceNothingSomething(_) => true
+ case CoerceSomethingAny(_) => true
+ case CoerceSomethingAnyValue(_) => true
+ case CoerceJoinUnion(inner, _, _) => inner.forall(_.isPromoting)
+ case CoerceSelectUnion(inner, _, _, _) => inner.isPromoting
+ case CoerceBoolResource() => true
+ case CoerceNullRef() => true
+ case CoerceNullArray(_) => true
+ case CoerceNullClass(_, _) => true
+ case CoerceNullJavaClass(_) => true
+ case CoerceNullAnyClass() => true
+ case CoerceNullPointer(_) => true
+ case CoerceNullEnum(_) => true
+ case CoerceFracZFrac() => true
+ case CoerceZFracRat() => true
+ case CoerceFloatRat(_) => true
+ case CoerceIncreasePrecision(_, _) => true
+ case CoerceIntRat() => true
+ case CoerceWidenBound(_, _) => true
+ case CoerceUnboundInt(_, _) => true
+ case CoerceBoundIntFrac() => true
+ case CoerceBoundIntZFrac(_) => true
+ case CoerceSupports(_, _) => true
+ case CoerceJavaSupports(_, _) => true
+ case CoerceClassAnyClass(_, _) => true
+ case CoerceJavaClassAnyClass(_) => true
+ case CoerceCPrimitiveToCol(_, _) => true
+ case CoerceColToCPrimitive(_, _) => true
+ case CoerceCPPPrimitiveToCol(_, _) => true
+ case CoerceColToCPPPrimitive(_, _) => true
+ case CoerceCPPArrayPointer(_) => true
+ case CoerceCArrayPointer(_) => true
+ case CoerceCVectorVector(_, _) => true
+ case CoerceResourceResourceVal() => true
+ case CoerceResourceValResource() => true
+ case CoerceMapOption(inner, _, _) => inner.isPromoting
+ case CoerceMapTuple(inner, _, _) => inner.forall(_.isPromoting)
+ case CoerceMapEither(inner, _, _) =>
+ inner._1.isPromoting && inner._2.isPromoting
+ case CoerceMapSeq(inner, _, _) => inner.isPromoting
+ case CoerceMapSet(inner, _, _) => inner.isPromoting
+ case CoerceMapVector(inner, _, _, _) => inner.isPromoting
+ case CoerceMapBag(inner, _, _) => inner.isPromoting
+ case CoerceMapMatrix(inner, _, _) => inner.isPromoting
+ case CoerceMapMap(inner, _, _) => inner.isPromoting
+ case CoerceMapType(inner, _, _) => inner.isPromoting
+ case CoerceRatZFrac() => false
+ case CoerceZFracFrac() => false
+ case CoerceBoundIntFloat(_, _) => false
- case CoerceCIntCFloat(_) => true
- case CoerceCIntInt() => true
- case CoerceCFloatFloat(_, _) => true
- case CoerceDecreasePrecision(_, _) => false
- case CoerceCFloatCInt(_) => false
- }
-}
\ No newline at end of file
+ case CoerceCIntCFloat(_) => true
+ case CoerceCIntInt() => true
+ case CoerceCFloatFloat(_, _) => true
+ case CoerceDecreasePrecision(_, _) => false
+ case CoerceCFloatCInt(_) => false
+ }
+}
diff --git a/src/col/vct/col/ast/family/coercion/CoercionSequenceImpl.scala b/src/col/vct/col/ast/family/coercion/CoercionSequenceImpl.scala
index 1a9a363b30..d616b19e86 100644
--- a/src/col/vct/col/ast/family/coercion/CoercionSequenceImpl.scala
+++ b/src/col/vct/col/ast/family/coercion/CoercionSequenceImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.coercion
import vct.col.ast.{CoercionSequence, Type}
import vct.col.ast.ops.CoercionSequenceOps
-trait CoercionSequenceImpl[G] extends CoercionSequenceOps[G] { this: CoercionSequence[G] =>
+trait CoercionSequenceImpl[G] extends CoercionSequenceOps[G] {
+ this: CoercionSequence[G] =>
override def target: Type[G] = coercions.last.target
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/family/contract/ApplicableContractImpl.scala b/src/col/vct/col/ast/family/contract/ApplicableContractImpl.scala
index 71c0f49fcc..2f624e3dd4 100644
--- a/src/col/vct/col/ast/family/contract/ApplicableContractImpl.scala
+++ b/src/col/vct/col/ast/family/contract/ApplicableContractImpl.scala
@@ -1,30 +1,60 @@
package vct.col.ast.family.contract
-import vct.col.ast.{ApplicableContract, BooleanValue, Node, UnitAccountedPredicate}
+import vct.col.ast.{
+ ApplicableContract,
+ BooleanValue,
+ Node,
+ UnitAccountedPredicate,
+}
import vct.col.ast.node.NodeFamilyImpl
import vct.col.check.{CheckContext, CheckError}
import vct.col.print._
import vct.col.ast.ops.{ApplicableContractOps, ApplicableContractFamilyOps}
-trait ApplicableContractImpl[G] extends NodeFamilyImpl[G] with ApplicableContractOps[G] with ApplicableContractFamilyOps[G] { this: ApplicableContract[G] =>
- override def checkContextRecursor[T](context: CheckContext[G], f: (CheckContext[G], Node[G]) => T): Seq[T] =
+trait ApplicableContractImpl[G]
+ extends NodeFamilyImpl[G]
+ with ApplicableContractOps[G]
+ with ApplicableContractFamilyOps[G] {
+ this: ApplicableContract[G] =>
+ override def checkContextRecursor[T](
+ context: CheckContext[G],
+ f: (CheckContext[G], Node[G]) => T,
+ ): Seq[T] =
this match {
// Redundant match so this doesn't compile if we add a field to ApplicableContract
- case ApplicableContract(requires, ensures, contextEverywhere, signals, givenArgs, yieldsArgs, decreases) =>
+ case ApplicableContract(
+ requires,
+ ensures,
+ contextEverywhere,
+ signals,
+ givenArgs,
+ yieldsArgs,
+ decreases,
+ ) =>
f(context.withUndeclared(yieldsArgs).withPrecondition, requires) +:
- f(context.withPostcondition, ensures) +:
- f(context.withUndeclared(yieldsArgs).withPrecondition, contextEverywhere) +: (
- signals.map(f(context, _)) ++
- givenArgs.map(f(context, _)) ++
- yieldsArgs.map(f(context, _)) ++
- decreases.toSeq.map(f(context.withUndeclared(yieldsArgs), _))
- )
+ f(context.withPostcondition, ensures) +: f(
+ context.withUndeclared(yieldsArgs).withPrecondition,
+ contextEverywhere,
+ ) +:
+ (signals.map(f(context, _)) ++ givenArgs.map(f(context, _)) ++
+ yieldsArgs.map(f(context, _)) ++
+ decreases.toSeq.map(f(context.withUndeclared(yieldsArgs), _)))
}
- def isEmpty: Boolean = this match {
- case ApplicableContract(UnitAccountedPredicate(BooleanValue(true)), UnitAccountedPredicate(BooleanValue(true)), BooleanValue(true), Nil, Nil, Nil, None) => true
- case _ => false
- }
+ def isEmpty: Boolean =
+ this match {
+ case ApplicableContract(
+ UnitAccountedPredicate(BooleanValue(true)),
+ UnitAccountedPredicate(BooleanValue(true)),
+ BooleanValue(true),
+ Nil,
+ Nil,
+ Nil,
+ None,
+ ) =>
+ true
+ case _ => false
+ }
def nonEmpty: Boolean = !isEmpty
@@ -51,8 +81,9 @@ trait ApplicableContractImpl[G] extends NodeFamilyImpl[G] with ApplicableContrac
Doc.stack(signals),
))
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.Silver => layoutSilver
- case _ => Doc.spec(Show.lazily(layoutSpec(_)))
- }
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.Silver => layoutSilver
+ case _ => Doc.spec(Show.lazily(layoutSpec(_)))
+ }
+}
diff --git a/src/col/vct/col/ast/family/data/BipGlueAcceptsImpl.scala b/src/col/vct/col/ast/family/data/BipGlueAcceptsImpl.scala
index 1fa9767dde..24a1d4af84 100644
--- a/src/col/vct/col/ast/family/data/BipGlueAcceptsImpl.scala
+++ b/src/col/vct/col/ast/family/data/BipGlueAcceptsImpl.scala
@@ -4,7 +4,10 @@ import vct.col.ast.BipGlueAccepts
import vct.col.print._
import vct.col.ast.ops.{BipGlueAcceptsOps, BipGlueAcceptsFamilyOps}
-trait BipGlueAcceptsImpl[G] extends BipGlueAcceptsOps[G] with BipGlueAcceptsFamilyOps[G] { this: BipGlueAccepts[G] =>
+trait BipGlueAcceptsImpl[G]
+ extends BipGlueAcceptsOps[G] with BipGlueAcceptsFamilyOps[G] {
+ this: BipGlueAccepts[G] =>
override def layout(implicit ctx: Ctx): Doc =
- Text(ctx.name(port)) <> ".accepts(" <> Doc.args(others.map(ctx.name).map(Text)) <> ");"
+ Text(ctx.name(port)) <> ".accepts(" <>
+ Doc.args(others.map(ctx.name).map(Text)) <> ");"
}
diff --git a/src/col/vct/col/ast/family/data/BipGlueDataWireImpl.scala b/src/col/vct/col/ast/family/data/BipGlueDataWireImpl.scala
index 05e27f07c8..b5fa6e1ee1 100644
--- a/src/col/vct/col/ast/family/data/BipGlueDataWireImpl.scala
+++ b/src/col/vct/col/ast/family/data/BipGlueDataWireImpl.scala
@@ -4,7 +4,9 @@ import vct.col.ast.BipGlueDataWire
import vct.col.print._
import vct.col.ast.ops.{BipGlueDataWireOps, BipGlueDataWireFamilyOps}
-trait BipGlueDataWireImpl[G] extends BipGlueDataWireOps[G] with BipGlueDataWireFamilyOps[G] { this: BipGlueDataWire[G] =>
+trait BipGlueDataWireImpl[G]
+ extends BipGlueDataWireOps[G] with BipGlueDataWireFamilyOps[G] {
+ this: BipGlueDataWire[G] =>
override def layout(implicit ctx: Ctx): Doc =
Text(ctx.name(dataOut)) <> ".to(" <> Doc.arg(Text(ctx.name(dataIn))) <> ");"
}
diff --git a/src/col/vct/col/ast/family/data/BipGlueRequiresImpl.scala b/src/col/vct/col/ast/family/data/BipGlueRequiresImpl.scala
index fc7283ab21..53d065153c 100644
--- a/src/col/vct/col/ast/family/data/BipGlueRequiresImpl.scala
+++ b/src/col/vct/col/ast/family/data/BipGlueRequiresImpl.scala
@@ -4,7 +4,10 @@ import vct.col.ast.BipGlueRequires
import vct.col.print._
import vct.col.ast.ops.{BipGlueRequiresOps, BipGlueRequiresFamilyOps}
-trait BipGlueRequiresImpl[G] extends BipGlueRequiresOps[G] with BipGlueRequiresFamilyOps[G] { this: BipGlueRequires[G] =>
+trait BipGlueRequiresImpl[G]
+ extends BipGlueRequiresOps[G] with BipGlueRequiresFamilyOps[G] {
+ this: BipGlueRequires[G] =>
override def layout(implicit ctx: Ctx): Doc =
- Text(ctx.name(port)) <> ".requires(" <> Doc.args(others.map(ctx.name).map(Text)) <> ");"
+ Text(ctx.name(port)) <> ".requires(" <>
+ Doc.args(others.map(ctx.name).map(Text)) <> ");"
}
diff --git a/src/col/vct/col/ast/family/data/JavaBipGlueNameImpl.scala b/src/col/vct/col/ast/family/data/JavaBipGlueNameImpl.scala
index 5b0409d809..2ad4671cb0 100644
--- a/src/col/vct/col/ast/family/data/JavaBipGlueNameImpl.scala
+++ b/src/col/vct/col/ast/family/data/JavaBipGlueNameImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.JavaBipGlueName
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.{JavaBipGlueNameOps, JavaBipGlueNameFamilyOps}
-trait JavaBipGlueNameImpl[G] extends JavaBipGlueNameOps[G] with JavaBipGlueNameFamilyOps[G] { this: JavaBipGlueName[G] =>
- override def layout(implicit ctx: Ctx): Doc =
- t.show <> "," <+> e.show
+trait JavaBipGlueNameImpl[G]
+ extends JavaBipGlueNameOps[G] with JavaBipGlueNameFamilyOps[G] {
+ this: JavaBipGlueName[G] =>
+ override def layout(implicit ctx: Ctx): Doc = t.show <> "," <+> e.show
}
diff --git a/src/col/vct/col/ast/family/decreases/DecreasesClauseAssumeImpl.scala b/src/col/vct/col/ast/family/decreases/DecreasesClauseAssumeImpl.scala
index d2cd961a89..ea274dda5c 100644
--- a/src/col/vct/col/ast/family/decreases/DecreasesClauseAssumeImpl.scala
+++ b/src/col/vct/col/ast/family/decreases/DecreasesClauseAssumeImpl.scala
@@ -4,7 +4,7 @@ import vct.col.ast.DecreasesClauseAssume
import vct.col.print._
import vct.col.ast.ops.DecreasesClauseAssumeOps
-trait DecreasesClauseAssumeImpl[G] extends DecreasesClauseAssumeOps[G] { this: DecreasesClauseAssume[G] =>
- override def layout(implicit ctx: Ctx): Doc =
- Text("decreases assume;")
+trait DecreasesClauseAssumeImpl[G] extends DecreasesClauseAssumeOps[G] {
+ this: DecreasesClauseAssume[G] =>
+ override def layout(implicit ctx: Ctx): Doc = Text("decreases assume;")
}
diff --git a/src/col/vct/col/ast/family/decreases/DecreasesClauseImpl.scala b/src/col/vct/col/ast/family/decreases/DecreasesClauseImpl.scala
index f9eea85fc8..422209a2f1 100644
--- a/src/col/vct/col/ast/family/decreases/DecreasesClauseImpl.scala
+++ b/src/col/vct/col/ast/family/decreases/DecreasesClauseImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.decreases
import vct.col.ast.DecreasesClause
import vct.col.ast.ops.DecreasesClauseFamilyOps
-trait DecreasesClauseImpl[G] extends DecreasesClauseFamilyOps[G] { this: DecreasesClause[G] =>
+trait DecreasesClauseImpl[G] extends DecreasesClauseFamilyOps[G] {
+ this: DecreasesClause[G] =>
}
diff --git a/src/col/vct/col/ast/family/decreases/DecreasesClauseNoRecursionImpl.scala b/src/col/vct/col/ast/family/decreases/DecreasesClauseNoRecursionImpl.scala
index e821b09089..bf350c5986 100644
--- a/src/col/vct/col/ast/family/decreases/DecreasesClauseNoRecursionImpl.scala
+++ b/src/col/vct/col/ast/family/decreases/DecreasesClauseNoRecursionImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.DecreasesClauseNoRecursion
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.DecreasesClauseNoRecursionOps
-trait DecreasesClauseNoRecursionImpl[G] extends DecreasesClauseNoRecursionOps[G] { this: DecreasesClauseNoRecursion[G] =>
- override def layout(implicit ctx: Ctx): Doc =
- Text("decreases;")
+trait DecreasesClauseNoRecursionImpl[G]
+ extends DecreasesClauseNoRecursionOps[G] {
+ this: DecreasesClauseNoRecursion[G] =>
+ override def layout(implicit ctx: Ctx): Doc = Text("decreases;")
}
diff --git a/src/col/vct/col/ast/family/decreases/DecreasesClauseTupleImpl.scala b/src/col/vct/col/ast/family/decreases/DecreasesClauseTupleImpl.scala
index 3cb5bac02d..c5143b1246 100644
--- a/src/col/vct/col/ast/family/decreases/DecreasesClauseTupleImpl.scala
+++ b/src/col/vct/col/ast/family/decreases/DecreasesClauseTupleImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.DecreasesClauseTuple
import vct.col.print._
import vct.col.ast.ops.DecreasesClauseTupleOps
-trait DecreasesClauseTupleImpl[G] extends DecreasesClauseTupleOps[G] { this: DecreasesClauseTuple[G] =>
+trait DecreasesClauseTupleImpl[G] extends DecreasesClauseTupleOps[G] {
+ this: DecreasesClauseTuple[G] =>
override def layout(implicit ctx: Ctx): Doc =
Group(Text("decreases") <+> Doc.args(exprs) <> ";")
}
diff --git a/src/col/vct/col/ast/family/fieldflag/FieldFlagImpl.scala b/src/col/vct/col/ast/family/fieldflag/FieldFlagImpl.scala
index 18912ba42e..7a0546fe6d 100644
--- a/src/col/vct/col/ast/family/fieldflag/FieldFlagImpl.scala
+++ b/src/col/vct/col/ast/family/fieldflag/FieldFlagImpl.scala
@@ -4,7 +4,7 @@ import vct.col.ast.FieldFlag
import vct.col.print._
import vct.col.ast.ops.FieldFlagFamilyOps
-trait FieldFlagImpl[G] extends FieldFlagFamilyOps[G] { this: FieldFlag[G] =>
- override def layout(implicit ctx: Ctx): Doc =
- Text("final")
+trait FieldFlagImpl[G] extends FieldFlagFamilyOps[G] {
+ this: FieldFlag[G] =>
+ override def layout(implicit ctx: Ctx): Doc = Text("final")
}
diff --git a/src/col/vct/col/ast/family/fieldflag/FinalImpl.scala b/src/col/vct/col/ast/family/fieldflag/FinalImpl.scala
index 5a62e87069..f2af622e06 100644
--- a/src/col/vct/col/ast/family/fieldflag/FinalImpl.scala
+++ b/src/col/vct/col/ast/family/fieldflag/FinalImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.fieldflag
import vct.col.ast.Final
import vct.col.ast.ops.FinalOps
-trait FinalImpl[G] extends FinalOps[G] { this: Final[G] =>
+trait FinalImpl[G] extends FinalOps[G] {
+ this: Final[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/family/invoking/InvokingNodeImpl.scala b/src/col/vct/col/ast/family/invoking/InvokingNodeImpl.scala
index 7db967605c..8262484c1c 100644
--- a/src/col/vct/col/ast/family/invoking/InvokingNodeImpl.scala
+++ b/src/col/vct/col/ast/family/invoking/InvokingNodeImpl.scala
@@ -5,7 +5,8 @@ import vct.col.check.CheckError
import vct.col.origin.{Blame, InvocationFailure}
import vct.col.ref.Ref
-trait InvokingNodeImpl[G] { this: InvokingNode[G] =>
+trait InvokingNodeImpl[G] {
+ this: InvokingNode[G] =>
def ref: Ref[G, _ <: ContractApplicable[G]]
def blame: Blame[InvocationFailure]
def givenMap: Seq[(Ref[G, Variable[G]], Expr[G])]
diff --git a/src/col/vct/col/ast/family/itervariable/IterVariableImpl.scala b/src/col/vct/col/ast/family/itervariable/IterVariableImpl.scala
index 227cb52d11..b712fc503a 100644
--- a/src/col/vct/col/ast/family/itervariable/IterVariableImpl.scala
+++ b/src/col/vct/col/ast/family/itervariable/IterVariableImpl.scala
@@ -4,7 +4,9 @@ import vct.col.ast.IterVariable
import vct.col.print._
import vct.col.ast.ops.{IterVariableOps, IterVariableFamilyOps}
-trait IterVariableImpl[G] extends IterVariableOps[G] with IterVariableFamilyOps[G] { this: IterVariable[G] =>
+trait IterVariableImpl[G]
+ extends IterVariableOps[G] with IterVariableFamilyOps[G] {
+ this: IterVariable[G] =>
override def layout(implicit ctx: Ctx): Doc =
Group(variable.show <+> "=" <>> Group(from.show <+> ".." <+/> to))
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/family/javavar/JavaVariableDeclarationImpl.scala b/src/col/vct/col/ast/family/javavar/JavaVariableDeclarationImpl.scala
index 26d1b87b63..2477fad8e3 100644
--- a/src/col/vct/col/ast/family/javavar/JavaVariableDeclarationImpl.scala
+++ b/src/col/vct/col/ast/family/javavar/JavaVariableDeclarationImpl.scala
@@ -2,10 +2,18 @@ package vct.col.ast.family.javavar
import vct.col.ast.JavaVariableDeclaration
import vct.col.print._
-import vct.col.ast.ops.{JavaVariableDeclarationOps, JavaVariableDeclarationFamilyOps}
+import vct.col.ast.ops.{
+ JavaVariableDeclarationOps,
+ JavaVariableDeclarationFamilyOps,
+}
-trait JavaVariableDeclarationImpl[G] extends JavaVariableDeclarationOps[G] with JavaVariableDeclarationFamilyOps[G] { this: JavaVariableDeclaration[G] =>
+trait JavaVariableDeclarationImpl[G]
+ extends JavaVariableDeclarationOps[G]
+ with JavaVariableDeclarationFamilyOps[G] {
+ this: JavaVariableDeclaration[G] =>
override def layout(implicit ctx: Ctx): Doc =
- Group(Text(name) <> "[]".repeat(moreDims) <>
- init.map(Text(" =") <>> _).getOrElse(Empty))
+ Group(
+ Text(name) <> "[]".repeat(moreDims) <> init.map(Text(" =") <>> _)
+ .getOrElse(Empty)
+ )
}
diff --git a/src/col/vct/col/ast/family/location/AmbiguousLocationImpl.scala b/src/col/vct/col/ast/family/location/AmbiguousLocationImpl.scala
index 3f7dcde32c..343e6450c1 100644
--- a/src/col/vct/col/ast/family/location/AmbiguousLocationImpl.scala
+++ b/src/col/vct/col/ast/family/location/AmbiguousLocationImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.AmbiguousLocation
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.AmbiguousLocationOps
-trait AmbiguousLocationImpl[G] extends AmbiguousLocationOps[G] { this: AmbiguousLocation[G] =>
+trait AmbiguousLocationImpl[G] extends AmbiguousLocationOps[G] {
+ this: AmbiguousLocation[G] =>
override def layout(implicit ctx: Ctx): Doc = expr.show
}
diff --git a/src/col/vct/col/ast/family/location/ArrayLocationImpl.scala b/src/col/vct/col/ast/family/location/ArrayLocationImpl.scala
index e45868d571..8f0e848414 100644
--- a/src/col/vct/col/ast/family/location/ArrayLocationImpl.scala
+++ b/src/col/vct/col/ast/family/location/ArrayLocationImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.ArrayLocation
import vct.col.print._
import vct.col.ast.ops.ArrayLocationOps
-trait ArrayLocationImpl[G] extends ArrayLocationOps[G] { this: ArrayLocation[G] =>
+trait ArrayLocationImpl[G] extends ArrayLocationOps[G] {
+ this: ArrayLocation[G] =>
override def layout(implicit ctx: Ctx): Doc =
Group(array.bind(Precedence.POSTFIX) <> "[" <> Doc.arg(subscript) <> "]")
}
diff --git a/src/col/vct/col/ast/family/location/FieldLocationImpl.scala b/src/col/vct/col/ast/family/location/FieldLocationImpl.scala
index b3ef8b9af7..65482ed0fa 100644
--- a/src/col/vct/col/ast/family/location/FieldLocationImpl.scala
+++ b/src/col/vct/col/ast/family/location/FieldLocationImpl.scala
@@ -5,10 +5,13 @@ import vct.col.print._
import vct.col.ast.ops.FieldLocationOps
import vct.col.check.{CheckContext, CheckError, FinalPermission}
-trait FieldLocationImpl[G] extends FieldLocationOps[G] with LocationImpl[G] { this: FieldLocation[G] =>
+trait FieldLocationImpl[G] extends FieldLocationOps[G] with LocationImpl[G] {
+ this: FieldLocation[G] =>
override def check(context: CheckContext[G]): Seq[CheckError] =
- if(field.decl.flags.collectFirst { case Final() => () }.nonEmpty) Seq(FinalPermission(this)) ++ super.check(context)
- else super.check(context)
+ if (field.decl.flags.collectFirst { case Final() => () }.nonEmpty)
+ Seq(FinalPermission(this)) ++ super.check(context)
+ else
+ super.check(context)
override def layout(implicit ctx: Ctx): Doc =
obj.bind(Precedence.POSTFIX) <> "." <> ctx.name(field)
diff --git a/src/col/vct/col/ast/family/location/HeapVariableLocationImpl.scala b/src/col/vct/col/ast/family/location/HeapVariableLocationImpl.scala
index 34eb64b29a..e0b00561a1 100644
--- a/src/col/vct/col/ast/family/location/HeapVariableLocationImpl.scala
+++ b/src/col/vct/col/ast/family/location/HeapVariableLocationImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.location
import vct.col.ast.HeapVariableLocation
import vct.col.ast.ops.HeapVariableLocationOps
-trait HeapVariableLocationImpl[G] extends HeapVariableLocationOps[G] { this: HeapVariableLocation[G] =>
+trait HeapVariableLocationImpl[G] extends HeapVariableLocationOps[G] {
+ this: HeapVariableLocation[G] =>
}
diff --git a/src/col/vct/col/ast/family/location/InLinePatternLocationImpl.scala b/src/col/vct/col/ast/family/location/InLinePatternLocationImpl.scala
index 2866fd92b2..305ad82e7e 100644
--- a/src/col/vct/col/ast/family/location/InLinePatternLocationImpl.scala
+++ b/src/col/vct/col/ast/family/location/InLinePatternLocationImpl.scala
@@ -4,6 +4,8 @@ import vct.col.ast.InLinePatternLocation
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.InLinePatternLocationOps
-trait InLinePatternLocationImpl[G] extends InLinePatternLocationOps[G] { this: InLinePatternLocation[G] =>
- override def layout(implicit ctx: Ctx): Doc = loc.show <+> "{" <> pattern <> "}"
+trait InLinePatternLocationImpl[G] extends InLinePatternLocationOps[G] {
+ this: InLinePatternLocation[G] =>
+ override def layout(implicit ctx: Ctx): Doc =
+ loc.show <+> "{" <> pattern <> "}"
}
diff --git a/src/col/vct/col/ast/family/location/InstancePredicateLocationImpl.scala b/src/col/vct/col/ast/family/location/InstancePredicateLocationImpl.scala
index c790d35e46..68bdcef925 100644
--- a/src/col/vct/col/ast/family/location/InstancePredicateLocationImpl.scala
+++ b/src/col/vct/col/ast/family/location/InstancePredicateLocationImpl.scala
@@ -4,7 +4,11 @@ import vct.col.ast.InstancePredicateLocation
import vct.col.print._
import vct.col.ast.ops.InstancePredicateLocationOps
-trait InstancePredicateLocationImpl[G] extends InstancePredicateLocationOps[G] { this: InstancePredicateLocation[G] =>
+trait InstancePredicateLocationImpl[G] extends InstancePredicateLocationOps[G] {
+ this: InstancePredicateLocation[G] =>
override def layout(implicit ctx: Ctx): Doc =
- Group(obj.bind(Precedence.POSTFIX) <> "." <> ctx.name(predicate) <> "(" <> Doc.args(args) <> ")")
+ Group(
+ obj.bind(Precedence.POSTFIX) <> "." <> ctx.name(predicate) <> "(" <>
+ Doc.args(args) <> ")"
+ )
}
diff --git a/src/col/vct/col/ast/family/location/LocationImpl.scala b/src/col/vct/col/ast/family/location/LocationImpl.scala
index f524adafc7..73681feca4 100644
--- a/src/col/vct/col/ast/family/location/LocationImpl.scala
+++ b/src/col/vct/col/ast/family/location/LocationImpl.scala
@@ -1,12 +1,27 @@
package vct.col.ast.family.location
-import vct.col.ast.{AmbiguousLocation, ArrayLocation, FieldLocation, HeapVariableLocation, InLinePatternLocation, InstancePredicateLocation, Location, ModelLocation, PointerLocation, PredicateLocation, SilverFieldLocation, Type}
+import vct.col.ast.{
+ AmbiguousLocation,
+ ArrayLocation,
+ FieldLocation,
+ HeapVariableLocation,
+ InLinePatternLocation,
+ InstancePredicateLocation,
+ Location,
+ ModelLocation,
+ PointerLocation,
+ PredicateLocation,
+ SilverFieldLocation,
+ Type,
+}
import vct.col.ast.node.NodeFamilyImpl
import vct.col.ast.ops.LocationFamilyOps
import vct.col.check.{CheckContext, CheckError}
-trait LocationImpl[G] extends NodeFamilyImpl[G] with LocationFamilyOps[G] { this: Location[G] =>
- override def check(context: CheckContext[G]): Seq[CheckError] = super.check(context)
+trait LocationImpl[G] extends NodeFamilyImpl[G] with LocationFamilyOps[G] {
+ this: Location[G] =>
+ override def check(context: CheckContext[G]): Seq[CheckError] =
+ super.check(context)
def t: Type[G] = {
this match {
diff --git a/src/col/vct/col/ast/family/location/ModelLocationImpl.scala b/src/col/vct/col/ast/family/location/ModelLocationImpl.scala
index c14fc279ba..191d3f5fc9 100644
--- a/src/col/vct/col/ast/family/location/ModelLocationImpl.scala
+++ b/src/col/vct/col/ast/family/location/ModelLocationImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.ModelLocation
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.ModelLocationOps
-trait ModelLocationImpl[G] extends ModelLocationOps[G] { this: ModelLocation[G] =>
+trait ModelLocationImpl[G] extends ModelLocationOps[G] {
+ this: ModelLocation[G] =>
override def layout(implicit ctx: Ctx): Doc =
obj.bind(Precedence.POSTFIX) <> "." <> ctx.name(field)
}
diff --git a/src/col/vct/col/ast/family/location/PointerLocationImpl.scala b/src/col/vct/col/ast/family/location/PointerLocationImpl.scala
index 2fe127436e..73af012f76 100644
--- a/src/col/vct/col/ast/family/location/PointerLocationImpl.scala
+++ b/src/col/vct/col/ast/family/location/PointerLocationImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.PointerLocation
import vct.col.print.{Ctx, Doc}
import vct.col.ast.ops.PointerLocationOps
-trait PointerLocationImpl[G] extends PointerLocationOps[G] { this: PointerLocation[G] =>
+trait PointerLocationImpl[G] extends PointerLocationOps[G] {
+ this: PointerLocation[G] =>
override def layout(implicit ctx: Ctx): Doc = pointer.show
}
diff --git a/src/col/vct/col/ast/family/location/PredicateLocationImpl.scala b/src/col/vct/col/ast/family/location/PredicateLocationImpl.scala
index 039e94b687..33937b63bb 100644
--- a/src/col/vct/col/ast/family/location/PredicateLocationImpl.scala
+++ b/src/col/vct/col/ast/family/location/PredicateLocationImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.PredicateLocation
import vct.col.print.{Ctx, Doc, Group, Text}
import vct.col.ast.ops.PredicateLocationOps
-trait PredicateLocationImpl[G] extends PredicateLocationOps[G] { this: PredicateLocation[G] =>
+trait PredicateLocationImpl[G] extends PredicateLocationOps[G] {
+ this: PredicateLocation[G] =>
override def layout(implicit ctx: Ctx): Doc =
Group(Text(ctx.name(predicate)) <> "(" <> Doc.args(args) <> ")")
}
diff --git a/src/col/vct/col/ast/family/location/SilverFieldLocationImpl.scala b/src/col/vct/col/ast/family/location/SilverFieldLocationImpl.scala
index 572ff9f298..4f58c5b5b4 100644
--- a/src/col/vct/col/ast/family/location/SilverFieldLocationImpl.scala
+++ b/src/col/vct/col/ast/family/location/SilverFieldLocationImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.SilverFieldLocation
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.ast.ops.SilverFieldLocationOps
-trait SilverFieldLocationImpl[G] extends SilverFieldLocationOps[G] { this: SilverFieldLocation[G] =>
+trait SilverFieldLocationImpl[G] extends SilverFieldLocationOps[G] {
+ this: SilverFieldLocation[G] =>
override def layout(implicit ctx: Ctx): Doc =
obj.bind(Precedence.POSTFIX) <> "." <> ctx.name(field)
}
diff --git a/src/col/vct/col/ast/family/loopcontract/IterationContractImpl.scala b/src/col/vct/col/ast/family/loopcontract/IterationContractImpl.scala
index 7dccfc1d8d..6de106c28d 100644
--- a/src/col/vct/col/ast/family/loopcontract/IterationContractImpl.scala
+++ b/src/col/vct/col/ast/family/loopcontract/IterationContractImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.IterationContract
import vct.col.print._
import vct.col.ast.ops.IterationContractOps
-trait IterationContractImpl[G] extends IterationContractOps[G] { this: IterationContract[G] =>
+trait IterationContractImpl[G] extends IterationContractOps[G] {
+ this: IterationContract[G] =>
def layoutSpec(implicit ctx: Ctx): Doc =
Doc.stack(Seq(
DocUtil.clauses("context_everywhere", context_everywhere),
@@ -14,4 +15,4 @@ trait IterationContractImpl[G] extends IterationContractOps[G] { this: Iteration
override def layout(implicit ctx: Ctx): Doc =
Doc.spec(Show.lazily(layoutSpec(_)))
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/family/loopcontract/LoopContractImpl.scala b/src/col/vct/col/ast/family/loopcontract/LoopContractImpl.scala
index 30d35d9039..3bb8f65d07 100644
--- a/src/col/vct/col/ast/family/loopcontract/LoopContractImpl.scala
+++ b/src/col/vct/col/ast/family/loopcontract/LoopContractImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.loopcontract
import vct.col.ast.LoopContract
import vct.col.ast.ops.LoopContractFamilyOps
-trait LoopContractImpl[G] extends LoopContractFamilyOps[G] { this: LoopContract[G] =>
+trait LoopContractImpl[G] extends LoopContractFamilyOps[G] {
+ this: LoopContract[G] =>
}
diff --git a/src/col/vct/col/ast/family/loopcontract/LoopInvariantImpl.scala b/src/col/vct/col/ast/family/loopcontract/LoopInvariantImpl.scala
index 5aab279a24..f630b9d90e 100644
--- a/src/col/vct/col/ast/family/loopcontract/LoopInvariantImpl.scala
+++ b/src/col/vct/col/ast/family/loopcontract/LoopInvariantImpl.scala
@@ -4,10 +4,17 @@ import vct.col.ast.LoopInvariant
import vct.col.print._
import vct.col.ast.ops.LoopInvariantOps
-trait LoopInvariantImpl[G] extends LoopInvariantOps[G] { this: LoopInvariant[G] =>
+trait LoopInvariantImpl[G] extends LoopInvariantOps[G] {
+ this: LoopInvariant[G] =>
override def layout(implicit ctx: Ctx): Doc =
Doc.stack(Seq(
Doc.stack(decreases.toSeq),
- DocUtil.clauses(if(ctx.syntax == Ctx.Silver) "invariant" else "loop_invariant", invariant),
+ DocUtil.clauses(
+ if (ctx.syntax == Ctx.Silver)
+ "invariant"
+ else
+ "loop_invariant",
+ invariant,
+ ),
))
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/family/parregion/ParBlockImpl.scala b/src/col/vct/col/ast/family/parregion/ParBlockImpl.scala
index 200700222b..da9f48d639 100644
--- a/src/col/vct/col/ast/family/parregion/ParBlockImpl.scala
+++ b/src/col/vct/col/ast/family/parregion/ParBlockImpl.scala
@@ -9,30 +9,45 @@ import vct.col.util.AstBuildHelpers._
import vct.col.util.Substitute
import vct.col.ast.ops.ParBlockOps
-trait ParBlockImpl[G] extends ParRegionImpl[G] with Declarator[G] with ParBlockOps[G] { this: ParBlock[G] =>
+trait ParBlockImpl[G]
+ extends ParRegionImpl[G] with Declarator[G] with ParBlockOps[G] {
+ this: ParBlock[G] =>
override def declarations: Seq[Declaration[G]] = iters.map(_.variable)
def quantify(expr: Expr[G], blame: Blame[ReceiverNotInjective]): Expr[G] = {
- val quantVars = iters.map(_.variable).map(v => v -> new Variable[G](v.t)(v.o)).toMap
- val body = Substitute(quantVars.map { case (l, r) => Local[G](l.ref) -> Local[G](r.ref) }.toMap[Expr[G], Expr[G]]).dispatch(expr)
+ val quantVars =
+ iters.map(_.variable).map(v => v -> new Variable[G](v.t)(v.o)).toMap
+ val body = Substitute(
+ quantVars.map { case (l, r) => Local[G](l.ref) -> Local[G](r.ref) }
+ .toMap[Expr[G], Expr[G]]
+ ).dispatch(expr)
iters.foldLeft(body)((body, iter) => {
val v = quantVars(iter.variable)
- Starall(Seq(v), Nil, (iter.from <= v.get && v.get < iter.to) ==> body)(blame)
+ Starall(Seq(v), Nil, (iter.from <= v.get && v.get < iter.to) ==> body)(
+ blame
+ )
})
}
override def enterCheckContextRoScopes(context: CheckContext[G]): Int =
context.scopes.size
- override def enterCheckContextRoScopeReason(context: CheckContext[G]): Option[Node[G]] =
- Some(this)
+ override def enterCheckContextRoScopeReason(
+ context: CheckContext[G]
+ ): Option[Node[G]] = Some(this)
- override def enterCheckContextScopes(context: CheckContext[G]): Seq[CheckContext.ScopeFrame[G]] =
- context.withScope(declarations)
+ override def enterCheckContextScopes(
+ context: CheckContext[G]
+ ): Seq[CheckContext.ScopeFrame[G]] = context.withScope(declarations)
override def layout(implicit ctx: Ctx): Doc = {
- val header = Group(Text("par") <+> ctx.name(decl) <>
- (if(iters.nonEmpty) Text("(") <> Doc.args(iters) <> ")" else Empty))
+ val header = Group(
+ Text("par") <+> ctx.name(decl) <>
+ (if (iters.nonEmpty)
+ Text("(") <> Doc.args(iters) <> ")"
+ else
+ Empty)
+ )
val contract = Doc.stack(Seq(
DocUtil.clauses("context_everywhere", context_everywhere),
@@ -42,4 +57,4 @@ trait ParBlockImpl[G] extends ParRegionImpl[G] with Declarator[G] with ParBlockO
Doc.stack(Seq(header, contract)) <+> content.layoutAsBlock
}
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/family/parregion/ParParallelImpl.scala b/src/col/vct/col/ast/family/parregion/ParParallelImpl.scala
index 3cd7223c9f..9a36a3c905 100644
--- a/src/col/vct/col/ast/family/parregion/ParParallelImpl.scala
+++ b/src/col/vct/col/ast/family/parregion/ParParallelImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.ParParallel
import vct.col.print._
import vct.col.ast.ops.ParParallelOps
-trait ParParallelImpl[G] extends ParParallelOps[G] { this: ParParallel[G] =>
+trait ParParallelImpl[G] extends ParParallelOps[G] {
+ this: ParParallel[G] =>
override def layout(implicit ctx: Ctx): Doc =
Text("parallel") <+> "{" <>> Doc.stack(regions) <+/> "}"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/family/parregion/ParRegionImpl.scala b/src/col/vct/col/ast/family/parregion/ParRegionImpl.scala
index dc296ebaf4..7c56b17a11 100644
--- a/src/col/vct/col/ast/family/parregion/ParRegionImpl.scala
+++ b/src/col/vct/col/ast/family/parregion/ParRegionImpl.scala
@@ -6,12 +6,14 @@ import vct.col.check.{CheckContext, CheckError}
import vct.col.origin.{Blame, ParPreconditionFailed}
import vct.col.ast.ops.ParRegionFamilyOps
-trait ParRegionImpl[G] extends NodeFamilyImpl[G] with ParRegionFamilyOps[G] { this: ParRegion[G] =>
+trait ParRegionImpl[G] extends NodeFamilyImpl[G] with ParRegionFamilyOps[G] {
+ this: ParRegion[G] =>
def blame: Blame[ParPreconditionFailed]
override def enterCheckContextRoScopes(context: CheckContext[G]): Int =
context.scopes.size
- override def enterCheckContextRoScopeReason(context: CheckContext[G]): Option[Node[G]] =
- Some(this)
+ override def enterCheckContextRoScopeReason(
+ context: CheckContext[G]
+ ): Option[Node[G]] = Some(this)
}
diff --git a/src/col/vct/col/ast/family/parregion/ParSequentialImpl.scala b/src/col/vct/col/ast/family/parregion/ParSequentialImpl.scala
index b0bdc710c0..bbc2083de3 100644
--- a/src/col/vct/col/ast/family/parregion/ParSequentialImpl.scala
+++ b/src/col/vct/col/ast/family/parregion/ParSequentialImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.ParSequential
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.ParSequentialOps
-trait ParSequentialImpl[G] extends ParSequentialOps[G] { this: ParSequential[G] =>
+trait ParSequentialImpl[G] extends ParSequentialOps[G] {
+ this: ParSequential[G] =>
override def layout(implicit ctx: Ctx): Doc =
Text("sequential") <+> "{" <>> Doc.stack(regions) <+/> "}"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/family/pvlcommunicate/PVLCommunicateImpl.scala b/src/col/vct/col/ast/family/pvlcommunicate/PVLCommunicateImpl.scala
index ae8ed3af2f..a3eaf9a6fe 100644
--- a/src/col/vct/col/ast/family/pvlcommunicate/PVLCommunicateImpl.scala
+++ b/src/col/vct/col/ast/family/pvlcommunicate/PVLCommunicateImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.pvlcommunicate
import vct.col.ast.PVLCommunicate
import vct.col.ast.ops.PVLCommunicateOps
-trait PVLCommunicateImpl[G] extends PVLCommunicateOps[G] { this: PVLCommunicate[G] =>
+trait PVLCommunicateImpl[G] extends PVLCommunicateOps[G] {
+ this: PVLCommunicate[G] =>
}
diff --git a/src/col/vct/col/ast/family/pvlcommunicate/PVLEndpointNameImpl.scala b/src/col/vct/col/ast/family/pvlcommunicate/PVLEndpointNameImpl.scala
index 2a539b2d91..3e0e663699 100644
--- a/src/col/vct/col/ast/family/pvlcommunicate/PVLEndpointNameImpl.scala
+++ b/src/col/vct/col/ast/family/pvlcommunicate/PVLEndpointNameImpl.scala
@@ -4,5 +4,7 @@ import vct.col.ast.PVLEndpointName
import vct.col.ast.ops.PVLEndpointNameOps
import vct.col.ast.ops.{PVLEndpointNameOps, PVLEndpointNameFamilyOps}
-trait PVLEndpointNameImpl[G] extends PVLEndpointNameOps[G] with PVLEndpointNameFamilyOps[G] { this: PVLEndpointName[G] =>
+trait PVLEndpointNameImpl[G]
+ extends PVLEndpointNameOps[G] with PVLEndpointNameFamilyOps[G] {
+ this: PVLEndpointName[G] =>
}
diff --git a/src/col/vct/col/ast/family/seqguard/ChorGuardImpl.scala b/src/col/vct/col/ast/family/seqguard/ChorGuardImpl.scala
index f6e900950d..a40fbf67d0 100644
--- a/src/col/vct/col/ast/family/seqguard/ChorGuardImpl.scala
+++ b/src/col/vct/col/ast/family/seqguard/ChorGuardImpl.scala
@@ -3,7 +3,8 @@ package vct.col.ast.family.seqguard
import vct.col.ast.{Endpoint, Expr, ChorGuard, UnpointedGuard}
import vct.col.ast.ops.ChorGuardFamilyOps
-trait ChorGuardImpl[G] extends ChorGuardFamilyOps[G] { this: ChorGuard[G] =>
+trait ChorGuardImpl[G] extends ChorGuardFamilyOps[G] {
+ this: ChorGuard[G] =>
def condition: Expr[G]
def endpointOpt: Option[Endpoint[G]]
}
diff --git a/src/col/vct/col/ast/family/seqguard/EndpointGuardImpl.scala b/src/col/vct/col/ast/family/seqguard/EndpointGuardImpl.scala
index f6a6d99016..6a96824e98 100644
--- a/src/col/vct/col/ast/family/seqguard/EndpointGuardImpl.scala
+++ b/src/col/vct/col/ast/family/seqguard/EndpointGuardImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.family.seqguard
import vct.col.ast.EndpointGuard
import vct.col.ast.ops.EndpointGuardOps
-trait EndpointGuardImpl[G] extends EndpointGuardOps[G] { this: EndpointGuard[G] =>
+trait EndpointGuardImpl[G] extends EndpointGuardOps[G] {
+ this: EndpointGuard[G] =>
def endpointOpt = Some(endpoint.decl)
}
diff --git a/src/col/vct/col/ast/family/seqguard/UnpointedGuardImpl.scala b/src/col/vct/col/ast/family/seqguard/UnpointedGuardImpl.scala
index 7b5a1a3e25..7c89c4f7ff 100644
--- a/src/col/vct/col/ast/family/seqguard/UnpointedGuardImpl.scala
+++ b/src/col/vct/col/ast/family/seqguard/UnpointedGuardImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.UnpointedGuard
import vct.col.ast.ops.UnpointedGuardOps
import vct.result.VerificationError.Unreachable
-trait UnpointedGuardImpl[G] extends UnpointedGuardOps[G] { this: UnpointedGuard[G] =>
+trait UnpointedGuardImpl[G] extends UnpointedGuardOps[G] {
+ this: UnpointedGuard[G] =>
def endpointOpt = None
}
diff --git a/src/col/vct/col/ast/family/seqrun/ChorRunImpl.scala b/src/col/vct/col/ast/family/seqrun/ChorRunImpl.scala
index 657b196ae0..efced73456 100644
--- a/src/col/vct/col/ast/family/seqrun/ChorRunImpl.scala
+++ b/src/col/vct/col/ast/family/seqrun/ChorRunImpl.scala
@@ -5,7 +5,8 @@ import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.{ChorRunOps, ChorRunFamilyOps}
import vct.col.ast.ops.{ChorRunOps, ChorRunFamilyOps}
-trait ChorRunImpl[G] extends ChorRunOps[G] with ChorRunFamilyOps[G] { this: ChorRun[G] =>
+trait ChorRunImpl[G] extends ChorRunOps[G] with ChorRunFamilyOps[G] {
+ this: ChorRun[G] =>
override def layout(implicit ctx: Ctx): Doc = {
contract.show > Text("seq_run") <+> this.body.show
}
diff --git a/src/col/vct/col/ast/family/signals/SignalsClauseImpl.scala b/src/col/vct/col/ast/family/signals/SignalsClauseImpl.scala
index e8562a38f6..65353cf7e2 100644
--- a/src/col/vct/col/ast/family/signals/SignalsClauseImpl.scala
+++ b/src/col/vct/col/ast/family/signals/SignalsClauseImpl.scala
@@ -5,9 +5,13 @@ import vct.col.ast.util.Declarator
import vct.col.print.{Ctx, Doc, Text, Group}
import vct.col.ast.ops.{SignalsClauseOps, SignalsClauseFamilyOps}
-trait SignalsClauseImpl[G] extends Declarator[G] with SignalsClauseOps[G] with SignalsClauseFamilyOps[G] { this: SignalsClause[G] =>
+trait SignalsClauseImpl[G]
+ extends Declarator[G]
+ with SignalsClauseOps[G]
+ with SignalsClauseFamilyOps[G] {
+ this: SignalsClause[G] =>
override def declarations: Seq[Declaration[G]] = Seq(binding)
override def layout(implicit ctx: Ctx): Doc =
Group(Text("signals") <+> "(" <> binding <> ")" <>> assn)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/AmbiguousTruncModImpl.scala b/src/col/vct/col/ast/lang/c/AmbiguousTruncModImpl.scala
index 256562db2e..ea78abb35b 100644
--- a/src/col/vct/col/ast/lang/c/AmbiguousTruncModImpl.scala
+++ b/src/col/vct/col/ast/lang/c/AmbiguousTruncModImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.AmbiguousTruncMod
import vct.col.ast.ops.AmbiguousTruncModOps
import vct.col.print._
-trait AmbiguousTruncModImpl[G] extends AmbiguousTruncModOps[G] { this: AmbiguousTruncMod[G] =>
+trait AmbiguousTruncModImpl[G] extends AmbiguousTruncModOps[G] {
+ this: AmbiguousTruncMod[G] =>
override def precedence: Int = Precedence.MULTIPLICATIVE
override def layout(implicit ctx: Ctx): Doc = lassoc(left, "%", right)
}
diff --git a/src/col/vct/col/ast/lang/c/CAbstractDeclarationImpl.scala b/src/col/vct/col/ast/lang/c/CAbstractDeclarationImpl.scala
index fdf49da510..0da9b5823b 100644
--- a/src/col/vct/col/ast/lang/c/CAbstractDeclarationImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CAbstractDeclarationImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.lang.c
import vct.col.ast.CAbstractDeclaration
-trait CAbstractDeclarationImpl[G] { this: CAbstractDeclaration[G] =>
+trait CAbstractDeclarationImpl[G] {
+ this: CAbstractDeclaration[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CAlignmentSpecifierImpl.scala b/src/col/vct/col/ast/lang/c/CAlignmentSpecifierImpl.scala
index f69e87c56d..9636e52d44 100644
--- a/src/col/vct/col/ast/lang/c/CAlignmentSpecifierImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CAlignmentSpecifierImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.lang.c
import vct.col.ast.CAlignmentSpecifier
-trait CAlignmentSpecifierImpl[G] { this: CAlignmentSpecifier[G] =>
+trait CAlignmentSpecifierImpl[G] {
+ this: CAlignmentSpecifier[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CAnonymousFunctionDeclaratorImpl.scala b/src/col/vct/col/ast/lang/c/CAnonymousFunctionDeclaratorImpl.scala
index 67914a743f..b43f0bb83c 100644
--- a/src/col/vct/col/ast/lang/c/CAnonymousFunctionDeclaratorImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CAnonymousFunctionDeclaratorImpl.scala
@@ -4,7 +4,9 @@ import vct.col.ast.CAnonymousFunctionDeclarator
import vct.col.ast.ops.CAnonymousFunctionDeclaratorOps
import vct.col.print._
-trait CAnonymousFunctionDeclaratorImpl[G] extends CAnonymousFunctionDeclaratorOps[G] { this: CAnonymousFunctionDeclarator[G] =>
+trait CAnonymousFunctionDeclaratorImpl[G]
+ extends CAnonymousFunctionDeclaratorOps[G] {
+ this: CAnonymousFunctionDeclarator[G] =>
override def layout(implicit ctx: Ctx): Doc =
Group(inner.show <> "(" <> Doc.args(params.map(Text)) <> ")")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CArrayDeclaratorImpl.scala b/src/col/vct/col/ast/lang/c/CArrayDeclaratorImpl.scala
index d73dfd3e22..d227babf9e 100644
--- a/src/col/vct/col/ast/lang/c/CArrayDeclaratorImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CArrayDeclaratorImpl.scala
@@ -4,7 +4,10 @@ import vct.col.ast.CArrayDeclarator
import vct.col.ast.ops.CArrayDeclaratorOps
import vct.col.print.{Ctx, Doc, Group}
-trait CArrayDeclaratorImpl[G] extends CArrayDeclaratorOps[G] { this: CArrayDeclarator[G] =>
+trait CArrayDeclaratorImpl[G] extends CArrayDeclaratorOps[G] {
+ this: CArrayDeclarator[G] =>
override def layout(implicit ctx: Ctx): Doc =
- Group(inner.show <> "[" <> Doc.arg(Doc.stack(qualifiers ++ size.toSeq)) <> "]")
-}
\ No newline at end of file
+ Group(
+ inner.show <> "[" <> Doc.arg(Doc.stack(qualifiers ++ size.toSeq)) <> "]"
+ )
+}
diff --git a/src/col/vct/col/ast/lang/c/CAtomicImpl.scala b/src/col/vct/col/ast/lang/c/CAtomicImpl.scala
index acca1d368c..a9452337ce 100644
--- a/src/col/vct/col/ast/lang/c/CAtomicImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CAtomicImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CAtomic
import vct.col.ast.ops.CAtomicOps
import vct.col.print.{Ctx, Doc, Text}
-trait CAtomicImpl[G] extends CAtomicOps[G] { this: CAtomic[G] =>
+trait CAtomicImpl[G] extends CAtomicOps[G] {
+ this: CAtomic[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("_Atomic")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CBoolImpl.scala b/src/col/vct/col/ast/lang/c/CBoolImpl.scala
index 613e37503f..234384e9f9 100644
--- a/src/col/vct/col/ast/lang/c/CBoolImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CBoolImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CBool
import vct.col.ast.ops.CBoolOps
import vct.col.print.{Ctx, Doc, Text}
-trait CBoolImpl[G] extends CBoolOps[G] { this: CBool[G] =>
+trait CBoolImpl[G] extends CBoolOps[G] {
+ this: CBool[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("_Bool")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CCastImpl.scala b/src/col/vct/col/ast/lang/c/CCastImpl.scala
index f818755f3f..7e2d8488ec 100644
--- a/src/col/vct/col/ast/lang/c/CCastImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CCastImpl.scala
@@ -5,10 +5,12 @@ import vct.col.print.Doc.{arg, fold}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.CCastOps
-trait CCastImpl[G] extends CCastOps[G] { this: CCast[G] =>
+trait CCastImpl[G] extends CCastOps[G] {
+ this: CCast[G] =>
override def t: Type[G] = castType
override def precedence = Precedence.ATOMIC
- override def layout(implicit ctx: Ctx): Doc = Text("(") <> t <> ")" <> assoc(expr)
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ Text("(") <> t <> ")" <> assoc(expr)
+}
diff --git a/src/col/vct/col/ast/lang/c/CCharImpl.scala b/src/col/vct/col/ast/lang/c/CCharImpl.scala
index 38d2a3602b..950a18cd18 100644
--- a/src/col/vct/col/ast/lang/c/CCharImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CCharImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CChar
import vct.col.ast.ops.CCharOps
import vct.col.print.{Ctx, Doc, Text}
-trait CCharImpl[G] extends CCharOps[G] { this: CChar[G] =>
+trait CCharImpl[G] extends CCharOps[G] {
+ this: CChar[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("char")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CConstImpl.scala b/src/col/vct/col/ast/lang/c/CConstImpl.scala
index 209faac224..7dc42ed017 100644
--- a/src/col/vct/col/ast/lang/c/CConstImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CConstImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CConst
import vct.col.ast.ops.CConstOps
import vct.col.print.{Ctx, Doc, Text}
-trait CConstImpl[G] extends CConstOps[G] { this: CConst[G] =>
+trait CConstImpl[G] extends CConstOps[G] {
+ this: CConst[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("const")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CDeclarationImpl.scala b/src/col/vct/col/ast/lang/c/CDeclarationImpl.scala
index ea69bb27ac..c0bf5af319 100644
--- a/src/col/vct/col/ast/lang/c/CDeclarationImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CDeclarationImpl.scala
@@ -5,8 +5,11 @@ import vct.col.ast.{CDeclaration, TResource}
import vct.col.check.{CheckContext, CheckError}
import vct.col.print._
-trait CDeclarationImpl[G] extends CDeclarationOps[G] with CDeclarationFamilyOps[G] { this: CDeclaration[G] =>
- override def check(context: CheckContext[G]): Seq[CheckError] = kernelInvariant.checkSubType(TResource())
+trait CDeclarationImpl[G]
+ extends CDeclarationOps[G] with CDeclarationFamilyOps[G] {
+ this: CDeclaration[G] =>
+ override def check(context: CheckContext[G]): Seq[CheckError] =
+ kernelInvariant.checkSubType(TResource())
// PB: Please keep in sync with ApplicableContractImpl
def layoutContract(implicit ctx: Ctx): Doc =
@@ -22,10 +25,5 @@ trait CDeclarationImpl[G] extends CDeclarationOps[G] with CDeclarationFamilyOps[
))
override def layout(implicit ctx: Ctx): Doc =
- Doc.stack(Seq(
- layoutContract,
- Group(
- Doc.spread(specs) <>> Doc.args(inits)
- ),
- ))
-}
\ No newline at end of file
+ Doc.stack(Seq(layoutContract, Group(Doc.spread(specs) <>> Doc.args(inits))))
+}
diff --git a/src/col/vct/col/ast/lang/c/CDeclarationSpecifierImpl.scala b/src/col/vct/col/ast/lang/c/CDeclarationSpecifierImpl.scala
index 2ffaa806f4..55a2a80f29 100644
--- a/src/col/vct/col/ast/lang/c/CDeclarationSpecifierImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CDeclarationSpecifierImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.lang.c
import vct.col.ast.CDeclarationSpecifier
import vct.col.ast.ops.CDeclarationSpecifierFamilyOps
-trait CDeclarationSpecifierImpl[G] extends CDeclarationSpecifierFamilyOps[G] { this: CDeclarationSpecifier[G] =>
+trait CDeclarationSpecifierImpl[G] extends CDeclarationSpecifierFamilyOps[G] {
+ this: CDeclarationSpecifier[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CDeclarationStatementImpl.scala b/src/col/vct/col/ast/lang/c/CDeclarationStatementImpl.scala
index 633d2794d9..6505ca9dd3 100644
--- a/src/col/vct/col/ast/lang/c/CDeclarationStatementImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CDeclarationStatementImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CDeclarationStatement
import vct.col.ast.ops.CDeclarationStatementOps
import vct.col.print.{Ctx, Doc}
-trait CDeclarationStatementImpl[G] extends CDeclarationStatementOps[G] { this: CDeclarationStatement[G] =>
+trait CDeclarationStatementImpl[G] extends CDeclarationStatementOps[G] {
+ this: CDeclarationStatement[G] =>
override def layout(implicit ctx: Ctx): Doc = decl.show <> ";"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CDeclaratorImpl.scala b/src/col/vct/col/ast/lang/c/CDeclaratorImpl.scala
index 96c17fa875..1871d85ff8 100644
--- a/src/col/vct/col/ast/lang/c/CDeclaratorImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CDeclaratorImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.lang.c
import vct.col.ast.CDeclarator
import vct.col.ast.ops.CDeclaratorFamilyOps
-trait CDeclaratorImpl[G] extends CDeclaratorFamilyOps[G] { this: CDeclarator[G] =>
+trait CDeclaratorImpl[G] extends CDeclaratorFamilyOps[G] {
+ this: CDeclarator[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CDoubleImpl.scala b/src/col/vct/col/ast/lang/c/CDoubleImpl.scala
index 2994edcd38..2ae57502c0 100644
--- a/src/col/vct/col/ast/lang/c/CDoubleImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CDoubleImpl.scala
@@ -4,6 +4,7 @@ import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.CDouble
import vct.col.ast.ops.CDoubleOps
-trait CDoubleImpl[G] extends CDoubleOps[G] { this: CDouble[G] =>
- override def layout(implicit ctx: Ctx): Doc = Text("double")
-}
\ No newline at end of file
+trait CDoubleImpl[G] extends CDoubleOps[G] {
+ this: CDouble[G] =>
+ override def layout(implicit ctx: Ctx): Doc = Text("double")
+}
diff --git a/src/col/vct/col/ast/lang/c/CExprImpl.scala b/src/col/vct/col/ast/lang/c/CExprImpl.scala
index b13cfca592..892e63adb1 100644
--- a/src/col/vct/col/ast/lang/c/CExprImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CExprImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.lang.c
import vct.col.ast.CExpr
-trait CExprImpl[G] { this: CExpr[G] =>
+trait CExprImpl[G] {
+ this: CExpr[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CExternImpl.scala b/src/col/vct/col/ast/lang/c/CExternImpl.scala
index 09fb7aeeed..9e12da9a22 100644
--- a/src/col/vct/col/ast/lang/c/CExternImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CExternImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CExtern
import vct.col.ast.ops.CExternOps
import vct.col.print.{Ctx, Doc, Text}
-trait CExternImpl[G] extends CExternOps[G] { this: CExtern[G] =>
+trait CExternImpl[G] extends CExternOps[G] {
+ this: CExtern[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("extern")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CFieldAccessImpl.scala b/src/col/vct/col/ast/lang/c/CFieldAccessImpl.scala
index 2c7bea5430..08c328f41f 100644
--- a/src/col/vct/col/ast/lang/c/CFieldAccessImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CFieldAccessImpl.scala
@@ -1,43 +1,61 @@
package vct.col.ast.lang.c
-import vct.col.ast.{CFieldAccess, CPrimitiveType, CSpecificationType, TCInt, TEnum, TOpenCLVector, Type}
+import vct.col.ast.{
+ CFieldAccess,
+ CPrimitiveType,
+ CSpecificationType,
+ TCInt,
+ TEnum,
+ TOpenCLVector,
+ Type,
+}
import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.resolve.ctx._
import vct.col.typerules.Types
import vct.col.ast.ops.CFieldAccessOps
import vct.col.resolve.lang.C
-trait CFieldAccessImpl[G] extends CFieldAccessOps[G] { this: CFieldAccess[G] =>
- override lazy val t: Type[G] = ref.get match {
- case ref: RefCStructField[G] => C.typeOrReturnTypeFromDeclaration(ref.decls.specs, ref.decls.decls(ref.idx))
- case ref: RefOpenCLVectorMembers[G] =>
- val innerType = obj.t match {
- case CPrimitiveType(Seq(CSpecificationType(v: TOpenCLVector[G]))) => v.innerType
- case v: TOpenCLVector[G] => v.innerType
- case _ => ???
- }
+trait CFieldAccessImpl[G] extends CFieldAccessOps[G] {
+ this: CFieldAccess[G] =>
+ override lazy val t: Type[G] =
+ ref.get match {
+ case ref: RefCStructField[G] =>
+ C.typeOrReturnTypeFromDeclaration(
+ ref.decls.specs,
+ ref.decls.decls(ref.idx),
+ )
+ case ref: RefOpenCLVectorMembers[G] =>
+ val innerType =
+ obj.t match {
+ case CPrimitiveType(Seq(CSpecificationType(v: TOpenCLVector[G]))) =>
+ v.innerType
+ case v: TOpenCLVector[G] => v.innerType
+ case _ => ???
+ }
- if(ref.idx.size == 1) innerType
- else if(ref.idx.size > 1) TOpenCLVector(ref.idx.size, innerType)
- else ???
- case ref: RefModelField[G] => ref.decl.t
- case ref: RefFunction[G] => Types.notAValue(ref)
- case ref: RefProcedure[G] => Types.notAValue(ref)
- case ref: RefPredicate[G] => Types.notAValue(ref)
- case ref: RefInstanceFunction[G] => Types.notAValue(ref)
- case ref: RefInstanceMethod[G] => Types.notAValue(ref)
- case ref: RefInstancePredicate[G] => Types.notAValue(ref)
- case ref: RefADTFunction[G] => Types.notAValue(ref)
- case ref: RefModelProcess[G] => Types.notAValue(ref)
- case ref: RefModelAction[G] => Types.notAValue(ref)
- case ref: BuiltinField[G] => ref.f(obj).t
- case ref: BuiltinInstanceMethod[G] => Types.notAValue(ref)
- case ref: RefCudaVecDim[G] => TCInt()
- case RefEnumConstant(enum, _) => TEnum(enum.get.ref)
- case RefProverFunction(decl) => decl.returnType
- }
+ if (ref.idx.size == 1)
+ innerType
+ else if (ref.idx.size > 1)
+ TOpenCLVector(ref.idx.size, innerType)
+ else
+ ???
+ case ref: RefModelField[G] => ref.decl.t
+ case ref: RefFunction[G] => Types.notAValue(ref)
+ case ref: RefProcedure[G] => Types.notAValue(ref)
+ case ref: RefPredicate[G] => Types.notAValue(ref)
+ case ref: RefInstanceFunction[G] => Types.notAValue(ref)
+ case ref: RefInstanceMethod[G] => Types.notAValue(ref)
+ case ref: RefInstancePredicate[G] => Types.notAValue(ref)
+ case ref: RefADTFunction[G] => Types.notAValue(ref)
+ case ref: RefModelProcess[G] => Types.notAValue(ref)
+ case ref: RefModelAction[G] => Types.notAValue(ref)
+ case ref: BuiltinField[G] => ref.f(obj).t
+ case ref: BuiltinInstanceMethod[G] => Types.notAValue(ref)
+ case ref: RefCudaVecDim[G] => TCInt()
+ case RefEnumConstant(enum, _) => TEnum(enum.get.ref)
+ case RefProverFunction(decl) => decl.returnType
+ }
override def precedence: Int = Precedence.POSTFIX
- override def layout(implicit ctx: Ctx): Doc =
- assoc(obj) <> "." <> field
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc = assoc(obj) <> "." <> field
+}
diff --git a/src/col/vct/col/ast/lang/c/CFloatImpl.scala b/src/col/vct/col/ast/lang/c/CFloatImpl.scala
index a3cf473e85..0fddfb7360 100644
--- a/src/col/vct/col/ast/lang/c/CFloatImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CFloatImpl.scala
@@ -4,6 +4,7 @@ import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.CFloat
import vct.col.ast.ops.CFloatOps
-trait CFloatImpl[G] extends CFloatOps[G] { this: CFloat[G] =>
- override def layout(implicit ctx: Ctx): Doc = Text("float")
-}
\ No newline at end of file
+trait CFloatImpl[G] extends CFloatOps[G] {
+ this: CFloat[G] =>
+ override def layout(implicit ctx: Ctx): Doc = Text("float")
+}
diff --git a/src/col/vct/col/ast/lang/c/CFunctionDefinitionImpl.scala b/src/col/vct/col/ast/lang/c/CFunctionDefinitionImpl.scala
index c02cb416be..3ccc037fb7 100644
--- a/src/col/vct/col/ast/lang/c/CFunctionDefinitionImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CFunctionDefinitionImpl.scala
@@ -4,12 +4,11 @@ import vct.col.ast.CFunctionDefinition
import vct.col.ast.ops.CFunctionDefinitionOps
import vct.col.print.{Ctx, Doc, Group}
-trait CFunctionDefinitionImpl[G] extends CFunctionDefinitionOps[G] { this: CFunctionDefinition[G] =>
+trait CFunctionDefinitionImpl[G] extends CFunctionDefinitionOps[G] {
+ this: CFunctionDefinition[G] =>
override def layout(implicit ctx: Ctx): Doc =
Doc.stack(Seq(
contract,
- Group(
- Doc.spread(specs) <>> declarator
- ) <+> body.layoutAsBlock,
+ Group(Doc.spread(specs) <>> declarator) <+> body.layoutAsBlock,
))
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CFunctionSpecifierImpl.scala b/src/col/vct/col/ast/lang/c/CFunctionSpecifierImpl.scala
index af4f5d44b8..424c53d6d4 100644
--- a/src/col/vct/col/ast/lang/c/CFunctionSpecifierImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CFunctionSpecifierImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.lang.c
import vct.col.ast.CFunctionSpecifier
-trait CFunctionSpecifierImpl[G] { this: CFunctionSpecifier[G] =>
+trait CFunctionSpecifierImpl[G] {
+ this: CFunctionSpecifier[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CGlobalDeclarationImpl.scala b/src/col/vct/col/ast/lang/c/CGlobalDeclarationImpl.scala
index 69d5e98489..b3976af6b8 100644
--- a/src/col/vct/col/ast/lang/c/CGlobalDeclarationImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CGlobalDeclarationImpl.scala
@@ -4,7 +4,7 @@ import vct.col.ast.CGlobalDeclaration
import vct.col.ast.ops.CGlobalDeclarationOps
import vct.col.print._
-trait CGlobalDeclarationImpl[G] extends CGlobalDeclarationOps[G] { this: CGlobalDeclaration[G] =>
- override def layout(implicit ctx: Ctx): Doc =
- decl.show <> ";"
-}
\ No newline at end of file
+trait CGlobalDeclarationImpl[G] extends CGlobalDeclarationOps[G] {
+ this: CGlobalDeclaration[G] =>
+ override def layout(implicit ctx: Ctx): Doc = decl.show <> ";"
+}
diff --git a/src/col/vct/col/ast/lang/c/CGotoImpl.scala b/src/col/vct/col/ast/lang/c/CGotoImpl.scala
index 3785b17b50..873f0d938b 100644
--- a/src/col/vct/col/ast/lang/c/CGotoImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CGotoImpl.scala
@@ -4,7 +4,7 @@ import vct.col.ast.CGoto
import vct.col.ast.ops.CGotoOps
import vct.col.print.{Ctx, Doc, Text}
-trait CGotoImpl[G] extends CGotoOps[G] { this: CGoto[G] =>
- override def layout(implicit ctx: Ctx): Doc =
- Text("goto") <+> label <> ";"
-}
\ No newline at end of file
+trait CGotoImpl[G] extends CGotoOps[G] {
+ this: CGoto[G] =>
+ override def layout(implicit ctx: Ctx): Doc = Text("goto") <+> label <> ";"
+}
diff --git a/src/col/vct/col/ast/lang/c/CGpgpuKernelSpecifierImpl.scala b/src/col/vct/col/ast/lang/c/CGpgpuKernelSpecifierImpl.scala
index ae6b53c2e9..9200778932 100644
--- a/src/col/vct/col/ast/lang/c/CGpgpuKernelSpecifierImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CGpgpuKernelSpecifierImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.lang.c
import vct.col.ast.CGpgpuKernelSpecifier
import vct.col.origin.{Blame, KernelFailure}
-trait CGpgpuKernelSpecifierImpl[G] { this: CGpgpuKernelSpecifier[G] =>
+trait CGpgpuKernelSpecifierImpl[G] {
+ this: CGpgpuKernelSpecifier[G] =>
def blame: Blame[KernelFailure]
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CInitImpl.scala b/src/col/vct/col/ast/lang/c/CInitImpl.scala
index f6b65c4fa9..f648c4164b 100644
--- a/src/col/vct/col/ast/lang/c/CInitImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CInitImpl.scala
@@ -4,7 +4,11 @@ import vct.col.ast.CInit
import vct.col.ast.ops.{CInitFamilyOps, CInitOps}
import vct.col.print.{Ctx, Doc, Group}
-trait CInitImpl[G] extends CInitOps[G] with CInitFamilyOps[G] { this: CInit[G] =>
+trait CInitImpl[G] extends CInitOps[G] with CInitFamilyOps[G] {
+ this: CInit[G] =>
override def layout(implicit ctx: Ctx): Doc =
- if(init.isEmpty) decl.show else Group(decl.show <+> "=" <>> init.get)
-}
\ No newline at end of file
+ if (init.isEmpty)
+ decl.show
+ else
+ Group(decl.show <+> "=" <>> init.get)
+}
diff --git a/src/col/vct/col/ast/lang/c/CInlineImpl.scala b/src/col/vct/col/ast/lang/c/CInlineImpl.scala
index 4943cc63ab..a3ff453e88 100644
--- a/src/col/vct/col/ast/lang/c/CInlineImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CInlineImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CInline
import vct.col.ast.ops.CInlineOps
import vct.col.print.{Ctx, Doc, Text}
-trait CInlineImpl[G] extends CInlineOps[G] { this: CInline[G] =>
+trait CInlineImpl[G] extends CInlineOps[G] {
+ this: CInline[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("inline")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CIntImpl.scala b/src/col/vct/col/ast/lang/c/CIntImpl.scala
index 3aa4cf2aaf..eb17b77c94 100644
--- a/src/col/vct/col/ast/lang/c/CIntImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CIntImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CInt
import vct.col.ast.ops.CIntOps
import vct.col.print.{Ctx, Doc, Text}
-trait CIntImpl[G] extends CIntOps[G] { this: CInt[G] =>
+trait CIntImpl[G] extends CIntOps[G] {
+ this: CInt[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("int")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CInvocationImpl.scala b/src/col/vct/col/ast/lang/c/CInvocationImpl.scala
index 14d501bdd4..f6db4c5ea8 100644
--- a/src/col/vct/col/ast/lang/c/CInvocationImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CInvocationImpl.scala
@@ -7,29 +7,44 @@ import vct.col.resolve.ctx._
import vct.col.resolve.lang.C
import vct.result.VerificationError.Unreachable
-trait CInvocationImpl[G] extends CInvocationOps[G] { this: CInvocation[G] =>
- override lazy val t: Type[G] = ref.get match {
- case RefFunction(decl) => decl.returnType
- case RefProcedure(decl) => decl.returnType
- case RefPredicate(decl) => decl.returnType
- case RefADTFunction(decl) => decl.returnType
- case RefModelProcess(decl) => decl.returnType
- case RefModelAction(decl) => decl.returnType
- case RefOpenCLVectorLiteralCInvocationTarget(size, t) => TOpenCLVector(size, t)
- case RefCFunctionDefinition(decl) => C.typeOrReturnTypeFromDeclaration(decl.specs, decl.declarator)
- case RefCGlobalDeclaration(decls, initIdx) => C.typeOrReturnTypeFromDeclaration(decls.decl.specs, decls.decl.inits(initIdx).decl)
- case RefProverFunction(decl) => decl.returnType
- case RefInstanceMethod(decl) => decl.returnType
- case RefInstanceFunction(decl) => decl.returnType
- case RefInstancePredicate(decl) => decl.returnType
- case BuiltinInstanceMethod(f) => applicable match {
- case CFieldAccess(obj, _) => f(obj)(args).t
- case other => throw Unreachable("BuiltinInstanceMethod resolution of CInvocation must invoke a CStructAccess.")
+trait CInvocationImpl[G] extends CInvocationOps[G] {
+ this: CInvocation[G] =>
+ override lazy val t: Type[G] =
+ ref.get match {
+ case RefFunction(decl) => decl.returnType
+ case RefProcedure(decl) => decl.returnType
+ case RefPredicate(decl) => decl.returnType
+ case RefADTFunction(decl) => decl.returnType
+ case RefModelProcess(decl) => decl.returnType
+ case RefModelAction(decl) => decl.returnType
+ case RefOpenCLVectorLiteralCInvocationTarget(size, t) =>
+ TOpenCLVector(size, t)
+ case RefCFunctionDefinition(decl) =>
+ C.typeOrReturnTypeFromDeclaration(decl.specs, decl.declarator)
+ case RefCGlobalDeclaration(decls, initIdx) =>
+ C.typeOrReturnTypeFromDeclaration(
+ decls.decl.specs,
+ decls.decl.inits(initIdx).decl,
+ )
+ case RefProverFunction(decl) => decl.returnType
+ case RefInstanceMethod(decl) => decl.returnType
+ case RefInstanceFunction(decl) => decl.returnType
+ case RefInstancePredicate(decl) => decl.returnType
+ case BuiltinInstanceMethod(f) =>
+ applicable match {
+ case CFieldAccess(obj, _) => f(obj)(args).t
+ case other =>
+ throw Unreachable(
+ "BuiltinInstanceMethod resolution of CInvocation must invoke a CStructAccess."
+ )
+ }
}
- }
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
- Group(assoc(applicable) <> "(" <> Doc.args(args) <> ")" <> DocUtil.givenYields(givenArgs, yields))
-}
\ No newline at end of file
+ Group(
+ assoc(applicable) <> "(" <> Doc.args(args) <> ")" <>
+ DocUtil.givenYields(givenArgs, yields)
+ )
+}
diff --git a/src/col/vct/col/ast/lang/c/CLiteralArrayImpl.scala b/src/col/vct/col/ast/lang/c/CLiteralArrayImpl.scala
index adee02947b..093df9f3a9 100644
--- a/src/col/vct/col/ast/lang/c/CLiteralArrayImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CLiteralArrayImpl.scala
@@ -5,10 +5,12 @@ import vct.col.print.Doc.{arg, fold}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.CLiteralArrayOps
-trait CLiteralArrayImpl[G] extends CLiteralArrayOps[G] { this: CLiteralArray[G] =>
+trait CLiteralArrayImpl[G] extends CLiteralArrayOps[G] {
+ this: CLiteralArray[G] =>
override def t: Type[G] = new TNotAValue()
override def precedence = Precedence.ATOMIC
- override def layout(implicit ctx: Ctx): Doc = Text("{") <> arg(fold(exprs)(_ <> "," <+> _)) <> "}"
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ Text("{") <> arg(fold(exprs)(_ <> "," <+> _)) <> "}"
+}
diff --git a/src/col/vct/col/ast/lang/c/CLocalDeclarationImpl.scala b/src/col/vct/col/ast/lang/c/CLocalDeclarationImpl.scala
index 8e292b07ad..c00a17133e 100644
--- a/src/col/vct/col/ast/lang/c/CLocalDeclarationImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CLocalDeclarationImpl.scala
@@ -4,6 +4,8 @@ import vct.col.ast.CLocalDeclaration
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.{CLocalDeclarationOps, CLocalDeclarationFamilyOps}
-trait CLocalDeclarationImpl[G] extends CLocalDeclarationOps[G] with CLocalDeclarationFamilyOps[G] { this: CLocalDeclaration[G] =>
+trait CLocalDeclarationImpl[G]
+ extends CLocalDeclarationOps[G] with CLocalDeclarationFamilyOps[G] {
+ this: CLocalDeclaration[G] =>
override def layout(implicit ctx: Ctx): Doc = decl.show
}
diff --git a/src/col/vct/col/ast/lang/c/CLocalImpl.scala b/src/col/vct/col/ast/lang/c/CLocalImpl.scala
index c8ebb7d5d0..f5e14ba194 100644
--- a/src/col/vct/col/ast/lang/c/CLocalImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CLocalImpl.scala
@@ -7,32 +7,46 @@ import vct.col.resolve.ctx._
import vct.col.resolve.lang.C
import vct.col.typerules.Types
-trait CLocalImpl[G] extends CLocalOps[G] { this: CLocal[G] =>
- override lazy val t: Type[G] = ref.get match {
- case ref: RefCParam[G] => C.typeOrReturnTypeFromDeclaration(ref.decl.specifiers, ref.decl.declarator)
- case ref: RefAxiomaticDataType[G] => Types.notAValue(ref)
- case RefVariable(decl) => decl.t
- case ref: RefCFunctionDefinition[G] => Types.notAValue(ref)
- case ref: RefCStruct[G] => Types.notAValue(ref)
- case ref @ RefCGlobalDeclaration(decls, initIdx) =>
- val declInfo = C.getDeclaratorInfo(decls.decl.inits(initIdx).decl)
- declInfo.params match {
- case Some(_) => Types.notAValue(ref) // Function declaration
- case None => declInfo.typeOrReturnType(CPrimitiveType(decls.decl.specs)) // Static declaration
- }
- case ref @ RefCLocalDeclaration(decls, initIdx) =>
- val declInfo = C.getDeclaratorInfo(decls.decl.inits(initIdx).decl)
- declInfo.params match {
- case Some(_) => Types.notAValue(ref) // Function declaration
- case None => declInfo.typeOrReturnType(CPrimitiveType(decls.decl.specs)) // Static declaration
- }
- case RefModelField(field) => field.t
- case target: SpecInvocationTarget[G] => Types.notAValue(target)
- case _: RefCudaVec[G] => CTCudaVec()
- case cls: RefClass[G] => Types.notAValue(cls)
- case enum: RefEnum[G] => Types.notAValue(enum)
- case RefEnumConstant(enum, _) => TEnum(enum.get.ref)
- }
+trait CLocalImpl[G] extends CLocalOps[G] {
+ this: CLocal[G] =>
+ override lazy val t: Type[G] =
+ ref.get match {
+ case ref: RefCParam[G] =>
+ C.typeOrReturnTypeFromDeclaration(
+ ref.decl.specifiers,
+ ref.decl.declarator,
+ )
+ case ref: RefAxiomaticDataType[G] => Types.notAValue(ref)
+ case RefVariable(decl) => decl.t
+ case ref: RefCFunctionDefinition[G] => Types.notAValue(ref)
+ case ref: RefCStruct[G] => Types.notAValue(ref)
+ case ref @ RefCGlobalDeclaration(decls, initIdx) =>
+ val declInfo = C.getDeclaratorInfo(decls.decl.inits(initIdx).decl)
+ declInfo.params match {
+ case Some(_) => Types.notAValue(ref) // Function declaration
+ case None =>
+ declInfo
+ .typeOrReturnType(CPrimitiveType(
+ decls.decl.specs
+ )) // Static declaration
+ }
+ case ref @ RefCLocalDeclaration(decls, initIdx) =>
+ val declInfo = C.getDeclaratorInfo(decls.decl.inits(initIdx).decl)
+ declInfo.params match {
+ case Some(_) => Types.notAValue(ref) // Function declaration
+ case None =>
+ declInfo
+ .typeOrReturnType(CPrimitiveType(
+ decls.decl.specs
+ )) // Static declaration
+ }
+ case RefModelField(field) => field.t
+ case target: SpecInvocationTarget[G] => Types.notAValue(target)
+ case _: RefCudaVec[G] => CTCudaVec()
+ case cls: RefClass[G] => Types.notAValue(cls)
+ case enum: RefEnum[G] => Types.notAValue(enum)
+ case RefEnumConstant(enum, _) => TEnum(enum.get.ref)
+ }
override def layout(implicit ctx: Ctx): Doc = Text(name)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CLongImpl.scala b/src/col/vct/col/ast/lang/c/CLongImpl.scala
index c64d6f21d3..cd194f77ae 100644
--- a/src/col/vct/col/ast/lang/c/CLongImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CLongImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CLong
import vct.col.ast.ops.CLongOps
import vct.col.print.{Ctx, Doc, Text}
-trait CLongImpl[G] extends CLongOps[G] { this: CLong[G] =>
+trait CLongImpl[G] extends CLongOps[G] {
+ this: CLong[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("long")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CNameImpl.scala b/src/col/vct/col/ast/lang/c/CNameImpl.scala
index 9a92099ea8..d1087c9227 100644
--- a/src/col/vct/col/ast/lang/c/CNameImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CNameImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CName
import vct.col.ast.ops.CNameOps
import vct.col.print.{Ctx, Doc, Text}
-trait CNameImpl[G] extends CNameOps[G] { this: CName[G] =>
+trait CNameImpl[G] extends CNameOps[G] {
+ this: CName[G] =>
override def layout(implicit ctx: Ctx): Doc = Text(name)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CParamImpl.scala b/src/col/vct/col/ast/lang/c/CParamImpl.scala
index c2d982405c..88fbec2c0c 100644
--- a/src/col/vct/col/ast/lang/c/CParamImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CParamImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.CParam
import vct.col.ast.ops.{CParamFamilyOps, CParamOps}
import vct.col.print.{Ctx, Doc}
-trait CParamImpl[G] extends CParamOps[G] with CParamFamilyOps[G] { this: CParam[G] =>
+trait CParamImpl[G] extends CParamOps[G] with CParamFamilyOps[G] {
+ this: CParam[G] =>
override def layout(implicit ctx: Ctx): Doc =
Doc.spread(specifiers) <+> declarator
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CPointerDeclaratorImpl.scala b/src/col/vct/col/ast/lang/c/CPointerDeclaratorImpl.scala
index c0ff813e80..3e9a24704f 100644
--- a/src/col/vct/col/ast/lang/c/CPointerDeclaratorImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CPointerDeclaratorImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.CPointerDeclarator
import vct.col.ast.ops.CPointerDeclaratorOps
import vct.col.print.{Ctx, Doc}
-trait CPointerDeclaratorImpl[G] extends CPointerDeclaratorOps[G] { this: CPointerDeclarator[G] =>
+trait CPointerDeclaratorImpl[G] extends CPointerDeclaratorOps[G] {
+ this: CPointerDeclarator[G] =>
override def layout(implicit ctx: Ctx): Doc =
inner.show <> Doc.fold(pointers)(_ <> _)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CPointerImpl.scala b/src/col/vct/col/ast/lang/c/CPointerImpl.scala
index d2219f873e..9a929524e8 100644
--- a/src/col/vct/col/ast/lang/c/CPointerImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CPointerImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.CPointer
import vct.col.ast.ops.{CPointerFamilyOps, CPointerOps}
import vct.col.print.{Ctx, Doc, Text}
-trait CPointerImpl[G] extends CPointerOps[G] with CPointerFamilyOps[G] { this: CPointer[G] =>
+trait CPointerImpl[G] extends CPointerOps[G] with CPointerFamilyOps[G] {
+ this: CPointer[G] =>
override def layout(implicit ctx: Ctx): Doc =
Text("*") <> Doc.rspread(qualifiers)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CPrimitiveTypeImpl.scala b/src/col/vct/col/ast/lang/c/CPrimitiveTypeImpl.scala
index 1b2757eb69..613a7671c7 100644
--- a/src/col/vct/col/ast/lang/c/CPrimitiveTypeImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CPrimitiveTypeImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CPrimitiveType
import vct.col.print.{Ctx, Doc}
import vct.col.ast.ops.CPrimitiveTypeOps
-trait CPrimitiveTypeImpl[G] extends CPrimitiveTypeOps[G] { this: CPrimitiveType[G] =>
+trait CPrimitiveTypeImpl[G] extends CPrimitiveTypeOps[G] {
+ this: CPrimitiveType[G] =>
override def layout(implicit ctx: Ctx): Doc = Doc.spread(specifiers)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CPureImpl.scala b/src/col/vct/col/ast/lang/c/CPureImpl.scala
index 59c47851a4..061e6532d1 100644
--- a/src/col/vct/col/ast/lang/c/CPureImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CPureImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CPure
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.CPureOps
-trait CPureImpl[G] extends CPureOps[G] { this: CPure[G] =>
+trait CPureImpl[G] extends CPureOps[G] {
+ this: CPure[G] =>
override def layout(implicit ctx: Ctx): Doc = Doc.inlineSpec(Text("pure"))
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CRestrictImpl.scala b/src/col/vct/col/ast/lang/c/CRestrictImpl.scala
index c942daf792..988e4e5cf6 100644
--- a/src/col/vct/col/ast/lang/c/CRestrictImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CRestrictImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CRestrict
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.CRestrictOps
-trait CRestrictImpl[G] extends CRestrictOps[G] { this: CRestrict[G] =>
+trait CRestrictImpl[G] extends CRestrictOps[G] {
+ this: CRestrict[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("restrict")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CShortImpl.scala b/src/col/vct/col/ast/lang/c/CShortImpl.scala
index f27ba9e4ed..a055047d87 100644
--- a/src/col/vct/col/ast/lang/c/CShortImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CShortImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CShort
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.CShortOps
-trait CShortImpl[G] extends CShortOps[G] { this: CShort[G] =>
+trait CShortImpl[G] extends CShortOps[G] {
+ this: CShort[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("short")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CSignedImpl.scala b/src/col/vct/col/ast/lang/c/CSignedImpl.scala
index 429c3a9ded..1b5076bec7 100644
--- a/src/col/vct/col/ast/lang/c/CSignedImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CSignedImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CSigned
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.CSignedOps
-trait CSignedImpl[G] extends CSignedOps[G] { this: CSigned[G] =>
+trait CSignedImpl[G] extends CSignedOps[G] {
+ this: CSigned[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("signed")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CSpecificationModifierImpl.scala b/src/col/vct/col/ast/lang/c/CSpecificationModifierImpl.scala
index c1796587cf..630a8f60f6 100644
--- a/src/col/vct/col/ast/lang/c/CSpecificationModifierImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CSpecificationModifierImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.lang.c
import vct.col.ast.CSpecificationModifier
-trait CSpecificationModifierImpl[G] { this: CSpecificationModifier[G] =>
+trait CSpecificationModifierImpl[G] {
+ this: CSpecificationModifier[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CSpecificationTypeImpl.scala b/src/col/vct/col/ast/lang/c/CSpecificationTypeImpl.scala
index 97aa6b0c1a..3e3fb21df6 100644
--- a/src/col/vct/col/ast/lang/c/CSpecificationTypeImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CSpecificationTypeImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CSpecificationType
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.CSpecificationTypeOps
-trait CSpecificationTypeImpl[G] extends CSpecificationTypeOps[G] { this: CSpecificationType[G] =>
+trait CSpecificationTypeImpl[G] extends CSpecificationTypeOps[G] {
+ this: CSpecificationType[G] =>
override def layout(implicit ctx: Ctx): Doc = t.show
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CStatementImpl.scala b/src/col/vct/col/ast/lang/c/CStatementImpl.scala
index 4deeb227cf..058905a139 100644
--- a/src/col/vct/col/ast/lang/c/CStatementImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CStatementImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.lang.c
import vct.col.ast.CStatement
-trait CStatementImpl[G] { this: CStatement[G] =>
+trait CStatementImpl[G] {
+ this: CStatement[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CStaticImpl.scala b/src/col/vct/col/ast/lang/c/CStaticImpl.scala
index 0d87248d6e..1c31552fd2 100644
--- a/src/col/vct/col/ast/lang/c/CStaticImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CStaticImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CStatic
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.CStaticOps
-trait CStaticImpl[G] extends CStaticOps[G] { this: CStatic[G] =>
+trait CStaticImpl[G] extends CStaticOps[G] {
+ this: CStatic[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("static")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CStorageClassSpecifierImpl.scala b/src/col/vct/col/ast/lang/c/CStorageClassSpecifierImpl.scala
index 3c46c438a5..8992e1ae24 100644
--- a/src/col/vct/col/ast/lang/c/CStorageClassSpecifierImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CStorageClassSpecifierImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.lang.c
import vct.col.ast.CStorageClassSpecifier
-trait CStorageClassSpecifierImpl[G] { this: CStorageClassSpecifier[G] =>
+trait CStorageClassSpecifierImpl[G] {
+ this: CStorageClassSpecifier[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CStructDeclarationImpl.scala b/src/col/vct/col/ast/lang/c/CStructDeclarationImpl.scala
index cc5827cd60..ee288f91c2 100644
--- a/src/col/vct/col/ast/lang/c/CStructDeclarationImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CStructDeclarationImpl.scala
@@ -4,12 +4,15 @@ import vct.col.ast.CStructDeclaration
import vct.col.ast.ops.CStructDeclarationOps
import vct.col.print.{Ctx, Doc, Empty, Text}
-trait CStructDeclarationImpl[G] extends CStructDeclarationOps[G] { this: CStructDeclaration[G] =>
+trait CStructDeclarationImpl[G] extends CStructDeclarationOps[G] {
+ this: CStructDeclaration[G] =>
override def layout(implicit ctx: Ctx): Doc = {
Doc.stack(Seq(
Text("struct") <+>
- (if (name.isEmpty) Empty else Text(name.get)) <+>
- "{" <>> Doc.stack(decl) <+/> "}"
+ (if (name.isEmpty)
+ Empty
+ else
+ Text(name.get)) <+> "{" <>> Doc.stack(decl) <+/> "}"
))
}
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CStructDerefImpl.scala b/src/col/vct/col/ast/lang/c/CStructDerefImpl.scala
index 5b13d194f3..76847a4111 100644
--- a/src/col/vct/col/ast/lang/c/CStructDerefImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CStructDerefImpl.scala
@@ -7,26 +7,31 @@ import vct.col.resolve.ctx._
import vct.col.resolve.lang.C
import vct.col.typerules.Types
-trait CStructDerefImpl[G] extends CStructDerefOps[G] { this: CStructDeref[G] =>
- override lazy val t: Type[G] = ref.get match {
- case ref: RefCStructField[G] => C.typeOrReturnTypeFromDeclaration(ref.decls.specs, ref.decls.decls(ref.idx))
- case ref: RefCStruct[G] => Types.notAValue(ref)
- case ref: RefModelField[G] => ref.decl.t
- case ref: RefFunction[G] => Types.notAValue(ref)
- case ref: RefProcedure[G] => Types.notAValue(ref)
- case ref: RefPredicate[G] => Types.notAValue(ref)
- case ref: RefInstanceFunction[G] => Types.notAValue(ref)
- case ref: RefInstanceMethod[G] => Types.notAValue(ref)
- case ref: RefInstancePredicate[G] => Types.notAValue(ref)
- case ref: RefADTFunction[G] => Types.notAValue(ref)
- case ref: RefModelProcess[G] => Types.notAValue(ref)
- case ref: RefModelAction[G] => Types.notAValue(ref)
- case ref: BuiltinField[G] => ref.f(struct).t
- case ref: BuiltinInstanceMethod[G] => Types.notAValue(ref)
- case ref: RefCudaVecDim[G] => TCInt()
- }
+trait CStructDerefImpl[G] extends CStructDerefOps[G] {
+ this: CStructDeref[G] =>
+ override lazy val t: Type[G] =
+ ref.get match {
+ case ref: RefCStructField[G] =>
+ C.typeOrReturnTypeFromDeclaration(
+ ref.decls.specs,
+ ref.decls.decls(ref.idx),
+ )
+ case ref: RefCStruct[G] => Types.notAValue(ref)
+ case ref: RefModelField[G] => ref.decl.t
+ case ref: RefFunction[G] => Types.notAValue(ref)
+ case ref: RefProcedure[G] => Types.notAValue(ref)
+ case ref: RefPredicate[G] => Types.notAValue(ref)
+ case ref: RefInstanceFunction[G] => Types.notAValue(ref)
+ case ref: RefInstanceMethod[G] => Types.notAValue(ref)
+ case ref: RefInstancePredicate[G] => Types.notAValue(ref)
+ case ref: RefADTFunction[G] => Types.notAValue(ref)
+ case ref: RefModelProcess[G] => Types.notAValue(ref)
+ case ref: RefModelAction[G] => Types.notAValue(ref)
+ case ref: BuiltinField[G] => ref.f(struct).t
+ case ref: BuiltinInstanceMethod[G] => Types.notAValue(ref)
+ case ref: RefCudaVecDim[G] => TCInt()
+ }
override def precedence: Int = Precedence.POSTFIX
- override def layout(implicit ctx: Ctx): Doc =
- assoc(struct) <> "->" <> field
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc = assoc(struct) <> "->" <> field
+}
diff --git a/src/col/vct/col/ast/lang/c/CStructMemberDeclaratorImpl.scala b/src/col/vct/col/ast/lang/c/CStructMemberDeclaratorImpl.scala
index 8e6dbfeed3..e5406b400c 100644
--- a/src/col/vct/col/ast/lang/c/CStructMemberDeclaratorImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CStructMemberDeclaratorImpl.scala
@@ -1,10 +1,20 @@
package vct.col.ast.lang.c
import vct.col.ast.CStructMemberDeclarator
-import vct.col.ast.ops.{CStructMemberDeclaratorFamilyOps, CStructMemberDeclaratorOps}
+import vct.col.ast.ops.{
+ CStructMemberDeclaratorFamilyOps,
+ CStructMemberDeclaratorOps,
+}
import vct.col.print.{Ctx, Doc, Empty, Text}
-trait CStructMemberDeclaratorImpl[G] extends CStructMemberDeclaratorOps[G] with CStructMemberDeclaratorFamilyOps[G] { this: CStructMemberDeclarator[G] =>
- override def layout(implicit ctx: Ctx): Doc = Doc.spread(specs) <>
- (if(decls.isEmpty) Empty else Text(" ") <> Doc.fold(decls)(_ <> ", " <> _)) <> ";"
-}
\ No newline at end of file
+trait CStructMemberDeclaratorImpl[G]
+ extends CStructMemberDeclaratorOps[G]
+ with CStructMemberDeclaratorFamilyOps[G] {
+ this: CStructMemberDeclarator[G] =>
+ override def layout(implicit ctx: Ctx): Doc =
+ Doc.spread(specs) <>
+ (if (decls.isEmpty)
+ Empty
+ else
+ Text(" ") <> Doc.fold(decls)(_ <> ", " <> _)) <> ";"
+}
diff --git a/src/col/vct/col/ast/lang/c/CStructSpecifierImpl.scala b/src/col/vct/col/ast/lang/c/CStructSpecifierImpl.scala
index 7e1a4d320d..fbd3746564 100644
--- a/src/col/vct/col/ast/lang/c/CStructSpecifierImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CStructSpecifierImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CStructSpecifier
import vct.col.ast.ops.CStructSpecifierOps
import vct.col.print.{Ctx, Doc, Text}
-trait CStructSpecifierImpl[G] extends CStructSpecifierOps[G] { this: CStructSpecifier[G] =>
+trait CStructSpecifierImpl[G] extends CStructSpecifierOps[G] {
+ this: CStructSpecifier[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("struct") <+> name
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CTArrayImpl.scala b/src/col/vct/col/ast/lang/c/CTArrayImpl.scala
index d62349da12..e9e1f5b4ef 100644
--- a/src/col/vct/col/ast/lang/c/CTArrayImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CTArrayImpl.scala
@@ -4,8 +4,8 @@ import vct.col.ast.CTArray
import vct.col.print.{Ctx, Doc, Group}
import vct.col.ast.ops.CTArrayOps
-trait CTArrayImpl[G] extends CTArrayOps[G] { this: CTArray[G] =>
+trait CTArrayImpl[G] extends CTArrayOps[G] {
+ this: CTArray[G] =>
override def layout(implicit ctx: Ctx): Doc =
Group(innerType.show <> "[" <> Doc.args(size.toSeq) <> "]")
}
-
diff --git a/src/col/vct/col/ast/lang/c/CTCudaVecImpl.scala b/src/col/vct/col/ast/lang/c/CTCudaVecImpl.scala
index 37f3b7ab8e..3ba3cb7a08 100644
--- a/src/col/vct/col/ast/lang/c/CTCudaVecImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CTCudaVecImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.lang.c
import vct.col.ast.CTCudaVec
import vct.col.ast.ops.CTCudaVecOps
-trait CTCudaVecImpl[G] extends CTCudaVecOps[G] { this: CTCudaVec[G] =>
+trait CTCudaVecImpl[G] extends CTCudaVecOps[G] {
+ this: CTCudaVec[G] =>
}
diff --git a/src/col/vct/col/ast/lang/c/CTPointerImpl.scala b/src/col/vct/col/ast/lang/c/CTPointerImpl.scala
index 328d0d21c4..233f297193 100644
--- a/src/col/vct/col/ast/lang/c/CTPointerImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CTPointerImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.CTPointer
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.CTPointerOps
-trait CTPointerImpl[G] extends CTPointerOps[G] { this: CTPointer[G] =>
+trait CTPointerImpl[G] extends CTPointerOps[G] {
+ this: CTPointer[G] =>
override def layout(implicit ctx: Ctx): Doc =
Text("pointer") <> open <> innerType <> close
}
diff --git a/src/col/vct/col/ast/lang/c/CTStructImpl.scala b/src/col/vct/col/ast/lang/c/CTStructImpl.scala
index 887f2d6e02..441bb9a2e4 100644
--- a/src/col/vct/col/ast/lang/c/CTStructImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CTStructImpl.scala
@@ -4,7 +4,7 @@ import vct.col.ast.CTStruct
import vct.col.ast.ops.CTStructOps
import vct.col.print.{Ctx, Doc, Text}
-trait CTStructImpl[G] extends CTStructOps[G] { this: CTStruct[G] =>
- override def layout(implicit ctx: Ctx): Doc =
- Text("struct") <+> ctx.name(ref)
-}
\ No newline at end of file
+trait CTStructImpl[G] extends CTStructOps[G] {
+ this: CTStruct[G] =>
+ override def layout(implicit ctx: Ctx): Doc = Text("struct") <+> ctx.name(ref)
+}
diff --git a/src/col/vct/col/ast/lang/c/CTVectorImpl.scala b/src/col/vct/col/ast/lang/c/CTVectorImpl.scala
index 36bbb6a75d..141f0c8d08 100644
--- a/src/col/vct/col/ast/lang/c/CTVectorImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CTVectorImpl.scala
@@ -15,15 +15,25 @@ object CTVector {
}
}
-trait CTVectorImpl[G] extends CTVectorOps[G] { this: CTVector[G] =>
+trait CTVectorImpl[G] extends CTVectorOps[G] {
+ this: CTVector[G] =>
override def layout(implicit ctx: Ctx): Doc =
Text("vector") <> "<" <> innerType <> "," <> size <> ">"
- lazy val intSize = size match {
- case AmbiguousMult(SizeOf(ts), e) if ts == innerType && isConstantInt(e).isDefined => isConstantInt(e).get
- case AmbiguousMult(e, SizeOf(ts)) if ts == innerType && isConstantInt(e).isDefined => isConstantInt(e).get
- case Mult(e, SizeOf(ts)) if ts == innerType && isConstantInt(e).isDefined => isConstantInt(e).get
- case Mult(SizeOf(ts), e) if ts == innerType && isConstantInt(e).isDefined => isConstantInt(e).get
- case _ => throw CTVector.WrongVectorType(this)
- }
+ lazy val intSize =
+ size match {
+ case AmbiguousMult(SizeOf(ts), e)
+ if ts == innerType && isConstantInt(e).isDefined =>
+ isConstantInt(e).get
+ case AmbiguousMult(e, SizeOf(ts))
+ if ts == innerType && isConstantInt(e).isDefined =>
+ isConstantInt(e).get
+ case Mult(e, SizeOf(ts))
+ if ts == innerType && isConstantInt(e).isDefined =>
+ isConstantInt(e).get
+ case Mult(SizeOf(ts), e)
+ if ts == innerType && isConstantInt(e).isDefined =>
+ isConstantInt(e).get
+ case _ => throw CTVector.WrongVectorType(this)
+ }
}
diff --git a/src/col/vct/col/ast/lang/c/CTranslationUnitImpl.scala b/src/col/vct/col/ast/lang/c/CTranslationUnitImpl.scala
index d9e4157b1e..5005d60c5b 100644
--- a/src/col/vct/col/ast/lang/c/CTranslationUnitImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CTranslationUnitImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CTranslationUnit
import vct.col.print.{Ctx, Doc, Group}
import vct.col.ast.ops.CTranslationUnitOps
-trait CTranslationUnitImpl[G] extends CTranslationUnitOps[G] { this: CTranslationUnit[G] =>
+trait CTranslationUnitImpl[G] extends CTranslationUnitOps[G] {
+ this: CTranslationUnit[G] =>
override def layout(implicit ctx: Ctx): Doc = Doc.stack(declarations)
}
diff --git a/src/col/vct/col/ast/lang/c/CTypeAttributeImpl.scala b/src/col/vct/col/ast/lang/c/CTypeAttributeImpl.scala
index 3678981e63..d1e3612589 100644
--- a/src/col/vct/col/ast/lang/c/CTypeAttributeImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CTypeAttributeImpl.scala
@@ -4,8 +4,10 @@ import vct.col.ast.CTypeAttribute
import vct.col.ast.ops.CTypeAttributeOps
import vct.col.print.{Ctx, Doc, Text}
-trait CTypeAttributeImpl[G] extends CTypeAttributeOps[G] { this: CTypeAttribute[G] =>
+trait CTypeAttributeImpl[G] extends CTypeAttributeOps[G] {
+ this: CTypeAttribute[G] =>
override def layout(implicit ctx: Ctx): Doc = {
- Text("__attribute__") <> "( (" <> name <> "(" <> Doc.args(args) <> ")" <> ") )"
+ Text("__attribute__") <> "( (" <> name <> "(" <> Doc.args(args) <> ")" <>
+ ") )"
}
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CTypeExtensionDeclaratorImpl.scala b/src/col/vct/col/ast/lang/c/CTypeExtensionDeclaratorImpl.scala
index 2dd30a995d..d1972612d0 100644
--- a/src/col/vct/col/ast/lang/c/CTypeExtensionDeclaratorImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CTypeExtensionDeclaratorImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.CTypeExtensionDeclarator
import vct.col.ast.ops.CTypeExtensionDeclaratorOps
import vct.col.print.{Ctx, Doc}
-trait CTypeExtensionDeclaratorImpl[G] extends CTypeExtensionDeclaratorOps[G] { this: CTypeExtensionDeclarator[G] =>
+trait CTypeExtensionDeclaratorImpl[G] extends CTypeExtensionDeclaratorOps[G] {
+ this: CTypeExtensionDeclarator[G] =>
override def layout(implicit ctx: Ctx): Doc =
inner.show <> Doc.fold(extensions)(_ <+> _)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CTypeExtensionsImpl.scala b/src/col/vct/col/ast/lang/c/CTypeExtensionsImpl.scala
index 8e0105ef28..a2e22e234a 100644
--- a/src/col/vct/col/ast/lang/c/CTypeExtensionsImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CTypeExtensionsImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.lang.c
import vct.col.ast.CTypeExtensions
import vct.col.ast.ops.CTypeExtensionsFamilyOps
-trait CTypeExtensionsImpl[G] extends CTypeExtensionsFamilyOps[G] { this: CTypeExtensions[G] =>
+trait CTypeExtensionsImpl[G] extends CTypeExtensionsFamilyOps[G] {
+ this: CTypeExtensions[G] =>
}
diff --git a/src/col/vct/col/ast/lang/c/CTypeImpl.scala b/src/col/vct/col/ast/lang/c/CTypeImpl.scala
index d3fd1f056d..02a19fa2d2 100644
--- a/src/col/vct/col/ast/lang/c/CTypeImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CTypeImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.lang.c
import vct.col.ast.CType
-trait CTypeImpl[G] { this: CType[G] =>
+trait CTypeImpl[G] {
+ this: CType[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CTypeQualifierDeclarationSpecifierImpl.scala b/src/col/vct/col/ast/lang/c/CTypeQualifierDeclarationSpecifierImpl.scala
index b28bdd0529..889c91cfbf 100644
--- a/src/col/vct/col/ast/lang/c/CTypeQualifierDeclarationSpecifierImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CTypeQualifierDeclarationSpecifierImpl.scala
@@ -4,6 +4,8 @@ import vct.col.ast.CTypeQualifierDeclarationSpecifier
import vct.col.print.{Ctx, Doc}
import vct.col.ast.ops.CTypeQualifierDeclarationSpecifierOps
-trait CTypeQualifierDeclarationSpecifierImpl[G] extends CTypeQualifierDeclarationSpecifierOps[G] { this: CTypeQualifierDeclarationSpecifier[G] =>
+trait CTypeQualifierDeclarationSpecifierImpl[G]
+ extends CTypeQualifierDeclarationSpecifierOps[G] {
+ this: CTypeQualifierDeclarationSpecifier[G] =>
override def layout(implicit ctx: Ctx): Doc = typeQual.show
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CTypeQualifierImpl.scala b/src/col/vct/col/ast/lang/c/CTypeQualifierImpl.scala
index 532e3df4a7..47aac8bac5 100644
--- a/src/col/vct/col/ast/lang/c/CTypeQualifierImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CTypeQualifierImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.lang.c
import vct.col.ast.CTypeQualifier
import vct.col.ast.ops.CTypeQualifierFamilyOps
-trait CTypeQualifierImpl[G] extends CTypeQualifierFamilyOps[G] { this: CTypeQualifier[G] =>
+trait CTypeQualifierImpl[G] extends CTypeQualifierFamilyOps[G] {
+ this: CTypeQualifier[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CTypeSpecifierImpl.scala b/src/col/vct/col/ast/lang/c/CTypeSpecifierImpl.scala
index 87334676ef..529d19ce1a 100644
--- a/src/col/vct/col/ast/lang/c/CTypeSpecifierImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CTypeSpecifierImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.lang.c
import vct.col.ast.CTypeSpecifier
-trait CTypeSpecifierImpl[G] { this: CTypeSpecifier[G] =>
+trait CTypeSpecifierImpl[G] {
+ this: CTypeSpecifier[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CTypedFunctionDeclaratorImpl.scala b/src/col/vct/col/ast/lang/c/CTypedFunctionDeclaratorImpl.scala
index 11c4485dd6..b87a4b96d7 100644
--- a/src/col/vct/col/ast/lang/c/CTypedFunctionDeclaratorImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CTypedFunctionDeclaratorImpl.scala
@@ -4,7 +4,16 @@ import vct.col.ast.CTypedFunctionDeclarator
import vct.col.print.{Ctx, Doc, Text, Group}
import vct.col.ast.ops.CTypedFunctionDeclaratorOps
-trait CTypedFunctionDeclaratorImpl[G] extends CTypedFunctionDeclaratorOps[G] { this: CTypedFunctionDeclarator[G] =>
+trait CTypedFunctionDeclaratorImpl[G] extends CTypedFunctionDeclaratorOps[G] {
+ this: CTypedFunctionDeclarator[G] =>
override def layout(implicit ctx: Ctx): Doc =
- Group(inner.show <> "(" <> Doc.args(params ++ (if(varargs) Seq(Text("...")) else Nil)) <> ")")
-}
\ No newline at end of file
+ Group(
+ inner.show <> "(" <> Doc.args(
+ params ++
+ (if (varargs)
+ Seq(Text("..."))
+ else
+ Nil)
+ ) <> ")"
+ )
+}
diff --git a/src/col/vct/col/ast/lang/c/CTypedefImpl.scala b/src/col/vct/col/ast/lang/c/CTypedefImpl.scala
index b3dc216594..0fe4750a29 100644
--- a/src/col/vct/col/ast/lang/c/CTypedefImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CTypedefImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CTypedef
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.CTypedefOps
-trait CTypedefImpl[G] extends CTypedefOps[G] { this: CTypedef[G] =>
+trait CTypedefImpl[G] extends CTypedefOps[G] {
+ this: CTypedef[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("typedef")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CTypedefNameImpl.scala b/src/col/vct/col/ast/lang/c/CTypedefNameImpl.scala
index cdb6945b04..6a101af027 100644
--- a/src/col/vct/col/ast/lang/c/CTypedefNameImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CTypedefNameImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CTypedefName
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.CTypedefNameOps
-trait CTypedefNameImpl[G] extends CTypedefNameOps[G] { this: CTypedefName[G] =>
+trait CTypedefNameImpl[G] extends CTypedefNameOps[G] {
+ this: CTypedefName[G] =>
override def layout(implicit ctx: Ctx): Doc = Text(name)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CUDAKernelImpl.scala b/src/col/vct/col/ast/lang/c/CUDAKernelImpl.scala
index 9aea87a0d4..2d02634739 100644
--- a/src/col/vct/col/ast/lang/c/CUDAKernelImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CUDAKernelImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CUDAKernel
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.CUDAKernelOps
-trait CUDAKernelImpl[G] extends CUDAKernelOps[G] { this: CUDAKernel[G] =>
+trait CUDAKernelImpl[G] extends CUDAKernelOps[G] {
+ this: CUDAKernel[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("__global__")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CUnsignedImpl.scala b/src/col/vct/col/ast/lang/c/CUnsignedImpl.scala
index 6c00aba168..fb95bba412 100644
--- a/src/col/vct/col/ast/lang/c/CUnsignedImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CUnsignedImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CUnsigned
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.CUnsignedOps
-trait CUnsignedImpl[G] extends CUnsignedOps[G] { this: CUnsigned[G] =>
+trait CUnsignedImpl[G] extends CUnsignedOps[G] {
+ this: CUnsigned[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("unsigned")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CVoidImpl.scala b/src/col/vct/col/ast/lang/c/CVoidImpl.scala
index e646d1a771..537e7e8d9d 100644
--- a/src/col/vct/col/ast/lang/c/CVoidImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CVoidImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CVoid
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.CVoidOps
-trait CVoidImpl[G] extends CVoidOps[G] { this: CVoid[G] =>
+trait CVoidImpl[G] extends CVoidOps[G] {
+ this: CVoid[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("void")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/CVolatileImpl.scala b/src/col/vct/col/ast/lang/c/CVolatileImpl.scala
index 428c3bb19e..8c2980046c 100644
--- a/src/col/vct/col/ast/lang/c/CVolatileImpl.scala
+++ b/src/col/vct/col/ast/lang/c/CVolatileImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CVolatile
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.CVolatileOps
-trait CVolatileImpl[G] extends CVolatileOps[G] { this: CVolatile[G] =>
+trait CVolatileImpl[G] extends CVolatileOps[G] {
+ this: CVolatile[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("volatile")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/c/TOpenCLVectorImpl.scala b/src/col/vct/col/ast/lang/c/TOpenCLVectorImpl.scala
index 07fc0be817..eccf5a476d 100644
--- a/src/col/vct/col/ast/lang/c/TOpenCLVectorImpl.scala
+++ b/src/col/vct/col/ast/lang/c/TOpenCLVectorImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.TOpenCLVector
import vct.col.ast.ops.TOpenCLVectorOps
import vct.col.print._
-trait TOpenCLVectorImpl[G] extends TOpenCLVectorOps[G] { this: TOpenCLVector[G] =>
+trait TOpenCLVectorImpl[G] extends TOpenCLVectorOps[G] {
+ this: TOpenCLVector[G] =>
override def layout(implicit ctx: Ctx): Doc =
Text("openCLVector") <> "<" <> innerType <> "," <> size.toString <> ">"
}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPAbstractDeclarationImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPAbstractDeclarationImpl.scala
index fd0210b781..aea9f64672 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPAbstractDeclarationImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPAbstractDeclarationImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.lang.cpp
import vct.col.ast.CPPAbstractDeclaration
-trait CPPAbstractDeclarationImpl[G] { this: CPPAbstractDeclaration[G] =>
+trait CPPAbstractDeclarationImpl[G] {
+ this: CPPAbstractDeclaration[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPAddressingDeclaratorImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPAddressingDeclaratorImpl.scala
index 20bf09e354..2774f80f33 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPAddressingDeclaratorImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPAddressingDeclaratorImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.CPPAddressingDeclarator
import vct.col.print.{Ctx, Doc}
import vct.col.ast.ops.CPPAddressingDeclaratorOps
-trait CPPAddressingDeclaratorImpl[G] extends CPPAddressingDeclaratorOps[G] { this: CPPAddressingDeclarator[G] =>
+trait CPPAddressingDeclaratorImpl[G] extends CPPAddressingDeclaratorOps[G] {
+ this: CPPAddressingDeclarator[G] =>
override def layout(implicit ctx: Ctx): Doc =
inner.show <> Doc.fold(operators)(_ <> _)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPAddressingImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPAddressingImpl.scala
index d39c22b2bf..0d58aafdca 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPAddressingImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPAddressingImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.lang.cpp
import vct.col.ast.CPPAddressing
import vct.col.ast.ops.CPPAddressingFamilyOps
-trait CPPAddressingImpl[G] extends CPPAddressingFamilyOps[G] { this: CPPAddressing[G] =>
+trait CPPAddressingImpl[G] extends CPPAddressingFamilyOps[G] {
+ this: CPPAddressing[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPArrayDeclaratorImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPArrayDeclaratorImpl.scala
index 84c463479d..f624f779a5 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPArrayDeclaratorImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPArrayDeclaratorImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.CPPArrayDeclarator
import vct.col.print.{Ctx, Doc, Group}
import vct.col.ast.ops.CPPArrayDeclaratorOps
-trait CPPArrayDeclaratorImpl[G] extends CPPArrayDeclaratorOps[G] { this: CPPArrayDeclarator[G] =>
+trait CPPArrayDeclaratorImpl[G] extends CPPArrayDeclaratorOps[G] {
+ this: CPPArrayDeclarator[G] =>
override def layout(implicit ctx: Ctx): Doc =
Group(inner.show <> "[" <> Doc.arg(Doc.stack(size.toSeq)) <> "]")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPBoolImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPBoolImpl.scala
index 9f35235c33..8d6316a4cf 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPBoolImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPBoolImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CPPBool
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.CPPBoolOps
-trait CPPBoolImpl[G] extends CPPBoolOps[G] { this: CPPBool[G] =>
+trait CPPBoolImpl[G] extends CPPBoolOps[G] {
+ this: CPPBool[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("bool")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPCharImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPCharImpl.scala
index 304607054f..920eda78c6 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPCharImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPCharImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CPPChar
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.CPPCharOps
-trait CPPCharImpl[G] extends CPPCharOps[G] { this: CPPChar[G] =>
+trait CPPCharImpl[G] extends CPPCharOps[G] {
+ this: CPPChar[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("char")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPClassMethodOrFieldAccessImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPClassMethodOrFieldAccessImpl.scala
index 4e95c47cd0..f78c686b66 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPClassMethodOrFieldAccessImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPClassMethodOrFieldAccessImpl.scala
@@ -6,26 +6,29 @@ import vct.col.resolve.ctx._
import vct.col.typerules.Types
import vct.col.ast.ops.CPPClassMethodOrFieldAccessOps
-trait CPPClassMethodOrFieldAccessImpl[G] extends CPPClassMethodOrFieldAccessOps[G] { this: CPPClassMethodOrFieldAccess[G] =>
- override lazy val t: Type[G] = ref.get match {
- case ref: RefModelField[G] => ref.decl.t
- case ref: RefFunction[G] => Types.notAValue(ref)
- case ref: RefProcedure[G] => Types.notAValue(ref)
- case ref: RefPredicate[G] => Types.notAValue(ref)
- case ref: RefInstanceFunction[G] => Types.notAValue(ref)
- case ref: RefInstanceMethod[G] => Types.notAValue(ref)
- case ref: RefInstancePredicate[G] => Types.notAValue(ref)
- case ref: RefADTFunction[G] => Types.notAValue(ref)
- case ref: RefModelProcess[G] => Types.notAValue(ref)
- case ref: RefModelAction[G] => Types.notAValue(ref)
- case RefProverFunction(decl) => decl.returnType
- case ref: BuiltinField[G] => ref.f(classInstance).t
- case ref: BuiltinInstanceMethod[G] => Types.notAValue(ref)
- case RefEnumConstant(enum, _) => TEnum(enum.get.ref)
- case ref: RefCPPGlobalDeclaration[G] => Types.notAValue(ref)
- }
+trait CPPClassMethodOrFieldAccessImpl[G]
+ extends CPPClassMethodOrFieldAccessOps[G] {
+ this: CPPClassMethodOrFieldAccess[G] =>
+ override lazy val t: Type[G] =
+ ref.get match {
+ case ref: RefModelField[G] => ref.decl.t
+ case ref: RefFunction[G] => Types.notAValue(ref)
+ case ref: RefProcedure[G] => Types.notAValue(ref)
+ case ref: RefPredicate[G] => Types.notAValue(ref)
+ case ref: RefInstanceFunction[G] => Types.notAValue(ref)
+ case ref: RefInstanceMethod[G] => Types.notAValue(ref)
+ case ref: RefInstancePredicate[G] => Types.notAValue(ref)
+ case ref: RefADTFunction[G] => Types.notAValue(ref)
+ case ref: RefModelProcess[G] => Types.notAValue(ref)
+ case ref: RefModelAction[G] => Types.notAValue(ref)
+ case RefProverFunction(decl) => decl.returnType
+ case ref: BuiltinField[G] => ref.f(classInstance).t
+ case ref: BuiltinInstanceMethod[G] => Types.notAValue(ref)
+ case RefEnumConstant(enum, _) => TEnum(enum.get.ref)
+ case ref: RefCPPGlobalDeclaration[G] => Types.notAValue(ref)
+ }
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
assoc(classInstance) <> "." <> methodOrFieldName
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPDeclarationImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPDeclarationImpl.scala
index d8eef630c3..ed3897c729 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPDeclarationImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPDeclarationImpl.scala
@@ -4,7 +4,9 @@ import vct.col.ast.CPPDeclaration
import vct.col.print._
import vct.col.ast.ops.{CPPDeclarationOps, CPPDeclarationFamilyOps}
-trait CPPDeclarationImpl[G] extends CPPDeclarationOps[G] with CPPDeclarationFamilyOps[G] { this: CPPDeclaration[G] =>
+trait CPPDeclarationImpl[G]
+ extends CPPDeclarationOps[G] with CPPDeclarationFamilyOps[G] {
+ this: CPPDeclaration[G] =>
// PB: Please keep in sync with ApplicableContractImpl
def layoutContract(implicit ctx: Ctx): Doc =
Doc.stack(Seq(
@@ -18,10 +20,5 @@ trait CPPDeclarationImpl[G] extends CPPDeclarationOps[G] with CPPDeclarationFami
))
override def layout(implicit ctx: Ctx): Doc =
- Doc.stack(Seq(
- layoutContract,
- Group(
- Doc.spread(specs) <>> Doc.args(inits)
- ),
- ))
-}
\ No newline at end of file
+ Doc.stack(Seq(layoutContract, Group(Doc.spread(specs) <>> Doc.args(inits))))
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPDeclarationSpecifierImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPDeclarationSpecifierImpl.scala
index 6f34e2a97e..bdf470162d 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPDeclarationSpecifierImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPDeclarationSpecifierImpl.scala
@@ -3,6 +3,8 @@ package vct.col.ast.lang.cpp
import vct.col.ast.CPPDeclarationSpecifier
import vct.col.ast.ops.CPPDeclarationSpecifierFamilyOps
-trait CPPDeclarationSpecifierImpl[G] extends CPPDeclarationSpecifierFamilyOps[G] { this: CPPDeclarationSpecifier[G] =>
+trait CPPDeclarationSpecifierImpl[G]
+ extends CPPDeclarationSpecifierFamilyOps[G] {
+ this: CPPDeclarationSpecifier[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPDeclarationStatementImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPDeclarationStatementImpl.scala
index 68d6e88946..be46d5b244 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPDeclarationStatementImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPDeclarationStatementImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CPPDeclarationStatement
import vct.col.print.{Ctx, Doc}
import vct.col.ast.ops.CPPDeclarationStatementOps
-trait CPPDeclarationStatementImpl[G] extends CPPDeclarationStatementOps[G] { this: CPPDeclarationStatement[G] =>
+trait CPPDeclarationStatementImpl[G] extends CPPDeclarationStatementOps[G] {
+ this: CPPDeclarationStatement[G] =>
override def layout(implicit ctx: Ctx): Doc = decl.show <> ";"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPDeclaratorImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPDeclaratorImpl.scala
index 89b17ec635..adb78968d2 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPDeclaratorImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPDeclaratorImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.lang.cpp
import vct.col.ast.CPPDeclarator
import vct.col.ast.ops.CPPDeclaratorFamilyOps
-trait CPPDeclaratorImpl[G] extends CPPDeclaratorFamilyOps[G] { this: CPPDeclarator[G] =>
+trait CPPDeclaratorImpl[G] extends CPPDeclaratorFamilyOps[G] {
+ this: CPPDeclarator[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPExprImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPExprImpl.scala
index b479fc2010..1a036a7e12 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPExprImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPExprImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.lang.cpp
import vct.col.ast.CPPExpr
-trait CPPExprImpl[G] { this: CPPExpr[G] =>
+trait CPPExprImpl[G] {
+ this: CPPExpr[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPExprOrTypeSpecifierImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPExprOrTypeSpecifierImpl.scala
index edd5838bf9..3e9f8dbbec 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPExprOrTypeSpecifierImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPExprOrTypeSpecifierImpl.scala
@@ -1,8 +1,14 @@
package vct.col.ast.lang.cpp
import vct.col.ast.CPPExprOrTypeSpecifier
-import vct.col.ast.ops.{CPPExprOrTypeSpecifierOps, CPPExprOrTypeSpecifierFamilyOps}
+import vct.col.ast.ops.{
+ CPPExprOrTypeSpecifierOps,
+ CPPExprOrTypeSpecifierFamilyOps,
+}
-trait CPPExprOrTypeSpecifierImpl[G] extends CPPExprOrTypeSpecifierOps[G] with CPPExprOrTypeSpecifierFamilyOps[G] { this: CPPExprOrTypeSpecifier[G] =>
+trait CPPExprOrTypeSpecifierImpl[G]
+ extends CPPExprOrTypeSpecifierOps[G]
+ with CPPExprOrTypeSpecifierFamilyOps[G] {
+ this: CPPExprOrTypeSpecifier[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPFunctionDefinitionImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPFunctionDefinitionImpl.scala
index 81a5a36256..c64f8b6503 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPFunctionDefinitionImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPFunctionDefinitionImpl.scala
@@ -4,12 +4,11 @@ import vct.col.ast.CPPFunctionDefinition
import vct.col.print.{Ctx, Doc, Group}
import vct.col.ast.ops.CPPFunctionDefinitionOps
-trait CPPFunctionDefinitionImpl[G] extends CPPFunctionDefinitionOps[G] { this: CPPFunctionDefinition[G] =>
+trait CPPFunctionDefinitionImpl[G] extends CPPFunctionDefinitionOps[G] {
+ this: CPPFunctionDefinition[G] =>
override def layout(implicit ctx: Ctx): Doc =
Doc.stack(Seq(
contract,
- Group(
- Doc.spread(specs) <>> declarator
- ) <+> body.layoutAsBlock,
+ Group(Doc.spread(specs) <>> declarator) <+> body.layoutAsBlock,
))
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPGlobalDeclarationImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPGlobalDeclarationImpl.scala
index 4f690fec9f..40ec5ce431 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPGlobalDeclarationImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPGlobalDeclarationImpl.scala
@@ -4,7 +4,7 @@ import vct.col.ast.CPPGlobalDeclaration
import vct.col.print._
import vct.col.ast.ops.CPPGlobalDeclarationOps
-trait CPPGlobalDeclarationImpl[G] extends CPPGlobalDeclarationOps[G] { this: CPPGlobalDeclaration[G] =>
- override def layout(implicit ctx: Ctx): Doc =
- decl.show <> ";"
-}
\ No newline at end of file
+trait CPPGlobalDeclarationImpl[G] extends CPPGlobalDeclarationOps[G] {
+ this: CPPGlobalDeclaration[G] =>
+ override def layout(implicit ctx: Ctx): Doc = decl.show <> ";"
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPInitImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPInitImpl.scala
index e33cf12b07..5e2a0c3003 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPInitImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPInitImpl.scala
@@ -4,7 +4,11 @@ import vct.col.ast.CPPInit
import vct.col.print.{Ctx, Doc, Group}
import vct.col.ast.ops.{CPPInitOps, CPPInitFamilyOps}
-trait CPPInitImpl[G] extends CPPInitOps[G] with CPPInitFamilyOps[G] { this: CPPInit[G] =>
+trait CPPInitImpl[G] extends CPPInitOps[G] with CPPInitFamilyOps[G] {
+ this: CPPInit[G] =>
override def layout(implicit ctx: Ctx): Doc =
- if(init.isEmpty) decl.show else Group(decl.show <+> "=" <>> init.get)
-}
\ No newline at end of file
+ if (init.isEmpty)
+ decl.show
+ else
+ Group(decl.show <+> "=" <>> init.get)
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPInlineImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPInlineImpl.scala
index f04fd32d9e..ae0e38b4a7 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPInlineImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPInlineImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CPPInline
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.CPPInlineOps
-trait CPPInlineImpl[G] extends CPPInlineOps[G] { this: CPPInline[G] =>
+trait CPPInlineImpl[G] extends CPPInlineOps[G] {
+ this: CPPInline[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("inline")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPIntImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPIntImpl.scala
index b3a7c9a7b1..e2266dd661 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPIntImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPIntImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CPPInt
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.CPPIntOps
-trait CPPIntImpl[G] extends CPPIntOps[G] { this: CPPInt[G] =>
+trait CPPIntImpl[G] extends CPPIntOps[G] {
+ this: CPPInt[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("int")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPInvocationImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPInvocationImpl.scala
index 594f59ec55..8703911e3d 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPInvocationImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPInvocationImpl.scala
@@ -7,29 +7,43 @@ import vct.col.resolve.lang.CPP
import vct.result.VerificationError.Unreachable
import vct.col.ast.ops.CPPInvocationOps
-trait CPPInvocationImpl[G] extends CPPInvocationOps[G] { this: CPPInvocation[G] =>
- override lazy val t: Type[G] = ref.get match {
- case RefFunction(decl) => decl.returnType
- case RefProcedure(decl) => decl.returnType
- case RefPredicate(decl) => decl.returnType
- case RefADTFunction(decl) => decl.returnType
- case RefModelProcess(decl) => decl.returnType
- case RefModelAction(decl) => decl.returnType
- case RefCPPFunctionDefinition(decl) => CPP.typeOrReturnTypeFromDeclarator(decl.specs, decl.declarator)
- case RefCPPGlobalDeclaration(decls, initIdx) => CPP.typeOrReturnTypeFromDeclarator(decls.decl.specs, decls.decl.inits(initIdx).decl)
- case RefSYCLConstructorDefinition(typ) => typ
- case RefCPPLambdaDefinition(_) => CPPTLambda()
- case RefProverFunction(decl) => decl.returnType
- case RefInstanceMethod(decl) => decl.returnType
- case RefInstanceFunction(decl) => decl.returnType
- case RefInstancePredicate(decl) => decl.returnType
- case BuiltinInstanceMethod(f) => applicable match {
- case _ => throw Unreachable("BuiltinInstanceMethod resolution of CPPInvocation cannot invoke anything.")
+trait CPPInvocationImpl[G] extends CPPInvocationOps[G] {
+ this: CPPInvocation[G] =>
+ override lazy val t: Type[G] =
+ ref.get match {
+ case RefFunction(decl) => decl.returnType
+ case RefProcedure(decl) => decl.returnType
+ case RefPredicate(decl) => decl.returnType
+ case RefADTFunction(decl) => decl.returnType
+ case RefModelProcess(decl) => decl.returnType
+ case RefModelAction(decl) => decl.returnType
+ case RefCPPFunctionDefinition(decl) =>
+ CPP.typeOrReturnTypeFromDeclarator(decl.specs, decl.declarator)
+ case RefCPPGlobalDeclaration(decls, initIdx) =>
+ CPP.typeOrReturnTypeFromDeclarator(
+ decls.decl.specs,
+ decls.decl.inits(initIdx).decl,
+ )
+ case RefSYCLConstructorDefinition(typ) => typ
+ case RefCPPLambdaDefinition(_) => CPPTLambda()
+ case RefProverFunction(decl) => decl.returnType
+ case RefInstanceMethod(decl) => decl.returnType
+ case RefInstanceFunction(decl) => decl.returnType
+ case RefInstancePredicate(decl) => decl.returnType
+ case BuiltinInstanceMethod(f) =>
+ applicable match {
+ case _ =>
+ throw Unreachable(
+ "BuiltinInstanceMethod resolution of CPPInvocation cannot invoke anything."
+ )
+ }
}
- }
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
- Group(assoc(applicable) <> "(" <> Doc.args(args) <> ")" <> DocUtil.givenYields(givenArgs, yields))
-}
\ No newline at end of file
+ Group(
+ assoc(applicable) <> "(" <> Doc.args(args) <> ")" <>
+ DocUtil.givenYields(givenArgs, yields)
+ )
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPLambdaDeclaratorImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPLambdaDeclaratorImpl.scala
index e14f8715b8..5e508c5955 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPLambdaDeclaratorImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPLambdaDeclaratorImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.CPPLambdaDeclarator
import vct.col.print.{Ctx, Doc, Group, Text}
import vct.col.ast.ops.CPPLambdaDeclaratorOps
-trait CPPLambdaDeclaratorImpl[G] extends CPPLambdaDeclaratorOps[G] { this: CPPLambdaDeclarator[G] =>
+trait CPPLambdaDeclaratorImpl[G] extends CPPLambdaDeclaratorOps[G] {
+ this: CPPLambdaDeclarator[G] =>
override def layout(implicit ctx: Ctx): Doc =
Group(Text("(") <> Doc.args(params) <> ")")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPLambdaDefinitionImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPLambdaDefinitionImpl.scala
index 0f079a84a4..a310105373 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPLambdaDefinitionImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPLambdaDefinitionImpl.scala
@@ -4,11 +4,10 @@ import vct.col.ast.{CPPLambdaDefinition, CPPTLambda, Type}
import vct.col.print.{Ctx, Doc}
import vct.col.ast.ops.CPPLambdaDefinitionOps
-trait CPPLambdaDefinitionImpl[G] extends CPPLambdaDefinitionOps[G] { this: CPPLambdaDefinition[G] =>
+trait CPPLambdaDefinitionImpl[G] extends CPPLambdaDefinitionOps[G] {
+ this: CPPLambdaDefinition[G] =>
override lazy val t: Type[G] = CPPTLambda[G]()
override def layout(implicit ctx: Ctx): Doc =
- Doc.stack(Seq(
- contract, declarator.show <+> body.layoutAsBlock,
- ))
-}
\ No newline at end of file
+ Doc.stack(Seq(contract, declarator.show <+> body.layoutAsBlock))
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPLambdaRefImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPLambdaRefImpl.scala
index d676dc23f4..52cd8a8508 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPLambdaRefImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPLambdaRefImpl.scala
@@ -4,8 +4,9 @@ import vct.col.ast.{CPPLambdaRef, TRef, Type}
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.CPPLambdaRefOps
-trait CPPLambdaRefImpl[G] extends CPPLambdaRefOps[G] { this: CPPLambdaRef[G] =>
+trait CPPLambdaRefImpl[G] extends CPPLambdaRefOps[G] {
+ this: CPPLambdaRef[G] =>
override lazy val t: Type[G] = TRef()
override def layout(implicit ctx: Ctx): Doc = Text("VERCORS::LAMBDA")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPLifetimeScopeImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPLifetimeScopeImpl.scala
index bc4528db9d..1741ac9ed6 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPLifetimeScopeImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPLifetimeScopeImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CPPLifetimeScope
import vct.col.print.{Ctx, Doc}
import vct.col.ast.ops.CPPLifetimeScopeOps
-trait CPPLifetimeScopeImpl[G] extends CPPLifetimeScopeOps[G] {this: CPPLifetimeScope[G] =>
+trait CPPLifetimeScopeImpl[G] extends CPPLifetimeScopeOps[G] {
+ this: CPPLifetimeScope[G] =>
override def layout(implicit ctx: Ctx): Doc = body.show
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPLiteralArrayImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPLiteralArrayImpl.scala
index 18d1fd8b18..cfc5baa5c3 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPLiteralArrayImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPLiteralArrayImpl.scala
@@ -5,10 +5,12 @@ import vct.col.print.Doc.{arg, fold}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.CPPLiteralArrayOps
-trait CPPLiteralArrayImpl[G] extends CPPLiteralArrayOps[G] { this: CPPLiteralArray[G] =>
+trait CPPLiteralArrayImpl[G] extends CPPLiteralArrayOps[G] {
+ this: CPPLiteralArray[G] =>
override def t: Type[G] = new TNotAValue()
override def precedence = Precedence.ATOMIC
- override def layout(implicit ctx: Ctx): Doc = Text("{") <> arg(fold(exprs)(_ <> "," <+> _)) <> "}"
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ Text("{") <> arg(fold(exprs)(_ <> "," <+> _)) <> "}"
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPLocalDeclarationImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPLocalDeclarationImpl.scala
index f680a414bb..da5b67179a 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPLocalDeclarationImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPLocalDeclarationImpl.scala
@@ -4,6 +4,8 @@ import vct.col.ast.CPPLocalDeclaration
import vct.col.print.{Ctx, Doc}
import vct.col.ast.ops.{CPPLocalDeclarationOps, CPPLocalDeclarationFamilyOps}
-trait CPPLocalDeclarationImpl[G] extends CPPLocalDeclarationOps[G] with CPPLocalDeclarationFamilyOps[G] { this: CPPLocalDeclaration[G] =>
+trait CPPLocalDeclarationImpl[G]
+ extends CPPLocalDeclarationOps[G] with CPPLocalDeclarationFamilyOps[G] {
+ this: CPPLocalDeclaration[G] =>
override def layout(implicit ctx: Ctx): Doc = decl.show
}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPLocalImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPLocalImpl.scala
index 84f7506cf3..f951462bbb 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPLocalImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPLocalImpl.scala
@@ -7,33 +7,53 @@ import vct.col.resolve.lang.CPP
import vct.col.typerules.Types
import vct.col.ast.ops.CPPLocalOps
-trait CPPLocalImpl[G] extends CPPLocalOps[G] { this: CPPLocal[G] =>
- override lazy val t: Type[G] = ref.get match {
- case ref: RefCPPParam[G] => CPP.typeOrReturnTypeFromDeclarator(ref.decl.specifiers, ref.decl.declarator)
- case ref: RefAxiomaticDataType[G] => Types.notAValue(ref)
- case RefVariable(decl) => decl.t
- case ref: RefCPPFunctionDefinition[G] => Types.notAValue(ref)
- case ref @ RefCPPGlobalDeclaration(decls, initIdx) =>
- val declInfo = CPP.getDeclaratorInfo(decls.decl.inits(initIdx).decl)
- declInfo.params match {
- case Some(_) => Types.notAValue(ref) // Function declaration
- case None => declInfo.typeOrReturnType(CPPPrimitiveType(decls.decl.specs)) // Static declaration
- }
- case ref @ RefCPPLocalDeclaration(decls, initIdx) =>
- val declInfo = CPP.getDeclaratorInfo(decls.decl.inits(initIdx).decl)
- declInfo.params match {
- case Some(_) => Types.notAValue(ref) // Function declaration
- case None => declInfo.typeOrReturnType(CPPPrimitiveType(decls.decl.specs)) // Static declaration
- }
- case _: RefSYCLAccessMode[G] => SYCLTAccessMode()
- case ref: RefSYCLConstructorDefinition[G] => Types.notAValue(ref)
- case RefModelField(field) => field.t
- case target: SpecInvocationTarget[G] => Types.notAValue(target)
- case cls: RefClass[G] => Types.notAValue(cls)
- case enum: RefEnum[G] => Types.notAValue(enum)
- case RefEnumConstant(enum, _) => TEnum(enum.get.ref)
- }
+trait CPPLocalImpl[G] extends CPPLocalOps[G] {
+ this: CPPLocal[G] =>
+ override lazy val t: Type[G] =
+ ref.get match {
+ case ref: RefCPPParam[G] =>
+ CPP.typeOrReturnTypeFromDeclarator(
+ ref.decl.specifiers,
+ ref.decl.declarator,
+ )
+ case ref: RefAxiomaticDataType[G] => Types.notAValue(ref)
+ case RefVariable(decl) => decl.t
+ case ref: RefCPPFunctionDefinition[G] => Types.notAValue(ref)
+ case ref @ RefCPPGlobalDeclaration(decls, initIdx) =>
+ val declInfo = CPP.getDeclaratorInfo(decls.decl.inits(initIdx).decl)
+ declInfo.params match {
+ case Some(_) => Types.notAValue(ref) // Function declaration
+ case None =>
+ declInfo
+ .typeOrReturnType(CPPPrimitiveType(
+ decls.decl.specs
+ )) // Static declaration
+ }
+ case ref @ RefCPPLocalDeclaration(decls, initIdx) =>
+ val declInfo = CPP.getDeclaratorInfo(decls.decl.inits(initIdx).decl)
+ declInfo.params match {
+ case Some(_) => Types.notAValue(ref) // Function declaration
+ case None =>
+ declInfo
+ .typeOrReturnType(CPPPrimitiveType(
+ decls.decl.specs
+ )) // Static declaration
+ }
+ case _: RefSYCLAccessMode[G] => SYCLTAccessMode()
+ case ref: RefSYCLConstructorDefinition[G] => Types.notAValue(ref)
+ case RefModelField(field) => field.t
+ case target: SpecInvocationTarget[G] => Types.notAValue(target)
+ case cls: RefClass[G] => Types.notAValue(cls)
+ case enum: RefEnum[G] => Types.notAValue(enum)
+ case RefEnumConstant(enum, _) => TEnum(enum.get.ref)
+ }
- override def layout(implicit ctx: Ctx): Doc = Group(Text(name) <>
- (if (genericArgs.nonEmpty) (Text("<") <> Doc.args(genericArgs) <> Text(">")) else Empty))
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ Group(
+ Text(name) <>
+ (if (genericArgs.nonEmpty)
+ (Text("<") <> Doc.args(genericArgs) <> Text(">"))
+ else
+ Empty)
+ )
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPLongImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPLongImpl.scala
index 494318e6e0..b93bd08711 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPLongImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPLongImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CPPLong
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.CPPLongOps
-trait CPPLongImpl[G] extends CPPLongOps[G] { this: CPPLong[G] =>
+trait CPPLongImpl[G] extends CPPLongOps[G] {
+ this: CPPLong[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("long")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPNameImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPNameImpl.scala
index 4e6b0d0fea..c818346b89 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPNameImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPNameImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CPPName
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.CPPNameOps
-trait CPPNameImpl[G] extends CPPNameOps[G] { this: CPPName[G] =>
+trait CPPNameImpl[G] extends CPPNameOps[G] {
+ this: CPPName[G] =>
override def layout(implicit ctx: Ctx): Doc = Text(name)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPParamImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPParamImpl.scala
index 801a3a0420..05608f27fc 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPParamImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPParamImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.CPPParam
import vct.col.print.{Ctx, Doc}
import vct.col.ast.ops.{CPPParamOps, CPPParamFamilyOps}
-trait CPPParamImpl[G] extends CPPParamOps[G] with CPPParamFamilyOps[G] { this: CPPParam[G] =>
+trait CPPParamImpl[G] extends CPPParamOps[G] with CPPParamFamilyOps[G] {
+ this: CPPParam[G] =>
override def layout(implicit ctx: Ctx): Doc =
Doc.spread(specifiers) <+> declarator
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPPointerImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPPointerImpl.scala
index 906cb5ad23..a21fd48ca1 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPPointerImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPPointerImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CPPPointer
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.CPPPointerOps
-trait CPPPointerImpl[G] extends CPPPointerOps[G] { this: CPPPointer[G] =>
+trait CPPPointerImpl[G] extends CPPPointerOps[G] {
+ this: CPPPointer[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("*")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPPrimitiveTypeImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPPrimitiveTypeImpl.scala
index 503c1ad9d3..f65eb18bef 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPPrimitiveTypeImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPPrimitiveTypeImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CPPPrimitiveType
import vct.col.print.{Ctx, Doc}
import vct.col.ast.ops.CPPPrimitiveTypeOps
-trait CPPPrimitiveTypeImpl[G] extends CPPPrimitiveTypeOps[G] { this: CPPPrimitiveType[G] =>
+trait CPPPrimitiveTypeImpl[G] extends CPPPrimitiveTypeOps[G] {
+ this: CPPPrimitiveType[G] =>
override def layout(implicit ctx: Ctx): Doc = Doc.spread(specifiers)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPPureImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPPureImpl.scala
index f3706d1b2b..7a7eb2bc4b 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPPureImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPPureImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CPPPure
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.CPPPureOps
-trait CPPPureImpl[G] extends CPPPureOps[G] { this: CPPPure[G] =>
+trait CPPPureImpl[G] extends CPPPureOps[G] {
+ this: CPPPure[G] =>
override def layout(implicit ctx: Ctx): Doc = Doc.inlineSpec(Text("pure"))
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPReferenceImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPReferenceImpl.scala
index f191863592..41d8b5f014 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPReferenceImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPReferenceImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CPPReference
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.CPPReferenceOps
-trait CPPReferenceImpl[G] extends CPPReferenceOps[G] { this: CPPReference[G] =>
+trait CPPReferenceImpl[G] extends CPPReferenceOps[G] {
+ this: CPPReference[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("&")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPShortImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPShortImpl.scala
index c018004662..edb7d80211 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPShortImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPShortImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CPPShort
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.CPPShortOps
-trait CPPShortImpl[G] extends CPPShortOps[G] { this: CPPShort[G] =>
+trait CPPShortImpl[G] extends CPPShortOps[G] {
+ this: CPPShort[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("short")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPSignedImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPSignedImpl.scala
index 899bbc4be5..a04ac447ee 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPSignedImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPSignedImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CPPSigned
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.CPPSignedOps
-trait CPPSignedImpl[G] extends CPPSignedOps[G] { this: CPPSigned[G] =>
+trait CPPSignedImpl[G] extends CPPSignedOps[G] {
+ this: CPPSigned[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("signed")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPSpecificationModifierImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPSpecificationModifierImpl.scala
index 4ee92d0e50..9dfb589b36 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPSpecificationModifierImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPSpecificationModifierImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.lang.cpp
import vct.col.ast.CPPSpecificationModifier
-trait CPPSpecificationModifierImpl[G] { this: CPPSpecificationModifier[G] =>
+trait CPPSpecificationModifierImpl[G] {
+ this: CPPSpecificationModifier[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPSpecificationTypeImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPSpecificationTypeImpl.scala
index 670f9bce7b..8ec7a8c94b 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPSpecificationTypeImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPSpecificationTypeImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CPPSpecificationType
import vct.col.print.{Ctx, Doc}
import vct.col.ast.ops.CPPSpecificationTypeOps
-trait CPPSpecificationTypeImpl[G] extends CPPSpecificationTypeOps[G] { this: CPPSpecificationType[G] =>
+trait CPPSpecificationTypeImpl[G] extends CPPSpecificationTypeOps[G] {
+ this: CPPSpecificationType[G] =>
override def layout(implicit ctx: Ctx): Doc = t.show
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPStatementImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPStatementImpl.scala
index f98bf4f3ba..5467653b1c 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPStatementImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPStatementImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.lang.cpp
import vct.col.ast.CPPStatement
-trait CPPStatementImpl[G] { this: CPPStatement[G] =>
+trait CPPStatementImpl[G] {
+ this: CPPStatement[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPTArrayImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPTArrayImpl.scala
index 00ece02f0a..b3128ea093 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPTArrayImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPTArrayImpl.scala
@@ -4,8 +4,8 @@ import vct.col.ast.CPPTArray
import vct.col.print.{Ctx, Doc, Group}
import vct.col.ast.ops.CPPTArrayOps
-trait CPPTArrayImpl[G] extends CPPTArrayOps[G] { this: CPPTArray[G] =>
+trait CPPTArrayImpl[G] extends CPPTArrayOps[G] {
+ this: CPPTArray[G] =>
override def layout(implicit ctx: Ctx): Doc =
Group(innerType.show <> "[" <> Doc.args(size.toSeq) <> "]")
}
-
diff --git a/src/col/vct/col/ast/lang/cpp/CPPTLambdaImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPTLambdaImpl.scala
index 6c19892c25..76c68f8861 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPTLambdaImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPTLambdaImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CPPTLambda
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.CPPTLambdaOps
-trait CPPTLambdaImpl[G] extends CPPTLambdaOps[G] { this: CPPTLambda[G] =>
+trait CPPTLambdaImpl[G] extends CPPTLambdaOps[G] {
+ this: CPPTLambda[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("VERCORS::LAMBDA")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPTranslationUnitImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPTranslationUnitImpl.scala
index 0d9bb6b117..65986e04fe 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPTranslationUnitImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPTranslationUnitImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CPPTranslationUnit
import vct.col.print.{Ctx, Doc}
import vct.col.ast.ops.CPPTranslationUnitOps
-trait CPPTranslationUnitImpl[G] extends CPPTranslationUnitOps[G] { this: CPPTranslationUnit[G] =>
+trait CPPTranslationUnitImpl[G] extends CPPTranslationUnitOps[G] {
+ this: CPPTranslationUnit[G] =>
override def layout(implicit ctx: Ctx): Doc = Doc.stack(declarations)
}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPTypeImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPTypeImpl.scala
index 7e3f3da99e..8df469ab39 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPTypeImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPTypeImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.lang.cpp
import vct.col.ast.CPPType
-trait CPPTypeImpl[G] { this: CPPType[G] =>
+trait CPPTypeImpl[G] {
+ this: CPPType[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPTypeSpecifierImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPTypeSpecifierImpl.scala
index 1f47f648ff..f26a133340 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPTypeSpecifierImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPTypeSpecifierImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.lang.cpp
import vct.col.ast.CPPTypeSpecifier
-trait CPPTypeSpecifierImpl[G] { this: CPPTypeSpecifier[G] =>
+trait CPPTypeSpecifierImpl[G] {
+ this: CPPTypeSpecifier[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPTypedFunctionDeclaratorImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPTypedFunctionDeclaratorImpl.scala
index 29c9da7eb0..d9b3585aa9 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPTypedFunctionDeclaratorImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPTypedFunctionDeclaratorImpl.scala
@@ -4,7 +4,17 @@ import vct.col.ast.CPPTypedFunctionDeclarator
import vct.col.print.{Ctx, Doc, Group, Text}
import vct.col.ast.ops.CPPTypedFunctionDeclaratorOps
-trait CPPTypedFunctionDeclaratorImpl[G] extends CPPTypedFunctionDeclaratorOps[G] { this: CPPTypedFunctionDeclarator[G] =>
+trait CPPTypedFunctionDeclaratorImpl[G]
+ extends CPPTypedFunctionDeclaratorOps[G] {
+ this: CPPTypedFunctionDeclarator[G] =>
override def layout(implicit ctx: Ctx): Doc =
- Group(inner.show <> "(" <> Doc.args(params ++ (if(varargs) Seq(Text("...")) else Nil)) <> ")")
-}
\ No newline at end of file
+ Group(
+ inner.show <> "(" <> Doc.args(
+ params ++
+ (if (varargs)
+ Seq(Text("..."))
+ else
+ Nil)
+ ) <> ")"
+ )
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPTypedefNameImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPTypedefNameImpl.scala
index 7776ad8f3e..138c9e4f47 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPTypedefNameImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPTypedefNameImpl.scala
@@ -4,12 +4,19 @@ import vct.col.ast.CPPTypedefName
import vct.col.print.{Ctx, Doc, Group, Text}
import vct.col.ast.ops.CPPTypedefNameOps
-trait CPPTypedefNameImpl[G] extends CPPTypedefNameOps[G] { this: CPPTypedefName[G] =>
- override def layout(implicit ctx: Ctx): Doc = Group(Text(nestedName) <>
- (if (genericArgs.nonEmpty) (Text("<") <> Doc.args(genericArgs) <> Text(">")) else Text("")))
+trait CPPTypedefNameImpl[G] extends CPPTypedefNameOps[G] {
+ this: CPPTypedefName[G] =>
+ override def layout(implicit ctx: Ctx): Doc =
+ Group(
+ Text(nestedName) <>
+ (if (genericArgs.nonEmpty)
+ (Text("<") <> Doc.args(genericArgs) <> Text(">"))
+ else
+ Text(""))
+ )
def appendName(postfix: String): CPPTypedefName[G] = {
nestedName ++= postfix
this
}
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPUnsignedImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPUnsignedImpl.scala
index 86d0535614..44a54e3b75 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPUnsignedImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPUnsignedImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CPPUnsigned
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.CPPUnsignedOps
-trait CPPUnsignedImpl[G] extends CPPUnsignedOps[G] { this: CPPUnsigned[G] =>
+trait CPPUnsignedImpl[G] extends CPPUnsignedOps[G] {
+ this: CPPUnsigned[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("unsigned")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/cpp/CPPVoidImpl.scala b/src/col/vct/col/ast/lang/cpp/CPPVoidImpl.scala
index 6a14125d67..c4f99a1765 100644
--- a/src/col/vct/col/ast/lang/cpp/CPPVoidImpl.scala
+++ b/src/col/vct/col/ast/lang/cpp/CPPVoidImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CPPVoid
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.CPPVoidOps
-trait CPPVoidImpl[G] extends CPPVoidOps[G] { this: CPPVoid[G] =>
+trait CPPVoidImpl[G] extends CPPVoidOps[G] {
+ this: CPPVoid[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("void")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/gpgpu/GPUGlobalImpl.scala b/src/col/vct/col/ast/lang/gpgpu/GPUGlobalImpl.scala
index b377dbe042..6e395f145f 100644
--- a/src/col/vct/col/ast/lang/gpgpu/GPUGlobalImpl.scala
+++ b/src/col/vct/col/ast/lang/gpgpu/GPUGlobalImpl.scala
@@ -4,6 +4,8 @@ import vct.col.ast.GPUGlobal
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.GPUGlobalOps
-trait GPUGlobalImpl[G] extends GPUGlobalOps[G] { this: GPUGlobal[G] =>
- override def layout(implicit ctx: Ctx): Doc = Text("__vercors_global_memory__")
+trait GPUGlobalImpl[G] extends GPUGlobalOps[G] {
+ this: GPUGlobal[G] =>
+ override def layout(implicit ctx: Ctx): Doc =
+ Text("__vercors_global_memory__")
}
diff --git a/src/col/vct/col/ast/lang/gpgpu/GPULocalImpl.scala b/src/col/vct/col/ast/lang/gpgpu/GPULocalImpl.scala
index 85024ace45..12f502e8d1 100644
--- a/src/col/vct/col/ast/lang/gpgpu/GPULocalImpl.scala
+++ b/src/col/vct/col/ast/lang/gpgpu/GPULocalImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.GPULocal
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.GPULocalOps
-trait GPULocalImpl[G] extends GPULocalOps[G] {this: GPULocal[G] =>
+trait GPULocalImpl[G] extends GPULocalOps[G] {
+ this: GPULocal[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("__vercors_local_memory__")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/gpgpu/GpgpuAtomicImpl.scala b/src/col/vct/col/ast/lang/gpgpu/GpgpuAtomicImpl.scala
index 4d65563578..4cdd220925 100644
--- a/src/col/vct/col/ast/lang/gpgpu/GpgpuAtomicImpl.scala
+++ b/src/col/vct/col/ast/lang/gpgpu/GpgpuAtomicImpl.scala
@@ -4,15 +4,24 @@ import vct.col.ast.{GpgpuAtomic, Block}
import vct.col.print._
import vct.col.ast.ops.GpgpuAtomicOps
-trait GpgpuAtomicImpl[G] extends GpgpuAtomicOps[G] { this: GpgpuAtomic[G] =>
- def layoutWith(implicit ctx: Ctx): Doc = Group(Text("with") <+> before.layoutAsBlock)
+trait GpgpuAtomicImpl[G] extends GpgpuAtomicOps[G] {
+ this: GpgpuAtomic[G] =>
+ def layoutWith(implicit ctx: Ctx): Doc =
+ Group(Text("with") <+> before.layoutAsBlock)
- def layoutThen(implicit ctx: Ctx): Doc = Group(Text("then") <+> after.layoutAsBlock)
+ def layoutThen(implicit ctx: Ctx): Doc =
+ Group(Text("then") <+> after.layoutAsBlock)
override def layout(implicit ctx: Ctx): Doc =
Doc.stack(Seq(
- if(impl == Block[G](Nil)) Empty else Doc.inlineSpec(Show.lazily(layoutWith(_))),
+ if (impl == Block[G](Nil))
+ Empty
+ else
+ Doc.inlineSpec(Show.lazily(layoutWith(_))),
Text("__vercors_atomic__") <+> impl.layoutAsBlock,
- if(impl == Block[G](Nil)) Empty else Doc.inlineSpec(Show.lazily(layoutThen(_))),
+ if (impl == Block[G](Nil))
+ Empty
+ else
+ Doc.inlineSpec(Show.lazily(layoutThen(_))),
))
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/gpgpu/GpgpuBarrierImpl.scala b/src/col/vct/col/ast/lang/gpgpu/GpgpuBarrierImpl.scala
index e9e0a71e51..e4ab6fe736 100644
--- a/src/col/vct/col/ast/lang/gpgpu/GpgpuBarrierImpl.scala
+++ b/src/col/vct/col/ast/lang/gpgpu/GpgpuBarrierImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.GpgpuBarrier
import vct.col.print.{Ctx, Doc, DocUtil, Show, Text, Group}
import vct.col.ast.ops.GpgpuBarrierOps
-trait GpgpuBarrierImpl[G] extends GpgpuBarrierOps[G] { this: GpgpuBarrier[G] =>
+trait GpgpuBarrierImpl[G] extends GpgpuBarrierOps[G] {
+ this: GpgpuBarrier[G] =>
def layoutContract(implicit ctx: Ctx): Doc =
Doc.stack(Seq(
DocUtil.clauses("requires", requires),
@@ -15,7 +16,8 @@ trait GpgpuBarrierImpl[G] extends GpgpuBarrierOps[G] { this: GpgpuBarrier[G] =>
Doc.stack(Seq(
Doc.spec(Show.lazily(layoutContract(_))),
Group(
- Text("__vercors_barrier__") <> "(" <> Doc.arg(Doc.fold(specifiers)(_ <+> "|" <+/> _)) <> ")"
+ Text("__vercors_barrier__") <> "(" <>
+ Doc.arg(Doc.fold(specifiers)(_ <+> "|" <+/> _)) <> ")"
),
))
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/gpgpu/GpgpuCudaKernelInvocationImpl.scala b/src/col/vct/col/ast/lang/gpgpu/GpgpuCudaKernelInvocationImpl.scala
index dbc159b30e..89da73ed96 100644
--- a/src/col/vct/col/ast/lang/gpgpu/GpgpuCudaKernelInvocationImpl.scala
+++ b/src/col/vct/col/ast/lang/gpgpu/GpgpuCudaKernelInvocationImpl.scala
@@ -6,23 +6,36 @@ import vct.col.resolve.ctx._
import vct.col.resolve.lang.C
import vct.col.ast.ops.GpgpuCudaKernelInvocationOps
-trait GpgpuCudaKernelInvocationImpl[G] extends GpgpuCudaKernelInvocationOps[G] { this: GpgpuCudaKernelInvocation[G] =>
- override lazy val t: Type[G] = ref.get match {
- case RefFunction(decl) => decl.returnType
- case RefProcedure(decl) => decl.returnType
- case RefPredicate(decl) => decl.returnType
- case RefInstanceFunction(decl) => decl.returnType
- case RefInstanceMethod(decl) => decl.returnType
- case RefInstancePredicate(decl) => decl.returnType
- case RefADTFunction(decl) => decl.returnType
- case RefModelProcess(decl) => decl.returnType
- case RefModelAction(decl) => decl.returnType
- case RefCFunctionDefinition(decl) => C.typeOrReturnTypeFromDeclaration(decl.specs, decl.declarator)
- case RefCGlobalDeclaration(decls, initIdx) => C.typeOrReturnTypeFromDeclaration(decls.decl.specs, decls.decl.inits(initIdx).decl)
- case BuiltinInstanceMethod(f) => ???
- case RefProverFunction(decl) => decl.returnType
- }
+trait GpgpuCudaKernelInvocationImpl[G] extends GpgpuCudaKernelInvocationOps[G] {
+ this: GpgpuCudaKernelInvocation[G] =>
+ override lazy val t: Type[G] =
+ ref.get match {
+ case RefFunction(decl) => decl.returnType
+ case RefProcedure(decl) => decl.returnType
+ case RefPredicate(decl) => decl.returnType
+ case RefInstanceFunction(decl) => decl.returnType
+ case RefInstanceMethod(decl) => decl.returnType
+ case RefInstancePredicate(decl) => decl.returnType
+ case RefADTFunction(decl) => decl.returnType
+ case RefModelProcess(decl) => decl.returnType
+ case RefModelAction(decl) => decl.returnType
+ case RefCFunctionDefinition(decl) =>
+ C.typeOrReturnTypeFromDeclaration(decl.specs, decl.declarator)
+ case RefCGlobalDeclaration(decls, initIdx) =>
+ C.typeOrReturnTypeFromDeclaration(
+ decls.decl.specs,
+ decls.decl.inits(initIdx).decl,
+ )
+ case BuiltinInstanceMethod(f) => ???
+ case RefProverFunction(decl) => decl.returnType
+ }
override def layout(implicit ctx: Ctx): Doc =
- Group(Group(Group(Text(kernel) <> "<<<" <> Doc.args(Seq(blocks, threads)) <> ">>>") <> "(" <> Doc.args(args) <> ")") <> DocUtil.givenYields(givenArgs, yields))
-}
\ No newline at end of file
+ Group(
+ Group(
+ Group(
+ Text(kernel) <> "<<<" <> Doc.args(Seq(blocks, threads)) <> ">>>"
+ ) <> "(" <> Doc.args(args) <> ")"
+ ) <> DocUtil.givenYields(givenArgs, yields)
+ )
+}
diff --git a/src/col/vct/col/ast/lang/gpgpu/GpuGlobalMemoryFenceImpl.scala b/src/col/vct/col/ast/lang/gpgpu/GpuGlobalMemoryFenceImpl.scala
index 263e1f4c68..ce2bdd9c5f 100644
--- a/src/col/vct/col/ast/lang/gpgpu/GpuGlobalMemoryFenceImpl.scala
+++ b/src/col/vct/col/ast/lang/gpgpu/GpuGlobalMemoryFenceImpl.scala
@@ -4,6 +4,8 @@ import vct.col.ast.GpuGlobalMemoryFence
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.GpuGlobalMemoryFenceOps
-trait GpuGlobalMemoryFenceImpl[G] extends GpuGlobalMemoryFenceOps[G] { this: GpuGlobalMemoryFence[G] =>
- override def layout(implicit ctx: Ctx): Doc = Text("__vercors_global_mem_fence__")
+trait GpuGlobalMemoryFenceImpl[G] extends GpuGlobalMemoryFenceOps[G] {
+ this: GpuGlobalMemoryFence[G] =>
+ override def layout(implicit ctx: Ctx): Doc =
+ Text("__vercors_global_mem_fence__")
}
diff --git a/src/col/vct/col/ast/lang/gpgpu/GpuLocalMemoryFenceImpl.scala b/src/col/vct/col/ast/lang/gpgpu/GpuLocalMemoryFenceImpl.scala
index 470949b9df..7c17363ffa 100644
--- a/src/col/vct/col/ast/lang/gpgpu/GpuLocalMemoryFenceImpl.scala
+++ b/src/col/vct/col/ast/lang/gpgpu/GpuLocalMemoryFenceImpl.scala
@@ -4,6 +4,8 @@ import vct.col.ast.GpuLocalMemoryFence
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.GpuLocalMemoryFenceOps
-trait GpuLocalMemoryFenceImpl[G] extends GpuLocalMemoryFenceOps[G] { this: GpuLocalMemoryFence[G] =>
- override def layout(implicit ctx: Ctx): Doc = Text("__vercors_local_mem_fence__")
+trait GpuLocalMemoryFenceImpl[G] extends GpuLocalMemoryFenceOps[G] {
+ this: GpuLocalMemoryFence[G] =>
+ override def layout(implicit ctx: Ctx): Doc =
+ Text("__vercors_local_mem_fence__")
}
diff --git a/src/col/vct/col/ast/lang/gpgpu/GpuMemoryFenceImpl.scala b/src/col/vct/col/ast/lang/gpgpu/GpuMemoryFenceImpl.scala
index d3f879d224..73371610fb 100644
--- a/src/col/vct/col/ast/lang/gpgpu/GpuMemoryFenceImpl.scala
+++ b/src/col/vct/col/ast/lang/gpgpu/GpuMemoryFenceImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.lang.gpgpu
import vct.col.ast.GpuMemoryFence
import vct.col.ast.ops.GpuMemoryFenceFamilyOps
-trait GpuMemoryFenceImpl[G] extends GpuMemoryFenceFamilyOps[G] { this: GpuMemoryFence[G] =>
+trait GpuMemoryFenceImpl[G] extends GpuMemoryFenceFamilyOps[G] {
+ this: GpuMemoryFence[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/gpgpu/GpuZeroMemoryFenceImpl.scala b/src/col/vct/col/ast/lang/gpgpu/GpuZeroMemoryFenceImpl.scala
index eb6abd8757..d8dfb1576c 100644
--- a/src/col/vct/col/ast/lang/gpgpu/GpuZeroMemoryFenceImpl.scala
+++ b/src/col/vct/col/ast/lang/gpgpu/GpuZeroMemoryFenceImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.GpuZeroMemoryFence
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.GpuZeroMemoryFenceOps
-trait GpuZeroMemoryFenceImpl[G] extends GpuZeroMemoryFenceOps[G] { this: GpuZeroMemoryFence[G] =>
+trait GpuZeroMemoryFenceImpl[G] extends GpuZeroMemoryFenceOps[G] {
+ this: GpuZeroMemoryFence[G] =>
override def layout(implicit ctx: Ctx): Doc = Text(value.toString)
}
diff --git a/src/col/vct/col/ast/lang/gpgpu/OpenCLKernelImpl.scala b/src/col/vct/col/ast/lang/gpgpu/OpenCLKernelImpl.scala
index b39d665e3e..ff990b9a51 100644
--- a/src/col/vct/col/ast/lang/gpgpu/OpenCLKernelImpl.scala
+++ b/src/col/vct/col/ast/lang/gpgpu/OpenCLKernelImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.OpenCLKernel
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.OpenCLKernelOps
-trait OpenCLKernelImpl[G] extends OpenCLKernelOps[G] { this: OpenCLKernel[G] =>
+trait OpenCLKernelImpl[G] extends OpenCLKernelOps[G] {
+ this: OpenCLKernel[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("__kernel")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/gpgpu/SharedMemSizeImpl.scala b/src/col/vct/col/ast/lang/gpgpu/SharedMemSizeImpl.scala
index 4af6efaedd..453c062bc8 100644
--- a/src/col/vct/col/ast/lang/gpgpu/SharedMemSizeImpl.scala
+++ b/src/col/vct/col/ast/lang/gpgpu/SharedMemSizeImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{SharedMemSize, TCInt, Type}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.SharedMemSizeOps
-trait SharedMemSizeImpl[G] extends SharedMemSizeOps[G] { this: SharedMemSize[G] =>
+trait SharedMemSizeImpl[G] extends SharedMemSizeOps[G] {
+ this: SharedMemSize[G] =>
override def t: Type[G] = TCInt()
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Text("\\shared_mem_size(") <> pointer <> ")"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaAbstractImpl.scala b/src/col/vct/col/ast/lang/java/JavaAbstractImpl.scala
index bf3c13e683..bf81e757dd 100644
--- a/src/col/vct/col/ast/lang/java/JavaAbstractImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaAbstractImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.JavaAbstract
import vct.col.print._
import vct.col.ast.ops.JavaAbstractOps
-trait JavaAbstractImpl[G] extends JavaAbstractOps[G] { this: JavaAbstract[G] =>
+trait JavaAbstractImpl[G] extends JavaAbstractOps[G] {
+ this: JavaAbstract[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("abstract")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaAnnotationImpl.scala b/src/col/vct/col/ast/lang/java/JavaAnnotationImpl.scala
index edb846c94d..52c639222e 100644
--- a/src/col/vct/col/ast/lang/java/JavaAnnotationImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaAnnotationImpl.scala
@@ -8,15 +8,19 @@ import vct.result.VerificationError.UserError
import vct.col.ast.ops.JavaAnnotationOps
object JavaAnnotationImpl {
- case class AnnotationElementMissing(ann: JavaAnnotation[_], element: String) extends UserError {
+ case class AnnotationElementMissing(ann: JavaAnnotation[_], element: String)
+ extends UserError {
override def code: String = "annotationElementMissing"
- override def text: String = ann.o.messageInContext(s"The element $element should be present")
+ override def text: String =
+ ann.o.messageInContext(s"The element $element should be present")
}
}
object JavaAnnotationEx {
- def unapply[G](ja: JavaAnnotation[G]): Option[(Type[G], Seq[(String, Expr[G])], JavaAnnotationData[G])] = {
+ def unapply[G](
+ ja: JavaAnnotation[G]
+ ): Option[(Type[G], Seq[(String, Expr[G])], JavaAnnotationData[G])] = {
ja.data match {
case Some(data) => Some(ja.name, ja.args, data)
case None => None
@@ -24,14 +28,18 @@ object JavaAnnotationEx {
}
}
-trait JavaAnnotationImpl[G] extends JavaAnnotationOps[G] { this: JavaAnnotation[G] =>
+trait JavaAnnotationImpl[G] extends JavaAnnotationOps[G] {
+ this: JavaAnnotation[G] =>
def get(n: String): Option[Expr[G]] = args.find(_._1 == n).map(_._2)
- def expect(elem: String): Expr[G] = get(elem) match {
- case Some(expr) => expr
- case None => throw AnnotationElementMissing(this, elem)
- }
+ def expect(elem: String): Expr[G] =
+ get(elem) match {
+ case Some(expr) => expr
+ case None => throw AnnotationElementMissing(this, elem)
+ }
override def layout(implicit ctx: Ctx): Doc =
- Text("@") <> name <> "(" <> Doc.args(args.map { case (key, value) => Text(key) <> "=" <> value }) <> ")"
-}
\ No newline at end of file
+ Text("@") <> name <> "(" <> Doc.args(args.map { case (key, value) =>
+ Text(key) <> "=" <> value
+ }) <> ")"
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaAnnotationInterfaceImpl.scala b/src/col/vct/col/ast/lang/java/JavaAnnotationInterfaceImpl.scala
index 22b6f49ce1..c006891b20 100644
--- a/src/col/vct/col/ast/lang/java/JavaAnnotationInterfaceImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaAnnotationInterfaceImpl.scala
@@ -3,7 +3,8 @@ package vct.col.ast.lang.java
import vct.col.ast.{JavaAnnotationInterface, Type, Variable}
import vct.col.ast.ops.JavaAnnotationInterfaceOps
-trait JavaAnnotationInterfaceImpl[G] extends JavaAnnotationInterfaceOps[G] { this: JavaAnnotationInterface[G] =>
+trait JavaAnnotationInterfaceImpl[G] extends JavaAnnotationInterfaceOps[G] {
+ this: JavaAnnotationInterface[G] =>
override def supports: Seq[Type[G]] = Seq(ext)
override def typeParams: Seq[Variable[G]] = Seq()
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaAnnotationMethodImpl.scala b/src/col/vct/col/ast/lang/java/JavaAnnotationMethodImpl.scala
index 14fc5c997f..eb4a652755 100644
--- a/src/col/vct/col/ast/lang/java/JavaAnnotationMethodImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaAnnotationMethodImpl.scala
@@ -4,7 +4,9 @@ import vct.col.ast.{Declaration, JavaAnnotationMethod}
import vct.col.ast.util.Declarator
import vct.col.ast.ops.JavaAnnotationMethodOps
-trait JavaAnnotationMethodImpl[G] extends Declarator[G] with JavaAnnotationMethodOps[G] { this: JavaAnnotationMethod[G] =>
+trait JavaAnnotationMethodImpl[G]
+ extends Declarator[G] with JavaAnnotationMethodOps[G] {
+ this: JavaAnnotationMethod[G] =>
override def declarations: Seq[Declaration[G]] = Seq()
override def isStatic = false
}
diff --git a/src/col/vct/col/ast/lang/java/JavaClassDeclarationImpl.scala b/src/col/vct/col/ast/lang/java/JavaClassDeclarationImpl.scala
index 1789d711e9..c39842d81d 100644
--- a/src/col/vct/col/ast/lang/java/JavaClassDeclarationImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaClassDeclarationImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.lang.java
import vct.col.ast.JavaClassDeclaration
-trait JavaClassDeclarationImpl[G] { this: JavaClassDeclaration[G] =>
+trait JavaClassDeclarationImpl[G] {
+ this: JavaClassDeclaration[G] =>
def isStatic: Boolean
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaClassImpl.scala b/src/col/vct/col/ast/lang/java/JavaClassImpl.scala
index b6601ed02b..6f8c30b5cd 100644
--- a/src/col/vct/col/ast/lang/java/JavaClassImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaClassImpl.scala
@@ -6,40 +6,56 @@ import vct.col.resolve.ctx._
import vct.col.util.AstBuildHelpers.tt
import vct.col.ast.ops.JavaClassOps
-trait JavaClassImpl[G] extends JavaClassOps[G] { this: JavaClass[G] =>
+trait JavaClassImpl[G] extends JavaClassOps[G] {
+ this: JavaClass[G] =>
override def supports: Seq[Type[G]] = ext +: imp
- def getField(name: String): Option[JavaFields[G]] = decls.collectFirst {
- case fields: JavaFields[G] if fields.decls.exists(_.name == name) => fields
- }
+ def getField(name: String): Option[JavaFields[G]] =
+ decls.collectFirst {
+ case fields: JavaFields[G] if fields.decls.exists(_.name == name) =>
+ fields
+ }
- def getFieldRef(name: String): Option[RefJavaField[G]] = getField(name).map({
- case fields => RefJavaField(fields, fields.decls.indexWhere(_.name == name))
- })
+ def getFieldRef(name: String): Option[RefJavaField[G]] =
+ getField(name).map({ case fields =>
+ RefJavaField(fields, fields.decls.indexWhere(_.name == name))
+ })
- def getInstanceField(name: String): Option[RefJavaField[G]] = getFieldRef(name).collect({
- case r @ RefJavaField(decls, idx) if !decls.isStatic => r
- })
+ def getInstanceField(name: String): Option[RefJavaField[G]] =
+ getFieldRef(name).collect({
+ case r @ RefJavaField(decls, idx) if !decls.isStatic => r
+ })
- def getClassField(name: String): Option[RefJavaField[G]] = getFieldRef(name).collect({
- case r @ RefJavaField(decls, idx) if decls.isStatic => r
- })
+ def getClassField(name: String): Option[RefJavaField[G]] =
+ getFieldRef(name).collect({
+ case r @ RefJavaField(decls, idx) if decls.isStatic => r
+ })
- def getMethods(name: String): Seq[RefJavaMethod[G]] = decls.collect {
- case m: JavaMethod[G] if m.name == name => RefJavaMethod(m)
- }
+ def getMethods(name: String): Seq[RefJavaMethod[G]] =
+ decls.collect {
+ case m: JavaMethod[G] if m.name == name => RefJavaMethod(m)
+ }
def layoutLockInvariant(implicit ctx: Ctx): Doc =
Text("lock_invariant") <+> intrinsicLockInvariant <> ";"
override def layout(implicit ctx: Ctx): Doc = {
Doc.stack(Seq(
- if(intrinsicLockInvariant == tt[G]) Empty else Doc.inlineSpec(Show.lazily(layoutLockInvariant(_))),
- Group(Doc.spread(modifiers :+ Text("class")) <+> name <>
- (if(typeParams.isEmpty) Empty else Text("<") <> Doc.args(typeParams) <> ">") <+>
- "extends" <+> ext <>
- (if(imp.isEmpty) Empty else Empty <+> "implements" <+> Doc.args(imp))) <+>
- "{" <>> Doc.stack(decls) <+/> "}",
+ if (intrinsicLockInvariant == tt[G])
+ Empty
+ else
+ Doc.inlineSpec(Show.lazily(layoutLockInvariant(_))),
+ Group(
+ Doc.spread(modifiers :+ Text("class")) <+> name <>
+ (if (typeParams.isEmpty)
+ Empty
+ else
+ Text("<") <> Doc.args(typeParams) <> ">") <+> "extends" <+> ext <>
+ (if (imp.isEmpty)
+ Empty
+ else
+ Empty <+> "implements" <+> Doc.args(imp))
+ ) <+> "{" <>> Doc.stack(decls) <+/> "}",
))
}
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaClassOrInterfaceImpl.scala b/src/col/vct/col/ast/lang/java/JavaClassOrInterfaceImpl.scala
index 81437331ba..281fc7bfdd 100644
--- a/src/col/vct/col/ast/lang/java/JavaClassOrInterfaceImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaClassOrInterfaceImpl.scala
@@ -1,23 +1,36 @@
package vct.col.ast.lang.java
-import vct.col.ast.{ClassDeclaration, Declaration, JavaAnnotationMethod, JavaClassOrInterface, JavaMethod, JavaModifier, JavaName, JavaTClass, Type, Variable}
+import vct.col.ast.{
+ ClassDeclaration,
+ Declaration,
+ JavaAnnotationMethod,
+ JavaClassOrInterface,
+ JavaMethod,
+ JavaModifier,
+ JavaName,
+ JavaTClass,
+ Type,
+ Variable,
+}
import vct.col.origin.DiagnosticOrigin
import vct.col.ref.Ref
import vct.result.VerificationError.Unreachable
import scala.reflect.ClassTag
-trait JavaClassOrInterfaceImpl[G] { this: JavaClassOrInterface[G] =>
+trait JavaClassOrInterfaceImpl[G] {
+ this: JavaClassOrInterface[G] =>
def name: String
def modifiers: Seq[JavaModifier[G]]
def typeParams: Seq[Variable[G]]
def decls: Seq[ClassDeclaration[G]]
def supports: Seq[Type[G]]
- def transSupportArrows(seen: Set[JavaClassOrInterface[G]]): Seq[(JavaClassOrInterface[G], JavaClassOrInterface[G])] = {
- if(seen.contains(this)) {
- Nil
- } else {
+ def transSupportArrows(
+ seen: Set[JavaClassOrInterface[G]]
+ ): Seq[(JavaClassOrInterface[G], JavaClassOrInterface[G])] = {
+ if (seen.contains(this)) { Nil }
+ else {
val ts = supports.flatMap {
case JavaTClass(Ref(cls), _) => Seq(cls)
case _ => Nil
@@ -29,15 +42,16 @@ trait JavaClassOrInterfaceImpl[G] { this: JavaClassOrInterface[G] =>
override def declarations: Seq[Declaration[G]] = typeParams ++ decls
- def findMethodByName[Decl <: ClassDeclaration[G]](name: String)(implicit tag: ClassTag[Decl]): Seq[Decl] = {
- def matches(decl: ClassDeclaration[G]): Boolean = decl match {
- case decl: JavaMethod[G] if decl.name == name => true
- case decl: JavaAnnotationMethod[G] if decl.name == name => true
- case _ => false
- }
+ def findMethodByName[Decl <: ClassDeclaration[G]](
+ name: String
+ )(implicit tag: ClassTag[Decl]): Seq[Decl] = {
+ def matches(decl: ClassDeclaration[G]): Boolean =
+ decl match {
+ case decl: JavaMethod[G] if decl.name == name => true
+ case decl: JavaAnnotationMethod[G] if decl.name == name => true
+ case _ => false
+ }
- decls.collect {
- case decl: Decl if matches(decl) => decl
- }
+ decls.collect { case decl: Decl if matches(decl) => decl }
}
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaConstructorImpl.scala b/src/col/vct/col/ast/lang/java/JavaConstructorImpl.scala
index a10d2462ed..1103129e48 100644
--- a/src/col/vct/col/ast/lang/java/JavaConstructorImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaConstructorImpl.scala
@@ -5,19 +5,30 @@ import vct.col.ast.{Declaration, JavaConstructor}
import vct.col.print._
import vct.col.ast.ops.JavaConstructorOps
-trait JavaConstructorImpl[G] extends Declarator[G] with JavaConstructorOps[G] { this: JavaConstructor[G] =>
- override def declarations: Seq[Declaration[G]] = parameters ++ typeParameters ++ contract.givenArgs ++ contract.yieldsArgs
+trait JavaConstructorImpl[G] extends Declarator[G] with JavaConstructorOps[G] {
+ this: JavaConstructor[G] =>
+ override def declarations: Seq[Declaration[G]] =
+ parameters ++ typeParameters ++ contract.givenArgs ++ contract.yieldsArgs
override def isStatic = false
def layoutTypeArgs(implicit ctx: Ctx): Doc =
- if(typeParameters.isEmpty) Empty else Text("<") <> Doc.args(typeParameters) <> ">"
+ if (typeParameters.isEmpty)
+ Empty
+ else
+ Text("<") <> Doc.args(typeParameters) <> ">"
def layoutSignals(implicit ctx: Ctx): Doc =
- if(signals.isEmpty) Empty else Empty <>> Group(Text("throws") <+> Doc.args(signals))
+ if (signals.isEmpty)
+ Empty
+ else
+ Empty <>> Group(Text("throws") <+> Doc.args(signals))
override def layout(implicit ctx: Ctx): Doc =
Doc.stack(Seq(
contract,
- Group(Doc.spread(modifiers :+ layoutTypeArgs :+ Text(name)) <> "(" <> Doc.args(parameters) <> ")" <> layoutSignals) <+> body.layoutAsBlock,
+ Group(
+ Doc.spread(modifiers :+ layoutTypeArgs :+ Text(name)) <> "(" <>
+ Doc.args(parameters) <> ")" <> layoutSignals
+ ) <+> body.layoutAsBlock,
))
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaDerefImpl.scala b/src/col/vct/col/ast/lang/java/JavaDerefImpl.scala
index 6b80efde82..b5b8011951 100644
--- a/src/col/vct/col/ast/lang/java/JavaDerefImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaDerefImpl.scala
@@ -7,22 +7,24 @@ import vct.col.resolve.ctx._
import vct.col.typerules.Types
import vct.col.ast.ops.JavaDerefOps
-trait JavaDerefImpl[G] extends JavaDerefOps[G] { this: JavaDeref[G] =>
- override lazy val t: Type[G] = ref.get match {
- case RefModelField(decl) => decl.t
- case ref: RefUnloadedJavaNamespace[G] => Types.notAValue(ref)
- case ref: RefJavaClass[G] => Types.notAValue(ref)
- case ref: RefAxiomaticDataType[G] => Types.notAValue(ref)
- case ref: RefModel[G] => Types.notAValue(ref)
- case RefVariable(v) => v.t
- case RefJavaField(decls, idx) => FuncTools.repeat[Type[G]](TArray(_), decls.decls(idx).moreDims, decls.t)
- case RefEnumConstant(enum, _) => TEnum(enum.get.ref)
- case BuiltinField(f) => f(obj).t
- case ref: RefEnum[G] => Types.notAValue(ref)
- case ref: RefProverType[G] => Types.notAValue(ref)
- }
+trait JavaDerefImpl[G] extends JavaDerefOps[G] {
+ this: JavaDeref[G] =>
+ override lazy val t: Type[G] =
+ ref.get match {
+ case RefModelField(decl) => decl.t
+ case ref: RefUnloadedJavaNamespace[G] => Types.notAValue(ref)
+ case ref: RefJavaClass[G] => Types.notAValue(ref)
+ case ref: RefAxiomaticDataType[G] => Types.notAValue(ref)
+ case ref: RefModel[G] => Types.notAValue(ref)
+ case RefVariable(v) => v.t
+ case RefJavaField(decls, idx) =>
+ FuncTools.repeat[Type[G]](TArray(_), decls.decls(idx).moreDims, decls.t)
+ case RefEnumConstant(enum, _) => TEnum(enum.get.ref)
+ case BuiltinField(f) => f(obj).t
+ case ref: RefEnum[G] => Types.notAValue(ref)
+ case ref: RefProverType[G] => Types.notAValue(ref)
+ }
override def precedence: Int = Precedence.POSTFIX
- override def layout(implicit ctx: Ctx): Doc =
- assoc(obj) <> "." <> field
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc = assoc(obj) <> "." <> field
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaExprImpl.scala b/src/col/vct/col/ast/lang/java/JavaExprImpl.scala
index 7477258cad..0f91b1b087 100644
--- a/src/col/vct/col/ast/lang/java/JavaExprImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaExprImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.lang.java
import vct.col.ast.JavaExpr
-trait JavaExprImpl[G] { this: JavaExpr[G] =>
+trait JavaExprImpl[G] {
+ this: JavaExpr[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaFieldsImpl.scala b/src/col/vct/col/ast/lang/java/JavaFieldsImpl.scala
index 17ecc82fe9..772e622a51 100644
--- a/src/col/vct/col/ast/lang/java/JavaFieldsImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaFieldsImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{JavaFields, JavaStatic}
import vct.col.print._
import vct.col.ast.ops.JavaFieldsOps
-trait JavaFieldsImpl[G] extends JavaFieldsOps[G] { this: JavaFields[G] =>
+trait JavaFieldsImpl[G] extends JavaFieldsOps[G] {
+ this: JavaFields[G] =>
override def isStatic = modifiers.contains(JavaStatic[G]())
override def layout(implicit ctx: Ctx): Doc =
Doc.rspread(modifiers) <> t <+> Doc.spread(decls) <> ";"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaFinalImpl.scala b/src/col/vct/col/ast/lang/java/JavaFinalImpl.scala
index 3ae75ca764..57e05a8934 100644
--- a/src/col/vct/col/ast/lang/java/JavaFinalImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaFinalImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.JavaFinal
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.JavaFinalOps
-trait JavaFinalImpl[G] extends JavaFinalOps[G] { this: JavaFinal[G] =>
+trait JavaFinalImpl[G] extends JavaFinalOps[G] {
+ this: JavaFinal[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("final")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaGlobalDeclarationImpl.scala b/src/col/vct/col/ast/lang/java/JavaGlobalDeclarationImpl.scala
index 37327d091e..2fcc7896d0 100644
--- a/src/col/vct/col/ast/lang/java/JavaGlobalDeclarationImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaGlobalDeclarationImpl.scala
@@ -2,5 +2,6 @@ package vct.col.ast.lang.java
import vct.col.ast.{JavaGlobalDeclaration}
-trait JavaGlobalDeclarationImpl[G] { this: JavaGlobalDeclaration[G] =>
-}
\ No newline at end of file
+trait JavaGlobalDeclarationImpl[G] {
+ this: JavaGlobalDeclaration[G] =>
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaImportImpl.scala b/src/col/vct/col/ast/lang/java/JavaImportImpl.scala
index c81762943c..4cdbce4354 100644
--- a/src/col/vct/col/ast/lang/java/JavaImportImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaImportImpl.scala
@@ -4,8 +4,17 @@ import vct.col.ast.JavaImport
import vct.col.print.{Ctx, Doc, Text, Empty}
import vct.col.ast.ops.{JavaImportOps, JavaImportFamilyOps}
-trait JavaImportImpl[G] extends JavaImportOps[G] with JavaImportFamilyOps[G] { this: JavaImport[G] =>
+trait JavaImportImpl[G] extends JavaImportOps[G] with JavaImportFamilyOps[G] {
+ this: JavaImport[G] =>
override def layout(implicit ctx: Ctx): Doc =
- Text(if(isStatic) "import static" else "import") <+>
- name <> (if(star) Text(".*") else Empty)
-}
\ No newline at end of file
+ Text(
+ if (isStatic)
+ "import static"
+ else
+ "import"
+ ) <+> name <>
+ (if (star)
+ Text(".*")
+ else
+ Empty)
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaInlineImpl.scala b/src/col/vct/col/ast/lang/java/JavaInlineImpl.scala
index f5907149b7..d943eb4bf7 100644
--- a/src/col/vct/col/ast/lang/java/JavaInlineImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaInlineImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.JavaInline
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.JavaInlineOps
-trait JavaInlineImpl[G] extends JavaInlineOps[G] { this: JavaInline[G] =>
+trait JavaInlineImpl[G] extends JavaInlineOps[G] {
+ this: JavaInline[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("inline")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaInterfaceImpl.scala b/src/col/vct/col/ast/lang/java/JavaInterfaceImpl.scala
index d35b70722a..6bd65a8fe7 100644
--- a/src/col/vct/col/ast/lang/java/JavaInterfaceImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaInterfaceImpl.scala
@@ -5,13 +5,21 @@ import vct.col.print.{Ctx, Doc, Empty, Group, Show, Text}
import vct.col.util.AstBuildHelpers.tt
import vct.col.ast.ops.JavaInterfaceOps
-trait JavaInterfaceImpl[G] extends JavaInterfaceOps[G] { this: JavaInterface[G] =>
+trait JavaInterfaceImpl[G] extends JavaInterfaceOps[G] {
+ this: JavaInterface[G] =>
override def supports: Seq[Type[G]] = ext
override def layout(implicit ctx: Ctx): Doc = {
- Group(Doc.spread(modifiers :+ Text("interface")) <+> name <>
- (if (typeParams.isEmpty) Empty else Text("<") <> Doc.args(typeParams) <> ">") <>
- (if (ext.isEmpty) Empty else Empty <+> "extends" <+> Doc.args(ext))) <+>
- "{" <>> Doc.stack(decls) <+/> "}"
+ Group(
+ Doc.spread(modifiers :+ Text("interface")) <+> name <>
+ (if (typeParams.isEmpty)
+ Empty
+ else
+ Text("<") <> Doc.args(typeParams) <> ">") <>
+ (if (ext.isEmpty)
+ Empty
+ else
+ Empty <+> "extends" <+> Doc.args(ext))
+ ) <+> "{" <>> Doc.stack(decls) <+/> "}"
}
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaInvocationImpl.scala b/src/col/vct/col/ast/lang/java/JavaInvocationImpl.scala
index 80eeb07368..da81e9e9fa 100644
--- a/src/col/vct/col/ast/lang/java/JavaInvocationImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaInvocationImpl.scala
@@ -6,27 +6,31 @@ import vct.col.resolve.ctx._
import vct.col.util.AstBuildHelpers.tt
import vct.col.ast.ops.JavaInvocationOps
-trait JavaInvocationImpl[G] extends JavaInvocationOps[G] { this: JavaInvocation[G] =>
- override lazy val t: Type[G] = ref.get match {
- case RefFunction(decl) => decl.returnType
- case RefProcedure(decl) => decl.returnType
- case RefPredicate(decl) => decl.returnType
- case RefInstanceFunction(decl) => decl.returnType
- case RefInstanceMethod(decl) => decl.returnType
- case RefInstancePredicate(decl) => decl.returnType
- case RefADTFunction(decl) => decl.returnType
- case RefModelProcess(decl) => decl.returnType
- case RefModelAction(decl) => decl.returnType
- case RefJavaMethod(decl) => decl.returnType
- case RefProverFunction(decl) => decl.returnType
- case BuiltinInstanceMethod(f) => f(obj.get)(arguments).t
- case RefJavaAnnotationMethod(decl) => decl.returnType
- }
+trait JavaInvocationImpl[G] extends JavaInvocationOps[G] {
+ this: JavaInvocation[G] =>
+ override lazy val t: Type[G] =
+ ref.get match {
+ case RefFunction(decl) => decl.returnType
+ case RefProcedure(decl) => decl.returnType
+ case RefPredicate(decl) => decl.returnType
+ case RefInstanceFunction(decl) => decl.returnType
+ case RefInstanceMethod(decl) => decl.returnType
+ case RefInstancePredicate(decl) => decl.returnType
+ case RefADTFunction(decl) => decl.returnType
+ case RefModelProcess(decl) => decl.returnType
+ case RefModelAction(decl) => decl.returnType
+ case RefJavaMethod(decl) => decl.returnType
+ case RefProverFunction(decl) => decl.returnType
+ case BuiltinInstanceMethod(f) => f(obj.get)(arguments).t
+ case RefJavaAnnotationMethod(decl) => decl.returnType
+ }
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
- obj.map(obj => assoc(obj) <> ".").getOrElse(Empty) <>
- method <>
- (if(typeParams.isEmpty) Empty else Text("<") <> Doc.args(typeParams) <> ">") <>
- "(" <> Doc.args(arguments) <> ")" <> DocUtil.givenYields(givenArgs, yields)
-}
\ No newline at end of file
+ obj.map(obj => assoc(obj) <> ".").getOrElse(Empty) <> method <>
+ (if (typeParams.isEmpty)
+ Empty
+ else
+ Text("<") <> Doc.args(typeParams) <> ">") <> "(" <>
+ Doc.args(arguments) <> ")" <> DocUtil.givenYields(givenArgs, yields)
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaLiteralArrayImpl.scala b/src/col/vct/col/ast/lang/java/JavaLiteralArrayImpl.scala
index d3251d18a0..dace7ef298 100644
--- a/src/col/vct/col/ast/lang/java/JavaLiteralArrayImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaLiteralArrayImpl.scala
@@ -4,8 +4,9 @@ import vct.col.ast.{JavaLiteralArray, Type}
import vct.col.print.Precedence
import vct.col.ast.ops.JavaLiteralArrayOps
-trait JavaLiteralArrayImpl[G] extends JavaLiteralArrayOps[G] { this: JavaLiteralArray[G] =>
+trait JavaLiteralArrayImpl[G] extends JavaLiteralArrayOps[G] {
+ this: JavaLiteralArray[G] =>
override def t: Type[G] = typeContext.get
override def precedence = Precedence.ATOMIC
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaLocalDeclarationImpl.scala b/src/col/vct/col/ast/lang/java/JavaLocalDeclarationImpl.scala
index 7ddc4fd61b..134e802c8e 100644
--- a/src/col/vct/col/ast/lang/java/JavaLocalDeclarationImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaLocalDeclarationImpl.scala
@@ -4,7 +4,9 @@ import vct.col.ast.JavaLocalDeclaration
import vct.col.print.{Ctx, Doc, Group}
import vct.col.ast.ops.{JavaLocalDeclarationOps, JavaLocalDeclarationFamilyOps}
-trait JavaLocalDeclarationImpl[G] extends JavaLocalDeclarationOps[G] with JavaLocalDeclarationFamilyOps[G] { this: JavaLocalDeclaration[G] =>
+trait JavaLocalDeclarationImpl[G]
+ extends JavaLocalDeclarationOps[G] with JavaLocalDeclarationFamilyOps[G] {
+ this: JavaLocalDeclaration[G] =>
override def layout(implicit ctx: Ctx): Doc =
Group(Doc.rspread(modifiers) <> t <+> Doc.args(decls))
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaLocalDeclarationStatementImpl.scala b/src/col/vct/col/ast/lang/java/JavaLocalDeclarationStatementImpl.scala
index dcc7d4b477..6016e9b7c6 100644
--- a/src/col/vct/col/ast/lang/java/JavaLocalDeclarationStatementImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaLocalDeclarationStatementImpl.scala
@@ -4,6 +4,8 @@ import vct.col.ast.JavaLocalDeclarationStatement
import vct.col.print.{Ctx, Doc, Group}
import vct.col.ast.ops.JavaLocalDeclarationStatementOps
-trait JavaLocalDeclarationStatementImpl[G] extends JavaLocalDeclarationStatementOps[G] { this: JavaLocalDeclarationStatement[G] =>
+trait JavaLocalDeclarationStatementImpl[G]
+ extends JavaLocalDeclarationStatementOps[G] {
+ this: JavaLocalDeclarationStatement[G] =>
override def layout(implicit ctx: Ctx): Doc = decl.show <> ";"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaLocalImpl.scala b/src/col/vct/col/ast/lang/java/JavaLocalImpl.scala
index 0a41454069..820d05c981 100644
--- a/src/col/vct/col/ast/lang/java/JavaLocalImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaLocalImpl.scala
@@ -7,21 +7,25 @@ import vct.col.resolve.ctx._
import vct.col.typerules.Types
import vct.col.ast.ops.JavaLocalOps
-trait JavaLocalImpl[G] extends JavaLocalOps[G] { this: JavaLocal[G] =>
- override lazy val t: Type[G] = ref.get match {
- case ref: RefAxiomaticDataType[G] => Types.notAValue(ref)
- case ref: RefEnum[G] => Types.notAValue(ref)
- case RefEnumConstant(enum, _) => TEnum(enum.get.ref)
- case RefVariable(decl) => decl.t
- case ref: RefUnloadedJavaNamespace[G] => Types.notAValue(ref)
- case ref: RefJavaClass[G] => Types.notAValue(ref)
- case RefJavaField(decls, idx) => FuncTools.repeat[Type[G]](TArray(_), decls.decls(idx).moreDims, decls.t)
- case RefJavaLocalDeclaration(decls, idx) => FuncTools.repeat[Type[G]](TArray(_), decls.decls(idx).moreDims, decls.t)
- case RefJavaParam(decl) => decl.t
- case RefJavaBipGuard(_) => TBool()
- case RefModelField(field) => field.t
- case ref: RefClass[G] => Types.notAValue(ref)
- }
+trait JavaLocalImpl[G] extends JavaLocalOps[G] {
+ this: JavaLocal[G] =>
+ override lazy val t: Type[G] =
+ ref.get match {
+ case ref: RefAxiomaticDataType[G] => Types.notAValue(ref)
+ case ref: RefEnum[G] => Types.notAValue(ref)
+ case RefEnumConstant(enum, _) => TEnum(enum.get.ref)
+ case RefVariable(decl) => decl.t
+ case ref: RefUnloadedJavaNamespace[G] => Types.notAValue(ref)
+ case ref: RefJavaClass[G] => Types.notAValue(ref)
+ case RefJavaField(decls, idx) =>
+ FuncTools.repeat[Type[G]](TArray(_), decls.decls(idx).moreDims, decls.t)
+ case RefJavaLocalDeclaration(decls, idx) =>
+ FuncTools.repeat[Type[G]](TArray(_), decls.decls(idx).moreDims, decls.t)
+ case RefJavaParam(decl) => decl.t
+ case RefJavaBipGuard(_) => TBool()
+ case RefModelField(field) => field.t
+ case ref: RefClass[G] => Types.notAValue(ref)
+ }
override def layout(implicit ctx: Ctx): Doc = Text(name)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaMethodImpl.scala b/src/col/vct/col/ast/lang/java/JavaMethodImpl.scala
index 12880ed64a..c20a7a4785 100644
--- a/src/col/vct/col/ast/lang/java/JavaMethodImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaMethodImpl.scala
@@ -5,18 +5,30 @@ import vct.col.ast.util.Declarator
import vct.col.print._
import vct.col.ast.ops.JavaMethodOps
-trait JavaMethodImpl[G] extends Declarator[G] with JavaMethodOps[G] { this: JavaMethod[G] =>
- override def declarations: Seq[Declaration[G]] = parameters ++ typeParameters ++ contract.givenArgs ++ contract.yieldsArgs
+trait JavaMethodImpl[G] extends Declarator[G] with JavaMethodOps[G] {
+ this: JavaMethod[G] =>
+ override def declarations: Seq[Declaration[G]] =
+ parameters ++ typeParameters ++ contract.givenArgs ++ contract.yieldsArgs
override def isStatic = modifiers.contains(JavaStatic[G]())
override def layout(implicit ctx: Ctx): Doc =
Doc.stack(Seq(
contract,
- Group(Group(Group(
- Doc.rspread(modifiers) <>
- (if(typeParameters.isEmpty) Empty else Text("<") <> Doc.args(typeParameters) <> ">" <+> Empty) <>
- returnType <+> name <> "[]".repeat(dims)) <> "(" <> Doc.args(parameters) <> ")") <>
- (if(signals.isEmpty) Empty else Empty <>> Group(Text("throws") <+> Doc.args(signals)))
- ) <> body.map(Empty <+> _.layoutAsBlock).getOrElse(Text(";"))
+ Group(
+ Group(
+ Group(
+ Doc.rspread(modifiers) <>
+ (if (typeParameters.isEmpty)
+ Empty
+ else
+ Text("<") <> Doc.args(typeParameters) <> ">" <+> Empty) <>
+ returnType <+> name <> "[]".repeat(dims)
+ ) <> "(" <> Doc.args(parameters) <> ")"
+ ) <>
+ (if (signals.isEmpty)
+ Empty
+ else
+ Empty <>> Group(Text("throws") <+> Doc.args(signals)))
+ ) <> body.map(Empty <+> _.layoutAsBlock).getOrElse(Text(";")),
))
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaModifierImpl.scala b/src/col/vct/col/ast/lang/java/JavaModifierImpl.scala
index 323c07a7cd..1c211d648b 100644
--- a/src/col/vct/col/ast/lang/java/JavaModifierImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaModifierImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.lang.java
import vct.col.ast.JavaModifier
import vct.col.ast.ops.JavaModifierFamilyOps
-trait JavaModifierImpl[G] extends JavaModifierFamilyOps[G] { this: JavaModifier[G] =>
+trait JavaModifierImpl[G] extends JavaModifierFamilyOps[G] {
+ this: JavaModifier[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaNameImpl.scala b/src/col/vct/col/ast/lang/java/JavaNameImpl.scala
index f465e4fa5b..b2bf0e84d1 100644
--- a/src/col/vct/col/ast/lang/java/JavaNameImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaNameImpl.scala
@@ -4,6 +4,8 @@ import vct.col.ast.JavaName
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.{JavaNameOps, JavaNameFamilyOps}
-trait JavaNameImpl[G] extends JavaNameOps[G] with JavaNameFamilyOps[G] { this: JavaName[G] =>
- override def layout(implicit ctx: Ctx): Doc = Doc.fold(names.map(Text))(_ <> "." <> _)
-}
\ No newline at end of file
+trait JavaNameImpl[G] extends JavaNameOps[G] with JavaNameFamilyOps[G] {
+ this: JavaName[G] =>
+ override def layout(implicit ctx: Ctx): Doc =
+ Doc.fold(names.map(Text))(_ <> "." <> _)
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaNamedTypeImpl.scala b/src/col/vct/col/ast/lang/java/JavaNamedTypeImpl.scala
index b6201ff882..c189baad36 100644
--- a/src/col/vct/col/ast/lang/java/JavaNamedTypeImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaNamedTypeImpl.scala
@@ -4,10 +4,12 @@ import vct.col.ast.JavaNamedType
import vct.col.print._
import vct.col.ast.ops.JavaNamedTypeOps
-trait JavaNamedTypeImpl[G] extends JavaNamedTypeOps[G] { this: JavaNamedType[G] =>
+trait JavaNamedTypeImpl[G] extends JavaNamedTypeOps[G] {
+ this: JavaNamedType[G] =>
override def layout(implicit ctx: Ctx): Doc =
Doc.fold(names.map {
case (name, None) => Text(name)
- case (name, Some(typeArgs)) => Text(name) <> "<" <> Doc.fold(typeArgs)(_ <> "," <+> _) <> ">"
+ case (name, Some(typeArgs)) =>
+ Text(name) <> "<" <> Doc.fold(typeArgs)(_ <> "," <+> _) <> ">"
})(_ <> "." <> _)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaNamespaceImpl.scala b/src/col/vct/col/ast/lang/java/JavaNamespaceImpl.scala
index 6684378feb..ddb9690403 100644
--- a/src/col/vct/col/ast/lang/java/JavaNamespaceImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaNamespaceImpl.scala
@@ -6,16 +6,21 @@ import vct.col.print._
import vct.col.resolve.lang.Java
import vct.col.ast.ops.JavaNamespaceOps
-trait JavaNamespaceImpl[G] extends JavaNamespaceOps[G] { this: JavaNamespace[G] =>
- lazy val name: Option[String] = pkg match {
- case Some(value) => Some(value.names.mkString("."))
- case None => None
- }
+trait JavaNamespaceImpl[G] extends JavaNamespaceOps[G] {
+ this: JavaNamespace[G] =>
+ lazy val name: Option[String] =
+ pkg match {
+ case Some(value) => Some(value.names.mkString("."))
+ case None => None
+ }
override def layout(implicit ctx: Ctx): Doc =
Doc.stack(Seq(
- if(pkg.isEmpty) Empty else Text("package") <+> pkg.get,
+ if (pkg.isEmpty)
+ Empty
+ else
+ Text("package") <+> pkg.get,
Doc.stack(imports),
Doc.stack(declarations),
))
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaNativeImpl.scala b/src/col/vct/col/ast/lang/java/JavaNativeImpl.scala
index 2e9de48e61..54897f6fe2 100644
--- a/src/col/vct/col/ast/lang/java/JavaNativeImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaNativeImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.JavaNative
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.JavaNativeOps
-trait JavaNativeImpl[G] extends JavaNativeOps[G] { this: JavaNative[G] =>
+trait JavaNativeImpl[G] extends JavaNativeOps[G] {
+ this: JavaNative[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("native")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaNewClassImpl.scala b/src/col/vct/col/ast/lang/java/JavaNewClassImpl.scala
index d44fa125d0..a02539fbad 100644
--- a/src/col/vct/col/ast/lang/java/JavaNewClassImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaNewClassImpl.scala
@@ -4,14 +4,19 @@ import vct.col.ast.{JavaNewClass, Type}
import vct.col.print.{Ctx, Doc, DocUtil, Empty, Group, Text}
import vct.col.ast.ops.JavaNewClassOps
-trait JavaNewClassImpl[G] extends JavaNewClassOps[G] { this: JavaNewClass[G] =>
+trait JavaNewClassImpl[G] extends JavaNewClassOps[G] {
+ this: JavaNewClass[G] =>
override def t: Type[G] = name
override def layout(implicit ctx: Ctx): Doc =
Group(
- Group(Text("new") <+> name <>
- (if(typeArgs.isEmpty) Empty else Text("<") <> Doc.args(typeArgs) <> ">")) <>
- "(" <> Doc.args(args) <> ")" <>
+ Group(
+ Text("new") <+> name <>
+ (if (typeArgs.isEmpty)
+ Empty
+ else
+ Text("<") <> Doc.args(typeArgs) <> ">")
+ ) <> "(" <> Doc.args(args) <> ")" <>
DocUtil.givenYields(givenArgs, yields)
)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaNewDefaultArrayImpl.scala b/src/col/vct/col/ast/lang/java/JavaNewDefaultArrayImpl.scala
index e96d6b5b7b..9c2a82b355 100644
--- a/src/col/vct/col/ast/lang/java/JavaNewDefaultArrayImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaNewDefaultArrayImpl.scala
@@ -4,10 +4,14 @@ import vct.col.ast.{JavaNewDefaultArray, TArray, Type}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.JavaNewDefaultArrayOps
-trait JavaNewDefaultArrayImpl[G] extends JavaNewDefaultArrayOps[G] { this: JavaNewDefaultArray[G] =>
- override lazy val t: Type[G] = (0 until (specifiedDims.size + moreDims)).foldLeft(baseType)((t, _) => TArray(t))
+trait JavaNewDefaultArrayImpl[G] extends JavaNewDefaultArrayOps[G] {
+ this: JavaNewDefaultArray[G] =>
+ override lazy val t: Type[G] = (0 until (specifiedDims.size + moreDims))
+ .foldLeft(baseType)((t, _) => TArray(t))
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
- Text("new") <+> baseType <> Doc.fold(specifiedDims.map(Text("[") <> _ <> "]"))(_ <> _) <> "[]".repeat(moreDims)
-}
\ No newline at end of file
+ Text("new") <+> baseType <>
+ Doc.fold(specifiedDims.map(Text("[") <> _ <> "]"))(_ <> _) <>
+ "[]".repeat(moreDims)
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaNewLiteralArrayImpl.scala b/src/col/vct/col/ast/lang/java/JavaNewLiteralArrayImpl.scala
index 33db0c0354..9e79dd435c 100644
--- a/src/col/vct/col/ast/lang/java/JavaNewLiteralArrayImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaNewLiteralArrayImpl.scala
@@ -5,10 +5,12 @@ import vct.col.ast.{JavaNewLiteralArray, TArray, Type}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.JavaNewLiteralArrayOps
-trait JavaNewLiteralArrayImpl[G] extends JavaNewLiteralArrayOps[G] { this: JavaNewLiteralArray[G] =>
- override lazy val t: Type[G] = FuncTools.repeat[Type[G]](TArray(_), dims, baseType)
+trait JavaNewLiteralArrayImpl[G] extends JavaNewLiteralArrayOps[G] {
+ this: JavaNewLiteralArray[G] =>
+ override lazy val t: Type[G] = FuncTools
+ .repeat[Type[G]](TArray(_), dims, baseType)
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Text("new") <+> baseType <> "[]".repeat(dims) <> initializer
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaParamImpl.scala b/src/col/vct/col/ast/lang/java/JavaParamImpl.scala
index f039c3a0fe..6cbeb9e39a 100644
--- a/src/col/vct/col/ast/lang/java/JavaParamImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaParamImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.JavaParam
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.{JavaParamOps, JavaParamFamilyOps}
-trait JavaParamImpl[G] extends JavaParamOps[G] with JavaParamFamilyOps[G] { this: JavaParam[G] =>
+trait JavaParamImpl[G] extends JavaParamOps[G] with JavaParamFamilyOps[G] {
+ this: JavaParam[G] =>
override def layout(implicit ctx: Ctx): Doc = t.show <+> name
}
diff --git a/src/col/vct/col/ast/lang/java/JavaPrivateImpl.scala b/src/col/vct/col/ast/lang/java/JavaPrivateImpl.scala
index 2e8921c2d8..fa927905f8 100644
--- a/src/col/vct/col/ast/lang/java/JavaPrivateImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaPrivateImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.JavaPrivate
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.JavaPrivateOps
-trait JavaPrivateImpl[G] extends JavaPrivateOps[G] { this: JavaPrivate[G] =>
+trait JavaPrivateImpl[G] extends JavaPrivateOps[G] {
+ this: JavaPrivate[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("private")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaProtectedImpl.scala b/src/col/vct/col/ast/lang/java/JavaProtectedImpl.scala
index caee28aa8f..08b1340ff4 100644
--- a/src/col/vct/col/ast/lang/java/JavaProtectedImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaProtectedImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.JavaProtected
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.JavaProtectedOps
-trait JavaProtectedImpl[G] extends JavaProtectedOps[G] { this: JavaProtected[G] =>
+trait JavaProtectedImpl[G] extends JavaProtectedOps[G] {
+ this: JavaProtected[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("protected")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaPublicImpl.scala b/src/col/vct/col/ast/lang/java/JavaPublicImpl.scala
index 63d5c6c0c4..a6ab2ae321 100644
--- a/src/col/vct/col/ast/lang/java/JavaPublicImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaPublicImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.JavaPublic
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.JavaPublicOps
-trait JavaPublicImpl[G] extends JavaPublicOps[G] { this: JavaPublic[G] =>
+trait JavaPublicImpl[G] extends JavaPublicOps[G] {
+ this: JavaPublic[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("public")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaPureImpl.scala b/src/col/vct/col/ast/lang/java/JavaPureImpl.scala
index 82778ef5af..ccd90f92ae 100644
--- a/src/col/vct/col/ast/lang/java/JavaPureImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaPureImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.JavaPure
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.JavaPureOps
-trait JavaPureImpl[G] extends JavaPureOps[G] { this: JavaPure[G] =>
+trait JavaPureImpl[G] extends JavaPureOps[G] {
+ this: JavaPure[G] =>
override def layout(implicit ctx: Ctx): Doc = Doc.inlineSpec(Text("pure"))
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaSharedInitializationImpl.scala b/src/col/vct/col/ast/lang/java/JavaSharedInitializationImpl.scala
index 9c62013207..9f16738bac 100644
--- a/src/col/vct/col/ast/lang/java/JavaSharedInitializationImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaSharedInitializationImpl.scala
@@ -4,7 +4,11 @@ import vct.col.ast.JavaSharedInitialization
import vct.col.print.{Ctx, Doc, Text, Empty}
import vct.col.ast.ops.JavaSharedInitializationOps
-trait JavaSharedInitializationImpl[G] extends JavaSharedInitializationOps[G] { this: JavaSharedInitialization[G] =>
+trait JavaSharedInitializationImpl[G] extends JavaSharedInitializationOps[G] {
+ this: JavaSharedInitialization[G] =>
override def layout(implicit ctx: Ctx): Doc =
- (if(isStatic) Text("static") <+> Empty else Empty) <> initialization.layoutAsBlock
-}
\ No newline at end of file
+ (if (isStatic)
+ Text("static") <+> Empty
+ else
+ Empty) <> initialization.layoutAsBlock
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaStatementImpl.scala b/src/col/vct/col/ast/lang/java/JavaStatementImpl.scala
index a065daa476..77578e554a 100644
--- a/src/col/vct/col/ast/lang/java/JavaStatementImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaStatementImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.lang.java
import vct.col.ast.JavaStatement
-trait JavaStatementImpl[G] { this: JavaStatement[G] =>
+trait JavaStatementImpl[G] {
+ this: JavaStatement[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaStaticImpl.scala b/src/col/vct/col/ast/lang/java/JavaStaticImpl.scala
index 1e5f07ffec..b470c837ac 100644
--- a/src/col/vct/col/ast/lang/java/JavaStaticImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaStaticImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.JavaStatic
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.JavaStaticOps
-trait JavaStaticImpl[G] extends JavaStaticOps[G] { this: JavaStatic[G] =>
+trait JavaStaticImpl[G] extends JavaStaticOps[G] {
+ this: JavaStatic[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("static")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaStrictFPImpl.scala b/src/col/vct/col/ast/lang/java/JavaStrictFPImpl.scala
index fcd68166f6..a33a0aee8c 100644
--- a/src/col/vct/col/ast/lang/java/JavaStrictFPImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaStrictFPImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.JavaStrictFP
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.JavaStrictFPOps
-trait JavaStrictFPImpl[G] extends JavaStrictFPOps[G] { this: JavaStrictFP[G] =>
+trait JavaStrictFPImpl[G] extends JavaStrictFPOps[G] {
+ this: JavaStrictFP[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("strictfp")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaStringValueImpl.scala b/src/col/vct/col/ast/lang/java/JavaStringValueImpl.scala
index 9f14ba2d9f..8f4522dee5 100644
--- a/src/col/vct/col/ast/lang/java/JavaStringValueImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaStringValueImpl.scala
@@ -1,11 +1,17 @@
package vct.col.ast.lang.java
-import vct.col.ast.{JavaClass, JavaClassOrInterface, JavaStringValue, JavaTClass, Type}
+import vct.col.ast.{
+ JavaClass,
+ JavaClassOrInterface,
+ JavaStringValue,
+ JavaTClass,
+ Type,
+}
import vct.col.print.{Ctx, Doc, Text}
import vct.result.VerificationError.Unreachable
import vct.col.ast.ops.JavaStringValueOps
-trait JavaStringValueImpl[G] extends JavaStringValueOps[G] { this: JavaStringValue[G] =>
- override def layout(implicit ctx: Ctx): Doc =
- Text("\"") <> data <> Text("\"")
+trait JavaStringValueImpl[G] extends JavaStringValueOps[G] {
+ this: JavaStringValue[G] =>
+ override def layout(implicit ctx: Ctx): Doc = Text("\"") <> data <> Text("\"")
}
diff --git a/src/col/vct/col/ast/lang/java/JavaSynchronizedImpl.scala b/src/col/vct/col/ast/lang/java/JavaSynchronizedImpl.scala
index 90203d3c59..fccc2464ff 100644
--- a/src/col/vct/col/ast/lang/java/JavaSynchronizedImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaSynchronizedImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.JavaSynchronized
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.JavaSynchronizedOps
-trait JavaSynchronizedImpl[G] extends JavaSynchronizedOps[G] { this: JavaSynchronized[G] =>
+trait JavaSynchronizedImpl[G] extends JavaSynchronizedOps[G] {
+ this: JavaSynchronized[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("synchronized")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaTClassImpl.scala b/src/col/vct/col/ast/lang/java/JavaTClassImpl.scala
index 38270857e8..4ab2edfba6 100644
--- a/src/col/vct/col/ast/lang/java/JavaTClassImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaTClassImpl.scala
@@ -4,8 +4,12 @@ import vct.col.ast.JavaTClass
import vct.col.print.{Ctx, Doc, Empty, Text}
import vct.col.ast.ops.JavaTClassOps
-trait JavaTClassImpl[G] extends JavaTClassOps[G] { this: JavaTClass[G] =>
+trait JavaTClassImpl[G] extends JavaTClassOps[G] {
+ this: JavaTClass[G] =>
override def layout(implicit ctx: Ctx): Doc =
Text(ctx.name(ref)) <>
- (if(typeArgs.isEmpty) Empty else Empty <+> "<" <> Doc.args(typeArgs) <> ">")
-}
\ No newline at end of file
+ (if (typeArgs.isEmpty)
+ Empty
+ else
+ Empty <+> "<" <> Doc.args(typeArgs) <> ">")
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaTransientImpl.scala b/src/col/vct/col/ast/lang/java/JavaTransientImpl.scala
index 54895fc8ce..3293f76987 100644
--- a/src/col/vct/col/ast/lang/java/JavaTransientImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaTransientImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.JavaTransient
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.JavaTransientOps
-trait JavaTransientImpl[G] extends JavaTransientOps[G] { this: JavaTransient[G] =>
+trait JavaTransientImpl[G] extends JavaTransientOps[G] {
+ this: JavaTransient[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("transient")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaTypeImpl.scala b/src/col/vct/col/ast/lang/java/JavaTypeImpl.scala
index 8a87f12eb3..d0e0fdc933 100644
--- a/src/col/vct/col/ast/lang/java/JavaTypeImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaTypeImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.lang.java
import vct.col.ast.JavaType
-trait JavaTypeImpl[G] { this: JavaType[G] =>
+trait JavaTypeImpl[G] {
+ this: JavaType[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaVolatileImpl.scala b/src/col/vct/col/ast/lang/java/JavaVolatileImpl.scala
index 2babb59a6e..ca7ae3cf8d 100644
--- a/src/col/vct/col/ast/lang/java/JavaVolatileImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaVolatileImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.JavaVolatile
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.JavaVolatileOps
-trait JavaVolatileImpl[G] extends JavaVolatileOps[G] { this: JavaVolatile[G] =>
+trait JavaVolatileImpl[G] extends JavaVolatileOps[G] {
+ this: JavaVolatile[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("volatile")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/java/JavaWildcardImpl.scala b/src/col/vct/col/ast/lang/java/JavaWildcardImpl.scala
index 9d96f4a506..76261c33e2 100644
--- a/src/col/vct/col/ast/lang/java/JavaWildcardImpl.scala
+++ b/src/col/vct/col/ast/lang/java/JavaWildcardImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.JavaWildcard
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.JavaWildcardOps
-trait JavaWildcardImpl[G] extends JavaWildcardOps[G] { this: JavaWildcard[G] =>
+trait JavaWildcardImpl[G] extends JavaWildcardOps[G] {
+ this: JavaWildcard[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("?")
}
diff --git a/src/col/vct/col/ast/lang/llvm/LlvmAmbiguousFunctionInvocationImpl.scala b/src/col/vct/col/ast/lang/llvm/LlvmAmbiguousFunctionInvocationImpl.scala
index 54008f75e4..cb6b12eba3 100644
--- a/src/col/vct/col/ast/lang/llvm/LlvmAmbiguousFunctionInvocationImpl.scala
+++ b/src/col/vct/col/ast/lang/llvm/LlvmAmbiguousFunctionInvocationImpl.scala
@@ -1,20 +1,28 @@
package vct.col.ast.lang.llvm
-import vct.col.ast.{LlvmAmbiguousFunctionInvocation, LlvmFunctionDefinition, LlvmSpecFunction, Type}
+import vct.col.ast.{
+ LlvmAmbiguousFunctionInvocation,
+ LlvmFunctionDefinition,
+ LlvmSpecFunction,
+ Type,
+}
import vct.col.print.{Ctx, Doc, DocUtil, Group, Precedence, Text}
import vct.col.ast.ops.LlvmAmbiguousFunctionInvocationOps
-trait LlvmAmbiguousFunctionInvocationImpl[G] extends LlvmAmbiguousFunctionInvocationOps[G] { this: LlvmAmbiguousFunctionInvocation[G] =>
- override lazy val t: Type[G] = ref.get.decl match {
- case func: LlvmFunctionDefinition[G] => func.returnType
- case func: LlvmSpecFunction[G] => func.returnType
- }
+trait LlvmAmbiguousFunctionInvocationImpl[G]
+ extends LlvmAmbiguousFunctionInvocationOps[G] {
+ this: LlvmAmbiguousFunctionInvocation[G] =>
+ override lazy val t: Type[G] =
+ ref.get.decl match {
+ case func: LlvmFunctionDefinition[G] => func.returnType
+ case func: LlvmSpecFunction[G] => func.returnType
+ }
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Group(
- Group(
- Text(name) <> "(") <> Doc.args(args) <> ")" <> DocUtil.givenYields(givenMap, yields)
+ Group(Text(name) <> "(") <> Doc.args(args) <> ")" <>
+ DocUtil.givenYields(givenMap, yields)
)
}
diff --git a/src/col/vct/col/ast/lang/llvm/LlvmExprImpl.scala b/src/col/vct/col/ast/lang/llvm/LlvmExprImpl.scala
index ee5805f530..6b4c7524e8 100644
--- a/src/col/vct/col/ast/lang/llvm/LlvmExprImpl.scala
+++ b/src/col/vct/col/ast/lang/llvm/LlvmExprImpl.scala
@@ -1,7 +1,7 @@
package vct.col.ast.lang.llvm
-
import vct.col.ast.LlvmExpr
-trait LlvmExprImpl[G] { this: LlvmExpr[G] =>
+trait LlvmExprImpl[G] {
+ this: LlvmExpr[G] =>
}
diff --git a/src/col/vct/col/ast/lang/llvm/LlvmFunctionContractImpl.scala b/src/col/vct/col/ast/lang/llvm/LlvmFunctionContractImpl.scala
index c8480817e0..48c8828248 100644
--- a/src/col/vct/col/ast/lang/llvm/LlvmFunctionContractImpl.scala
+++ b/src/col/vct/col/ast/lang/llvm/LlvmFunctionContractImpl.scala
@@ -3,5 +3,7 @@ package vct.col.ast.lang.llvm
import vct.col.ast.LlvmFunctionContract
import vct.col.ast.ops.{LlvmFunctionContractOps, LlvmFunctionContractFamilyOps}
-trait LlvmFunctionContractImpl[G] extends LlvmFunctionContractOps[G] with LlvmFunctionContractFamilyOps[G] { this: LlvmFunctionContract[G] =>
+trait LlvmFunctionContractImpl[G]
+ extends LlvmFunctionContractOps[G] with LlvmFunctionContractFamilyOps[G] {
+ this: LlvmFunctionContract[G] =>
}
diff --git a/src/col/vct/col/ast/lang/llvm/LlvmFunctionDefinitionImpl.scala b/src/col/vct/col/ast/lang/llvm/LlvmFunctionDefinitionImpl.scala
index f304be3124..89b836798c 100644
--- a/src/col/vct/col/ast/lang/llvm/LlvmFunctionDefinitionImpl.scala
+++ b/src/col/vct/col/ast/lang/llvm/LlvmFunctionDefinitionImpl.scala
@@ -5,7 +5,11 @@ import vct.col.ast.{Declaration, LlvmFunctionDefinition, Statement}
import vct.col.ast.util.Declarator
import vct.col.ast.ops.LlvmFunctionDefinitionOps
-trait LlvmFunctionDefinitionImpl[G] extends Declarator[G] with ApplicableImpl[G] with LlvmFunctionDefinitionOps[G] { this: LlvmFunctionDefinition[G] =>
+trait LlvmFunctionDefinitionImpl[G]
+ extends Declarator[G]
+ with ApplicableImpl[G]
+ with LlvmFunctionDefinitionOps[G] {
+ this: LlvmFunctionDefinition[G] =>
override def declarations: Seq[Declaration[G]] = args
override def body: Option[Statement[G]] = Some(functionBody)
diff --git a/src/col/vct/col/ast/lang/llvm/LlvmFunctionInvocationImpl.scala b/src/col/vct/col/ast/lang/llvm/LlvmFunctionInvocationImpl.scala
index b14416eaf9..40f41dd1b4 100644
--- a/src/col/vct/col/ast/lang/llvm/LlvmFunctionInvocationImpl.scala
+++ b/src/col/vct/col/ast/lang/llvm/LlvmFunctionInvocationImpl.scala
@@ -4,12 +4,13 @@ import vct.col.ast.LlvmFunctionInvocation
import vct.col.print.{Ctx, Doc, DocUtil, Empty, Group, Precedence, Text}
import vct.col.ast.ops.LlvmFunctionInvocationOps
-trait LlvmFunctionInvocationImpl[G] extends LlvmFunctionInvocationOps[G] { this: LlvmFunctionInvocation[G] =>
+trait LlvmFunctionInvocationImpl[G] extends LlvmFunctionInvocationOps[G] {
+ this: LlvmFunctionInvocation[G] =>
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Group(
- Group(
- Text(ctx.name(ref)) <> "(") <> Doc.args(args) <> ")" <> DocUtil.givenYields(givenMap, yields)
+ Group(Text(ctx.name(ref)) <> "(") <> Doc.args(args) <> ")" <>
+ DocUtil.givenYields(givenMap, yields)
)
}
diff --git a/src/col/vct/col/ast/lang/llvm/LlvmGlobalImpl.scala b/src/col/vct/col/ast/lang/llvm/LlvmGlobalImpl.scala
index c1205598d5..3a92e81e9e 100644
--- a/src/col/vct/col/ast/lang/llvm/LlvmGlobalImpl.scala
+++ b/src/col/vct/col/ast/lang/llvm/LlvmGlobalImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.LlvmGlobal
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.LlvmGlobalOps
-trait LlvmGlobalImpl[G] extends LlvmGlobalOps[G] { this: LlvmGlobal[G] =>
+trait LlvmGlobalImpl[G] extends LlvmGlobalOps[G] {
+ this: LlvmGlobal[G] =>
override def layout(implicit ctx: Ctx): Doc = Text(value)
diff --git a/src/col/vct/col/ast/lang/llvm/LlvmLocalImpl.scala b/src/col/vct/col/ast/lang/llvm/LlvmLocalImpl.scala
index 6d8468df6c..0baa756520 100644
--- a/src/col/vct/col/ast/lang/llvm/LlvmLocalImpl.scala
+++ b/src/col/vct/col/ast/lang/llvm/LlvmLocalImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{LlvmLocal, Type}
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.LlvmLocalOps
-trait LlvmLocalImpl[G] extends LlvmLocalOps[G] { this: LlvmLocal[G] =>
+trait LlvmLocalImpl[G] extends LlvmLocalOps[G] {
+ this: LlvmLocal[G] =>
override lazy val t: Type[G] = ref.get.decl.t
override def layout(implicit ctx: Ctx): Doc = Text(name)
diff --git a/src/col/vct/col/ast/lang/llvm/LlvmLoopContractImpl.scala b/src/col/vct/col/ast/lang/llvm/LlvmLoopContractImpl.scala
index 08af908b3b..95f2c492c5 100644
--- a/src/col/vct/col/ast/lang/llvm/LlvmLoopContractImpl.scala
+++ b/src/col/vct/col/ast/lang/llvm/LlvmLoopContractImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.lang.llvm
import vct.col.ast.LlvmLoopContract
import vct.col.ast.ops.LlvmLoopContractFamilyOps
-trait LlvmLoopContractImpl[G] extends LlvmLoopContractFamilyOps[G] { this: LlvmLoopContract[G] =>
+trait LlvmLoopContractImpl[G] extends LlvmLoopContractFamilyOps[G] {
+ this: LlvmLoopContract[G] =>
}
diff --git a/src/col/vct/col/ast/lang/llvm/LlvmLoopImpl.scala b/src/col/vct/col/ast/lang/llvm/LlvmLoopImpl.scala
index 2f723bdf0b..29b2aca394 100644
--- a/src/col/vct/col/ast/lang/llvm/LlvmLoopImpl.scala
+++ b/src/col/vct/col/ast/lang/llvm/LlvmLoopImpl.scala
@@ -3,7 +3,7 @@ package vct.col.ast.lang.llvm
import vct.col.ast.LlvmLoop
import vct.col.ast.ops.LlvmLoopOps
-
-trait LlvmLoopImpl[G] extends LlvmLoopOps[G] { this: LlvmLoop[G] =>
+trait LlvmLoopImpl[G] extends LlvmLoopOps[G] {
+ this: LlvmLoop[G] =>
}
diff --git a/src/col/vct/col/ast/lang/llvm/LlvmLoopInvariantImpl.scala b/src/col/vct/col/ast/lang/llvm/LlvmLoopInvariantImpl.scala
index 1e14ff9846..30f26a31b1 100644
--- a/src/col/vct/col/ast/lang/llvm/LlvmLoopInvariantImpl.scala
+++ b/src/col/vct/col/ast/lang/llvm/LlvmLoopInvariantImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.lang.llvm
import vct.col.ast.LlvmLoopInvariant
import vct.col.ast.ops.LlvmLoopInvariantOps
-trait LlvmLoopInvariantImpl[G] extends LlvmLoopInvariantOps[G] { this: LlvmLoopInvariant[G] =>
+trait LlvmLoopInvariantImpl[G] extends LlvmLoopInvariantOps[G] {
+ this: LlvmLoopInvariant[G] =>
}
diff --git a/src/col/vct/col/ast/lang/llvm/LlvmSpecFunctionImpl.scala b/src/col/vct/col/ast/lang/llvm/LlvmSpecFunctionImpl.scala
index 58ad33d280..fe9430a026 100644
--- a/src/col/vct/col/ast/lang/llvm/LlvmSpecFunctionImpl.scala
+++ b/src/col/vct/col/ast/lang/llvm/LlvmSpecFunctionImpl.scala
@@ -8,25 +8,32 @@ import vct.col.print.{Ctx, Doc, Empty, Group, Show, Text}
import scala.collection.immutable.ListMap
import vct.col.ast.ops.LlvmSpecFunctionOps
-trait LlvmSpecFunctionImpl[G] extends GlobalDeclarationImpl[G] with AbstractFunctionImpl[G] with LlvmSpecFunctionOps[G] {
+trait LlvmSpecFunctionImpl[G]
+ extends GlobalDeclarationImpl[G]
+ with AbstractFunctionImpl[G]
+ with LlvmSpecFunctionOps[G] {
this: LlvmSpecFunction[G] =>
- def layoutModifiers(implicit ctx: Ctx): Seq[Doc] = ListMap(
- inline -> "inline",
- threadLocal -> "thread_local",
- ).filter(_._1).values.map(Text).map(Doc.inlineSpec).toSeq
+ def layoutModifiers(implicit ctx: Ctx): Seq[Doc] =
+ ListMap(inline -> "inline", threadLocal -> "thread_local").filter(_._1)
+ .values.map(Text).map(Doc.inlineSpec).toSeq
def layoutSpec(implicit ctx: Ctx): Doc =
Doc.stack(Seq(
contract,
Group(
- Group(Doc.rspread(layoutModifiers) <> "pure" <+> returnType <+> ctx.name(this) <>
- (if (typeArgs.nonEmpty) Text("<") <> Doc.args(typeArgs.map(ctx.name).map(Text)) <> ">" else Empty) <>
- "(" <> Doc.args(args) <> ")") <>
- body.map(Text(" =") <>> _ <> ";").getOrElse(Text(";"))
+ Group(
+ Doc.rspread(layoutModifiers) <> "pure" <+> returnType <+>
+ ctx.name(this) <>
+ (if (typeArgs.nonEmpty)
+ Text("<") <> Doc.args(typeArgs.map(ctx.name).map(Text)) <> ">"
+ else
+ Empty) <> "(" <> Doc.args(args) <> ")"
+ ) <> body.map(Text(" =") <>> _ <> ";").getOrElse(Text(";"))
),
))
- override def layout(implicit ctx: Ctx): Doc = Doc.spec(Show.lazily(layoutSpec(_)))
+ override def layout(implicit ctx: Ctx): Doc =
+ Doc.spec(Show.lazily(layoutSpec(_)))
}
diff --git a/src/col/vct/col/ast/lang/pvl/PVLClassDeclarationImpl.scala b/src/col/vct/col/ast/lang/pvl/PVLClassDeclarationImpl.scala
index 898a633acb..60ab1bddcb 100644
--- a/src/col/vct/col/ast/lang/pvl/PVLClassDeclarationImpl.scala
+++ b/src/col/vct/col/ast/lang/pvl/PVLClassDeclarationImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.lang.pvl
import vct.col.ast.PVLClassDeclaration
-trait PVLClassDeclarationImpl[G] { this: PVLClassDeclaration[G] =>
+trait PVLClassDeclarationImpl[G] {
+ this: PVLClassDeclaration[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/pvl/PVLConstructorImpl.scala b/src/col/vct/col/ast/lang/pvl/PVLConstructorImpl.scala
index b6989b661c..55c6ca0120 100644
--- a/src/col/vct/col/ast/lang/pvl/PVLConstructorImpl.scala
+++ b/src/col/vct/col/ast/lang/pvl/PVLConstructorImpl.scala
@@ -5,12 +5,15 @@ import vct.col.ast.{Declaration, PVLConstructor}
import vct.col.print.{Ctx, Doc, Text, Empty}
import vct.col.ast.ops.PVLConstructorOps
-trait PVLConstructorImpl[G] extends Declarator[G] with PVLConstructorOps[G] { this: PVLConstructor[G] =>
- override def declarations: Seq[Declaration[G]] = args ++ contract.givenArgs ++ contract.yieldsArgs
+trait PVLConstructorImpl[G] extends Declarator[G] with PVLConstructorOps[G] {
+ this: PVLConstructor[G] =>
+ override def declarations: Seq[Declaration[G]] =
+ args ++ contract.givenArgs ++ contract.yieldsArgs
override def layout(implicit ctx: Ctx): Doc =
Doc.stack(Seq(
contract,
- Text("constructor") <> "(" <> Doc.args(args) <> ")" <> body.map(Empty <+> _.layoutAsBlock).getOrElse(Text(";"))
+ Text("constructor") <> "(" <> Doc.args(args) <> ")" <>
+ body.map(Empty <+> _.layoutAsBlock).getOrElse(Text(";")),
))
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/pvl/PVLDerefImpl.scala b/src/col/vct/col/ast/lang/pvl/PVLDerefImpl.scala
index 0ecea7a19d..468c4c7716 100644
--- a/src/col/vct/col/ast/lang/pvl/PVLDerefImpl.scala
+++ b/src/col/vct/col/ast/lang/pvl/PVLDerefImpl.scala
@@ -5,16 +5,17 @@ import vct.col.print.{Ctx, Doc, Precedence}
import vct.col.resolve.ctx._
import vct.col.ast.ops.PVLDerefOps
-trait PVLDerefImpl[G] extends PVLDerefOps[G] { this: PVLDeref[G] =>
- override lazy val t: Type[G] = ref.get match {
- case ref: RefModelField[G] => ref.decl.t
- case ref: RefField[G] =>
- obj.t.asClass.map(_.instantiate(ref.decl.t)).getOrElse(ref.decl.t)
- case RefEnumConstant(enum, _) => TEnum(enum.get.ref)
- case ref: BuiltinField[G] => ref.f(obj).t
- }
+trait PVLDerefImpl[G] extends PVLDerefOps[G] {
+ this: PVLDeref[G] =>
+ override lazy val t: Type[G] =
+ ref.get match {
+ case ref: RefModelField[G] => ref.decl.t
+ case ref: RefField[G] =>
+ obj.t.asClass.map(_.instantiate(ref.decl.t)).getOrElse(ref.decl.t)
+ case RefEnumConstant(enum, _) => TEnum(enum.get.ref)
+ case ref: BuiltinField[G] => ref.f(obj).t
+ }
override def precedence: Int = Precedence.POSTFIX
- override def layout(implicit ctx: Ctx): Doc =
- assoc(obj) <> "." <> field
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc = assoc(obj) <> "." <> field
+}
diff --git a/src/col/vct/col/ast/lang/pvl/PVLExprImpl.scala b/src/col/vct/col/ast/lang/pvl/PVLExprImpl.scala
index a9c7f15be0..cbda94e8e9 100644
--- a/src/col/vct/col/ast/lang/pvl/PVLExprImpl.scala
+++ b/src/col/vct/col/ast/lang/pvl/PVLExprImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.lang.pvl
import vct.col.ast.PVLExpr
-trait PVLExprImpl[G] { this: PVLExpr[G] =>
+trait PVLExprImpl[G] {
+ this: PVLExpr[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/pvl/PVLInvocationImpl.scala b/src/col/vct/col/ast/lang/pvl/PVLInvocationImpl.scala
index 788fda9029..0f8e9c741a 100644
--- a/src/col/vct/col/ast/lang/pvl/PVLInvocationImpl.scala
+++ b/src/col/vct/col/ast/lang/pvl/PVLInvocationImpl.scala
@@ -1,26 +1,37 @@
package vct.col.ast.lang.pvl
-import vct.col.ast.{Applicable, ContractApplicable, PVLInvocation, TClass, TProcess, TResource, Type, Variable}
+import vct.col.ast.{
+ Applicable,
+ ContractApplicable,
+ PVLInvocation,
+ TClass,
+ TProcess,
+ TResource,
+ Type,
+ Variable,
+}
import vct.col.print.{Ctx, Doc, DocUtil, Empty, Group, Text}
import vct.col.resolve.ctx._
import vct.col.ast.ops.PVLInvocationOps
import vct.col.ref.Ref
-trait PVLInvocationImpl[G] extends PVLInvocationOps[G] { this: PVLInvocation[G] =>
- override lazy val t: Type[G] = ref.get match {
- case RefFunction(decl) => returnType(decl)
- case RefProcedure(decl) => returnType(decl)
- case RefPredicate(_) => TResource()
- case RefInstanceFunction(decl) => returnType(decl)
- case RefInstanceMethod(decl) => returnType(decl)
- case RefInstancePredicate(_) => TResource()
- case RefADTFunction(decl) => decl.returnType
- case RefModelProcess(_) => TProcess()
- case RefModelAction(_) => TProcess()
- case RefProverFunction(decl) => decl.returnType
- case PVLBuiltinInstanceMethod(f) => f(obj.get)(args).t
- case BuiltinInstanceMethod(f) => f(obj.get)(args).t
- }
+trait PVLInvocationImpl[G] extends PVLInvocationOps[G] {
+ this: PVLInvocation[G] =>
+ override lazy val t: Type[G] =
+ ref.get match {
+ case RefFunction(decl) => returnType(decl)
+ case RefProcedure(decl) => returnType(decl)
+ case RefPredicate(_) => TResource()
+ case RefInstanceFunction(decl) => returnType(decl)
+ case RefInstanceMethod(decl) => returnType(decl)
+ case RefInstancePredicate(_) => TResource()
+ case RefADTFunction(decl) => decl.returnType
+ case RefModelProcess(_) => TProcess()
+ case RefModelAction(_) => TProcess()
+ case RefProverFunction(decl) => decl.returnType
+ case PVLBuiltinInstanceMethod(f) => f(obj.get)(args).t
+ case BuiltinInstanceMethod(f) => f(obj.get)(args).t
+ }
private def returnType(app: ContractApplicable[G]): Type[G] =
app.returnType.particularize(typeEnv(app))
@@ -28,13 +39,19 @@ trait PVLInvocationImpl[G] extends PVLInvocationOps[G] { this: PVLInvocation[G]
// Take care to include type arguments of both the type of the object the method is called on, as well as
// the arguments given to the method call itself.
private def typeEnv(app: ContractApplicable[G]): Map[Variable[G], Type[G]] =
- app.typeArgs.zip(typeArgs).toMap ++
- obj.flatMap(_.t.asClass).map(_.typeEnv).getOrElse(Map.empty)
+ app.typeArgs.zip(typeArgs).toMap ++ obj.flatMap(_.t.asClass).map(_.typeEnv)
+ .getOrElse(Map.empty)
override def layout(implicit ctx: Ctx): Doc =
- Group(Group(Group(obj.map(assoc(_) <> ".").getOrElse(Empty) <>
- method <>
- (if(typeArgs.isEmpty) Empty else Text("<") <> Doc.args(typeArgs) <> ">")) <>
- "(" <> Doc.args(args) <> ")") <>
- DocUtil.givenYields(givenMap, yields))
-}
\ No newline at end of file
+ Group(
+ Group(
+ Group(
+ obj.map(assoc(_) <> ".").getOrElse(Empty) <> method <>
+ (if (typeArgs.isEmpty)
+ Empty
+ else
+ Text("<") <> Doc.args(typeArgs) <> ">")
+ ) <> "(" <> Doc.args(args) <> ")"
+ ) <> DocUtil.givenYields(givenMap, yields)
+ )
+}
diff --git a/src/col/vct/col/ast/lang/pvl/PVLLocalImpl.scala b/src/col/vct/col/ast/lang/pvl/PVLLocalImpl.scala
index f22e9a1791..e5fc66c9e1 100644
--- a/src/col/vct/col/ast/lang/pvl/PVLLocalImpl.scala
+++ b/src/col/vct/col/ast/lang/pvl/PVLLocalImpl.scala
@@ -6,18 +6,20 @@ import vct.col.resolve.ctx._
import vct.col.typerules.Types
import vct.col.ast.ops.PVLLocalOps
-trait PVLLocalImpl[G] extends PVLLocalOps[G] { this: PVLLocal[G] =>
- override lazy val t: Type[G] = ref.get match {
- case ref: RefAxiomaticDataType[G] => Types.notAValue(ref)
- case ref: RefEnum[G] => Types.notAValue(ref)
- case ref: RefVariable[G] => ref.decl.t
- case ref: RefClass[G] => Types.notAValue(ref)
- case ref: RefField[G] => ref.decl.t
- case ref: RefModelField[G] => ref.decl.t
- case ref: RefEndpoint[G] => ref.decl.t
- case ref: RefPVLEndpoint[G] => ref.decl.t
- case RefEnumConstant(enum, _) => TEnum(enum.get.ref)
- }
+trait PVLLocalImpl[G] extends PVLLocalOps[G] {
+ this: PVLLocal[G] =>
+ override lazy val t: Type[G] =
+ ref.get match {
+ case ref: RefAxiomaticDataType[G] => Types.notAValue(ref)
+ case ref: RefEnum[G] => Types.notAValue(ref)
+ case ref: RefVariable[G] => ref.decl.t
+ case ref: RefClass[G] => Types.notAValue(ref)
+ case ref: RefField[G] => ref.decl.t
+ case ref: RefModelField[G] => ref.decl.t
+ case ref: RefEndpoint[G] => ref.decl.t
+ case ref: RefPVLEndpoint[G] => ref.decl.t
+ case RefEnumConstant(enum, _) => TEnum(enum.get.ref)
+ }
override def layout(implicit ctx: Ctx): Doc = Text(name)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/pvl/PVLNamedTypeImpl.scala b/src/col/vct/col/ast/lang/pvl/PVLNamedTypeImpl.scala
index a3951767a9..0bb2eba821 100644
--- a/src/col/vct/col/ast/lang/pvl/PVLNamedTypeImpl.scala
+++ b/src/col/vct/col/ast/lang/pvl/PVLNamedTypeImpl.scala
@@ -4,8 +4,14 @@ import vct.col.ast.PVLNamedType
import vct.col.print.{Ctx, Doc, Text, Empty, Group}
import vct.col.ast.ops.PVLNamedTypeOps
-trait PVLNamedTypeImpl[G] extends PVLNamedTypeOps[G] { this: PVLNamedType[G] =>
+trait PVLNamedTypeImpl[G] extends PVLNamedTypeOps[G] {
+ this: PVLNamedType[G] =>
override def layout(implicit ctx: Ctx): Doc =
- Group(Text(name) <>
- (if(typeArgs.isEmpty) Empty else Text("<") <> Doc.args(typeArgs) <> ">"))
-}
\ No newline at end of file
+ Group(
+ Text(name) <>
+ (if (typeArgs.isEmpty)
+ Empty
+ else
+ Text("<") <> Doc.args(typeArgs) <> ">")
+ )
+}
diff --git a/src/col/vct/col/ast/lang/pvl/PVLNewImpl.scala b/src/col/vct/col/ast/lang/pvl/PVLNewImpl.scala
index 2e749636fd..a180363c77 100644
--- a/src/col/vct/col/ast/lang/pvl/PVLNewImpl.scala
+++ b/src/col/vct/col/ast/lang/pvl/PVLNewImpl.scala
@@ -4,7 +4,11 @@ import vct.col.ast.PVLNew
import vct.col.print.{Ctx, Doc, DocUtil, Text, Group}
import vct.col.ast.ops.PVLNewOps
-trait PVLNewImpl[G] extends PVLNewOps[G] { this: PVLNew[G] =>
+trait PVLNewImpl[G] extends PVLNewOps[G] {
+ this: PVLNew[G] =>
override def layout(implicit ctx: Ctx): Doc =
- Group(Group(Text("new") <+> t <> "(" <> Doc.args(args) <> ")") <> DocUtil.givenYields(givenMap, yields))
-}
\ No newline at end of file
+ Group(
+ Group(Text("new") <+> t <> "(" <> Doc.args(args) <> ")") <>
+ DocUtil.givenYields(givenMap, yields)
+ )
+}
diff --git a/src/col/vct/col/ast/lang/pvl/PVLTypeImpl.scala b/src/col/vct/col/ast/lang/pvl/PVLTypeImpl.scala
index 71428cfa6b..22e809bb7c 100644
--- a/src/col/vct/col/ast/lang/pvl/PVLTypeImpl.scala
+++ b/src/col/vct/col/ast/lang/pvl/PVLTypeImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.lang.pvl
import vct.col.ast.PVLType
-trait PVLTypeImpl[G] { this: PVLType[G] =>
+trait PVLTypeImpl[G] {
+ this: PVLType[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/silver/SilverAssignImpl.scala b/src/col/vct/col/ast/lang/silver/SilverAssignImpl.scala
index 2eaf4b8c24..028cea832b 100644
--- a/src/col/vct/col/ast/lang/silver/SilverAssignImpl.scala
+++ b/src/col/vct/col/ast/lang/silver/SilverAssignImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.lang.silver
import vct.col.ast.SilverAssign
-trait SilverAssignImpl[G] { this: SilverAssign[G] =>
+trait SilverAssignImpl[G] {
+ this: SilverAssign[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/silver/SilverBagSizeImpl.scala b/src/col/vct/col/ast/lang/silver/SilverBagSizeImpl.scala
index b5a40aaa67..35cea1cc0a 100644
--- a/src/col/vct/col/ast/lang/silver/SilverBagSizeImpl.scala
+++ b/src/col/vct/col/ast/lang/silver/SilverBagSizeImpl.scala
@@ -4,10 +4,10 @@ import vct.col.ast.{SilverBagSize, TInt}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.SilverBagSizeOps
-trait SilverBagSizeImpl[G] extends SilverBagSizeOps[G] { this: SilverBagSize[G] =>
+trait SilverBagSizeImpl[G] extends SilverBagSizeOps[G] {
+ this: SilverBagSize[G] =>
override def t: TInt[G] = TInt[G]()
override def precedence: Int = Precedence.ATOMIC
- override def layout(implicit ctx: Ctx): Doc =
- Text("|") <> bag <> "|"
+ override def layout(implicit ctx: Ctx): Doc = Text("|") <> bag <> "|"
}
diff --git a/src/col/vct/col/ast/lang/silver/SilverCurFieldPermImpl.scala b/src/col/vct/col/ast/lang/silver/SilverCurFieldPermImpl.scala
index 464f58fb71..20a6e3ae9b 100644
--- a/src/col/vct/col/ast/lang/silver/SilverCurFieldPermImpl.scala
+++ b/src/col/vct/col/ast/lang/silver/SilverCurFieldPermImpl.scala
@@ -4,10 +4,12 @@ import vct.col.ast.{SilverCurFieldPerm, TRational, Type}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.SilverCurFieldPermOps
-trait SilverCurFieldPermImpl[G] extends SilverCurFieldPermOps[G] { this: SilverCurFieldPerm[G] =>
+trait SilverCurFieldPermImpl[G] extends SilverCurFieldPermOps[G] {
+ this: SilverCurFieldPerm[G] =>
override def t: Type[G] = TRational()
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
- Text("perm(") <> obj.bind(Precedence.POSTFIX) <> "." <> ctx.name(field) <> ")"
-}
\ No newline at end of file
+ Text("perm(") <> obj.bind(Precedence.POSTFIX) <> "." <> ctx.name(field) <>
+ ")"
+}
diff --git a/src/col/vct/col/ast/lang/silver/SilverCurPredPermImpl.scala b/src/col/vct/col/ast/lang/silver/SilverCurPredPermImpl.scala
index f7837f0b3e..ff7d8d33db 100644
--- a/src/col/vct/col/ast/lang/silver/SilverCurPredPermImpl.scala
+++ b/src/col/vct/col/ast/lang/silver/SilverCurPredPermImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{SilverCurPredPerm, TRational, Type}
import vct.col.print.{Ctx, Doc, Precedence, Text, Group}
import vct.col.ast.ops.SilverCurPredPermOps
-trait SilverCurPredPermImpl[G] extends SilverCurPredPermOps[G] { this: SilverCurPredPerm[G] =>
+trait SilverCurPredPermImpl[G] extends SilverCurPredPermOps[G] {
+ this: SilverCurPredPerm[G] =>
override def t: Type[G] = TRational()
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
Group(Text("perm(") <> ctx.name(ref) <> "(" <> Doc.args(args) <> ")" <> ")")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/silver/SilverDeclarationImpl.scala b/src/col/vct/col/ast/lang/silver/SilverDeclarationImpl.scala
index d8440d12d4..7bc2fb757c 100644
--- a/src/col/vct/col/ast/lang/silver/SilverDeclarationImpl.scala
+++ b/src/col/vct/col/ast/lang/silver/SilverDeclarationImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.lang.silver
import vct.col.ast.SilverDeclaration
-trait SilverDeclarationImpl[G] { this: SilverDeclaration[G] =>
+trait SilverDeclarationImpl[G] {
+ this: SilverDeclaration[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/silver/SilverDerefImpl.scala b/src/col/vct/col/ast/lang/silver/SilverDerefImpl.scala
index 666b20ad74..23af7dbd16 100644
--- a/src/col/vct/col/ast/lang/silver/SilverDerefImpl.scala
+++ b/src/col/vct/col/ast/lang/silver/SilverDerefImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{SilverDeref, Type}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.SilverDerefOps
-trait SilverDerefImpl[G] extends SilverDerefOps[G] { this: SilverDeref[G] =>
+trait SilverDerefImpl[G] extends SilverDerefOps[G] {
+ this: SilverDeref[G] =>
override def t: Type[G] = field.decl.t
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
assoc(obj) <> "." <> ctx.name(field)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/silver/SilverExprImpl.scala b/src/col/vct/col/ast/lang/silver/SilverExprImpl.scala
index fb80614d38..0813cb6e69 100644
--- a/src/col/vct/col/ast/lang/silver/SilverExprImpl.scala
+++ b/src/col/vct/col/ast/lang/silver/SilverExprImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.lang.silver
import vct.col.ast.SilverExpr
-trait SilverExprImpl[G] { this: SilverExpr[G] =>
+trait SilverExprImpl[G] {
+ this: SilverExpr[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/silver/SilverFieldAssignImpl.scala b/src/col/vct/col/ast/lang/silver/SilverFieldAssignImpl.scala
index 5483a0f410..243936288e 100644
--- a/src/col/vct/col/ast/lang/silver/SilverFieldAssignImpl.scala
+++ b/src/col/vct/col/ast/lang/silver/SilverFieldAssignImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{Expr, SilverFieldAssign}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.SilverFieldAssignOps
-trait SilverFieldAssignImpl[G] extends SilverFieldAssignOps[G] { this: SilverFieldAssign[G] =>
+trait SilverFieldAssignImpl[G] extends SilverFieldAssignOps[G] {
+ this: SilverFieldAssign[G] =>
override def layout(implicit ctx: Ctx): Doc =
obj.bind(Precedence.POSTFIX) <> "." <> ctx.name(field) <+> ":=" <+> value
override def expr: Expr[G] = this.value
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/silver/SilverFieldImpl.scala b/src/col/vct/col/ast/lang/silver/SilverFieldImpl.scala
index 44e386122d..68c5e55103 100644
--- a/src/col/vct/col/ast/lang/silver/SilverFieldImpl.scala
+++ b/src/col/vct/col/ast/lang/silver/SilverFieldImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.SilverField
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.SilverFieldOps
-trait SilverFieldImpl[G] extends SilverFieldOps[G] { this: SilverField[G] =>
+trait SilverFieldImpl[G] extends SilverFieldOps[G] {
+ this: SilverField[G] =>
override def layout(implicit ctx: Ctx): Doc =
Text("field") <+> ctx.name(this) <> ":" <+> t
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/silver/SilverIntToRatImpl.scala b/src/col/vct/col/ast/lang/silver/SilverIntToRatImpl.scala
index 79f1c473f6..959feb7658 100644
--- a/src/col/vct/col/ast/lang/silver/SilverIntToRatImpl.scala
+++ b/src/col/vct/col/ast/lang/silver/SilverIntToRatImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SilverIntToRat, TRational, Type}
import vct.col.print.{Ctx, Doc}
import vct.col.ast.ops.SilverIntToRatOps
-trait SilverIntToRatImpl[G] extends SilverIntToRatOps[G] { this: SilverIntToRat[G] =>
+trait SilverIntToRatImpl[G] extends SilverIntToRatOps[G] {
+ this: SilverIntToRat[G] =>
override def t: Type[G] = TRational()
override def precedence: Int = perm.precedence
diff --git a/src/col/vct/col/ast/lang/silver/SilverLocalAssignImpl.scala b/src/col/vct/col/ast/lang/silver/SilverLocalAssignImpl.scala
index 432549a54a..6e0e30ff09 100644
--- a/src/col/vct/col/ast/lang/silver/SilverLocalAssignImpl.scala
+++ b/src/col/vct/col/ast/lang/silver/SilverLocalAssignImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.{Expr, SilverLocalAssign}
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.SilverLocalAssignOps
-trait SilverLocalAssignImpl[G] extends SilverLocalAssignOps[G] { this: SilverLocalAssign[G] =>
+trait SilverLocalAssignImpl[G] extends SilverLocalAssignOps[G] {
+ this: SilverLocalAssign[G] =>
override def layout(implicit ctx: Ctx): Doc =
Text(ctx.name(v)) <+> ":=" <+> value
override def expr: Expr[G] = this.value
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/silver/SilverMapSizeImpl.scala b/src/col/vct/col/ast/lang/silver/SilverMapSizeImpl.scala
index e245b57098..0d31b5f21c 100644
--- a/src/col/vct/col/ast/lang/silver/SilverMapSizeImpl.scala
+++ b/src/col/vct/col/ast/lang/silver/SilverMapSizeImpl.scala
@@ -4,10 +4,10 @@ import vct.col.ast.{SilverMapSize, TInt}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.SilverMapSizeOps
-trait SilverMapSizeImpl[G] extends SilverMapSizeOps[G] { this: SilverMapSize[G] =>
+trait SilverMapSizeImpl[G] extends SilverMapSizeOps[G] {
+ this: SilverMapSize[G] =>
override def t: TInt[G] = TInt()
override def precedence: Int = Precedence.ATOMIC
- override def layout(implicit ctx: Ctx): Doc =
- Text("|") <> map.show <> "|"
+ override def layout(implicit ctx: Ctx): Doc = Text("|") <> map.show <> "|"
}
diff --git a/src/col/vct/col/ast/lang/silver/SilverNewRefImpl.scala b/src/col/vct/col/ast/lang/silver/SilverNewRefImpl.scala
index cbab39b2a3..8f745fd480 100644
--- a/src/col/vct/col/ast/lang/silver/SilverNewRefImpl.scala
+++ b/src/col/vct/col/ast/lang/silver/SilverNewRefImpl.scala
@@ -4,7 +4,11 @@ import vct.col.ast.SilverNewRef
import vct.col.print.{Ctx, Doc, Group, Text}
import vct.col.ast.ops.SilverNewRefOps
-trait SilverNewRefImpl[G] extends SilverNewRefOps[G] { this: SilverNewRef[G] =>
+trait SilverNewRefImpl[G] extends SilverNewRefOps[G] {
+ this: SilverNewRef[G] =>
override def layout(implicit ctx: Ctx): Doc =
- Group(Text(ctx.name(v)) <+> ":=" <+> "new(" <> Doc.args(fields.map(ctx.name).map(Text)) <> ")")
-}
\ No newline at end of file
+ Group(
+ Text(ctx.name(v)) <+> ":=" <+> "new(" <>
+ Doc.args(fields.map(ctx.name).map(Text)) <> ")"
+ )
+}
diff --git a/src/col/vct/col/ast/lang/silver/SilverNullImpl.scala b/src/col/vct/col/ast/lang/silver/SilverNullImpl.scala
index d7e9f691d5..daefad2332 100644
--- a/src/col/vct/col/ast/lang/silver/SilverNullImpl.scala
+++ b/src/col/vct/col/ast/lang/silver/SilverNullImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SilverNull, TRef}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.SilverNullOps
-trait SilverNullImpl[G] extends SilverNullOps[G] { this: SilverNull[G] =>
+trait SilverNullImpl[G] extends SilverNullOps[G] {
+ this: SilverNull[G] =>
override def t: TRef[G] = TRef[G]()
override def layout(implicit ctx: Ctx): Doc = Text("null")
diff --git a/src/col/vct/col/ast/lang/silver/SilverPartialADTFunctionInvocationImpl.scala b/src/col/vct/col/ast/lang/silver/SilverPartialADTFunctionInvocationImpl.scala
index 31e6d0ecc2..e31f156d03 100644
--- a/src/col/vct/col/ast/lang/silver/SilverPartialADTFunctionInvocationImpl.scala
+++ b/src/col/vct/col/ast/lang/silver/SilverPartialADTFunctionInvocationImpl.scala
@@ -1,20 +1,31 @@
package vct.col.ast.lang.silver
-import vct.col.ast.{ADTFunction, AxiomaticDataType, SilverPartialADTFunctionInvocation, Type}
+import vct.col.ast.{
+ ADTFunction,
+ AxiomaticDataType,
+ SilverPartialADTFunctionInvocation,
+ Type,
+}
import vct.col.print._
import vct.col.ref.Ref
import vct.col.ast.ops.SilverPartialADTFunctionInvocationOps
-trait SilverPartialADTFunctionInvocationImpl[G] extends SilverPartialADTFunctionInvocationOps[G] { this: SilverPartialADTFunctionInvocation[G] =>
+trait SilverPartialADTFunctionInvocationImpl[G]
+ extends SilverPartialADTFunctionInvocationOps[G] {
+ this: SilverPartialADTFunctionInvocation[G] =>
def adt: AxiomaticDataType[G] = ref.get._1
def function: ADTFunction[G] = ref.get._2
def maybeTypeArgs: Option[Seq[Type[G]]] =
- Some(adt.typeArgs.map(arg => partialTypeArgs.collectFirst { case (Ref(v), t) if arg == v => t }.getOrElse(return None)))
+ Some(adt.typeArgs.map(arg =>
+ partialTypeArgs.collectFirst { case (Ref(v), t) if arg == v => t }
+ .getOrElse(return None)
+ ))
def typeArgs: Seq[Type[G]] = maybeTypeArgs.get
- override lazy val t: Type[G] = function.returnType.particularize(adt.typeArgs.zip(typeArgs).toMap)
+ override lazy val t: Type[G] = function.returnType
+ .particularize(adt.typeArgs.zip(typeArgs).toMap)
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
diff --git a/src/col/vct/col/ast/lang/silver/SilverPartialTAxiomaticImpl.scala b/src/col/vct/col/ast/lang/silver/SilverPartialTAxiomaticImpl.scala
index 454dbd571d..1be8b638f9 100644
--- a/src/col/vct/col/ast/lang/silver/SilverPartialTAxiomaticImpl.scala
+++ b/src/col/vct/col/ast/lang/silver/SilverPartialTAxiomaticImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.SilverPartialTAxiomatic
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.SilverPartialTAxiomaticOps
-trait SilverPartialTAxiomaticImpl[G] extends SilverPartialTAxiomaticOps[G] { this: SilverPartialTAxiomatic[G] =>
+trait SilverPartialTAxiomaticImpl[G] extends SilverPartialTAxiomaticOps[G] {
+ this: SilverPartialTAxiomatic[G] =>
override def layout(implicit ctx: Ctx): Doc =
Text(ctx.name(ref)) <> open <> "..." <> close
}
diff --git a/src/col/vct/col/ast/lang/silver/SilverSeqSizeImpl.scala b/src/col/vct/col/ast/lang/silver/SilverSeqSizeImpl.scala
index 67b12a118e..0ebbbda5c7 100644
--- a/src/col/vct/col/ast/lang/silver/SilverSeqSizeImpl.scala
+++ b/src/col/vct/col/ast/lang/silver/SilverSeqSizeImpl.scala
@@ -4,10 +4,10 @@ import vct.col.ast.{SilverSeqSize, TInt}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.SilverSeqSizeOps
-trait SilverSeqSizeImpl[G] extends SilverSeqSizeOps[G] { this: SilverSeqSize[G] =>
+trait SilverSeqSizeImpl[G] extends SilverSeqSizeOps[G] {
+ this: SilverSeqSize[G] =>
override def t: TInt[G] = TInt[G]()
override def precedence: Int = Precedence.ATOMIC
- override def layout(implicit ctx: Ctx): Doc =
- Text("|") <> seq <> "|"
+ override def layout(implicit ctx: Ctx): Doc = Text("|") <> seq <> "|"
}
diff --git a/src/col/vct/col/ast/lang/silver/SilverSetSizeImpl.scala b/src/col/vct/col/ast/lang/silver/SilverSetSizeImpl.scala
index 4fd311ae34..785126d4ca 100644
--- a/src/col/vct/col/ast/lang/silver/SilverSetSizeImpl.scala
+++ b/src/col/vct/col/ast/lang/silver/SilverSetSizeImpl.scala
@@ -4,10 +4,10 @@ import vct.col.ast.{SilverSetSize, TInt}
import vct.col.print.{Ctx, Doc, Precedence, Text}
import vct.col.ast.ops.SilverSetSizeOps
-trait SilverSetSizeImpl[G] extends SilverSetSizeOps[G] { this: SilverSetSize[G] =>
+trait SilverSetSizeImpl[G] extends SilverSetSizeOps[G] {
+ this: SilverSetSize[G] =>
override def t: TInt[G] = TInt[G]()
override def precedence: Int = Precedence.ATOMIC
- override def layout(implicit ctx: Ctx): Doc =
- Text("|") <> set <> "|"
+ override def layout(implicit ctx: Ctx): Doc = Text("|") <> set <> "|"
}
diff --git a/src/col/vct/col/ast/lang/silver/SilverStatementImpl.scala b/src/col/vct/col/ast/lang/silver/SilverStatementImpl.scala
index f7674da787..0ab76fccb4 100644
--- a/src/col/vct/col/ast/lang/silver/SilverStatementImpl.scala
+++ b/src/col/vct/col/ast/lang/silver/SilverStatementImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.lang.silver
import vct.col.ast.SilverStatement
-trait SilverStatementImpl[G] { this: SilverStatement[G] =>
+trait SilverStatementImpl[G] {
+ this: SilverStatement[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/silver/SilverTypeImpl.scala b/src/col/vct/col/ast/lang/silver/SilverTypeImpl.scala
index e61d1ff42a..c3c86165c8 100644
--- a/src/col/vct/col/ast/lang/silver/SilverTypeImpl.scala
+++ b/src/col/vct/col/ast/lang/silver/SilverTypeImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.lang.silver
import vct.col.ast.SilverType
-trait SilverTypeImpl[G] { this: SilverType[G] =>
-
+trait SilverTypeImpl[G] {
+ this: SilverType[G] =>
+
}
diff --git a/src/col/vct/col/ast/lang/silver/SilverUntypedNonemptyLiteralMapImpl.scala b/src/col/vct/col/ast/lang/silver/SilverUntypedNonemptyLiteralMapImpl.scala
index fe6bdd5f0c..9a90e0b959 100644
--- a/src/col/vct/col/ast/lang/silver/SilverUntypedNonemptyLiteralMapImpl.scala
+++ b/src/col/vct/col/ast/lang/silver/SilverUntypedNonemptyLiteralMapImpl.scala
@@ -5,7 +5,9 @@ import vct.col.print.{Ctx, Doc, Precedence, Text, Group}
import vct.col.typerules.Types
import vct.col.ast.ops.SilverUntypedNonemptyLiteralMapOps
-trait SilverUntypedNonemptyLiteralMapImpl[G] extends SilverUntypedNonemptyLiteralMapOps[G] { this: SilverUntypedNonemptyLiteralMap[G] =>
+trait SilverUntypedNonemptyLiteralMapImpl[G]
+ extends SilverUntypedNonemptyLiteralMapOps[G] {
+ this: SilverUntypedNonemptyLiteralMap[G] =>
def mapKeys: Seq[Expr[G]] = values.map(_._1)
def mapValues: Seq[Expr[G]] = values.map(_._2)
@@ -16,7 +18,7 @@ trait SilverUntypedNonemptyLiteralMapImpl[G] extends SilverUntypedNonemptyLitera
override def precedence: Int = Precedence.POSTFIX
override def layout(implicit ctx: Ctx): Doc =
- Group(Text("Map(") <> Doc.args(values.map {
- case (k, v) => k.show <+> ":=" <+> v
+ Group(Text("Map(") <> Doc.args(values.map { case (k, v) =>
+ k.show <+> ":=" <+> v
}) <> ")")
}
diff --git a/src/col/vct/col/ast/lang/smt/BoogieImpl.scala b/src/col/vct/col/ast/lang/smt/BoogieImpl.scala
index ed7acca297..54d2839115 100644
--- a/src/col/vct/col/ast/lang/smt/BoogieImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/BoogieImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.Boogie
import vct.col.ast.ops.BoogieOps
import vct.col.print._
-trait BoogieImpl[G] extends BoogieOps[G] { this: Boogie[G] =>
+trait BoogieImpl[G] extends BoogieOps[G] {
+ this: Boogie[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/ProverLanguageImpl.scala b/src/col/vct/col/ast/lang/smt/ProverLanguageImpl.scala
index 2d6c529f06..8c4a7eaeb7 100644
--- a/src/col/vct/col/ast/lang/smt/ProverLanguageImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/ProverLanguageImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.ProverLanguage
import vct.col.ast.ops.ProverLanguageFamilyOps
import vct.col.print._
-trait ProverLanguageImpl[G] extends ProverLanguageFamilyOps[G] { this: ProverLanguage[G] =>
+trait ProverLanguageImpl[G] extends ProverLanguageFamilyOps[G] {
+ this: ProverLanguage[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtLibImpl.scala b/src/col/vct/col/ast/lang/smt/SmtLibImpl.scala
index c1ed79dbcb..44f4fe06e1 100644
--- a/src/col/vct/col/ast/lang/smt/SmtLibImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtLibImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.SmtLib
import vct.col.ast.ops.SmtLibOps
import vct.col.print._
-trait SmtLibImpl[G] extends SmtLibOps[G] { this: SmtLib[G] =>
+trait SmtLibImpl[G] extends SmtLibOps[G] {
+ this: SmtLib[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibADTFunctionSymbolImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibADTFunctionSymbolImpl.scala
index 98b6a30de4..d62ad3268e 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibADTFunctionSymbolImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibADTFunctionSymbolImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.SmtlibADTFunctionSymbol
import vct.col.ast.ops.SmtlibADTFunctionSymbolOps
import vct.col.print._
-trait SmtlibADTFunctionSymbolImpl[G] extends SmtlibADTFunctionSymbolOps[G] { this: SmtlibADTFunctionSymbol[G] =>
+trait SmtlibADTFunctionSymbolImpl[G] extends SmtlibADTFunctionSymbolOps[G] {
+ this: SmtlibADTFunctionSymbol[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibBitvecLiteralImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibBitvecLiteralImpl.scala
index 9bf93ad860..6bdde0e020 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibBitvecLiteralImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibBitvecLiteralImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibBitvecLiteral, TSmtlibBitVector, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibBitvecLiteralOps
-trait SmtlibBitvecLiteralImpl[G] extends SmtlibBitvecLiteralOps[G] { this: SmtlibBitvecLiteral[G] =>
+trait SmtlibBitvecLiteralImpl[G] extends SmtlibBitvecLiteralOps[G] {
+ this: SmtlibBitvecLiteral[G] =>
override def t: Type[G] = TSmtlibBitVector(data.length)
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibBvAddImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibBvAddImpl.scala
index c1d73f1750..69696e4328 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibBvAddImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibBvAddImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.SmtlibBvAddOps
-trait SmtlibBvAddImpl[G] extends SmtlibBvAddOps[G] { this: SmtlibBvAdd[G] =>
+trait SmtlibBvAddImpl[G] extends SmtlibBvAddOps[G] {
+ this: SmtlibBvAdd[G] =>
override def t: Type[G] = left.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibBvAndImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibBvAndImpl.scala
index 7039a5190a..682056ec00 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibBvAndImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibBvAndImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.SmtlibBvAndOps
-trait SmtlibBvAndImpl[G] extends SmtlibBvAndOps[G] { this: SmtlibBvAnd[G] =>
+trait SmtlibBvAndImpl[G] extends SmtlibBvAndOps[G] {
+ this: SmtlibBvAnd[G] =>
override def t: Type[G] = left.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibBvMulImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibBvMulImpl.scala
index b1b3fd1567..4cdae9d8a0 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibBvMulImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibBvMulImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.SmtlibBvMulOps
-trait SmtlibBvMulImpl[G] extends SmtlibBvMulOps[G] { this: SmtlibBvMul[G] =>
+trait SmtlibBvMulImpl[G] extends SmtlibBvMulOps[G] {
+ this: SmtlibBvMul[G] =>
override def t: Type[G] = left.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibBvNegImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibBvNegImpl.scala
index e14f787b10..d6db2814b5 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibBvNegImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibBvNegImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.SmtlibBvNegOps
-trait SmtlibBvNegImpl[G] extends SmtlibBvNegOps[G] { this: SmtlibBvNeg[G] =>
+trait SmtlibBvNegImpl[G] extends SmtlibBvNegOps[G] {
+ this: SmtlibBvNeg[G] =>
override def t: Type[G] = bv.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibBvNotImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibBvNotImpl.scala
index 23c72f1b60..e81a511d2d 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibBvNotImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibBvNotImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.SmtlibBvNotOps
-trait SmtlibBvNotImpl[G] extends SmtlibBvNotOps[G] { this: SmtlibBvNot[G] =>
+trait SmtlibBvNotImpl[G] extends SmtlibBvNotOps[G] {
+ this: SmtlibBvNot[G] =>
override def t: Type[G] = bv.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibBvOrImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibBvOrImpl.scala
index 961432228e..4026a7fb8a 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibBvOrImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibBvOrImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.SmtlibBvOrOps
-trait SmtlibBvOrImpl[G] extends SmtlibBvOrOps[G] { this: SmtlibBvOr[G] =>
+trait SmtlibBvOrImpl[G] extends SmtlibBvOrOps[G] {
+ this: SmtlibBvOr[G] =>
override def t: Type[G] = left.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibBvShlImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibBvShlImpl.scala
index 7cee447db6..afbe7bc5ce 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibBvShlImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibBvShlImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.SmtlibBvShlOps
-trait SmtlibBvShlImpl[G] extends SmtlibBvShlOps[G] { this: SmtlibBvShl[G] =>
+trait SmtlibBvShlImpl[G] extends SmtlibBvShlOps[G] {
+ this: SmtlibBvShl[G] =>
override def t: Type[G] = left.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibBvShrImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibBvShrImpl.scala
index d6fa0b3e25..c60fd58e2f 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibBvShrImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibBvShrImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.SmtlibBvShrOps
-trait SmtlibBvShrImpl[G] extends SmtlibBvShrOps[G] { this: SmtlibBvShr[G] =>
+trait SmtlibBvShrImpl[G] extends SmtlibBvShrOps[G] {
+ this: SmtlibBvShr[G] =>
override def t: Type[G] = left.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibBvUDivImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibBvUDivImpl.scala
index 510d8991a5..88f3656a12 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibBvUDivImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibBvUDivImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.SmtlibBvUDivOps
-trait SmtlibBvUDivImpl[G] extends SmtlibBvUDivOps[G] { this: SmtlibBvUDiv[G] =>
+trait SmtlibBvUDivImpl[G] extends SmtlibBvUDivOps[G] {
+ this: SmtlibBvUDiv[G] =>
override def t: Type[G] = left.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibBvULtImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibBvULtImpl.scala
index 23b894991b..824898b319 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibBvULtImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibBvULtImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.SmtlibBvULtOps
-trait SmtlibBvULtImpl[G] extends SmtlibBvULtOps[G] { this: SmtlibBvULt[G] =>
+trait SmtlibBvULtImpl[G] extends SmtlibBvULtOps[G] {
+ this: SmtlibBvULt[G] =>
override def t: Type[G] = left.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibBvURemImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibBvURemImpl.scala
index 5811a31ad4..599fc258e9 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibBvURemImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibBvURemImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.SmtlibBvURemOps
-trait SmtlibBvURemImpl[G] extends SmtlibBvURemOps[G] { this: SmtlibBvURem[G] =>
+trait SmtlibBvURemImpl[G] extends SmtlibBvURemOps[G] {
+ this: SmtlibBvURem[G] =>
override def t: Type[G] = left.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibConcatImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibConcatImpl.scala
index fac1a05d14..62ab9a3aa1 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibConcatImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibConcatImpl.scala
@@ -4,7 +4,10 @@ import vct.col.ast.{SmtlibConcat, TSmtlibBitVector, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibConcatOps
-trait SmtlibConcatImpl[G] extends SmtlibConcatOps[G] { this: SmtlibConcat[G] =>
- override lazy val t: Type[G] = TSmtlibBitVector(left.t.asBitvec.get.size + right.t.asBitvec.get.size)
+trait SmtlibConcatImpl[G] extends SmtlibConcatOps[G] {
+ this: SmtlibConcat[G] =>
+ override lazy val t: Type[G] = TSmtlibBitVector(
+ left.t.asBitvec.get.size + right.t.asBitvec.get.size
+ )
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibExtractImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibExtractImpl.scala
index 31ebd628cd..01e5251183 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibExtractImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibExtractImpl.scala
@@ -4,7 +4,9 @@ import vct.col.ast.{SmtlibExtract, TSmtlibBitVector, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibExtractOps
-trait SmtlibExtractImpl[G] extends SmtlibExtractOps[G] { this: SmtlibExtract[G] =>
- override def t: Type[G] = TSmtlibBitVector(inclusiveEndIndexFromRight - startIndexFromRight + 1)
+trait SmtlibExtractImpl[G] extends SmtlibExtractOps[G] {
+ this: SmtlibExtract[G] =>
+ override def t: Type[G] =
+ TSmtlibBitVector(inclusiveEndIndexFromRight - startIndexFromRight + 1)
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFpAbsImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFpAbsImpl.scala
index 259a8a4983..4d413a13b0 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFpAbsImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFpAbsImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.SmtlibFpAbsOps
-trait SmtlibFpAbsImpl[G] extends SmtlibFpAbsOps[G] { this: SmtlibFpAbs[G] =>
+trait SmtlibFpAbsImpl[G] extends SmtlibFpAbsOps[G] {
+ this: SmtlibFpAbs[G] =>
override def t: Type[G] = arg.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFpAddImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFpAddImpl.scala
index 438391e25c..40ad794696 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFpAddImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFpAddImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.SmtlibFpAddOps
-trait SmtlibFpAddImpl[G] extends SmtlibFpAddOps[G] { this: SmtlibFpAdd[G] =>
+trait SmtlibFpAddImpl[G] extends SmtlibFpAddOps[G] {
+ this: SmtlibFpAdd[G] =>
override def t: Type[G] = left.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFpCastImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFpCastImpl.scala
index b43fd8861a..6d7c49d517 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFpCastImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFpCastImpl.scala
@@ -4,7 +4,9 @@ import vct.col.ast.{SmtlibFpCast, TSmtlibFloatingPoint, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibFpCastOps
-trait SmtlibFpCastImpl[G] extends SmtlibFpCastOps[G] { this: SmtlibFpCast[G] =>
- override def t: Type[G] = TSmtlibFloatingPoint(exponentBits, mantissaAndSignBits)
+trait SmtlibFpCastImpl[G] extends SmtlibFpCastOps[G] {
+ this: SmtlibFpCast[G] =>
+ override def t: Type[G] =
+ TSmtlibFloatingPoint(exponentBits, mantissaAndSignBits)
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFpDivImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFpDivImpl.scala
index e1224b8fc5..da7863201a 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFpDivImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFpDivImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.SmtlibFpDivOps
-trait SmtlibFpDivImpl[G] extends SmtlibFpDivOps[G] { this: SmtlibFpDiv[G] =>
+trait SmtlibFpDivImpl[G] extends SmtlibFpDivOps[G] {
+ this: SmtlibFpDiv[G] =>
override def t: Type[G] = left.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFpEqImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFpEqImpl.scala
index d5725a1003..a21437b899 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFpEqImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFpEqImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.{Type, TBool}
import vct.col.print._
import vct.col.ast.ops.SmtlibFpEqOps
-trait SmtlibFpEqImpl[G] extends SmtlibFpEqOps[G] { this: SmtlibFpEq[G] =>
+trait SmtlibFpEqImpl[G] extends SmtlibFpEqOps[G] {
+ this: SmtlibFpEq[G] =>
override def t: Type[G] = TBool()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFpFmaImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFpFmaImpl.scala
index 883c1eae60..6921666bb3 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFpFmaImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFpFmaImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.SmtlibFpFmaOps
-trait SmtlibFpFmaImpl[G] extends SmtlibFpFmaOps[G] { this: SmtlibFpFma[G] =>
+trait SmtlibFpFmaImpl[G] extends SmtlibFpFmaOps[G] {
+ this: SmtlibFpFma[G] =>
override def t: Type[G] = left.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFpFromRealImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFpFromRealImpl.scala
index 145e94fdf2..637c543a76 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFpFromRealImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFpFromRealImpl.scala
@@ -4,7 +4,9 @@ import vct.col.ast.{SmtlibFpFromReal, TSmtlibFloatingPoint, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibFpFromRealOps
-trait SmtlibFpFromRealImpl[G] extends SmtlibFpFromRealOps[G] { this: SmtlibFpFromReal[G] =>
- override def t: Type[G] = TSmtlibFloatingPoint(exponentBits, mantissaAndSignBits)
+trait SmtlibFpFromRealImpl[G] extends SmtlibFpFromRealOps[G] {
+ this: SmtlibFpFromReal[G] =>
+ override def t: Type[G] =
+ TSmtlibFloatingPoint(exponentBits, mantissaAndSignBits)
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFpFromSIntImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFpFromSIntImpl.scala
index 023a05c380..9e6e100423 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFpFromSIntImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFpFromSIntImpl.scala
@@ -4,7 +4,9 @@ import vct.col.ast.{SmtlibFpFromSInt, TSmtlibFloatingPoint, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibFpFromSIntOps
-trait SmtlibFpFromSIntImpl[G] extends SmtlibFpFromSIntOps[G] { this: SmtlibFpFromSInt[G] =>
- override def t: Type[G] = TSmtlibFloatingPoint(exponentBits, mantissaAndSignBits)
+trait SmtlibFpFromSIntImpl[G] extends SmtlibFpFromSIntOps[G] {
+ this: SmtlibFpFromSInt[G] =>
+ override def t: Type[G] =
+ TSmtlibFloatingPoint(exponentBits, mantissaAndSignBits)
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFpFromUIntImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFpFromUIntImpl.scala
index e63a36b2e5..8bceef1ae5 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFpFromUIntImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFpFromUIntImpl.scala
@@ -4,7 +4,9 @@ import vct.col.ast.{SmtlibFpFromUInt, TSmtlibFloatingPoint, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibFpFromUIntOps
-trait SmtlibFpFromUIntImpl[G] extends SmtlibFpFromUIntOps[G] { this: SmtlibFpFromUInt[G] =>
- override def t: Type[G] = TSmtlibFloatingPoint(exponentBits, mantissaAndSignBits)
+trait SmtlibFpFromUIntImpl[G] extends SmtlibFpFromUIntOps[G] {
+ this: SmtlibFpFromUInt[G] =>
+ override def t: Type[G] =
+ TSmtlibFloatingPoint(exponentBits, mantissaAndSignBits)
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFpGeqImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFpGeqImpl.scala
index 0de5d01d3f..051b9ef04b 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFpGeqImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFpGeqImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibFpGeq, TBool, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibFpGeqOps
-trait SmtlibFpGeqImpl[G] extends SmtlibFpGeqOps[G] { this: SmtlibFpGeq[G] =>
+trait SmtlibFpGeqImpl[G] extends SmtlibFpGeqOps[G] {
+ this: SmtlibFpGeq[G] =>
override def t: Type[G] = TBool()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFpGtImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFpGtImpl.scala
index 41393e1623..f7d265c438 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFpGtImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFpGtImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibFpGt, TBool, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibFpGtOps
-trait SmtlibFpGtImpl[G] extends SmtlibFpGtOps[G] { this: SmtlibFpGt[G] =>
+trait SmtlibFpGtImpl[G] extends SmtlibFpGtOps[G] {
+ this: SmtlibFpGt[G] =>
override def t: Type[G] = TBool()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFpImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFpImpl.scala
index 6e915f7a8d..15a879eca6 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFpImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFpImpl.scala
@@ -4,7 +4,12 @@ import vct.col.ast.{SmtlibFp, TSmtlibFloatingPoint, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibFpOps
-trait SmtlibFpImpl[G] extends SmtlibFpOps[G] { this: SmtlibFp[G] =>
- override def t: Type[G] = TSmtlibFloatingPoint(exponent.t.asBitvec.get.size, mantissa.t.asBitvec.get.size + 1)
+trait SmtlibFpImpl[G] extends SmtlibFpOps[G] {
+ this: SmtlibFp[G] =>
+ override def t: Type[G] =
+ TSmtlibFloatingPoint(
+ exponent.t.asBitvec.get.size,
+ mantissa.t.asBitvec.get.size + 1,
+ )
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFpIsInfiniteImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFpIsInfiniteImpl.scala
index 72c123497b..6a7b2a9454 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFpIsInfiniteImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFpIsInfiniteImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibFpIsInfinite, TBool, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibFpIsInfiniteOps
-trait SmtlibFpIsInfiniteImpl[G] extends SmtlibFpIsInfiniteOps[G] { this: SmtlibFpIsInfinite[G] =>
+trait SmtlibFpIsInfiniteImpl[G] extends SmtlibFpIsInfiniteOps[G] {
+ this: SmtlibFpIsInfinite[G] =>
override def t: Type[G] = TBool()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFpIsNaNImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFpIsNaNImpl.scala
index 4db14783d1..7e019fe8bb 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFpIsNaNImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFpIsNaNImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibFpIsNaN, TBool, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibFpIsNaNOps
-trait SmtlibFpIsNaNImpl[G] extends SmtlibFpIsNaNOps[G] { this: SmtlibFpIsNaN[G] =>
+trait SmtlibFpIsNaNImpl[G] extends SmtlibFpIsNaNOps[G] {
+ this: SmtlibFpIsNaN[G] =>
override def t: Type[G] = TBool()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFpIsNegativeImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFpIsNegativeImpl.scala
index 7f0368d6e2..d31464a68f 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFpIsNegativeImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFpIsNegativeImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibFpIsNegative, TBool, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibFpIsNegativeOps
-trait SmtlibFpIsNegativeImpl[G] extends SmtlibFpIsNegativeOps[G] { this: SmtlibFpIsNegative[G] =>
+trait SmtlibFpIsNegativeImpl[G] extends SmtlibFpIsNegativeOps[G] {
+ this: SmtlibFpIsNegative[G] =>
override def t: Type[G] = TBool()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFpIsNormalImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFpIsNormalImpl.scala
index a79ad6efd4..c3f0a09c66 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFpIsNormalImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFpIsNormalImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibFpIsNormal, TBool, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibFpIsNormalOps
-trait SmtlibFpIsNormalImpl[G] extends SmtlibFpIsNormalOps[G] { this: SmtlibFpIsNormal[G] =>
+trait SmtlibFpIsNormalImpl[G] extends SmtlibFpIsNormalOps[G] {
+ this: SmtlibFpIsNormal[G] =>
override def t: Type[G] = TBool()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFpIsPositiveImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFpIsPositiveImpl.scala
index 8bd5fcdc49..83cfc96fa8 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFpIsPositiveImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFpIsPositiveImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibFpIsPositive, TBool, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibFpIsPositiveOps
-trait SmtlibFpIsPositiveImpl[G] extends SmtlibFpIsPositiveOps[G] { this: SmtlibFpIsPositive[G] =>
+trait SmtlibFpIsPositiveImpl[G] extends SmtlibFpIsPositiveOps[G] {
+ this: SmtlibFpIsPositive[G] =>
override def t: Type[G] = TBool()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFpIsSubnormalImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFpIsSubnormalImpl.scala
index 8e8b5c3303..4f1c610edf 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFpIsSubnormalImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFpIsSubnormalImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibFpIsSubnormal, TBool, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibFpIsSubnormalOps
-trait SmtlibFpIsSubnormalImpl[G] extends SmtlibFpIsSubnormalOps[G] { this: SmtlibFpIsSubnormal[G] =>
+trait SmtlibFpIsSubnormalImpl[G] extends SmtlibFpIsSubnormalOps[G] {
+ this: SmtlibFpIsSubnormal[G] =>
override def t: Type[G] = TBool()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFpIsZeroImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFpIsZeroImpl.scala
index 0edc14d36e..877c62ae2a 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFpIsZeroImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFpIsZeroImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibFpIsZero, TBool, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibFpIsZeroOps
-trait SmtlibFpIsZeroImpl[G] extends SmtlibFpIsZeroOps[G] { this: SmtlibFpIsZero[G] =>
+trait SmtlibFpIsZeroImpl[G] extends SmtlibFpIsZeroOps[G] {
+ this: SmtlibFpIsZero[G] =>
override def t: Type[G] = TBool()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFpLeqImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFpLeqImpl.scala
index 3ad2342af0..57d81504c3 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFpLeqImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFpLeqImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibFpLeq, TBool, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibFpLeqOps
-trait SmtlibFpLeqImpl[G] extends SmtlibFpLeqOps[G] { this: SmtlibFpLeq[G] =>
+trait SmtlibFpLeqImpl[G] extends SmtlibFpLeqOps[G] {
+ this: SmtlibFpLeq[G] =>
override def t: Type[G] = TBool()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFpLtImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFpLtImpl.scala
index 32f22ce083..4eb61c66ab 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFpLtImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFpLtImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibFpLt, TBool, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibFpLtOps
-trait SmtlibFpLtImpl[G] extends SmtlibFpLtOps[G] { this: SmtlibFpLt[G] =>
+trait SmtlibFpLtImpl[G] extends SmtlibFpLtOps[G] {
+ this: SmtlibFpLt[G] =>
override def t: Type[G] = TBool()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFpMaxImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFpMaxImpl.scala
index c81475da7e..7f56deecca 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFpMaxImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFpMaxImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.SmtlibFpMaxOps
-trait SmtlibFpMaxImpl[G] extends SmtlibFpMaxOps[G] { this: SmtlibFpMax[G] =>
+trait SmtlibFpMaxImpl[G] extends SmtlibFpMaxOps[G] {
+ this: SmtlibFpMax[G] =>
override def t: Type[G] = left.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFpMinImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFpMinImpl.scala
index 04f1b0004e..2cfe19b413 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFpMinImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFpMinImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.SmtlibFpMinOps
-trait SmtlibFpMinImpl[G] extends SmtlibFpMinOps[G] { this: SmtlibFpMin[G] =>
+trait SmtlibFpMinImpl[G] extends SmtlibFpMinOps[G] {
+ this: SmtlibFpMin[G] =>
override def t: Type[G] = left.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFpMulImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFpMulImpl.scala
index 1ac952d822..26adea8739 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFpMulImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFpMulImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.SmtlibFpMulOps
-trait SmtlibFpMulImpl[G] extends SmtlibFpMulOps[G] { this: SmtlibFpMul[G] =>
+trait SmtlibFpMulImpl[G] extends SmtlibFpMulOps[G] {
+ this: SmtlibFpMul[G] =>
override def t: Type[G] = left.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFpNegImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFpNegImpl.scala
index 02005d4b89..ed874ccf15 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFpNegImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFpNegImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.SmtlibFpNegOps
-trait SmtlibFpNegImpl[G] extends SmtlibFpNegOps[G] { this: SmtlibFpNeg[G] =>
+trait SmtlibFpNegImpl[G] extends SmtlibFpNegOps[G] {
+ this: SmtlibFpNeg[G] =>
override def t: Type[G] = arg.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFpRemImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFpRemImpl.scala
index 0842e110a2..c3c3598368 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFpRemImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFpRemImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.SmtlibFpRemOps
-trait SmtlibFpRemImpl[G] extends SmtlibFpRemOps[G] { this: SmtlibFpRem[G] =>
+trait SmtlibFpRemImpl[G] extends SmtlibFpRemOps[G] {
+ this: SmtlibFpRem[G] =>
override def t: Type[G] = left.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFpRoundToIntegralImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFpRoundToIntegralImpl.scala
index 48230d724e..c9b42df03c 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFpRoundToIntegralImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFpRoundToIntegralImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.SmtlibFpRoundToIntegralOps
-trait SmtlibFpRoundToIntegralImpl[G] extends SmtlibFpRoundToIntegralOps[G] { this: SmtlibFpRoundToIntegral[G] =>
+trait SmtlibFpRoundToIntegralImpl[G] extends SmtlibFpRoundToIntegralOps[G] {
+ this: SmtlibFpRoundToIntegral[G] =>
override def t: Type[G] = arg.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFpSqrtImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFpSqrtImpl.scala
index d86891a3ab..ae83e4b18c 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFpSqrtImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFpSqrtImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.SmtlibFpSqrtOps
-trait SmtlibFpSqrtImpl[G] extends SmtlibFpSqrtOps[G] { this: SmtlibFpSqrt[G] =>
+trait SmtlibFpSqrtImpl[G] extends SmtlibFpSqrtOps[G] {
+ this: SmtlibFpSqrt[G] =>
override def t: Type[G] = arg.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFpSubImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFpSubImpl.scala
index 00962cb337..dfb5f35740 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFpSubImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFpSubImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.SmtlibFpSubOps
-trait SmtlibFpSubImpl[G] extends SmtlibFpSubOps[G] { this: SmtlibFpSub[G] =>
+trait SmtlibFpSubImpl[G] extends SmtlibFpSubOps[G] {
+ this: SmtlibFpSub[G] =>
override def t: Type[G] = left.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFpToRealImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFpToRealImpl.scala
index b7d535fd6b..d0d94f686a 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFpToRealImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFpToRealImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibFpToReal, TRational, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibFpToRealOps
-trait SmtlibFpToRealImpl[G] extends SmtlibFpToRealOps[G] { this: SmtlibFpToReal[G] =>
+trait SmtlibFpToRealImpl[G] extends SmtlibFpToRealOps[G] {
+ this: SmtlibFpToReal[G] =>
override def t: Type[G] = TRational()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFpToSIntImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFpToSIntImpl.scala
index 7deaf7009b..2663b85156 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFpToSIntImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFpToSIntImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibFpToSInt, TSmtlibBitVector, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibFpToSIntOps
-trait SmtlibFpToSIntImpl[G] extends SmtlibFpToSIntOps[G] { this: SmtlibFpToSInt[G] =>
+trait SmtlibFpToSIntImpl[G] extends SmtlibFpToSIntOps[G] {
+ this: SmtlibFpToSInt[G] =>
override def t: Type[G] = TSmtlibBitVector(bits)
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFpToUIntImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFpToUIntImpl.scala
index 8ecb67f2b5..cda47c85d2 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFpToUIntImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFpToUIntImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibFpToUInt, TSmtlibBitVector, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibFpToUIntOps
-trait SmtlibFpToUIntImpl[G] extends SmtlibFpToUIntOps[G] { this: SmtlibFpToUInt[G] =>
+trait SmtlibFpToUIntImpl[G] extends SmtlibFpToUIntOps[G] {
+ this: SmtlibFpToUInt[G] =>
override def t: Type[G] = TSmtlibBitVector(bits)
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibFunctionSymbolImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibFunctionSymbolImpl.scala
index ebba4f185b..462fe728a1 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibFunctionSymbolImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibFunctionSymbolImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.{Applicable, SmtlibFunctionSymbol}
import vct.col.ref.Ref
import vct.col.ast.ops.SmtlibFunctionSymbolFamilyOps
-trait SmtlibFunctionSymbolImpl[G] extends SmtlibFunctionSymbolFamilyOps[G] { this: SmtlibFunctionSymbol[G] =>
+trait SmtlibFunctionSymbolImpl[G] extends SmtlibFunctionSymbolFamilyOps[G] {
+ this: SmtlibFunctionSymbol[G] =>
def ref: Ref[G, _ <: Applicable[G]]
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibIsIntImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibIsIntImpl.scala
index 179c1ee50f..343f8ce562 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibIsIntImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibIsIntImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibIsInt, TBool, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibIsIntOps
-trait SmtlibIsIntImpl[G] extends SmtlibIsIntOps[G] { this: SmtlibIsInt[G] =>
+trait SmtlibIsIntImpl[G] extends SmtlibIsIntOps[G] {
+ this: SmtlibIsInt[G] =>
override def t: Type[G] = TBool()
override def layout(implicit ctx: Ctx): Doc = Text("is_int(") <> arg <> ")"
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibLiteralStringImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibLiteralStringImpl.scala
index bcbc510190..b77df1506d 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibLiteralStringImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibLiteralStringImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibLiteralString, TSmtlibString, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibLiteralStringOps
-trait SmtlibLiteralStringImpl[G] extends SmtlibLiteralStringOps[G] { this: SmtlibLiteralString[G] =>
+trait SmtlibLiteralStringImpl[G] extends SmtlibLiteralStringOps[G] {
+ this: SmtlibLiteralString[G] =>
override def t: Type[G] = TSmtlibString()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibPowImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibPowImpl.scala
index b0a12cfe76..31dad2bfb2 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibPowImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibPowImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibPow, TBool, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibPowOps
-trait SmtlibPowImpl[G] extends SmtlibPowOps[G] { this: SmtlibPow[G] =>
+trait SmtlibPowImpl[G] extends SmtlibPowOps[G] {
+ this: SmtlibPow[G] =>
override def precedence: Int = Precedence.PVL_POW
override lazy val t: Type[G] = getNumericType
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibProverFunctionSymbolImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibProverFunctionSymbolImpl.scala
index 3fd196ce58..e1e61fb5e6 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibProverFunctionSymbolImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibProverFunctionSymbolImpl.scala
@@ -4,6 +4,8 @@ import vct.col.ast.SmtlibProverFunctionSymbol
import vct.col.ast.ops.SmtlibProverFunctionSymbolOps
import vct.col.print._
-trait SmtlibProverFunctionSymbolImpl[G] extends SmtlibProverFunctionSymbolOps[G] { this: SmtlibProverFunctionSymbol[G] =>
+trait SmtlibProverFunctionSymbolImpl[G]
+ extends SmtlibProverFunctionSymbolOps[G] {
+ this: SmtlibProverFunctionSymbol[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibRNAImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibRNAImpl.scala
index 70c3f19dfb..8b1b1a4e90 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibRNAImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibRNAImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibRNA, TSmtlibRoundingMode, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibRNAOps
-trait SmtlibRNAImpl[G] extends SmtlibRNAOps[G] { this: SmtlibRNA[G] =>
+trait SmtlibRNAImpl[G] extends SmtlibRNAOps[G] {
+ this: SmtlibRNA[G] =>
override def t: Type[G] = TSmtlibRoundingMode()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibRNEImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibRNEImpl.scala
index 52ed147b23..5b2dbe432d 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibRNEImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibRNEImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibRNE, TSmtlibRoundingMode, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibRNEOps
-trait SmtlibRNEImpl[G] extends SmtlibRNEOps[G] { this: SmtlibRNE[G] =>
+trait SmtlibRNEImpl[G] extends SmtlibRNEOps[G] {
+ this: SmtlibRNE[G] =>
override def t: Type[G] = TSmtlibRoundingMode()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibRTNImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibRTNImpl.scala
index 6717f54a45..b7cd80c95d 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibRTNImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibRTNImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibRTN, TSmtlibRoundingMode, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibRTNOps
-trait SmtlibRTNImpl[G] extends SmtlibRTNOps[G] { this: SmtlibRTN[G] =>
+trait SmtlibRTNImpl[G] extends SmtlibRTNOps[G] {
+ this: SmtlibRTN[G] =>
override def t: Type[G] = TSmtlibRoundingMode()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibRTPImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibRTPImpl.scala
index 65c521b9e3..12241d2112 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibRTPImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibRTPImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibRTP, TSmtlibRoundingMode, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibRTPOps
-trait SmtlibRTPImpl[G] extends SmtlibRTPOps[G] { this: SmtlibRTP[G] =>
+trait SmtlibRTPImpl[G] extends SmtlibRTPOps[G] {
+ this: SmtlibRTP[G] =>
override def t: Type[G] = TSmtlibRoundingMode()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibRTZImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibRTZImpl.scala
index 3bedc05e7f..bffb043a56 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibRTZImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibRTZImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibRTZ, TSmtlibRoundingMode, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibRTZOps
-trait SmtlibRTZImpl[G] extends SmtlibRTZOps[G] { this: SmtlibRTZ[G] =>
+trait SmtlibRTZImpl[G] extends SmtlibRTZOps[G] {
+ this: SmtlibRTZ[G] =>
override def t: Type[G] = TSmtlibRoundingMode()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibReAllCharImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibReAllCharImpl.scala
index 308207abfc..b9ba1c99cc 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibReAllCharImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibReAllCharImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibReAllChar, TSmtlibRegLan, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibReAllCharOps
-trait SmtlibReAllCharImpl[G] extends SmtlibReAllCharOps[G] { this: SmtlibReAllChar[G] =>
+trait SmtlibReAllCharImpl[G] extends SmtlibReAllCharOps[G] {
+ this: SmtlibReAllChar[G] =>
override def t: Type[G] = TSmtlibRegLan()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibReAllImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibReAllImpl.scala
index d555050495..9926576972 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibReAllImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibReAllImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibReAll, TSmtlibRegLan, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibReAllOps
-trait SmtlibReAllImpl[G] extends SmtlibReAllOps[G] { this: SmtlibReAll[G] =>
+trait SmtlibReAllImpl[G] extends SmtlibReAllOps[G] {
+ this: SmtlibReAll[G] =>
override def t: Type[G] = TSmtlibRegLan()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibReCompImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibReCompImpl.scala
index ebd899f9fa..0486ccadef 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibReCompImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibReCompImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibReComp, TSmtlibRegLan, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibReCompOps
-trait SmtlibReCompImpl[G] extends SmtlibReCompOps[G] { this: SmtlibReComp[G] =>
+trait SmtlibReCompImpl[G] extends SmtlibReCompOps[G] {
+ this: SmtlibReComp[G] =>
override def t: Type[G] = TSmtlibRegLan()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibReConcatImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibReConcatImpl.scala
index bee281d9f9..4951ce0f7e 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibReConcatImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibReConcatImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibReConcat, TSmtlibRegLan, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibReConcatOps
-trait SmtlibReConcatImpl[G] extends SmtlibReConcatOps[G] { this: SmtlibReConcat[G] =>
+trait SmtlibReConcatImpl[G] extends SmtlibReConcatOps[G] {
+ this: SmtlibReConcat[G] =>
override def t: Type[G] = TSmtlibRegLan()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibReContainsImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibReContainsImpl.scala
index 7af8850996..cc3b03ad55 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibReContainsImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibReContainsImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibReContains, TBool, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibReContainsOps
-trait SmtlibReContainsImpl[G] extends SmtlibReContainsOps[G] { this: SmtlibReContains[G] =>
+trait SmtlibReContainsImpl[G] extends SmtlibReContainsOps[G] {
+ this: SmtlibReContains[G] =>
override def t: Type[G] = TBool()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibReDiffImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibReDiffImpl.scala
index c818ab46f3..3d229b3f5a 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibReDiffImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibReDiffImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibReDiff, TSmtlibRegLan, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibReDiffOps
-trait SmtlibReDiffImpl[G] extends SmtlibReDiffOps[G] { this: SmtlibReDiff[G] =>
+trait SmtlibReDiffImpl[G] extends SmtlibReDiffOps[G] {
+ this: SmtlibReDiff[G] =>
override def t: Type[G] = TSmtlibRegLan()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibReFromStrImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibReFromStrImpl.scala
index 6d4420998a..17921483a7 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibReFromStrImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibReFromStrImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibReFromStr, TSmtlibRegLan, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibReFromStrOps
-trait SmtlibReFromStrImpl[G] extends SmtlibReFromStrOps[G] { this: SmtlibReFromStr[G] =>
+trait SmtlibReFromStrImpl[G] extends SmtlibReFromStrOps[G] {
+ this: SmtlibReFromStr[G] =>
override def t: Type[G] = TSmtlibRegLan()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibReInterImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibReInterImpl.scala
index ab7cfb966f..526940041b 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibReInterImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibReInterImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibReInter, TSmtlibRegLan, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibReInterOps
-trait SmtlibReInterImpl[G] extends SmtlibReInterOps[G] { this: SmtlibReInter[G] =>
+trait SmtlibReInterImpl[G] extends SmtlibReInterOps[G] {
+ this: SmtlibReInter[G] =>
override def t: Type[G] = TSmtlibRegLan()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibReNoneImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibReNoneImpl.scala
index 471c7835e3..50304c1749 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibReNoneImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibReNoneImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibReNone, TSmtlibRegLan, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibReNoneOps
-trait SmtlibReNoneImpl[G] extends SmtlibReNoneOps[G] { this: SmtlibReNone[G] =>
+trait SmtlibReNoneImpl[G] extends SmtlibReNoneOps[G] {
+ this: SmtlibReNone[G] =>
override def t: Type[G] = TSmtlibRegLan()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibReOptImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibReOptImpl.scala
index f287bd4e0d..40499bf34e 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibReOptImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibReOptImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibReOpt, TSmtlibRegLan, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibReOptOps
-trait SmtlibReOptImpl[G] extends SmtlibReOptOps[G] { this: SmtlibReOpt[G] =>
+trait SmtlibReOptImpl[G] extends SmtlibReOptOps[G] {
+ this: SmtlibReOpt[G] =>
override def t: Type[G] = TSmtlibRegLan()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibRePlusImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibRePlusImpl.scala
index b60a8e8c4d..ad95f45264 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibRePlusImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibRePlusImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibRePlus, TSmtlibRegLan, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibRePlusOps
-trait SmtlibRePlusImpl[G] extends SmtlibRePlusOps[G] { this: SmtlibRePlus[G] =>
+trait SmtlibRePlusImpl[G] extends SmtlibRePlusOps[G] {
+ this: SmtlibRePlus[G] =>
override def t: Type[G] = TSmtlibRegLan()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibReRangeImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibReRangeImpl.scala
index 505442efcd..8d2d9ed3d9 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibReRangeImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibReRangeImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibReRange, TSmtlibRegLan, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibReRangeOps
-trait SmtlibReRangeImpl[G] extends SmtlibReRangeOps[G] { this: SmtlibReRange[G] =>
+trait SmtlibReRangeImpl[G] extends SmtlibReRangeOps[G] {
+ this: SmtlibReRange[G] =>
override def t: Type[G] = TSmtlibRegLan()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibReRepeatImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibReRepeatImpl.scala
index f428b5d293..886959c6c8 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibReRepeatImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibReRepeatImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibReRepeat, TSmtlibRegLan, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibReRepeatOps
-trait SmtlibReRepeatImpl[G] extends SmtlibReRepeatOps[G] { this: SmtlibReRepeat[G] =>
+trait SmtlibReRepeatImpl[G] extends SmtlibReRepeatOps[G] {
+ this: SmtlibReRepeat[G] =>
override def t: Type[G] = TSmtlibRegLan()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibReRepeatRangeImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibReRepeatRangeImpl.scala
index 9d6115a116..3c4da64e14 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibReRepeatRangeImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibReRepeatRangeImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibReRepeatRange, TSmtlibRegLan, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibReRepeatRangeOps
-trait SmtlibReRepeatRangeImpl[G] extends SmtlibReRepeatRangeOps[G] { this: SmtlibReRepeatRange[G] =>
+trait SmtlibReRepeatRangeImpl[G] extends SmtlibReRepeatRangeOps[G] {
+ this: SmtlibReRepeatRange[G] =>
override def t: Type[G] = TSmtlibRegLan()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibReStarImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibReStarImpl.scala
index 7e7d91982f..c62c2e9a42 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibReStarImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibReStarImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibReStar, TSmtlibRegLan, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibReStarOps
-trait SmtlibReStarImpl[G] extends SmtlibReStarOps[G] { this: SmtlibReStar[G] =>
+trait SmtlibReStarImpl[G] extends SmtlibReStarOps[G] {
+ this: SmtlibReStar[G] =>
override def t: Type[G] = TSmtlibRegLan()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibReUnionImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibReUnionImpl.scala
index ff5974508f..a9c7f3820e 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibReUnionImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibReUnionImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibReUnion, TSmtlibRegLan, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibReUnionOps
-trait SmtlibReUnionImpl[G] extends SmtlibReUnionOps[G] { this: SmtlibReUnion[G] =>
+trait SmtlibReUnionImpl[G] extends SmtlibReUnionOps[G] {
+ this: SmtlibReUnion[G] =>
override def t: Type[G] = TSmtlibRegLan()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibSelectImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibSelectImpl.scala
index 83b50cd51a..75f0fceab0 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibSelectImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibSelectImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.SmtlibSelectOps
-trait SmtlibSelectImpl[G] extends SmtlibSelectOps[G] { this: SmtlibSelect[G] =>
+trait SmtlibSelectImpl[G] extends SmtlibSelectOps[G] {
+ this: SmtlibSelect[G] =>
override def t: Type[G] = arr.t.asSmtlibArray.get.value
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibStoreImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibStoreImpl.scala
index 8f54a35802..44c0800503 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibStoreImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibStoreImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.SmtlibStoreOps
-trait SmtlibStoreImpl[G] extends SmtlibStoreOps[G] { this: SmtlibStore[G] =>
+trait SmtlibStoreImpl[G] extends SmtlibStoreOps[G] {
+ this: SmtlibStore[G] =>
override def t: Type[G] = arr.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibStrAtImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibStrAtImpl.scala
index f1991db2b5..f7514a40d8 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibStrAtImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibStrAtImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibStrAt, TSmtlibString, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibStrAtOps
-trait SmtlibStrAtImpl[G] extends SmtlibStrAtOps[G] { this: SmtlibStrAt[G] =>
+trait SmtlibStrAtImpl[G] extends SmtlibStrAtOps[G] {
+ this: SmtlibStrAt[G] =>
override def t: Type[G] = TSmtlibString()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibStrConcatImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibStrConcatImpl.scala
index a04bc82e6d..b270ad8091 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibStrConcatImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibStrConcatImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibStrConcat, TSmtlibString, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibStrConcatOps
-trait SmtlibStrConcatImpl[G] extends SmtlibStrConcatOps[G] { this: SmtlibStrConcat[G] =>
+trait SmtlibStrConcatImpl[G] extends SmtlibStrConcatOps[G] {
+ this: SmtlibStrConcat[G] =>
override def t: Type[G] = TSmtlibString()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibStrContainsImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibStrContainsImpl.scala
index b3d19c0551..224c6f3feb 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibStrContainsImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibStrContainsImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibStrContains, TBool, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibStrContainsOps
-trait SmtlibStrContainsImpl[G] extends SmtlibStrContainsOps[G] { this: SmtlibStrContains[G] =>
+trait SmtlibStrContainsImpl[G] extends SmtlibStrContainsOps[G] {
+ this: SmtlibStrContains[G] =>
override def t: Type[G] = TBool()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibStrFromCodeImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibStrFromCodeImpl.scala
index e553b3b079..50002eef64 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibStrFromCodeImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibStrFromCodeImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibStrFromCode, TSmtlibString, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibStrFromCodeOps
-trait SmtlibStrFromCodeImpl[G] extends SmtlibStrFromCodeOps[G] { this: SmtlibStrFromCode[G] =>
+trait SmtlibStrFromCodeImpl[G] extends SmtlibStrFromCodeOps[G] {
+ this: SmtlibStrFromCode[G] =>
override def t: Type[G] = TSmtlibString()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibStrFromIntImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibStrFromIntImpl.scala
index 5bbf87df7a..10dae3f1a3 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibStrFromIntImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibStrFromIntImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibStrFromInt, TSmtlibString, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibStrFromIntOps
-trait SmtlibStrFromIntImpl[G] extends SmtlibStrFromIntOps[G] { this: SmtlibStrFromInt[G] =>
+trait SmtlibStrFromIntImpl[G] extends SmtlibStrFromIntOps[G] {
+ this: SmtlibStrFromInt[G] =>
override def t: Type[G] = TSmtlibString()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibStrIndexOfImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibStrIndexOfImpl.scala
index 4d15aa26d1..a4eabc5594 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibStrIndexOfImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibStrIndexOfImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibStrIndexOf, TInt, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibStrIndexOfOps
-trait SmtlibStrIndexOfImpl[G] extends SmtlibStrIndexOfOps[G] { this: SmtlibStrIndexOf[G] =>
+trait SmtlibStrIndexOfImpl[G] extends SmtlibStrIndexOfOps[G] {
+ this: SmtlibStrIndexOf[G] =>
override def t: Type[G] = TInt()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibStrIsDigitImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibStrIsDigitImpl.scala
index daedf8b97e..1a21d22335 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibStrIsDigitImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibStrIsDigitImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibStrIsDigit, TBool, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibStrIsDigitOps
-trait SmtlibStrIsDigitImpl[G] extends SmtlibStrIsDigitOps[G] { this: SmtlibStrIsDigit[G] =>
+trait SmtlibStrIsDigitImpl[G] extends SmtlibStrIsDigitOps[G] {
+ this: SmtlibStrIsDigit[G] =>
override def t: Type[G] = TBool()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibStrLenImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibStrLenImpl.scala
index 968acc565d..e43a1c6bc0 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibStrLenImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibStrLenImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibStrLen, TInt, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibStrLenOps
-trait SmtlibStrLenImpl[G] extends SmtlibStrLenOps[G] { this: SmtlibStrLen[G] =>
+trait SmtlibStrLenImpl[G] extends SmtlibStrLenOps[G] {
+ this: SmtlibStrLen[G] =>
override def t: Type[G] = TInt()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibStrLeqImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibStrLeqImpl.scala
index e15b532f2e..3dd00f0804 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibStrLeqImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibStrLeqImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibStrLeq, TBool, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibStrLeqOps
-trait SmtlibStrLeqImpl[G] extends SmtlibStrLeqOps[G] { this: SmtlibStrLeq[G] =>
+trait SmtlibStrLeqImpl[G] extends SmtlibStrLeqOps[G] {
+ this: SmtlibStrLeq[G] =>
override def t: Type[G] = TBool()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibStrLtImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibStrLtImpl.scala
index 3de93a5e65..566067c062 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibStrLtImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibStrLtImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibStrLt, TBool, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibStrLtOps
-trait SmtlibStrLtImpl[G] extends SmtlibStrLtOps[G] { this: SmtlibStrLt[G] =>
+trait SmtlibStrLtImpl[G] extends SmtlibStrLtOps[G] {
+ this: SmtlibStrLt[G] =>
override def t: Type[G] = TBool()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibStrPrefixOfImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibStrPrefixOfImpl.scala
index bd4ed657fa..bcbf54e9f2 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibStrPrefixOfImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibStrPrefixOfImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibStrPrefixOf, TBool, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibStrPrefixOfOps
-trait SmtlibStrPrefixOfImpl[G] extends SmtlibStrPrefixOfOps[G] { this: SmtlibStrPrefixOf[G] =>
+trait SmtlibStrPrefixOfImpl[G] extends SmtlibStrPrefixOfOps[G] {
+ this: SmtlibStrPrefixOf[G] =>
override def t: Type[G] = TBool()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibStrReplaceAllImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibStrReplaceAllImpl.scala
index 7f0a9225a0..bbae08ff06 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibStrReplaceAllImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibStrReplaceAllImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibStrReplaceAll, TSmtlibString, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibStrReplaceAllOps
-trait SmtlibStrReplaceAllImpl[G] extends SmtlibStrReplaceAllOps[G] { this: SmtlibStrReplaceAll[G] =>
+trait SmtlibStrReplaceAllImpl[G] extends SmtlibStrReplaceAllOps[G] {
+ this: SmtlibStrReplaceAll[G] =>
override def t: Type[G] = TSmtlibString()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibStrReplaceImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibStrReplaceImpl.scala
index fddf02307f..d87923ea09 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibStrReplaceImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibStrReplaceImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibStrReplace, TSmtlibString, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibStrReplaceOps
-trait SmtlibStrReplaceImpl[G] extends SmtlibStrReplaceOps[G] { this: SmtlibStrReplace[G] =>
+trait SmtlibStrReplaceImpl[G] extends SmtlibStrReplaceOps[G] {
+ this: SmtlibStrReplace[G] =>
override def t: Type[G] = TSmtlibString()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibStrReplaceReAllImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibStrReplaceReAllImpl.scala
index 8eb2a32489..59c5aa23fc 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibStrReplaceReAllImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibStrReplaceReAllImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibStrReplaceReAll, TSmtlibString, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibStrReplaceReAllOps
-trait SmtlibStrReplaceReAllImpl[G] extends SmtlibStrReplaceReAllOps[G] { this: SmtlibStrReplaceReAll[G] =>
+trait SmtlibStrReplaceReAllImpl[G] extends SmtlibStrReplaceReAllOps[G] {
+ this: SmtlibStrReplaceReAll[G] =>
override def t: Type[G] = TSmtlibString()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibStrReplaceReImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibStrReplaceReImpl.scala
index 0bf6f4bef4..38425fa292 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibStrReplaceReImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibStrReplaceReImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibStrReplaceRe, TSmtlibString, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibStrReplaceReOps
-trait SmtlibStrReplaceReImpl[G] extends SmtlibStrReplaceReOps[G] { this: SmtlibStrReplaceRe[G] =>
+trait SmtlibStrReplaceReImpl[G] extends SmtlibStrReplaceReOps[G] {
+ this: SmtlibStrReplaceRe[G] =>
override def t: Type[G] = TSmtlibString()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibStrSuffixOfImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibStrSuffixOfImpl.scala
index 53a6dfde16..7fbe3772d8 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibStrSuffixOfImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibStrSuffixOfImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibStrSuffixOf, TBool, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibStrSuffixOfOps
-trait SmtlibStrSuffixOfImpl[G] extends SmtlibStrSuffixOfOps[G] { this: SmtlibStrSuffixOf[G] =>
+trait SmtlibStrSuffixOfImpl[G] extends SmtlibStrSuffixOfOps[G] {
+ this: SmtlibStrSuffixOf[G] =>
override def t: Type[G] = TBool()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibStrToCodeImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibStrToCodeImpl.scala
index 80d11a6441..8dac30d758 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibStrToCodeImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibStrToCodeImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibStrToCode, TInt, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibStrToCodeOps
-trait SmtlibStrToCodeImpl[G] extends SmtlibStrToCodeOps[G] { this: SmtlibStrToCode[G] =>
+trait SmtlibStrToCodeImpl[G] extends SmtlibStrToCodeOps[G] {
+ this: SmtlibStrToCode[G] =>
override def t: Type[G] = TInt()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibStrToIntImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibStrToIntImpl.scala
index 12dbb69267..ccf9266af4 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibStrToIntImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibStrToIntImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.{Type, TInt}
import vct.col.print._
import vct.col.ast.ops.SmtlibStrToIntOps
-trait SmtlibStrToIntImpl[G] extends SmtlibStrToIntOps[G] { this: SmtlibStrToInt[G] =>
+trait SmtlibStrToIntImpl[G] extends SmtlibStrToIntOps[G] {
+ this: SmtlibStrToInt[G] =>
override def t: Type[G] = TInt()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibSubstrImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibSubstrImpl.scala
index bb5eaf1d75..f36cea7d13 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibSubstrImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibSubstrImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibSubstr, TSmtlibString, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibSubstrOps
-trait SmtlibSubstrImpl[G] extends SmtlibSubstrOps[G] { this: SmtlibSubstr[G] =>
+trait SmtlibSubstrImpl[G] extends SmtlibSubstrOps[G] {
+ this: SmtlibSubstr[G] =>
override def t: Type[G] = TSmtlibString()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibToFpImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibToFpImpl.scala
index 111e763c8d..3947fa2284 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibToFpImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibToFpImpl.scala
@@ -4,7 +4,9 @@ import vct.col.ast.{SmtlibToFp, TSmtlibFloatingPoint, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibToFpOps
-trait SmtlibToFpImpl[G] extends SmtlibToFpOps[G] { this: SmtlibToFp[G] =>
- override def t: Type[G] = TSmtlibFloatingPoint(exponentBits, mantissaAndSignBits)
+trait SmtlibToFpImpl[G] extends SmtlibToFpOps[G] {
+ this: SmtlibToFp[G] =>
+ override def t: Type[G] =
+ TSmtlibFloatingPoint(exponentBits, mantissaAndSignBits)
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibToIntImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibToIntImpl.scala
index bf99a541cb..f18ed68b52 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibToIntImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibToIntImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibToInt, TInt, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibToIntOps
-trait SmtlibToIntImpl[G] extends SmtlibToIntOps[G] { this: SmtlibToInt[G] =>
+trait SmtlibToIntImpl[G] extends SmtlibToIntOps[G] {
+ this: SmtlibToInt[G] =>
override def t: Type[G] = TInt()
override def layout(implicit ctx: Ctx): Doc = Text("to_int(") <> arg <> ")"
}
diff --git a/src/col/vct/col/ast/lang/smt/SmtlibToRealImpl.scala b/src/col/vct/col/ast/lang/smt/SmtlibToRealImpl.scala
index 8e02765b95..f8aafb590b 100644
--- a/src/col/vct/col/ast/lang/smt/SmtlibToRealImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/SmtlibToRealImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{SmtlibToReal, TRational, Type}
import vct.col.print._
import vct.col.ast.ops.SmtlibToRealOps
-trait SmtlibToRealImpl[G] extends SmtlibToRealOps[G] { this: SmtlibToReal[G] =>
+trait SmtlibToRealImpl[G] extends SmtlibToRealOps[G] {
+ this: SmtlibToReal[G] =>
override def t: Type[G] = TRational()
override def layout(implicit ctx: Ctx): Doc = Text("to_real(") <> arg <> ")"
}
diff --git a/src/col/vct/col/ast/lang/smt/TSmtlibArrayImpl.scala b/src/col/vct/col/ast/lang/smt/TSmtlibArrayImpl.scala
index 33ac7a3f18..f8dbec2cda 100644
--- a/src/col/vct/col/ast/lang/smt/TSmtlibArrayImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/TSmtlibArrayImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.TSmtlibArray
import vct.col.ast.ops.TSmtlibArrayOps
import vct.col.print._
-trait TSmtlibArrayImpl[G] extends TSmtlibArrayOps[G] { this: TSmtlibArray[G] =>
+trait TSmtlibArrayImpl[G] extends TSmtlibArrayOps[G] {
+ this: TSmtlibArray[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/TSmtlibBitVectorImpl.scala b/src/col/vct/col/ast/lang/smt/TSmtlibBitVectorImpl.scala
index 9fafadef78..4fc8c45292 100644
--- a/src/col/vct/col/ast/lang/smt/TSmtlibBitVectorImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/TSmtlibBitVectorImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.TSmtlibBitVector
import vct.col.ast.ops.TSmtlibBitVectorOps
import vct.col.print._
-trait TSmtlibBitVectorImpl[G] extends TSmtlibBitVectorOps[G] { this: TSmtlibBitVector[G] =>
+trait TSmtlibBitVectorImpl[G] extends TSmtlibBitVectorOps[G] {
+ this: TSmtlibBitVector[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/TSmtlibFloatingPointImpl.scala b/src/col/vct/col/ast/lang/smt/TSmtlibFloatingPointImpl.scala
index 35b8158d9d..5f4e4e9ac0 100644
--- a/src/col/vct/col/ast/lang/smt/TSmtlibFloatingPointImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/TSmtlibFloatingPointImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.TSmtlibFloatingPoint
import vct.col.ast.ops.TSmtlibFloatingPointOps
import vct.col.print._
-trait TSmtlibFloatingPointImpl[G] extends TSmtlibFloatingPointOps[G] { this: TSmtlibFloatingPoint[G] =>
+trait TSmtlibFloatingPointImpl[G] extends TSmtlibFloatingPointOps[G] {
+ this: TSmtlibFloatingPoint[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/TSmtlibRegLanImpl.scala b/src/col/vct/col/ast/lang/smt/TSmtlibRegLanImpl.scala
index c2c3de3e7b..4c68ee9b48 100644
--- a/src/col/vct/col/ast/lang/smt/TSmtlibRegLanImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/TSmtlibRegLanImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.TSmtlibRegLan
import vct.col.ast.ops.TSmtlibRegLanOps
import vct.col.print._
-trait TSmtlibRegLanImpl[G] extends TSmtlibRegLanOps[G] { this: TSmtlibRegLan[G] =>
+trait TSmtlibRegLanImpl[G] extends TSmtlibRegLanOps[G] {
+ this: TSmtlibRegLan[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/TSmtlibRoundingModeImpl.scala b/src/col/vct/col/ast/lang/smt/TSmtlibRoundingModeImpl.scala
index 5051b74c8c..3bf54350a1 100644
--- a/src/col/vct/col/ast/lang/smt/TSmtlibRoundingModeImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/TSmtlibRoundingModeImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.TSmtlibRoundingMode
import vct.col.ast.ops.TSmtlibRoundingModeOps
import vct.col.print._
-trait TSmtlibRoundingModeImpl[G] extends TSmtlibRoundingModeOps[G] { this: TSmtlibRoundingMode[G] =>
+trait TSmtlibRoundingModeImpl[G] extends TSmtlibRoundingModeOps[G] {
+ this: TSmtlibRoundingMode[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/TSmtlibSeqImpl.scala b/src/col/vct/col/ast/lang/smt/TSmtlibSeqImpl.scala
index faac536c46..4be7e7cea4 100644
--- a/src/col/vct/col/ast/lang/smt/TSmtlibSeqImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/TSmtlibSeqImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.TSmtlibSeq
import vct.col.ast.ops.TSmtlibSeqOps
import vct.col.print._
-trait TSmtlibSeqImpl[G] extends TSmtlibSeqOps[G] { this: TSmtlibSeq[G] =>
+trait TSmtlibSeqImpl[G] extends TSmtlibSeqOps[G] {
+ this: TSmtlibSeq[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/TSmtlibStringImpl.scala b/src/col/vct/col/ast/lang/smt/TSmtlibStringImpl.scala
index 36645dc1f3..e868566b60 100644
--- a/src/col/vct/col/ast/lang/smt/TSmtlibStringImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/TSmtlibStringImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.TSmtlibString
import vct.col.ast.ops.TSmtlibStringOps
import vct.col.print._
-trait TSmtlibStringImpl[G] extends TSmtlibStringOps[G] { this: TSmtlibString[G] =>
+trait TSmtlibStringImpl[G] extends TSmtlibStringOps[G] {
+ this: TSmtlibString[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/Z3ArrayConstImpl.scala b/src/col/vct/col/ast/lang/smt/Z3ArrayConstImpl.scala
index c0fb668076..bd9e54a46b 100644
--- a/src/col/vct/col/ast/lang/smt/Z3ArrayConstImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/Z3ArrayConstImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{TSmtlibArray, Type, Z3ArrayConst}
import vct.col.print._
import vct.col.ast.ops.Z3ArrayConstOps
-trait Z3ArrayConstImpl[G] extends Z3ArrayConstOps[G] { this: Z3ArrayConst[G] =>
+trait Z3ArrayConstImpl[G] extends Z3ArrayConstOps[G] {
+ this: Z3ArrayConst[G] =>
override def t: Type[G] = TSmtlibArray(domain, codomain)
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/Z3ArrayMapImpl.scala b/src/col/vct/col/ast/lang/smt/Z3ArrayMapImpl.scala
index 4624312a8f..e90f037aa5 100644
--- a/src/col/vct/col/ast/lang/smt/Z3ArrayMapImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/Z3ArrayMapImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.Z3ArrayMapOps
-trait Z3ArrayMapImpl[G] extends Z3ArrayMapOps[G] { this: Z3ArrayMap[G] =>
+trait Z3ArrayMapImpl[G] extends Z3ArrayMapOps[G] {
+ this: Z3ArrayMap[G] =>
override def t: Type[G] = ref.ref.decl.returnType
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/Z3ArrayOfFunctionImpl.scala b/src/col/vct/col/ast/lang/smt/Z3ArrayOfFunctionImpl.scala
index 9a256f4835..ee6e56e64f 100644
--- a/src/col/vct/col/ast/lang/smt/Z3ArrayOfFunctionImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/Z3ArrayOfFunctionImpl.scala
@@ -4,7 +4,11 @@ import vct.col.ast.{TSmtlibArray, Type, Z3ArrayOfFunction}
import vct.col.print._
import vct.col.ast.ops.Z3ArrayOfFunctionOps
-trait Z3ArrayOfFunctionImpl[G] extends Z3ArrayOfFunctionOps[G] { this: Z3ArrayOfFunction[G] =>
- override lazy val t: Type[G] = TSmtlibArray(ref.ref.decl.args.map(_.t), ref.ref.decl.returnType)
+trait Z3ArrayOfFunctionImpl[G] extends Z3ArrayOfFunctionOps[G] {
+ this: Z3ArrayOfFunction[G] =>
+ override lazy val t: Type[G] = TSmtlibArray(
+ ref.ref.decl.args.map(_.t),
+ ref.ref.decl.returnType,
+ )
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/Z3BvNandImpl.scala b/src/col/vct/col/ast/lang/smt/Z3BvNandImpl.scala
index 6e62806c44..c622f3c35f 100644
--- a/src/col/vct/col/ast/lang/smt/Z3BvNandImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/Z3BvNandImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.Z3BvNandOps
-trait Z3BvNandImpl[G] extends Z3BvNandOps[G] { this: Z3BvNand[G] =>
+trait Z3BvNandImpl[G] extends Z3BvNandOps[G] {
+ this: Z3BvNand[G] =>
override def t: Type[G] = left.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/Z3BvNorImpl.scala b/src/col/vct/col/ast/lang/smt/Z3BvNorImpl.scala
index 511f522c41..bc7cf660bb 100644
--- a/src/col/vct/col/ast/lang/smt/Z3BvNorImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/Z3BvNorImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.Z3BvNorOps
-trait Z3BvNorImpl[G] extends Z3BvNorOps[G] { this: Z3BvNor[G] =>
+trait Z3BvNorImpl[G] extends Z3BvNorOps[G] {
+ this: Z3BvNor[G] =>
override def t: Type[G] = left.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/Z3BvSModImpl.scala b/src/col/vct/col/ast/lang/smt/Z3BvSModImpl.scala
index 22b54b5633..60b27dc0a4 100644
--- a/src/col/vct/col/ast/lang/smt/Z3BvSModImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/Z3BvSModImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.Z3BvSModOps
-trait Z3BvSModImpl[G] extends Z3BvSModOps[G] { this: Z3BvSMod[G] =>
+trait Z3BvSModImpl[G] extends Z3BvSModOps[G] {
+ this: Z3BvSMod[G] =>
override def t: Type[G] = left.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/Z3BvSRemImpl.scala b/src/col/vct/col/ast/lang/smt/Z3BvSRemImpl.scala
index 79dbb81cd0..ba0453830f 100644
--- a/src/col/vct/col/ast/lang/smt/Z3BvSRemImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/Z3BvSRemImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.Z3BvSRemOps
-trait Z3BvSRemImpl[G] extends Z3BvSRemOps[G] { this: Z3BvSRem[G] =>
+trait Z3BvSRemImpl[G] extends Z3BvSRemOps[G] {
+ this: Z3BvSRem[G] =>
override def t: Type[G] = left.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/Z3BvSShrImpl.scala b/src/col/vct/col/ast/lang/smt/Z3BvSShrImpl.scala
index 36467ca26d..04210e2563 100644
--- a/src/col/vct/col/ast/lang/smt/Z3BvSShrImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/Z3BvSShrImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.Z3BvSShrOps
-trait Z3BvSShrImpl[G] extends Z3BvSShrOps[G] { this: Z3BvSShr[G] =>
+trait Z3BvSShrImpl[G] extends Z3BvSShrOps[G] {
+ this: Z3BvSShr[G] =>
override def t: Type[G] = left.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/Z3BvSubImpl.scala b/src/col/vct/col/ast/lang/smt/Z3BvSubImpl.scala
index 5daf591568..8349e9365c 100644
--- a/src/col/vct/col/ast/lang/smt/Z3BvSubImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/Z3BvSubImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.Z3BvSubOps
-trait Z3BvSubImpl[G] extends Z3BvSubOps[G] { this: Z3BvSub[G] =>
+trait Z3BvSubImpl[G] extends Z3BvSubOps[G] {
+ this: Z3BvSub[G] =>
override def t: Type[G] = left.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/Z3BvXnorImpl.scala b/src/col/vct/col/ast/lang/smt/Z3BvXnorImpl.scala
index 384131c379..72142cda0c 100644
--- a/src/col/vct/col/ast/lang/smt/Z3BvXnorImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/Z3BvXnorImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.Z3BvXnorOps
-trait Z3BvXnorImpl[G] extends Z3BvXnorOps[G] { this: Z3BvXnor[G] =>
+trait Z3BvXnorImpl[G] extends Z3BvXnorOps[G] {
+ this: Z3BvXnor[G] =>
override def t: Type[G] = left.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/Z3SeqAtImpl.scala b/src/col/vct/col/ast/lang/smt/Z3SeqAtImpl.scala
index b252bd8e72..4fe35604f5 100644
--- a/src/col/vct/col/ast/lang/smt/Z3SeqAtImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/Z3SeqAtImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.Z3SeqAtOps
-trait Z3SeqAtImpl[G] extends Z3SeqAtOps[G] { this: Z3SeqAt[G] =>
+trait Z3SeqAtImpl[G] extends Z3SeqAtOps[G] {
+ this: Z3SeqAt[G] =>
override def t: Type[G] = seq.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/Z3SeqConcatImpl.scala b/src/col/vct/col/ast/lang/smt/Z3SeqConcatImpl.scala
index 87f123bc41..c0322511a3 100644
--- a/src/col/vct/col/ast/lang/smt/Z3SeqConcatImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/Z3SeqConcatImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.Z3SeqConcatOps
-trait Z3SeqConcatImpl[G] extends Z3SeqConcatOps[G] { this: Z3SeqConcat[G] =>
+trait Z3SeqConcatImpl[G] extends Z3SeqConcatOps[G] {
+ this: Z3SeqConcat[G] =>
override def t: Type[G] = left.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/Z3SeqContainsImpl.scala b/src/col/vct/col/ast/lang/smt/Z3SeqContainsImpl.scala
index 9c36c4e87d..3a545ee06e 100644
--- a/src/col/vct/col/ast/lang/smt/Z3SeqContainsImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/Z3SeqContainsImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{TBool, Type, Z3SeqContains}
import vct.col.print._
import vct.col.ast.ops.Z3SeqContainsOps
-trait Z3SeqContainsImpl[G] extends Z3SeqContainsOps[G] { this: Z3SeqContains[G] =>
+trait Z3SeqContainsImpl[G] extends Z3SeqContainsOps[G] {
+ this: Z3SeqContains[G] =>
override def t: Type[G] = TBool()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/Z3SeqEmptyImpl.scala b/src/col/vct/col/ast/lang/smt/Z3SeqEmptyImpl.scala
index 30ef9b6ef1..cc4f84476a 100644
--- a/src/col/vct/col/ast/lang/smt/Z3SeqEmptyImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/Z3SeqEmptyImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{TSmtlibSeq, Type, Z3SeqEmpty}
import vct.col.print._
import vct.col.ast.ops.Z3SeqEmptyOps
-trait Z3SeqEmptyImpl[G] extends Z3SeqEmptyOps[G] { this: Z3SeqEmpty[G] =>
+trait Z3SeqEmptyImpl[G] extends Z3SeqEmptyOps[G] {
+ this: Z3SeqEmpty[G] =>
override def t: Type[G] = TSmtlibSeq(elementType)
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/Z3SeqExtractImpl.scala b/src/col/vct/col/ast/lang/smt/Z3SeqExtractImpl.scala
index 85e8e41ed8..ef5563c3a0 100644
--- a/src/col/vct/col/ast/lang/smt/Z3SeqExtractImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/Z3SeqExtractImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.Z3SeqExtractOps
-trait Z3SeqExtractImpl[G] extends Z3SeqExtractOps[G] { this: Z3SeqExtract[G] =>
+trait Z3SeqExtractImpl[G] extends Z3SeqExtractOps[G] {
+ this: Z3SeqExtract[G] =>
override def t: Type[G] = seq.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/Z3SeqFoldlIImpl.scala b/src/col/vct/col/ast/lang/smt/Z3SeqFoldlIImpl.scala
index 27661e959b..84457e5c7a 100644
--- a/src/col/vct/col/ast/lang/smt/Z3SeqFoldlIImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/Z3SeqFoldlIImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.Z3SeqFoldlIOps
-trait Z3SeqFoldlIImpl[G] extends Z3SeqFoldlIOps[G] { this: Z3SeqFoldlI[G] =>
+trait Z3SeqFoldlIImpl[G] extends Z3SeqFoldlIOps[G] {
+ this: Z3SeqFoldlI[G] =>
override def t: Type[G] = seq.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/Z3SeqFoldlImpl.scala b/src/col/vct/col/ast/lang/smt/Z3SeqFoldlImpl.scala
index e0a63a1b77..5cb5eb5d74 100644
--- a/src/col/vct/col/ast/lang/smt/Z3SeqFoldlImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/Z3SeqFoldlImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.Z3SeqFoldlOps
-trait Z3SeqFoldlImpl[G] extends Z3SeqFoldlOps[G] { this: Z3SeqFoldl[G] =>
+trait Z3SeqFoldlImpl[G] extends Z3SeqFoldlOps[G] {
+ this: Z3SeqFoldl[G] =>
override def t: Type[G] = seq.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/Z3SeqLenImpl.scala b/src/col/vct/col/ast/lang/smt/Z3SeqLenImpl.scala
index 4e670b6304..adfdbf2241 100644
--- a/src/col/vct/col/ast/lang/smt/Z3SeqLenImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/Z3SeqLenImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{TInt, Type, Z3SeqLen}
import vct.col.print._
import vct.col.ast.ops.Z3SeqLenOps
-trait Z3SeqLenImpl[G] extends Z3SeqLenOps[G] { this: Z3SeqLen[G] =>
+trait Z3SeqLenImpl[G] extends Z3SeqLenOps[G] {
+ this: Z3SeqLen[G] =>
override def t: Type[G] = TInt()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/Z3SeqMapIImpl.scala b/src/col/vct/col/ast/lang/smt/Z3SeqMapIImpl.scala
index eb1cd0c5e0..5d48bf25a0 100644
--- a/src/col/vct/col/ast/lang/smt/Z3SeqMapIImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/Z3SeqMapIImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{TSmtlibSeq, Type, Z3SeqMapI}
import vct.col.print._
import vct.col.ast.ops.Z3SeqMapIOps
-trait Z3SeqMapIImpl[G] extends Z3SeqMapIOps[G] { this: Z3SeqMapI[G] =>
+trait Z3SeqMapIImpl[G] extends Z3SeqMapIOps[G] {
+ this: Z3SeqMapI[G] =>
override lazy val t: Type[G] = TSmtlibSeq(f.t.asSmtlibArray.get.value)
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/Z3SeqMapImpl.scala b/src/col/vct/col/ast/lang/smt/Z3SeqMapImpl.scala
index 4274da73d8..e9877258bb 100644
--- a/src/col/vct/col/ast/lang/smt/Z3SeqMapImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/Z3SeqMapImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{TSmtlibSeq, Type, Z3SeqMap}
import vct.col.print._
import vct.col.ast.ops.Z3SeqMapOps
-trait Z3SeqMapImpl[G] extends Z3SeqMapOps[G] { this: Z3SeqMap[G] =>
+trait Z3SeqMapImpl[G] extends Z3SeqMapOps[G] {
+ this: Z3SeqMap[G] =>
override def t: Type[G] = TSmtlibSeq(f.t.asSmtlibArray.get.value)
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/Z3SeqNthImpl.scala b/src/col/vct/col/ast/lang/smt/Z3SeqNthImpl.scala
index e478089613..36182f47dd 100644
--- a/src/col/vct/col/ast/lang/smt/Z3SeqNthImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/Z3SeqNthImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.Z3SeqNthOps
-trait Z3SeqNthImpl[G] extends Z3SeqNthOps[G] { this: Z3SeqNth[G] =>
+trait Z3SeqNthImpl[G] extends Z3SeqNthOps[G] {
+ this: Z3SeqNth[G] =>
override def t: Type[G] = seq.t.asSmtlibSeq.get.element
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/Z3SeqPrefixOfImpl.scala b/src/col/vct/col/ast/lang/smt/Z3SeqPrefixOfImpl.scala
index 55b2b0dfbb..a518aca7a3 100644
--- a/src/col/vct/col/ast/lang/smt/Z3SeqPrefixOfImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/Z3SeqPrefixOfImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{TBool, Type, Z3SeqPrefixOf}
import vct.col.print._
import vct.col.ast.ops.Z3SeqPrefixOfOps
-trait Z3SeqPrefixOfImpl[G] extends Z3SeqPrefixOfOps[G] { this: Z3SeqPrefixOf[G] =>
+trait Z3SeqPrefixOfImpl[G] extends Z3SeqPrefixOfOps[G] {
+ this: Z3SeqPrefixOf[G] =>
override def t: Type[G] = TBool()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/Z3SeqReplaceImpl.scala b/src/col/vct/col/ast/lang/smt/Z3SeqReplaceImpl.scala
index bc784052a1..319705a9be 100644
--- a/src/col/vct/col/ast/lang/smt/Z3SeqReplaceImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/Z3SeqReplaceImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.Type
import vct.col.print._
import vct.col.ast.ops.Z3SeqReplaceOps
-trait Z3SeqReplaceImpl[G] extends Z3SeqReplaceOps[G] { this: Z3SeqReplace[G] =>
+trait Z3SeqReplaceImpl[G] extends Z3SeqReplaceOps[G] {
+ this: Z3SeqReplace[G] =>
override def t: Type[G] = haystack.t
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/Z3SeqSuffixOfImpl.scala b/src/col/vct/col/ast/lang/smt/Z3SeqSuffixOfImpl.scala
index c5816d50a7..478e0839c9 100644
--- a/src/col/vct/col/ast/lang/smt/Z3SeqSuffixOfImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/Z3SeqSuffixOfImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{TBool, Type, Z3SeqSuffixOf}
import vct.col.print._
import vct.col.ast.ops.Z3SeqSuffixOfOps
-trait Z3SeqSuffixOfImpl[G] extends Z3SeqSuffixOfOps[G] { this: Z3SeqSuffixOf[G] =>
+trait Z3SeqSuffixOfImpl[G] extends Z3SeqSuffixOfOps[G] {
+ this: Z3SeqSuffixOf[G] =>
override def t: Type[G] = TBool()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/Z3SeqUnitImpl.scala b/src/col/vct/col/ast/lang/smt/Z3SeqUnitImpl.scala
index dc9728dc2b..65960fa57e 100644
--- a/src/col/vct/col/ast/lang/smt/Z3SeqUnitImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/Z3SeqUnitImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{TSmtlibSeq, Type, Z3SeqUnit}
import vct.col.print._
import vct.col.ast.ops.Z3SeqUnitOps
-trait Z3SeqUnitImpl[G] extends Z3SeqUnitOps[G] { this: Z3SeqUnit[G] =>
+trait Z3SeqUnitImpl[G] extends Z3SeqUnitOps[G] {
+ this: Z3SeqUnit[G] =>
override def t: Type[G] = TSmtlibSeq(arg.t)
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/smt/Z3TransitiveClosureImpl.scala b/src/col/vct/col/ast/lang/smt/Z3TransitiveClosureImpl.scala
index 8c44ff71c8..ec06560196 100644
--- a/src/col/vct/col/ast/lang/smt/Z3TransitiveClosureImpl.scala
+++ b/src/col/vct/col/ast/lang/smt/Z3TransitiveClosureImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{TBool, Type, Z3TransitiveClosure}
import vct.col.print._
import vct.col.ast.ops.Z3TransitiveClosureOps
-trait Z3TransitiveClosureImpl[G] extends Z3TransitiveClosureOps[G] { this: Z3TransitiveClosure[G] =>
+trait Z3TransitiveClosureImpl[G] extends Z3TransitiveClosureOps[G] {
+ this: Z3TransitiveClosure[G] =>
override def t: Type[G] = TBool()
// def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/lang/sycl/SYCLAccessModeImpl.scala b/src/col/vct/col/ast/lang/sycl/SYCLAccessModeImpl.scala
index 60deaab288..3243d56bb0 100644
--- a/src/col/vct/col/ast/lang/sycl/SYCLAccessModeImpl.scala
+++ b/src/col/vct/col/ast/lang/sycl/SYCLAccessModeImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.lang.sycl
import vct.col.ast.SYCLAccessMode
-trait SYCLAccessModeImpl[G] { this: SYCLAccessMode[G] =>
+trait SYCLAccessModeImpl[G] {
+ this: SYCLAccessMode[G] =>
val name: String
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/sycl/SYCLClassDefNameImpl.scala b/src/col/vct/col/ast/lang/sycl/SYCLClassDefNameImpl.scala
index a4c8e64135..106b82a655 100644
--- a/src/col/vct/col/ast/lang/sycl/SYCLClassDefNameImpl.scala
+++ b/src/col/vct/col/ast/lang/sycl/SYCLClassDefNameImpl.scala
@@ -4,8 +4,14 @@ import vct.col.ast.SYCLClassDefName
import vct.col.print.{Ctx, Doc, Group, Text}
import vct.col.ast.ops.SYCLClassDefNameOps
-trait SYCLClassDefNameImpl[G] extends SYCLClassDefNameOps[G] { this: SYCLClassDefName[G] =>
+trait SYCLClassDefNameImpl[G] extends SYCLClassDefNameOps[G] {
+ this: SYCLClassDefName[G] =>
override def layout(implicit ctx: Ctx): Doc =
- Group(Text(name) <>
- (if (genericArgs.nonEmpty) (Text("<") <> Doc.args(genericArgs) <> Text(">")) else Text("")))
-}
\ No newline at end of file
+ Group(
+ Text(name) <>
+ (if (genericArgs.nonEmpty)
+ (Text("<") <> Doc.args(genericArgs) <> Text(">"))
+ else
+ Text(""))
+ )
+}
diff --git a/src/col/vct/col/ast/lang/sycl/SYCLNDRangeImpl.scala b/src/col/vct/col/ast/lang/sycl/SYCLNDRangeImpl.scala
index 9b6df10ad3..d2636a936d 100644
--- a/src/col/vct/col/ast/lang/sycl/SYCLNDRangeImpl.scala
+++ b/src/col/vct/col/ast/lang/sycl/SYCLNDRangeImpl.scala
@@ -4,13 +4,18 @@ import vct.col.ast.{SYCLNDRange, SYCLTNDRange, SYCLTRange, Type}
import vct.col.print.{Ctx, Doc, Group, Text}
import vct.col.ast.ops.SYCLNDRangeOps
-trait SYCLNDRangeImpl[G] extends SYCLNDRangeOps[G] { this: SYCLNDRange[G] =>
- override def t: Type[G] = globalSize.t match {
- case SYCLTRange(dimCount) => SYCLTNDRange(dimCount)
- case _ => ??? // All other types are not allowed
- }
+trait SYCLNDRangeImpl[G] extends SYCLNDRangeOps[G] {
+ this: SYCLNDRange[G] =>
+ override def t: Type[G] =
+ globalSize.t match {
+ case SYCLTRange(dimCount) => SYCLTNDRange(dimCount)
+ case _ => ??? // All other types are not allowed
+ }
override def layout(implicit ctx: Ctx): Doc =
- Group(Text("sycl::nd_range") <> "<" <> Text(this.t.asInstanceOf[SYCLTNDRange[G]].dimCount.toString) <> ">" <>
- "(" <> globalSize.show <> ", " <> localSize.show <> ")")
-}
\ No newline at end of file
+ Group(
+ Text("sycl::nd_range") <> "<" <>
+ Text(this.t.asInstanceOf[SYCLTNDRange[G]].dimCount.toString) <> ">" <>
+ "(" <> globalSize.show <> ", " <> localSize.show <> ")"
+ )
+}
diff --git a/src/col/vct/col/ast/lang/sycl/SYCLRangeImpl.scala b/src/col/vct/col/ast/lang/sycl/SYCLRangeImpl.scala
index 44ac2dd862..5059c9747f 100644
--- a/src/col/vct/col/ast/lang/sycl/SYCLRangeImpl.scala
+++ b/src/col/vct/col/ast/lang/sycl/SYCLRangeImpl.scala
@@ -5,12 +5,15 @@ import vct.col.print.{Ctx, Doc, Group, Text}
import vct.col.util.AstBuildHelpers.ExprBuildHelpers
import vct.col.ast.ops.SYCLRangeOps
-trait SYCLRangeImpl[G] extends SYCLRangeOps[G] { this: SYCLRange[G] =>
+trait SYCLRangeImpl[G] extends SYCLRangeOps[G] {
+ this: SYCLRange[G] =>
val size: Expr[G] = dimensions.reduce((e1, e2) => e1 * e2)
override def t: Type[G] = SYCLTRange(dimensions.size)
override def layout(implicit ctx: Ctx): Doc =
- Group(Text("sycl::range") <> "<" <> Text(dimensions.size.toString) <> ">" <>
- "(" <> Text(dimensions.mkString(",")) <> ")")
-}
\ No newline at end of file
+ Group(
+ Text("sycl::range") <> "<" <> Text(dimensions.size.toString) <> ">" <>
+ "(" <> Text(dimensions.mkString(",")) <> ")"
+ )
+}
diff --git a/src/col/vct/col/ast/lang/sycl/SYCLReadOnlyAccessImpl.scala b/src/col/vct/col/ast/lang/sycl/SYCLReadOnlyAccessImpl.scala
index c0d2ed1f91..0d3a335f62 100644
--- a/src/col/vct/col/ast/lang/sycl/SYCLReadOnlyAccessImpl.scala
+++ b/src/col/vct/col/ast/lang/sycl/SYCLReadOnlyAccessImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{SYCLReadOnlyAccess, SYCLTAccessMode, Type}
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.SYCLReadOnlyAccessOps
-trait SYCLReadOnlyAccessImpl[G] extends SYCLReadOnlyAccessOps[G] { this: SYCLReadOnlyAccess[G] =>
+trait SYCLReadOnlyAccessImpl[G] extends SYCLReadOnlyAccessOps[G] {
+ this: SYCLReadOnlyAccess[G] =>
override def t: Type[G] = SYCLTAccessMode()
override def layout(implicit ctx: Ctx): Doc = Text(name)
val name = "sycl::read_only"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/sycl/SYCLReadWriteAccessImpl.scala b/src/col/vct/col/ast/lang/sycl/SYCLReadWriteAccessImpl.scala
index 00e688eb81..e422af81ff 100644
--- a/src/col/vct/col/ast/lang/sycl/SYCLReadWriteAccessImpl.scala
+++ b/src/col/vct/col/ast/lang/sycl/SYCLReadWriteAccessImpl.scala
@@ -4,10 +4,11 @@ import vct.col.ast.{SYCLReadWriteAccess, SYCLTAccessMode, Type}
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.SYCLReadWriteAccessOps
-trait SYCLReadWriteAccessImpl[G] extends SYCLReadWriteAccessOps[G] { this: SYCLReadWriteAccess[G] =>
+trait SYCLReadWriteAccessImpl[G] extends SYCLReadWriteAccessOps[G] {
+ this: SYCLReadWriteAccess[G] =>
override def t: Type[G] = SYCLTAccessMode()
override def layout(implicit ctx: Ctx): Doc = Text(name)
val name = "sycl::read_write"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/sycl/SYCLTAccessModeImpl.scala b/src/col/vct/col/ast/lang/sycl/SYCLTAccessModeImpl.scala
index fccc01b110..56700bf1b3 100644
--- a/src/col/vct/col/ast/lang/sycl/SYCLTAccessModeImpl.scala
+++ b/src/col/vct/col/ast/lang/sycl/SYCLTAccessModeImpl.scala
@@ -4,8 +4,10 @@ import vct.col.ast.SYCLTAccessMode
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.SYCLTAccessModeOps
-trait SYCLTAccessModeImpl[G] extends SYCLTAccessModeOps[G] { this: SYCLTAccessMode[G] =>
- override def layout(implicit ctx: Ctx): Doc = Text("VERCORS::SYCL::ACCESS_MODE")
+trait SYCLTAccessModeImpl[G] extends SYCLTAccessModeOps[G] {
+ this: SYCLTAccessMode[G] =>
+ override def layout(implicit ctx: Ctx): Doc =
+ Text("VERCORS::SYCL::ACCESS_MODE")
override val namespacePath = ""
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/sycl/SYCLTAccessorImpl.scala b/src/col/vct/col/ast/lang/sycl/SYCLTAccessorImpl.scala
index 49b1565af6..5d29ff9d4e 100644
--- a/src/col/vct/col/ast/lang/sycl/SYCLTAccessorImpl.scala
+++ b/src/col/vct/col/ast/lang/sycl/SYCLTAccessorImpl.scala
@@ -2,42 +2,123 @@ package vct.col.ast.lang.sycl
import vct.col.ast._
import vct.col.print.{Ctx, Doc, Group, Text}
-import vct.col.resolve.ctx.{CPPInvocationTarget, RefSYCLAccessMode, RefSYCLConstructorDefinition}
+import vct.col.resolve.ctx.{
+ CPPInvocationTarget,
+ RefSYCLAccessMode,
+ RefSYCLConstructorDefinition,
+}
import vct.col.resolve.lang.{CPP, Util}
import vct.col.ast.ops.SYCLTAccessorOps
-trait SYCLTAccessorImpl[G] extends SYCLTAccessorOps[G] { this: SYCLTAccessor[G] =>
+trait SYCLTAccessorImpl[G] extends SYCLTAccessorOps[G] {
+ this: SYCLTAccessor[G] =>
override def layout(implicit ctx: Ctx): Doc =
- Group(Text("sycl::accessor") <> "<" <> typ <> ", " <> Text(dimCount.toString) <> ", " <> Text(if (readOnly) "sycl::access_mode::read" else "sycl::access_mode::read_write") <> ">")
+ Group(
+ Text("sycl::accessor") <> "<" <> typ <> ", " <> Text(dimCount.toString) <>
+ ", " <> Text(
+ if (readOnly)
+ "sycl::access_mode::read"
+ else
+ "sycl::access_mode::read_write"
+ ) <> ">"
+ )
override val namespacePath = "sycl::accessor"
- def findConstructor(genericArgs: Seq[CPPExprOrTypeSpecifier[G]], args: Seq[Expr[G]]): Option[CPPInvocationTarget[G]] = {
- if (args.nonEmpty) CPP.unwrappedType(args.head.t) match {
- case SYCLTBuffer(typ, dimCount) => genericArgs match {
- case Seq(CPPExprOrTypeSpecifier(None, Some(typeSpec)), CPPExprOrTypeSpecifier(Some(CIntegerValue(dim)), None), CPPExprOrTypeSpecifier(None, Some(SYCLClassDefName("access_mode::read_write", Nil)))) if dim > 0 && dim <= 3 &&
- Util.compatTypes[G](args, Seq(SYCLTBuffer(CPP.getBaseTypeFromSpecs(Seq(typeSpec)), dim.toInt), SYCLTHandler[G](), SYCLTAccessMode[G]())) && isAccessMode(args(2), SYCLReadWriteAccess[G]()) =>
- Some(RefSYCLConstructorDefinition(SYCLTAccessor(typ, dimCount)))
- case Seq(CPPExprOrTypeSpecifier(None, Some(typeSpec)), CPPExprOrTypeSpecifier(Some(CIntegerValue(dim)), None), CPPExprOrTypeSpecifier(None, Some(SYCLClassDefName("access_mode::read", Nil)))) if dim > 0 && dim <= 3 &&
- Util.compatTypes[G](args, Seq(SYCLTBuffer(CPP.getBaseTypeFromSpecs(Seq(typeSpec)), dim.toInt), SYCLTHandler[G](), SYCLTAccessMode[G]())) && isAccessMode(args(2), SYCLReadOnlyAccess[G]()) =>
- Some(RefSYCLConstructorDefinition(SYCLTAccessor(typ, dimCount, readOnly = true)))
- case Seq(CPPExprOrTypeSpecifier(None, Some(typeSpec)), CPPExprOrTypeSpecifier(Some(CIntegerValue(dim)), None)) if dim > 0 && dim <= 3 &&
- Util.compatTypes[G](args, Seq(SYCLTBuffer(CPP.getBaseTypeFromSpecs(Seq(typeSpec)), dim.toInt), SYCLTHandler[G](), SYCLTAccessMode[G]())) && isAccessMode(args(2), SYCLReadWriteAccess[G]()) =>
- Some(RefSYCLConstructorDefinition(SYCLTAccessor(typ, dimCount)))
- case Seq(CPPExprOrTypeSpecifier(None, Some(typeSpec))) if dimCount == 1 &&
- Util.compatTypes[G](args, Seq(SYCLTBuffer(CPP.getBaseTypeFromSpecs(Seq(typeSpec))), SYCLTHandler[G](), SYCLTAccessMode[G]())) && isAccessMode(args(2), SYCLReadWriteAccess[G]()) =>
- Some(RefSYCLConstructorDefinition(SYCLTAccessor(typ, dimCount)))
- case Nil => Some(RefSYCLConstructorDefinition(SYCLTAccessor(typ, dimCount, isAccessMode(args(2), SYCLReadOnlyAccess[G]()))))
+ def findConstructor(
+ genericArgs: Seq[CPPExprOrTypeSpecifier[G]],
+ args: Seq[Expr[G]],
+ ): Option[CPPInvocationTarget[G]] = {
+ if (args.nonEmpty)
+ CPP.unwrappedType(args.head.t) match {
+ case SYCLTBuffer(typ, dimCount) =>
+ genericArgs match {
+ case Seq(
+ CPPExprOrTypeSpecifier(None, Some(typeSpec)),
+ CPPExprOrTypeSpecifier(Some(CIntegerValue(dim)), None),
+ CPPExprOrTypeSpecifier(
+ None,
+ Some(SYCLClassDefName("access_mode::read_write", Nil)),
+ ),
+ )
+ if dim > 0 && dim <= 3 && Util.compatTypes[G](
+ args,
+ Seq(
+ SYCLTBuffer(
+ CPP.getBaseTypeFromSpecs(Seq(typeSpec)),
+ dim.toInt,
+ ),
+ SYCLTHandler[G](),
+ SYCLTAccessMode[G](),
+ ),
+ ) && isAccessMode(args(2), SYCLReadWriteAccess[G]()) =>
+ Some(RefSYCLConstructorDefinition(SYCLTAccessor(typ, dimCount)))
+ case Seq(
+ CPPExprOrTypeSpecifier(None, Some(typeSpec)),
+ CPPExprOrTypeSpecifier(Some(CIntegerValue(dim)), None),
+ CPPExprOrTypeSpecifier(
+ None,
+ Some(SYCLClassDefName("access_mode::read", Nil)),
+ ),
+ )
+ if dim > 0 && dim <= 3 && Util.compatTypes[G](
+ args,
+ Seq(
+ SYCLTBuffer(
+ CPP.getBaseTypeFromSpecs(Seq(typeSpec)),
+ dim.toInt,
+ ),
+ SYCLTHandler[G](),
+ SYCLTAccessMode[G](),
+ ),
+ ) && isAccessMode(args(2), SYCLReadOnlyAccess[G]()) =>
+ Some(RefSYCLConstructorDefinition(
+ SYCLTAccessor(typ, dimCount, readOnly = true)
+ ))
+ case Seq(
+ CPPExprOrTypeSpecifier(None, Some(typeSpec)),
+ CPPExprOrTypeSpecifier(Some(CIntegerValue(dim)), None),
+ )
+ if dim > 0 && dim <= 3 && Util.compatTypes[G](
+ args,
+ Seq(
+ SYCLTBuffer(
+ CPP.getBaseTypeFromSpecs(Seq(typeSpec)),
+ dim.toInt,
+ ),
+ SYCLTHandler[G](),
+ SYCLTAccessMode[G](),
+ ),
+ ) && isAccessMode(args(2), SYCLReadWriteAccess[G]()) =>
+ Some(RefSYCLConstructorDefinition(SYCLTAccessor(typ, dimCount)))
+ case Seq(CPPExprOrTypeSpecifier(None, Some(typeSpec)))
+ if dimCount == 1 && Util.compatTypes[G](
+ args,
+ Seq(
+ SYCLTBuffer(CPP.getBaseTypeFromSpecs(Seq(typeSpec))),
+ SYCLTHandler[G](),
+ SYCLTAccessMode[G](),
+ ),
+ ) && isAccessMode(args(2), SYCLReadWriteAccess[G]()) =>
+ Some(RefSYCLConstructorDefinition(SYCLTAccessor(typ, dimCount)))
+ case Nil =>
+ Some(RefSYCLConstructorDefinition(SYCLTAccessor(
+ typ,
+ dimCount,
+ isAccessMode(args(2), SYCLReadOnlyAccess[G]()),
+ )))
+ case _ => None
+ }
case _ => None
}
- case _ => None
- } else {
- None
- }
+ else { None }
}
- private def isAccessMode(e: Expr[G], accessMode: SYCLAccessMode[G]): Boolean = e match {
- case local: CPPLocal[G] if local.ref.get.equals(RefSYCLAccessMode(accessMode)) => true
- case _ => false
- }
-}
\ No newline at end of file
+ private def isAccessMode(e: Expr[G], accessMode: SYCLAccessMode[G]): Boolean =
+ e match {
+ case local: CPPLocal[G]
+ if local.ref.get.equals(RefSYCLAccessMode(accessMode)) =>
+ true
+ case _ => false
+ }
+}
diff --git a/src/col/vct/col/ast/lang/sycl/SYCLTBufferImpl.scala b/src/col/vct/col/ast/lang/sycl/SYCLTBufferImpl.scala
index 6a64475501..c4b2da5c94 100644
--- a/src/col/vct/col/ast/lang/sycl/SYCLTBufferImpl.scala
+++ b/src/col/vct/col/ast/lang/sycl/SYCLTBufferImpl.scala
@@ -7,45 +7,103 @@ import vct.col.print.{Ctx, Doc, Group, Text}
import vct.col.ref.Ref
import vct.col.resolve.ctx.{CPPInvocationTarget, RefSYCLConstructorDefinition}
import vct.col.resolve.lang.{CPP, Util}
-import vct.col.util.AstBuildHelpers.{ExprBuildHelpers, c_const, foldStar, tt, withResult}
+import vct.col.util.AstBuildHelpers.{
+ ExprBuildHelpers,
+ c_const,
+ foldStar,
+ tt,
+ withResult,
+}
import vct.col.ast.ops.SYCLTBufferOps
-trait SYCLTBufferImpl[G] extends SYCLTBufferOps[G] { this: SYCLTBuffer[G] =>
+trait SYCLTBufferImpl[G] extends SYCLTBufferOps[G] {
+ this: SYCLTBuffer[G] =>
override def layout(implicit ctx: Ctx): Doc =
- Group(Text("sycl::buffer") <> "<" <> typ <> ", " <> Text(dimCount.toString) <> ">")
+ Group(
+ Text("sycl::buffer") <> "<" <> typ <> ", " <> Text(dimCount.toString) <>
+ ">"
+ )
override val namespacePath = "sycl::buffer"
- def findConstructor(genericArgs: Seq[CPPExprOrTypeSpecifier[G]], args: Seq[Expr[G]]): Option[CPPInvocationTarget[G]] = genericArgs match {
- case Seq(CPPExprOrTypeSpecifier(None, Some(typeSpec)), CPPExprOrTypeSpecifier(Some(CIntegerValue(dim)), None)) if dim > 0 && dim <= 3 && args.nonEmpty && args.head.t.asPointer.isDefined &&
- CPP.getBaseTypeFromSpecs[G](Seq(typeSpec)).superTypeOf(args.head.t.asPointer.get.element) && Util.compatTypes[G](args.tail, Seq(SYCLTRange[G](dim.toInt))) =>
- Some(RefSYCLConstructorDefinition[G](SYCLTBuffer[G](CPP.getBaseTypeFromSpecs[G](Seq(typeSpec)), dim.toInt)))
- case Seq(CPPExprOrTypeSpecifier(None, Some(typeSpec))) if args.nonEmpty && args.head.t.asPointer.isDefined &&
- CPP.getBaseTypeFromSpecs[G](Seq(typeSpec)).superTypeOf(args.head.t.asPointer.get.element) && Util.compatTypes[G](args.tail, Seq(SYCLTRange[G](1))) =>
- Some(RefSYCLConstructorDefinition(SYCLTBuffer(CPP.getBaseTypeFromSpecs(Seq(typeSpec)), 1)))
- case Seq(CPPExprOrTypeSpecifier(None, Some(typeSpec))) if args.nonEmpty && args.head.t.asPointer.isDefined &&
- CPP.getBaseTypeFromSpecs[G](Seq(typeSpec)).superTypeOf(args.head.t.asPointer.get.element) && Util.compatTypes[G](args.tail, Seq(SYCLTRange[G](2))) =>
- Some(RefSYCLConstructorDefinition(SYCLTBuffer(CPP.getBaseTypeFromSpecs(Seq(typeSpec)), 2)))
- case Seq(CPPExprOrTypeSpecifier(None, Some(typeSpec))) if args.nonEmpty && args.head.t.asPointer.isDefined &&
- CPP.getBaseTypeFromSpecs[G](Seq(typeSpec)).superTypeOf(args.head.t.asPointer.get.element) && Util.compatTypes[G](args.tail, Seq(SYCLTRange[G](3))) =>
- Some(RefSYCLConstructorDefinition(SYCLTBuffer(CPP.getBaseTypeFromSpecs(Seq(typeSpec)), 3)))
- case Nil if args.nonEmpty && args.head.t.asPointer.isDefined && Util.compatTypes(args.tail, Seq(SYCLTRange[G](1))) =>
- Some(RefSYCLConstructorDefinition(SYCLTBuffer(args.head.t.asPointer.get.element, 1)))
- case Nil if args.nonEmpty && args.head.t.asPointer.isDefined && Util.compatTypes(args.tail, Seq(SYCLTRange[G](2))) =>
- Some(RefSYCLConstructorDefinition(SYCLTBuffer(args.head.t.asPointer.get.element, 2)))
- case Nil if args.nonEmpty && args.head.t.asPointer.isDefined && Util.compatTypes(args.tail, Seq(SYCLTRange[G](3))) =>
- Some(RefSYCLConstructorDefinition(SYCLTBuffer(args.head.t.asPointer.get.element, 3)))
- case _ => None
- }
+ def findConstructor(
+ genericArgs: Seq[CPPExprOrTypeSpecifier[G]],
+ args: Seq[Expr[G]],
+ ): Option[CPPInvocationTarget[G]] =
+ genericArgs match {
+ case Seq(
+ CPPExprOrTypeSpecifier(None, Some(typeSpec)),
+ CPPExprOrTypeSpecifier(Some(CIntegerValue(dim)), None),
+ )
+ if dim > 0 && dim <= 3 && args.nonEmpty &&
+ args.head.t.asPointer.isDefined &&
+ CPP.getBaseTypeFromSpecs[G](Seq(typeSpec))
+ .superTypeOf(args.head.t.asPointer.get.element) &&
+ Util.compatTypes[G](args.tail, Seq(SYCLTRange[G](dim.toInt))) =>
+ Some(RefSYCLConstructorDefinition[G](
+ SYCLTBuffer[G](CPP.getBaseTypeFromSpecs[G](Seq(typeSpec)), dim.toInt)
+ ))
+ case Seq(CPPExprOrTypeSpecifier(None, Some(typeSpec)))
+ if args.nonEmpty && args.head.t.asPointer.isDefined &&
+ CPP.getBaseTypeFromSpecs[G](Seq(typeSpec))
+ .superTypeOf(args.head.t.asPointer.get.element) &&
+ Util.compatTypes[G](args.tail, Seq(SYCLTRange[G](1))) =>
+ Some(RefSYCLConstructorDefinition(
+ SYCLTBuffer(CPP.getBaseTypeFromSpecs(Seq(typeSpec)), 1)
+ ))
+ case Seq(CPPExprOrTypeSpecifier(None, Some(typeSpec)))
+ if args.nonEmpty && args.head.t.asPointer.isDefined &&
+ CPP.getBaseTypeFromSpecs[G](Seq(typeSpec))
+ .superTypeOf(args.head.t.asPointer.get.element) &&
+ Util.compatTypes[G](args.tail, Seq(SYCLTRange[G](2))) =>
+ Some(RefSYCLConstructorDefinition(
+ SYCLTBuffer(CPP.getBaseTypeFromSpecs(Seq(typeSpec)), 2)
+ ))
+ case Seq(CPPExprOrTypeSpecifier(None, Some(typeSpec)))
+ if args.nonEmpty && args.head.t.asPointer.isDefined &&
+ CPP.getBaseTypeFromSpecs[G](Seq(typeSpec))
+ .superTypeOf(args.head.t.asPointer.get.element) &&
+ Util.compatTypes[G](args.tail, Seq(SYCLTRange[G](3))) =>
+ Some(RefSYCLConstructorDefinition(
+ SYCLTBuffer(CPP.getBaseTypeFromSpecs(Seq(typeSpec)), 3)
+ ))
+ case Nil
+ if args.nonEmpty && args.head.t.asPointer.isDefined &&
+ Util.compatTypes(args.tail, Seq(SYCLTRange[G](1))) =>
+ Some(RefSYCLConstructorDefinition(
+ SYCLTBuffer(args.head.t.asPointer.get.element, 1)
+ ))
+ case Nil
+ if args.nonEmpty && args.head.t.asPointer.isDefined &&
+ Util.compatTypes(args.tail, Seq(SYCLTRange[G](2))) =>
+ Some(RefSYCLConstructorDefinition(
+ SYCLTBuffer(args.head.t.asPointer.get.element, 2)
+ ))
+ case Nil
+ if args.nonEmpty && args.head.t.asPointer.isDefined &&
+ Util.compatTypes(args.tail, Seq(SYCLTRange[G](3))) =>
+ Some(RefSYCLConstructorDefinition(
+ SYCLTBuffer(args.head.t.asPointer.get.element, 3)
+ ))
+ case _ => None
+ }
// resource exclusive_hostData_access(TYPE* hostData, int range) = \pointer(hostData, range, write);
def generateExclusiveAccessPredicate(): Predicate[G] = {
- val hostDataVar = new Variable[G](TPointer(this.typ))(o.where(name = "hostData"))
- val sizeVar = new Variable[G](TInt())(o.where(name = "size")) // Needs to be TInt instead of TCInt as it is called with a Length expr which has type TInt
+ val hostDataVar =
+ new Variable[G](TPointer(this.typ))(o.where(name = "hostData"))
+ val sizeVar =
+ new Variable[G](TInt())(
+ o.where(name = "size")
+ ) // Needs to be TInt instead of TCInt as it is called with a Length expr which has type TInt
new Predicate[G](
args = Seq(hostDataVar, sizeVar),
- body = Some(PermPointer[G](Local[G](hostDataVar.ref), Local[G](sizeVar.ref), WritePerm())),
+ body = Some(PermPointer[G](
+ Local[G](hostDataVar.ref),
+ Local[G](sizeVar.ref),
+ WritePerm(),
+ )),
)(o.where(name = "exclusive_hostData_access"))
}
@@ -55,10 +113,13 @@ trait SYCLTBufferImpl[G] extends SYCLTBufferOps[G] { this: SYCLTBuffer[G] =>
// ensures (\forall int i; i >= 0 && i < size; {: \result[i] :} == hostData[i]);
// TYPE[] copy_hostdata_to_buffer(TYPE* hostData, int size);
def generateCopyHostDataToBufferProcedure(): Procedure[G] = {
- val hostDataVar = new Variable[G](TPointer(this.typ))(o.where(name = "hostData"))
+ val hostDataVar =
+ new Variable[G](TPointer(this.typ))(o.where(name = "hostData"))
val sizeVar = new Variable[G](TCInt())(o.where(name = "size"))
val indexVar = new Variable[G](TCInt())(o.where(name = "i"))
- val copyHostdataToBufferBlame = PanicBlame("The generated method 'copy_hostData_to_buffer' should not throw any errors.")
+ val copyHostdataToBufferBlame = PanicBlame(
+ "The generated method 'copy_hostData_to_buffer' should not throw any errors."
+ )
withResult((result: Result[G]) => {
new Procedure[G](
@@ -67,31 +128,54 @@ trait SYCLTBufferImpl[G] extends SYCLTBufferOps[G] { this: SYCLTBuffer[G] =>
outArgs = Nil,
typeArgs = Nil,
body = None,
- contract = ApplicableContract(
- requires = UnitAccountedPredicate(Star(
- GreaterEq(Local[G](sizeVar.ref), c_const(0)),
- PermPointer[G](Local[G](hostDataVar.ref), Local[G](sizeVar.ref), WritePerm())
- )),
- ensures = UnitAccountedPredicate(foldStar(Seq(
- PermPointer[G](Local[G](hostDataVar.ref), Local[G](sizeVar.ref), WritePerm()),
- validArray(result, Local[G](sizeVar.ref), WritePerm(), copyHostdataToBufferBlame),
- Forall(
- bindings = Seq(indexVar),
- triggers = Seq(Seq(ArraySubscript(result, Local[G](indexVar.ref))(copyHostdataToBufferBlame))),
- body =
- (Local[G](indexVar.ref) >= c_const(0) && Local[G](indexVar.ref) < Local[G](sizeVar.ref)) ==>
- Eq(
- ArraySubscript(result, Local[G](indexVar.ref))(copyHostdataToBufferBlame),
- PointerSubscript(Local[G](hostDataVar.ref), Local[G](indexVar.ref))(copyHostdataToBufferBlame)
- )
- )
- ))),
- contextEverywhere = tt,
- signals = Nil,
- givenArgs = Nil,
- yieldsArgs = Nil,
- decreases = None
- )(copyHostdataToBufferBlame)
+ contract =
+ ApplicableContract(
+ requires = UnitAccountedPredicate(Star(
+ GreaterEq(Local[G](sizeVar.ref), c_const(0)),
+ PermPointer[G](
+ Local[G](hostDataVar.ref),
+ Local[G](sizeVar.ref),
+ WritePerm(),
+ ),
+ )),
+ ensures = UnitAccountedPredicate(foldStar(Seq(
+ PermPointer[G](
+ Local[G](hostDataVar.ref),
+ Local[G](sizeVar.ref),
+ WritePerm(),
+ ),
+ validArray(
+ result,
+ Local[G](sizeVar.ref),
+ WritePerm(),
+ copyHostdataToBufferBlame,
+ ),
+ Forall(
+ bindings = Seq(indexVar),
+ triggers = Seq(
+ Seq(ArraySubscript(result, Local[G](indexVar.ref))(
+ copyHostdataToBufferBlame
+ ))
+ ),
+ body =
+ (Local[G](indexVar.ref) >= c_const(0) &&
+ Local[G](indexVar.ref) < Local[G](sizeVar.ref)) ==> Eq(
+ ArraySubscript(result, Local[G](indexVar.ref))(
+ copyHostdataToBufferBlame
+ ),
+ PointerSubscript(
+ Local[G](hostDataVar.ref),
+ Local[G](indexVar.ref),
+ )(copyHostdataToBufferBlame),
+ ),
+ ),
+ ))),
+ contextEverywhere = tt,
+ signals = Nil,
+ givenArgs = Nil,
+ yieldsArgs = Nil,
+ decreases = None,
+ )(copyHostdataToBufferBlame),
)(copyHostdataToBufferBlame)(o.where(name = "copy_hostData_to_buffer"))
})
}
@@ -100,11 +184,16 @@ trait SYCLTBufferImpl[G] extends SYCLTBufferOps[G] { this: SYCLTBuffer[G] =>
// context \array(buffer, buffer.length) ** Perm(buffer[*], read);
// ensures \unfolding sycl::buffer::exclusive_hostData_access(hostData, buffer.length) \in (\forall int i; i >= 0 && i < buffer.length; {: hostData[i] :} == buffer[i]);
// void copy_buffer_to_hostdata(TYPE* hostData, TYPE[] buffer);
- def generateCopyBufferToHostDataProcedure(exclusiveAccessPredRef: Ref[G, Predicate[G]]): Procedure[G] = {
+ def generateCopyBufferToHostDataProcedure(
+ exclusiveAccessPredRef: Ref[G, Predicate[G]]
+ ): Procedure[G] = {
val bufferVar = new Variable[G](TArray(this.typ))(o.where(name = "buffer"))
- val hostDataVar = new Variable[G](TPointer(this.typ))(o.where(name = "hostData"))
+ val hostDataVar =
+ new Variable[G](TPointer(this.typ))(o.where(name = "hostData"))
val indexVar = new Variable[G](TCInt())(o.where(name = "i"))
- val copyBufferToHostdataBlame = PanicBlame("The generated method 'copy_buffer_to_hostData' should not throw any errors.")
+ val copyBufferToHostdataBlame = PanicBlame(
+ "The generated method 'copy_buffer_to_hostData' should not throw any errors."
+ )
new Procedure[G](
returnType = TVoid(),
@@ -112,45 +201,95 @@ trait SYCLTBufferImpl[G] extends SYCLTBufferOps[G] { this: SYCLTBuffer[G] =>
outArgs = Nil,
typeArgs = Nil,
body = None,
- contract = ApplicableContract(
- requires = UnitAccountedPredicate(foldStar(Seq(
- validArray(Local(bufferVar.ref), Length(Local[G](bufferVar.ref))(copyBufferToHostdataBlame), ReadPerm(), copyBufferToHostdataBlame),
- predApply(exclusiveAccessPredRef, hostDataVar, Length(Local[G](bufferVar.ref))(copyBufferToHostdataBlame))
- ))),
- ensures = UnitAccountedPredicate(foldStar(Seq(
- validArray(Local(bufferVar.ref), Length(Local[G](bufferVar.ref))(copyBufferToHostdataBlame), ReadPerm(), copyBufferToHostdataBlame),
- predApply(exclusiveAccessPredRef, hostDataVar, Length(Local[G](bufferVar.ref))(copyBufferToHostdataBlame)),
- Unfolding(
- predApply(exclusiveAccessPredRef, hostDataVar, Length(Local[G](bufferVar.ref))(copyBufferToHostdataBlame)),
- Forall(
- bindings = Seq(indexVar),
- triggers = Seq(Seq(PointerSubscript(Local[G](hostDataVar.ref), Local[G](indexVar.ref))(copyBufferToHostdataBlame))),
- body =
- (Local[G](indexVar.ref) >= c_const(0) && Local[G](indexVar.ref) < Length(Local[G](bufferVar.ref))(copyBufferToHostdataBlame)) ==>
- Eq(
- PointerSubscript(Local[G](hostDataVar.ref), Local[G](indexVar.ref))(copyBufferToHostdataBlame),
- ArraySubscript[G](Local[G](bufferVar.ref), Local[G](indexVar.ref))(copyBufferToHostdataBlame)
- )
- )
- )(copyBufferToHostdataBlame)
- ))),
- contextEverywhere = tt,
- signals = Nil,
- givenArgs = Nil,
- yieldsArgs = Nil,
- decreases = None
- )(copyBufferToHostdataBlame)
+ contract =
+ ApplicableContract(
+ requires = UnitAccountedPredicate(foldStar(Seq(
+ validArray(
+ Local(bufferVar.ref),
+ Length(Local[G](bufferVar.ref))(copyBufferToHostdataBlame),
+ ReadPerm(),
+ copyBufferToHostdataBlame,
+ ),
+ predApply(
+ exclusiveAccessPredRef,
+ hostDataVar,
+ Length(Local[G](bufferVar.ref))(copyBufferToHostdataBlame),
+ ),
+ ))),
+ ensures = UnitAccountedPredicate(foldStar(Seq(
+ validArray(
+ Local(bufferVar.ref),
+ Length(Local[G](bufferVar.ref))(copyBufferToHostdataBlame),
+ ReadPerm(),
+ copyBufferToHostdataBlame,
+ ),
+ predApply(
+ exclusiveAccessPredRef,
+ hostDataVar,
+ Length(Local[G](bufferVar.ref))(copyBufferToHostdataBlame),
+ ),
+ Unfolding(
+ predApply(
+ exclusiveAccessPredRef,
+ hostDataVar,
+ Length(Local[G](bufferVar.ref))(copyBufferToHostdataBlame),
+ ),
+ Forall(
+ bindings = Seq(indexVar),
+ triggers = Seq(Seq(
+ PointerSubscript(
+ Local[G](hostDataVar.ref),
+ Local[G](indexVar.ref),
+ )(copyBufferToHostdataBlame)
+ )),
+ body =
+ (
+ Local[G](indexVar.ref) >= c_const(0) &&
+ Local[G](indexVar.ref) <
+ Length(Local[G](bufferVar.ref))(copyBufferToHostdataBlame)
+ ) ==> Eq(
+ PointerSubscript(
+ Local[G](hostDataVar.ref),
+ Local[G](indexVar.ref),
+ )(copyBufferToHostdataBlame),
+ ArraySubscript[G](
+ Local[G](bufferVar.ref),
+ Local[G](indexVar.ref),
+ )(copyBufferToHostdataBlame),
+ ),
+ ),
+ )(copyBufferToHostdataBlame),
+ ))),
+ contextEverywhere = tt,
+ signals = Nil,
+ givenArgs = Nil,
+ yieldsArgs = Nil,
+ decreases = None,
+ )(copyBufferToHostdataBlame),
)(copyBufferToHostdataBlame)(o.where(name = "copy_buffer_to_hostData"))
}
- private def validArray(arr: Expr[G], len: Expr[G], perm: Expr[G], blame: PanicBlame): Expr[G] = {
+ private def validArray(
+ arr: Expr[G],
+ len: Expr[G],
+ perm: Expr[G],
+ blame: PanicBlame,
+ ): Expr[G] = {
Star(
ValidArray[G](arr, len),
- Perm(ArrayLocation(arr, Any()(blame))(blame), perm)
+ Perm(ArrayLocation(arr, Any()(blame))(blame), perm),
)
}
- private def predApply(exclusiveAccessPredRef: Ref[G, Predicate[G]], hostData: Variable[G], len: Expr[G]): Expr[G] = {
- PredicateApply[G](exclusiveAccessPredRef, Seq(Local[G](hostData.ref), len), WritePerm())
+ private def predApply(
+ exclusiveAccessPredRef: Ref[G, Predicate[G]],
+ hostData: Variable[G],
+ len: Expr[G],
+ ): Expr[G] = {
+ PredicateApply[G](
+ exclusiveAccessPredRef,
+ Seq(Local[G](hostData.ref), len),
+ WritePerm(),
+ )
}
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/sycl/SYCLTClassImpl.scala b/src/col/vct/col/ast/lang/sycl/SYCLTClassImpl.scala
index bb033415b6..259cf67987 100644
--- a/src/col/vct/col/ast/lang/sycl/SYCLTClassImpl.scala
+++ b/src/col/vct/col/ast/lang/sycl/SYCLTClassImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.lang.sycl
import vct.col.ast.SYCLTClass
-trait SYCLTClassImpl[G] { this: SYCLTClass[G] =>
+trait SYCLTClassImpl[G] {
+ this: SYCLTClass[G] =>
val namespacePath: String
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/sycl/SYCLTConstructableClassImpl.scala b/src/col/vct/col/ast/lang/sycl/SYCLTConstructableClassImpl.scala
index 32d0ae5cb1..1a98eabdf8 100644
--- a/src/col/vct/col/ast/lang/sycl/SYCLTConstructableClassImpl.scala
+++ b/src/col/vct/col/ast/lang/sycl/SYCLTConstructableClassImpl.scala
@@ -3,6 +3,10 @@ package vct.col.ast.lang.sycl
import vct.col.ast.{CPPExprOrTypeSpecifier, Expr, SYCLTConstructableClass}
import vct.col.resolve.ctx.CPPInvocationTarget
-trait SYCLTConstructableClassImpl[G] { this: SYCLTConstructableClass[G] =>
- def findConstructor(genericArgs: Seq[CPPExprOrTypeSpecifier[G]], args: Seq[Expr[G]]): Option[CPPInvocationTarget[G]]
-}
\ No newline at end of file
+trait SYCLTConstructableClassImpl[G] {
+ this: SYCLTConstructableClass[G] =>
+ def findConstructor(
+ genericArgs: Seq[CPPExprOrTypeSpecifier[G]],
+ args: Seq[Expr[G]],
+ ): Option[CPPInvocationTarget[G]]
+}
diff --git a/src/col/vct/col/ast/lang/sycl/SYCLTEventImpl.scala b/src/col/vct/col/ast/lang/sycl/SYCLTEventImpl.scala
index ab440c95c0..74a36a61a5 100644
--- a/src/col/vct/col/ast/lang/sycl/SYCLTEventImpl.scala
+++ b/src/col/vct/col/ast/lang/sycl/SYCLTEventImpl.scala
@@ -4,8 +4,9 @@ import vct.col.ast.SYCLTEvent
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.SYCLTEventOps
-trait SYCLTEventImpl[G] extends SYCLTEventOps[G] { this: SYCLTEvent[G] =>
+trait SYCLTEventImpl[G] extends SYCLTEventOps[G] {
+ this: SYCLTEvent[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("sycl::event")
override val namespacePath = "sycl::event"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/sycl/SYCLTHandlerImpl.scala b/src/col/vct/col/ast/lang/sycl/SYCLTHandlerImpl.scala
index 18b8ec3aeb..562464872f 100644
--- a/src/col/vct/col/ast/lang/sycl/SYCLTHandlerImpl.scala
+++ b/src/col/vct/col/ast/lang/sycl/SYCLTHandlerImpl.scala
@@ -4,8 +4,9 @@ import vct.col.ast.SYCLTHandler
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.SYCLTHandlerOps
-trait SYCLTHandlerImpl[G] extends SYCLTHandlerOps[G] { this: SYCLTHandler[G] =>
+trait SYCLTHandlerImpl[G] extends SYCLTHandlerOps[G] {
+ this: SYCLTHandler[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("sycl::handler")
override val namespacePath = "sycl::handler"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/sycl/SYCLTItemImpl.scala b/src/col/vct/col/ast/lang/sycl/SYCLTItemImpl.scala
index c505b8a8c1..eeaafa2467 100644
--- a/src/col/vct/col/ast/lang/sycl/SYCLTItemImpl.scala
+++ b/src/col/vct/col/ast/lang/sycl/SYCLTItemImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.SYCLTItem
import vct.col.print.{Ctx, Doc, Group, Text}
import vct.col.ast.ops.SYCLTItemOps
-trait SYCLTItemImpl[G] extends SYCLTItemOps[G] { this: SYCLTItem[G] =>
+trait SYCLTItemImpl[G] extends SYCLTItemOps[G] {
+ this: SYCLTItem[G] =>
override def layout(implicit ctx: Ctx): Doc =
Group(Text("sycl::item") <> "<" <> Text(dimCount.toString) <> ">")
override val namespacePath = "sycl::item"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/sycl/SYCLTLocalAccessorImpl.scala b/src/col/vct/col/ast/lang/sycl/SYCLTLocalAccessorImpl.scala
index 0f2317ac45..204e3cdb22 100644
--- a/src/col/vct/col/ast/lang/sycl/SYCLTLocalAccessorImpl.scala
+++ b/src/col/vct/col/ast/lang/sycl/SYCLTLocalAccessorImpl.scala
@@ -6,17 +6,38 @@ import vct.col.resolve.ctx.{CPPInvocationTarget, RefSYCLConstructorDefinition}
import vct.col.resolve.lang.{CPP, Util}
import vct.col.ast.ops.SYCLTLocalAccessorOps
-trait SYCLTLocalAccessorImpl[G] extends SYCLTLocalAccessorOps[G] { this: SYCLTLocalAccessor[G] =>
+trait SYCLTLocalAccessorImpl[G] extends SYCLTLocalAccessorOps[G] {
+ this: SYCLTLocalAccessor[G] =>
override def layout(implicit ctx: Ctx): Doc =
- Group(Text("sycl::local_accessor") <> "<" <> typ <> ", " <> Text(dimCount.toString) <> ">")
+ Group(
+ Text("sycl::local_accessor") <> "<" <> typ <> ", " <>
+ Text(dimCount.toString) <> ">"
+ )
override val namespacePath = "sycl::local_accessor"
- def findConstructor(genericArgs: Seq[CPPExprOrTypeSpecifier[G]], args: Seq[Expr[G]]): Option[CPPInvocationTarget[G]] = genericArgs match {
- case Seq(CPPExprOrTypeSpecifier(None, Some(typeSpec)), CPPExprOrTypeSpecifier(Some(CIntegerValue(dim)), None)) if dim > 0 && dim <= 3 &&
- Util.compatTypes[G](args, Seq(SYCLTRange[G](dim.toInt), SYCLTHandler[G]())) => Some(RefSYCLConstructorDefinition(SYCLTLocalAccessor[G](CPP.getBaseTypeFromSpecs[G](Seq(typeSpec)), dim.toInt)))
- case Seq(CPPExprOrTypeSpecifier(None, Some(typeSpec))) if Util.compatTypes(args, Seq(SYCLTRange[G](1), SYCLTHandler[G]())) =>
- Some(RefSYCLConstructorDefinition(SYCLTLocalAccessor(CPP.getBaseTypeFromSpecs(Seq(typeSpec)), 1)))
- case _ => None
- }
-}
\ No newline at end of file
+ def findConstructor(
+ genericArgs: Seq[CPPExprOrTypeSpecifier[G]],
+ args: Seq[Expr[G]],
+ ): Option[CPPInvocationTarget[G]] =
+ genericArgs match {
+ case Seq(
+ CPPExprOrTypeSpecifier(None, Some(typeSpec)),
+ CPPExprOrTypeSpecifier(Some(CIntegerValue(dim)), None),
+ )
+ if dim > 0 && dim <= 3 && Util.compatTypes[G](
+ args,
+ Seq(SYCLTRange[G](dim.toInt), SYCLTHandler[G]()),
+ ) =>
+ Some(RefSYCLConstructorDefinition(SYCLTLocalAccessor[G](
+ CPP.getBaseTypeFromSpecs[G](Seq(typeSpec)),
+ dim.toInt,
+ )))
+ case Seq(CPPExprOrTypeSpecifier(None, Some(typeSpec)))
+ if Util.compatTypes(args, Seq(SYCLTRange[G](1), SYCLTHandler[G]())) =>
+ Some(RefSYCLConstructorDefinition(
+ SYCLTLocalAccessor(CPP.getBaseTypeFromSpecs(Seq(typeSpec)), 1)
+ ))
+ case _ => None
+ }
+}
diff --git a/src/col/vct/col/ast/lang/sycl/SYCLTNDItemImpl.scala b/src/col/vct/col/ast/lang/sycl/SYCLTNDItemImpl.scala
index e457881d4d..a6ff4f9ee9 100644
--- a/src/col/vct/col/ast/lang/sycl/SYCLTNDItemImpl.scala
+++ b/src/col/vct/col/ast/lang/sycl/SYCLTNDItemImpl.scala
@@ -4,9 +4,10 @@ import vct.col.ast.SYCLTNDItem
import vct.col.print.{Ctx, Doc, Group, Text}
import vct.col.ast.ops.SYCLTNDItemOps
-trait SYCLTNDItemImpl[G] extends SYCLTNDItemOps[G] { this: SYCLTNDItem[G] =>
+trait SYCLTNDItemImpl[G] extends SYCLTNDItemOps[G] {
+ this: SYCLTNDItem[G] =>
override def layout(implicit ctx: Ctx): Doc =
Group(Text("sycl::nd_item") <> "<" <> Text(dimCount.toString) <> ">")
override val namespacePath = "sycl::nd_item"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/sycl/SYCLTNDRangeImpl.scala b/src/col/vct/col/ast/lang/sycl/SYCLTNDRangeImpl.scala
index c7ad4226d7..af20baed47 100644
--- a/src/col/vct/col/ast/lang/sycl/SYCLTNDRangeImpl.scala
+++ b/src/col/vct/col/ast/lang/sycl/SYCLTNDRangeImpl.scala
@@ -6,17 +6,33 @@ import vct.col.resolve.ctx.{CPPInvocationTarget, RefSYCLConstructorDefinition}
import vct.col.resolve.lang.Util
import vct.col.ast.ops.SYCLTNDRangeOps
-trait SYCLTNDRangeImpl[G] extends SYCLTNDRangeOps[G] { this: SYCLTNDRange[G] =>
+trait SYCLTNDRangeImpl[G] extends SYCLTNDRangeOps[G] {
+ this: SYCLTNDRange[G] =>
override def layout(implicit ctx: Ctx): Doc =
Group(Text("sycl::nd_range") <> "<" <> Text(dimCount.toString) <> ">")
override val namespacePath = "sycl::nd_range"
- def findConstructor(genericArgs: Seq[CPPExprOrTypeSpecifier[G]], args: Seq[Expr[G]]): Option[CPPInvocationTarget[G]] = genericArgs match {
- case Seq(CPPExprOrTypeSpecifier(Some(CIntegerValue(dim)), None)) if dim > 0 && dim <= 3 && Util.compatTypes(args, Seq(SYCLTRange[G](dim.toInt), SYCLTRange[G](dim.toInt))) => Some(RefSYCLConstructorDefinition(SYCLTNDRange(dim.toInt)))
- case Nil if Util.compatTypes(args, Seq(SYCLTRange[G](1), SYCLTRange[G](1))) => Some(RefSYCLConstructorDefinition(SYCLTNDRange(1)))
- case Nil if Util.compatTypes(args, Seq(SYCLTRange[G](2), SYCLTRange[G](2))) => Some(RefSYCLConstructorDefinition(SYCLTNDRange(2)))
- case Nil if Util.compatTypes(args, Seq(SYCLTRange[G](3), SYCLTRange[G](3))) => Some(RefSYCLConstructorDefinition(SYCLTNDRange(3)))
- case _ => None
- }
-}
\ No newline at end of file
+ def findConstructor(
+ genericArgs: Seq[CPPExprOrTypeSpecifier[G]],
+ args: Seq[Expr[G]],
+ ): Option[CPPInvocationTarget[G]] =
+ genericArgs match {
+ case Seq(CPPExprOrTypeSpecifier(Some(CIntegerValue(dim)), None))
+ if dim > 0 && dim <= 3 && Util.compatTypes(
+ args,
+ Seq(SYCLTRange[G](dim.toInt), SYCLTRange[G](dim.toInt)),
+ ) =>
+ Some(RefSYCLConstructorDefinition(SYCLTNDRange(dim.toInt)))
+ case Nil
+ if Util.compatTypes(args, Seq(SYCLTRange[G](1), SYCLTRange[G](1))) =>
+ Some(RefSYCLConstructorDefinition(SYCLTNDRange(1)))
+ case Nil
+ if Util.compatTypes(args, Seq(SYCLTRange[G](2), SYCLTRange[G](2))) =>
+ Some(RefSYCLConstructorDefinition(SYCLTNDRange(2)))
+ case Nil
+ if Util.compatTypes(args, Seq(SYCLTRange[G](3), SYCLTRange[G](3))) =>
+ Some(RefSYCLConstructorDefinition(SYCLTNDRange(3)))
+ case _ => None
+ }
+}
diff --git a/src/col/vct/col/ast/lang/sycl/SYCLTQueueImpl.scala b/src/col/vct/col/ast/lang/sycl/SYCLTQueueImpl.scala
index 2d9eae79b3..756c893701 100644
--- a/src/col/vct/col/ast/lang/sycl/SYCLTQueueImpl.scala
+++ b/src/col/vct/col/ast/lang/sycl/SYCLTQueueImpl.scala
@@ -4,8 +4,9 @@ import vct.col.ast.SYCLTQueue
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.SYCLTQueueOps
-trait SYCLTQueueImpl[G] extends SYCLTQueueOps[G] { this: SYCLTQueue[G] =>
+trait SYCLTQueueImpl[G] extends SYCLTQueueOps[G] {
+ this: SYCLTQueue[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("sycl::queue")
override val namespacePath = "sycl::queue"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/lang/sycl/SYCLTRangeImpl.scala b/src/col/vct/col/ast/lang/sycl/SYCLTRangeImpl.scala
index 5f195d10ae..11dcd9c241 100644
--- a/src/col/vct/col/ast/lang/sycl/SYCLTRangeImpl.scala
+++ b/src/col/vct/col/ast/lang/sycl/SYCLTRangeImpl.scala
@@ -6,17 +6,31 @@ import vct.col.resolve.ctx.{CPPInvocationTarget, RefSYCLConstructorDefinition}
import vct.col.resolve.lang.Util
import vct.col.ast.ops.SYCLTRangeOps
-trait SYCLTRangeImpl[G] extends SYCLTRangeOps[G] { this: SYCLTRange[G] =>
+trait SYCLTRangeImpl[G] extends SYCLTRangeOps[G] {
+ this: SYCLTRange[G] =>
override def layout(implicit ctx: Ctx): Doc =
Group(Text("sycl::range") <> "<" <> Text(dimCount.toString) <> ">")
val namespacePath = "sycl::range"
- def findConstructor(genericArgs: Seq[CPPExprOrTypeSpecifier[G]], args: Seq[Expr[G]]): Option[CPPInvocationTarget[G]] = genericArgs match {
- case Seq(CPPExprOrTypeSpecifier(Some(CIntegerValue(dim)), None)) if dim > 0 && dim <= 3 && Util.compatTypes(args, Seq.range(0, dim.toInt).map(_ => TCInt[G]())) => Some(RefSYCLConstructorDefinition(SYCLTRange(dim.toInt)))
- case Nil if Util.compatTypes(args, Seq(TCInt[G]())) => Some(RefSYCLConstructorDefinition(SYCLTRange(1)))
- case Nil if Util.compatTypes(args, Seq(TCInt[G](), TCInt[G]())) => Some(RefSYCLConstructorDefinition(SYCLTRange(2)))
- case Nil if Util.compatTypes(args, Seq(TCInt[G](), TCInt[G](), TCInt[G]())) => Some(RefSYCLConstructorDefinition(SYCLTRange(3)))
- case _ => None
- }
-}
\ No newline at end of file
+ def findConstructor(
+ genericArgs: Seq[CPPExprOrTypeSpecifier[G]],
+ args: Seq[Expr[G]],
+ ): Option[CPPInvocationTarget[G]] =
+ genericArgs match {
+ case Seq(CPPExprOrTypeSpecifier(Some(CIntegerValue(dim)), None))
+ if dim > 0 && dim <= 3 && Util.compatTypes(
+ args,
+ Seq.range(0, dim.toInt).map(_ => TCInt[G]()),
+ ) =>
+ Some(RefSYCLConstructorDefinition(SYCLTRange(dim.toInt)))
+ case Nil if Util.compatTypes(args, Seq(TCInt[G]())) =>
+ Some(RefSYCLConstructorDefinition(SYCLTRange(1)))
+ case Nil if Util.compatTypes(args, Seq(TCInt[G](), TCInt[G]())) =>
+ Some(RefSYCLConstructorDefinition(SYCLTRange(2)))
+ case Nil
+ if Util.compatTypes(args, Seq(TCInt[G](), TCInt[G](), TCInt[G]())) =>
+ Some(RefSYCLConstructorDefinition(SYCLTRange(3)))
+ case _ => None
+ }
+}
diff --git a/src/col/vct/col/ast/node/NodeFamilyImpl.scala b/src/col/vct/col/ast/node/NodeFamilyImpl.scala
index f757e761fd..c9c072850f 100644
--- a/src/col/vct/col/ast/node/NodeFamilyImpl.scala
+++ b/src/col/vct/col/ast/node/NodeFamilyImpl.scala
@@ -9,14 +9,17 @@ import vct.col.typerules.{CoercingRewriter, NopCoercingRewriter}
Marker trait to indicate this node, or this hierarchy of nodes, always rewrites to itself. This is for example for
Expr (which always rewrites to an Expr), but also single-purpose nodes, such as a catch clause.
*/
-trait NodeFamilyImpl[G] extends NodeImpl[G] { this: NodeFamily[G] =>
+trait NodeFamilyImpl[G] extends NodeImpl[G] {
+ this: NodeFamily[G] =>
override def check(context: CheckContext[G]): Seq[CheckError] =
try {
- NopCoercingRewriter().coerceAny(this.asInstanceOf[NodeFamily[InitialGeneration]])
+ NopCoercingRewriter()
+ .coerceAny(this.asInstanceOf[NodeFamily[InitialGeneration]])
Nil
} catch {
case CoercingRewriter.Incoercible(e, t) => Seq(TypeError(e, t))
case CoercingRewriter.IncoercibleText(e, m) => Seq(TypeErrorText(e, m))
- case CoercingRewriter.IncoercibleExplanation(e, m) => Seq(TypeErrorExplanation(e, m))
+ case CoercingRewriter.IncoercibleExplanation(e, m) =>
+ Seq(TypeErrorExplanation(e, m))
}
}
diff --git a/src/col/vct/col/ast/node/NodeImpl.scala b/src/col/vct/col/ast/node/NodeImpl.scala
index f71e70513e..a208fb098f 100644
--- a/src/col/vct/col/ast/node/NodeImpl.scala
+++ b/src/col/vct/col/ast/node/NodeImpl.scala
@@ -11,40 +11,48 @@ import vct.col.util.CurrentCheckNodeContext
import scala.runtime.ScalaRunTime
-/**
- * [[Node]] is the root type for all nodes in the abstract syntax tree. The family is sealed, meaning the compiler
- * guarantees that all node definitions occur in one file; Node.scala.
- *
- * Note that the structure of the Node file is restricted: helpers are generated based on the definitions in the file,
- * so you cannot write arbitrary code in the file. Please refer to the developer documentation in the
- * VerCors wiki for details.
- *
- * [[Node]] is subdivided into categories. The root of each category extends the marker trait [[NodeFamily]]; the code
- * generation looks for this trait to determine the node categories. Some of the bigger categories include:
- *
- *
- *
[[Type]] contains all the types that can be declared and stored, as well as some helper types.
- *
[[Statement]] contains nodes that are executable, and may change the state.
- *
[[Expr]] contains nodes that have a defined value and type, given a state.
- *
- *
- * The [[Declaration]] family has a special status, and is hence not marked as a [[NodeFamily]]. All direct descendants
- * of [[Declaration]] together constitute the "declaration kinds".
- *
- * For each node `equals` must be implemented in such a way that equality means they are semantically equivalent. For
- * most nodes that means simple structural equality, while for (references to) declarations this means identity
- * (reference) equality.
- *
- * @tparam G The generation marker: not used as a concrete type.
- */
-trait NodeImpl[G] extends Show { this: Node[G] =>
+/** [[Node]] is the root type for all nodes in the abstract syntax tree. The
+ * family is sealed, meaning the compiler guarantees that all node definitions
+ * occur in one file; Node.scala.
+ *
+ * Note that the structure of the Node file is restricted: helpers are
+ * generated based on the definitions in the file, so you cannot write
+ * arbitrary code in the file. Please refer to the developer documentation in
+ * the VerCors wiki
+ * for details.
+ *
+ * [[Node]] is subdivided into categories. The root of each category extends
+ * the marker trait [[NodeFamily]]; the code generation looks for this trait to
+ * determine the node categories. Some of the bigger categories include:
+ *
+ *
[[Type]] contains all the types that can be declared and stored, as
+ * well as some helper types.
[[Statement]] contains nodes that are
+ * executable, and may change the state.
[[Expr]] contains nodes that
+ * have a defined value and type, given a state.
+ *
+ * The [[Declaration]] family has a special status, and is hence not marked as
+ * a [[NodeFamily]]. All direct descendants of [[Declaration]] together
+ * constitute the "declaration kinds".
+ *
+ * For each node `equals` must be implemented in such a way that equality means
+ * they are semantically equivalent. For most nodes that means simple
+ * structural equality, while for (references to) declarations this means
+ * identity (reference) equality.
+ *
+ * @tparam G
+ * The generation marker: not used as a concrete type.
+ */
+trait NodeImpl[G] extends Show {
+ this: Node[G] =>
def check(context: CheckContext[G]): Seq[CheckError]
def o: Origin
def compare[G1](other: Node[G1]): LazyList[CompareResult[G, G1]]
def rewriteDefault[G1]()(implicit rw: AbstractRewriter[G, G1]): Node[G1]
def serialize(decls: Map[Declaration[G], Long]): scalapb.GeneratedMessage
- def serializeFamily(decls: Map[Declaration[G], Long]): scalapb.GeneratedMessage
+ def serializeFamily(
+ decls: Map[Declaration[G], Long]
+ ): scalapb.GeneratedMessage
final def enterCheckContext(context: CheckContext[G]): CheckContext[G] =
CheckContext(
@@ -61,42 +69,68 @@ trait NodeImpl[G] extends Show { this: Node[G] =>
enterCheckContextDeclarationStack(context),
)
- def enterCheckContextScopes(context: CheckContext[G]): Seq[CheckContext.ScopeFrame[G]] = context.scopes
- def enterCheckContextUndeclared(context: CheckContext[G]): Seq[Seq[Declaration[G]]] = context.undeclared
- def enterCheckContextRoScopes(context: CheckContext[G]): Int = context.roScopes
- def enterCheckContextRoScopeReason(context: CheckContext[G]): Option[Node[G]] = context.roScopeReason
- def enterCheckContextCurrentApplicable(context: CheckContext[G]): Option[Applicable[G]] = context.currentApplicable
- def enterCheckContextInPreCondition(context: CheckContext[G]): Boolean = context.inPreCondition
- def enterCheckContextInPostCondition(context: CheckContext[G]): Boolean = context.inPostCondition
- def enterCheckContextCurrentChoreography(context: CheckContext[G]): Option[Choreography[G]] = context.currentChoreography
- def enterCheckContextCurrentReceiverEndpoint(context: CheckContext[G]): Option[Endpoint[G]] = context.currentReceiverEndpoint
- def enterCheckContextCurrentParticipatingEndpoints(context: CheckContext[G]): Option[Set[Endpoint[G]]] = context.currentParticipatingEndpoints
- def enterCheckContextDeclarationStack(context: CheckContext[G]): Seq[Declaration[G]] = context.declarationStack
+ def enterCheckContextScopes(
+ context: CheckContext[G]
+ ): Seq[CheckContext.ScopeFrame[G]] = context.scopes
+ def enterCheckContextUndeclared(
+ context: CheckContext[G]
+ ): Seq[Seq[Declaration[G]]] = context.undeclared
+ def enterCheckContextRoScopes(context: CheckContext[G]): Int =
+ context.roScopes
+ def enterCheckContextRoScopeReason(
+ context: CheckContext[G]
+ ): Option[Node[G]] = context.roScopeReason
+ def enterCheckContextCurrentApplicable(
+ context: CheckContext[G]
+ ): Option[Applicable[G]] = context.currentApplicable
+ def enterCheckContextInPreCondition(context: CheckContext[G]): Boolean =
+ context.inPreCondition
+ def enterCheckContextInPostCondition(context: CheckContext[G]): Boolean =
+ context.inPostCondition
+ def enterCheckContextCurrentChoreography(
+ context: CheckContext[G]
+ ): Option[Choreography[G]] = context.currentChoreography
+ def enterCheckContextCurrentReceiverEndpoint(
+ context: CheckContext[G]
+ ): Option[Endpoint[G]] = context.currentReceiverEndpoint
+ def enterCheckContextCurrentParticipatingEndpoints(
+ context: CheckContext[G]
+ ): Option[Set[Endpoint[G]]] = context.currentParticipatingEndpoints
+ def enterCheckContextDeclarationStack(
+ context: CheckContext[G]
+ ): Seq[Declaration[G]] = context.declarationStack
/* Check children first, so that the check of nodes higher in the tree may depend on the type and correctness of
subnodes */
final def checkTrans(context: CheckContext[G]): Seq[CheckError] = {
- val childrenErrors = checkContextRecursor(context, (ctx, node) => node.checkTrans(ctx)).flatten
+ val childrenErrors =
+ checkContextRecursor(context, (ctx, node) => node.checkTrans(ctx)).flatten
- if(childrenErrors.nonEmpty) {
- childrenErrors
- } else {
+ if (childrenErrors.nonEmpty) { childrenErrors }
+ else {
VerificationError.withContext(CurrentCheckNodeContext(this)) {
check(context)
}
}
}
- /**
- * Applies a function to all subnodes, passing the appropriate context per subnode. By default, all subnodes get the
- * same context, as defined by [[enterCheckContext]]
- * @param context the initial context
- * @param f the function to apply to all subnodes
- * @tparam T the result type of the function
- * @return the result of applying `f` with the appropriate context per subnode to all subnodes
- */
- def checkContextRecursor[T](context: CheckContext[G], f: (CheckContext[G], Node[G]) => T): Seq[T] =
- subnodes.map(f(enterCheckContext(context), _))
+ /** Applies a function to all subnodes, passing the appropriate context per
+ * subnode. By default, all subnodes get the same context, as defined by
+ * [[enterCheckContext]]
+ * @param context
+ * the initial context
+ * @param f
+ * the function to apply to all subnodes
+ * @tparam T
+ * the result type of the function
+ * @return
+ * the result of applying `f` with the appropriate context per subnode to
+ * all subnodes
+ */
+ def checkContextRecursor[T](
+ context: CheckContext[G],
+ f: (CheckContext[G], Node[G]) => T,
+ ): Seq[T] = subnodes.map(f(enterCheckContext(context), _))
def subnodes: Seq[Node[G]]
@@ -118,8 +152,9 @@ trait NodeImpl[G] extends Show { this: Node[G] =>
def collect[T](f: PartialFunction[Node[G], T]): LazyList[T] =
transSubnodes.collect(f)
- def flatCollect[T](f: PartialFunction[Node[G], IterableOnce[T]]): LazyList[T] =
- transSubnodes.collect(f).flatten
+ def flatCollect[T](
+ f: PartialFunction[Node[G], IterableOnce[T]]
+ ): LazyList[T] = transSubnodes.collect(f).flatten
def collectFirst[T](f: PartialFunction[Node[G], T]): Option[T] =
collect(f).headOption
@@ -127,30 +162,46 @@ trait NodeImpl[G] extends Show { this: Node[G] =>
def exists[T](f: PartialFunction[Node[G], Boolean]): Boolean =
collectFirst(f).getOrElse(false)
- def unsafeTransmuteGeneration[TNode[_] <: Node[_], G2]
- (implicit witness: this.type <:< TNode[G])
- : TNode[G2] = (this : TNode[G]).asInstanceOf[TNode[G2]]
-
- private def debugLayout(x: scala.Any)(implicit ctx: Ctx): Doc = x match {
- case n: Node[_] => n.show
- case r: Ref[_, _] => Text("Ref(") <> ctx.name(r) <> ")"
- case o: scala.Option[scala.Any] if o.isEmpty => Text("None")
- case o: scala.Option[scala.Any] => Text("Some(") <> debugLayout(o.get) <> ")"
- case i: scala.Iterable[scala.Any] => Group(Text(i.getClass.getSimpleName) <> "(" <> Doc.args(i.map(debugLayout).toSeq) <> ")")
- case p: scala.Product => Group(Text(p.getClass.getSimpleName) <> "(" <> Doc.args(p.productIterator.map(debugLayout).toSeq) <> ")")
- case other => Text(other.toString)
- }
+ def unsafeTransmuteGeneration[TNode[_] <: Node[_], G2](
+ implicit witness: this.type <:< TNode[G]
+ ): TNode[G2] = (this: TNode[G]).asInstanceOf[TNode[G2]]
+
+ private def debugLayout(x: scala.Any)(implicit ctx: Ctx): Doc =
+ x match {
+ case n: Node[_] => n.show
+ case r: Ref[_, _] => Text("Ref(") <> ctx.name(r) <> ")"
+ case o: scala.Option[scala.Any] if o.isEmpty => Text("None")
+ case o: scala.Option[scala.Any] =>
+ Text("Some(") <> debugLayout(o.get) <> ")"
+ case i: scala.Iterable[scala.Any] =>
+ Group(
+ Text(i.getClass.getSimpleName) <> "(" <>
+ Doc.args(i.map(debugLayout).toSeq) <> ")"
+ )
+ case p: scala.Product =>
+ Group(
+ Text(p.getClass.getSimpleName) <> "(" <>
+ Doc.args(p.productIterator.map(debugLayout).toSeq) <> ")"
+ )
+ case other => Text(other.toString)
+ }
final def show(implicit ctx: Ctx): Doc = NodeDoc(this, layout)
- protected[this] def layout(implicit ctx: Ctx): Doc = this match {
- case p: scala.Product =>
- Group(Text(s"??${this.getClass.getSimpleName}??(") <> Doc.args(p.productIterator.map(debugLayout).toSeq) <> ")")
- case _ =>
- Group(Text(s"??${this.getClass.getSimpleName}??(") <> Doc.args(subnodes) <> ")")
- }
+ protected[this] def layout(implicit ctx: Ctx): Doc =
+ this match {
+ case p: scala.Product =>
+ Group(
+ Text(s"??${this.getClass.getSimpleName}??(") <>
+ Doc.args(p.productIterator.map(debugLayout).toSeq) <> ")"
+ )
+ case _ =>
+ Group(
+ Text(s"??${this.getClass.getSimpleName}??(") <> Doc.args(subnodes) <>
+ ")"
+ )
+ }
- override def toString: String =
- toStringWithContext(Ctx().namesIn(this))
+ override def toString: String = toStringWithContext(Ctx().namesIn(this))
def toInlineString: String = {
implicit val ctx = Ctx().namesIn(this).copy(width = Int.MaxValue)
@@ -164,4 +215,4 @@ trait NodeImpl[G] extends Show { this: Node[G] =>
NodeImpl.this.show.highlight(node).strip()
}
}
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/node/ProgramImpl.scala b/src/col/vct/col/ast/node/ProgramImpl.scala
index d5fb1cdd44..e17e0373c9 100644
--- a/src/col/vct/col/ast/node/ProgramImpl.scala
+++ b/src/col/vct/col/ast/node/ProgramImpl.scala
@@ -8,14 +8,18 @@ import vct.col.util.CurrentCheckProgramContext
import vct.result.VerificationError
import vct.col.ast.ops.{ProgramOps, ProgramFamilyOps}
-trait ProgramImpl[G] extends Declarator[G] with ProgramOps[G] with ProgramFamilyOps[G] { this: Program[G] =>
+trait ProgramImpl[G]
+ extends Declarator[G] with ProgramOps[G] with ProgramFamilyOps[G] {
+ this: Program[G] =>
def check: Seq[CheckError] = checkTrans(CheckContext())
- override def checkContextRecursor[T](context: CheckContext[G], f: (CheckContext[G], Node[G]) => T): Seq[T] =
+ override def checkContextRecursor[T](
+ context: CheckContext[G],
+ f: (CheckContext[G], Node[G]) => T,
+ ): Seq[T] =
VerificationError.withContext(CurrentCheckProgramContext(this)) {
super.checkContextRecursor(context, f)
}
- override def layout(implicit ctx: Ctx): Doc =
- Doc.stack(declarations)
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc = Doc.stack(declarations)
+}
diff --git a/src/col/vct/col/ast/node/VerificationContextImpl.scala b/src/col/vct/col/ast/node/VerificationContextImpl.scala
index 31e5e0ac7f..1f2bb67b26 100644
--- a/src/col/vct/col/ast/node/VerificationContextImpl.scala
+++ b/src/col/vct/col/ast/node/VerificationContextImpl.scala
@@ -4,6 +4,8 @@ import vct.col.ast.VerificationContext
import vct.col.print._
import vct.col.ast.ops.{VerificationContextOps, VerificationContextFamilyOps}
-trait VerificationContextImpl[G] extends VerificationContextOps[G] with VerificationContextFamilyOps[G] { this: VerificationContext[G] =>
+trait VerificationContextImpl[G]
+ extends VerificationContextOps[G] with VerificationContextFamilyOps[G] {
+ this: VerificationContext[G] =>
override def layout(implicit ctx: Ctx): Doc = program.show
}
diff --git a/src/col/vct/col/ast/node/VerificationImpl.scala b/src/col/vct/col/ast/node/VerificationImpl.scala
index a0e4d76331..f5cf293f62 100644
--- a/src/col/vct/col/ast/node/VerificationImpl.scala
+++ b/src/col/vct/col/ast/node/VerificationImpl.scala
@@ -5,12 +5,16 @@ import vct.col.check.{CheckContext, CheckError}
import vct.col.print._
import vct.col.ast.ops.{VerificationOps, VerificationFamilyOps}
-trait VerificationImpl[G] extends VerificationOps[G] with VerificationFamilyOps[G] { this: Verification[G] =>
+trait VerificationImpl[G]
+ extends VerificationOps[G] with VerificationFamilyOps[G] {
+ this: Verification[G] =>
def check: Seq[CheckError] = checkTrans(CheckContext())
override def layout(implicit ctx: Ctx): Doc =
- if(tasks.size == 1) tasks.head.show
- else Doc.stack(tasks.zipWithIndex.map {
- case (task, i) => Text(s"/* Verification task ${i+1} */") <+/> task.show
- })
+ if (tasks.size == 1)
+ tasks.head.show
+ else
+ Doc.stack(tasks.zipWithIndex.map { case (task, i) =>
+ Text(s"/* Verification task ${i + 1} */") <+/> task.show
+ })
}
diff --git a/src/col/vct/col/ast/statement/StatementImpl.scala b/src/col/vct/col/ast/statement/StatementImpl.scala
index 1108745d7d..45cede57fe 100644
--- a/src/col/vct/col/ast/statement/StatementImpl.scala
+++ b/src/col/vct/col/ast/statement/StatementImpl.scala
@@ -6,7 +6,8 @@ import vct.col.check.{CheckContext, CheckError, SeqProgStatement}
import vct.col.print._
import vct.col.ast.ops.StatementFamilyOps
-trait StatementImpl[G] extends NodeFamilyImpl[G] with StatementFamilyOps[G] { this: Statement[G] =>
+trait StatementImpl[G] extends NodeFamilyImpl[G] with StatementFamilyOps[G] {
+ this: Statement[G] =>
def layoutAsBlock(implicit ctx: Ctx): Doc =
Text("{") <>> foldBlock(_ <+/> _) <+/> "}"
diff --git a/src/col/vct/col/ast/statement/behavior/ExpressionContainerStatementImpl.scala b/src/col/vct/col/ast/statement/behavior/ExpressionContainerStatementImpl.scala
index b9e503bccb..1e30f37219 100644
--- a/src/col/vct/col/ast/statement/behavior/ExpressionContainerStatementImpl.scala
+++ b/src/col/vct/col/ast/statement/behavior/ExpressionContainerStatementImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.statement.behavior
import vct.col.ast.{Expr, ExpressionContainerStatement}
import vct.col.ast.statement.StatementImpl
-trait ExpressionContainerStatementImpl[G] extends StatementImpl[G] { this: ExpressionContainerStatement[G] =>
+trait ExpressionContainerStatementImpl[G] extends StatementImpl[G] {
+ this: ExpressionContainerStatement[G] =>
def expr: Expr[G]
}
diff --git a/src/col/vct/col/ast/statement/composite/BlockImpl.scala b/src/col/vct/col/ast/statement/composite/BlockImpl.scala
index bf3a095fbe..99f837d785 100644
--- a/src/col/vct/col/ast/statement/composite/BlockImpl.scala
+++ b/src/col/vct/col/ast/statement/composite/BlockImpl.scala
@@ -4,7 +4,9 @@ import vct.col.ast.Block
import vct.col.print._
import vct.col.ast.ops.BlockOps
-trait BlockImpl[G] extends BlockOps[G] { this: Block[G] =>
+trait BlockImpl[G] extends BlockOps[G] {
+ this: Block[G] =>
override def layout(implicit ctx: Ctx): Doc = layoutAsBlock
- override def foldBlock(f: (Doc, Doc) => Doc)(implicit ctx: Ctx): Doc = NodeDoc(this, Doc.fold(statements.map(_.foldBlock(f)))(f))
-}
\ No newline at end of file
+ override def foldBlock(f: (Doc, Doc) => Doc)(implicit ctx: Ctx): Doc =
+ NodeDoc(this, Doc.fold(statements.map(_.foldBlock(f)))(f))
+}
diff --git a/src/col/vct/col/ast/statement/composite/BranchImpl.scala b/src/col/vct/col/ast/statement/composite/BranchImpl.scala
index fa89d40e01..ed9398829e 100644
--- a/src/col/vct/col/ast/statement/composite/BranchImpl.scala
+++ b/src/col/vct/col/ast/statement/composite/BranchImpl.scala
@@ -4,12 +4,13 @@ import vct.col.ast.{Branch, BooleanValue}
import vct.col.print._
import vct.col.ast.ops.BranchOps
-trait BranchImpl[G] extends BranchOps[G] { this: Branch[G] =>
+trait BranchImpl[G] extends BranchOps[G] {
+ this: Branch[G] =>
override def layout(implicit ctx: Ctx): Doc =
Doc.fold(branches.zipWithIndex.map {
- case ((BooleanValue(true), body), i) if i == branches.size-1 =>
+ case ((BooleanValue(true), body), i) if i == branches.size - 1 =>
body.layoutAsBlock
case ((cond, body), _) =>
Group(Text("if (") <> Doc.arg(cond) <> ")") <+> body.layoutAsBlock
})(_ <+> "else" <+> _)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/statement/composite/CompositeStatementImpl.scala b/src/col/vct/col/ast/statement/composite/CompositeStatementImpl.scala
index 11cd77b0f3..674e1137c7 100644
--- a/src/col/vct/col/ast/statement/composite/CompositeStatementImpl.scala
+++ b/src/col/vct/col/ast/statement/composite/CompositeStatementImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.statement.composite
import vct.col.ast.CompositeStatement
-trait CompositeStatementImpl[G] { this: CompositeStatement[G] =>
+trait CompositeStatementImpl[G] {
+ this: CompositeStatement[G] =>
}
diff --git a/src/col/vct/col/ast/statement/composite/IndetBranchImpl.scala b/src/col/vct/col/ast/statement/composite/IndetBranchImpl.scala
index 3bf37e543e..2493be3f1d 100644
--- a/src/col/vct/col/ast/statement/composite/IndetBranchImpl.scala
+++ b/src/col/vct/col/ast/statement/composite/IndetBranchImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.ops.IndetBranchOps
import vct.col.ast.statement.StatementImpl
import vct.col.print._
-trait IndetBranchImpl[G] extends StatementImpl[G] with IndetBranchOps[G] { this: IndetBranch[G] =>
+trait IndetBranchImpl[G] extends StatementImpl[G] with IndetBranchOps[G] {
+ this: IndetBranch[G] =>
override def foldBlock(f: (Doc, Doc) => Doc)(implicit ctx: Ctx): Doc =
branches match {
case Seq(branch) => NodeDoc(this, branch.foldBlock(f))
@@ -14,9 +15,7 @@ trait IndetBranchImpl[G] extends StatementImpl[G] with IndetBranchOps[G] { this:
override def layout(implicit ctx: Ctx): Doc =
Doc.fold(branches.zipWithIndex.map {
- case (branch, i) if i == branches.size - 1 =>
- branch.layoutAsBlock
- case (branch, _) =>
- Text("if(*)") <+> branch.layoutAsBlock
+ case (branch, i) if i == branches.size - 1 => branch.layoutAsBlock
+ case (branch, _) => Text("if(*)") <+> branch.layoutAsBlock
})(_ <+> "else" <+> _)
}
diff --git a/src/col/vct/col/ast/statement/composite/LoopImpl.scala b/src/col/vct/col/ast/statement/composite/LoopImpl.scala
index de4751be5e..a8b06b176b 100644
--- a/src/col/vct/col/ast/statement/composite/LoopImpl.scala
+++ b/src/col/vct/col/ast/statement/composite/LoopImpl.scala
@@ -10,26 +10,38 @@ import vct.col.util.AstBuildHelpers._
import vct.result.VerificationError.UserError
object LoopImpl {
- case class InvalidLoopFormatForIterationContract(loop: Loop[_], message: String) extends UserError {
+ case class InvalidLoopFormatForIterationContract(
+ loop: Loop[_],
+ message: String,
+ ) extends UserError {
override def code: String = "invalidIterationLoop"
override def text: String =
- loop.o.messageInContext(s"This loop has an iteration contract, but $message.")
+ loop.o
+ .messageInContext(s"This loop has an iteration contract, but $message.")
}
- case class IterationContractData[G](v: Variable[G], lowerBound: Expr[G], upperBound: Expr[G])
+ case class IterationContractData[G](
+ v: Variable[G],
+ lowerBound: Expr[G],
+ upperBound: Expr[G],
+ )
}
-trait LoopImpl[G] extends LoopOps[G] { this: Loop[G] =>
+trait LoopImpl[G] extends LoopOps[G] {
+ this: Loop[G] =>
import LoopImpl._
- def getVariableAndLowerBound(implicit o: Origin): Option[(Variable[G], Expr[G])] =
+ def getVariableAndLowerBound(
+ implicit o: Origin
+ ): Option[(Variable[G], Expr[G])] =
init match {
- case Block(Seq(Assign(Local(Ref(v)), low))) =>
- Some((v, low))
+ case Block(Seq(Assign(Local(Ref(v)), low))) => Some((v, low))
case _ => None
}
- def getExclusiveUpperBound(v: Variable[G])(implicit o: Origin): Option[Expr[G]] =
+ def getExclusiveUpperBound(
+ v: Variable[G]
+ )(implicit o: Origin): Option[Expr[G]] =
cond match {
case Less(Local(Ref(`v`)), high) => Some(high)
case LessEq(Local(Ref(`v`)), high) => Some(high + const(1))
@@ -41,78 +53,108 @@ trait LoopImpl[G] extends LoopOps[G] { this: Loop[G] =>
def doesIncrement(v: Variable[G], update: Statement[G] = update): Boolean =
update match {
case Block(Seq(s)) => doesIncrement(v, s)
- case Assign(Local(Ref(`v`)), Plus(Local(Ref(`v`)), IntegerValue(ONE))) => true
- case Eval(PostAssignExpression(Local(Ref(`v`)), Plus(Local(Ref(`v`)), IntegerValue(ONE)))) => true
+ case Assign(Local(Ref(`v`)), Plus(Local(Ref(`v`)), IntegerValue(ONE))) =>
+ true
+ case Eval(
+ PostAssignExpression(
+ Local(Ref(`v`)),
+ Plus(Local(Ref(`v`)), IntegerValue(ONE)),
+ )
+ ) =>
+ true
case _ => false
}
- def getIterationContractData(implicit o: Origin): Either[InvalidLoopFormatForIterationContract, IterationContractData[G]] = {
+ def getIterationContractData(
+ implicit o: Origin
+ ): Either[InvalidLoopFormatForIterationContract, IterationContractData[G]] = {
val (v, low) = getVariableAndLowerBound.getOrElse(
- return Left(InvalidLoopFormatForIterationContract(this,
- "we could not derive the iteration variable or its lower bound from the initialization portion of the loop")))
+ return Left(InvalidLoopFormatForIterationContract(
+ this,
+ "we could not derive the iteration variable or its lower bound from the initialization portion of the loop",
+ ))
+ )
val high = getExclusiveUpperBound(v).getOrElse(
- return Left(InvalidLoopFormatForIterationContract(this,
- "we could not derive an upper bound for the iteration variable from the condition")))
-
- if(!doesIncrement(v))
- return Left(InvalidLoopFormatForIterationContract(this,
- "we could not ascertain that the iteration variable is incremented by one each iteration"))
+ return Left(InvalidLoopFormatForIterationContract(
+ this,
+ "we could not derive an upper bound for the iteration variable from the condition",
+ ))
+ )
+
+ if (!doesIncrement(v))
+ return Left(InvalidLoopFormatForIterationContract(
+ this,
+ "we could not ascertain that the iteration variable is incremented by one each iteration",
+ ))
Right(IterationContractData(v, low, high))
}
def layoutSilver(implicit ctx: Ctx): Doc =
- Doc.stack(Seq(
- Group(Text("while") <+> "(" <> Doc.arg(cond) <> ")"),
- contract,
- )) <+> body.layoutAsBlock
+ Doc.stack(
+ Seq(Group(Text("while") <+> "(" <> Doc.arg(cond) <> ")"), contract)
+ ) <+> body.layoutAsBlock
def layoutGeneric(implicit ctx: Ctx): Doc =
- if(init == Block[G](Nil) && update == Block[G](Nil)) layoutGenericWhile
- else layoutGenericFor
+ if (init == Block[G](Nil) && update == Block[G](Nil))
+ layoutGenericWhile
+ else
+ layoutGenericFor
def layoutGenericWhile(implicit ctx: Ctx): Doc =
Doc.stack(Seq(
contract,
- Group(Text("while") <+> "(" <> Doc.arg(cond) <> ")") <+> body.layoutAsBlock
+ Group(Text("while") <+> "(" <> Doc.arg(cond) <> ")") <+>
+ body.layoutAsBlock,
))
- def simpleControlElements(stat: Statement[G])(implicit ctx: Ctx): Option[Doc] = stat match {
- case Eval(e) => Some(e.show)
- case a: Assign[G] => Some(a.layoutAsExpr)
- case e: VeyMontAssignExpression[G] => simpleControlElements(e.assign)
- case e: CommunicateX[G] => simpleControlElements(e.assign)
- case LocalDecl(local) => Some(local.show)
- case JavaLocalDeclarationStatement(local) => Some(local.show)
-
- case Block(stats) =>
- stats
- .map(simpleControlElements(_))
- .foldLeft[Option[Seq[Doc]]](Some(Nil)) {
- case (Some(acc), Some(more)) => Some(acc :+ more)
- case (_, _) => None
- }
- .map(elems => NodeDoc(stat, Doc.fold(elems)(_ <> "," <+/> _)))
-
- case _ => None
- }
+ def simpleControlElements(
+ stat: Statement[G]
+ )(implicit ctx: Ctx): Option[Doc] =
+ stat match {
+ case Eval(e) => Some(e.show)
+ case a: Assign[G] => Some(a.layoutAsExpr)
+ case e: VeyMontAssignExpression[G] => simpleControlElements(e.assign)
+ case e: CommunicateX[G] => simpleControlElements(e.assign)
+ case LocalDecl(local) => Some(local.show)
+ case JavaLocalDeclarationStatement(local) => Some(local.show)
+
+ case Block(stats) =>
+ stats.map(simpleControlElements(_))
+ .foldLeft[Option[Seq[Doc]]](Some(Nil)) {
+ case (Some(acc), Some(more)) => Some(acc :+ more)
+ case (_, _) => None
+ }.map(elems => NodeDoc(stat, Doc.fold(elems)(_ <> "," <+/> _)))
+
+ case _ => None
+ }
def layoutControl(stat: Statement[G])(implicit ctx: Ctx): Doc =
- simpleControlElements(stat).map(doc => Group(Doc.arg(doc))).getOrElse(stat.show)
+ simpleControlElements(stat).map(doc => Group(Doc.arg(doc)))
+ .getOrElse(stat.show)
def layoutGenericFor(implicit ctx: Ctx): Doc =
Doc.stack(Seq(
contract,
- Group(Text("for") <+> "(" <> Nest(NonWsLine <>
- (if(init == Block[G](Nil)) Text(";") else layoutControl(init) <> ";" <+/> print.Empty) <>
- cond <> ";" <>
- (if(update == Block[G](Nil)) print.Empty else print.Empty <+/> layoutControl(update))
- ) > ")") <+> body.layoutAsBlock
+ Group(
+ Text("for") <+> "(" <> Nest(
+ NonWsLine <>
+ (if (init == Block[G](Nil))
+ Text(";")
+ else
+ layoutControl(init) <> ";" <+/> print.Empty) <> cond <> ";" <>
+ (if (update == Block[G](Nil))
+ print.Empty
+ else
+ print.Empty <+/> layoutControl(update))
+ ) > ")"
+ ) <+> body.layoutAsBlock,
))
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.Silver => layoutSilver
- case _ => layoutGeneric
- }
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.Silver => layoutSilver
+ case _ => layoutGeneric
+ }
+}
diff --git a/src/col/vct/col/ast/statement/composite/ModelDoImpl.scala b/src/col/vct/col/ast/statement/composite/ModelDoImpl.scala
index 03bf8f692f..aef4baa657 100644
--- a/src/col/vct/col/ast/statement/composite/ModelDoImpl.scala
+++ b/src/col/vct/col/ast/statement/composite/ModelDoImpl.scala
@@ -4,7 +4,10 @@ import vct.col.ast.ModelDo
import vct.col.print._
import vct.col.ast.ops.ModelDoOps
-trait ModelDoImpl[G] extends ModelDoOps[G] { this: ModelDo[G] =>
+trait ModelDoImpl[G] extends ModelDoOps[G] {
+ this: ModelDo[G] =>
override def layout(implicit ctx: Ctx): Doc =
- Group(Text("action(") <> Doc.args(Seq(model, perm, after, action)) <> ")") <+> impl.layoutAsBlock
-}
\ No newline at end of file
+ Group(
+ Text("action(") <> Doc.args(Seq(model, perm, after, action)) <> ")"
+ ) <+> impl.layoutAsBlock
+}
diff --git a/src/col/vct/col/ast/statement/composite/ParAtomicImpl.scala b/src/col/vct/col/ast/statement/composite/ParAtomicImpl.scala
index 4891731511..54a3af1477 100644
--- a/src/col/vct/col/ast/statement/composite/ParAtomicImpl.scala
+++ b/src/col/vct/col/ast/statement/composite/ParAtomicImpl.scala
@@ -5,10 +5,12 @@ import vct.col.check.{CheckContext, CheckError}
import vct.col.print.{Ctx, Doc, Group, Text}
import vct.col.ast.ops.ParAtomicOps
-trait ParAtomicImpl[G] extends ParAtomicOps[G] { this: ParAtomic[G] =>
+trait ParAtomicImpl[G] extends ParAtomicOps[G] {
+ this: ParAtomic[G] =>
override def check(context: CheckContext[G]): Seq[CheckError] =
inv.flatMap(context.checkInScope(this, _))
override def layout(implicit ctx: Ctx): Doc =
- Group(Text("atomic(") <> Doc.args(inv.map(ctx.name).map(Text)) <> ")") <+> content.layoutAsBlock
-}
\ No newline at end of file
+ Group(Text("atomic(") <> Doc.args(inv.map(ctx.name).map(Text)) <> ")") <+>
+ content.layoutAsBlock
+}
diff --git a/src/col/vct/col/ast/statement/composite/ParBarrierImpl.scala b/src/col/vct/col/ast/statement/composite/ParBarrierImpl.scala
index 4e6232e9fa..c239be7f5e 100644
--- a/src/col/vct/col/ast/statement/composite/ParBarrierImpl.scala
+++ b/src/col/vct/col/ast/statement/composite/ParBarrierImpl.scala
@@ -4,9 +4,12 @@ import vct.col.ast.ParBarrier
import vct.col.print.{Ctx, Doc, Empty, Text}
import vct.col.ast.ops.ParBarrierOps
-trait ParBarrierImpl[G] extends ParBarrierOps[G] { this: ParBarrier[G] =>
+trait ParBarrierImpl[G] extends ParBarrierOps[G] {
+ this: ParBarrier[G] =>
override def layout(implicit ctx: Ctx): Doc =
Text("barrier(") <> ctx.name(block) <>
- (if(invs.nonEmpty) Text(";") <+> Doc.args(invs.map(ctx.name).map(Text)) else Empty) <> ")" <+>
- content.layoutAsBlock
-}
\ No newline at end of file
+ (if (invs.nonEmpty)
+ Text(";") <+> Doc.args(invs.map(ctx.name).map(Text))
+ else
+ Empty) <> ")" <+> content.layoutAsBlock
+}
diff --git a/src/col/vct/col/ast/statement/composite/ParInvariantImpl.scala b/src/col/vct/col/ast/statement/composite/ParInvariantImpl.scala
index 5a1470d9e8..1704c7b4ce 100644
--- a/src/col/vct/col/ast/statement/composite/ParInvariantImpl.scala
+++ b/src/col/vct/col/ast/statement/composite/ParInvariantImpl.scala
@@ -5,9 +5,12 @@ import vct.col.ast.{Declaration, ParInvariant}
import vct.col.print.{Ctx, Doc, Group, Text}
import vct.col.ast.ops.ParInvariantOps
-trait ParInvariantImpl[G] extends Declarator[G] with ParInvariantOps[G] { this: ParInvariant[G] =>
+trait ParInvariantImpl[G] extends Declarator[G] with ParInvariantOps[G] {
+ this: ParInvariant[G] =>
override def declarations: Seq[Declaration[G]] = Seq(decl)
override def layout(implicit ctx: Ctx): Doc =
- Group(Text("invariant") <+> ctx.name(decl) <> "(" <> Doc.arg(inv) <> ")") <+> content.layoutAsBlock
-}
\ No newline at end of file
+ Group(
+ Text("invariant") <+> ctx.name(decl) <> "(" <> Doc.arg(inv) <> ")"
+ ) <+> content.layoutAsBlock
+}
diff --git a/src/col/vct/col/ast/statement/composite/ParStatementImpl.scala b/src/col/vct/col/ast/statement/composite/ParStatementImpl.scala
index 27bb9e656e..5f400d5bcd 100644
--- a/src/col/vct/col/ast/statement/composite/ParStatementImpl.scala
+++ b/src/col/vct/col/ast/statement/composite/ParStatementImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.ParStatement
import vct.col.print.{Ctx, Doc, Group, Text}
import vct.col.ast.ops.ParStatementOps
-trait ParStatementImpl[G] extends ParStatementOps[G] { this: ParStatement[G] =>
+trait ParStatementImpl[G] extends ParStatementOps[G] {
+ this: ParStatement[G] =>
override def layout(implicit ctx: Ctx): Doc = impl.show
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/statement/composite/RangedForImpl.scala b/src/col/vct/col/ast/statement/composite/RangedForImpl.scala
index 1af3e4e362..e9867e342e 100644
--- a/src/col/vct/col/ast/statement/composite/RangedForImpl.scala
+++ b/src/col/vct/col/ast/statement/composite/RangedForImpl.scala
@@ -4,12 +4,12 @@ import vct.col.ast.{Declaration, RangedFor}
import vct.col.print._
import vct.col.ast.ops.RangedForOps
-trait RangedForImpl[G] extends RangedForOps[G] { this: RangedFor[G] =>
+trait RangedForImpl[G] extends RangedForOps[G] {
+ this: RangedFor[G] =>
override def declarations: Seq[Declaration[G]] = Seq(iter.variable)
override def layout(implicit ctx: Ctx): Doc =
- Doc.stack(Seq(
- contract.show,
- Group(Text("for") <> "(" <> Doc.arg(iter) <> ")"),
- )) <+> body.layoutAsBlock
+ Doc.stack(
+ Seq(contract.show, Group(Text("for") <> "(" <> Doc.arg(iter) <> ")"))
+ ) <+> body.layoutAsBlock
}
diff --git a/src/col/vct/col/ast/statement/composite/ScopeImpl.scala b/src/col/vct/col/ast/statement/composite/ScopeImpl.scala
index bb0301ba51..64a3a7c6a6 100644
--- a/src/col/vct/col/ast/statement/composite/ScopeImpl.scala
+++ b/src/col/vct/col/ast/statement/composite/ScopeImpl.scala
@@ -9,15 +9,22 @@ import vct.col.ast.ops.ScopeOps
trait ScopeImpl[G] extends ScopeOps[G] {
this: Scope[G] =>
- override def enterCheckContextScopes(context: CheckContext[G]): Seq[CheckContext.ScopeFrame[G]] =
+ override def enterCheckContextScopes(
+ context: CheckContext[G]
+ ): Seq[CheckContext.ScopeFrame[G]] =
context.withScope(locals, toScan = Seq(body))
override def layout(implicit ctx: Ctx): Doc = layoutAsBlock
override def foldBlock(f: (Doc, Doc) => Doc)(implicit ctx: Ctx): Doc =
- NodeDoc(this,
- Doc.fold(locals.map(local => ctx.syntax match {
- case Ctx.Silver => Text("var") <+> local
- case _ => local.show <> ";"
- }) :+ body.foldBlock(f))(f)
+ NodeDoc(
+ this,
+ Doc.fold(
+ locals.map(local =>
+ ctx.syntax match {
+ case Ctx.Silver => Text("var") <+> local
+ case _ => local.show <> ";"
+ }
+ ) :+ body.foldBlock(f)
+ )(f),
)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/statement/composite/SwitchImpl.scala b/src/col/vct/col/ast/statement/composite/SwitchImpl.scala
index 64d19a6744..7790c66b4e 100644
--- a/src/col/vct/col/ast/statement/composite/SwitchImpl.scala
+++ b/src/col/vct/col/ast/statement/composite/SwitchImpl.scala
@@ -6,14 +6,17 @@ import vct.col.print._
import scala.annotation.tailrec
import vct.col.ast.ops.SwitchOps
-trait SwitchImpl[G] extends SwitchOps[G] { this: Switch[G] =>
- def isCase(s: Show): Boolean = s match {
- case DefaultCase() | Case(_) => true
- case _ => false
- }
+trait SwitchImpl[G] extends SwitchOps[G] {
+ this: Switch[G] =>
+ def isCase(s: Show): Boolean =
+ s match {
+ case DefaultCase() | Case(_) => true
+ case _ => false
+ }
def isNotCase(s: Show): Boolean = !isCase(s)
override def layout(implicit ctx: Ctx): Doc =
- Group(Text("switch") <+> "(" <> Doc.arg(expr) <> ")") <+> "{" <>> body.foldBlock(_ <+/> _) <+/> "}"
-}
\ No newline at end of file
+ Group(Text("switch") <+> "(" <> Doc.arg(expr) <> ")") <+> "{" <>>
+ body.foldBlock(_ <+/> _) <+/> "}"
+}
diff --git a/src/col/vct/col/ast/statement/composite/SynchronizedImpl.scala b/src/col/vct/col/ast/statement/composite/SynchronizedImpl.scala
index 2f68dd7b8d..0b8b2341fc 100644
--- a/src/col/vct/col/ast/statement/composite/SynchronizedImpl.scala
+++ b/src/col/vct/col/ast/statement/composite/SynchronizedImpl.scala
@@ -4,7 +4,9 @@ import vct.col.ast.Synchronized
import vct.col.print._
import vct.col.ast.ops.SynchronizedOps
-trait SynchronizedImpl[G] extends SynchronizedOps[G] { this: Synchronized[G] =>
+trait SynchronizedImpl[G] extends SynchronizedOps[G] {
+ this: Synchronized[G] =>
override def layout(implicit ctx: Ctx): Doc =
- Group(Text("synchronized") <+> "(" <> Doc.arg(obj) <> ")") <+> body.layoutAsBlock
-}
\ No newline at end of file
+ Group(Text("synchronized") <+> "(" <> Doc.arg(obj) <> ")") <+>
+ body.layoutAsBlock
+}
diff --git a/src/col/vct/col/ast/statement/composite/TryCatchFinallyImpl.scala b/src/col/vct/col/ast/statement/composite/TryCatchFinallyImpl.scala
index 477a39a4e2..667973d7fb 100644
--- a/src/col/vct/col/ast/statement/composite/TryCatchFinallyImpl.scala
+++ b/src/col/vct/col/ast/statement/composite/TryCatchFinallyImpl.scala
@@ -7,15 +7,14 @@ import vct.col.print._
import vct.col.typerules.Types
import vct.col.ast.ops.TryCatchFinallyOps
-trait TryCatchFinallyImpl[G] extends NodeFamilyImpl[G] with TryCatchFinallyOps[G] { this: TryCatchFinally[G] =>
+trait TryCatchFinallyImpl[G]
+ extends NodeFamilyImpl[G] with TryCatchFinallyOps[G] {
+ this: TryCatchFinally[G] =>
def checkOverlappingCatches: Seq[CheckError] = {
- this.catches.foldLeft[Type[G]](TNothing()) {
- case (caughtAlready, clause) =>
- if(caughtAlready.superTypeOf(clause.decl.t)) {
- return Seq(RedundantCatchClause(clause))
- } else {
- Types.leastCommonSuperType(caughtAlready, clause.decl.t)
- }
+ this.catches.foldLeft[Type[G]](TNothing()) { case (caughtAlready, clause) =>
+ if (caughtAlready.superTypeOf(clause.decl.t)) {
+ return Seq(RedundantCatchClause(clause))
+ } else { Types.leastCommonSuperType(caughtAlready, clause.decl.t) }
}
Nil
}
@@ -27,6 +26,9 @@ trait TryCatchFinallyImpl[G] extends NodeFamilyImpl[G] with TryCatchFinallyOps[G
Doc.spread(Seq(
Text("try") <+> body.layoutAsBlock,
Doc.spread(catches),
- if(after == Block[G](Nil)) Empty else Text("finally") <+> after.layoutAsBlock
+ if (after == Block[G](Nil))
+ Empty
+ else
+ Text("finally") <+> after.layoutAsBlock,
))
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/statement/composite/VecBlockImpl.scala b/src/col/vct/col/ast/statement/composite/VecBlockImpl.scala
index fac73fd9b0..b01eb45b4a 100644
--- a/src/col/vct/col/ast/statement/composite/VecBlockImpl.scala
+++ b/src/col/vct/col/ast/statement/composite/VecBlockImpl.scala
@@ -5,7 +5,8 @@ import vct.col.ast.{Declaration, VecBlock}
import vct.col.print._
import vct.col.ast.ops.VecBlockOps
-trait VecBlockImpl[G] extends Declarator[G] with VecBlockOps[G] { this: VecBlock[G] =>
+trait VecBlockImpl[G] extends Declarator[G] with VecBlockOps[G] {
+ this: VecBlock[G] =>
override def declarations: Seq[Declaration[G]] = iters.map(_.variable)
override def layout(implicit ctx: Ctx): Doc =
@@ -14,4 +15,4 @@ trait VecBlockImpl[G] extends Declarator[G] with VecBlockOps[G] { this: VecBlock
DocUtil.clauses("requires", requires),
DocUtil.clauses("ensures", ensures),
)) <+> content.layoutAsBlock
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/statement/composite/WandPackageImpl.scala b/src/col/vct/col/ast/statement/composite/WandPackageImpl.scala
index 49c9c47157..65649d1a00 100644
--- a/src/col/vct/col/ast/statement/composite/WandPackageImpl.scala
+++ b/src/col/vct/col/ast/statement/composite/WandPackageImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.WandPackage
import vct.col.print._
import vct.col.ast.ops.WandPackageOps
-trait WandPackageImpl[G] extends WandPackageOps[G] { this: WandPackage[G] =>
+trait WandPackageImpl[G] extends WandPackageOps[G] {
+ this: WandPackage[G] =>
override def layout(implicit ctx: Ctx): Doc =
Group(Text("package") <>> res) <+> proof.layoutAsBlock
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/statement/exceptional/BreakImpl.scala b/src/col/vct/col/ast/statement/exceptional/BreakImpl.scala
index 7a5aeea069..a17ca2af5f 100644
--- a/src/col/vct/col/ast/statement/exceptional/BreakImpl.scala
+++ b/src/col/vct/col/ast/statement/exceptional/BreakImpl.scala
@@ -4,7 +4,12 @@ import vct.col.ast.Break
import vct.col.print.{Ctx, Doc, Empty, Text}
import vct.col.ast.ops.BreakOps
-trait BreakImpl[G] extends BreakOps[G] { this: Break[G] =>
+trait BreakImpl[G] extends BreakOps[G] {
+ this: Break[G] =>
override def layout(implicit ctx: Ctx): Doc =
- Text("break") <> (if(label.isEmpty) Empty else Empty <+> ctx.name(label.get)) <> ";"
-}
\ No newline at end of file
+ Text("break") <>
+ (if (label.isEmpty)
+ Empty
+ else
+ Empty <+> ctx.name(label.get)) <> ";"
+}
diff --git a/src/col/vct/col/ast/statement/exceptional/ContinueImpl.scala b/src/col/vct/col/ast/statement/exceptional/ContinueImpl.scala
index a43615db38..7746c338b8 100644
--- a/src/col/vct/col/ast/statement/exceptional/ContinueImpl.scala
+++ b/src/col/vct/col/ast/statement/exceptional/ContinueImpl.scala
@@ -4,7 +4,12 @@ import vct.col.ast.Continue
import vct.col.print.{Ctx, Doc, Empty, Text}
import vct.col.ast.ops.ContinueOps
-trait ContinueImpl[G] extends ContinueOps[G] { this: Continue[G] =>
+trait ContinueImpl[G] extends ContinueOps[G] {
+ this: Continue[G] =>
override def layout(implicit ctx: Ctx): Doc =
- Text("continue") <> (if (label.isEmpty) Empty else Empty <+> ctx.name(label.get)) <> ";"
-}
\ No newline at end of file
+ Text("continue") <>
+ (if (label.isEmpty)
+ Empty
+ else
+ Empty <+> ctx.name(label.get)) <> ";"
+}
diff --git a/src/col/vct/col/ast/statement/exceptional/EvalImpl.scala b/src/col/vct/col/ast/statement/exceptional/EvalImpl.scala
index 3ab5cf9eb5..9303605581 100644
--- a/src/col/vct/col/ast/statement/exceptional/EvalImpl.scala
+++ b/src/col/vct/col/ast/statement/exceptional/EvalImpl.scala
@@ -1,13 +1,26 @@
package vct.col.ast.statement.exceptional
import vct.col.ast.statement.StatementImpl
-import vct.col.ast.{Deref, Endpoint, EndpointName, Eval, Expr, MethodInvocation, PVLDeref, PVLEndpoint, PVLLocal, Statement, ThisChoreography}
+import vct.col.ast.{
+ Deref,
+ Endpoint,
+ EndpointName,
+ Eval,
+ Expr,
+ MethodInvocation,
+ PVLDeref,
+ PVLEndpoint,
+ PVLLocal,
+ Statement,
+ ThisChoreography,
+}
import vct.col.check.{CheckContext, CheckError, SeqProgInvocation}
import vct.col.print.{Ctx, Doc}
import vct.col.ast.ops.EvalOps
import vct.col.ref.Ref
import vct.col.resolve.ctx.RefPVLEndpoint
-trait EvalImpl[G] extends StatementImpl[G] with EvalOps[G] { this: Eval[G] =>
+trait EvalImpl[G] extends StatementImpl[G] with EvalOps[G] {
+ this: Eval[G] =>
override def layout(implicit ctx: Ctx): Doc = expr.show <> ";"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/statement/exceptional/ExceptionalStatementImpl.scala b/src/col/vct/col/ast/statement/exceptional/ExceptionalStatementImpl.scala
index f0ed571ec5..ad1a44c0f5 100644
--- a/src/col/vct/col/ast/statement/exceptional/ExceptionalStatementImpl.scala
+++ b/src/col/vct/col/ast/statement/exceptional/ExceptionalStatementImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.statement.exceptional
import vct.col.ast.ExceptionalStatement
import vct.col.ast.statement.StatementImpl
-trait ExceptionalStatementImpl[G] extends StatementImpl[G] { this: ExceptionalStatement[G] =>
+trait ExceptionalStatementImpl[G] extends StatementImpl[G] {
+ this: ExceptionalStatement[G] =>
}
diff --git a/src/col/vct/col/ast/statement/exceptional/InvocationStatementImpl.scala b/src/col/vct/col/ast/statement/exceptional/InvocationStatementImpl.scala
index 4b56dd0f77..a82b1ae637 100644
--- a/src/col/vct/col/ast/statement/exceptional/InvocationStatementImpl.scala
+++ b/src/col/vct/col/ast/statement/exceptional/InvocationStatementImpl.scala
@@ -3,7 +3,8 @@ package vct.col.ast.statement.exceptional
import vct.col.ast.{AbstractMethod, Expr, InvocationStatement, Variable}
import vct.col.ref.Ref
-trait InvocationStatementImpl[G] { this: InvocationStatement[G] =>
+trait InvocationStatementImpl[G] {
+ this: InvocationStatement[G] =>
override def ref: Ref[G, _ <: AbstractMethod[G]]
def outArgs: Seq[Expr[G]]
def args: Seq[Expr[G]]
diff --git a/src/col/vct/col/ast/statement/exceptional/InvokeMethodImpl.scala b/src/col/vct/col/ast/statement/exceptional/InvokeMethodImpl.scala
index d8780fcae6..f6c026719c 100644
--- a/src/col/vct/col/ast/statement/exceptional/InvokeMethodImpl.scala
+++ b/src/col/vct/col/ast/statement/exceptional/InvokeMethodImpl.scala
@@ -4,15 +4,20 @@ import vct.col.ast.{InvokeMethod, Variable, Type}
import vct.col.print.{Ctx, Doc, DocUtil, Empty, Group, Text}
import vct.col.ast.ops.InvokeMethodOps
-trait InvokeMethodImpl[G] extends InvokeMethodOps[G] { this: InvokeMethod[G] =>
+trait InvokeMethodImpl[G] extends InvokeMethodOps[G] {
+ this: InvokeMethod[G] =>
override def layout(implicit ctx: Ctx): Doc =
Group(
Group(
obj.show <> "." <> ctx.name(ref) <>
- (if (typeArgs.nonEmpty) Text("<") <> Doc.args(typeArgs) <> ">" else Empty) <>
- "("
- ) <> Doc.args(args ++ outArgs) <> ")" <> DocUtil.givenYields(givenMap, yields) <> ";"
+ (if (typeArgs.nonEmpty)
+ Text("<") <> Doc.args(typeArgs) <> ">"
+ else
+ Empty) <> "("
+ ) <> Doc.args(args ++ outArgs) <> ")" <>
+ DocUtil.givenYields(givenMap, yields) <> ";"
)
- def typeEnv: Map[Variable[G], Type[G]] = ref.decl.typeArgs.zip(typeArgs).toMap ++ obj.t.asClass.get.typeEnv
+ def typeEnv: Map[Variable[G], Type[G]] =
+ ref.decl.typeArgs.zip(typeArgs).toMap ++ obj.t.asClass.get.typeEnv
}
diff --git a/src/col/vct/col/ast/statement/exceptional/InvokeProcedureImpl.scala b/src/col/vct/col/ast/statement/exceptional/InvokeProcedureImpl.scala
index 41d32493d3..b7a6359809 100644
--- a/src/col/vct/col/ast/statement/exceptional/InvokeProcedureImpl.scala
+++ b/src/col/vct/col/ast/statement/exceptional/InvokeProcedureImpl.scala
@@ -4,23 +4,31 @@ import vct.col.ast.{InvokeProcedure, Variable, Type}
import vct.col.print.{Ctx, Doc, DocUtil, Empty, Group, Text}
import vct.col.ast.ops.InvokeProcedureOps
-trait InvokeProcedureImpl[G] extends InvokeProcedureOps[G] { this: InvokeProcedure[G] =>
- def layoutGeneric(implicit ctx: Ctx): Doc = Group(
+trait InvokeProcedureImpl[G] extends InvokeProcedureOps[G] {
+ this: InvokeProcedure[G] =>
+ def layoutGeneric(implicit ctx: Ctx): Doc =
Group(
- Text(ctx.name(ref)) <>
- (if (typeArgs.nonEmpty) Text("<") <> Doc.args(typeArgs) <> ">" else Empty) <>
- "("
- ) <> Doc.args(args ++ outArgs) <> ")" <> DocUtil.givenYields(givenMap, yields)
- ) <> ";"
+ Group(
+ Text(ctx.name(ref)) <>
+ (if (typeArgs.nonEmpty)
+ Text("<") <> Doc.args(typeArgs) <> ">"
+ else
+ Empty) <> "("
+ ) <> Doc.args(args ++ outArgs) <> ")" <>
+ DocUtil.givenYields(givenMap, yields)
+ ) <> ";"
def layoutSilver(implicit ctx: Ctx): Doc =
- (if(outArgs.nonEmpty) Doc.fold(outArgs)(_ <> "," <+> _) <+> ":=" <+> Empty else Empty) <>
- Text(ctx.name(ref)) <> "(" <> Doc.args(args) <> ")"
+ (if (outArgs.nonEmpty)
+ Doc.fold(outArgs)(_ <> "," <+> _) <+> ":=" <+> Empty
+ else
+ Empty) <> Text(ctx.name(ref)) <> "(" <> Doc.args(args) <> ")"
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.Silver => layoutSilver
- case _ => layoutGeneric
- }
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.Silver => layoutSilver
+ case _ => layoutGeneric
+ }
def typeEnv: Map[Variable[G], Type[G]] = ref.decl.typeArgs.zip(typeArgs).toMap
}
diff --git a/src/col/vct/col/ast/statement/exceptional/ReturnImpl.scala b/src/col/vct/col/ast/statement/exceptional/ReturnImpl.scala
index d5b5060505..c0a39fd96e 100644
--- a/src/col/vct/col/ast/statement/exceptional/ReturnImpl.scala
+++ b/src/col/vct/col/ast/statement/exceptional/ReturnImpl.scala
@@ -5,19 +5,32 @@ import vct.col.print.{Ctx, Doc, Empty, Text}
import vct.col.ast.ops.ReturnOps
import vct.col.check.{CheckContext, CheckError, ReturnOutsideMethod}
-trait ReturnImpl[G] extends ExceptionalStatementImpl[G] with ReturnOps[G] { this: Return[G] =>
+trait ReturnImpl[G] extends ExceptionalStatementImpl[G] with ReturnOps[G] {
+ this: Return[G] =>
override def check(context: CheckContext[G]): Seq[CheckError] = {
val app = context.declarationStack.collectFirst {
- case _: Procedure[G] | _: InstanceMethod[G] | _: InstanceOperatorMethod[G] => ()
- case _: JavaMethod[G] | _: CFunctionDefinition[G] | _: CPPFunctionDefinition[G] | _: LlvmFunctionDefinition[G] => ()
+ case _: Procedure[G] | _: InstanceMethod[G] |
+ _: InstanceOperatorMethod[G] =>
+ ()
+ case _: JavaMethod[G] | _: CFunctionDefinition[G] |
+ _: CPPFunctionDefinition[G] | _: LlvmFunctionDefinition[G] =>
+ ()
case _: BipTransition[G] | _: BipGuard[G] | _: BipOutgoingData[G] => ()
}
- val wrongReturn = if(app.isEmpty) Seq(ReturnOutsideMethod(this)) else Nil
+ val wrongReturn =
+ if (app.isEmpty)
+ Seq(ReturnOutsideMethod(this))
+ else
+ Nil
super.check(context) ++ wrongReturn
}
override def layout(implicit ctx: Ctx): Doc =
- Text("return") <> (if(result == Void[G]()) Text(";") else Empty <+> result <> ";")
+ Text("return") <>
+ (if (result == Void[G]())
+ Text(";")
+ else
+ Empty <+> result <> ";")
override def expr: Expr[G] = this.result
}
diff --git a/src/col/vct/col/ast/statement/exceptional/ThrowImpl.scala b/src/col/vct/col/ast/statement/exceptional/ThrowImpl.scala
index c49866e6e9..30c69b3611 100644
--- a/src/col/vct/col/ast/statement/exceptional/ThrowImpl.scala
+++ b/src/col/vct/col/ast/statement/exceptional/ThrowImpl.scala
@@ -4,9 +4,9 @@ import vct.col.ast.{Expr, Throw}
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.ThrowOps
-trait ThrowImpl[G] extends ThrowOps[G] { this: Throw[G] =>
- override def layout(implicit ctx: Ctx): Doc =
- Text("throw") <+> obj <> ";"
+trait ThrowImpl[G] extends ThrowOps[G] {
+ this: Throw[G] =>
+ override def layout(implicit ctx: Ctx): Doc = Text("throw") <+> obj <> ";"
override def expr: Expr[G] = this.obj
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/statement/nonexecutable/LocalDeclImpl.scala b/src/col/vct/col/ast/statement/nonexecutable/LocalDeclImpl.scala
index 2d36f609b7..ec3d5ffb3f 100644
--- a/src/col/vct/col/ast/statement/nonexecutable/LocalDeclImpl.scala
+++ b/src/col/vct/col/ast/statement/nonexecutable/LocalDeclImpl.scala
@@ -4,9 +4,11 @@ import vct.col.ast.LocalDecl
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.LocalDeclOps
-trait LocalDeclImpl[G] extends LocalDeclOps[G] { this: LocalDecl[G] =>
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.Silver => Text("var") <+> local.show
- case _ => local.show <> ";"
- }
-}
\ No newline at end of file
+trait LocalDeclImpl[G] extends LocalDeclOps[G] {
+ this: LocalDecl[G] =>
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.Silver => Text("var") <+> local.show
+ case _ => local.show <> ";"
+ }
+}
diff --git a/src/col/vct/col/ast/statement/nonexecutable/NonExecutableStatementImpl.scala b/src/col/vct/col/ast/statement/nonexecutable/NonExecutableStatementImpl.scala
index 37d4104280..5854b309e1 100644
--- a/src/col/vct/col/ast/statement/nonexecutable/NonExecutableStatementImpl.scala
+++ b/src/col/vct/col/ast/statement/nonexecutable/NonExecutableStatementImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.statement.nonexecutable
import vct.col.ast.NonExecutableStatement
-trait NonExecutableStatementImpl[G] { this: NonExecutableStatement[G] =>
+trait NonExecutableStatementImpl[G] {
+ this: NonExecutableStatement[G] =>
}
diff --git a/src/col/vct/col/ast/statement/nonexecutable/SpecIgnoreEndImpl.scala b/src/col/vct/col/ast/statement/nonexecutable/SpecIgnoreEndImpl.scala
index 420178a710..91e439213d 100644
--- a/src/col/vct/col/ast/statement/nonexecutable/SpecIgnoreEndImpl.scala
+++ b/src/col/vct/col/ast/statement/nonexecutable/SpecIgnoreEndImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.SpecIgnoreEnd
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.SpecIgnoreEndOps
-trait SpecIgnoreEndImpl[G] extends SpecIgnoreEndOps[G] { this: SpecIgnoreEnd[G] =>
+trait SpecIgnoreEndImpl[G] extends SpecIgnoreEndOps[G] {
+ this: SpecIgnoreEnd[G] =>
override def layout(implicit ctx: Ctx): Doc =
Doc.inlineSpec(Text("spec_ignore }"))
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/statement/nonexecutable/SpecIgnoreStartImpl.scala b/src/col/vct/col/ast/statement/nonexecutable/SpecIgnoreStartImpl.scala
index 19b96e5de7..d9527fc1ca 100644
--- a/src/col/vct/col/ast/statement/nonexecutable/SpecIgnoreStartImpl.scala
+++ b/src/col/vct/col/ast/statement/nonexecutable/SpecIgnoreStartImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.SpecIgnoreStart
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.SpecIgnoreStartOps
-trait SpecIgnoreStartImpl[G] extends SpecIgnoreStartOps[G] { this: SpecIgnoreStart[G] =>
+trait SpecIgnoreStartImpl[G] extends SpecIgnoreStartOps[G] {
+ this: SpecIgnoreStart[G] =>
override def layout(implicit ctx: Ctx): Doc =
Doc.inlineSpec(Text("spec_ignore {"))
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/statement/terminal/AssertImpl.scala b/src/col/vct/col/ast/statement/terminal/AssertImpl.scala
index c34211c664..3b6808b00f 100644
--- a/src/col/vct/col/ast/statement/terminal/AssertImpl.scala
+++ b/src/col/vct/col/ast/statement/terminal/AssertImpl.scala
@@ -4,17 +4,17 @@ import vct.col.ast.{Assert, Expr}
import vct.col.print.{Ctx, Doc, Show, Text}
import vct.col.ast.ops.AssertOps
-trait AssertImpl[G] extends AssertOps[G] { this: Assert[G] =>
- def layoutSpec(implicit ctx: Ctx): Doc =
- Text("assert") <+> res <> ";"
+trait AssertImpl[G] extends AssertOps[G] {
+ this: Assert[G] =>
+ def layoutSpec(implicit ctx: Ctx): Doc = Text("assert") <+> res <> ";"
- def layoutSilver(implicit ctx: Ctx): Doc =
- Text("assert") <+> res
+ def layoutSilver(implicit ctx: Ctx): Doc = Text("assert") <+> res
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.Silver => layoutSilver
- case _ => Doc.inlineSpec(Show.lazily(layoutSpec(_)))
- }
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.Silver => layoutSilver
+ case _ => Doc.inlineSpec(Show.lazily(layoutSpec(_)))
+ }
override def expr: Expr[G] = this.res
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/statement/terminal/AssignImpl.scala b/src/col/vct/col/ast/statement/terminal/AssignImpl.scala
index 43bf790119..f8079b4e50 100644
--- a/src/col/vct/col/ast/statement/terminal/AssignImpl.scala
+++ b/src/col/vct/col/ast/statement/terminal/AssignImpl.scala
@@ -5,17 +5,32 @@ import vct.col.check.{CheckContext, CheckError, SeqProgEndpointAssign}
import vct.col.print._
import vct.col.ast.ops.AssignOps
-trait AssignImpl[G] extends NormallyCompletingStatementImpl[G] with AssignOps[G] { this: Assign[G] =>
+trait AssignImpl[G]
+ extends NormallyCompletingStatementImpl[G] with AssignOps[G] {
+ this: Assign[G] =>
override def check(context: CheckContext[G]): Seq[CheckError] =
- super.check(context) ++ (target match {
- case Local(ref) => context.checkInWriteScope(context.roScopeReason, this, ref)
- case EndpointName(_) if context.currentChoreography.isDefined => Seq(SeqProgEndpointAssign(this))
- case _ => Nil
- })
+ super.check(context) ++
+ (target match {
+ case Local(ref) =>
+ context.checkInWriteScope(context.roScopeReason, this, ref)
+ case EndpointName(_) if context.currentChoreography.isDefined =>
+ Seq(SeqProgEndpointAssign(this))
+ case _ => Nil
+ })
def layoutAsExpr(implicit ctx: Ctx): Doc =
- Group(target.show <+> (if(ctx.syntax == Ctx.Silver) ":=" else "=") <>> value)
+ Group(
+ target.show <+>
+ (if (ctx.syntax == Ctx.Silver)
+ ":="
+ else
+ "=") <>> value
+ )
override def layout(implicit ctx: Ctx): Doc =
- layoutAsExpr <> (if(ctx.syntax == Ctx.Silver) Empty else Text(";"))
-}
\ No newline at end of file
+ layoutAsExpr <>
+ (if (ctx.syntax == Ctx.Silver)
+ Empty
+ else
+ Text(";"))
+}
diff --git a/src/col/vct/col/ast/statement/terminal/AssumeImpl.scala b/src/col/vct/col/ast/statement/terminal/AssumeImpl.scala
index 0c6ebb0227..7022a9daa6 100644
--- a/src/col/vct/col/ast/statement/terminal/AssumeImpl.scala
+++ b/src/col/vct/col/ast/statement/terminal/AssumeImpl.scala
@@ -4,17 +4,17 @@ import vct.col.ast.{Assume, Expr}
import vct.col.print.{Ctx, Doc, Show, Text}
import vct.col.ast.ops.AssumeOps
-trait AssumeImpl[G] extends AssumeOps[G] { this: Assume[G] =>
- def layoutSpec(implicit ctx: Ctx): Doc =
- Text("assume") <+> assn <> ";"
+trait AssumeImpl[G] extends AssumeOps[G] {
+ this: Assume[G] =>
+ def layoutSpec(implicit ctx: Ctx): Doc = Text("assume") <+> assn <> ";"
- def layoutSilver(implicit ctx: Ctx): Doc =
- Text("assume") <+> assn
+ def layoutSilver(implicit ctx: Ctx): Doc = Text("assume") <+> assn
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.Silver => layoutSilver
- case _ => Doc.inlineSpec(Show.lazily(layoutSpec(_)))
- }
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.Silver => layoutSilver
+ case _ => Doc.inlineSpec(Show.lazily(layoutSpec(_)))
+ }
override def expr: Expr[G] = this.assn
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/statement/terminal/CaseImpl.scala b/src/col/vct/col/ast/statement/terminal/CaseImpl.scala
index 26c06cf445..66e5a53895 100644
--- a/src/col/vct/col/ast/statement/terminal/CaseImpl.scala
+++ b/src/col/vct/col/ast/statement/terminal/CaseImpl.scala
@@ -4,7 +4,7 @@ import vct.col.ast.Case
import vct.col.print.{Ctx, Doc, Show, Text}
import vct.col.ast.ops.CaseOps
-trait CaseImpl[G] extends CaseOps[G] { this: Case[G] =>
- override def layout(implicit ctx: Ctx): Doc =
- Text("case") <+> pattern <> ":"
-}
\ No newline at end of file
+trait CaseImpl[G] extends CaseOps[G] {
+ this: Case[G] =>
+ override def layout(implicit ctx: Ctx): Doc = Text("case") <+> pattern <> ":"
+}
diff --git a/src/col/vct/col/ast/statement/terminal/CommitImpl.scala b/src/col/vct/col/ast/statement/terminal/CommitImpl.scala
index 58260e1576..c130809981 100644
--- a/src/col/vct/col/ast/statement/terminal/CommitImpl.scala
+++ b/src/col/vct/col/ast/statement/terminal/CommitImpl.scala
@@ -4,11 +4,12 @@ import vct.col.ast.{Commit, Expr}
import vct.col.print.{Ctx, Doc, Show, Text}
import vct.col.ast.ops.CommitOps
-trait CommitImpl[G] extends CommitOps[G] { this: Commit[G] =>
- def layoutSpec(implicit ctx: Ctx): Doc =
- Text("commit") <+> obj <> ";"
+trait CommitImpl[G] extends CommitOps[G] {
+ this: Commit[G] =>
+ def layoutSpec(implicit ctx: Ctx): Doc = Text("commit") <+> obj <> ";"
- override def layout(implicit ctx: Ctx): Doc = Doc.inlineSpec(Show.lazily(layoutSpec(_)))
+ override def layout(implicit ctx: Ctx): Doc =
+ Doc.inlineSpec(Show.lazily(layoutSpec(_)))
override def expr: Expr[G] = this.obj
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/statement/terminal/DefaultCaseImpl.scala b/src/col/vct/col/ast/statement/terminal/DefaultCaseImpl.scala
index 4f13844557..efadae3f9e 100644
--- a/src/col/vct/col/ast/statement/terminal/DefaultCaseImpl.scala
+++ b/src/col/vct/col/ast/statement/terminal/DefaultCaseImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.DefaultCase
import vct.col.print.{Ctx, Doc, Show, Text}
import vct.col.ast.ops.DefaultCaseOps
-trait DefaultCaseImpl[G] extends DefaultCaseOps[G] { this: DefaultCase[G] =>
+trait DefaultCaseImpl[G] extends DefaultCaseOps[G] {
+ this: DefaultCase[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("default:")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/statement/terminal/ExhaleImpl.scala b/src/col/vct/col/ast/statement/terminal/ExhaleImpl.scala
index a4f547867f..b18536c7a9 100644
--- a/src/col/vct/col/ast/statement/terminal/ExhaleImpl.scala
+++ b/src/col/vct/col/ast/statement/terminal/ExhaleImpl.scala
@@ -4,17 +4,17 @@ import vct.col.ast.{Exhale, Expr}
import vct.col.print.{Ctx, Doc, Show, Text}
import vct.col.ast.ops.ExhaleOps
-trait ExhaleImpl[G] extends ExhaleOps[G] { this: Exhale[G] =>
- def layoutSpec(implicit ctx: Ctx): Doc =
- Text("exhale") <+> res <> ";"
+trait ExhaleImpl[G] extends ExhaleOps[G] {
+ this: Exhale[G] =>
+ def layoutSpec(implicit ctx: Ctx): Doc = Text("exhale") <+> res <> ";"
- def layoutSilver(implicit ctx: Ctx): Doc =
- Text("exhale") <+> res
+ def layoutSilver(implicit ctx: Ctx): Doc = Text("exhale") <+> res
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.Silver => layoutSilver
- case _ => Doc.inlineSpec(Show.lazily(layoutSpec(_)))
- }
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.Silver => layoutSilver
+ case _ => Doc.inlineSpec(Show.lazily(layoutSpec(_)))
+ }
override def expr: Expr[G] = this.res
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/statement/terminal/ExtractImpl.scala b/src/col/vct/col/ast/statement/terminal/ExtractImpl.scala
index 526034c8da..1c811e9d0c 100644
--- a/src/col/vct/col/ast/statement/terminal/ExtractImpl.scala
+++ b/src/col/vct/col/ast/statement/terminal/ExtractImpl.scala
@@ -4,6 +4,8 @@ import vct.col.ast.Extract
import vct.col.print.{Ctx, Doc, Show, Text}
import vct.col.ast.ops.ExtractOps
-trait ExtractImpl[G] extends ExtractOps[G] { this: Extract[G] =>
- override def layout(implicit ctx: Ctx): Doc = Doc.inlineSpec(Text("extract")) <+> contractedStatement
+trait ExtractImpl[G] extends ExtractOps[G] {
+ this: Extract[G] =>
+ override def layout(implicit ctx: Ctx): Doc =
+ Doc.inlineSpec(Text("extract")) <+> contractedStatement
}
diff --git a/src/col/vct/col/ast/statement/terminal/FoldImpl.scala b/src/col/vct/col/ast/statement/terminal/FoldImpl.scala
index ace25ef36f..88d88897aa 100644
--- a/src/col/vct/col/ast/statement/terminal/FoldImpl.scala
+++ b/src/col/vct/col/ast/statement/terminal/FoldImpl.scala
@@ -6,17 +6,18 @@ import vct.col.ast.util.CheckFoldUnfoldTarget
import vct.col.print.{Ctx, Doc, Show, Text}
import vct.col.ast.ops.FoldOps
-trait FoldImpl[G] extends NodeFamilyImpl[G] with CheckFoldUnfoldTarget[G] with FoldOps[G] { this: Fold[G] =>
- def layoutSpec(implicit ctx: Ctx): Doc =
- Text("fold") <+> res <> ";"
+trait FoldImpl[G]
+ extends NodeFamilyImpl[G] with CheckFoldUnfoldTarget[G] with FoldOps[G] {
+ this: Fold[G] =>
+ def layoutSpec(implicit ctx: Ctx): Doc = Text("fold") <+> res <> ";"
- def layoutSilver(implicit ctx: Ctx): Doc =
- Text("fold") <+> res
+ def layoutSilver(implicit ctx: Ctx): Doc = Text("fold") <+> res
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.Silver => layoutSilver
- case _ => Doc.inlineSpec(Show.lazily(layoutSpec(_)))
- }
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.Silver => layoutSilver
+ case _ => Doc.inlineSpec(Show.lazily(layoutSpec(_)))
+ }
override def expr: Expr[G] = this.res
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/statement/terminal/ForkImpl.scala b/src/col/vct/col/ast/statement/terminal/ForkImpl.scala
index 6ae45b80c8..edb237ca80 100644
--- a/src/col/vct/col/ast/statement/terminal/ForkImpl.scala
+++ b/src/col/vct/col/ast/statement/terminal/ForkImpl.scala
@@ -4,11 +4,12 @@ import vct.col.ast.{Expr, Fork}
import vct.col.print.{Ctx, Doc, Show, Text}
import vct.col.ast.ops.ForkOps
-trait ForkImpl[G] extends ForkOps[G] { this: Fork[G] =>
- def layoutSpec(implicit ctx: Ctx): Doc =
- Text("fork") <+> obj <> ";"
+trait ForkImpl[G] extends ForkOps[G] {
+ this: Fork[G] =>
+ def layoutSpec(implicit ctx: Ctx): Doc = Text("fork") <+> obj <> ";"
- override def layout(implicit ctx: Ctx): Doc = Doc.inlineSpec(Show.lazily(layoutSpec(_)))
+ override def layout(implicit ctx: Ctx): Doc =
+ Doc.inlineSpec(Show.lazily(layoutSpec(_)))
override def expr: Expr[G] = this.obj
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/statement/terminal/FramedProofImpl.scala b/src/col/vct/col/ast/statement/terminal/FramedProofImpl.scala
index d0db7e4fa7..314d068343 100644
--- a/src/col/vct/col/ast/statement/terminal/FramedProofImpl.scala
+++ b/src/col/vct/col/ast/statement/terminal/FramedProofImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.FramedProof
import vct.col.print.{Ctx, Doc, DocUtil, Show, Text}
import vct.col.ast.ops.FramedProofOps
-trait FramedProofImpl[G] extends FramedProofOps[G] { this: FramedProof[G] =>
+trait FramedProofImpl[G] extends FramedProofOps[G] {
+ this: FramedProof[G] =>
def frameHeader(implicit ctx: Ctx): Doc =
Doc.stack(Seq(
Text("frame"),
@@ -14,7 +15,8 @@ trait FramedProofImpl[G] extends FramedProofOps[G] { this: FramedProof[G] =>
))
def layoutWithSpec(implicit ctx: Ctx): Doc =
- Doc.spec(Show.lazily(frameHeader(_))) <+/> body.foldBlock(_ <+/> _) <+/> Doc.inlineSpec(Text("}"))
+ Doc.spec(Show.lazily(frameHeader(_))) <+/> body.foldBlock(_ <+/> _) <+/>
+ Doc.inlineSpec(Text("}"))
def layoutNative(implicit ctx: Ctx): Doc =
Doc.stack(Seq(
@@ -24,6 +26,8 @@ trait FramedProofImpl[G] extends FramedProofOps[G] { this: FramedProof[G] =>
)) <+> body.layoutAsBlock
override def layout(implicit ctx: Ctx): Doc =
- if(ctx.syntax != Ctx.PVL && !ctx.inSpec) layoutWithSpec
- else layoutNative
+ if (ctx.syntax != Ctx.PVL && !ctx.inSpec)
+ layoutWithSpec
+ else
+ layoutNative
}
diff --git a/src/col/vct/col/ast/statement/terminal/GotoImpl.scala b/src/col/vct/col/ast/statement/terminal/GotoImpl.scala
index bef6e93042..0d3fda6435 100644
--- a/src/col/vct/col/ast/statement/terminal/GotoImpl.scala
+++ b/src/col/vct/col/ast/statement/terminal/GotoImpl.scala
@@ -5,7 +5,8 @@ import vct.col.check.{CheckContext, CheckError, OutOfScopeError}
import vct.col.print.{Ctx, Doc, Show, Text}
import vct.col.ast.ops.GotoOps
-trait GotoImpl[G] extends GotoOps[G] { this: Goto[G] =>
+trait GotoImpl[G] extends GotoOps[G] {
+ this: Goto[G] =>
override def check(context: CheckContext[G]): Seq[CheckError] =
context.currentApplicable.get.body.get.transSubnodes.collectFirst {
case label: LabelDecl[G] if label == lbl.decl => label
@@ -14,8 +15,9 @@ trait GotoImpl[G] extends GotoOps[G] { this: Goto[G] =>
case None => Seq(OutOfScopeError(this, lbl))
}
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.Silver => Text("goto") <+> ctx.name(lbl)
- case _ => Text("goto") <+> ctx.name(lbl) <> ";"
- }
-}
\ No newline at end of file
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.Silver => Text("goto") <+> ctx.name(lbl)
+ case _ => Text("goto") <+> ctx.name(lbl) <> ";"
+ }
+}
diff --git a/src/col/vct/col/ast/statement/terminal/HavocImpl.scala b/src/col/vct/col/ast/statement/terminal/HavocImpl.scala
index eb346ef388..c33f126482 100644
--- a/src/col/vct/col/ast/statement/terminal/HavocImpl.scala
+++ b/src/col/vct/col/ast/statement/terminal/HavocImpl.scala
@@ -4,11 +4,12 @@ import vct.col.ast.{Expr, Havoc}
import vct.col.print.{Ctx, Doc, Show, Text}
import vct.col.ast.ops.HavocOps
-trait HavocImpl[G] extends HavocOps[G] { this: Havoc[G] =>
- def layoutSpec(implicit ctx: Ctx): Doc =
- Text("havoc") <+> loc <> ";"
+trait HavocImpl[G] extends HavocOps[G] {
+ this: Havoc[G] =>
+ def layoutSpec(implicit ctx: Ctx): Doc = Text("havoc") <+> loc <> ";"
- override def layout(implicit ctx: Ctx): Doc = Doc.inlineSpec(Show.lazily(layoutSpec(_)))
+ override def layout(implicit ctx: Ctx): Doc =
+ Doc.inlineSpec(Show.lazily(layoutSpec(_)))
override def expr: Expr[G] = this.loc
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/statement/terminal/InhaleImpl.scala b/src/col/vct/col/ast/statement/terminal/InhaleImpl.scala
index 0a4dfcf00a..a46f2f6f67 100644
--- a/src/col/vct/col/ast/statement/terminal/InhaleImpl.scala
+++ b/src/col/vct/col/ast/statement/terminal/InhaleImpl.scala
@@ -4,17 +4,17 @@ import vct.col.ast.{Expr, Inhale}
import vct.col.print.{Ctx, Doc, Show, Text}
import vct.col.ast.ops.InhaleOps
-trait InhaleImpl[G] extends InhaleOps[G] { this: Inhale[G] =>
- def layoutSpec(implicit ctx: Ctx): Doc =
- Text("inhale") <+> res <> ";"
+trait InhaleImpl[G] extends InhaleOps[G] {
+ this: Inhale[G] =>
+ def layoutSpec(implicit ctx: Ctx): Doc = Text("inhale") <+> res <> ";"
- def layoutSilver(implicit ctx: Ctx): Doc =
- Text("inhale") <+> res
+ def layoutSilver(implicit ctx: Ctx): Doc = Text("inhale") <+> res
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.Silver => layoutSilver
- case _ => Doc.inlineSpec(Show.lazily(layoutSpec(_)))
- }
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.Silver => layoutSilver
+ case _ => Doc.inlineSpec(Show.lazily(layoutSpec(_)))
+ }
override def expr: Expr[G] = this.res
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/statement/terminal/JoinImpl.scala b/src/col/vct/col/ast/statement/terminal/JoinImpl.scala
index 3d7f3f9bde..1d77797aa6 100644
--- a/src/col/vct/col/ast/statement/terminal/JoinImpl.scala
+++ b/src/col/vct/col/ast/statement/terminal/JoinImpl.scala
@@ -4,11 +4,12 @@ import vct.col.ast.{Expr, Join}
import vct.col.print.{Ctx, Doc, Show, Text}
import vct.col.ast.ops.JoinOps
-trait JoinImpl[G] extends JoinOps[G] { this: Join[G] =>
- def layoutSpec(implicit ctx: Ctx): Doc =
- Text("join") <+> obj <> ";"
+trait JoinImpl[G] extends JoinOps[G] {
+ this: Join[G] =>
+ def layoutSpec(implicit ctx: Ctx): Doc = Text("join") <+> obj <> ";"
- override def layout(implicit ctx: Ctx): Doc = Doc.inlineSpec(Show.lazily(layoutSpec(_)))
+ override def layout(implicit ctx: Ctx): Doc =
+ Doc.inlineSpec(Show.lazily(layoutSpec(_)))
override def expr: Expr[G] = this.obj
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/statement/terminal/LabelImpl.scala b/src/col/vct/col/ast/statement/terminal/LabelImpl.scala
index 3f8b621850..0d0b777da7 100644
--- a/src/col/vct/col/ast/statement/terminal/LabelImpl.scala
+++ b/src/col/vct/col/ast/statement/terminal/LabelImpl.scala
@@ -4,20 +4,28 @@ import vct.col.ast.Label
import vct.col.print.{Ctx, Doc, NodeDoc, Show, Text}
import vct.col.ast.ops.LabelOps
-trait LabelImpl[G] extends LabelOps[G] { this: Label[G] =>
- override def foldBlock(f: (Doc, Doc) => Doc)(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.PVL => f(layoutLabel, stat.foldBlock(f))
- case Ctx.Silver => f(layoutLabel, stat.foldBlock(f))
- case Ctx.Java => layoutLabel <+> stat.show
- case Ctx.C | Ctx.Cuda | Ctx.OpenCL | Ctx.CPP => f(layoutLabel, stat.foldBlock(f))
- }
+trait LabelImpl[G] extends LabelOps[G] {
+ this: Label[G] =>
+ override def foldBlock(f: (Doc, Doc) => Doc)(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.PVL => f(layoutLabel, stat.foldBlock(f))
+ case Ctx.Silver => f(layoutLabel, stat.foldBlock(f))
+ case Ctx.Java => layoutLabel <+> stat.show
+ case Ctx.C | Ctx.Cuda | Ctx.OpenCL | Ctx.CPP =>
+ f(layoutLabel, stat.foldBlock(f))
+ }
- def layoutLabel(implicit ctx: Ctx): Doc = NodeDoc(this, ctx.syntax match {
- case Ctx.PVL => Text("label") <+> ctx.name(decl) <> ";"
- case Ctx.Silver => Text("label") <+> ctx.name(decl)
- case Ctx.Java => Text(ctx.name(decl)) <> ":"
- case Ctx.C | Ctx.Cuda | Ctx.OpenCL | Ctx.CPP => Text(ctx.name(decl)) <> ":"
- })
+ def layoutLabel(implicit ctx: Ctx): Doc =
+ NodeDoc(
+ this,
+ ctx.syntax match {
+ case Ctx.PVL => Text("label") <+> ctx.name(decl) <> ";"
+ case Ctx.Silver => Text("label") <+> ctx.name(decl)
+ case Ctx.Java => Text(ctx.name(decl)) <> ":"
+ case Ctx.C | Ctx.Cuda | Ctx.OpenCL | Ctx.CPP =>
+ Text(ctx.name(decl)) <> ":"
+ },
+ )
override def layout(implicit ctx: Ctx): Doc = foldBlock(_ <+/> _)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/statement/terminal/LockImpl.scala b/src/col/vct/col/ast/statement/terminal/LockImpl.scala
index 6a864ee3f7..4ada85438b 100644
--- a/src/col/vct/col/ast/statement/terminal/LockImpl.scala
+++ b/src/col/vct/col/ast/statement/terminal/LockImpl.scala
@@ -4,11 +4,12 @@ import vct.col.ast.{Expr, Lock}
import vct.col.print.{Ctx, Doc, Show, Text}
import vct.col.ast.ops.LockOps
-trait LockImpl[G] extends LockOps[G] { this: Lock[G] =>
- def layoutSpec(implicit ctx: Ctx): Doc =
- Text("lock") <+> obj <> ";"
+trait LockImpl[G] extends LockOps[G] {
+ this: Lock[G] =>
+ def layoutSpec(implicit ctx: Ctx): Doc = Text("lock") <+> obj <> ";"
- override def layout(implicit ctx: Ctx): Doc = Doc.inlineSpec(Show.lazily(layoutSpec(_)))
+ override def layout(implicit ctx: Ctx): Doc =
+ Doc.inlineSpec(Show.lazily(layoutSpec(_)))
override def expr: Expr[G] = this.obj
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/statement/terminal/NormallyCompletingStatementImpl.scala b/src/col/vct/col/ast/statement/terminal/NormallyCompletingStatementImpl.scala
index 92d2d6696b..0489aacad5 100644
--- a/src/col/vct/col/ast/statement/terminal/NormallyCompletingStatementImpl.scala
+++ b/src/col/vct/col/ast/statement/terminal/NormallyCompletingStatementImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.statement.terminal
import vct.col.ast.NormallyCompletingStatement
import vct.col.ast.statement.StatementImpl
-trait NormallyCompletingStatementImpl[G] extends StatementImpl[G] { this: NormallyCompletingStatement[G] =>
+trait NormallyCompletingStatementImpl[G] extends StatementImpl[G] {
+ this: NormallyCompletingStatement[G] =>
}
diff --git a/src/col/vct/col/ast/statement/terminal/NotifyImpl.scala b/src/col/vct/col/ast/statement/terminal/NotifyImpl.scala
index 28a79fd47a..b362e81496 100644
--- a/src/col/vct/col/ast/statement/terminal/NotifyImpl.scala
+++ b/src/col/vct/col/ast/statement/terminal/NotifyImpl.scala
@@ -4,11 +4,12 @@ import vct.col.ast.{Expr, Notify}
import vct.col.print.{Ctx, Doc, Show, Text}
import vct.col.ast.ops.NotifyOps
-trait NotifyImpl[G] extends NotifyOps[G] { this: Notify[G] =>
- def layoutSpec(implicit ctx: Ctx): Doc =
- Text("notify") <+> obj <> ";"
+trait NotifyImpl[G] extends NotifyOps[G] {
+ this: Notify[G] =>
+ def layoutSpec(implicit ctx: Ctx): Doc = Text("notify") <+> obj <> ";"
- override def layout(implicit ctx: Ctx): Doc = Doc.inlineSpec(Show.lazily(layoutSpec(_)))
+ override def layout(implicit ctx: Ctx): Doc =
+ Doc.inlineSpec(Show.lazily(layoutSpec(_)))
override def expr: Expr[G] = this.obj
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/statement/terminal/RecvImpl.scala b/src/col/vct/col/ast/statement/terminal/RecvImpl.scala
index b07bfd077f..e03bd02b8e 100644
--- a/src/col/vct/col/ast/statement/terminal/RecvImpl.scala
+++ b/src/col/vct/col/ast/statement/terminal/RecvImpl.scala
@@ -4,10 +4,10 @@ import vct.col.ast.Recv
import vct.col.print._
import vct.col.ast.ops.RecvOps
-trait RecvImpl[G] extends RecvOps[G] { this: Recv[G] =>
- def layoutSpec(implicit ctx: Ctx): Doc =
- Text("recv") <+> ctx.name(ref) <> ";"
+trait RecvImpl[G] extends RecvOps[G] {
+ this: Recv[G] =>
+ def layoutSpec(implicit ctx: Ctx): Doc = Text("recv") <+> ctx.name(ref) <> ";"
override def layout(implicit ctx: Ctx): Doc =
Doc.inlineSpec(Show.lazily(layoutSpec(_)))
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/statement/terminal/RefuteImpl.scala b/src/col/vct/col/ast/statement/terminal/RefuteImpl.scala
index 957e4ed4e4..f48b4a3647 100644
--- a/src/col/vct/col/ast/statement/terminal/RefuteImpl.scala
+++ b/src/col/vct/col/ast/statement/terminal/RefuteImpl.scala
@@ -4,17 +4,17 @@ import vct.col.ast.{Expr, Refute}
import vct.col.print.{Ctx, Doc, Show, Text}
import vct.col.ast.ops.RefuteOps
-trait RefuteImpl[G] extends RefuteOps[G] { this: Refute[G] =>
- def layoutSpec(implicit ctx: Ctx): Doc =
- Text("refute") <+> assn <> ";"
+trait RefuteImpl[G] extends RefuteOps[G] {
+ this: Refute[G] =>
+ def layoutSpec(implicit ctx: Ctx): Doc = Text("refute") <+> assn <> ";"
- def layoutSilver(implicit ctx: Ctx): Doc =
- Text("refute") <+> assn
+ def layoutSilver(implicit ctx: Ctx): Doc = Text("refute") <+> assn
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.Silver => layoutSilver
- case _ => Doc.inlineSpec(Show.lazily(layoutSpec(_)))
- }
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.Silver => layoutSilver
+ case _ => Doc.inlineSpec(Show.lazily(layoutSpec(_)))
+ }
override def expr: Expr[G] = this.assn
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/statement/terminal/SendImpl.scala b/src/col/vct/col/ast/statement/terminal/SendImpl.scala
index fd007d8340..1f93da7b32 100644
--- a/src/col/vct/col/ast/statement/terminal/SendImpl.scala
+++ b/src/col/vct/col/ast/statement/terminal/SendImpl.scala
@@ -4,12 +4,16 @@ import vct.col.ast.{Expr, Send}
import vct.col.print.{Ctx, Doc, Group, Show, Text}
import vct.col.ast.ops.SendOps
-trait SendImpl[G] extends SendOps[G] { this: Send[G] =>
+trait SendImpl[G] extends SendOps[G] {
+ this: Send[G] =>
def layoutSpec(implicit ctx: Ctx): Doc =
- Group(Text("send") <+> ctx.name(decl) <> "," <+> delta.toString <> ":" <>> res <> ";")
+ Group(
+ Text("send") <+> ctx.name(decl) <> "," <+> delta.toString <> ":" <>>
+ res <> ";"
+ )
override def layout(implicit ctx: Ctx): Doc =
Doc.inlineSpec(Show.lazily(layoutSpec(_)))
override def expr: Expr[G] = this.res
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/statement/terminal/SwitchCaseImpl.scala b/src/col/vct/col/ast/statement/terminal/SwitchCaseImpl.scala
index 45daea311f..ae0290641b 100644
--- a/src/col/vct/col/ast/statement/terminal/SwitchCaseImpl.scala
+++ b/src/col/vct/col/ast/statement/terminal/SwitchCaseImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.statement.terminal
import vct.col.ast.SwitchCase
-trait SwitchCaseImpl[G] { this: SwitchCase[G] =>
+trait SwitchCaseImpl[G] {
+ this: SwitchCase[G] =>
}
diff --git a/src/col/vct/col/ast/statement/terminal/UnfoldImpl.scala b/src/col/vct/col/ast/statement/terminal/UnfoldImpl.scala
index 759e81c9c5..3d38445a62 100644
--- a/src/col/vct/col/ast/statement/terminal/UnfoldImpl.scala
+++ b/src/col/vct/col/ast/statement/terminal/UnfoldImpl.scala
@@ -6,17 +6,18 @@ import vct.col.ast.util.CheckFoldUnfoldTarget
import vct.col.print.{Ctx, Doc, Show, Text}
import vct.col.ast.ops.UnfoldOps
-trait UnfoldImpl[G] extends NodeFamilyImpl[G] with CheckFoldUnfoldTarget[G] with UnfoldOps[G] { this: Unfold[G] =>
- def layoutSpec(implicit ctx: Ctx): Doc =
- Text("unfold") <+> res <> ";"
+trait UnfoldImpl[G]
+ extends NodeFamilyImpl[G] with CheckFoldUnfoldTarget[G] with UnfoldOps[G] {
+ this: Unfold[G] =>
+ def layoutSpec(implicit ctx: Ctx): Doc = Text("unfold") <+> res <> ";"
- def layoutSilver(implicit ctx: Ctx): Doc =
- Text("unfold") <+> res
+ def layoutSilver(implicit ctx: Ctx): Doc = Text("unfold") <+> res
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.Silver => layoutSilver
- case _ => Doc.inlineSpec(Show.lazily(layoutSpec(_)))
- }
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.Silver => layoutSilver
+ case _ => Doc.inlineSpec(Show.lazily(layoutSpec(_)))
+ }
override def expr: Expr[G] = this.res
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/statement/terminal/UnlockImpl.scala b/src/col/vct/col/ast/statement/terminal/UnlockImpl.scala
index 3f4f2acc23..455f2eb2e6 100644
--- a/src/col/vct/col/ast/statement/terminal/UnlockImpl.scala
+++ b/src/col/vct/col/ast/statement/terminal/UnlockImpl.scala
@@ -4,11 +4,12 @@ import vct.col.ast.{Expr, Unlock}
import vct.col.print.{Ctx, Doc, Show, Text}
import vct.col.ast.ops.UnlockOps
-trait UnlockImpl[G] extends UnlockOps[G] { this: Unlock[G] =>
- def layoutSpec(implicit ctx: Ctx): Doc =
- Text("unlock") <+> obj <> ";"
+trait UnlockImpl[G] extends UnlockOps[G] {
+ this: Unlock[G] =>
+ def layoutSpec(implicit ctx: Ctx): Doc = Text("unlock") <+> obj <> ";"
- override def layout(implicit ctx: Ctx): Doc = Doc.inlineSpec(Show.lazily(layoutSpec(_)))
+ override def layout(implicit ctx: Ctx): Doc =
+ Doc.inlineSpec(Show.lazily(layoutSpec(_)))
override def expr: Expr[G] = this.obj
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/statement/terminal/WaitImpl.scala b/src/col/vct/col/ast/statement/terminal/WaitImpl.scala
index 317a91b89c..f97a7a588f 100644
--- a/src/col/vct/col/ast/statement/terminal/WaitImpl.scala
+++ b/src/col/vct/col/ast/statement/terminal/WaitImpl.scala
@@ -4,11 +4,12 @@ import vct.col.ast.{Expr, Wait}
import vct.col.print.{Ctx, Doc, Show, Text}
import vct.col.ast.ops.WaitOps
-trait WaitImpl[G] extends WaitOps[G] { this: Wait[G] =>
- def layoutSpec(implicit ctx: Ctx): Doc =
- Text("wait") <+> obj <> ";"
+trait WaitImpl[G] extends WaitOps[G] {
+ this: Wait[G] =>
+ def layoutSpec(implicit ctx: Ctx): Doc = Text("wait") <+> obj <> ";"
- override def layout(implicit ctx: Ctx): Doc = Doc.inlineSpec(Show.lazily(layoutSpec(_)))
+ override def layout(implicit ctx: Ctx): Doc =
+ Doc.inlineSpec(Show.lazily(layoutSpec(_)))
override def expr: Expr[G] = this.obj
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/statement/terminal/WandApplyImpl.scala b/src/col/vct/col/ast/statement/terminal/WandApplyImpl.scala
index 332ca1d490..1de595469a 100644
--- a/src/col/vct/col/ast/statement/terminal/WandApplyImpl.scala
+++ b/src/col/vct/col/ast/statement/terminal/WandApplyImpl.scala
@@ -4,14 +4,15 @@ import vct.col.ast.{Expr, WandApply}
import vct.col.print.{Ctx, Doc, Show, Text}
import vct.col.ast.ops.WandApplyOps
-trait WandApplyImpl[G] extends WandApplyOps[G] { this: WandApply[G] =>
- def layoutSpec(implicit ctx: Ctx): Doc =
- Text("apply") <+> res <> ";"
+trait WandApplyImpl[G] extends WandApplyOps[G] {
+ this: WandApply[G] =>
+ def layoutSpec(implicit ctx: Ctx): Doc = Text("apply") <+> res <> ";"
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.Silver => Text("apply") <+> res
- case _ => Doc.inlineSpec(Show.lazily(layoutSpec(_)))
- }
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.Silver => Text("apply") <+> res
+ case _ => Doc.inlineSpec(Show.lazily(layoutSpec(_)))
+ }
override def expr: Expr[G] = this.res
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/statement/veymont/ChorBranchImpl.scala b/src/col/vct/col/ast/statement/veymont/ChorBranchImpl.scala
index 5ba52ab396..a7b8f1b3f4 100644
--- a/src/col/vct/col/ast/statement/veymont/ChorBranchImpl.scala
+++ b/src/col/vct/col/ast/statement/veymont/ChorBranchImpl.scala
@@ -1,6 +1,15 @@
package vct.col.ast.statement.veymont
-import vct.col.ast.{Assign, ChorStatement, Communicate, Endpoint, EndpointGuard, EndpointName, ChorBranch, UnpointedGuard}
+import vct.col.ast.{
+ Assign,
+ ChorStatement,
+ Communicate,
+ Endpoint,
+ EndpointGuard,
+ EndpointName,
+ ChorBranch,
+ UnpointedGuard,
+}
import vct.col.ast.statement.StatementImpl
import vct.col.check.{CheckContext, CheckError, SeqProgParticipant}
import vct.col.ref.Ref
@@ -8,13 +17,18 @@ import vct.col.ref.Ref
import scala.collection.immutable.ListSet
import vct.col.ast.ops.ChorBranchOps
-trait ChorBranchImpl[G] extends StatementImpl[G] with ChorBranchOps[G] { this: ChorBranch[G] =>
+trait ChorBranchImpl[G] extends StatementImpl[G] with ChorBranchOps[G] {
+ this: ChorBranch[G] =>
assert(guards.nonEmpty)
- def hasUnpointed: Boolean = guards.exists { case _: UnpointedGuard[G] => true; case _ => false }
- def explicitParticipants: Seq[Endpoint[G]] = guards.collect { case EndpointGuard(Ref(endpoint), condition) => endpoint }
+ def hasUnpointed: Boolean =
+ guards.exists { case _: UnpointedGuard[G] => true; case _ => false }
+ def explicitParticipants: Seq[Endpoint[G]] =
+ guards.collect { case EndpointGuard(Ref(endpoint), condition) => endpoint }
- override def enterCheckContextCurrentParticipatingEndpoints(context: CheckContext[G]): Option[Set[Endpoint[G]]] = {
+ override def enterCheckContextCurrentParticipatingEndpoints(
+ context: CheckContext[G]
+ ): Option[Set[Endpoint[G]]] = {
// Assume SeqProg sets participatingEndpoints
assert(context.currentParticipatingEndpoints.isDefined)
@@ -27,18 +41,21 @@ trait ChorBranchImpl[G] extends StatementImpl[G] with ChorBranchOps[G] { this: C
}
}
- override def check(context: CheckContext[G]): Seq[CheckError] = super.check(context) ++ {
- // Assume SeqProg sets participatingEndpoints
- assert(context.currentParticipatingEndpoints.isDefined)
+ override def check(context: CheckContext[G]): Seq[CheckError] =
+ super.check(context) ++ {
+ // Assume SeqProg sets participatingEndpoints
+ assert(context.currentParticipatingEndpoints.isDefined)
- // Ensure the set of participants is at most refined
- if (Set.from(explicitParticipants).subsetOf(context.currentParticipatingEndpoints.get)) {
- Seq()
- } else {
- // There are participants in this if that have been excluded from participation: error
- Seq(SeqProgParticipant(this))
+ // Ensure the set of participants is at most refined
+ if (
+ Set.from(explicitParticipants)
+ .subsetOf(context.currentParticipatingEndpoints.get)
+ ) { Seq() }
+ else {
+ // There are participants in this if that have been excluded from participation: error
+ Seq(SeqProgParticipant(this))
+ }
}
- }
// All participants that concretely participate in the branch by being named explicitly through the condition,
// an assignment, or a communicate.
diff --git a/src/col/vct/col/ast/statement/veymont/ChorLoopImpl.scala b/src/col/vct/col/ast/statement/veymont/ChorLoopImpl.scala
index 511c531c76..fdb88069bb 100644
--- a/src/col/vct/col/ast/statement/veymont/ChorLoopImpl.scala
+++ b/src/col/vct/col/ast/statement/veymont/ChorLoopImpl.scala
@@ -1,18 +1,33 @@
package vct.col.ast.statement.veymont
import vct.col.ast.statement.StatementImpl
-import vct.col.ast.{Assign, ChorStatement, Communicate, Endpoint, EndpointGuard, EndpointName, ChorBranch, ChorLoop, UnpointedGuard}
+import vct.col.ast.{
+ Assign,
+ ChorStatement,
+ Communicate,
+ Endpoint,
+ EndpointGuard,
+ EndpointName,
+ ChorBranch,
+ ChorLoop,
+ UnpointedGuard,
+}
import vct.col.check.{CheckContext, CheckError, SeqProgParticipant}
import vct.col.ref.Ref
import scala.collection.immutable.ListSet
import vct.col.ast.ops.ChorLoopOps
-trait ChorLoopImpl[G] extends StatementImpl[G] with ChorLoopOps[G] { this: ChorLoop[G] =>
- def hasUnpointed: Boolean = guards.exists { case _: UnpointedGuard[G] => true; case _ => false }
- def explicitParticipants: Seq[Endpoint[G]] = guards.collect { case EndpointGuard(Ref(endpoint), condition) => endpoint }
+trait ChorLoopImpl[G] extends StatementImpl[G] with ChorLoopOps[G] {
+ this: ChorLoop[G] =>
+ def hasUnpointed: Boolean =
+ guards.exists { case _: UnpointedGuard[G] => true; case _ => false }
+ def explicitParticipants: Seq[Endpoint[G]] =
+ guards.collect { case EndpointGuard(Ref(endpoint), condition) => endpoint }
- override def enterCheckContextCurrentParticipatingEndpoints(context: CheckContext[G]): Option[Set[Endpoint[G]]] = {
+ override def enterCheckContextCurrentParticipatingEndpoints(
+ context: CheckContext[G]
+ ): Option[Set[Endpoint[G]]] = {
// Assume SeqProg sets participatingEndpoints
assert(context.currentParticipatingEndpoints.isDefined)
@@ -25,18 +40,21 @@ trait ChorLoopImpl[G] extends StatementImpl[G] with ChorLoopOps[G] { this: ChorL
}
}
- override def check(context: CheckContext[G]): Seq[CheckError] = super.check(context) ++ {
- // Assume SeqProg sets participatingEndpoints
- assert(context.currentParticipatingEndpoints.isDefined)
+ override def check(context: CheckContext[G]): Seq[CheckError] =
+ super.check(context) ++ {
+ // Assume SeqProg sets participatingEndpoints
+ assert(context.currentParticipatingEndpoints.isDefined)
- // Ensure the set of participants is at most refined
- if (Set.from(explicitParticipants).subsetOf(context.currentParticipatingEndpoints.get)) {
- Seq()
- } else {
- // There are participants in this if that have been excluded from participation: error
- Seq(SeqProgParticipant(this))
+ // Ensure the set of participants is at most refined
+ if (
+ Set.from(explicitParticipants)
+ .subsetOf(context.currentParticipatingEndpoints.get)
+ ) { Seq() }
+ else {
+ // There are participants in this if that have been excluded from participation: error
+ Seq(SeqProgParticipant(this))
+ }
}
- }
def participants: Set[Endpoint[G]] =
ListSet.from(collect {
diff --git a/src/col/vct/col/ast/statement/veymont/ChorStatementImpl.scala b/src/col/vct/col/ast/statement/veymont/ChorStatementImpl.scala
index 9be0079e8d..ba9286da0e 100644
--- a/src/col/vct/col/ast/statement/veymont/ChorStatementImpl.scala
+++ b/src/col/vct/col/ast/statement/veymont/ChorStatementImpl.scala
@@ -1,23 +1,58 @@
package vct.col.ast.statement.veymont
-import vct.col.ast.{Assert, Assign, Assume, Block, Branch, ChorBranch, ChorLoop, ChorStatement, Communicate, CommunicateStatement, CommunicateX, Deref, Endpoint, EndpointName, Eval, Expr, Loop, MethodInvocation, Scope, ThisChoreography, UnresolvedChorBranch, UnresolvedChorLoop, VeyMontAssignExpression}
+import vct.col.ast.{
+ Assert,
+ Assign,
+ Assume,
+ Block,
+ Branch,
+ ChorBranch,
+ ChorLoop,
+ ChorStatement,
+ Communicate,
+ CommunicateStatement,
+ CommunicateX,
+ Deref,
+ Endpoint,
+ EndpointName,
+ Eval,
+ Expr,
+ Loop,
+ MethodInvocation,
+ Scope,
+ ThisChoreography,
+ UnresolvedChorBranch,
+ UnresolvedChorLoop,
+ VeyMontAssignExpression,
+}
import vct.col.ast.ops.ChorStatementOps
import vct.col.ast.statement.StatementImpl
-import vct.col.check.{CheckContext, CheckError, SeqProgInvocation, SeqProgNoParticipant, SeqProgParticipant, SeqProgStatement}
+import vct.col.check.{
+ CheckContext,
+ CheckError,
+ SeqProgInvocation,
+ SeqProgNoParticipant,
+ SeqProgParticipant,
+ SeqProgStatement,
+}
import vct.col.print.{Ctx, Doc, Line, Text}
import vct.col.ref.Ref
-trait ChorStatementImpl[G] extends ChorStatementOps[G] with StatementImpl[G] { this: ChorStatement[G] =>
+trait ChorStatementImpl[G] extends ChorStatementOps[G] with StatementImpl[G] {
+ this: ChorStatement[G] =>
assert(wellformed)
- def wellformed: Boolean = inner match {
- // ChorStatement should not be nested, and is transparent w.r.t some statements.
- // Proper encoding & filtering of this should happen in LangVeymontToCol
- case _: Block[G] | _: Scope[G] | _: Branch[G] | _: Loop[G] | _: ChorStatement[G] => false
- // Communicate consists of two statements (send & receive) for which each should easily resolve to an endpoint,
- // so it also shouldn't be put in a chorstmt
- case _: CommunicateStatement[G] => false
- case _ => true
- }
+ def wellformed: Boolean =
+ inner match {
+ // ChorStatement should not be nested, and is transparent w.r.t some statements.
+ // Proper encoding & filtering of this should happen in LangVeymontToCol
+ case _: Block[G] | _: Scope[G] | _: Branch[G] | _: Loop[G] |
+ _: ChorStatement[G] =>
+ false
+ // Communicate consists of two statements (send & receive) for which each should easily resolve to an endpoint,
+ // so it also shouldn't be put in a chorstmt
+ case _: CommunicateStatement[G] => false
+ case _ => true
+ }
override def layout(implicit ctx: Ctx): Doc =
(endpoint match {
@@ -26,68 +61,98 @@ trait ChorStatementImpl[G] extends ChorStatementOps[G] with StatementImpl[G] { t
}) <> inner
object eval {
- def enterCheckContextCurrentReceiverEndpoint(chorStmt: ChorStatement[G], node: Eval[G], context: CheckContext[G]): Option[Endpoint[G]] =
+ def enterCheckContextCurrentReceiverEndpoint(
+ chorStmt: ChorStatement[G],
+ node: Eval[G],
+ context: CheckContext[G],
+ ): Option[Endpoint[G]] =
(chorStmt.endpoint, node) match {
- case (Some(Ref(endpoint)), Eval(MethodInvocation(_, _, _, _, _, _, _))) => Some(endpoint)
- case (None, Eval(MethodInvocation(e, _, _, _, _, _, _))) if rootEndpoint(e).isDefined => Some(rootEndpoint(e).get)
+ case (
+ Some(Ref(endpoint)),
+ Eval(MethodInvocation(_, _, _, _, _, _, _)),
+ ) =>
+ Some(endpoint)
+ case (None, Eval(MethodInvocation(e, _, _, _, _, _, _)))
+ if rootEndpoint(e).isDefined =>
+ Some(rootEndpoint(e).get)
case _ => context.currentReceiverEndpoint
}
- def check(chorStmt: ChorStatement[G], node: Eval[G], context: CheckContext[G]): Seq[CheckError] = (context.currentChoreography, node.expr) match {
- case (None, _) => Seq()
- case (Some(_), MethodInvocation(ThisChoreography(_), _, _, _, _, _, _)) => Seq()
- case (Some(_), MethodInvocation(e, _, _, _, _, _, _)) if rootEndpoint(e).isDefined => Seq()
- case _ => Seq(SeqProgInvocation(node))
- }
+ def check(
+ chorStmt: ChorStatement[G],
+ node: Eval[G],
+ context: CheckContext[G],
+ ): Seq[CheckError] =
+ (context.currentChoreography, node.expr) match {
+ case (None, _) => Seq()
+ case (
+ Some(_),
+ MethodInvocation(ThisChoreography(_), _, _, _, _, _, _),
+ ) =>
+ Seq()
+ case (Some(_), MethodInvocation(e, _, _, _, _, _, _))
+ if rootEndpoint(e).isDefined =>
+ Seq()
+ case _ => Seq(SeqProgInvocation(node))
+ }
}
- def rootEndpoint(expr: Expr[G]): Option[Endpoint[G]] = expr match {
- case MethodInvocation(e, _, _, _, _, _, _) => rootEndpoint(e)
- case Deref(obj, _) => rootEndpoint(obj)
- case EndpointName(Ref(e)) => Some(e)
- case _ => None
- }
+ def rootEndpoint(expr: Expr[G]): Option[Endpoint[G]] =
+ expr match {
+ case MethodInvocation(e, _, _, _, _, _, _) => rootEndpoint(e)
+ case Deref(obj, _) => rootEndpoint(obj)
+ case EndpointName(Ref(e)) => Some(e)
+ case _ => None
+ }
object assign {
- def receiver(chorStmt: ChorStatement[G], node: Assign[G]): Option[Endpoint[G]] =
- chorStmt.endpoint.map(_.decl)
+ def receiver(
+ chorStmt: ChorStatement[G],
+ node: Assign[G],
+ ): Option[Endpoint[G]] = chorStmt.endpoint.map(_.decl)
- def enterCheckContextCurrentReceiverEndpoint(chorStmt: ChorStatement[G], node: Assign[G], context: CheckContext[G]): Option[Endpoint[G]] =
- receiver(chorStmt, node)
+ def enterCheckContextCurrentReceiverEndpoint(
+ chorStmt: ChorStatement[G],
+ node: Assign[G],
+ context: CheckContext[G],
+ ): Option[Endpoint[G]] = receiver(chorStmt, node)
- def check(chorStmt: ChorStatement[G], node: Assign[G], context: CheckContext[G]): Seq[CheckError] = {
+ def check(
+ chorStmt: ChorStatement[G],
+ node: Assign[G],
+ context: CheckContext[G],
+ ): Seq[CheckError] = {
receiver(chorStmt, node) match {
- case Some(endpoint) if !context.currentParticipatingEndpoints.get.contains(endpoint) =>
+ case Some(endpoint)
+ if !context.currentParticipatingEndpoints.get.contains(endpoint) =>
Seq(SeqProgParticipant(chorStmt))
case _ => Nil
}
}
}
- override def enterCheckContextCurrentReceiverEndpoint(context: CheckContext[G]): Option[Endpoint[G]] = inner match {
- case node: Eval[G] => eval.enterCheckContextCurrentReceiverEndpoint(this, node, context)
- case node: Assign[G] => assign.enterCheckContextCurrentReceiverEndpoint(this, node, context)
- case _ => context.currentReceiverEndpoint
- }
+ override def enterCheckContextCurrentReceiverEndpoint(
+ context: CheckContext[G]
+ ): Option[Endpoint[G]] =
+ inner match {
+ case node: Eval[G] =>
+ eval.enterCheckContextCurrentReceiverEndpoint(this, node, context)
+ case node: Assign[G] =>
+ assign.enterCheckContextCurrentReceiverEndpoint(this, node, context)
+ case _ => context.currentReceiverEndpoint
+ }
- override def check(context: CheckContext[G]): Seq[CheckError] = super.check(context) ++ (inner match {
- case node: Eval[G] => eval.check(this, node, context)
- case node: Assign[G] => assign.check(this, node, context)
- case
- _: CommunicateX[G] |
- _: CommunicateStatement[G] |
- _: VeyMontAssignExpression[G] |
- _: Branch[G] |
- _: Loop[G] |
- _: Scope[G] |
- _: Block[G] |
- _: Assert[G] |
- _: Assume[G] |
- _: UnresolvedChorBranch[G] |
- _: UnresolvedChorLoop[G] |
- _: ChorBranch[G] |
- _: ChorLoop[G] |
- _: ChorStatement[G] => Seq()
- case _ => Seq(SeqProgStatement(this))
- })
+ override def check(context: CheckContext[G]): Seq[CheckError] =
+ super.check(context) ++
+ (inner match {
+ case node: Eval[G] => eval.check(this, node, context)
+ case node: Assign[G] => assign.check(this, node, context)
+ case _: CommunicateX[G] | _: CommunicateStatement[G] |
+ _: VeyMontAssignExpression[G] | _: Branch[G] | _: Loop[G] |
+ _: Scope[G] | _: Block[G] | _: Assert[G] | _: Assume[G] |
+ _: UnresolvedChorBranch[G] | _: UnresolvedChorLoop[G] |
+ _: ChorBranch[G] | _: ChorLoop[G] | _: ChorStatement[G] =>
+ Seq()
+ case _ => Seq(SeqProgStatement(this))
+ })
}
diff --git a/src/col/vct/col/ast/statement/veymont/CommunicateImpl.scala b/src/col/vct/col/ast/statement/veymont/CommunicateImpl.scala
index 103efe356a..5a7bd590a5 100644
--- a/src/col/vct/col/ast/statement/veymont/CommunicateImpl.scala
+++ b/src/col/vct/col/ast/statement/veymont/CommunicateImpl.scala
@@ -7,21 +7,34 @@ import vct.col.ref.Ref
import vct.col.ast.ops.CommunicateOps
import vct.col.ast.ops.{CommunicateOps, CommunicateFamilyOps}
-trait CommunicateImpl[G] extends CommunicateOps[G] with CommunicateFamilyOps[G] { this: Communicate[G] =>
+trait CommunicateImpl[G]
+ extends CommunicateOps[G] with CommunicateFamilyOps[G] {
+ this: Communicate[G] =>
override def layout(implicit ctx: Ctx): Doc =
- Group(Text("communicate") <+> layoutParticipant(receiver) <> target.show <+> "<-" <+> layoutParticipant(sender) <> msg.show <> ";")
+ Group(
+ Text("communicate") <+> layoutParticipant(receiver) <> target.show <+>
+ "<-" <+> layoutParticipant(sender) <> msg.show <> ";"
+ )
- def layoutParticipant(endpoint: Option[Ref[G, Endpoint[G]]])(implicit ctx: Ctx) =
- endpoint.map(ref => Text(ctx.name(ref)) <> ": ").getOrElse(Text(""))
+ def layoutParticipant(endpoint: Option[Ref[G, Endpoint[G]]])(
+ implicit ctx: Ctx
+ ) = endpoint.map(ref => Text(ctx.name(ref)) <> ": ").getOrElse(Text(""))
- override def check(context: CheckContext[G]): Seq[CheckError] = this match {
- case comm: Communicate[G] if sender.isDefined && !context.currentParticipatingEndpoints.get.contains(sender.get.decl) =>
- Seq(SeqProgParticipant(sender.get.decl))
- case comm: Communicate[G] if receiver.isDefined && !context.currentParticipatingEndpoints.get.contains(receiver.get.decl) =>
- Seq(SeqProgParticipant(receiver.get.decl))
- case _ => Nil
- }
+ override def check(context: CheckContext[G]): Seq[CheckError] =
+ this match {
+ case comm: Communicate[G]
+ if sender.isDefined &&
+ !context.currentParticipatingEndpoints.get
+ .contains(sender.get.decl) =>
+ Seq(SeqProgParticipant(sender.get.decl))
+ case comm: Communicate[G]
+ if receiver.isDefined &&
+ !context.currentParticipatingEndpoints.get
+ .contains(receiver.get.decl) =>
+ Seq(SeqProgParticipant(receiver.get.decl))
+ case _ => Nil
+ }
- def participants: Seq[Endpoint[G]] =
- (sender.toSeq ++ receiver.toSeq).map(_.decl)
+ def participants: Seq[Endpoint[G]] = (sender.toSeq ++ receiver.toSeq)
+ .map(_.decl)
}
diff --git a/src/col/vct/col/ast/statement/veymont/CommunicateXImpl.scala b/src/col/vct/col/ast/statement/veymont/CommunicateXImpl.scala
index a9673da207..96fdaabca4 100644
--- a/src/col/vct/col/ast/statement/veymont/CommunicateXImpl.scala
+++ b/src/col/vct/col/ast/statement/veymont/CommunicateXImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CommunicateX
import vct.col.print.{Ctx, Doc}
import vct.col.ast.ops.CommunicateXOps
-trait CommunicateXImpl[G] extends CommunicateXOps[G] { this: CommunicateX[G] =>
+trait CommunicateXImpl[G] extends CommunicateXOps[G] {
+ this: CommunicateX[G] =>
override def layout(implicit ctx: Ctx): Doc = assign.show
}
diff --git a/src/col/vct/col/ast/statement/veymont/VeyMontAssignExpressionImpl.scala b/src/col/vct/col/ast/statement/veymont/VeyMontAssignExpressionImpl.scala
index 1b24014bd3..4f36cc51dd 100644
--- a/src/col/vct/col/ast/statement/veymont/VeyMontAssignExpressionImpl.scala
+++ b/src/col/vct/col/ast/statement/veymont/VeyMontAssignExpressionImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.VeyMontAssignExpression
import vct.col.print._
import vct.col.ast.ops.VeyMontAssignExpressionOps
-trait VeyMontAssignExpressionImpl[G] extends VeyMontAssignExpressionOps[G] { this: VeyMontAssignExpression[G] =>
+trait VeyMontAssignExpressionImpl[G] extends VeyMontAssignExpressionOps[G] {
+ this: VeyMontAssignExpression[G] =>
override def layout(implicit ctx: Ctx): Doc = assign.show
}
diff --git a/src/col/vct/col/ast/type/TAnyClassImpl.scala b/src/col/vct/col/ast/type/TAnyClassImpl.scala
index f6090146b3..092921c5e0 100644
--- a/src/col/vct/col/ast/type/TAnyClassImpl.scala
+++ b/src/col/vct/col/ast/type/TAnyClassImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.TAnyClass
import vct.col.print._
import vct.col.ast.ops.TAnyClassOps
-trait TAnyClassImpl[G] extends TAnyClassOps[G] { this: TAnyClass[G] =>
+trait TAnyClassImpl[G] extends TAnyClassOps[G] {
+ this: TAnyClass[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("Object")
}
diff --git a/src/col/vct/col/ast/type/TAnyImpl.scala b/src/col/vct/col/ast/type/TAnyImpl.scala
index af6257082d..f8e7d9d73f 100644
--- a/src/col/vct/col/ast/type/TAnyImpl.scala
+++ b/src/col/vct/col/ast/type/TAnyImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.`type`
import vct.col.ast.TAny
import vct.col.ast.ops.TAnyOps
-trait TAnyImpl[G] extends TAnyOps[G] { this: TAny[G] =>
+trait TAnyImpl[G] extends TAnyOps[G] {
+ this: TAny[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/type/TAnyValueImpl.scala b/src/col/vct/col/ast/type/TAnyValueImpl.scala
index e70b98a126..195e4fe15c 100644
--- a/src/col/vct/col/ast/type/TAnyValueImpl.scala
+++ b/src/col/vct/col/ast/type/TAnyValueImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.TAnyValue
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.TAnyValueOps
-trait TAnyValueImpl[G] extends TAnyValueOps[G] { this: TAnyValue[G] =>
+trait TAnyValueImpl[G] extends TAnyValueOps[G] {
+ this: TAnyValue[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("any")
}
diff --git a/src/col/vct/col/ast/type/TArrayImpl.scala b/src/col/vct/col/ast/type/TArrayImpl.scala
index 250e0fc7a7..6cce58a313 100644
--- a/src/col/vct/col/ast/type/TArrayImpl.scala
+++ b/src/col/vct/col/ast/type/TArrayImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.TArray
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.TArrayOps
-trait TArrayImpl[G] extends TArrayOps[G] { this: TArray[G] =>
+trait TArrayImpl[G] extends TArrayOps[G] {
+ this: TArray[G] =>
override def layout(implicit ctx: Ctx): Doc = element.show <> "[]"
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/type/TAxiomaticImpl.scala b/src/col/vct/col/ast/type/TAxiomaticImpl.scala
index 02ba46b302..0e7a0cbd8e 100644
--- a/src/col/vct/col/ast/type/TAxiomaticImpl.scala
+++ b/src/col/vct/col/ast/type/TAxiomaticImpl.scala
@@ -4,7 +4,14 @@ import vct.col.ast.TAxiomatic
import vct.col.print.{Ctx, Doc, Text, Empty, Group}
import vct.col.ast.ops.TAxiomaticOps
-trait TAxiomaticImpl[G] extends TAxiomaticOps[G] { this: TAxiomatic[G] =>
+trait TAxiomaticImpl[G] extends TAxiomaticOps[G] {
+ this: TAxiomatic[G] =>
override def layout(implicit ctx: Ctx): Doc =
- Group(Text(ctx.name(adt)) <> (if(args.isEmpty) Empty else open <> Doc.args(args) <> close))
-}
\ No newline at end of file
+ Group(
+ Text(ctx.name(adt)) <>
+ (if (args.isEmpty)
+ Empty
+ else
+ open <> Doc.args(args) <> close)
+ )
+}
diff --git a/src/col/vct/col/ast/type/TBagImpl.scala b/src/col/vct/col/ast/type/TBagImpl.scala
index f5b01448f0..321ee3540f 100644
--- a/src/col/vct/col/ast/type/TBagImpl.scala
+++ b/src/col/vct/col/ast/type/TBagImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.TBag
import vct.col.print.{Ctx, Doc, Empty, Group, Text}
import vct.col.ast.ops.TBagOps
-trait TBagImpl[G] extends TBagOps[G] { this: TBag[G] =>
+trait TBagImpl[G] extends TBagOps[G] {
+ this: TBag[G] =>
override def layout(implicit ctx: Ctx): Doc =
Group(Text("bag") <> open <> Doc.arg(element) <> close)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/type/TBoolImpl.scala b/src/col/vct/col/ast/type/TBoolImpl.scala
index 3f0c75b9df..b12a553cb0 100644
--- a/src/col/vct/col/ast/type/TBoolImpl.scala
+++ b/src/col/vct/col/ast/type/TBoolImpl.scala
@@ -4,11 +4,13 @@ import vct.col.ast.TBool
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.TBoolOps
-trait TBoolImpl[G] extends TBoolOps[G] { this: TBool[G] =>
- override def layout(implicit ctx: Ctx): Doc = ctx.syntax match {
- case Ctx.PVL => Text("boolean")
- case Ctx.Silver => Text("Bool")
- case Ctx.Java => Text("boolean")
- case Ctx.C | Ctx.Cuda | Ctx.OpenCL | Ctx.CPP => Text("bool")
- }
-}
\ No newline at end of file
+trait TBoolImpl[G] extends TBoolOps[G] {
+ this: TBool[G] =>
+ override def layout(implicit ctx: Ctx): Doc =
+ ctx.syntax match {
+ case Ctx.PVL => Text("boolean")
+ case Ctx.Silver => Text("Bool")
+ case Ctx.Java => Text("boolean")
+ case Ctx.C | Ctx.Cuda | Ctx.OpenCL | Ctx.CPP => Text("bool")
+ }
+}
diff --git a/src/col/vct/col/ast/type/TBoundedIntImpl.scala b/src/col/vct/col/ast/type/TBoundedIntImpl.scala
index f3590db4a6..c0d2899206 100644
--- a/src/col/vct/col/ast/type/TBoundedIntImpl.scala
+++ b/src/col/vct/col/ast/type/TBoundedIntImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.`type`
import vct.col.ast.TBoundedInt
import vct.col.ast.ops.TBoundedIntOps
-trait TBoundedIntImpl[G] extends TBoundedIntOps[G] { this: TBoundedInt[G] =>
+trait TBoundedIntImpl[G] extends TBoundedIntOps[G] {
+ this: TBoundedInt[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/type/TCFloatImpl.scala b/src/col/vct/col/ast/type/TCFloatImpl.scala
index c97b7ad49e..e635d66aa0 100644
--- a/src/col/vct/col/ast/type/TCFloatImpl.scala
+++ b/src/col/vct/col/ast/type/TCFloatImpl.scala
@@ -5,12 +5,14 @@ import vct.col.ast.`type`.typeclass.TFloats
import vct.col.ast.ops.TCFloatOps
object TCFloats {
- def fromTCFloat[G](t: TCFloat[G]): TFloat[G] = TFloat(t.exponent, t.mantissa)(t.o)
+ def fromTCFloat[G](t: TCFloat[G]): TFloat[G] =
+ TFloat(t.exponent, t.mantissa)(t.o)
}
-trait TCFloatImpl[G] extends TCFloatOps[G] { this: TCFloat[G] =>
+trait TCFloatImpl[G] extends TCFloatOps[G] {
+ this: TCFloat[G] =>
def is_ieee754_32bit: Boolean = this == TFloats.C_ieee754_32bit[G]
def is_ieee754_64bit: Boolean = this == TFloats.C_ieee754_64bit[G]
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/type/TCIntImpl.scala b/src/col/vct/col/ast/type/TCIntImpl.scala
index b97a18730b..ffda4c52f0 100644
--- a/src/col/vct/col/ast/type/TCIntImpl.scala
+++ b/src/col/vct/col/ast/type/TCIntImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.TCInt
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.TCIntOps
-trait TCIntImpl[G] extends TCIntOps[G] { this: TCInt[G] =>
+trait TCIntImpl[G] extends TCIntOps[G] {
+ this: TCInt[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("int")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/type/TCharImpl.scala b/src/col/vct/col/ast/type/TCharImpl.scala
index 14c580312a..5e0b428326 100644
--- a/src/col/vct/col/ast/type/TCharImpl.scala
+++ b/src/col/vct/col/ast/type/TCharImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.TChar
import vct.col.print.{Ctx, Doc, Group, Text}
import vct.col.ast.ops.TCharOps
-trait TCharImpl[G] extends TCharOps[G] { this: TChar[G] =>
+trait TCharImpl[G] extends TCharOps[G] {
+ this: TChar[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("char")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/type/TChoreographyImpl.scala b/src/col/vct/col/ast/type/TChoreographyImpl.scala
index 5661da8bc6..57b4885dfa 100644
--- a/src/col/vct/col/ast/type/TChoreographyImpl.scala
+++ b/src/col/vct/col/ast/type/TChoreographyImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.TChoreography
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.TChoreographyOps
-trait TChoreographyImpl[G] extends TChoreographyOps[G] { this: TChoreography[G] =>
+trait TChoreographyImpl[G] extends TChoreographyOps[G] {
+ this: TChoreography[G] =>
override def layout(implicit ctx: Ctx): Doc = Text(ctx.name(cls))
}
diff --git a/src/col/vct/col/ast/type/TClassImpl.scala b/src/col/vct/col/ast/type/TClassImpl.scala
index 1cc807da7a..42a03d7983 100644
--- a/src/col/vct/col/ast/type/TClassImpl.scala
+++ b/src/col/vct/col/ast/type/TClassImpl.scala
@@ -1,21 +1,45 @@
package vct.col.ast.`type`
-import vct.col.ast.{Applicable, Class, ClassDeclaration, Constructor, ContractApplicable, InstanceField, InstanceFunction, InstanceMethod, InstanceOperatorFunction, InstanceOperatorMethod, TClass, Type, Variable}
+import vct.col.ast.{
+ Applicable,
+ Class,
+ ClassDeclaration,
+ Constructor,
+ ContractApplicable,
+ InstanceField,
+ InstanceFunction,
+ InstanceMethod,
+ InstanceOperatorFunction,
+ InstanceOperatorMethod,
+ TClass,
+ Type,
+ Variable,
+}
import vct.col.print.{Ctx, Doc, Empty, Group, Text}
import vct.col.ast.ops.TClassOps
import vct.col.ref.Ref
import vct.result.VerificationError.Unreachable
-trait TClassImpl[G] extends TClassOps[G] { this: TClass[G] =>
- def transSupportArrowsHelper(seen: Set[TClass[G]]): Seq[(TClass[G], TClass[G])] =
- cls.decl.transSupportArrowsHelper(seen).map {
- case (clsA, clsB) => (instantiate(clsA).asClass.get, instantiate(clsB).asClass.get)
+trait TClassImpl[G] extends TClassOps[G] {
+ this: TClass[G] =>
+ def transSupportArrowsHelper(
+ seen: Set[TClass[G]]
+ ): Seq[(TClass[G], TClass[G])] =
+ cls.decl.transSupportArrowsHelper(seen).map { case (clsA, clsB) =>
+ (instantiate(clsA).asClass.get, instantiate(clsB).asClass.get)
}
- def transSupportArrows(): Seq[(TClass[G], TClass[G])] = transSupportArrowsHelper(Set.empty)
+ def transSupportArrows(): Seq[(TClass[G], TClass[G])] =
+ transSupportArrowsHelper(Set.empty)
- override def layout(implicit ctx: Ctx): Doc = Group(Text(ctx.name(cls)) <> (
- if (typeArgs.nonEmpty) Text("<") <> Doc.args(typeArgs) <> ">" else Empty))
+ override def layout(implicit ctx: Ctx): Doc =
+ Group(
+ Text(ctx.name(cls)) <>
+ (if (typeArgs.nonEmpty)
+ Text("<") <> Doc.args(typeArgs) <> ">"
+ else
+ Empty)
+ )
def typeEnv: Map[Variable[G], Type[G]] = cls.decl.typeArgs.zip(typeArgs).toMap
@@ -27,4 +51,4 @@ trait TClassImpl[G] extends TClassOps[G] { this: TClass[G] =>
}
def fieldType(decl: InstanceField[G]): Type[G] = instantiate(decl.t)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/type/TEitherImpl.scala b/src/col/vct/col/ast/type/TEitherImpl.scala
index 0287bd6359..6a3b5dfc7e 100644
--- a/src/col/vct/col/ast/type/TEitherImpl.scala
+++ b/src/col/vct/col/ast/type/TEitherImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.TEither
import vct.col.print.{Ctx, Doc, Group, Text}
import vct.col.ast.ops.TEitherOps
-trait TEitherImpl[G] extends TEitherOps[G] { this: TEither[G] =>
+trait TEitherImpl[G] extends TEitherOps[G] {
+ this: TEither[G] =>
override def layout(implicit ctx: Ctx): Doc =
Group(Text("either") <> open <> Doc.args(Seq(left, right)) <> close)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/type/TEndpointImpl.scala b/src/col/vct/col/ast/type/TEndpointImpl.scala
index 905b089c36..a12fadf8fd 100644
--- a/src/col/vct/col/ast/type/TEndpointImpl.scala
+++ b/src/col/vct/col/ast/type/TEndpointImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.TEndpoint
import vct.col.print._
import vct.col.ast.ops.TEndpointOps
-trait TEndpointImpl[G] extends TEndpointOps[G] { this: TEndpoint[G] =>
+trait TEndpointImpl[G] extends TEndpointOps[G] {
+ this: TEndpoint[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("endpoint")
}
diff --git a/src/col/vct/col/ast/type/TFloatImpl.scala b/src/col/vct/col/ast/type/TFloatImpl.scala
index dba980e14e..7b9430b0af 100644
--- a/src/col/vct/col/ast/type/TFloatImpl.scala
+++ b/src/col/vct/col/ast/type/TFloatImpl.scala
@@ -5,8 +5,9 @@ import vct.col.ast
import vct.col.ast.ops.TFloatOps
import vct.col.ast.`type`.typeclass.TFloats
-trait TFloatImpl[G] extends TFloatOps[G] { this: TFloat[G] =>
+trait TFloatImpl[G] extends TFloatOps[G] {
+ this: TFloat[G] =>
override def is_ieee754_32bit: Boolean = this == TFloats.ieee754_32bit
override def is_ieee754_64bit: Boolean = this == TFloats.ieee754_64bit
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/type/TFractionImpl.scala b/src/col/vct/col/ast/type/TFractionImpl.scala
index 93aa770cfa..ae7e31c86a 100644
--- a/src/col/vct/col/ast/type/TFractionImpl.scala
+++ b/src/col/vct/col/ast/type/TFractionImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.TFraction
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.TFractionOps
-trait TFractionImpl[G] extends TFractionOps[G] { this: TFraction[G] =>
+trait TFractionImpl[G] extends TFractionOps[G] {
+ this: TFraction[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("frac")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/type/TIntImpl.scala b/src/col/vct/col/ast/type/TIntImpl.scala
index 04c9d68949..365cb5224f 100644
--- a/src/col/vct/col/ast/type/TIntImpl.scala
+++ b/src/col/vct/col/ast/type/TIntImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.`type`
import vct.col.ast.TInt
import vct.col.ast.ops.TIntOps
-trait TIntImpl[G] extends TIntOps[G] { this: TInt[G] =>
+trait TIntImpl[G] extends TIntOps[G] {
+ this: TInt[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/type/TMapImpl.scala b/src/col/vct/col/ast/type/TMapImpl.scala
index 46464a1054..6ec43eaac8 100644
--- a/src/col/vct/col/ast/type/TMapImpl.scala
+++ b/src/col/vct/col/ast/type/TMapImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.TMap
import vct.col.print.{Ctx, Doc, Group, Text}
import vct.col.ast.ops.TMapOps
-trait TMapImpl[G] extends TMapOps[G] { this: TMap[G] =>
+trait TMapImpl[G] extends TMapOps[G] {
+ this: TMap[G] =>
override def layout(implicit ctx: Ctx): Doc =
Group(Text("maps") <> open <> Doc.args(Seq(key, value)) <> close)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/type/TMatrixImpl.scala b/src/col/vct/col/ast/type/TMatrixImpl.scala
index 82e7fc5ae3..1b28d5c068 100644
--- a/src/col/vct/col/ast/type/TMatrixImpl.scala
+++ b/src/col/vct/col/ast/type/TMatrixImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.`type`
import vct.col.ast.TMatrix
import vct.col.ast.ops.TMatrixOps
-trait TMatrixImpl[G] extends TMatrixOps[G] { this: TMatrix[G] =>
+trait TMatrixImpl[G] extends TMatrixOps[G] {
+ this: TMatrix[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/type/TModelImpl.scala b/src/col/vct/col/ast/type/TModelImpl.scala
index 28559ea61b..e57b7430a2 100644
--- a/src/col/vct/col/ast/type/TModelImpl.scala
+++ b/src/col/vct/col/ast/type/TModelImpl.scala
@@ -4,7 +4,7 @@ import vct.col.ast.TModel
import vct.col.print._
import vct.col.ast.ops.TModelOps
-trait TModelImpl[G] extends TModelOps[G] { this: TModel[G] =>
- override def layout(implicit ctx: Ctx): Doc =
- Text(ctx.name(model))
-}
\ No newline at end of file
+trait TModelImpl[G] extends TModelOps[G] {
+ this: TModel[G] =>
+ override def layout(implicit ctx: Ctx): Doc = Text(ctx.name(model))
+}
diff --git a/src/col/vct/col/ast/type/TNotAValueImpl.scala b/src/col/vct/col/ast/type/TNotAValueImpl.scala
index bbb9feb073..b2c379a8b4 100644
--- a/src/col/vct/col/ast/type/TNotAValueImpl.scala
+++ b/src/col/vct/col/ast/type/TNotAValueImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.`type`
import vct.col.ast.TNotAValue
import vct.col.ast.ops.TNotAValueOps
-trait TNotAValueImpl[G] extends TNotAValueOps[G] { this: TNotAValue[G] =>
+trait TNotAValueImpl[G] extends TNotAValueOps[G] {
+ this: TNotAValue[G] =>
}
diff --git a/src/col/vct/col/ast/type/TNothingImpl.scala b/src/col/vct/col/ast/type/TNothingImpl.scala
index c81de6c1f3..3d6e01771e 100644
--- a/src/col/vct/col/ast/type/TNothingImpl.scala
+++ b/src/col/vct/col/ast/type/TNothingImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.TNothing
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.TNothingOps
-trait TNothingImpl[G] extends TNothingOps[G] { this: TNothing[G] =>
+trait TNothingImpl[G] extends TNothingOps[G] {
+ this: TNothing[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("nothing")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/type/TNullImpl.scala b/src/col/vct/col/ast/type/TNullImpl.scala
index 19f286f88c..d6d99f365b 100644
--- a/src/col/vct/col/ast/type/TNullImpl.scala
+++ b/src/col/vct/col/ast/type/TNullImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.`type`
import vct.col.ast.TNull
import vct.col.ast.ops.TNullOps
-trait TNullImpl[G] extends TNullOps[G] { this: TNull[G] =>
+trait TNullImpl[G] extends TNullOps[G] {
+ this: TNull[G] =>
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/type/TOptionImpl.scala b/src/col/vct/col/ast/type/TOptionImpl.scala
index 30d02204a8..a409405522 100644
--- a/src/col/vct/col/ast/type/TOptionImpl.scala
+++ b/src/col/vct/col/ast/type/TOptionImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.TOption
import vct.col.print.{Ctx, Doc, Group, Text}
import vct.col.ast.ops.TOptionOps
-trait TOptionImpl[G] extends TOptionOps[G] { this: TOption[G] =>
+trait TOptionImpl[G] extends TOptionOps[G] {
+ this: TOption[G] =>
override def layout(implicit ctx: Ctx): Doc =
Group(Text("option") <> open <> Doc.arg(element) <> close)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/type/TPointerImpl.scala b/src/col/vct/col/ast/type/TPointerImpl.scala
index fe0ad7f39b..f0a5302b3c 100644
--- a/src/col/vct/col/ast/type/TPointerImpl.scala
+++ b/src/col/vct/col/ast/type/TPointerImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.TPointer
import vct.col.print._
import vct.col.ast.ops.TPointerOps
-trait TPointerImpl[G] extends TPointerOps[G] { this: TPointer[G] =>
+trait TPointerImpl[G] extends TPointerOps[G] {
+ this: TPointer[G] =>
override def layoutSplitDeclarator(implicit ctx: Ctx): (Doc, Doc) = {
val (spec, decl) = element.layoutSplitDeclarator
(spec, decl <> "*")
@@ -12,4 +13,4 @@ trait TPointerImpl[G] extends TPointerOps[G] { this: TPointer[G] =>
override def layout(implicit ctx: Ctx): Doc =
Group(Text("pointer") <> open <> element <> close)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/type/TProcessImpl.scala b/src/col/vct/col/ast/type/TProcessImpl.scala
index d7f8583f16..518ce18ba2 100644
--- a/src/col/vct/col/ast/type/TProcessImpl.scala
+++ b/src/col/vct/col/ast/type/TProcessImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.TProcess
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.TProcessOps
-trait TProcessImpl[G] extends TProcessOps[G] { this: TProcess[G] =>
+trait TProcessImpl[G] extends TProcessOps[G] {
+ this: TProcess[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("process")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/type/TProverTypeImpl.scala b/src/col/vct/col/ast/type/TProverTypeImpl.scala
index 46f0514e0a..64564f3512 100644
--- a/src/col/vct/col/ast/type/TProverTypeImpl.scala
+++ b/src/col/vct/col/ast/type/TProverTypeImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.`type`
import vct.col.ast.TProverType
import vct.col.ast.ops.TProverTypeOps
-trait TProverTypeImpl[G] extends TProverTypeOps[G] { this: TProverType[G] =>
+trait TProverTypeImpl[G] extends TProverTypeOps[G] {
+ this: TProverType[G] =>
}
diff --git a/src/col/vct/col/ast/type/TRationalImpl.scala b/src/col/vct/col/ast/type/TRationalImpl.scala
index 99645528fe..22046231a2 100644
--- a/src/col/vct/col/ast/type/TRationalImpl.scala
+++ b/src/col/vct/col/ast/type/TRationalImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.TRational
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.TRationalOps
-trait TRationalImpl[G] extends TRationalOps[G] { this: TRational[G] =>
+trait TRationalImpl[G] extends TRationalOps[G] {
+ this: TRational[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("rational")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/type/TRefImpl.scala b/src/col/vct/col/ast/type/TRefImpl.scala
index 0b76f7220b..ba54df95b9 100644
--- a/src/col/vct/col/ast/type/TRefImpl.scala
+++ b/src/col/vct/col/ast/type/TRefImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.TRef
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.TRefOps
-trait TRefImpl[G] extends TRefOps[G] { this: TRef[G] =>
+trait TRefImpl[G] extends TRefOps[G] {
+ this: TRef[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("ref")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/type/TResourceImpl.scala b/src/col/vct/col/ast/type/TResourceImpl.scala
index f875aaf78a..bdcdcbe75b 100644
--- a/src/col/vct/col/ast/type/TResourceImpl.scala
+++ b/src/col/vct/col/ast/type/TResourceImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.TResource
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.TResourceOps
-trait TResourceImpl[G] extends TResourceOps[G] { this: TResource[G] =>
+trait TResourceImpl[G] extends TResourceOps[G] {
+ this: TResource[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("resource")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/type/TResourceValImpl.scala b/src/col/vct/col/ast/type/TResourceValImpl.scala
index d17c2aa589..83ff9f4409 100644
--- a/src/col/vct/col/ast/type/TResourceValImpl.scala
+++ b/src/col/vct/col/ast/type/TResourceValImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.`type`
import vct.col.ast.TResourceVal
import vct.col.ast.ops.TResourceValOps
-trait TResourceValImpl[G] extends TResourceValOps[G] { this: TResourceVal[G] =>
+trait TResourceValImpl[G] extends TResourceValOps[G] {
+ this: TResourceVal[G] =>
}
diff --git a/src/col/vct/col/ast/type/TSeqImpl.scala b/src/col/vct/col/ast/type/TSeqImpl.scala
index a605903130..fab36672a9 100644
--- a/src/col/vct/col/ast/type/TSeqImpl.scala
+++ b/src/col/vct/col/ast/type/TSeqImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.TSeq
import vct.col.print.{Ctx, Doc, Group, Text}
import vct.col.ast.ops.TSeqOps
-trait TSeqImpl[G] extends TSeqOps[G] { this: TSeq[G] =>
+trait TSeqImpl[G] extends TSeqOps[G] {
+ this: TSeq[G] =>
override def layout(implicit ctx: Ctx): Doc =
Group(Text("seq") <> open <> Doc.arg(element) <> close)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/type/TSetImpl.scala b/src/col/vct/col/ast/type/TSetImpl.scala
index a906060f9c..772e1bc18b 100644
--- a/src/col/vct/col/ast/type/TSetImpl.scala
+++ b/src/col/vct/col/ast/type/TSetImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.TSet
import vct.col.print.{Ctx, Doc, Group, Text}
import vct.col.ast.ops.TSetOps
-trait TSetImpl[G] extends TSetOps[G] { this: TSet[G] =>
+trait TSetImpl[G] extends TSetOps[G] {
+ this: TSet[G] =>
override def layout(implicit ctx: Ctx): Doc =
Group(Text("set") <> open <> Doc.arg(element) <> close)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/type/TStringImpl.scala b/src/col/vct/col/ast/type/TStringImpl.scala
index f69149fd9a..d54755890b 100644
--- a/src/col/vct/col/ast/type/TStringImpl.scala
+++ b/src/col/vct/col/ast/type/TStringImpl.scala
@@ -4,10 +4,12 @@ import vct.col.ast.TString
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.TStringOps
-trait TStringImpl[G] extends TStringOps[G] { this: TString[G] =>
- override def layout(implicit ctx: Ctx): Doc = Text(ctx.syntax match {
- case Ctx.PVL => "string"
- case Ctx.Java => "String"
- case _ => "string"
- })
-}
\ No newline at end of file
+trait TStringImpl[G] extends TStringOps[G] {
+ this: TString[G] =>
+ override def layout(implicit ctx: Ctx): Doc =
+ Text(ctx.syntax match {
+ case Ctx.PVL => "string"
+ case Ctx.Java => "String"
+ case _ => "string"
+ })
+}
diff --git a/src/col/vct/col/ast/type/TTupleImpl.scala b/src/col/vct/col/ast/type/TTupleImpl.scala
index e591f61405..a2e9bf82c6 100644
--- a/src/col/vct/col/ast/type/TTupleImpl.scala
+++ b/src/col/vct/col/ast/type/TTupleImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.TTuple
import vct.col.print.{Ctx, Doc, Group, Text}
import vct.col.ast.ops.TTupleOps
-trait TTupleImpl[G] extends TTupleOps[G] { this: TTuple[G] =>
+trait TTupleImpl[G] extends TTupleOps[G] {
+ this: TTuple[G] =>
override def layout(implicit ctx: Ctx): Doc =
Group(Text("seq") <> open <> Doc.args(elements) <> close)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/type/TTypeImpl.scala b/src/col/vct/col/ast/type/TTypeImpl.scala
index 77eb95e067..ecbf310bab 100644
--- a/src/col/vct/col/ast/type/TTypeImpl.scala
+++ b/src/col/vct/col/ast/type/TTypeImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.TType
import vct.col.print.{Ctx, Doc, Group, Text}
import vct.col.ast.ops.TTypeOps
-trait TTypeImpl[G] extends TTypeOps[G] { this: TType[G] =>
+trait TTypeImpl[G] extends TTypeOps[G] {
+ this: TType[G] =>
override def layout(implicit ctx: Ctx): Doc =
Group(Text("type") <> open <> Doc.arg(t) <> close)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/type/TUnionImpl.scala b/src/col/vct/col/ast/type/TUnionImpl.scala
index ccdb75e5fb..de8160a261 100644
--- a/src/col/vct/col/ast/type/TUnionImpl.scala
+++ b/src/col/vct/col/ast/type/TUnionImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.TUnion
import vct.col.print.{Ctx, Doc}
import vct.col.ast.ops.TUnionOps
-trait TUnionImpl[G] extends TUnionOps[G] { this: TUnion[G] =>
- override def layout(implicit ctx: Ctx): Doc = Doc.fold(types)(_ <+> "|" <+> _)
+trait TUnionImpl[G] extends TUnionOps[G] {
+ this: TUnion[G] =>
+ override def layout(implicit ctx: Ctx): Doc = Doc.fold(types)(_ <+> "|" <+> _)
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/type/TVarImpl.scala b/src/col/vct/col/ast/type/TVarImpl.scala
index 056babccc5..1c5141d431 100644
--- a/src/col/vct/col/ast/type/TVarImpl.scala
+++ b/src/col/vct/col/ast/type/TVarImpl.scala
@@ -5,11 +5,14 @@ import vct.col.check.{CheckContext, CheckError, GenericTypeError}
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.TVarOps
-trait TVarImpl[G] extends TVarOps[G] { this: TVar[G] =>
+trait TVarImpl[G] extends TVarOps[G] {
+ this: TVar[G] =>
override def check(context: CheckContext[G]): Seq[CheckError] =
context.checkInScope(this, ref) ++
- (if(TType(TAnyValue()).superTypeOf(ref.decl.t)) Nil
- else Seq(GenericTypeError(this, TType(TAnyValue()))))
+ (if (TType(TAnyValue()).superTypeOf(ref.decl.t))
+ Nil
+ else
+ Seq(GenericTypeError(this, TType(TAnyValue()))))
override def layout(implicit ctx: Ctx): Doc = Text(ctx.name(ref))
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/type/TVectorImpl.scala b/src/col/vct/col/ast/type/TVectorImpl.scala
index c921fc5ef9..b44351e0ff 100644
--- a/src/col/vct/col/ast/type/TVectorImpl.scala
+++ b/src/col/vct/col/ast/type/TVectorImpl.scala
@@ -4,7 +4,11 @@ import vct.col.ast.TVector
import vct.col.ast.ops.TVectorOps
import vct.col.print.{Ctx, Doc, Group, Text}
-trait TVectorImpl[G] extends TVectorOps[G] { this: TVector[G] =>
+trait TVectorImpl[G] extends TVectorOps[G] {
+ this: TVector[G] =>
override def layout(implicit ctx: Ctx): Doc =
- Group(Text("vector") <> open <> Doc.arg(element) <> "," <> size.toString <> close)
-}
\ No newline at end of file
+ Group(
+ Text("vector") <> open <> Doc.arg(element) <> "," <> size.toString <>
+ close
+ )
+}
diff --git a/src/col/vct/col/ast/type/TVeyMontChannelImpl.scala b/src/col/vct/col/ast/type/TVeyMontChannelImpl.scala
index 498e9c7304..1fc0c0646c 100644
--- a/src/col/vct/col/ast/type/TVeyMontChannelImpl.scala
+++ b/src/col/vct/col/ast/type/TVeyMontChannelImpl.scala
@@ -4,7 +4,7 @@ import vct.col.ast.TVeyMontChannel
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.TVeyMontChannelOps
-trait TVeyMontChannelImpl[G] extends TVeyMontChannelOps[G] { this: TVeyMontChannel[G] =>
- override def layout(implicit ctx: Ctx): Doc =
- Text(this.channelType)
-}
\ No newline at end of file
+trait TVeyMontChannelImpl[G] extends TVeyMontChannelOps[G] {
+ this: TVeyMontChannel[G] =>
+ override def layout(implicit ctx: Ctx): Doc = Text(this.channelType)
+}
diff --git a/src/col/vct/col/ast/type/TVoidImpl.scala b/src/col/vct/col/ast/type/TVoidImpl.scala
index aaadc4ea41..dae4d681e7 100644
--- a/src/col/vct/col/ast/type/TVoidImpl.scala
+++ b/src/col/vct/col/ast/type/TVoidImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.TVoid
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.TVoidOps
-trait TVoidImpl[G] extends TVoidOps[G] { this: TVoid[G] =>
+trait TVoidImpl[G] extends TVoidOps[G] {
+ this: TVoid[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("void")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/type/TZFractionImpl.scala b/src/col/vct/col/ast/type/TZFractionImpl.scala
index ec3eb85445..12f13268d7 100644
--- a/src/col/vct/col/ast/type/TZFractionImpl.scala
+++ b/src/col/vct/col/ast/type/TZFractionImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.TZFraction
import vct.col.print.{Ctx, Doc, Text}
import vct.col.ast.ops.TZFractionOps
-trait TZFractionImpl[G] extends TZFractionOps[G] { this: TZFraction[G] =>
+trait TZFractionImpl[G] extends TZFractionOps[G] {
+ this: TZFraction[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("zfrac")
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/ast/type/typeclass/CompositeTypeImpl.scala b/src/col/vct/col/ast/type/typeclass/CompositeTypeImpl.scala
index bc78e64de1..324f956b48 100644
--- a/src/col/vct/col/ast/type/typeclass/CompositeTypeImpl.scala
+++ b/src/col/vct/col/ast/type/typeclass/CompositeTypeImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.`type`.typeclass
import vct.col.ast.CompositeType
-trait CompositeTypeImpl[G] { this: CompositeType[G] =>
+trait CompositeTypeImpl[G] {
+ this: CompositeType[G] =>
}
diff --git a/src/col/vct/col/ast/type/typeclass/DeclaredTypeImpl.scala b/src/col/vct/col/ast/type/typeclass/DeclaredTypeImpl.scala
index 9d6e892977..201074fefd 100644
--- a/src/col/vct/col/ast/type/typeclass/DeclaredTypeImpl.scala
+++ b/src/col/vct/col/ast/type/typeclass/DeclaredTypeImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.`type`.typeclass
import vct.col.ast.DeclaredType
-trait DeclaredTypeImpl[G] { this: DeclaredType[G] =>
+trait DeclaredTypeImpl[G] {
+ this: DeclaredType[G] =>
}
diff --git a/src/col/vct/col/ast/type/typeclass/FloatTypeImpl.scala b/src/col/vct/col/ast/type/typeclass/FloatTypeImpl.scala
index 5431475459..13095208d3 100644
--- a/src/col/vct/col/ast/type/typeclass/FloatTypeImpl.scala
+++ b/src/col/vct/col/ast/type/typeclass/FloatTypeImpl.scala
@@ -1,7 +1,14 @@
package vct.col.ast.`type`.typeclass
import vct.col.ast.`type`.TCFloats.fromTCFloat
-import vct.col.ast.{CPrimitiveType, CSpecificationType, FloatType, TCFloat, TFloat, Type}
+import vct.col.ast.{
+ CPrimitiveType,
+ CSpecificationType,
+ FloatType,
+ TCFloat,
+ TFloat,
+ Type,
+}
import vct.col.origin.{DiagnosticOrigin, Origin}
import vct.col.print.{Ctx, Doc, Text}
import vct.col.typerules.CoercionUtils
@@ -11,62 +18,86 @@ import vct.col.resolve.lang.C
// https://en.wikipedia.org/wiki/Double-precision_floating-point_format#IEEE_754_double-precision_binary_floating-point_format:_binary64
object TFloats {
// Integer part bit that is implicit, is included here.
- def ieee754_32bit[G](implicit o: Origin = DiagnosticOrigin): TFloat[G] = vct.col.ast.TFloat(8, 24)
- def ieee754_64bit[G](implicit o: Origin = DiagnosticOrigin): TFloat[G] = vct.col.ast.TFloat(11, 53)
- def C_ieee754_32bit[G](implicit o: Origin = DiagnosticOrigin): TCFloat[G] = vct.col.ast.TCFloat(8, 24)
- def C_ieee754_64bit[G](implicit o: Origin = DiagnosticOrigin): TCFloat[G] = vct.col.ast.TCFloat(11, 53)
+ def ieee754_32bit[G](implicit o: Origin = DiagnosticOrigin): TFloat[G] =
+ vct.col.ast.TFloat(8, 24)
+ def ieee754_64bit[G](implicit o: Origin = DiagnosticOrigin): TFloat[G] =
+ vct.col.ast.TFloat(11, 53)
+ def C_ieee754_32bit[G](implicit o: Origin = DiagnosticOrigin): TCFloat[G] =
+ vct.col.ast.TCFloat(8, 24)
+ def C_ieee754_64bit[G](implicit o: Origin = DiagnosticOrigin): TCFloat[G] =
+ vct.col.ast.TCFloat(11, 53)
// Only returns a float, when one of the types is floating itself
// Returns to biggest float, e.g. (float32, float64) should return float64
def getFloatMax[G](ll: Type[G], rr: Type[G]): Option[FloatType[G]] = {
val l = C.stripCPrimitiveType(ll)
val r = C.stripCPrimitiveType(rr)
- val promote = (l, r) match {
- case (_: TFloat[G], _) => true
- case (_, _: TFloat[G]) => true
- case _ => false
- }
+ val promote =
+ (l, r) match {
+ case (_: TFloat[G], _) => true
+ case (_, _: TFloat[G]) => true
+ case _ => false
+ }
val promoting: FloatType[G] => FloatType[G] = {
- case t: TCFloat[G] => if(promote) fromTCFloat(t) else t
+ case t: TCFloat[G] =>
+ if (promote)
+ fromTCFloat(t)
+ else
+ t
case t: TFloat[G] => t
}
(l, r) match {
- case (l: FloatType[G], r: FloatType[G]) if r.exponent == l.exponent && r.mantissa == l.mantissa => Some(promoting(l))
- case (l: FloatType[G], r: FloatType[G]) if l.exponent < r.exponent && l.mantissa < r.mantissa => Some(promoting(r))
- case (l: FloatType[G], r: FloatType[G]) if r.exponent < l.exponent && r.mantissa < l.mantissa => Some(promoting(l))
- case (l: FloatType[G], r: FloatType[G]) => ??? // Assuming there is only one Float for each exponent, mantissa
+ case (l: FloatType[G], r: FloatType[G])
+ if r.exponent == l.exponent && r.mantissa == l.mantissa =>
+ Some(promoting(l))
+ case (l: FloatType[G], r: FloatType[G])
+ if l.exponent < r.exponent && l.mantissa < r.mantissa =>
+ Some(promoting(r))
+ case (l: FloatType[G], r: FloatType[G])
+ if r.exponent < l.exponent && r.mantissa < l.mantissa =>
+ Some(promoting(l))
+ case (l: FloatType[G], r: FloatType[G]) =>
+ ??? // Assuming there is only one Float for each exponent, mantissa
// If one if them needs to be coerced, we coerce and try again
- case (l: FloatType[G], r) => CoercionUtils.getCoercion(r, l).flatMap(c => getFloatMax(l, c.target))
- case (l, r: FloatType[G]) => CoercionUtils.getCoercion(l, r).flatMap(c => getFloatMax(r, c.target))
+ case (l: FloatType[G], r) =>
+ CoercionUtils.getCoercion(r, l).flatMap(c => getFloatMax(l, c.target))
+ case (l, r: FloatType[G]) =>
+ CoercionUtils.getCoercion(l, r).flatMap(c => getFloatMax(r, c.target))
case _ => None
}
}
}
-trait FloatTypeImpl[G] { this: FloatType[G] =>
+trait FloatTypeImpl[G] {
+ this: FloatType[G] =>
val exponent: Int
val mantissa: Int
assert(this.exponent > 0)
assert(this.mantissa > 0)
- def layoutFloat(implicit ctx: Ctx): Doc = Text(ctx.syntax match {
- case Ctx.PVL => "float32"
- case Ctx.Java => "float"
- case _ => "float"
- })
+ def layoutFloat(implicit ctx: Ctx): Doc =
+ Text(ctx.syntax match {
+ case Ctx.PVL => "float32"
+ case Ctx.Java => "float"
+ case _ => "float"
+ })
- def layoutDouble(implicit ctx: Ctx): Doc = Text(ctx.syntax match {
- case Ctx.PVL => "float64"
- case Ctx.Java => "double"
- case _ => "double"
- })
+ def layoutDouble(implicit ctx: Ctx): Doc =
+ Text(ctx.syntax match {
+ case Ctx.PVL => "float64"
+ case Ctx.Java => "double"
+ case _ => "double"
+ })
def is_ieee754_32bit: Boolean
def is_ieee754_64bit: Boolean
override def layout(implicit ctx: Ctx): Doc =
- if (is_ieee754_32bit) layoutFloat
- else if (is_ieee754_64bit) layoutDouble
- else Text(s"??float_${exponent}_${mantissa}??")
+ if (is_ieee754_32bit)
+ layoutFloat
+ else if (is_ieee754_64bit)
+ layoutDouble
+ else
+ Text(s"??float_${exponent}_${mantissa}??")
}
diff --git a/src/col/vct/col/ast/type/typeclass/IntTypeImpl.scala b/src/col/vct/col/ast/type/typeclass/IntTypeImpl.scala
index 50fbabf4c3..18f55ddf40 100644
--- a/src/col/vct/col/ast/type/typeclass/IntTypeImpl.scala
+++ b/src/col/vct/col/ast/type/typeclass/IntTypeImpl.scala
@@ -3,6 +3,7 @@ package vct.col.ast.`type`.typeclass
import vct.col.ast.IntType
import vct.col.print.{Ctx, Doc, Text}
-trait IntTypeImpl[G] { this: IntType[G] =>
+trait IntTypeImpl[G] {
+ this: IntType[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("int")
}
diff --git a/src/col/vct/col/ast/type/typeclass/NumericTypeImpl.scala b/src/col/vct/col/ast/type/typeclass/NumericTypeImpl.scala
index 0eea7a7fe5..049fc6ab06 100644
--- a/src/col/vct/col/ast/type/typeclass/NumericTypeImpl.scala
+++ b/src/col/vct/col/ast/type/typeclass/NumericTypeImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.`type`.typeclass
import vct.col.ast.NumericType
-trait NumericTypeImpl[G] { this: NumericType[G] =>
+trait NumericTypeImpl[G] {
+ this: NumericType[G] =>
}
diff --git a/src/col/vct/col/ast/type/typeclass/PrimitiveTypeImpl.scala b/src/col/vct/col/ast/type/typeclass/PrimitiveTypeImpl.scala
index a679e80da0..5f63e96f85 100644
--- a/src/col/vct/col/ast/type/typeclass/PrimitiveTypeImpl.scala
+++ b/src/col/vct/col/ast/type/typeclass/PrimitiveTypeImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.`type`.typeclass
import vct.col.ast.PrimitiveType
-trait PrimitiveTypeImpl[G] { this: PrimitiveType[G] =>
+trait PrimitiveTypeImpl[G] {
+ this: PrimitiveType[G] =>
}
diff --git a/src/col/vct/col/ast/type/typeclass/SizedTypeImpl.scala b/src/col/vct/col/ast/type/typeclass/SizedTypeImpl.scala
index f897ed6394..cdde112818 100644
--- a/src/col/vct/col/ast/type/typeclass/SizedTypeImpl.scala
+++ b/src/col/vct/col/ast/type/typeclass/SizedTypeImpl.scala
@@ -2,6 +2,7 @@ package vct.col.ast.`type`.typeclass
import vct.col.ast.SizedType
-trait SizedTypeImpl[G] { this: SizedType[G] =>
+trait SizedTypeImpl[G] {
+ this: SizedType[G] =>
}
diff --git a/src/col/vct/col/ast/type/typeclass/TypeImpl.scala b/src/col/vct/col/ast/type/typeclass/TypeImpl.scala
index 05a839677b..b2bb1bc8ab 100644
--- a/src/col/vct/col/ast/type/typeclass/TypeImpl.scala
+++ b/src/col/vct/col/ast/type/typeclass/TypeImpl.scala
@@ -8,7 +8,8 @@ import vct.col.typerules.CoercionUtils
import vct.col.print._
import vct.col.ast.ops.TypeFamilyOps
-trait TypeImpl[G] extends TypeFamilyOps[G] { this: Type[G] =>
+trait TypeImpl[G] extends TypeFamilyOps[G] {
+ this: Type[G] =>
def superTypeOf(other: Type[G]): Boolean =
CoercionUtils.getCoercion(other, this).isDefined
@@ -16,44 +17,76 @@ trait TypeImpl[G] extends TypeFamilyOps[G] { this: Type[G] =>
def asSeq: Option[TSeq[G]] = CoercionUtils.getAnySeqCoercion(this).map(_._2)
def asSet: Option[TSet[G]] = CoercionUtils.getAnySetCoercion(this).map(_._2)
- def asVector: Option[TVector[G]] = CoercionUtils.getAnyVectorCoercion(this).map(_._2)
+ def asVector: Option[TVector[G]] =
+ CoercionUtils.getAnyVectorCoercion(this).map(_._2)
def asBag: Option[TBag[G]] = CoercionUtils.getAnyBagCoercion(this).map(_._2)
- def asPointer: Option[TPointer[G]] = CoercionUtils.getAnyPointerCoercion(this).map(_._2)
- def asArray: Option[TArray[G]] = CoercionUtils.getAnyArrayCoercion(this).map(_._2)
- def asCArray: Option[CTArray[G]] = CoercionUtils.getAnyCArrayCoercion(this).map(_._2)
- def asCPPArray: Option[CPPTArray[G]] = CoercionUtils.getAnyCPPArrayCoercion(this).map(_._2)
- def asOption: Option[TOption[G]] = CoercionUtils.getAnyOptionCoercion(this).map(_._2)
+ def asPointer: Option[TPointer[G]] =
+ CoercionUtils.getAnyPointerCoercion(this).map(_._2)
+ def asArray: Option[TArray[G]] =
+ CoercionUtils.getAnyArrayCoercion(this).map(_._2)
+ def asCArray: Option[CTArray[G]] =
+ CoercionUtils.getAnyCArrayCoercion(this).map(_._2)
+ def asCPPArray: Option[CPPTArray[G]] =
+ CoercionUtils.getAnyCPPArrayCoercion(this).map(_._2)
+ def asOption: Option[TOption[G]] =
+ CoercionUtils.getAnyOptionCoercion(this).map(_._2)
def asMap: Option[TMap[G]] = CoercionUtils.getAnyMapCoercion(this).map(_._2)
- def asTuple: Option[TTuple[G]] = CoercionUtils.getAnyTupleCoercion(this).map(_._2)
- def asMatrix: Option[TMatrix[G]] = CoercionUtils.getAnyMatrixCoercion(this).map(_._2)
- def asModel: Option[TModel[G]] = CoercionUtils.getAnyModelCoercion(this).map(_._2)
- def asClass: Option[TClass[G]] = CoercionUtils.getAnyClassCoercion(this).map(_._2)
- def asEither: Option[TEither[G]] = CoercionUtils.getAnyEitherCoercion(this).map(_._2)
- def asBitvec: Option[TSmtlibBitVector[G]] = CoercionUtils.getAnyBitvecCoercion(this).map(_._2)
- def asSmtlibFloat: Option[TSmtlibFloatingPoint[G]] = CoercionUtils.getAnySmtlibFloatCoercion(this).map(_._2)
- def asSmtlibArray: Option[TSmtlibArray[G]] = CoercionUtils.getAnySmtlibArrayCoercion(this).map(_._2)
- def asSmtlibSeq: Option[TSmtlibSeq[G]] = CoercionUtils.getAnySmtlibSeqCoercion(this).map(_._2)
+ def asTuple: Option[TTuple[G]] =
+ CoercionUtils.getAnyTupleCoercion(this).map(_._2)
+ def asMatrix: Option[TMatrix[G]] =
+ CoercionUtils.getAnyMatrixCoercion(this).map(_._2)
+ def asModel: Option[TModel[G]] =
+ CoercionUtils.getAnyModelCoercion(this).map(_._2)
+ def asClass: Option[TClass[G]] =
+ CoercionUtils.getAnyClassCoercion(this).map(_._2)
+ def asEither: Option[TEither[G]] =
+ CoercionUtils.getAnyEitherCoercion(this).map(_._2)
+ def asBitvec: Option[TSmtlibBitVector[G]] =
+ CoercionUtils.getAnyBitvecCoercion(this).map(_._2)
+ def asSmtlibFloat: Option[TSmtlibFloatingPoint[G]] =
+ CoercionUtils.getAnySmtlibFloatCoercion(this).map(_._2)
+ def asSmtlibArray: Option[TSmtlibArray[G]] =
+ CoercionUtils.getAnySmtlibArrayCoercion(this).map(_._2)
+ def asSmtlibSeq: Option[TSmtlibSeq[G]] =
+ CoercionUtils.getAnySmtlibSeqCoercion(this).map(_._2)
/*def asVector: Option[TVector] = optMatch(this) { case vec: TVector => vec }*/
def particularize(substitutions: Map[Variable[G], Type[G]]): Type[G] = {
case object Particularize extends NonLatchingRewriter[G, G] {
- case object IdentitySuccessorsProvider extends SuccessorsProviderTrafo[G, G](allScopes.freeze) {
- override def preTransform[I <: Declaration[G], O <: Declaration[G]](pre: I): Option[O] =
- Some(pre.asInstanceOf[O])
+ case object IdentitySuccessorsProvider
+ extends SuccessorsProviderTrafo[G, G](allScopes.freeze) {
+ override def preTransform[I <: Declaration[G], O <: Declaration[G]](
+ pre: I
+ ): Option[O] = Some(pre.asInstanceOf[O])
}
- override def succProvider: SuccessorsProvider[G, G] = IdentitySuccessorsProvider
+ override def succProvider: SuccessorsProvider[G, G] =
+ IdentitySuccessorsProvider
- override def dispatch(t: Type[G]): Type[G] = t match {
- case TVar(Ref(v)) => substitutions(v)
- case other => rewriteDefault(other)
- }
+ override def dispatch(t: Type[G]): Type[G] =
+ t match {
+ case TVar(Ref(v)) => substitutions(v)
+ case other => rewriteDefault(other)
+ }
}
Particularize.dispatch(this)
}
- def layoutSplitDeclarator(implicit ctx: Ctx): (Doc, Doc) = (show, vct.col.print.Empty)
+ def layoutSplitDeclarator(implicit ctx: Ctx): (Doc, Doc) =
+ (show, vct.col.print.Empty)
- protected def open(implicit ctx: Ctx): Doc = Text(if(ctx.syntax == Ctx.Silver) "[" else "<")
- protected def close(implicit ctx: Ctx): Doc = Text(if(ctx.syntax == Ctx.Silver) "]" else ">")
+ protected def open(implicit ctx: Ctx): Doc =
+ Text(
+ if (ctx.syntax == Ctx.Silver)
+ "["
+ else
+ "<"
+ )
+ protected def close(implicit ctx: Ctx): Doc =
+ Text(
+ if (ctx.syntax == Ctx.Silver)
+ "]"
+ else
+ ">"
+ )
}
diff --git a/src/col/vct/col/ast/unsorted/BipGlueImpl.scala b/src/col/vct/col/ast/unsorted/BipGlueImpl.scala
index 5760ae9551..850d29a775 100644
--- a/src/col/vct/col/ast/unsorted/BipGlueImpl.scala
+++ b/src/col/vct/col/ast/unsorted/BipGlueImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.BipGlue
import vct.col.ast.ops.BipGlueOps
import vct.col.print._
-trait BipGlueImpl[G] extends BipGlueOps[G] { this: BipGlue[G] =>
+trait BipGlueImpl[G] extends BipGlueOps[G] {
+ this: BipGlue[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/unsorted/BipPortTypeImpl.scala b/src/col/vct/col/ast/unsorted/BipPortTypeImpl.scala
index a165517298..760fa87c43 100644
--- a/src/col/vct/col/ast/unsorted/BipPortTypeImpl.scala
+++ b/src/col/vct/col/ast/unsorted/BipPortTypeImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.BipPortType
import vct.col.ast.ops.BipPortTypeFamilyOps
import vct.col.print._
-trait BipPortTypeImpl[G] extends BipPortTypeFamilyOps[G] { this: BipPortType[G] =>
+trait BipPortTypeImpl[G] extends BipPortTypeFamilyOps[G] {
+ this: BipPortType[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/unsorted/CFunctionTypeExtensionModifierImpl.scala b/src/col/vct/col/ast/unsorted/CFunctionTypeExtensionModifierImpl.scala
index e2e879ebb8..db6ad82180 100644
--- a/src/col/vct/col/ast/unsorted/CFunctionTypeExtensionModifierImpl.scala
+++ b/src/col/vct/col/ast/unsorted/CFunctionTypeExtensionModifierImpl.scala
@@ -5,9 +5,12 @@ import vct.col.ast.ops.CFunctionTypeExtensionModifierOps
import vct.col.print.Doc.fold
import vct.col.print._
-trait CFunctionTypeExtensionModifierImpl[G] extends CFunctionTypeExtensionModifierOps[G] { this: CFunctionTypeExtensionModifier[G] =>
+trait CFunctionTypeExtensionModifierImpl[G]
+ extends CFunctionTypeExtensionModifierOps[G] {
+ this: CFunctionTypeExtensionModifier[G] =>
override def layout(implicit ctx: Ctx): Doc = {
- val attr = extensions.collect{case a: CTypeAttribute[G] => a}.map(a => Text(a.name) <> "(" <> Doc.args(a.args) <> ")")
+ val attr = extensions.collect { case a: CTypeAttribute[G] => a }
+ .map(a => Text(a.name) <> "(" <> Doc.args(a.args) <> ")")
Text("__attribute__ ((") <> fold(attr)(_ <+> _) <> "))"
}
}
diff --git a/src/col/vct/col/ast/unsorted/ChooseFreshImpl.scala b/src/col/vct/col/ast/unsorted/ChooseFreshImpl.scala
index dfa49c2323..0fe8ef860b 100644
--- a/src/col/vct/col/ast/unsorted/ChooseFreshImpl.scala
+++ b/src/col/vct/col/ast/unsorted/ChooseFreshImpl.scala
@@ -4,9 +4,9 @@ import vct.col.ast.{ChooseFresh, Type}
import vct.col.ast.ops.ChooseFreshOps
import vct.col.print._
-trait ChooseFreshImpl[G] extends ChooseFreshOps[G] { this: ChooseFresh[G] =>
- override lazy val t: Type[G] =
- xs.t.asSet.get.element
+trait ChooseFreshImpl[G] extends ChooseFreshOps[G] {
+ this: ChooseFresh[G] =>
+ override lazy val t: Type[G] = xs.t.asSet.get.element
override def precedence: Int = Precedence.ATOMIC
override def layout(implicit ctx: Ctx): Doc =
diff --git a/src/col/vct/col/ast/unsorted/ChooseImpl.scala b/src/col/vct/col/ast/unsorted/ChooseImpl.scala
index 90cd37c70e..e6a89f6231 100644
--- a/src/col/vct/col/ast/unsorted/ChooseImpl.scala
+++ b/src/col/vct/col/ast/unsorted/ChooseImpl.scala
@@ -4,9 +4,9 @@ import vct.col.ast.{Choose, Type}
import vct.col.ast.ops.ChooseOps
import vct.col.print._
-trait ChooseImpl[G] extends ChooseOps[G] { this: Choose[G] =>
- override lazy val t: Type[G] =
- xs.t.asSet.get.element
+trait ChooseImpl[G] extends ChooseOps[G] {
+ this: Choose[G] =>
+ override lazy val t: Type[G] = xs.t.asSet.get.element
override def precedence: Int = Precedence.ATOMIC
override def layout(implicit ctx: Ctx): Doc =
diff --git a/src/col/vct/col/ast/unsorted/ChorPermImpl.scala b/src/col/vct/col/ast/unsorted/ChorPermImpl.scala
index 54fbfd2e88..74689eeb45 100644
--- a/src/col/vct/col/ast/unsorted/ChorPermImpl.scala
+++ b/src/col/vct/col/ast/unsorted/ChorPermImpl.scala
@@ -4,9 +4,11 @@ import vct.col.ast.{ChorPerm, TResource, Type}
import vct.col.ast.ops.ChorPermOps
import vct.col.print._
-trait ChorPermImpl[G] extends ChorPermOps[G] { this: ChorPerm[G] =>
+trait ChorPermImpl[G] extends ChorPermOps[G] {
+ this: ChorPerm[G] =>
override def layout(implicit ctx: Ctx): Doc =
- Text("Perm") <> "[" <> ctx.name(endpoint) <> "]" <> "(" <> loc <> ", " <> perm <> ")"
+ Text("Perm") <> "[" <> ctx.name(endpoint) <> "]" <> "(" <> loc <> ", " <>
+ perm <> ")"
override def t: Type[G] = TResource()
}
diff --git a/src/col/vct/col/ast/unsorted/CoerceDecreasePrecisionImpl.scala b/src/col/vct/col/ast/unsorted/CoerceDecreasePrecisionImpl.scala
index 63a9d2542e..c59f6f7056 100644
--- a/src/col/vct/col/ast/unsorted/CoerceDecreasePrecisionImpl.scala
+++ b/src/col/vct/col/ast/unsorted/CoerceDecreasePrecisionImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CoerceDecreasePrecision
import vct.col.ast.ops.CoerceDecreasePrecisionOps
import vct.col.print._
-trait CoerceDecreasePrecisionImpl[G] extends CoerceDecreasePrecisionOps[G] { this: CoerceDecreasePrecision[G] =>
+trait CoerceDecreasePrecisionImpl[G] extends CoerceDecreasePrecisionOps[G] {
+ this: CoerceDecreasePrecision[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/unsorted/CoerceIncreasePrecisionImpl.scala b/src/col/vct/col/ast/unsorted/CoerceIncreasePrecisionImpl.scala
index 840db45313..b7ad3c115c 100644
--- a/src/col/vct/col/ast/unsorted/CoerceIncreasePrecisionImpl.scala
+++ b/src/col/vct/col/ast/unsorted/CoerceIncreasePrecisionImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.CoerceIncreasePrecision
import vct.col.ast.ops.CoerceIncreasePrecisionOps
import vct.col.print._
-trait CoerceIncreasePrecisionImpl[G] extends CoerceIncreasePrecisionOps[G] { this: CoerceIncreasePrecision[G] =>
+trait CoerceIncreasePrecisionImpl[G] extends CoerceIncreasePrecisionOps[G] {
+ this: CoerceIncreasePrecision[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/unsorted/CommunicateStatementImpl.scala b/src/col/vct/col/ast/unsorted/CommunicateStatementImpl.scala
index 3fc866199a..f91db97077 100644
--- a/src/col/vct/col/ast/unsorted/CommunicateStatementImpl.scala
+++ b/src/col/vct/col/ast/unsorted/CommunicateStatementImpl.scala
@@ -4,6 +4,8 @@ import vct.col.ast.CommunicateStatement
import vct.col.ast.ops.CommunicateStatementOps
import vct.col.print._
-trait CommunicateStatementImpl[G] extends CommunicateStatementOps[G] { this: CommunicateStatement[G] =>
- override def layout(implicit ctx: Ctx): Doc = Text("/* Communicate container */") <+> inner
+trait CommunicateStatementImpl[G] extends CommunicateStatementOps[G] {
+ this: CommunicateStatement[G] =>
+ override def layout(implicit ctx: Ctx): Doc =
+ Text("/* Communicate container */") <+> inner
}
diff --git a/src/col/vct/col/ast/unsorted/ConstructorImpl.scala b/src/col/vct/col/ast/unsorted/ConstructorImpl.scala
index 6f1a0a702a..23f656fc03 100644
--- a/src/col/vct/col/ast/unsorted/ConstructorImpl.scala
+++ b/src/col/vct/col/ast/unsorted/ConstructorImpl.scala
@@ -4,16 +4,20 @@ import vct.col.ast.{Constructor, Statement, TClass, TVar, Variable}
import vct.col.ast.ops.ConstructorOps
import vct.col.print._
-trait ConstructorImpl[G] extends ConstructorOps[G] { this: Constructor[G] =>
+trait ConstructorImpl[G] extends ConstructorOps[G] {
+ this: Constructor[G] =>
override def pure: Boolean = false
- override def returnType: TClass[G] = TClass(cls, cls.decl.typeArgs.map((v: Variable[G]) => TVar(v.ref)))
+ override def returnType: TClass[G] =
+ TClass(cls, cls.decl.typeArgs.map((v: Variable[G]) => TVar(v.ref)))
- override def layout(implicit ctx: Ctx): Doc = {
- Doc.stack(Seq(
- contract,
- Group(Text("constructor") <> DocUtil.javaGenericParams(typeArgs) <> "(" <> Doc.args(args) <> ")") <>
- body.map(Text(" ") <> _).getOrElse(Text(";"))
- ))
- }
+ override def layout(implicit ctx: Ctx): Doc = {
+ Doc.stack(Seq(
+ contract,
+ Group(
+ Text("constructor") <> DocUtil.javaGenericParams(typeArgs) <> "(" <>
+ Doc.args(args) <> ")"
+ ) <> body.map(Text(" ") <> _).getOrElse(Text(";")),
+ ))
+ }
}
diff --git a/src/col/vct/col/ast/unsorted/ConstructorInvocationImpl.scala b/src/col/vct/col/ast/unsorted/ConstructorInvocationImpl.scala
index e9538d70d6..cd0b8d4f52 100644
--- a/src/col/vct/col/ast/unsorted/ConstructorInvocationImpl.scala
+++ b/src/col/vct/col/ast/unsorted/ConstructorInvocationImpl.scala
@@ -6,20 +6,22 @@ import vct.col.print._
import scala.util.Try
-trait ConstructorInvocationImpl[G] extends ConstructorInvocationOps[G] { this: ConstructorInvocation[G] =>
+trait ConstructorInvocationImpl[G] extends ConstructorInvocationOps[G] {
+ this: ConstructorInvocation[G] =>
def cls: Class[G] = ref.decl.cls.decl
override def typeEnv: Map[Variable[G], Type[G]] =
(cls.typeArgs.zip(classTypeArgs) ++ ref.decl.typeArgs.zip(typeArgs)).toMap
- override def layout(implicit ctx: Ctx): Doc = {
- Doc.spread(Seq(
- Text("new"),
- DocUtil.javaGenericArgs(typeArgs),
- Text(Try(cls).map(ctx.name(_)).getOrElse("?brokenref?")) <> DocUtil.javaGenericArgs(classTypeArgs) <>
- "(" <> DocUtil.argsOutArgs(args, outArgs) <> ")" <>
- DocUtil.givenYields(givenMap, yields)
- ))
- }
+ override def layout(implicit ctx: Ctx): Doc = {
+ Doc.spread(Seq(
+ Text("new"),
+ DocUtil.javaGenericArgs(typeArgs),
+ Text(Try(cls).map(ctx.name(_)).getOrElse("?brokenref?")) <>
+ DocUtil.javaGenericArgs(classTypeArgs) <> "(" <>
+ DocUtil.argsOutArgs(args, outArgs) <> ")" <>
+ DocUtil.givenYields(givenMap, yields),
+ ))
+ }
}
diff --git a/src/col/vct/col/ast/unsorted/EnumConstantImpl.scala b/src/col/vct/col/ast/unsorted/EnumConstantImpl.scala
index c521a52c32..cd7b515e27 100644
--- a/src/col/vct/col/ast/unsorted/EnumConstantImpl.scala
+++ b/src/col/vct/col/ast/unsorted/EnumConstantImpl.scala
@@ -4,6 +4,8 @@ import vct.col.ast.EnumConstant
import vct.col.ast.ops.{EnumConstantOps, EnumConstantFamilyOps}
import vct.col.print._
-trait EnumConstantImpl[G] extends EnumConstantOps[G] with EnumConstantFamilyOps[G] { this: EnumConstant[G] =>
+trait EnumConstantImpl[G]
+ extends EnumConstantOps[G] with EnumConstantFamilyOps[G] {
+ this: EnumConstant[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/unsorted/InstantiateImpl.scala b/src/col/vct/col/ast/unsorted/InstantiateImpl.scala
index 85fadd5742..4b96d1633a 100644
--- a/src/col/vct/col/ast/unsorted/InstantiateImpl.scala
+++ b/src/col/vct/col/ast/unsorted/InstantiateImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{Expr, Instantiate}
import vct.col.ast.ops.InstantiateOps
import vct.col.print._
-trait InstantiateImpl[G] extends InstantiateOps[G] { this: Instantiate[G] =>
+trait InstantiateImpl[G] extends InstantiateOps[G] {
+ this: Instantiate[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
override def expr: Expr[G] = this.out
}
diff --git a/src/col/vct/col/ast/unsorted/InvokeConstructorImpl.scala b/src/col/vct/col/ast/unsorted/InvokeConstructorImpl.scala
index 96e38009da..fd06de55ce 100644
--- a/src/col/vct/col/ast/unsorted/InvokeConstructorImpl.scala
+++ b/src/col/vct/col/ast/unsorted/InvokeConstructorImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{Class, InvokeConstructor, Type, Variable}
import vct.col.ast.ops.InvokeConstructorOps
import vct.col.print._
-trait InvokeConstructorImpl[G] extends InvokeConstructorOps[G] { this: InvokeConstructor[G] =>
+trait InvokeConstructorImpl[G] extends InvokeConstructorOps[G] {
+ this: InvokeConstructor[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
def cls: Class[G] = ref.decl.cls.decl
diff --git a/src/col/vct/col/ast/unsorted/JavaBipAnnotationImpl.scala b/src/col/vct/col/ast/unsorted/JavaBipAnnotationImpl.scala
index ac976973eb..f81566c34c 100644
--- a/src/col/vct/col/ast/unsorted/JavaBipAnnotationImpl.scala
+++ b/src/col/vct/col/ast/unsorted/JavaBipAnnotationImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.JavaBipAnnotation
import vct.col.ast.ops.JavaBipAnnotationOps
import vct.col.print._
-trait JavaBipAnnotationImpl[G] extends JavaBipAnnotationOps[G] { this: JavaBipAnnotation[G] =>
+trait JavaBipAnnotationImpl[G] extends JavaBipAnnotationOps[G] {
+ this: JavaBipAnnotation[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/unsorted/JavaBipGlueElementImpl.scala b/src/col/vct/col/ast/unsorted/JavaBipGlueElementImpl.scala
index ab83131df9..9c4ea622b1 100644
--- a/src/col/vct/col/ast/unsorted/JavaBipGlueElementImpl.scala
+++ b/src/col/vct/col/ast/unsorted/JavaBipGlueElementImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.JavaBipGlueElement
import vct.col.ast.ops.JavaBipGlueElementFamilyOps
import vct.col.print._
-trait JavaBipGlueElementImpl[G] extends JavaBipGlueElementFamilyOps[G] { this: JavaBipGlueElement[G] =>
+trait JavaBipGlueElementImpl[G] extends JavaBipGlueElementFamilyOps[G] {
+ this: JavaBipGlueElement[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/unsorted/MessageImpl.scala b/src/col/vct/col/ast/unsorted/MessageImpl.scala
index 7a261fd264..e171997251 100644
--- a/src/col/vct/col/ast/unsorted/MessageImpl.scala
+++ b/src/col/vct/col/ast/unsorted/MessageImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{Message, Type}
import vct.col.ast.ops.MessageOps
import vct.col.print._
-trait MessageImpl[G] extends MessageOps[G] { this: Message[G] =>
+trait MessageImpl[G] extends MessageOps[G] {
+ this: Message[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("\\msg")
override def t: Type[G] = ref.decl.msg.t
}
diff --git a/src/col/vct/col/ast/unsorted/OperatorImpl.scala b/src/col/vct/col/ast/unsorted/OperatorImpl.scala
index 4abbc6f620..bc671fa98d 100644
--- a/src/col/vct/col/ast/unsorted/OperatorImpl.scala
+++ b/src/col/vct/col/ast/unsorted/OperatorImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.Operator
import vct.col.ast.ops.OperatorFamilyOps
import vct.col.print._
-trait OperatorImpl[G] extends OperatorFamilyOps[G] { this: Operator[G] =>
+trait OperatorImpl[G] extends OperatorFamilyOps[G] {
+ this: Operator[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/unsorted/OperatorLeftPlusImpl.scala b/src/col/vct/col/ast/unsorted/OperatorLeftPlusImpl.scala
index 8d29fdaa0f..d7245fec55 100644
--- a/src/col/vct/col/ast/unsorted/OperatorLeftPlusImpl.scala
+++ b/src/col/vct/col/ast/unsorted/OperatorLeftPlusImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.OperatorLeftPlus
import vct.col.ast.ops.OperatorLeftPlusOps
import vct.col.print._
-trait OperatorLeftPlusImpl[G] extends OperatorLeftPlusOps[G] { this: OperatorLeftPlus[G] =>
+trait OperatorLeftPlusImpl[G] extends OperatorLeftPlusOps[G] {
+ this: OperatorLeftPlus[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/unsorted/OperatorRightPlusImpl.scala b/src/col/vct/col/ast/unsorted/OperatorRightPlusImpl.scala
index 093886cda6..6680a02bbd 100644
--- a/src/col/vct/col/ast/unsorted/OperatorRightPlusImpl.scala
+++ b/src/col/vct/col/ast/unsorted/OperatorRightPlusImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.OperatorRightPlus
import vct.col.ast.ops.OperatorRightPlusOps
import vct.col.print._
-trait OperatorRightPlusImpl[G] extends OperatorRightPlusOps[G] { this: OperatorRightPlus[G] =>
+trait OperatorRightPlusImpl[G] extends OperatorRightPlusOps[G] {
+ this: OperatorRightPlus[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/unsorted/PVLBranchImpl.scala b/src/col/vct/col/ast/unsorted/PVLBranchImpl.scala
index 57c932f0de..3428a9b4ef 100644
--- a/src/col/vct/col/ast/unsorted/PVLBranchImpl.scala
+++ b/src/col/vct/col/ast/unsorted/PVLBranchImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.PVLBranch
import vct.col.ast.ops.PVLBranchOps
import vct.col.print._
-trait PVLBranchImpl[G] extends PVLBranchOps[G] { this: PVLBranch[G] =>
+trait PVLBranchImpl[G] extends PVLBranchOps[G] {
+ this: PVLBranch[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/unsorted/PVLChannelInvariantImpl.scala b/src/col/vct/col/ast/unsorted/PVLChannelInvariantImpl.scala
index 15ea04cf9c..54bab5d79f 100644
--- a/src/col/vct/col/ast/unsorted/PVLChannelInvariantImpl.scala
+++ b/src/col/vct/col/ast/unsorted/PVLChannelInvariantImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.PVLChannelInvariant
import vct.col.ast.ops.PVLChannelInvariantOps
import vct.col.print._
-trait PVLChannelInvariantImpl[G] extends PVLChannelInvariantOps[G] { this: PVLChannelInvariant[G] =>
+trait PVLChannelInvariantImpl[G] extends PVLChannelInvariantOps[G] {
+ this: PVLChannelInvariant[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/unsorted/PVLChorPermImpl.scala b/src/col/vct/col/ast/unsorted/PVLChorPermImpl.scala
index c89cdd41f6..385d0f6962 100644
--- a/src/col/vct/col/ast/unsorted/PVLChorPermImpl.scala
+++ b/src/col/vct/col/ast/unsorted/PVLChorPermImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{PVLChorPerm, TResource, Type}
import vct.col.ast.ops.PVLChorPermOps
import vct.col.print._
-trait PVLChorPermImpl[G] extends PVLChorPermOps[G] { this: PVLChorPerm[G] =>
+trait PVLChorPermImpl[G] extends PVLChorPermOps[G] {
+ this: PVLChorPerm[G] =>
override def layout(implicit ctx: Ctx): Doc =
Text("Perm") <> "[" <> endpoint <> "]" <> "(" <> loc <> ", " <> perm <> ")"
diff --git a/src/col/vct/col/ast/unsorted/PVLChorRunImpl.scala b/src/col/vct/col/ast/unsorted/PVLChorRunImpl.scala
index 32e9cf85fa..5e5376efbd 100644
--- a/src/col/vct/col/ast/unsorted/PVLChorRunImpl.scala
+++ b/src/col/vct/col/ast/unsorted/PVLChorRunImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.PVLChorRun
import vct.col.ast.ops.PVLChorRunOps
import vct.col.print._
-trait PVLChorRunImpl[G] extends PVLChorRunOps[G] { this: PVLChorRun[G] =>
+trait PVLChorRunImpl[G] extends PVLChorRunOps[G] {
+ this: PVLChorRun[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/unsorted/PVLChorStatementImpl.scala b/src/col/vct/col/ast/unsorted/PVLChorStatementImpl.scala
index 87539d56cf..fde3de6ec1 100644
--- a/src/col/vct/col/ast/unsorted/PVLChorStatementImpl.scala
+++ b/src/col/vct/col/ast/unsorted/PVLChorStatementImpl.scala
@@ -1,35 +1,47 @@
package vct.col.ast.unsorted
-import vct.col.ast.{Assign, ChorStatement, Expr, PVLChorStatement, PVLDeref, PVLEndpoint, PVLLocal}
+import vct.col.ast.{
+ Assign,
+ ChorStatement,
+ Expr,
+ PVLChorStatement,
+ PVLDeref,
+ PVLEndpoint,
+ PVLLocal,
+}
import vct.col.ast.ops.PVLChorStatementOps
import vct.col.check.{CheckContext, CheckError, PVLSeqAssignEndpoint}
import vct.col.print._
import vct.col.resolve.ctx.RefPVLEndpoint
-trait PVLChorStatementImpl[G] extends PVLChorStatementOps[G] { this: PVLChorStatement[G] =>
+trait PVLChorStatementImpl[G] extends PVLChorStatementOps[G] {
+ this: PVLChorStatement[G] =>
assert(!inner.isInstanceOf[ChorStatement[_]])
// override def layout(implicit ctx: Ctx): Doc = ???
object assign {
def apply(): Assign[G] = inner.asInstanceOf[Assign[G]]
- def get: Option[Assign[G]] = inner match {
- case assign: Assign[G] => Some(assign)
- case _ => None
- }
+ def get: Option[Assign[G]] =
+ inner match {
+ case assign: Assign[G] => Some(assign)
+ case _ => None
+ }
def target: Expr[G] = assign().target
def endpoint: Option[PVLEndpoint[G]] = endpointHelper(target)
- def endpointHelper(expr: Expr[G]): Option[PVLEndpoint[G]] = expr match {
- case PVLDeref(obj, _) => endpointHelper(obj)
- case local: PVLLocal[G] => local.ref match {
- case Some(RefPVLEndpoint(endpoint)) => Some(endpoint)
+ def endpointHelper(expr: Expr[G]): Option[PVLEndpoint[G]] =
+ expr match {
+ case PVLDeref(obj, _) => endpointHelper(obj)
+ case local: PVLLocal[G] =>
+ local.ref match {
+ case Some(RefPVLEndpoint(endpoint)) => Some(endpoint)
+ case _ => None
+ }
case _ => None
}
- case _ => None
- }
}
// TODO (RR): How to redo this error? Purely with permissions? Then it has to be a blame
diff --git a/src/col/vct/col/ast/unsorted/PVLEndpointImpl.scala b/src/col/vct/col/ast/unsorted/PVLEndpointImpl.scala
index 94a88bb08e..9aea9ecdf0 100644
--- a/src/col/vct/col/ast/unsorted/PVLEndpointImpl.scala
+++ b/src/col/vct/col/ast/unsorted/PVLEndpointImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{PVLEndpoint, TClass, Type}
import vct.col.ast.ops.PVLEndpointOps
import vct.col.print._
-trait PVLEndpointImpl[G] extends PVLEndpointOps[G] { this: PVLEndpoint[G] =>
+trait PVLEndpointImpl[G] extends PVLEndpointOps[G] {
+ this: PVLEndpoint[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
def t: TClass[G] = TClass(cls, typeArgs)
diff --git a/src/col/vct/col/ast/unsorted/PVLLoopImpl.scala b/src/col/vct/col/ast/unsorted/PVLLoopImpl.scala
index f13f13b723..216715f562 100644
--- a/src/col/vct/col/ast/unsorted/PVLLoopImpl.scala
+++ b/src/col/vct/col/ast/unsorted/PVLLoopImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.PVLLoop
import vct.col.ast.ops.PVLLoopOps
import vct.col.print._
-trait PVLLoopImpl[G] extends PVLLoopOps[G] { this: PVLLoop[G] =>
+trait PVLLoopImpl[G] extends PVLLoopOps[G] {
+ this: PVLLoop[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/unsorted/PVLMessageImpl.scala b/src/col/vct/col/ast/unsorted/PVLMessageImpl.scala
index 891d5f142e..ec118ae033 100644
--- a/src/col/vct/col/ast/unsorted/PVLMessageImpl.scala
+++ b/src/col/vct/col/ast/unsorted/PVLMessageImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{PVLMessage, Type}
import vct.col.ast.ops.PVLMessageOps
import vct.col.print._
-trait PVLMessageImpl[G] extends PVLMessageOps[G] { this: PVLMessage[G] =>
+trait PVLMessageImpl[G] extends PVLMessageOps[G] {
+ this: PVLMessage[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("/* PVL */ \\msg")
override def t: Type[G] = ref.get.msg.t
}
diff --git a/src/col/vct/col/ast/unsorted/PVLReceiverImpl.scala b/src/col/vct/col/ast/unsorted/PVLReceiverImpl.scala
index 9766515fb6..d253e67177 100644
--- a/src/col/vct/col/ast/unsorted/PVLReceiverImpl.scala
+++ b/src/col/vct/col/ast/unsorted/PVLReceiverImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{PVLReceiver, Type}
import vct.col.ast.ops.PVLReceiverOps
import vct.col.print._
-trait PVLReceiverImpl[G] extends PVLReceiverOps[G] { this: PVLReceiver[G] =>
+trait PVLReceiverImpl[G] extends PVLReceiverOps[G] {
+ this: PVLReceiver[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("/* PVL */ \\receiver")
override def t: Type[G] = ref.get.inferredReceiver.get.t
}
diff --git a/src/col/vct/col/ast/unsorted/PVLSenderImpl.scala b/src/col/vct/col/ast/unsorted/PVLSenderImpl.scala
index 12e301a0b2..d18500cd6a 100644
--- a/src/col/vct/col/ast/unsorted/PVLSenderImpl.scala
+++ b/src/col/vct/col/ast/unsorted/PVLSenderImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{PVLSender, Type}
import vct.col.ast.ops.PVLSenderOps
import vct.col.print._
-trait PVLSenderImpl[G] extends PVLSenderOps[G] { this: PVLSender[G] =>
+trait PVLSenderImpl[G] extends PVLSenderOps[G] {
+ this: PVLSender[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("/* PVL */ \\sender")
override def t: Type[G] = ref.get.inferredSender.get.t
}
diff --git a/src/col/vct/col/ast/unsorted/RangeSetImpl.scala b/src/col/vct/col/ast/unsorted/RangeSetImpl.scala
index e1f07e6730..1ae2a71b96 100644
--- a/src/col/vct/col/ast/unsorted/RangeSetImpl.scala
+++ b/src/col/vct/col/ast/unsorted/RangeSetImpl.scala
@@ -4,9 +4,11 @@ import vct.col.ast.{RangeSet, TInt, TSet, Type}
import vct.col.ast.ops.RangeSetOps
import vct.col.print._
-trait RangeSetImpl[G] extends RangeSetOps[G] { this: RangeSet[G] =>
+trait RangeSetImpl[G] extends RangeSetOps[G] {
+ this: RangeSet[G] =>
override def t: Type[G] = TSet(TInt())
override def precedence: Int = Precedence.ATOMIC
- override def layout(implicit ctx: Ctx): Doc = Text("{") <> from <+> ".." <+> to <> "}"
+ override def layout(implicit ctx: Ctx): Doc =
+ Text("{") <> from <+> ".." <+> to <> "}"
}
diff --git a/src/col/vct/col/ast/unsorted/ReceiverImpl.scala b/src/col/vct/col/ast/unsorted/ReceiverImpl.scala
index d759b96e07..e3cff284b5 100644
--- a/src/col/vct/col/ast/unsorted/ReceiverImpl.scala
+++ b/src/col/vct/col/ast/unsorted/ReceiverImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{Receiver, Type}
import vct.col.ast.ops.ReceiverOps
import vct.col.print._
-trait ReceiverImpl[G] extends ReceiverOps[G] { this: Receiver[G] =>
+trait ReceiverImpl[G] extends ReceiverOps[G] {
+ this: Receiver[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("\\receiver")
override def t: Type[G] = ref.decl.receiver.get.decl.t
}
diff --git a/src/col/vct/col/ast/unsorted/SenderImpl.scala b/src/col/vct/col/ast/unsorted/SenderImpl.scala
index 642c5ac5b3..b99b311f64 100644
--- a/src/col/vct/col/ast/unsorted/SenderImpl.scala
+++ b/src/col/vct/col/ast/unsorted/SenderImpl.scala
@@ -4,7 +4,8 @@ import vct.col.ast.{Sender, Type}
import vct.col.ast.ops.SenderOps
import vct.col.print._
-trait SenderImpl[G] extends SenderOps[G] { this: Sender[G] =>
+trait SenderImpl[G] extends SenderOps[G] {
+ this: Sender[G] =>
override def layout(implicit ctx: Ctx): Doc = Text("\\sender")
override def t: Type[G] = ref.decl.sender.get.decl.t
}
diff --git a/src/col/vct/col/ast/unsorted/TEnumImpl.scala b/src/col/vct/col/ast/unsorted/TEnumImpl.scala
index 11ec4dd81a..dc08ad76ad 100644
--- a/src/col/vct/col/ast/unsorted/TEnumImpl.scala
+++ b/src/col/vct/col/ast/unsorted/TEnumImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.TEnum
import vct.col.ast.ops.TEnumOps
import vct.col.print._
-trait TEnumImpl[G] extends TEnumOps[G] { this: TEnum[G] =>
+trait TEnumImpl[G] extends TEnumOps[G] {
+ this: TEnum[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/unsorted/TPVLChoreographyImpl.scala b/src/col/vct/col/ast/unsorted/TPVLChoreographyImpl.scala
index bc0208e694..80785b2b0c 100644
--- a/src/col/vct/col/ast/unsorted/TPVLChoreographyImpl.scala
+++ b/src/col/vct/col/ast/unsorted/TPVLChoreographyImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.TPVLChoreography
import vct.col.print._
import vct.col.ast.ops.TPVLChoreographyOps
-trait TPVLChoreographyImpl[G] extends TPVLChoreographyOps[G] { this: TPVLChoreography[G] =>
+trait TPVLChoreographyImpl[G] extends TPVLChoreographyOps[G] {
+ this: TPVLChoreography[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/unsorted/UnresolvedChorBranchImpl.scala b/src/col/vct/col/ast/unsorted/UnresolvedChorBranchImpl.scala
index f4364c3859..ff63e49419 100644
--- a/src/col/vct/col/ast/unsorted/UnresolvedChorBranchImpl.scala
+++ b/src/col/vct/col/ast/unsorted/UnresolvedChorBranchImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.UnresolvedChorBranch
import vct.col.print._
import vct.col.ast.ops.UnresolvedChorBranchOps
-trait UnresolvedChorBranchImpl[G] extends UnresolvedChorBranchOps[G] { this: UnresolvedChorBranch[G] =>
+trait UnresolvedChorBranchImpl[G] extends UnresolvedChorBranchOps[G] {
+ this: UnresolvedChorBranch[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/unsorted/UnresolvedChorLoopImpl.scala b/src/col/vct/col/ast/unsorted/UnresolvedChorLoopImpl.scala
index 4934a109ce..7e2903c7d6 100644
--- a/src/col/vct/col/ast/unsorted/UnresolvedChorLoopImpl.scala
+++ b/src/col/vct/col/ast/unsorted/UnresolvedChorLoopImpl.scala
@@ -4,6 +4,7 @@ import vct.col.ast.UnresolvedChorLoop
import vct.col.print._
import vct.col.ast.ops.UnresolvedChorLoopOps
-trait UnresolvedChorLoopImpl[G] extends UnresolvedChorLoopOps[G] { this: UnresolvedChorLoop[G] =>
+trait UnresolvedChorLoopImpl[G] extends UnresolvedChorLoopOps[G] {
+ this: UnresolvedChorLoop[G] =>
// override def layout(implicit ctx: Ctx): Doc = ???
}
diff --git a/src/col/vct/col/ast/util/CheckFoldUnfoldTarget.scala b/src/col/vct/col/ast/util/CheckFoldUnfoldTarget.scala
index f3801b1afb..e5ad2fedbf 100644
--- a/src/col/vct/col/ast/util/CheckFoldUnfoldTarget.scala
+++ b/src/col/vct/col/ast/util/CheckFoldUnfoldTarget.scala
@@ -3,46 +3,61 @@ package vct.col.ast.util
import vct.col.ast
import vct.col.ast.node.NodeFamilyImpl
import vct.col.ast._
-import vct.col.check.{AbstractPredicate, CheckContext, CheckError, NotAPredicateApplication}
+import vct.col.check.{
+ AbstractPredicate,
+ CheckContext,
+ CheckError,
+ NotAPredicateApplication,
+}
import vct.col.resolve.ctx._
import scala.annotation.tailrec
-trait CheckFoldUnfoldTarget[G] extends NodeFamilyImpl[G] { this: NodeFamily[G] =>
+trait CheckFoldUnfoldTarget[G] extends NodeFamilyImpl[G] {
+ this: NodeFamily[G] =>
def res: Expr[G]
- private def checkNonAbstract(predicate: ast.AbstractPredicate[G], blame: Expr[G]): Option[CheckError] =
+ private def checkNonAbstract(
+ predicate: ast.AbstractPredicate[G],
+ blame: Expr[G],
+ ): Option[CheckError] =
predicate.body match {
case None => Some(AbstractPredicate(blame))
case Some(_) => None
}
@tailrec
- private def check(e: Expr[G]): Option[CheckError] = e match {
- case Scale(_, res) => check(res)
- case apply: ApplyAnyPredicate[G] => checkNonAbstract(apply.ref.decl, apply)
- case inv: PVLInvocation[G] => inv.ref.get match {
- case RefPredicate(decl) => checkNonAbstract(decl, inv)
- case RefInstancePredicate(decl) => checkNonAbstract(decl, inv)
- case _ => Some(NotAPredicateApplication(e))
- }
- case inv: JavaInvocation[G] => inv.ref.get match {
- case RefPredicate(decl) => checkNonAbstract(decl, inv)
- case RefInstancePredicate(decl) => checkNonAbstract(decl, inv)
- case _ => Some(NotAPredicateApplication(e))
- }
- case inv: CInvocation[G] => inv.ref.get match {
- case RefPredicate(decl) => checkNonAbstract(decl, inv)
- case RefInstancePredicate(decl) => checkNonAbstract(decl, inv)
- case _ => Some(NotAPredicateApplication(e))
- }
- case inv: CPPInvocation[G] => inv.ref.get match {
- case RefPredicate(decl) => checkNonAbstract(decl, inv)
- case RefInstancePredicate(decl) => checkNonAbstract(decl, inv)
+ private def check(e: Expr[G]): Option[CheckError] =
+ e match {
+ case Scale(_, res) => check(res)
+ case apply: ApplyAnyPredicate[G] =>
+ checkNonAbstract(apply.ref.decl, apply)
+ case inv: PVLInvocation[G] =>
+ inv.ref.get match {
+ case RefPredicate(decl) => checkNonAbstract(decl, inv)
+ case RefInstancePredicate(decl) => checkNonAbstract(decl, inv)
+ case _ => Some(NotAPredicateApplication(e))
+ }
+ case inv: JavaInvocation[G] =>
+ inv.ref.get match {
+ case RefPredicate(decl) => checkNonAbstract(decl, inv)
+ case RefInstancePredicate(decl) => checkNonAbstract(decl, inv)
+ case _ => Some(NotAPredicateApplication(e))
+ }
+ case inv: CInvocation[G] =>
+ inv.ref.get match {
+ case RefPredicate(decl) => checkNonAbstract(decl, inv)
+ case RefInstancePredicate(decl) => checkNonAbstract(decl, inv)
+ case _ => Some(NotAPredicateApplication(e))
+ }
+ case inv: CPPInvocation[G] =>
+ inv.ref.get match {
+ case RefPredicate(decl) => checkNonAbstract(decl, inv)
+ case RefInstancePredicate(decl) => checkNonAbstract(decl, inv)
+ case _ => Some(NotAPredicateApplication(e))
+ }
case _ => Some(NotAPredicateApplication(e))
}
- case _ => Some(NotAPredicateApplication(e))
- }
override def check(context: CheckContext[G]): Seq[CheckError] =
super.check(context) ++ check(res).toSeq
diff --git a/src/col/vct/col/ast/util/Declarator.scala b/src/col/vct/col/ast/util/Declarator.scala
index c75a210f6d..8e38abdaa6 100644
--- a/src/col/vct/col/ast/util/Declarator.scala
+++ b/src/col/vct/col/ast/util/Declarator.scala
@@ -4,13 +4,17 @@ import vct.col.ast.node.NodeImpl
import vct.col.ast.{Declaration, Node}
import vct.col.check.{CheckContext, DoesNotDefine, OutOfScopeError}
-trait Declarator[G] extends NodeImpl[G] { this: Node[G] =>
+trait Declarator[G] extends NodeImpl[G] {
+ this: Node[G] =>
def declarations: Seq[Declaration[G]]
- override def enterCheckContextScopes(context: CheckContext[G]): Seq[CheckContext.ScopeFrame[G]] =
- context.withScope(declarations)
+ override def enterCheckContextScopes(
+ context: CheckContext[G]
+ ): Seq[CheckContext.ScopeFrame[G]] = context.withScope(declarations)
def checkDefines(defn: Declaration[G], use: Node[G]): Seq[DoesNotDefine] =
- if(declarations.contains(defn)) Nil
- else Seq(DoesNotDefine(this, defn, use))
+ if (declarations.contains(defn))
+ Nil
+ else
+ Seq(DoesNotDefine(this, defn, use))
}
diff --git a/src/col/vct/col/ast/util/ExpressionEqualityCheck.scala b/src/col/vct/col/ast/util/ExpressionEqualityCheck.scala
index 224be6edbb..ab806c1ca8 100644
--- a/src/col/vct/col/ast/util/ExpressionEqualityCheck.scala
+++ b/src/col/vct/col/ast/util/ExpressionEqualityCheck.scala
@@ -10,7 +10,9 @@ import scala.collection.mutable
import scala.reflect.ClassTag
object ExpressionEqualityCheck {
- def apply[G](info: Option[AnnotationVariableInfo[G]] = None): ExpressionEqualityCheck[G] = new ExpressionEqualityCheck[G](info)
+ def apply[G](
+ info: Option[AnnotationVariableInfo[G]] = None
+ ): ExpressionEqualityCheck[G] = new ExpressionEqualityCheck[G](info)
def isConstantInt[G](e: Expr[G]): Option[BigInt] = {
ExpressionEqualityCheck().isConstantInt(e)
@@ -21,9 +23,11 @@ object ExpressionEqualityCheck {
}
}
-case class InconsistentVariableEquality(v: Local[_], x: BigInt, y: BigInt) extends UserError {
+case class InconsistentVariableEquality(v: Local[_], x: BigInt, y: BigInt)
+ extends UserError {
override def code: String = "inconsistentVariableEquality"
- override def text: String = s"Inconsistent variable equality: value of $v is required to be both $x and $y"
+ override def text: String =
+ s"Inconsistent variable equality: value of $v is required to be both $x and $y"
}
class ExpressionEqualityCheck[G](info: Option[AnnotationVariableInfo[G]]) {
@@ -38,111 +42,220 @@ class ExpressionEqualityCheck[G](info: Option[AnnotationVariableInfo[G]]) {
def eucl_mod(a: BigInt, b: BigInt): BigInt = {
val m = a % b
- val absB = if(b > 0) b else -b
- if(m <= 0) m + absB else m
+ val absB =
+ if (b > 0)
+ b
+ else
+ -b
+ if (m <= 0)
+ m + absB
+ else
+ m
}
def eucl_div(a: BigInt, b: BigInt): BigInt = {
val m = a % b
val d = a / b
- val add = if (b > 0) -1 else 1
- if (m <= 0) d + add else d
+ val add =
+ if (b > 0)
+ -1
+ else
+ 1
+ if (m <= 0)
+ d + add
+ else
+ d
}
- def isConstantIntRecurse(e: Expr[G]): Option[BigInt] = e match {
- case e: Local[G] =>
- // Does it have a direct int value?
- info.flatMap(_.variableValues.get(e)) match {
- case Some(x) => Some(x)
- case None =>
- info.flatMap(_.variableEqualities.get(e)) match {
- case None => None
- case Some(equals) =>
- for (eq <- equals) {
- // Make sure we do not loop indefinitely by keep replacing the same expressions somehow
- if (replacerDepthInt > max_depth) return None
- replacerDepthInt += 1
- val res = isConstantIntRecurse(eq)
- if (res.isDefined) return res
- }
- None
- }
- }
+ def isConstantIntRecurse(e: Expr[G]): Option[BigInt] =
+ e match {
+ case e: Local[G] =>
+ // Does it have a direct int value?
+ info.flatMap(_.variableValues.get(e)) match {
+ case Some(x) => Some(x)
+ case None =>
+ info.flatMap(_.variableEqualities.get(e)) match {
+ case None => None
+ case Some(equals) =>
+ for (eq <- equals) {
+ // Make sure we do not loop indefinitely by keep replacing the same expressions somehow
+ if (replacerDepthInt > max_depth)
+ return None
+ replacerDepthInt += 1
+ val res = isConstantIntRecurse(eq)
+ if (res.isDefined)
+ return res
+ }
+ None
+ }
+ }
- case i: ConstantInt[G] => Some(i.value)
- case Exp(e1, e2) => for {i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)} yield i1.pow(i2.toInt)
- case Plus(e1, e2) => for {i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)} yield i1 + i2
- case AmbiguousPlus(e1, e2) => for {i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)} yield i1 + i2
- case Minus(e1, e2) => for {i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)} yield i1 - i2
- case AmbiguousMinus(e1, e2) => for {i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)} yield i1 - i2
- case Mult(e1, e2) => for {i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)} yield i1 * i2
- case AmbiguousMult(e1, e2) => for {i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)} yield i1 * i2
- case FloorDiv(e1, e2) => for {i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)} yield eucl_div(i1, i2)
- case Mod(e1, e2) => for {i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)} yield eucl_mod(i1, i2)
- case TruncDiv(e1, e2) => for {i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)} yield i1 / i2
- case TruncMod(e1, e2) => for {i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)} yield i1 % i2
- case UMinus(e1) => for {i1 <- isConstantIntRecurse(e1)} yield -i1
-
- case BitAnd(e1, e2) => for {i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)} yield i1 & i2
- case ComputationalAnd(e1, e2) => for {i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)} yield i1 & i2
- case AmbiguousComputationalAnd(e1, e2) => for {i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)} yield i1 & i2
- case BitOr(e1, e2) => for {i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)} yield i1 | i2
- case ComputationalOr(e1, e2) => for {i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)} yield i1 | i2
- case AmbiguousComputationalOr(e1, e2) => for {i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)} yield i1 | i2
- case BitXor(e1, e2) => for {i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)} yield i1 ^ i2
- case ComputationalXor(e1, e2) => for {i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)} yield i1 ^ i2
- case AmbiguousComputationalXor(e1, e2) => for {i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)} yield i1 ^ i2
- case BitShl(e1, e2) => for {i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)} yield i1 << i2.toInt
- case BitShr(e1, e2) => for {i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)} yield i1 >> i2.toInt
- case BitUShr(e1, e2) => for {i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)} yield i1.toInt >>> i2.toInt
-
- case _ => None
- }
+ case i: ConstantInt[G] => Some(i.value)
+ case Exp(e1, e2) =>
+ for {
+ i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)
+ } yield i1.pow(i2.toInt)
+ case Plus(e1, e2) =>
+ for {
+ i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)
+ } yield i1 + i2
+ case AmbiguousPlus(e1, e2) =>
+ for {
+ i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)
+ } yield i1 + i2
+ case Minus(e1, e2) =>
+ for {
+ i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)
+ } yield i1 - i2
+ case AmbiguousMinus(e1, e2) =>
+ for {
+ i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)
+ } yield i1 - i2
+ case Mult(e1, e2) =>
+ for {
+ i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)
+ } yield i1 * i2
+ case AmbiguousMult(e1, e2) =>
+ for {
+ i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)
+ } yield i1 * i2
+ case FloorDiv(e1, e2) =>
+ for {
+ i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)
+ } yield eucl_div(i1, i2)
+ case Mod(e1, e2) =>
+ for {
+ i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)
+ } yield eucl_mod(i1, i2)
+ case TruncDiv(e1, e2) =>
+ for {
+ i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)
+ } yield i1 / i2
+ case TruncMod(e1, e2) =>
+ for {
+ i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)
+ } yield i1 % i2
+ case UMinus(e1) => for { i1 <- isConstantIntRecurse(e1) } yield -i1
+
+ case BitAnd(e1, e2) =>
+ for {
+ i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)
+ } yield i1 & i2
+ case ComputationalAnd(e1, e2) =>
+ for {
+ i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)
+ } yield i1 & i2
+ case AmbiguousComputationalAnd(e1, e2) =>
+ for {
+ i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)
+ } yield i1 & i2
+ case BitOr(e1, e2) =>
+ for {
+ i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)
+ } yield i1 | i2
+ case ComputationalOr(e1, e2) =>
+ for {
+ i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)
+ } yield i1 | i2
+ case AmbiguousComputationalOr(e1, e2) =>
+ for {
+ i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)
+ } yield i1 | i2
+ case BitXor(e1, e2) =>
+ for {
+ i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)
+ } yield i1 ^ i2
+ case ComputationalXor(e1, e2) =>
+ for {
+ i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)
+ } yield i1 ^ i2
+ case AmbiguousComputationalXor(e1, e2) =>
+ for {
+ i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)
+ } yield i1 ^ i2
+ case BitShl(e1, e2) =>
+ for {
+ i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)
+ } yield i1 << i2.toInt
+ case BitShr(e1, e2) =>
+ for {
+ i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)
+ } yield i1 >> i2.toInt
+ case BitUShr(e1, e2) =>
+ for {
+ i1 <- isConstantIntRecurse(e1); i2 <- isConstantIntRecurse(e2)
+ } yield i1.toInt >>> i2.toInt
+
+ case _ => None
+ }
def equalExpressions(lhs: Expr[G], rhs: Expr[G]): Boolean = {
replacerDepth = 0
equalExpressionsRecurse(lhs, rhs)
}
- def upperBound(e: Expr[G]): Option[BigInt] = {
- getBound(e, isLower=false)
- }
+ def upperBound(e: Expr[G]): Option[BigInt] = { getBound(e, isLower = false) }
- def lowerBound(e: Expr[G]): Option[BigInt] = {
- getBound(e, isLower=true)
- }
+ def lowerBound(e: Expr[G]): Option[BigInt] = { getBound(e, isLower = true) }
def getBound(e: Expr[G], isLower: Boolean): Option[BigInt] = {
- isConstantInt(e).foreach{ i => return Some(i)}
-
- val normalBound = if(isLower) lowerBound _ else upperBound _
- val reverseBound = if(isLower) upperBound _ else lowerBound _
+ isConstantInt(e).foreach { i => return Some(i) }
+
+ val normalBound =
+ if (isLower)
+ lowerBound _
+ else
+ upperBound _
+ val reverseBound =
+ if (isLower)
+ upperBound _
+ else
+ lowerBound _
e match {
- case v: Local[G] => info.foreach{ i => return if(isLower) i.lowerBound.get(v) else i.upperBound.get(v) }
- case Plus(e1, e2) => return for{
- b1 <- normalBound(e1)
- b2 <- normalBound(e2)
- } yield b1+b2
- case Minus(e1, e2) => return for{
- b1 <- normalBound(e1)
- b2 <- reverseBound(e2)
- } yield b1-b2
+ case v: Local[G] =>
+ info.foreach { i =>
+ return if (isLower)
+ i.lowerBound.get(v)
+ else
+ i.upperBound.get(v)
+ }
+ case Plus(e1, e2) =>
+ return for {
+ b1 <- normalBound(e1)
+ b2 <- normalBound(e2)
+ } yield b1 + b2
+ case Minus(e1, e2) =>
+ return for {
+ b1 <- normalBound(e1)
+ b2 <- reverseBound(e2)
+ } yield b1 - b2
case Mult(e1, e2) =>
- isConstantInt(e1).foreach {
- i => if(i>0) normalBound(e2) . foreach { b2 => return Some(i*b2) }
- if(i<0) reverseBound(e2) . foreach { u2 => return Some(i*u2) }
- if(i==0) return Some(0)
+ isConstantInt(e1).foreach { i =>
+ if (i > 0)
+ normalBound(e2).foreach { b2 => return Some(i * b2) }
+ if (i < 0)
+ reverseBound(e2).foreach { u2 => return Some(i * u2) }
+ if (i == 0)
+ return Some(0)
}
- isConstantInt(e2).foreach {
- i => if(i>0) normalBound(e1) . foreach { b1 => return Some(i*b1) }
- if(i<0) reverseBound(e1) . foreach { u1 => return Some(i*u1) }
- if(i==0) return Some(0)
+ isConstantInt(e2).foreach { i =>
+ if (i > 0)
+ normalBound(e1).foreach { b1 => return Some(i * b1) }
+ if (i < 0)
+ reverseBound(e1).foreach { u1 => return Some(i * u1) }
+ if (i == 0)
+ return Some(0)
}
- normalBound(e1) . foreach{ b1 => normalBound(e2) . foreach { b2 => if(b1>0 && b2>0) return Some(b1*b2) } }
- // THe other cases are to complicated, so we do not consider them
+ normalBound(e1).foreach { b1 =>
+ normalBound(e2).foreach { b2 =>
+ if (b1 > 0 && b2 > 0)
+ return Some(b1 * b2)
+ }
+ }
+ // THe other cases are to complicated, so we do not consider them
case Mod(e1, e2) if isLower => return Some(0)
case Mod(e1, e2) => isConstantInt(e2)
case _ =>
@@ -159,12 +272,18 @@ class ExpressionEqualityCheck[G](info: Option[AnnotationVariableInfo[G]]) {
}
// Compare two variables, where we sometimes store information about
(lhs, rhs) match {
- case (v1: Local[G], v2: Local[G]) => info.foreach{ i => if(i.lessThanEqVars.contains(v1) && i.lessThanEqVars(v1).contains(v2)) return Some(true) }
+ case (v1: Local[G], v2: Local[G]) =>
+ info.foreach { i =>
+ if (
+ i.lessThanEqVars.contains(v1) && i.lessThanEqVars(v1).contains(v2)
+ )
+ return Some(true)
+ }
case _ =>
}
// Compare upper and lower bounds of two variables
- (upperBound(lhs),lowerBound(rhs)) match {
+ (upperBound(lhs), lowerBound(rhs)) match {
case (Some(x), Some(y)) if x <= y => return Some(true)
case _ =>
}
@@ -172,13 +291,16 @@ class ExpressionEqualityCheck[G](info: Option[AnnotationVariableInfo[G]]) {
None
}
- def isNonZero(e: Expr[G]):Boolean = e match {
- case v: Local[G] => info.exists(_.variableNotZero.contains(v))
- case _ => isConstantInt(e).getOrElse(0) != 0
- case _ => lessThenEq(const(1)(e.o), e).getOrElse(false)
- }
+ def isNonZero(e: Expr[G]): Boolean =
+ e match {
+ case v: Local[G] => info.exists(_.variableNotZero.contains(v))
+ case _ => isConstantInt(e).getOrElse(0) != 0
+ case _ => lessThenEq(const(1)(e.o), e).getOrElse(false)
+ }
- def unfoldComm[B <: BinExpr[G]](e: Expr[G])(implicit tag: ClassTag[B]): Seq[Expr[G]] = {
+ def unfoldComm[B <: BinExpr[G]](
+ e: Expr[G]
+ )(implicit tag: ClassTag[B]): Seq[Expr[G]] = {
e match {
case e: B /* checked */ => unfoldComm[B](e.left) ++ unfoldComm[B](e.right)
case _ => Seq(e)
@@ -190,14 +312,17 @@ class ExpressionEqualityCheck[G](info: Option[AnnotationVariableInfo[G]]) {
(isConstantInt(lhs), isConstantInt(rhs)) match {
case (Some(i1), Some(i2)) => return i1 == i2
case (None, None) => ()
- //If one is a constant expression, and the other is not, this cannot be the same
+ // If one is a constant expression, and the other is not, this cannot be the same
case _ => return false
}
- def partitionOptionList[A,B](xs: Seq[A], f: A => Option[B]): (Seq[A], Seq[B]) = {
+ def partitionOptionList[A, B](
+ xs: Seq[A],
+ f: A => Option[B],
+ ): (Seq[A], Seq[B]) = {
var resLeft: Seq[A] = Seq()
var resRight: Seq[B] = Seq()
- for(x <- xs){
+ for (x <- xs) {
f(x) match {
case Some(b) => resRight ++= Seq(b)
case None => resLeft ++= Seq(x)
@@ -206,85 +331,106 @@ class ExpressionEqualityCheck[G](info: Option[AnnotationVariableInfo[G]]) {
(resLeft, resRight)
}
- def commAssoc[B <: BinExpr[G]](e1: B, e2: B)(implicit tag: ClassTag[B]): Boolean = {
+ def commAssoc[B <: BinExpr[G]](e1: B, e2: B)(
+ implicit tag: ClassTag[B]
+ ): Boolean = {
val e1s = unfoldComm[B](e1)
val e2s = unfoldComm[B](e2)
val (e1rest, e1Ints) = partitionOptionList(e1s, isConstantInt)
val (e2rest, e2Ints) = partitionOptionList(e2s, isConstantInt)
- if(e1rest.size != e2rest.size) return false
+ if (e1rest.size != e2rest.size)
+ return false
- val res1: Boolean = e1 match {
- case _: Plus[G] =>
- e1Ints.sum == e2Ints.sum
- case _: Mult[G] =>
- e1Ints.product == e2Ints.product
+ val res1: Boolean =
+ e1 match {
+ case _: Plus[G] => e1Ints.sum == e2Ints.sum
+ case _: Mult[G] => e1Ints.product == e2Ints.product
// Should not be reachable
- case _ => ???
- }
- if(!res1) return false
+ case _ => ???
+ }
+ if (!res1)
+ return false
var available: Seq[Expr[G]] = e2rest
- for(x <- e1rest){
+ for (x <- e1rest) {
var found = false
val freezeAvailable = available
- for(y <- freezeAvailable){
- if(!found && equalExpressionsRecurse(x, y)){
+ for (y <- freezeAvailable) {
+ if (!found && equalExpressionsRecurse(x, y)) {
found = true
available = available.diff(Seq(y))
}
}
- if(!found) return false
+ if (!found)
+ return false
}
true
}
- def comm(lhs1: Expr[G], lhs2: Expr[G], rhs1: Expr[G], rhs2: Expr[G]): Boolean =
- equalExpressionsRecurse(lhs1, rhs1) && equalExpressionsRecurse(lhs2, rhs2) ||
- equalExpressionsRecurse(lhs2, rhs1) && equalExpressionsRecurse(lhs1, rhs2)
+ def comm(
+ lhs1: Expr[G],
+ lhs2: Expr[G],
+ rhs1: Expr[G],
+ rhs2: Expr[G],
+ ): Boolean =
+ equalExpressionsRecurse(lhs1, rhs1) &&
+ equalExpressionsRecurse(lhs2, rhs2) ||
+ equalExpressionsRecurse(lhs2, rhs1) &&
+ equalExpressionsRecurse(lhs1, rhs2)
(lhs, rhs) match {
// Unsure if we could check/pattern match on this easier
// Commutative operators
- case (lhs@Plus(_, _), rhs@Plus(_, _)) => commAssoc[Plus[G]](lhs, rhs)
- case (lhs@Mult(_, _), rhs@Mult(_, _)) => commAssoc[Mult[G]](lhs, rhs)
- case (BitAnd(lhs1, lhs2), BitAnd(rhs1, rhs2)) => comm(lhs1, lhs2, rhs1, rhs2)
- case (BitOr(lhs1, lhs2), BitOr(rhs1, rhs2)) => comm(lhs1, lhs2, rhs1, rhs2)
- case (BitXor(lhs1, lhs2), BitXor(rhs1, rhs2)) => comm(lhs1, lhs2, rhs1, rhs2)
+ case (lhs @ Plus(_, _), rhs @ Plus(_, _)) => commAssoc[Plus[G]](lhs, rhs)
+ case (lhs @ Mult(_, _), rhs @ Mult(_, _)) => commAssoc[Mult[G]](lhs, rhs)
+ case (BitAnd(lhs1, lhs2), BitAnd(rhs1, rhs2)) =>
+ comm(lhs1, lhs2, rhs1, rhs2)
+ case (BitOr(lhs1, lhs2), BitOr(rhs1, rhs2)) =>
+ comm(lhs1, lhs2, rhs1, rhs2)
+ case (BitXor(lhs1, lhs2), BitXor(rhs1, rhs2)) =>
+ comm(lhs1, lhs2, rhs1, rhs2)
case (And(lhs1, lhs2), And(rhs1, rhs2)) => comm(lhs1, lhs2, rhs1, rhs2)
case (Or(lhs1, lhs2), Or(rhs1, rhs2)) => comm(lhs1, lhs2, rhs1, rhs2)
case (Eq(lhs1, lhs2), Eq(rhs1, rhs2)) => comm(lhs1, lhs2, rhs1, rhs2)
case (Neq(lhs1, lhs2), Neq(rhs1, rhs2)) => comm(lhs1, lhs2, rhs1, rhs2)
- //Non commutative operators
+ // Non commutative operators
case (e1: BinExpr[G], e2: BinExpr[G]) =>
- equalExpressionsRecurse(e1.left, e2.left) && equalExpressionsRecurse(e1.right, e2.right)
+ equalExpressionsRecurse(e1.left, e2.left) &&
+ equalExpressionsRecurse(e1.right, e2.right)
case (Star(lhs1, lhs2), Star(rhs1, rhs2)) =>
- equalExpressionsRecurse(lhs1, rhs1) && equalExpressionsRecurse(lhs2, rhs2)
+ equalExpressionsRecurse(lhs1, rhs1) &&
+ equalExpressionsRecurse(lhs2, rhs2)
case (Wand(lhs1, lhs2), Wand(rhs1, rhs2)) =>
- equalExpressionsRecurse(lhs1, rhs1) && equalExpressionsRecurse(lhs2, rhs2)
+ equalExpressionsRecurse(lhs1, rhs1) &&
+ equalExpressionsRecurse(lhs2, rhs2)
// Unary expressions
- case (e1: UnExpr[G], e2: UnExpr[G]) => equalExpressionsRecurse(e1.arg, e2.arg)
+ case (e1: UnExpr[G], e2: UnExpr[G]) =>
+ equalExpressionsRecurse(e1.arg, e2.arg)
// Variables
case (name1: Local[G], name2: Local[G]) =>
- if (name1 == name2) true
+ if (name1 == name2)
+ true
else if (info.isDefined) {
// Check if the variables are synonyms
- (info.get.variableSynonyms.get(name1), info.get.variableSynonyms.get(name2)) match {
+ (
+ info.get.variableSynonyms.get(name1),
+ info.get.variableSynonyms.get(name2),
+ ) match {
case (Some(x), Some(y)) => x == y
case _ => false
}
- } else false
- case (name1: Local[G], e2) =>
- replaceVariable(name1, e2)
- case (e1, name2: Local[G]) =>
- replaceVariable(name2, e1)
+ } else
+ false
+ case (name1: Local[G], e2) => replaceVariable(name1, e2)
+ case (e1, name2: Local[G]) => replaceVariable(name2, e1)
case (inv: MethodInvocation[G], _) if !inv.ref.decl.pure => false
case (_, inv: MethodInvocation[G]) if !inv.ref.decl.pure => false
@@ -294,7 +440,6 @@ class ExpressionEqualityCheck[G](info: Option[AnnotationVariableInfo[G]]) {
}
}
-
def replaceVariable(name: Local[G], other_e: Expr[G]): Boolean = {
if (info.isDefined) {
info.get.variableEqualities.get(name) match {
@@ -302,29 +447,33 @@ class ExpressionEqualityCheck[G](info: Option[AnnotationVariableInfo[G]]) {
case Some(equals) =>
for (eq <- equals) {
// Make sure we do not loop indefinitely by keep replacing the same expressions somehow
- if (replacerDepth > max_depth) return false
+ if (replacerDepth > max_depth)
+ return false
replacerDepth += 1
- if (equalExpressionsRecurse(eq, other_e)) return true
+ if (equalExpressionsRecurse(eq, other_e))
+ return true
}
false
}
- } else {
- false
- }
+ } else { false }
}
}
-case class AnnotationVariableInfo[G](variableEqualities: Map[Local[G], List[Expr[G]]], variableValues: Map[Local[G], BigInt],
- variableSynonyms: Map[Local[G], Int], variableNotZero: Set[Local[G]],
- lessThanEqVars: Map[Local[G], Set[Local[G]]],
- upperBound: Map[Local[G], BigInt],
- lowerBound: Map[Local[G], BigInt],
- usefullConditions: mutable.ArrayBuffer[Expr[G]])
-
-/** This class gathers information about variables, such as:
- * `requires x == 0` and stores that x is equal to the value 0.
- * Which we can use in simplify steps
- * This information is returned with ```getInfo(annotations: Iterable[Expr[G]])```
+case class AnnotationVariableInfo[G](
+ variableEqualities: Map[Local[G], List[Expr[G]]],
+ variableValues: Map[Local[G], BigInt],
+ variableSynonyms: Map[Local[G], Int],
+ variableNotZero: Set[Local[G]],
+ lessThanEqVars: Map[Local[G], Set[Local[G]]],
+ upperBound: Map[Local[G], BigInt],
+ lowerBound: Map[Local[G], BigInt],
+ usefullConditions: mutable.ArrayBuffer[Expr[G]],
+)
+
+/** This class gathers information about variables, such as: `requires x == 0`
+ * and stores that x is equal to the value 0. Which we can use in simplify
+ * steps This information is returned with ```getInfo(annotations:
+ * Iterable[Expr[G]])```
*/
class AnnotationVariableInfoGetter[G]() {
@@ -338,7 +487,8 @@ class AnnotationVariableInfoGetter[G]() {
var equalCheck: ExpressionEqualityCheck[G] = ExpressionEqualityCheck()
// lessThanEqVars(v) = {a,b,c} Captures that variable v is less than or eq to {a,b,c}
- val lessThanEqVars: mutable.Map[Local[G], mutable.Set[Local[G]]] = mutable.Map()
+ val lessThanEqVars: mutable.Map[Local[G], mutable.Set[Local[G]]] = mutable
+ .Map()
// upperBound(v) = 5 Captures that variable v is less than or equal to 5
val upperBound: mutable.Map[Local[G], BigInt] = mutable.Map()
// lowerBound(v) = 5 Captures that variable v is greater than or equal to 5
@@ -347,77 +497,92 @@ class AnnotationVariableInfoGetter[G]() {
val usefullConditions: mutable.ArrayBuffer[Expr[G]] = mutable.ArrayBuffer()
def extractEqualities(e: Expr[G]): Unit = {
- e match{
+ e match {
case Eq(e1, e2) =>
- (e1, e2) match{
- case (v1: Local[G], v2: Local[G]) => addSynonym(v1, v2)
- case (v1: Local[G], _) => addName(v1, e2)
- case (_, v2: Local[G]) => addName(v2, e1)
+ (e1, e2) match {
+ case (v1: Local[G], v2: Local[G]) => addSynonym(v1, v2)
+ case (v1: Local[G], _) => addName(v1, e2)
+ case (_, v2: Local[G]) => addName(v2, e1)
case _ =>
}
case _ =>
}
}
- def addLessEq(v: Local[G], i: BigInt): Unit ={
- val value = upperBound.getOrElse(v,i).min(i)
+ def addLessEq(v: Local[G], i: BigInt): Unit = {
+ val value = upperBound.getOrElse(v, i).min(i)
upperBound(v) = value
}
- def addGreaterEq(v: Local[G], i: BigInt): Unit ={
- val value = lowerBound.getOrElse(v,i).max(i)
+ def addGreaterEq(v: Local[G], i: BigInt): Unit = {
+ val value = lowerBound.getOrElse(v, i).max(i)
lowerBound(v) = value
}
def lt(e1: Expr[G], e2: Expr[G], equal: Boolean): Unit = {
e1 match {
// x <= i
- case v1: Local[G] if equal => equalCheck.isConstantInt(e2).foreach{i =>
- if(i < 0) variableNotZero.add(v1)
- addLessEq(v1, i)
- }
+ case v1: Local[G] if equal =>
+ equalCheck.isConstantInt(e2).foreach { i =>
+ if (i < 0)
+ variableNotZero.add(v1)
+ addLessEq(v1, i)
+ }
// x < i
- case v1: Local[G] if !equal => equalCheck.isConstantInt(e2).foreach{i =>
- if(i <= 0) variableNotZero.add(v1)
- addLessEq(v1, i-1)
- }
+ case v1: Local[G] if !equal =>
+ equalCheck.isConstantInt(e2).foreach { i =>
+ if (i <= 0)
+ variableNotZero.add(v1)
+ addLessEq(v1, i - 1)
+ }
case _ =>
}
e2 match {
// i <= x
- case v2: Local[G] if equal => equalCheck.isConstantInt(e1).foreach { i =>
- if (i > 0) variableNotZero.add(v2)
- addGreaterEq(v2, i)
- }
+ case v2: Local[G] if equal =>
+ equalCheck.isConstantInt(e1).foreach { i =>
+ if (i > 0)
+ variableNotZero.add(v2)
+ addGreaterEq(v2, i)
+ }
// i < x
- case v2: Local[G] if !equal => equalCheck.isConstantInt(e1).foreach { i =>
- if (i >= 0) variableNotZero.add(v2)
- addGreaterEq(v2, i+1)
- }
+ case v2: Local[G] if !equal =>
+ equalCheck.isConstantInt(e1).foreach { i =>
+ if (i >= 0)
+ variableNotZero.add(v2)
+ addGreaterEq(v2, i + 1)
+ }
case _ =>
}
(e1, e2) match {
// x < y
- case (v1: Local[G], v2: Local[G]) => lessThanEqVars.getOrElseUpdate(v1, mutable.Set()).addOne(v2)
+ case (v1: Local[G], v2: Local[G]) =>
+ lessThanEqVars.getOrElseUpdate(v1, mutable.Set()).addOne(v2)
case _ =>
}
}
// n == m + 1 then m <= n
def varEqVarPlusInt(v1: Local[G], v2: Local[G], i: BigInt): Unit = {
- if (i>=0) lessThanEqVars.getOrElseUpdate(v2, mutable.Set()).addOne(v1)
- if (i<=0) lessThanEqVars.getOrElseUpdate(v1, mutable.Set()).addOne(v2)
+ if (i >= 0)
+ lessThanEqVars.getOrElseUpdate(v2, mutable.Set()).addOne(v1)
+ if (i <= 0)
+ lessThanEqVars.getOrElseUpdate(v1, mutable.Set()).addOne(v2)
}
// n == m + k,
// if k>=0 then m <= n
// if k<=0 then n <= m
def varEqVarPlusVar(n: Local[G], m: Local[G], k: Local[G]): Unit = {
- if(lowerBound.contains(k) && lowerBound(k) >= 0) lessThanEqVars.getOrElseUpdate(m, mutable.Set()).addOne(n)
- if(upperBound.contains(k) && upperBound(k) <= 0) lessThanEqVars.getOrElseUpdate(n, mutable.Set()).addOne(m)
- if(lowerBound.contains(m) && lowerBound(m) >= 0) lessThanEqVars.getOrElseUpdate(k, mutable.Set()).addOne(n)
- if(upperBound.contains(m) && upperBound(m) <= 0) lessThanEqVars.getOrElseUpdate(n, mutable.Set()).addOne(k)
+ if (lowerBound.contains(k) && lowerBound(k) >= 0)
+ lessThanEqVars.getOrElseUpdate(m, mutable.Set()).addOne(n)
+ if (upperBound.contains(k) && upperBound(k) <= 0)
+ lessThanEqVars.getOrElseUpdate(n, mutable.Set()).addOne(m)
+ if (lowerBound.contains(m) && lowerBound(m) >= 0)
+ lessThanEqVars.getOrElseUpdate(k, mutable.Set()).addOne(n)
+ if (upperBound.contains(m) && upperBound(m) <= 0)
+ lessThanEqVars.getOrElseUpdate(n, mutable.Set()).addOne(k)
}
def isBool[G](e: Expr[G]) = {
@@ -429,9 +594,11 @@ class AnnotationVariableInfoGetter[G]() {
}
def isSimpleExpr(e: Expr[G]): Boolean = {
e match {
- case e if(!isInt(e) && !isBool(e)) => false
- case SeqMember(e1, Range(from, to)) => isSimpleExpr(e1) && isSimpleExpr(from) && isSimpleExpr(to)
- case SetMember(e1, RangeSet(from, to)) => isSimpleExpr(e1) && isSimpleExpr(from) && isSimpleExpr(to)
+ case e if (!isInt(e) && !isBool(e)) => false
+ case SeqMember(e1, Range(from, to)) =>
+ isSimpleExpr(e1) && isSimpleExpr(from) && isSimpleExpr(to)
+ case SetMember(e1, RangeSet(from, to)) =>
+ isSimpleExpr(e1) && isSimpleExpr(from) && isSimpleExpr(to)
case e: BinExpr[G] => isSimpleExpr(e.left) && isSimpleExpr(e.right)
case _: Local[G] => true
case _: Constant[G] => true
@@ -440,16 +607,24 @@ class AnnotationVariableInfoGetter[G]() {
}
def extractComparisons(e: Expr[G]): Unit = {
- e match{
+ e match {
case Neq(e1, e2) =>
e1 match {
// x != 0
- case v1: Local[G] => equalCheck.isConstantInt(e2).foreach{i => if(i == 0) variableNotZero.add(v1)}
+ case v1: Local[G] =>
+ equalCheck.isConstantInt(e2).foreach { i =>
+ if (i == 0)
+ variableNotZero.add(v1)
+ }
case _ =>
}
e2 match {
// 0 != x
- case v2: Local[G] => equalCheck.isConstantInt(e1).foreach { i => if (i == 0) variableNotZero.add(v2) }
+ case v2: Local[G] =>
+ equalCheck.isConstantInt(e1).foreach { i =>
+ if (i == 0)
+ variableNotZero.add(v2)
+ }
case _ =>
}
case Less(e1, e2) => lt(e1, e2, equal = false)
@@ -463,12 +638,18 @@ class AnnotationVariableInfoGetter[G]() {
lt(from, e1, equal = true)
lt(e1, to, equal = false)
// n == m + 1 then m < n
- case Eq(v1: Local[G], Plus(v2: Local[G], i: ConstantInt[G])) => varEqVarPlusInt(v1, v2, i.value)
- case Eq(v1: Local[G], Plus(i: ConstantInt[G], v2: Local[G])) => varEqVarPlusInt(v1, v2, i.value)
- case Eq(Plus(v2: Local[G], i: ConstantInt[G]), v1: Local[G]) => varEqVarPlusInt(v1, v2, i.value)
- case Eq(Plus(i: ConstantInt[G], v2: Local[G]), v1: Local[G]) => varEqVarPlusInt(v1, v2, i.value)
- case Eq(v1: Local[G], Plus(v2: Local[G], v3: Local[G])) => varEqVarPlusVar(v1, v2, v3)
- case Eq(Plus(v2: Local[G], v3: Local[G]), v1: Local[G]) => varEqVarPlusVar(v1, v2, v3)
+ case Eq(v1: Local[G], Plus(v2: Local[G], i: ConstantInt[G])) =>
+ varEqVarPlusInt(v1, v2, i.value)
+ case Eq(v1: Local[G], Plus(i: ConstantInt[G], v2: Local[G])) =>
+ varEqVarPlusInt(v1, v2, i.value)
+ case Eq(Plus(v2: Local[G], i: ConstantInt[G]), v1: Local[G]) =>
+ varEqVarPlusInt(v1, v2, i.value)
+ case Eq(Plus(i: ConstantInt[G], v2: Local[G]), v1: Local[G]) =>
+ varEqVarPlusInt(v1, v2, i.value)
+ case Eq(v1: Local[G], Plus(v2: Local[G], v3: Local[G])) =>
+ varEqVarPlusVar(v1, v2, v3)
+ case Eq(Plus(v2: Local[G], v3: Local[G]), v1: Local[G]) =>
+ varEqVarPlusVar(v1, v2, v3)
case _ =>
}
}
@@ -485,22 +666,30 @@ class AnnotationVariableInfoGetter[G]() {
case (None, Some(id2)) => variableSynonyms(v1) = id2
// Merge the groups, give every synonym group member of id2 value id1
case (Some(id1), Some(id2)) if id1 != id2 =>
- variableSynonyms.mapValuesInPlace((_, group) => if (group == id2) id1 else group)
+ variableSynonyms.mapValuesInPlace((_, group) =>
+ if (group == id2)
+ id1
+ else
+ group
+ )
case _ =>
}
}
def addValue(v: Local[G], x: BigInt): Unit =
variableValues.get(v) match {
- case Some(y) => if (x!=y) throw InconsistentVariableEquality(v, x, y)
+ case Some(y) =>
+ if (x != y)
+ throw InconsistentVariableEquality(v, x, y)
case None =>
variableValues(v) = x
- if(x!=0) variableNotZero.add(v)
+ if (x != 0)
+ variableNotZero.add(v)
addLessEq(v, x)
addGreaterEq(v, x)
}
- def addName(v: Local[G], expr: Expr[G]): Unit ={
+ def addName(v: Local[G], expr: Expr[G]): Unit = {
// Add to constant list
isConstantInt[G](expr) match {
case Some(x) => addValue(v, x)
@@ -521,17 +710,22 @@ class AnnotationVariableInfoGetter[G]() {
lowerBound.clear()
usefullConditions.clear()
- for(clause <- annotations){
- extractEqualities(clause)
- }
-
- val res = AnnotationVariableInfo[G](variableEqualities.view.mapValues(_.toList).toMap, variableValues.toMap,
- variableSynonyms.toMap, Set[Local[G]](), Map[Local[G], Set[Local[G]]](), Map[Local[G],BigInt](),
- Map[Local[G],BigInt](), usefullConditions)
+ for (clause <- annotations) { extractEqualities(clause) }
+
+ val res = AnnotationVariableInfo[G](
+ variableEqualities.view.mapValues(_.toList).toMap,
+ variableValues.toMap,
+ variableSynonyms.toMap,
+ Set[Local[G]](),
+ Map[Local[G], Set[Local[G]]](),
+ Map[Local[G], BigInt](),
+ Map[Local[G], BigInt](),
+ usefullConditions,
+ )
equalCheck = ExpressionEqualityCheck(Some(res))
- for(clause <- annotations){
- if(isSimpleExpr(clause)) {
+ for (clause <- annotations) {
+ if (isSimpleExpr(clause)) {
extractComparisons(clause)
usefullConditions.addOne(clause)
}
@@ -539,16 +733,23 @@ class AnnotationVariableInfoGetter[G]() {
distributeInfo()
- AnnotationVariableInfo(variableEqualities.view.mapValues(_.toList).toMap, variableValues.toMap,
- variableSynonyms.toMap, variableNotZero.toSet, lessThanEqVars.view.mapValues(_.toSet).toMap,
- upperBound.toMap, lowerBound.toMap, usefullConditions)
+ AnnotationVariableInfo(
+ variableEqualities.view.mapValues(_.toList).toMap,
+ variableValues.toMap,
+ variableSynonyms.toMap,
+ variableNotZero.toSet,
+ lessThanEqVars.view.mapValues(_.toSet).toMap,
+ upperBound.toMap,
+ lowerBound.toMap,
+ usefullConditions,
+ )
}
def distributeInfo(): Unit = {
// First check if expressions have become integers
- for((name, equals) <- variableEqualities){
- if(!variableValues.contains(name))
- for(equal <- equals){
+ for ((name, equals) <- variableEqualities) {
+ if (!variableValues.contains(name))
+ for (equal <- equals) {
equalCheck.isConstantInt(equal) match {
case Some(x) => addValue(name, x)
case None =>
@@ -558,41 +759,51 @@ class AnnotationVariableInfoGetter[G]() {
// Group synonym sets
val synonymSets: mutable.Map[Int, mutable.Set[Local[G]]] = mutable.Map()
- variableSynonyms.foreach{ case (v, groupId) => synonymSets.getOrElse(groupId,mutable.Set()).add(v) }
+ variableSynonyms.foreach { case (v, groupId) =>
+ synonymSets.getOrElse(groupId, mutable.Set()).add(v)
+ }
def hasValue(vars: mutable.Set[Local[G]]): Option[BigInt] = {
- vars.foreach{v => if(variableValues.contains(v)) return variableValues.get(v) }
+ vars.foreach { v =>
+ if (variableValues.contains(v))
+ return variableValues.get(v)
+ }
None
}
- def minOption(x: Option[BigInt], y: Option[BigInt]): Option[BigInt] = x.map{x => x.min(y.getOrElse(x))}.orElse(y)
- def maxOption(x: Option[BigInt], y: Option[BigInt]): Option[BigInt] = x.map{x => x.max(y.getOrElse(x))}.orElse(y)
+ def minOption(x: Option[BigInt], y: Option[BigInt]): Option[BigInt] =
+ x.map { x => x.min(y.getOrElse(x)) }.orElse(y)
+ def maxOption(x: Option[BigInt], y: Option[BigInt]): Option[BigInt] =
+ x.map { x => x.max(y.getOrElse(x)) }.orElse(y)
- synonymSets.foreach{ case (_, vars) =>
+ synonymSets.foreach { case (_, vars) =>
// Redistribute values over synonyms
- hasValue(vars).foreach{x => vars.foreach{addValue(_, x)}}
+ hasValue(vars).foreach { x => vars.foreach { addValue(_, x) } }
// Redistribute not-zero over synonyms
- if(vars.intersect(variableNotZero).nonEmpty) variableNotZero.addAll(vars)
+ if (vars.intersect(variableNotZero).nonEmpty)
+ variableNotZero.addAll(vars)
// Redistribute bounds that were found over synonym set
var min: Option[BigInt] = None
var max: Option[BigInt] = None
- vars.foreach{v =>
+ vars.foreach { v =>
min = minOption(upperBound.get(v), min)
max = maxOption(lowerBound.get(v), max)
}
- min.foreach{ x => vars.foreach{upperBound(_)=x}}
- max.foreach{ x => vars.foreach{lowerBound(_)=x}}
+ min.foreach { x => vars.foreach { upperBound(_) = x } }
+ max.foreach { x => vars.foreach { lowerBound(_) = x } }
// Collect all vars that are greater than
val greaterVars: mutable.Set[Local[G]] = mutable.Set()
- vars.foreach{ v =>
- lessThanEqVars(v) . map{variableSynonyms(_)} . foreach{ i => greaterVars.addAll(synonymSets(i)) }
+ vars.foreach { v =>
+ lessThanEqVars(v).map { variableSynonyms(_) }.foreach { i =>
+ greaterVars.addAll(synonymSets(i))
+ }
}
// Redistribute all greater vars again
- vars.foreach{ lessThanEqVars(_).addAll(greaterVars) }
+ vars.foreach { lessThanEqVars(_).addAll(greaterVars) }
- }
+ }
}
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/check/Check.scala b/src/col/vct/col/check/Check.scala
index dc8dd734d3..fbd7accf79 100644
--- a/src/col/vct/col/check/Check.scala
+++ b/src/col/vct/col/check/Check.scala
@@ -13,7 +13,10 @@ import scala.collection.immutable.ListSet
import scala.collection.mutable
case object Check {
- def inOrder(check1: => Seq[CheckError], check2: => Seq[CheckError]): Seq[CheckError] =
+ def inOrder(
+ check1: => Seq[CheckError],
+ check2: => Seq[CheckError],
+ ): Seq[CheckError] =
check1 match {
case Nil => check2
case more => more
@@ -28,23 +31,41 @@ sealed trait CheckError {
case TypeErrorText(expr, _) if expr.t.isInstanceOf[TNotAValue[_]] =>
Seq(context(expr) -> s"This expression is not a value.")
case TypeError(expr, expectedType) =>
- Seq(context(expr) -> s"Expected the type of this expression to be `$expectedType`, but got ${expr.t}.")
+ Seq(
+ context(expr) ->
+ s"Expected the type of this expression to be `$expectedType`, but got ${expr.t}."
+ )
case TypeErrorText(expr, expectedType) =>
- Seq(context(expr) -> s"Expected the type of this expression to be $expectedType, but got ${expr.t}.")
- case TypeErrorExplanation(expr, message) =>
- Seq(context(expr) -> message)
+ Seq(
+ context(expr) ->
+ s"Expected the type of this expression to be $expectedType, but got ${expr.t}."
+ )
+ case TypeErrorExplanation(expr, message) => Seq(context(expr) -> message)
case GenericTypeError(t, expectedType) =>
- Seq(context(t) -> s"This type variable refers to a name that is not actually a type.")
+ Seq(
+ context(t) ->
+ s"This type variable refers to a name that is not actually a type."
+ )
case OutOfScopeError(use, ref) =>
- Seq(context(use) -> "This usage is out of scope,", context(ref.decl) -> "since it is declared here.")
+ Seq(
+ context(use) -> "This usage is out of scope,",
+ context(ref.decl) -> "since it is declared here.",
+ )
case ThisOutsideScopeError(use) =>
- Seq(context(use) -> "`this` may not occur outside the declaration it refers to.")
+ Seq(
+ context(use) ->
+ "`this` may not occur outside the declaration it refers to."
+ )
case ThisInConstructorPre(use) =>
- Seq(context(use) -> "`this` may not occur in the precondition of a constructor.")
+ Seq(
+ context(use) ->
+ "`this` may not occur in the precondition of a constructor."
+ )
case OutOfWriteScopeError(reason, use, ref) =>
Seq(
context(use) -> "This may not be rewritten to, since ...",
- context(reason) -> "declarations outside this node must not be altered, and ...",
+ context(reason) ->
+ "declarations outside this node must not be altered, and ...",
context(ref.decl) -> "... it is declared here.",
)
case DoesNotDefine(declarator, declaration, use) =>
@@ -54,40 +75,72 @@ sealed trait CheckError {
context(declarator.asInstanceOf[Node[_]]) -> "in this declarator.",
)
// TODO PB: these are kind of obsolete? maybe?
- case IncomparableTypes(left, right) =>
- ???
- case TupleTypeCount(tup) =>
- ???
+ case IncomparableTypes(left, right) => ???
+ case TupleTypeCount(tup) => ???
case NotAPredicateApplication(res) =>
- Seq(context(res) -> "This expression is not a (scaled) predicate application")
+ Seq(
+ context(res) ->
+ "This expression is not a (scaled) predicate application"
+ )
case AbstractPredicate(res) =>
- Seq(context(res) -> "This predicate is abstract, and hence cannot be meaningfully folded or unfolded")
+ Seq(
+ context(res) ->
+ "This predicate is abstract, and hence cannot be meaningfully folded or unfolded"
+ )
case RedundantCatchClause(clause) =>
- Seq(context(clause) -> "This catch clause is redundant, because it is subsumed by the caught types of earlier catch clauses in this block.")
+ Seq(
+ context(clause) ->
+ "This catch clause is redundant, because it is subsumed by the caught types of earlier catch clauses in this block."
+ )
case ResultOutsidePostcondition(res) =>
Seq(context(res) -> "\\result may only occur in the postcondition.")
case ReturnOutsideMethod(ret) =>
Seq(context(ret) -> "return may only occur in methods and procedures.")
case FinalPermission(loc) =>
- Seq(context(loc) -> "Specifying permission over final fields is not allowed, since they are treated as constants.")
+ Seq(
+ context(loc) ->
+ "Specifying permission over final fields is not allowed, since they are treated as constants."
+ )
case PVLSeqAssignEndpoint(a) =>
- Seq(context(a) -> "This dereference does not take place on one of the endpoints in the surrounding `seq_prog`.")
+ Seq(
+ context(a) ->
+ "This dereference does not take place on one of the endpoints in the surrounding `seq_prog`."
+ )
case SeqProgStatement(s) =>
Seq(context(s) -> "This statement is not allowed in `seq_prog`.")
case SeqProgInstanceMethodArgs(m) =>
- Seq(context(m) -> "An instance method in a `seq_prog` cannot have any arguments.")
+ Seq(
+ context(m) ->
+ "An instance method in a `seq_prog` cannot have any arguments."
+ )
case SeqProgInstanceMethodBody(m) =>
- Seq(context(m) -> "An instance method in a `seq_prog` must have a body.")
+ Seq(
+ context(m) -> "An instance method in a `seq_prog` must have a body."
+ )
case SeqProgInstanceMethodNonVoid(m) =>
- Seq(context(m) -> "An instance method in a `seq_prog` must have return type `void`.")
+ Seq(
+ context(m) ->
+ "An instance method in a `seq_prog` must have return type `void`."
+ )
case SeqProgInvocation(s) =>
- Seq(context(s) -> "Only invocations on `this` and endpoints are allowed.")
+ Seq(
+ context(s) -> "Only invocations on `this` and endpoints are allowed."
+ )
case SeqProgReceivingEndpoint(e) =>
- Seq(context(e) -> s"Can only refer to the receiving endpoint of this statement.")
+ Seq(
+ context(e) ->
+ s"Can only refer to the receiving endpoint of this statement."
+ )
case SeqProgParticipant(s) =>
- Seq(context(s) -> s"An endpoint is used in this branch which is not allowed to participate at this point in the program because of earlier branches.")
+ Seq(
+ context(s) ->
+ s"An endpoint is used in this branch which is not allowed to participate at this point in the program because of earlier branches."
+ )
case SeqProgNoParticipant(s) =>
- Seq(context(s) -> s"Unclear what the participating endpoint is in this statement")
+ Seq(
+ context(s) ->
+ s"Unclear what the participating endpoint is in this statement"
+ )
case SeqProgEndpointAssign(a) =>
Seq(context(a) -> s"Raw assignment to an endpoint is not allowed.")
case SeqProgInstanceMethodPure(m) =>
@@ -100,28 +153,41 @@ sealed trait CheckError {
case class TypeError(expr: Expr[_], expectedType: Type[_]) extends CheckError {
val subcode = "type"
}
-case class TypeErrorText(expr: Expr[_], expectedType: String) extends CheckError {
+case class TypeErrorText(expr: Expr[_], expectedType: String)
+ extends CheckError {
val subcode = "type"
}
-case class TypeErrorExplanation(expr: Node[_], message: String) extends CheckError {
+case class TypeErrorExplanation(expr: Node[_], message: String)
+ extends CheckError {
val subcode = "type"
}
-case class GenericTypeError(t: Type[_], expectedType: TType[_]) extends CheckError {
+case class GenericTypeError(t: Type[_], expectedType: TType[_])
+ extends CheckError {
val subcode = "genericType"
}
-case class OutOfScopeError[G](use: Node[G], ref: Ref[G, _ <: Declaration[G]]) extends CheckError {
+case class OutOfScopeError[G](use: Node[G], ref: Ref[G, _ <: Declaration[G]])
+ extends CheckError {
val subcode = "outOfScope"
}
-case class ThisOutsideScopeError[G](use: ThisDeclaration[G]) extends CheckError {
+case class ThisOutsideScopeError[G](use: ThisDeclaration[G])
+ extends CheckError {
override def subcode: String = "thisOutOfScope"
}
case class ThisInConstructorPre[G](use: ThisObject[G]) extends CheckError {
override def subcode: String = "thisInConsPre"
}
-case class OutOfWriteScopeError[G](reason: Node[G], use: Node[G], ref: Ref[G, _ <: Declaration[G]]) extends CheckError {
+case class OutOfWriteScopeError[G](
+ reason: Node[G],
+ use: Node[G],
+ ref: Ref[G, _ <: Declaration[G]],
+) extends CheckError {
val subcode = "outOfWriteScope"
}
-case class DoesNotDefine(declarator: Declarator[_], declaration: Declaration[_], use: Node[_]) extends CheckError {
+case class DoesNotDefine(
+ declarator: Declarator[_],
+ declaration: Declaration[_],
+ use: Node[_],
+) extends CheckError {
val subcode = "doesNotDefine"
}
case class IncomparableTypes(left: Expr[_], right: Expr[_]) extends CheckError {
@@ -148,10 +214,12 @@ case class ReturnOutsideMethod(ret: Return[_]) extends CheckError {
case class FinalPermission(loc: FieldLocation[_]) extends CheckError {
override def subcode: String = "finalPerm"
}
-case class PVLSeqAssignEndpoint(assign: PVLChorStatement[_]) extends CheckError {
+case class PVLSeqAssignEndpoint(assign: PVLChorStatement[_])
+ extends CheckError {
val subcode = "pvlSeqAssignEndpoint"
}
-case class SeqProgInstanceMethodNonVoid(m: InstanceMethod[_]) extends CheckError {
+case class SeqProgInstanceMethodNonVoid(m: InstanceMethod[_])
+ extends CheckError {
val subcode = "seqProgInstanceMethodNonVoid"
}
case class SeqProgInstanceMethodArgs(m: InstanceMethod[_]) extends CheckError {
@@ -183,37 +251,46 @@ case class SeqProgInstanceMethodPure(m: InstanceMethod[_]) extends CheckError {
}
case object CheckContext {
- case class ScopeFrame[G](decls: Seq[Declaration[G]], scanLazily: Seq[Node[G]]) {
+ case class ScopeFrame[G](
+ decls: Seq[Declaration[G]],
+ scanLazily: Seq[Node[G]],
+ ) {
private lazy val declSet = decls.toSet
- private lazy val scannedDeclSet = scanLazily.flatMap(ResolveReferences.scanScope(TypeResolutionContext())).toSet
+ private lazy val scannedDeclSet =
+ scanLazily.flatMap(ResolveReferences.scanScope(TypeResolutionContext()))
+ .toSet
def contains(decl: Declaration[G]): Boolean =
- declSet.contains(decl) || (scanLazily.nonEmpty && scannedDeclSet.contains(decl))
+ declSet.contains(decl) ||
+ (scanLazily.nonEmpty && scannedDeclSet.contains(decl))
}
}
-case class CheckContext[G]
-(
- scopes: Seq[CheckContext.ScopeFrame[G]] = Seq(),
- undeclared: Seq[Seq[Declaration[G]]] = Nil,
- roScopes: Int = 0, roScopeReason: Option[Node[G]] = None,
- currentApplicable: Option[Applicable[G]] = None,
- inPreCondition: Boolean = false,
- inPostCondition: Boolean = false,
- currentChoreography: Option[Choreography[G]] = None,
- currentReceiverEndpoint: Option[Endpoint[G]] = None,
- currentParticipatingEndpoints: Option[Set[Endpoint[G]]] = None,
- declarationStack: Seq[Declaration[G]] = Nil,
+case class CheckContext[G](
+ scopes: Seq[CheckContext.ScopeFrame[G]] = Seq(),
+ undeclared: Seq[Seq[Declaration[G]]] = Nil,
+ roScopes: Int = 0,
+ roScopeReason: Option[Node[G]] = None,
+ currentApplicable: Option[Applicable[G]] = None,
+ inPreCondition: Boolean = false,
+ inPostCondition: Boolean = false,
+ currentChoreography: Option[Choreography[G]] = None,
+ currentReceiverEndpoint: Option[Endpoint[G]] = None,
+ currentParticipatingEndpoints: Option[Set[Endpoint[G]]] = None,
+ declarationStack: Seq[Declaration[G]] = Nil,
) {
def withScope(decls: Seq[Declaration[G]]): Seq[CheckContext.ScopeFrame[G]] =
scopes :+ CheckContext.ScopeFrame(decls, Nil)
- /**
- * In effect toScan is just scanned for LocalDecl's, and these are added to decls. We want to delay this, because
- * the scanning operation is expensive, and for most of the transformation run the declaration is declared directly
- * anyway.
- */
- def withScope(decls: Seq[Declaration[G]], toScan: Seq[Node[G]]): Seq[CheckContext.ScopeFrame[G]] =
+ /** In effect toScan is just scanned for LocalDecl's, and these are added to
+ * decls. We want to delay this, because the scanning operation is expensive,
+ * and for most of the transformation run the declaration is declared
+ * directly anyway.
+ */
+ def withScope(
+ decls: Seq[Declaration[G]],
+ toScan: Seq[Node[G]],
+ ): Seq[CheckContext.ScopeFrame[G]] =
scopes :+ CheckContext.ScopeFrame(decls, toScan)
def withDeclaration(decl: Declaration[G]): CheckContext[G] =
@@ -222,11 +299,9 @@ case class CheckContext[G]
def withApplicable(applicable: Applicable[G]): CheckContext[G] =
copy(currentApplicable = Some(applicable))
- def withPostcondition: CheckContext[G] =
- copy(inPostCondition = true)
+ def withPostcondition: CheckContext[G] = copy(inPostCondition = true)
- def withPrecondition: CheckContext[G] =
- copy(inPreCondition = true)
+ def withPrecondition: CheckContext[G] = copy(inPreCondition = true)
def withUndeclared(decls: Seq[Declaration[G]]): CheckContext[G] =
copy(undeclared = undeclared :+ decls)
@@ -237,11 +312,15 @@ case class CheckContext[G]
def withReceiverEndpoint(endpoint: Endpoint[G]): CheckContext[G] =
copy(currentReceiverEndpoint = Some(endpoint))
- def withCurrentParticipatingEndpoints(endpoints: Seq[Endpoint[G]]): Option[Set[Endpoint[G]]] =
+ def withCurrentParticipatingEndpoints(
+ endpoints: Seq[Endpoint[G]]
+ ): Option[Set[Endpoint[G]]] =
// ListSet to preserve insertion order
Some(ListSet.from(endpoints))
- def appendCurrentParticipatingEndpoints(newEndpoints: Seq[Endpoint[G]]): Option[Set[Endpoint[G]]] =
+ def appendCurrentParticipatingEndpoints(
+ newEndpoints: Seq[Endpoint[G]]
+ ): Option[Set[Endpoint[G]]] =
// ListSet to preserve insertion order
currentParticipatingEndpoints match {
case None => withCurrentParticipatingEndpoints(newEndpoints)
@@ -249,23 +328,39 @@ case class CheckContext[G]
}
def inScope[Decl <: Declaration[G]](ref: Ref[G, Decl]): Boolean =
- !undeclared.exists(_.contains(ref.decl)) && scopes.exists(_.contains(ref.decl))
+ !undeclared.exists(_.contains(ref.decl)) &&
+ scopes.exists(_.contains(ref.decl))
def inWriteScope[Decl <: Declaration[G]](ref: Ref[G, Decl]): Boolean =
- !undeclared.exists(_.contains(ref.decl)) && scopes.drop(roScopes).exists(_.contains(ref.decl))
+ !undeclared.exists(_.contains(ref.decl)) && scopes.drop(roScopes)
+ .exists(_.contains(ref.decl))
- def checkInScope[Decl <: Declaration[G]](use: Node[G], ref: Ref[G, Decl]): Seq[CheckError] =
- if(inScope(ref)) Nil
- else Seq(OutOfScopeError(use, ref))
+ def checkInScope[Decl <: Declaration[G]](
+ use: Node[G],
+ ref: Ref[G, Decl],
+ ): Seq[CheckError] =
+ if (inScope(ref))
+ Nil
+ else
+ Seq(OutOfScopeError(use, ref))
- def checkInWriteScope[Decl <: Declaration[G]](reason: Option[Node[G]], use: Node[G], ref: Ref[G, Decl]): Seq[CheckError] =
- if (!inScope(ref)) Seq(OutOfScopeError(use, ref))
- else if(!inWriteScope(ref)) Seq(OutOfWriteScopeError(reason.get, use, ref))
- else Nil
+ def checkInWriteScope[Decl <: Declaration[G]](
+ reason: Option[Node[G]],
+ use: Node[G],
+ ref: Ref[G, Decl],
+ ): Seq[CheckError] =
+ if (!inScope(ref))
+ Seq(OutOfScopeError(use, ref))
+ else if (!inWriteScope(ref))
+ Seq(OutOfWriteScopeError(reason.get, use, ref))
+ else
+ Nil
}
-case class UnreachableAfterTypeCheck(message: String, at: Node[_]) extends ASTStateError {
- override def text: String = "A condition was reached that should have been excluded by the type check. " +
- "Either a property of a node was queried before the type check, or the type check is missing a condition. " +
- f"The node says: $message"
-}
\ No newline at end of file
+case class UnreachableAfterTypeCheck(message: String, at: Node[_])
+ extends ASTStateError {
+ override def text: String =
+ "A condition was reached that should have been excluded by the type check. " +
+ "Either a property of a node was queried before the type check, or the type check is missing a condition. " +
+ f"The node says: $message"
+}
diff --git a/src/col/vct/col/compare/Compare.scala b/src/col/vct/col/compare/Compare.scala
index 37f51f28ce..93a6836a1f 100644
--- a/src/col/vct/col/compare/Compare.scala
+++ b/src/col/vct/col/compare/Compare.scala
@@ -5,16 +5,26 @@ import vct.col.ast.{Declaration, Node}
import scala.collection.mutable
case object Compare {
- def compare[L, R](left: Node[L], right: Node[R])(toNormalForm: PartialFunction[Node[L], Node[L]]): LazyList[CompareResult[L, R]] =
+ def compare[L, R](left: Node[L], right: Node[R])(
+ toNormalForm: PartialFunction[Node[L], Node[L]]
+ ): LazyList[CompareResult[L, R]] =
underEquivalence(left.compare(right))(toNormalForm)
- def underEquivalence[L, R](diffs: LazyList[CompareResult[L, R]])(toNormalForm: PartialFunction[Node[L], Node[L]]): LazyList[CompareResult[L, R]] =
+ def underEquivalence[L, R](diffs: LazyList[CompareResult[L, R]])(
+ toNormalForm: PartialFunction[Node[L], Node[L]]
+ ): LazyList[CompareResult[L, R]] =
diffs.flatMap {
case diff @ StructuralDifference(left, right) =>
- (toNormalForm.lift(left), toNormalForm.lift(right.asInstanceOf[Node[L]]).asInstanceOf[Option[Node[R]]]) match {
+ (
+ toNormalForm.lift(left),
+ toNormalForm.lift(right.asInstanceOf[Node[L]])
+ .asInstanceOf[Option[Node[R]]],
+ ) match {
case (None, None) => Seq(diff)
case (maybeLeft, maybeRight) =>
- compare(maybeLeft.getOrElse(left), maybeRight.getOrElse(right))(toNormalForm)
+ compare(maybeLeft.getOrElse(left), maybeRight.getOrElse(right))(
+ toNormalForm
+ )
}
case otherDiff => Seq(otherDiff)
}
@@ -22,13 +32,21 @@ case object Compare {
def equals[L, R](left: Node[L], right: Node[R]): Boolean =
left.compare(right).isEmpty
- def getIsomorphism[L, R](left: Node[L], right: Node[R], matchFreeVariables: Boolean = false): Either[Seq[(Node[L], Node[R])], Map[Declaration[L], Declaration[R]]] = {
+ def getIsomorphism[L, R](
+ left: Node[L],
+ right: Node[R],
+ matchFreeVariables: Boolean = false,
+ ): Either[Seq[(Node[L], Node[R])], Map[Declaration[L], Declaration[R]]] = {
val isomorphism = mutable.Map[Declaration[L], Declaration[R]]()
val valueSet = mutable.Set[Declaration[R]]()
val irreconcilableDiffs = mutable.ArrayBuffer[(Node[L], Node[R])]()
val boundVariables = mutable.Set[Declaration[L]]()
- def define(left: Declaration[L], right: Declaration[R], mustMatch: Boolean): Unit = {
+ def define(
+ left: Declaration[L],
+ right: Declaration[R],
+ mustMatch: Boolean,
+ ): Unit = {
if (mustMatch && left != right) {
irreconcilableDiffs += ((left, right))
return;
@@ -43,7 +61,12 @@ case object Compare {
}
left.compare(right).foreach {
- case MatchingReference(left, right) => define(left, right, mustMatch = matchFreeVariables && !boundVariables.contains(left))
+ case MatchingReference(left, right) =>
+ define(
+ left,
+ right,
+ mustMatch = matchFreeVariables && !boundVariables.contains(left),
+ )
case MatchingDeclaration(left, right) =>
boundVariables.add(left)
define(left, right, mustMatch = false)
@@ -51,10 +74,15 @@ case object Compare {
irreconcilableDiffs += ((left, right))
}
- if(irreconcilableDiffs.isEmpty) Right(isomorphism.toMap)
- else Left(irreconcilableDiffs.toSeq)
+ if (irreconcilableDiffs.isEmpty)
+ Right(isomorphism.toMap)
+ else
+ Left(irreconcilableDiffs.toSeq)
}
- def isIsomorphic[L, R](left: Node[L], right: Node[R], matchFreeVariables: Boolean = false): Boolean =
- getIsomorphism(left, right, matchFreeVariables).isRight
+ def isIsomorphic[L, R](
+ left: Node[L],
+ right: Node[R],
+ matchFreeVariables: Boolean = false,
+ ): Boolean = getIsomorphism(left, right, matchFreeVariables).isRight
}
diff --git a/src/col/vct/col/compare/CompareResult.scala b/src/col/vct/col/compare/CompareResult.scala
index b16f337a9a..56d4c26723 100644
--- a/src/col/vct/col/compare/CompareResult.scala
+++ b/src/col/vct/col/compare/CompareResult.scala
@@ -3,6 +3,11 @@ package vct.col.compare
import vct.col.ast.{Declaration, Node}
sealed trait CompareResult[L, R]
-case class MatchingDeclaration[L, R](left: Declaration[L], right: Declaration[R]) extends CompareResult[L, R]
-case class MatchingReference[L, R](left: Declaration[L], right: Declaration[R]) extends CompareResult[L, R]
-case class StructuralDifference[L, R](left: Node[L], right: Node[R]) extends CompareResult[L, R]
\ No newline at end of file
+case class MatchingDeclaration[L, R](
+ left: Declaration[L],
+ right: Declaration[R],
+) extends CompareResult[L, R]
+case class MatchingReference[L, R](left: Declaration[L], right: Declaration[R])
+ extends CompareResult[L, R]
+case class StructuralDifference[L, R](left: Node[L], right: Node[R])
+ extends CompareResult[L, R]
diff --git a/src/col/vct/col/debug/DebugRewriteState.scala b/src/col/vct/col/debug/DebugRewriteState.scala
index 784f765b8d..d493d638f1 100644
--- a/src/col/vct/col/debug/DebugRewriteState.scala
+++ b/src/col/vct/col/debug/DebugRewriteState.scala
@@ -3,4 +3,4 @@ package vct.col.debug
sealed trait DebugRewriteState
case object NotProcessed extends DebugRewriteState
case object Succeeded extends DebugRewriteState
-case object Dropped extends DebugRewriteState
\ No newline at end of file
+case object Dropped extends DebugRewriteState
diff --git a/src/col/vct/col/err/ASTStateError.scala b/src/col/vct/col/err/ASTStateError.scala
index 96109391db..1b505d89ce 100644
--- a/src/col/vct/col/err/ASTStateError.scala
+++ b/src/col/vct/col/err/ASTStateError.scala
@@ -2,4 +2,4 @@ package vct.col.err
import vct.result.VerificationError.SystemError
-abstract class ASTStateError extends SystemError
\ No newline at end of file
+abstract class ASTStateError extends SystemError
diff --git a/src/col/vct/col/err/ContextSensitiveNodeNotResolved.scala b/src/col/vct/col/err/ContextSensitiveNodeNotResolved.scala
index bae2b7abb7..91e50e9239 100644
--- a/src/col/vct/col/err/ContextSensitiveNodeNotResolved.scala
+++ b/src/col/vct/col/err/ContextSensitiveNodeNotResolved.scala
@@ -2,7 +2,8 @@ package vct.col.err
import vct.col.ast.Expr
-case class ContextSensitiveNodeNotResolved(expr: Expr[_], message: String) extends ASTStateError {
+case class ContextSensitiveNodeNotResolved(expr: Expr[_], message: String)
+ extends ASTStateError {
override def text: String =
"A node was encountered of which the type is context-sensitive, but its context is not yet resolved. " +
f"The node says: $message"
diff --git a/src/col/vct/col/err/InconsistentSuccessionTypes.scala b/src/col/vct/col/err/InconsistentSuccessionTypes.scala
index bf5f922e53..be16924ad9 100644
--- a/src/col/vct/col/err/InconsistentSuccessionTypes.scala
+++ b/src/col/vct/col/err/InconsistentSuccessionTypes.scala
@@ -4,13 +4,18 @@ import vct.col.ast.Declaration
import vct.result.Message
import vct.result.VerificationError.SystemError
-case class InconsistentSuccessionTypes(left: Declaration[_], right: Declaration[_]) extends SystemError {
+case class InconsistentSuccessionTypes(
+ left: Declaration[_],
+ right: Declaration[_],
+) extends SystemError {
override def text: String = {
- val leftContext = context[vct.col.util.CurrentRewriteProgramContext].getOrElse(left.o)
+ val leftContext = context[vct.col.util.CurrentRewriteProgramContext]
+ .getOrElse(left.o)
Message.messagesInContext(
leftContext -> "The kind of this declaration does not match ...",
- right.highlight(right) -> "... the kind of this declaration, so it may not be succeeded by this declaration.",
+ right.highlight(right) ->
+ "... the kind of this declaration, so it may not be succeeded by this declaration.",
)
}
}
diff --git a/src/col/vct/col/err/MistypedRef.scala b/src/col/vct/col/err/MistypedRef.scala
index 337167ce8f..3b0602546a 100644
--- a/src/col/vct/col/err/MistypedRef.scala
+++ b/src/col/vct/col/err/MistypedRef.scala
@@ -4,7 +4,8 @@ import vct.col.ast.Declaration
import scala.reflect.ClassTag
-case class MistypedRef(received: Declaration[_], expected: ClassTag[_]) extends ASTStateError {
+case class MistypedRef(received: Declaration[_], expected: ClassTag[_])
+ extends ASTStateError {
override def text: String =
"A reference in the AST is referencing a declaration of the wrong kind.\n" +
s"A ${expected.runtimeClass.getSimpleName} was expected here, but we got a ${received.getClass.getSimpleName}"
diff --git a/src/col/vct/col/err/NotResolved.scala b/src/col/vct/col/err/NotResolved.scala
index 3947cf661f..30cb3c94e8 100644
--- a/src/col/vct/col/err/NotResolved.scala
+++ b/src/col/vct/col/err/NotResolved.scala
@@ -5,7 +5,10 @@ import vct.col.ref.UnresolvedRef
import scala.reflect.ClassTag
-case class NotResolved[G](ref: UnresolvedRef[G, _ <: Declaration[G]], expected: ClassTag[_]) extends ASTStateError {
+case class NotResolved[G](
+ ref: UnresolvedRef[G, _ <: Declaration[G]],
+ expected: ClassTag[_],
+) extends ASTStateError {
override def text: String =
"The declaration of an unresolved reference was queried, but it is not yet resolved.\n" +
s"We expected the name `${ref.name}` to resolve to a ${expected.runtimeClass.getSimpleName}."
diff --git a/src/col/vct/col/feature/Feature.scala b/src/col/vct/col/feature/Feature.scala
index 1f9e34ff0e..7840e27f9d 100644
--- a/src/col/vct/col/feature/Feature.scala
+++ b/src/col/vct/col/feature/Feature.scala
@@ -33,9 +33,12 @@ case object Classes extends Feature // ClassToRef
case object Pointers extends Feature // ~ImportADT?
case object Arrays extends Feature // ~ImportADT?
case object AmbiguousOperators extends Feature // Disambiguate
-case object SugarPermissionOperator extends Feature // DesugarPermissionOperators
-case object SugarCollectionOperator extends Feature // DesugarCollectionOperators
-case object ExpressionWithSideEffects extends Feature // ResolveExpressionSideEffects
+case object SugarPermissionOperator
+ extends Feature // DesugarPermissionOperators
+case object SugarCollectionOperator
+ extends Feature // DesugarCollectionOperators
+case object ExpressionWithSideEffects
+ extends Feature // ResolveExpressionSideEffects
case object UnscopedDeclaration extends Feature // CollectLocalDeclarations
case object LoopIterationContract extends Feature // IterationContractToParBlock
case object ParallelRegion extends Feature // ParBlockEncoder
@@ -45,7 +48,8 @@ case object NonWhileLoop extends Feature // ForLoopToWhileLoop
case object IntrinsicLocks extends Feature // EncodeIntrinsicLock
case object WaitNotify extends Feature // EncodeIntrinsicLock
case object Evaluation extends Feature // EvaluationTargetDummy
-case object ExceptionalLoopControl extends Feature // ContinueToBreak + EncodeBreakReturn
+case object ExceptionalLoopControl
+ extends Feature // ContinueToBreak + EncodeBreakReturn
case object NonTrivialLabel extends Feature // EncodeBreakReturn
case object SwitchStatement extends Feature // SwitchToGoto
case object Exceptions extends Feature // EncodeTryThrowSignals
@@ -93,4 +97,4 @@ case object SmtDeclarations extends Feature
case object SmtTypes extends Feature
case object Methods extends Feature
case object WhileLoops extends Feature
-case object RootStructure extends Feature
\ No newline at end of file
+case object RootStructure extends Feature
diff --git a/src/col/vct/col/feature/FeatureRainbow.scala b/src/col/vct/col/feature/FeatureRainbow.scala
index e6feec1a58..6251618f6d 100644
--- a/src/col/vct/col/feature/FeatureRainbow.scala
+++ b/src/col/vct/col/feature/FeatureRainbow.scala
@@ -15,704 +15,765 @@ class FeatureRainbow[G] {
private var returnValues: Seq[Expr[G]] = Nil
def scan(node: Node[G]): Unit =
- node.transSubnodes.foreach(node => scanFlatly(node).foreach(f => {
- features += f
- examples.getOrElseUpdate(f, ArrayBuffer()) += node
- }))
-
- def scanFlatly(node: Node[G]): Seq[Feature] = Seq(node match {
- case node: AmbiguousLocation[G] => AmbiguousOperators
- case node: AmbiguousGreater[G] => AmbiguousOperators
- case node: AmbiguousLess[G] => AmbiguousOperators
- case node: AmbiguousGreaterEq[G] => AmbiguousOperators
- case node: AmbiguousLessEq[G] => AmbiguousOperators
-
- case node: ArrayLocation[G] => Arrays
- case node: NewArray[G] => Arrays
- case node: NewPointerArray[G] => Arrays
- case node: ArraySubscript[G] => Arrays
- case node: Length[G] => Arrays
- case node: TArray[G] => Arrays
-
- case node: Assign[G] => Assignment
- case node: Havoc[G] => Assignment
- case node: SilverLocalAssign[G] => Assignment
-
- case node: ADTAxiom[G] => AxiomaticDataTypes
- case node: ADTFunction[G] => AxiomaticDataTypes
- case node: ADTFunctionInvocation[G] => AxiomaticDataTypes
- case node: AxiomaticDataType[G] => AxiomaticDataTypes
- case node: TAxiomatic[G] => AxiomaticDataTypes
-
- case node: LiteralTuple[G] => AxiomaticLibraryType
- case node: LiteralMap[G] => AxiomaticLibraryType
- case node: OptSome[G] => AxiomaticLibraryType
- case node: OptNone[G] => AxiomaticLibraryType
- case node: EitherLeft[G] => AxiomaticLibraryType
- case node: EitherRight[G] => AxiomaticLibraryType
- case node: MapCons[G] => AxiomaticLibraryType
- case node: MapEq[G] => AxiomaticLibraryType
- case node: MapDisjoint[G] => AxiomaticLibraryType
- case node: MapKeySet[G] => AxiomaticLibraryType
- case node: MapValueSet[G] => AxiomaticLibraryType
- case node: MapItemSet[G] => AxiomaticLibraryType
- case node: MapRemove[G] => AxiomaticLibraryType
- case node: MapMember[G] => AxiomaticLibraryType
- case node: OptGet[G] => AxiomaticLibraryType
- case node: OptGetOrElse[G] => AxiomaticLibraryType
- case node: GetLeft[G] => AxiomaticLibraryType
- case node: GetRight[G] => AxiomaticLibraryType
- case node: IsLeft[G] => AxiomaticLibraryType
- case node: IsRight[G] => AxiomaticLibraryType
- case node: MapGet[G] => AxiomaticLibraryType
- case node: TupGet[G] => AxiomaticLibraryType
- case node: TFraction[G] => AxiomaticLibraryType
- case node: TZFraction[G] => AxiomaticLibraryType
- case node: TOption[G] => AxiomaticLibraryType
- case node: TEither[G] => AxiomaticLibraryType
- case node: TTuple[G] => AxiomaticLibraryType
- case node: TMap[G] => AxiomaticLibraryType
- case node: OptEmpty[G] => AxiomaticLibraryType
- case node: OptNoneTyped[G] => AxiomaticLibraryType
- case node: OptSomeTyped[G] => AxiomaticLibraryType
- case node: TNull[G] => AxiomaticLibraryType
-
- case node: Assert[G] => BasicStatement
- case node: Assume[G] => BasicStatement
- case node: Block[G] => BasicStatement
- case node: Scope[G] => BasicStatement
-
- case node: BitNot[G] => BitOperators
- case node: BitAnd[G] => BitOperators
- case node: BitOr[G] => BitOperators
- case node: BitXor[G] => BitOperators
- case node: BitShl[G] => BitOperators
- case node: BitShr[G] => BitOperators
- case node: BitUShr[G] => BitOperators
-
- case node: Values[G] => BuiltinArrayOperators
-
- case node: Deref[G] => Classes
- case node: InstancePredicateApply[G] => Classes
- case node: CoalesceInstancePredicateApply[G] => Classes
- case node: InstanceFunctionInvocation[G] => Classes
- case node: InstancePredicateLocation[G] => Classes
- case node: NewObject[G] => Classes
- case node: TClass[G] => Classes
- case node: Class[G] => Classes
- case node: FieldLocation[G] => Classes
- case node: InvokeMethod[G] => Classes
- case node: TAnyClass[G] => Classes
- case node: ThisObject[G] => Classes
- case node: InstanceField[G] => Classes
-
- case node: ApplyCoercion[G] => Coercions
- case node: CoerceBoolResource[G] => Coercions
- case node: CoerceBoundIntFrac[G] => Coercions
- case node: CoerceBoundIntZFrac[G] => Coercions
- case node: CoerceClassAnyClass[G] => Coercions
- case node: CoerceColToCPrimitive[G] => Coercions
- case node: CoerceCPrimitiveToCol[G] => Coercions
- case node: CoerceColToCPPPrimitive[G] => Coercions
- case node: CoerceCPPPrimitiveToCol[G] => Coercions
- case node: CoerceFloatRat[G] => Coercions
- case node: CoerceFracZFrac[G] => Coercions
- case node: CoerceIdentity[G] => Coercions
- case node: CoerceIncreasePrecision[G] => Coercions
- case node: CoerceIntRat[G] => Coercions
- case node: CoerceJavaClassAnyClass[G] => Coercions
- case node: CoerceJavaSupports[G] => Coercions
- case node: CoerceJoinUnion[G] => Coercions
- case node: CoerceMapBag[G] => Coercions
- case node: CoerceMapEither[G] => Coercions
- case node: CoerceMapMap[G] => Coercions
- case node: CoerceMapMatrix[G] => Coercions
- case node: CoerceMapOption[G] => Coercions
- case node: CoerceMapSeq[G] => Coercions
- case node: CoerceMapSet[G] => Coercions
- case node: CoerceMapTuple[G] => Coercions
- case node: CoerceMapType[G] => Coercions
- case node: CoerceMapVector[G] => Coercions
- case node: CoerceNothingSomething[G] => Coercions
- case node: CoerceNullAnyClass[G] => Coercions
- case node: CoerceNullArray[G] => Coercions
- case node: CoerceNullClass[G] => Coercions
- case node: CoerceNullJavaClass[G] => Coercions
- case node: CoerceNullPointer[G] => Coercions
- case node: CoerceNullRef[G] => Coercions
- case node: CoerceRatZFrac[G] => Coercions
- case node: CoerceSelectUnion[G] => Coercions
- case node: CoerceSomethingAnyValue[G] => Coercions
- case node: CoerceSupports[G] => Coercions
- case node: CoerceUnboundInt[G] => Coercions
- case node: CoerceWidenBound[G] => Coercions
- case node: CoerceZFracFrac[G] => Coercions
- case node: CoerceZFracRat[G] => Coercions
- case node: CoercionSequence[G] => Coercions
-
- case node: ComputationalOr[G] => ComputationalLogicOperator
- case node: ComputationalXor[G] => ComputationalLogicOperator
- case node: ComputationalAnd[G] => ComputationalLogicOperator
-
- case node: AmbiguousThis[G] => ContextSensitiveNode
- case node: AmbiguousResult[G] => ContextSensitiveNode
-
- case node: ApplicableContract[G] => Contracts
- case node: LoopInvariant[G] => Contracts
- case node: SplitAccountedPredicate[G] => Contracts
- case node: UnitAccountedPredicate[G] => Contracts
-
- case node: CAnonymousFunctionDeclarator[G] => CSpecific
- case node: CArrayDeclarator[G] => CSpecific
- case node: CAtomic[G] => CSpecific
- case node: CBool[G] => CSpecific
- case node: CConst[G] => CSpecific
- case node: CDeclaration[G] => CSpecific
- case node: CDouble[G] => CSpecific
- case node: CExtern[G] => CSpecific
- case node: CFloat[G] => CSpecific
- case node: CFunctionDefinition[G] => CSpecific
- case node: CGlobalDeclaration[G] => CSpecific
- case node: CInit[G] => CSpecific
- case node: CInline[G] => CSpecific
- case node: CInt[G] => CSpecific
- case node: CInvocation[G] => CSpecific
- case node: CLocal[G] => CSpecific
- case node: CLocalDeclaration[G] => CSpecific
- case node: CLong[G] => CSpecific
- case node: CName[G] => CSpecific
- case node: CParam[G] => CSpecific
- case node: CPrimitiveType[G] => CSpecific
- case node: CPure[G] => CSpecific
- case node: CRestrict[G] => CSpecific
- case node: CShort[G] => CSpecific
- case node: CSigned[G] => CSpecific
- case node: CSpecificationType[G] => CSpecific
- case node: CStatic[G] => CSpecific
- case node: CFieldAccess[G] => CSpecific
- case node: CStructDeref[G] => CSpecific
- case node: CTCudaVec[G] => CSpecific
- case node: CTranslationUnit[G] => CSpecific
- case node: CTypedef[G] => CSpecific
- case node: CTypedefName[G] => CSpecific
- case node: CTypedFunctionDeclarator[G] => CSpecific
- case node: CTypeQualifierDeclarationSpecifier[G] => CSpecific
- case node: CUDAKernel[G] => CSpecific
- case node: CUnsigned[G] => CSpecific
- case node: CVoid[G] => CSpecific
- case node: CVolatile[G] => CSpecific
- case node: GlobalThreadId[G] => CSpecific
- case node: GpgpuAtomic[G] => CSpecific
- case node: GpgpuBarrier[G] => CSpecific
- case node: GpgpuCudaKernelInvocation[G] => CSpecific
- case node: GPUGlobal[G] => CSpecific
- case node: GpuGlobalMemoryFence[G] => CSpecific
- case node: GPULocal[G] => CSpecific
- case node: GpuLocalMemoryFence[G] => CSpecific
- case node: GpuZeroMemoryFence[G] => CSpecific
- case node: LocalThreadId[G] => CSpecific
- case node: OpenCLKernel[G] => CSpecific
- case node: SharedMemSize[G] => CSpecific
-
- case node: CPPAddressingDeclarator[G] => CPPSpecific
- case node: CPPArrayDeclarator[G] => CPPSpecific
- case node: CPPBool[G] => CPPSpecific
- case node: CPPClassMethodOrFieldAccess[G] => CPPSpecific
- case node: CPPDeclaration[G] => CPPSpecific
- case node: CPPExprOrTypeSpecifier[G] => CPPSpecific
- case node: CPPFunctionDefinition[G] => CPPSpecific
- case node: CPPGlobalDeclaration[G] => CPPSpecific
- case node: CPPInit[G] => CPPSpecific
- case node: CPPInline[G] => CPPSpecific
- case node: CPPInt[G] => CPPSpecific
- case node: CPPInvocation[G] => CPPSpecific
- case node: CPPLambdaDeclarator[G] => CPPSpecific
- case node: CPPLambdaDefinition[G] => CPPSpecific
- case node: CPPLambdaRef[G] => CPPSpecific
- case node: CPPLifetimeScope[G] => CPPSpecific
- case node: CPPLocalDeclaration[G] => CPPSpecific
- case node: CPPLocal[G] => CPPSpecific
- case node: CPPLong[G] => CPPSpecific
- case node: CPPName[G] => CPPSpecific
- case node: CPPParam[G] => CPPSpecific
- case node: CPPPrimitiveType[G] => CPPSpecific
- case node: CPPPure[G] => CPPSpecific
- case node: CPPShort[G] => CPPSpecific
- case node: CPPSigned[G] => CPPSpecific
- case node: CPPSpecificationType[G] => CPPSpecific
- case node: CPPTArray[G] => CPPSpecific
- case node: CPPTLambda[G] => CPPSpecific
- case node: CPPTranslationUnit[G] => CPPSpecific
- case node: CPPTypedefName[G] => CPPSpecific
- case node: CPPTypedFunctionDeclarator[G] => CPPSpecific
- case node: CPPUnsigned[G] => CPPSpecific
- case node: CPPVoid[G] => CPPSpecific
-
- case node: SYCLClassDefName[G] => CPPSpecific
- case node: SYCLNDRange[G] => CPPSpecific
- case node: SYCLRange[G] => CPPSpecific
- case node: SYCLReadOnlyAccess[G] => CPPSpecific
- case node: SYCLReadWriteAccess[G] => CPPSpecific
- case node: SYCLTAccessMode[G] => CPPSpecific
- case node: SYCLTAccessor[G] => CPPSpecific
- case node: SYCLTBuffer[G] => CPPSpecific
- case node: SYCLTEvent[G] => CPPSpecific
- case node: SYCLTHandler[G] => CPPSpecific
- case node: SYCLTItem[G] => CPPSpecific
- case node: SYCLTLocalAccessor[G] => CPPSpecific
- case node: SYCLTNDItem[G] => CPPSpecific
- case node: SYCLTNDRange[G] => CPPSpecific
- case node: SYCLTQueue[G] => CPPSpecific
- case node: SYCLTRange[G] => CPPSpecific
-
- case node: CurrentThreadId[G] => CurrentThread
-
- case node: UntypedLiteralSeq[G] => DynamicallyTypedCollection
- case node: UntypedLiteralSet[G] => DynamicallyTypedCollection
- case node: UntypedLiteralBag[G] => DynamicallyTypedCollection
-
- case node: Eval[G] => Evaluation
-
- case node: Break[G] => ExceptionalLoopControl
- case node: Continue[G] => ExceptionalLoopControl
-
- case node: Throw[G] => Exceptions
- case node: SignalsClause[G] => Exceptions
-
- case node: TAny[G] => ExoticTypes
- case node: TAnyValue[G] => ExoticTypes
- case node: TNothing[G] => ExoticTypes
- case node: TUnion[G] => ExoticTypes
- case node: TBoundedInt[G] => ExoticTypes
- case node: TNotAValue[G] => ExoticTypes
-
- case node: Exp[G] => Exponents
-
- case node: PreAssignExpression[G] => ExpressionWithSideEffects
- case node: PostAssignExpression[G] => ExpressionWithSideEffects
- case node: With[G] => ExpressionWithSideEffects
- case node: Then[G] => ExpressionWithSideEffects
- case node: ScopedExpr[G] => ExpressionWithSideEffects
-
- case node: CastFloat[G] => Floats
- case node: FloatValue[G] => Floats
- case node: FloatType[G] => Floats
-
- case node: Final[G] => FinalField
-
- case node: Goto[G] => Gotos
- case node: LabelDecl[G] => Gotos
-
- case node: InlinePattern[G] => InlineQuantifierPattern
-
- case node: Held[G] => IntrinsicLocks
- case node: Synchronized[G] => IntrinsicLocks
- case node: Lock[G] => IntrinsicLocks
- case node: Unlock[G] => IntrinsicLocks
- case node: Commit[G] => IntrinsicLocks
- case node: Committed[G] => IntrinsicLocks
-
- case node: JavaAbstract[G] => JavaSpecific
- case node: JavaAnnotation[G] => JavaSpecific
- case node: JavaAnnotationInterface[G] => JavaSpecific
- case node: JavaAnnotationMethod[G] => JavaSpecific
- case node: JavaClass[G] => JavaSpecific
- case node: JavaConstructor[G] => JavaSpecific
- case node: JavaDeref[G] => JavaSpecific
- case node: JavaFields[G] => JavaSpecific
- case node: JavaFinal[G] => JavaSpecific
- case node: JavaImport[G] => JavaSpecific
- case node: JavaInline[G] => JavaSpecific
- case node: JavaInterface[G] => JavaSpecific
- case node: JavaInvocation[G] => JavaSpecific
- case node: JavaLiteralArray[G] => JavaSpecific
- case node: JavaLocal[G] => JavaSpecific
- case node: JavaLocalDeclaration[G] => JavaSpecific
- case node: JavaLocalDeclarationStatement[G] => JavaSpecific
- case node: JavaMethod[G] => JavaSpecific
- case node: JavaName[G] => JavaSpecific
- case node: JavaNamedType[G] => JavaSpecific
- case node: JavaNamespace[G] => JavaSpecific
- case node: JavaNative[G] => JavaSpecific
- case node: JavaNewClass[G] => JavaSpecific
- case node: JavaNewDefaultArray[G] => JavaSpecific
- case node: JavaNewLiteralArray[G] => JavaSpecific
- case node: JavaPrivate[G] => JavaSpecific
- case node: JavaProtected[G] => JavaSpecific
- case node: JavaPublic[G] => JavaSpecific
- case node: JavaPure[G] => JavaSpecific
- case node: JavaSharedInitialization[G] => JavaSpecific
- case node: JavaStatic[G] => JavaSpecific
- case node: JavaStrictFP[G] => JavaSpecific
- case node: JavaSynchronized[G] => JavaSpecific
- case node: JavaTClass[G] => JavaSpecific
- case node: JavaTransient[G] => JavaSpecific
- case node: JavaVariableDeclaration[G] => JavaSpecific
- case node: JavaVolatile[G] => JavaSpecific
-
- case node: IdleToken[G] => JavaThreads
- case node: JoinToken[G] => JavaThreads
- case node: RunMethod[G] => JavaThreads
- case node: Fork[G] => JavaThreads
- case node: Join[G] => JavaThreads
-
- case node: IterationContract[G] => LoopIterationContract
-
- case node: Wand[G] => MagicWand
- case node: WandPackage[G] => MagicWand
- case node: WandApply[G] => MagicWand
-
- case node: VectorSum[G] => MatrixVector
- case node: VectorCompare[G] => MatrixVector
- case node: VectorRepeat[G] => MatrixVector
- case node: MatrixSum[G] => MatrixVector
- case node: MatrixCompare[G] => MatrixVector
- case node: MatrixRepeat[G] => MatrixVector
- case node: TMatrix[G] => MatrixVector
-
- case node: InvokeProcedure[G] => Methods
- case node: MethodInvocation[G] => Methods
- case node: ProcedureInvocation[G] => Methods
-
- case node: ModelDeref[G] => Models
- case node: ModelLocation[G] => Models
- case node: EmptyProcess[G] => Models
- case node: ActionApply[G] => Models
- case node: ProcessApply[G] => Models
- case node: ProcessSeq[G] => Models
- case node: ProcessChoice[G] => Models
- case node: ProcessPar[G] => Models
- case node: ProcessSelect[G] => Models
- case node: ModelNew[G] => Models
- case node: ModelState[G] => Models
- case node: ModelAbstractState[G] => Models
- case node: ModelCreate[G] => Models
- case node: ModelDestroy[G] => Models
- case node: ModelSplit[G] => Models
- case node: ModelMerge[G] => Models
- case node: ModelChoose[G] => Models
- case node: ModelPerm[G] => Models
- case node: ActionPerm[G] => Models
- case node: ModelDo[G] => Models
- case node: TProcess[G] => Models
- case node: TModel[G] => Models
- case node: ModelField[G] => Models
- case node: ModelProcess[G] => Models
- case node: ModelAction[G] => Models
- case node: Model[G] => Models
- case node: ThisModel[G] => Models
-
- case node: IndetBranch[G] => NonTrivialBranch
-
- case node: Sum[G] => NumericReductionOperator
- case node: Product[G] => NumericReductionOperator
-
- case node: ParInvariant[G] => ParallelRegion
- case node: ParAtomic[G] => ParallelRegion
- case node: ParBarrier[G] => ParallelRegion
- case node: ParBlock[G] => ParallelRegion
- case node: ScaleByParBlock[G] => ParallelRegion
- case node: ParParallel[G] => ParallelRegion
- case node: ParRegion[G] => ParallelRegion
- case node: VecBlock[G] => ParallelRegion
- case node: ParStatement[G] => ParallelRegion
- case node: ParBlockDecl[G] => ParallelRegion
- case node: ParInvariantDecl[G] => ParallelRegion
- case node: IterVariable[G] => ParallelRegion
-
- case node: Permutation[G] => PermutationOperator
-
- case node: DerefPointer[G] => Pointers
- case node: AddrOf[G] => Pointers
- case node: PointerLocation[G] => Pointers
- case node: PointerAdd[G] => Pointers
- case node: PointerSubscript[G] => Pointers
- case node: PointerBlockLength[G] => Pointers
- case node: PointerBlockOffset[G] => Pointers
- case node: PointerLength[G] => Pointers
- case node: TPointer[G] => Pointers
-
- case node: Extract[G] => ProofHelpers
- case node: FramedProof[G] => ProofHelpers
- case node: Refute[G] => ProofHelpers
-
- case node: PVLConstructor[G] => PvlSpecific
- case node: PVLDeref[G] => PvlSpecific
- case node: PVLInvocation[G] => PvlSpecific
- case node: PVLLocal[G] => PvlSpecific
- case node: PVLNamedType[G] => PvlSpecific
- case node: PVLNew[G] => PvlSpecific
-
- case node: CurPerm[G] => Resources
- case node: Exhale[G] => Resources
- case node: Fold[G] => Resources
- case node: Inhale[G] => Resources
- case node: Null[G] => Resources
- case node: Old[G] => Resources
- case node: Perm[G] => Resources
- case node: PredicateApply[G] => Resources
- case node: PredicateLocation[G] => Resources
- case node: SilverDeref[G] => Resources
- case node: SilverField[G] => Resources
- case node: SilverFieldAssign[G] => Resources
- case node: SilverFieldLocation[G] => Resources
- case node: SilverNull[G] => Resources
- case node: Star[G] => Resources
- case node: Starall[G] => Resources
- case node: TRef[G] => Resources
- case node: TResource[G] => Resources
- case node: Unfold[G] => Resources
- case node: Unfolding[G] => Resources
- case node: Value[G] => Resources
-
- case node: Program[G] => RootStructure
- case node: Verification[G] => RootStructure
- case node: VerificationContext[G] => RootStructure
-
- case node: Send[G] => SendRecv
- case node: Recv[G] => SendRecv
- case node: SendDecl[G] => SendRecv
-
- case node: Range[G] => SequenceRange
-
- case node: BagAdd[G] => SilverAxiomaticLibraryType
- case node: BagLargestCommon[G] => SilverAxiomaticLibraryType
- case node: BagMemberCount[G] => SilverAxiomaticLibraryType
- case node: BagMinus[G] => SilverAxiomaticLibraryType
- case node: Concat[G] => SilverAxiomaticLibraryType
- case node: Drop[G] => SilverAxiomaticLibraryType
- case node: LiteralBag[G] => SilverAxiomaticLibraryType
- case node: LiteralSeq[G] => SilverAxiomaticLibraryType
- case node: LiteralSet[G] => SilverAxiomaticLibraryType
- case node: SeqMember[G] => SilverAxiomaticLibraryType
- case node: SeqSubscript[G] => SilverAxiomaticLibraryType
- case node: VectorSubscript[G] => SilverAxiomaticLibraryType
- case node: SeqUpdate[G] => SilverAxiomaticLibraryType
- case node: SetIntersection[G] => SilverAxiomaticLibraryType
- case node: SetMember[G] => SilverAxiomaticLibraryType
- case node: SetMinus[G] => SilverAxiomaticLibraryType
- case node: SetUnion[G] => SilverAxiomaticLibraryType
- case node: SilverBagSize[G] => SilverAxiomaticLibraryType
- case node: SilverMapSize[G] => SilverAxiomaticLibraryType
- case node: SilverSeqSize[G] => SilverAxiomaticLibraryType
- case node: SilverSetSize[G] => SilverAxiomaticLibraryType
- case node: Size[G] => SilverAxiomaticLibraryType
- case node: SubBag[G] => SilverAxiomaticLibraryType
- case node: SubSet[G] => SilverAxiomaticLibraryType
- case node: Take[G] => SilverAxiomaticLibraryType
- case node: TBag[G] => SilverAxiomaticLibraryType
- case node: TSeq[G] => SilverAxiomaticLibraryType
- case node: TSet[G] => SilverAxiomaticLibraryType
- case node: TVector[G] => SilverAxiomaticLibraryType
-
- case node: SilverCurFieldPerm[G] => SilverSpecific
- case node: SilverCurPredPerm[G] => SilverSpecific
- case node: SilverPartialADTFunctionInvocation[G] => SilverSpecific
- case node: SilverPartialTAxiomatic[G] => SilverSpecific
- case node: SilverUntypedNonemptyLiteralMap[G] => SilverSpecific
-
- case node: FunctionInvocation[G] => SmtDeclarations
- case node: Variable[G] => SmtDeclarations
-
- case node: And[G] => SmtOperators
- case node: BooleanValue[G] => SmtOperators
- case node: RatDiv[G] => SmtOperators
- case node: Eq[G] => SmtOperators
- case node: Exists[G] => SmtOperators
- case node: FloorDiv[G] => SmtOperators
- case node: FloatDiv[G] => SmtOperators
- case node: Forall[G] => SmtOperators
- case node: Greater[G] => SmtOperators
- case node: GreaterEq[G] => SmtOperators
- case node: Implies[G] => SmtOperators
- case node: IntegerValue[G] => SmtOperators
- case node: Less[G] => SmtOperators
- case node: LessEq[G] => SmtOperators
- case node: Let[G] => SmtOperators
- case node: Local[G] => SmtOperators
- case node: Minus[G] => SmtOperators
- case node: Mod[G] => SmtOperators
- case node: TruncMod[G] => SmtOperators
- case node: TruncDiv[G] => SmtOperators
- case node: Mult[G] => SmtOperators
- case node: Neq[G] => SmtOperators
- case node: NoPerm[G] => SmtOperators
- case node: Not[G] => SmtOperators
- case node: Or[G] => SmtOperators
- case node: Plus[G] => SmtOperators
- case node: Select[G] => SmtOperators
- case node: SilverIntToRat[G] => SmtOperators
- case node: UMinus[G] => SmtOperators
- case node: WritePerm[G] => SmtOperators
-
- case node: TBool[G] => SmtTypes
- case node: TInt[G] => SmtTypes
- case node: TRational[G] => SmtTypes
-
- case node: SpecIgnoreStart[G] => SpecIgnore
- case node: SpecIgnoreEnd[G] => SpecIgnore
-
- case node: Any[G] => StarSubscript
-
- case node: Cons[G] => SugarCollectionOperator
- case node: Head[G] => SugarCollectionOperator
- case node: Tail[G] => SugarCollectionOperator
- case node: Slice[G] => SugarCollectionOperator
- case node: RemoveAt[G] => SugarCollectionOperator
- case node: Empty[G] => SugarCollectionOperator
- case node: SubSetEq[G] => SugarCollectionOperator
- case node: SubBagEq[G] => SugarCollectionOperator
-
- case node: PointsTo[G] => SugarPermissionOperator
- case node: Scale[G] => SugarPermissionOperator
-
- case node: Switch[G] => SwitchStatement
- case node: DefaultCase[G] => SwitchStatement
- case node: Case[G] => SwitchStatement
-
- case node: DecreasesClauseAssume[G] => TerminationMeasure
- case node: DecreasesClauseNoRecursion[G] => TerminationMeasure
- case node: DecreasesClauseTuple[G] => TerminationMeasure
-
- case node: SimplificationRule[G] => TermRewriteRules
- case node: FunctionOf[G] => TermRewriteRules
-
- case node: TChar[G] => TextTypes
- case node: TString[G] => TextTypes
-
- case node: TryCatchFinally[G] => TryCatchStatement
- case node: CatchClause[G] => TryCatchStatement
-
- case node: TypeValue[G] => TypeValuesAndGenerics
- case node: TypeOf[G] => TypeValuesAndGenerics
- case node: InstanceOf[G] => TypeValuesAndGenerics
- case node: Cast[G] => TypeValuesAndGenerics
- case node: SubType[G] => TypeValuesAndGenerics
- case node: SuperType[G] => TypeValuesAndGenerics
- case node: TType[G] => TypeValuesAndGenerics
- case node: TVar[G] => TypeValuesAndGenerics
-
- case node: LocalDecl[G] => UnscopedDeclaration
-
- case node: Wait[G] => WaitNotify
- case node: Notify[G] => WaitNotify
-
- case node: ReadPerm[G] => WildcardReadPermission
-
- case node: AmbiguousComputationalAnd[G] =>
- return AmbiguousOperators +: (
- if(node.isBoolOp) Seq(ComputationalLogicOperator)
- else Seq(BitOperators)
- )
- case node: AmbiguousComputationalOr[G] =>
- return AmbiguousOperators +: (
- if (node.isBoolOp) Seq(ComputationalLogicOperator)
- else Seq(BitOperators)
- )
- case node: AmbiguousComputationalXor[G] =>
- return AmbiguousOperators +: (
- if (node.isBoolOp) Seq(ComputationalLogicOperator)
- else Seq(BitOperators)
- )
- case node: AmbiguousMult[G] =>
- return AmbiguousOperators +: (
- if(node.isProcessOp) Seq(Models)
- else Seq(SmtOperators)
- )
- case node: AmbiguousPlus[G] =>
- return AmbiguousOperators +: (
- if(node.isProcessOp) Seq(Models)
- else if(node.isPointerOp) Seq(Pointers)
- else Seq(SmtOperators)
- )
- case node: AmbiguousMinus[G] => AmbiguousOperators
- case node: AmbiguousOr[G] =>
- return AmbiguousOperators +: (
- if(node.isProcessOp) Seq(Models)
- else Seq(SmtOperators)
- )
- case node: AmbiguousSubscript[G] =>
- return AmbiguousOperators +: (
- if (node.isPointerOp) Seq(Pointers)
- else if (node.isMapOp) Seq(AxiomaticLibraryType)
- else if (node.isArrayOp) Seq(Arrays)
- else Seq(SilverAxiomaticLibraryType)
- )
- case node: AmbiguousMember[G] =>
- return AmbiguousOperators +: (
- if (node.isMapOp) Seq(AxiomaticLibraryType)
- else Seq(SilverAxiomaticLibraryType)
- )
-
- case node: Return[G] =>
- returnValues :+= node.result
- if (node.result == Void[G]()(DiagnosticOrigin)) return Seq(Methods)
- else return Seq(NonVoidReturn, Methods)
- case node: Branch[G] =>
- node.branches match {
- case Seq((_, _), (BooleanValue(true), _)) => BasicStatement
- case _ => NonTrivialBranch
- }
- case node: Loop[G] => node match {
- case Loop(Block(Nil), _, Block(Nil), _, _) => WhileLoops
- case _ => NonWhileLoop
- }
- case node: Function[G] =>
- return Seq(SmtDeclarations) ++
- (if (node.inline) Seq(ApplicableToBeInlined) else Nil) ++
- (if (node.typeArgs.nonEmpty) Seq(TypeValuesAndGenerics) else Nil)
- case node: Procedure[G] =>
- returnTypes :+= node.returnType
- return Seq(Methods) ++
- (if (node.inline) Seq(ApplicableToBeInlined) else Nil) ++
- (if (node.typeArgs.nonEmpty) Seq(TypeValuesAndGenerics) else Nil) ++
- (if (node.pure) Seq(MethodToBePurified) else Nil)
- case node: Predicate[G] =>
- return Seq(Resources) ++
- (if (node.inline) Seq(ApplicableToBeInlined) else Nil)
- case node: InstanceFunction[G] =>
- return Seq(Classes) ++
- (if (node.typeArgs.nonEmpty) Seq(TypeValuesAndGenerics) else Nil) ++
- (if (node.inline) Seq(ApplicableToBeInlined) else Nil)
- case node: InstanceMethod[G] =>
- returnTypes :+= node.returnType
- return Seq(Classes, Methods) ++
- (if (node.typeArgs.nonEmpty) Seq(TypeValuesAndGenerics) else Nil) ++
- (if (node.inline) Seq(ApplicableToBeInlined) else Nil) ++
- (if (node.pure) Seq(MethodToBePurified) else Nil)
- case node: InstancePredicate[G] =>
- return Seq(Classes) ++
- (if (node.inline) Seq(ApplicableToBeInlined) else Nil)
- case node: Label[G] => node.stat match {
- case Block(Nil) => Gotos
- case _ => return Seq(NonTrivialLabel, Gotos)
- }
- case node: TVoid[G] =>
- if (returnTypes.exists(_ eq node)) return Nil
- else AxiomaticLibraryType
- case node: Void[G] =>
- if (returnValues.exists(_ eq node)) return Nil
- else AxiomaticLibraryType
-
- case node: ValidArray[G] => return Seq(SugarPermissionOperator, Arrays)
- case node: ValidMatrix[G] => return Seq(SugarPermissionOperator, Arrays)
- case node: PermPointer[G] => return Seq(SugarPermissionOperator, Pointers)
- case node: PermPointerIndex[G] => return Seq(SugarPermissionOperator, Pointers)
- case node: CLiteralArray[G] => return Seq(CSpecific, Arrays)
- case node: CCast[G] => return Seq(CSpecific, TypeValuesAndGenerics)
- case node: CChar[G] => return Seq(CSpecific, TextTypes)
- case node: CDeclarationStatement[G] => return Seq(CSpecific, UnscopedDeclaration)
- case node: CGoto[G] => return Seq(CSpecific, Gotos)
- case node: CPointer[G] => return Seq(CSpecific, Pointers)
- case node: CPointerDeclarator[G] => return Seq(CSpecific, Pointers)
- case node: CPPLiteralArray[G] => return Seq(CPPSpecific, Arrays)
- case node: CPPChar[G] => return Seq(CPPSpecific, TextTypes)
- case node: CPPDeclarationStatement[G] => return Seq(CPPSpecific, UnscopedDeclaration)
- case node: CPPPointer[G] => return Seq(CPPSpecific, Pointers)
- case node: CPPReference[G] => return Seq(CPPSpecific, Pointers)
- case node: Result[G] => return scanFlatly(node.applicable.decl)
- case node: SilverNewRef[G] => return Seq(Assignment, Resources)
-
- case _ => return Nil
- })
+ node.transSubnodes.foreach(node =>
+ scanFlatly(node).foreach(f => {
+ features += f
+ examples.getOrElseUpdate(f, ArrayBuffer()) += node
+ })
+ )
+
+ def scanFlatly(node: Node[G]): Seq[Feature] =
+ Seq(node match {
+ case node: AmbiguousLocation[G] => AmbiguousOperators
+ case node: AmbiguousGreater[G] => AmbiguousOperators
+ case node: AmbiguousLess[G] => AmbiguousOperators
+ case node: AmbiguousGreaterEq[G] => AmbiguousOperators
+ case node: AmbiguousLessEq[G] => AmbiguousOperators
+
+ case node: ArrayLocation[G] => Arrays
+ case node: NewArray[G] => Arrays
+ case node: NewPointerArray[G] => Arrays
+ case node: ArraySubscript[G] => Arrays
+ case node: Length[G] => Arrays
+ case node: TArray[G] => Arrays
+
+ case node: Assign[G] => Assignment
+ case node: Havoc[G] => Assignment
+ case node: SilverLocalAssign[G] => Assignment
+
+ case node: ADTAxiom[G] => AxiomaticDataTypes
+ case node: ADTFunction[G] => AxiomaticDataTypes
+ case node: ADTFunctionInvocation[G] => AxiomaticDataTypes
+ case node: AxiomaticDataType[G] => AxiomaticDataTypes
+ case node: TAxiomatic[G] => AxiomaticDataTypes
+
+ case node: LiteralTuple[G] => AxiomaticLibraryType
+ case node: LiteralMap[G] => AxiomaticLibraryType
+ case node: OptSome[G] => AxiomaticLibraryType
+ case node: OptNone[G] => AxiomaticLibraryType
+ case node: EitherLeft[G] => AxiomaticLibraryType
+ case node: EitherRight[G] => AxiomaticLibraryType
+ case node: MapCons[G] => AxiomaticLibraryType
+ case node: MapEq[G] => AxiomaticLibraryType
+ case node: MapDisjoint[G] => AxiomaticLibraryType
+ case node: MapKeySet[G] => AxiomaticLibraryType
+ case node: MapValueSet[G] => AxiomaticLibraryType
+ case node: MapItemSet[G] => AxiomaticLibraryType
+ case node: MapRemove[G] => AxiomaticLibraryType
+ case node: MapMember[G] => AxiomaticLibraryType
+ case node: OptGet[G] => AxiomaticLibraryType
+ case node: OptGetOrElse[G] => AxiomaticLibraryType
+ case node: GetLeft[G] => AxiomaticLibraryType
+ case node: GetRight[G] => AxiomaticLibraryType
+ case node: IsLeft[G] => AxiomaticLibraryType
+ case node: IsRight[G] => AxiomaticLibraryType
+ case node: MapGet[G] => AxiomaticLibraryType
+ case node: TupGet[G] => AxiomaticLibraryType
+ case node: TFraction[G] => AxiomaticLibraryType
+ case node: TZFraction[G] => AxiomaticLibraryType
+ case node: TOption[G] => AxiomaticLibraryType
+ case node: TEither[G] => AxiomaticLibraryType
+ case node: TTuple[G] => AxiomaticLibraryType
+ case node: TMap[G] => AxiomaticLibraryType
+ case node: OptEmpty[G] => AxiomaticLibraryType
+ case node: OptNoneTyped[G] => AxiomaticLibraryType
+ case node: OptSomeTyped[G] => AxiomaticLibraryType
+ case node: TNull[G] => AxiomaticLibraryType
+
+ case node: Assert[G] => BasicStatement
+ case node: Assume[G] => BasicStatement
+ case node: Block[G] => BasicStatement
+ case node: Scope[G] => BasicStatement
+
+ case node: BitNot[G] => BitOperators
+ case node: BitAnd[G] => BitOperators
+ case node: BitOr[G] => BitOperators
+ case node: BitXor[G] => BitOperators
+ case node: BitShl[G] => BitOperators
+ case node: BitShr[G] => BitOperators
+ case node: BitUShr[G] => BitOperators
+
+ case node: Values[G] => BuiltinArrayOperators
+
+ case node: Deref[G] => Classes
+ case node: InstancePredicateApply[G] => Classes
+ case node: CoalesceInstancePredicateApply[G] => Classes
+ case node: InstanceFunctionInvocation[G] => Classes
+ case node: InstancePredicateLocation[G] => Classes
+ case node: NewObject[G] => Classes
+ case node: TClass[G] => Classes
+ case node: Class[G] => Classes
+ case node: FieldLocation[G] => Classes
+ case node: InvokeMethod[G] => Classes
+ case node: TAnyClass[G] => Classes
+ case node: ThisObject[G] => Classes
+ case node: InstanceField[G] => Classes
+
+ case node: ApplyCoercion[G] => Coercions
+ case node: CoerceBoolResource[G] => Coercions
+ case node: CoerceBoundIntFrac[G] => Coercions
+ case node: CoerceBoundIntZFrac[G] => Coercions
+ case node: CoerceClassAnyClass[G] => Coercions
+ case node: CoerceColToCPrimitive[G] => Coercions
+ case node: CoerceCPrimitiveToCol[G] => Coercions
+ case node: CoerceColToCPPPrimitive[G] => Coercions
+ case node: CoerceCPPPrimitiveToCol[G] => Coercions
+ case node: CoerceFloatRat[G] => Coercions
+ case node: CoerceFracZFrac[G] => Coercions
+ case node: CoerceIdentity[G] => Coercions
+ case node: CoerceIncreasePrecision[G] => Coercions
+ case node: CoerceIntRat[G] => Coercions
+ case node: CoerceJavaClassAnyClass[G] => Coercions
+ case node: CoerceJavaSupports[G] => Coercions
+ case node: CoerceJoinUnion[G] => Coercions
+ case node: CoerceMapBag[G] => Coercions
+ case node: CoerceMapEither[G] => Coercions
+ case node: CoerceMapMap[G] => Coercions
+ case node: CoerceMapMatrix[G] => Coercions
+ case node: CoerceMapOption[G] => Coercions
+ case node: CoerceMapSeq[G] => Coercions
+ case node: CoerceMapSet[G] => Coercions
+ case node: CoerceMapTuple[G] => Coercions
+ case node: CoerceMapType[G] => Coercions
+ case node: CoerceMapVector[G] => Coercions
+ case node: CoerceNothingSomething[G] => Coercions
+ case node: CoerceNullAnyClass[G] => Coercions
+ case node: CoerceNullArray[G] => Coercions
+ case node: CoerceNullClass[G] => Coercions
+ case node: CoerceNullJavaClass[G] => Coercions
+ case node: CoerceNullPointer[G] => Coercions
+ case node: CoerceNullRef[G] => Coercions
+ case node: CoerceRatZFrac[G] => Coercions
+ case node: CoerceSelectUnion[G] => Coercions
+ case node: CoerceSomethingAnyValue[G] => Coercions
+ case node: CoerceSupports[G] => Coercions
+ case node: CoerceUnboundInt[G] => Coercions
+ case node: CoerceWidenBound[G] => Coercions
+ case node: CoerceZFracFrac[G] => Coercions
+ case node: CoerceZFracRat[G] => Coercions
+ case node: CoercionSequence[G] => Coercions
+
+ case node: ComputationalOr[G] => ComputationalLogicOperator
+ case node: ComputationalXor[G] => ComputationalLogicOperator
+ case node: ComputationalAnd[G] => ComputationalLogicOperator
+
+ case node: AmbiguousThis[G] => ContextSensitiveNode
+ case node: AmbiguousResult[G] => ContextSensitiveNode
+
+ case node: ApplicableContract[G] => Contracts
+ case node: LoopInvariant[G] => Contracts
+ case node: SplitAccountedPredicate[G] => Contracts
+ case node: UnitAccountedPredicate[G] => Contracts
+
+ case node: CAnonymousFunctionDeclarator[G] => CSpecific
+ case node: CArrayDeclarator[G] => CSpecific
+ case node: CAtomic[G] => CSpecific
+ case node: CBool[G] => CSpecific
+ case node: CConst[G] => CSpecific
+ case node: CDeclaration[G] => CSpecific
+ case node: CDouble[G] => CSpecific
+ case node: CExtern[G] => CSpecific
+ case node: CFloat[G] => CSpecific
+ case node: CFunctionDefinition[G] => CSpecific
+ case node: CGlobalDeclaration[G] => CSpecific
+ case node: CInit[G] => CSpecific
+ case node: CInline[G] => CSpecific
+ case node: CInt[G] => CSpecific
+ case node: CInvocation[G] => CSpecific
+ case node: CLocal[G] => CSpecific
+ case node: CLocalDeclaration[G] => CSpecific
+ case node: CLong[G] => CSpecific
+ case node: CName[G] => CSpecific
+ case node: CParam[G] => CSpecific
+ case node: CPrimitiveType[G] => CSpecific
+ case node: CPure[G] => CSpecific
+ case node: CRestrict[G] => CSpecific
+ case node: CShort[G] => CSpecific
+ case node: CSigned[G] => CSpecific
+ case node: CSpecificationType[G] => CSpecific
+ case node: CStatic[G] => CSpecific
+ case node: CFieldAccess[G] => CSpecific
+ case node: CStructDeref[G] => CSpecific
+ case node: CTCudaVec[G] => CSpecific
+ case node: CTranslationUnit[G] => CSpecific
+ case node: CTypedef[G] => CSpecific
+ case node: CTypedefName[G] => CSpecific
+ case node: CTypedFunctionDeclarator[G] => CSpecific
+ case node: CTypeQualifierDeclarationSpecifier[G] => CSpecific
+ case node: CUDAKernel[G] => CSpecific
+ case node: CUnsigned[G] => CSpecific
+ case node: CVoid[G] => CSpecific
+ case node: CVolatile[G] => CSpecific
+ case node: GlobalThreadId[G] => CSpecific
+ case node: GpgpuAtomic[G] => CSpecific
+ case node: GpgpuBarrier[G] => CSpecific
+ case node: GpgpuCudaKernelInvocation[G] => CSpecific
+ case node: GPUGlobal[G] => CSpecific
+ case node: GpuGlobalMemoryFence[G] => CSpecific
+ case node: GPULocal[G] => CSpecific
+ case node: GpuLocalMemoryFence[G] => CSpecific
+ case node: GpuZeroMemoryFence[G] => CSpecific
+ case node: LocalThreadId[G] => CSpecific
+ case node: OpenCLKernel[G] => CSpecific
+ case node: SharedMemSize[G] => CSpecific
+
+ case node: CPPAddressingDeclarator[G] => CPPSpecific
+ case node: CPPArrayDeclarator[G] => CPPSpecific
+ case node: CPPBool[G] => CPPSpecific
+ case node: CPPClassMethodOrFieldAccess[G] => CPPSpecific
+ case node: CPPDeclaration[G] => CPPSpecific
+ case node: CPPExprOrTypeSpecifier[G] => CPPSpecific
+ case node: CPPFunctionDefinition[G] => CPPSpecific
+ case node: CPPGlobalDeclaration[G] => CPPSpecific
+ case node: CPPInit[G] => CPPSpecific
+ case node: CPPInline[G] => CPPSpecific
+ case node: CPPInt[G] => CPPSpecific
+ case node: CPPInvocation[G] => CPPSpecific
+ case node: CPPLambdaDeclarator[G] => CPPSpecific
+ case node: CPPLambdaDefinition[G] => CPPSpecific
+ case node: CPPLambdaRef[G] => CPPSpecific
+ case node: CPPLifetimeScope[G] => CPPSpecific
+ case node: CPPLocalDeclaration[G] => CPPSpecific
+ case node: CPPLocal[G] => CPPSpecific
+ case node: CPPLong[G] => CPPSpecific
+ case node: CPPName[G] => CPPSpecific
+ case node: CPPParam[G] => CPPSpecific
+ case node: CPPPrimitiveType[G] => CPPSpecific
+ case node: CPPPure[G] => CPPSpecific
+ case node: CPPShort[G] => CPPSpecific
+ case node: CPPSigned[G] => CPPSpecific
+ case node: CPPSpecificationType[G] => CPPSpecific
+ case node: CPPTArray[G] => CPPSpecific
+ case node: CPPTLambda[G] => CPPSpecific
+ case node: CPPTranslationUnit[G] => CPPSpecific
+ case node: CPPTypedefName[G] => CPPSpecific
+ case node: CPPTypedFunctionDeclarator[G] => CPPSpecific
+ case node: CPPUnsigned[G] => CPPSpecific
+ case node: CPPVoid[G] => CPPSpecific
+
+ case node: SYCLClassDefName[G] => CPPSpecific
+ case node: SYCLNDRange[G] => CPPSpecific
+ case node: SYCLRange[G] => CPPSpecific
+ case node: SYCLReadOnlyAccess[G] => CPPSpecific
+ case node: SYCLReadWriteAccess[G] => CPPSpecific
+ case node: SYCLTAccessMode[G] => CPPSpecific
+ case node: SYCLTAccessor[G] => CPPSpecific
+ case node: SYCLTBuffer[G] => CPPSpecific
+ case node: SYCLTEvent[G] => CPPSpecific
+ case node: SYCLTHandler[G] => CPPSpecific
+ case node: SYCLTItem[G] => CPPSpecific
+ case node: SYCLTLocalAccessor[G] => CPPSpecific
+ case node: SYCLTNDItem[G] => CPPSpecific
+ case node: SYCLTNDRange[G] => CPPSpecific
+ case node: SYCLTQueue[G] => CPPSpecific
+ case node: SYCLTRange[G] => CPPSpecific
+
+ case node: CurrentThreadId[G] => CurrentThread
+
+ case node: UntypedLiteralSeq[G] => DynamicallyTypedCollection
+ case node: UntypedLiteralSet[G] => DynamicallyTypedCollection
+ case node: UntypedLiteralBag[G] => DynamicallyTypedCollection
+
+ case node: Eval[G] => Evaluation
+
+ case node: Break[G] => ExceptionalLoopControl
+ case node: Continue[G] => ExceptionalLoopControl
+
+ case node: Throw[G] => Exceptions
+ case node: SignalsClause[G] => Exceptions
+
+ case node: TAny[G] => ExoticTypes
+ case node: TAnyValue[G] => ExoticTypes
+ case node: TNothing[G] => ExoticTypes
+ case node: TUnion[G] => ExoticTypes
+ case node: TBoundedInt[G] => ExoticTypes
+ case node: TNotAValue[G] => ExoticTypes
+
+ case node: Exp[G] => Exponents
+
+ case node: PreAssignExpression[G] => ExpressionWithSideEffects
+ case node: PostAssignExpression[G] => ExpressionWithSideEffects
+ case node: With[G] => ExpressionWithSideEffects
+ case node: Then[G] => ExpressionWithSideEffects
+ case node: ScopedExpr[G] => ExpressionWithSideEffects
+
+ case node: CastFloat[G] => Floats
+ case node: FloatValue[G] => Floats
+ case node: FloatType[G] => Floats
+
+ case node: Final[G] => FinalField
+
+ case node: Goto[G] => Gotos
+ case node: LabelDecl[G] => Gotos
+
+ case node: InlinePattern[G] => InlineQuantifierPattern
+
+ case node: Held[G] => IntrinsicLocks
+ case node: Synchronized[G] => IntrinsicLocks
+ case node: Lock[G] => IntrinsicLocks
+ case node: Unlock[G] => IntrinsicLocks
+ case node: Commit[G] => IntrinsicLocks
+ case node: Committed[G] => IntrinsicLocks
+
+ case node: JavaAbstract[G] => JavaSpecific
+ case node: JavaAnnotation[G] => JavaSpecific
+ case node: JavaAnnotationInterface[G] => JavaSpecific
+ case node: JavaAnnotationMethod[G] => JavaSpecific
+ case node: JavaClass[G] => JavaSpecific
+ case node: JavaConstructor[G] => JavaSpecific
+ case node: JavaDeref[G] => JavaSpecific
+ case node: JavaFields[G] => JavaSpecific
+ case node: JavaFinal[G] => JavaSpecific
+ case node: JavaImport[G] => JavaSpecific
+ case node: JavaInline[G] => JavaSpecific
+ case node: JavaInterface[G] => JavaSpecific
+ case node: JavaInvocation[G] => JavaSpecific
+ case node: JavaLiteralArray[G] => JavaSpecific
+ case node: JavaLocal[G] => JavaSpecific
+ case node: JavaLocalDeclaration[G] => JavaSpecific
+ case node: JavaLocalDeclarationStatement[G] => JavaSpecific
+ case node: JavaMethod[G] => JavaSpecific
+ case node: JavaName[G] => JavaSpecific
+ case node: JavaNamedType[G] => JavaSpecific
+ case node: JavaNamespace[G] => JavaSpecific
+ case node: JavaNative[G] => JavaSpecific
+ case node: JavaNewClass[G] => JavaSpecific
+ case node: JavaNewDefaultArray[G] => JavaSpecific
+ case node: JavaNewLiteralArray[G] => JavaSpecific
+ case node: JavaPrivate[G] => JavaSpecific
+ case node: JavaProtected[G] => JavaSpecific
+ case node: JavaPublic[G] => JavaSpecific
+ case node: JavaPure[G] => JavaSpecific
+ case node: JavaSharedInitialization[G] => JavaSpecific
+ case node: JavaStatic[G] => JavaSpecific
+ case node: JavaStrictFP[G] => JavaSpecific
+ case node: JavaSynchronized[G] => JavaSpecific
+ case node: JavaTClass[G] => JavaSpecific
+ case node: JavaTransient[G] => JavaSpecific
+ case node: JavaVariableDeclaration[G] => JavaSpecific
+ case node: JavaVolatile[G] => JavaSpecific
+
+ case node: IdleToken[G] => JavaThreads
+ case node: JoinToken[G] => JavaThreads
+ case node: RunMethod[G] => JavaThreads
+ case node: Fork[G] => JavaThreads
+ case node: Join[G] => JavaThreads
+
+ case node: IterationContract[G] => LoopIterationContract
+
+ case node: Wand[G] => MagicWand
+ case node: WandPackage[G] => MagicWand
+ case node: WandApply[G] => MagicWand
+
+ case node: VectorSum[G] => MatrixVector
+ case node: VectorCompare[G] => MatrixVector
+ case node: VectorRepeat[G] => MatrixVector
+ case node: MatrixSum[G] => MatrixVector
+ case node: MatrixCompare[G] => MatrixVector
+ case node: MatrixRepeat[G] => MatrixVector
+ case node: TMatrix[G] => MatrixVector
+
+ case node: InvokeProcedure[G] => Methods
+ case node: MethodInvocation[G] => Methods
+ case node: ProcedureInvocation[G] => Methods
+
+ case node: ModelDeref[G] => Models
+ case node: ModelLocation[G] => Models
+ case node: EmptyProcess[G] => Models
+ case node: ActionApply[G] => Models
+ case node: ProcessApply[G] => Models
+ case node: ProcessSeq[G] => Models
+ case node: ProcessChoice[G] => Models
+ case node: ProcessPar[G] => Models
+ case node: ProcessSelect[G] => Models
+ case node: ModelNew[G] => Models
+ case node: ModelState[G] => Models
+ case node: ModelAbstractState[G] => Models
+ case node: ModelCreate[G] => Models
+ case node: ModelDestroy[G] => Models
+ case node: ModelSplit[G] => Models
+ case node: ModelMerge[G] => Models
+ case node: ModelChoose[G] => Models
+ case node: ModelPerm[G] => Models
+ case node: ActionPerm[G] => Models
+ case node: ModelDo[G] => Models
+ case node: TProcess[G] => Models
+ case node: TModel[G] => Models
+ case node: ModelField[G] => Models
+ case node: ModelProcess[G] => Models
+ case node: ModelAction[G] => Models
+ case node: Model[G] => Models
+ case node: ThisModel[G] => Models
+
+ case node: IndetBranch[G] => NonTrivialBranch
+
+ case node: Sum[G] => NumericReductionOperator
+ case node: Product[G] => NumericReductionOperator
+
+ case node: ParInvariant[G] => ParallelRegion
+ case node: ParAtomic[G] => ParallelRegion
+ case node: ParBarrier[G] => ParallelRegion
+ case node: ParBlock[G] => ParallelRegion
+ case node: ScaleByParBlock[G] => ParallelRegion
+ case node: ParParallel[G] => ParallelRegion
+ case node: ParRegion[G] => ParallelRegion
+ case node: VecBlock[G] => ParallelRegion
+ case node: ParStatement[G] => ParallelRegion
+ case node: ParBlockDecl[G] => ParallelRegion
+ case node: ParInvariantDecl[G] => ParallelRegion
+ case node: IterVariable[G] => ParallelRegion
+
+ case node: Permutation[G] => PermutationOperator
+
+ case node: DerefPointer[G] => Pointers
+ case node: AddrOf[G] => Pointers
+ case node: PointerLocation[G] => Pointers
+ case node: PointerAdd[G] => Pointers
+ case node: PointerSubscript[G] => Pointers
+ case node: PointerBlockLength[G] => Pointers
+ case node: PointerBlockOffset[G] => Pointers
+ case node: PointerLength[G] => Pointers
+ case node: TPointer[G] => Pointers
+
+ case node: Extract[G] => ProofHelpers
+ case node: FramedProof[G] => ProofHelpers
+ case node: Refute[G] => ProofHelpers
+
+ case node: PVLConstructor[G] => PvlSpecific
+ case node: PVLDeref[G] => PvlSpecific
+ case node: PVLInvocation[G] => PvlSpecific
+ case node: PVLLocal[G] => PvlSpecific
+ case node: PVLNamedType[G] => PvlSpecific
+ case node: PVLNew[G] => PvlSpecific
+
+ case node: CurPerm[G] => Resources
+ case node: Exhale[G] => Resources
+ case node: Fold[G] => Resources
+ case node: Inhale[G] => Resources
+ case node: Null[G] => Resources
+ case node: Old[G] => Resources
+ case node: Perm[G] => Resources
+ case node: PredicateApply[G] => Resources
+ case node: PredicateLocation[G] => Resources
+ case node: SilverDeref[G] => Resources
+ case node: SilverField[G] => Resources
+ case node: SilverFieldAssign[G] => Resources
+ case node: SilverFieldLocation[G] => Resources
+ case node: SilverNull[G] => Resources
+ case node: Star[G] => Resources
+ case node: Starall[G] => Resources
+ case node: TRef[G] => Resources
+ case node: TResource[G] => Resources
+ case node: Unfold[G] => Resources
+ case node: Unfolding[G] => Resources
+ case node: Value[G] => Resources
+
+ case node: Program[G] => RootStructure
+ case node: Verification[G] => RootStructure
+ case node: VerificationContext[G] => RootStructure
+
+ case node: Send[G] => SendRecv
+ case node: Recv[G] => SendRecv
+ case node: SendDecl[G] => SendRecv
+
+ case node: Range[G] => SequenceRange
+
+ case node: BagAdd[G] => SilverAxiomaticLibraryType
+ case node: BagLargestCommon[G] => SilverAxiomaticLibraryType
+ case node: BagMemberCount[G] => SilverAxiomaticLibraryType
+ case node: BagMinus[G] => SilverAxiomaticLibraryType
+ case node: Concat[G] => SilverAxiomaticLibraryType
+ case node: Drop[G] => SilverAxiomaticLibraryType
+ case node: LiteralBag[G] => SilverAxiomaticLibraryType
+ case node: LiteralSeq[G] => SilverAxiomaticLibraryType
+ case node: LiteralSet[G] => SilverAxiomaticLibraryType
+ case node: SeqMember[G] => SilverAxiomaticLibraryType
+ case node: SeqSubscript[G] => SilverAxiomaticLibraryType
+ case node: VectorSubscript[G] => SilverAxiomaticLibraryType
+ case node: SeqUpdate[G] => SilverAxiomaticLibraryType
+ case node: SetIntersection[G] => SilverAxiomaticLibraryType
+ case node: SetMember[G] => SilverAxiomaticLibraryType
+ case node: SetMinus[G] => SilverAxiomaticLibraryType
+ case node: SetUnion[G] => SilverAxiomaticLibraryType
+ case node: SilverBagSize[G] => SilverAxiomaticLibraryType
+ case node: SilverMapSize[G] => SilverAxiomaticLibraryType
+ case node: SilverSeqSize[G] => SilverAxiomaticLibraryType
+ case node: SilverSetSize[G] => SilverAxiomaticLibraryType
+ case node: Size[G] => SilverAxiomaticLibraryType
+ case node: SubBag[G] => SilverAxiomaticLibraryType
+ case node: SubSet[G] => SilverAxiomaticLibraryType
+ case node: Take[G] => SilverAxiomaticLibraryType
+ case node: TBag[G] => SilverAxiomaticLibraryType
+ case node: TSeq[G] => SilverAxiomaticLibraryType
+ case node: TSet[G] => SilverAxiomaticLibraryType
+ case node: TVector[G] => SilverAxiomaticLibraryType
+
+ case node: SilverCurFieldPerm[G] => SilverSpecific
+ case node: SilverCurPredPerm[G] => SilverSpecific
+ case node: SilverPartialADTFunctionInvocation[G] => SilverSpecific
+ case node: SilverPartialTAxiomatic[G] => SilverSpecific
+ case node: SilverUntypedNonemptyLiteralMap[G] => SilverSpecific
+
+ case node: FunctionInvocation[G] => SmtDeclarations
+ case node: Variable[G] => SmtDeclarations
+
+ case node: And[G] => SmtOperators
+ case node: BooleanValue[G] => SmtOperators
+ case node: RatDiv[G] => SmtOperators
+ case node: Eq[G] => SmtOperators
+ case node: Exists[G] => SmtOperators
+ case node: FloorDiv[G] => SmtOperators
+ case node: FloatDiv[G] => SmtOperators
+ case node: Forall[G] => SmtOperators
+ case node: Greater[G] => SmtOperators
+ case node: GreaterEq[G] => SmtOperators
+ case node: Implies[G] => SmtOperators
+ case node: IntegerValue[G] => SmtOperators
+ case node: Less[G] => SmtOperators
+ case node: LessEq[G] => SmtOperators
+ case node: Let[G] => SmtOperators
+ case node: Local[G] => SmtOperators
+ case node: Minus[G] => SmtOperators
+ case node: Mod[G] => SmtOperators
+ case node: TruncMod[G] => SmtOperators
+ case node: TruncDiv[G] => SmtOperators
+ case node: Mult[G] => SmtOperators
+ case node: Neq[G] => SmtOperators
+ case node: NoPerm[G] => SmtOperators
+ case node: Not[G] => SmtOperators
+ case node: Or[G] => SmtOperators
+ case node: Plus[G] => SmtOperators
+ case node: Select[G] => SmtOperators
+ case node: SilverIntToRat[G] => SmtOperators
+ case node: UMinus[G] => SmtOperators
+ case node: WritePerm[G] => SmtOperators
+
+ case node: TBool[G] => SmtTypes
+ case node: TInt[G] => SmtTypes
+ case node: TRational[G] => SmtTypes
+
+ case node: SpecIgnoreStart[G] => SpecIgnore
+ case node: SpecIgnoreEnd[G] => SpecIgnore
+
+ case node: Any[G] => StarSubscript
+
+ case node: Cons[G] => SugarCollectionOperator
+ case node: Head[G] => SugarCollectionOperator
+ case node: Tail[G] => SugarCollectionOperator
+ case node: Slice[G] => SugarCollectionOperator
+ case node: RemoveAt[G] => SugarCollectionOperator
+ case node: Empty[G] => SugarCollectionOperator
+ case node: SubSetEq[G] => SugarCollectionOperator
+ case node: SubBagEq[G] => SugarCollectionOperator
+
+ case node: PointsTo[G] => SugarPermissionOperator
+ case node: Scale[G] => SugarPermissionOperator
+
+ case node: Switch[G] => SwitchStatement
+ case node: DefaultCase[G] => SwitchStatement
+ case node: Case[G] => SwitchStatement
+
+ case node: DecreasesClauseAssume[G] => TerminationMeasure
+ case node: DecreasesClauseNoRecursion[G] => TerminationMeasure
+ case node: DecreasesClauseTuple[G] => TerminationMeasure
+
+ case node: SimplificationRule[G] => TermRewriteRules
+ case node: FunctionOf[G] => TermRewriteRules
+
+ case node: TChar[G] => TextTypes
+ case node: TString[G] => TextTypes
+
+ case node: TryCatchFinally[G] => TryCatchStatement
+ case node: CatchClause[G] => TryCatchStatement
+
+ case node: TypeValue[G] => TypeValuesAndGenerics
+ case node: TypeOf[G] => TypeValuesAndGenerics
+ case node: InstanceOf[G] => TypeValuesAndGenerics
+ case node: Cast[G] => TypeValuesAndGenerics
+ case node: SubType[G] => TypeValuesAndGenerics
+ case node: SuperType[G] => TypeValuesAndGenerics
+ case node: TType[G] => TypeValuesAndGenerics
+ case node: TVar[G] => TypeValuesAndGenerics
+
+ case node: LocalDecl[G] => UnscopedDeclaration
+
+ case node: Wait[G] => WaitNotify
+ case node: Notify[G] => WaitNotify
+
+ case node: ReadPerm[G] => WildcardReadPermission
+
+ case node: AmbiguousComputationalAnd[G] =>
+ return AmbiguousOperators +:
+ (if (node.isBoolOp)
+ Seq(ComputationalLogicOperator)
+ else
+ Seq(BitOperators))
+ case node: AmbiguousComputationalOr[G] =>
+ return AmbiguousOperators +:
+ (if (node.isBoolOp)
+ Seq(ComputationalLogicOperator)
+ else
+ Seq(BitOperators))
+ case node: AmbiguousComputationalXor[G] =>
+ return AmbiguousOperators +:
+ (if (node.isBoolOp)
+ Seq(ComputationalLogicOperator)
+ else
+ Seq(BitOperators))
+ case node: AmbiguousMult[G] =>
+ return AmbiguousOperators +:
+ (if (node.isProcessOp)
+ Seq(Models)
+ else
+ Seq(SmtOperators))
+ case node: AmbiguousPlus[G] =>
+ return AmbiguousOperators +:
+ (if (node.isProcessOp)
+ Seq(Models)
+ else if (node.isPointerOp)
+ Seq(Pointers)
+ else
+ Seq(SmtOperators))
+ case node: AmbiguousMinus[G] => AmbiguousOperators
+ case node: AmbiguousOr[G] =>
+ return AmbiguousOperators +:
+ (if (node.isProcessOp)
+ Seq(Models)
+ else
+ Seq(SmtOperators))
+ case node: AmbiguousSubscript[G] =>
+ return AmbiguousOperators +:
+ (if (node.isPointerOp)
+ Seq(Pointers)
+ else if (node.isMapOp)
+ Seq(AxiomaticLibraryType)
+ else if (node.isArrayOp)
+ Seq(Arrays)
+ else
+ Seq(SilverAxiomaticLibraryType))
+ case node: AmbiguousMember[G] =>
+ return AmbiguousOperators +:
+ (if (node.isMapOp)
+ Seq(AxiomaticLibraryType)
+ else
+ Seq(SilverAxiomaticLibraryType))
+
+ case node: Return[G] =>
+ returnValues :+= node.result
+ if (node.result == Void[G]()(DiagnosticOrigin))
+ return Seq(Methods)
+ else
+ return Seq(NonVoidReturn, Methods)
+ case node: Branch[G] =>
+ node.branches match {
+ case Seq((_, _), (BooleanValue(true), _)) => BasicStatement
+ case _ => NonTrivialBranch
+ }
+ case node: Loop[G] =>
+ node match {
+ case Loop(Block(Nil), _, Block(Nil), _, _) => WhileLoops
+ case _ => NonWhileLoop
+ }
+ case node: Function[G] =>
+ return Seq(SmtDeclarations) ++
+ (if (node.inline)
+ Seq(ApplicableToBeInlined)
+ else
+ Nil) ++
+ (if (node.typeArgs.nonEmpty)
+ Seq(TypeValuesAndGenerics)
+ else
+ Nil)
+ case node: Procedure[G] =>
+ returnTypes :+= node.returnType
+ return Seq(Methods) ++
+ (if (node.inline)
+ Seq(ApplicableToBeInlined)
+ else
+ Nil) ++
+ (if (node.typeArgs.nonEmpty)
+ Seq(TypeValuesAndGenerics)
+ else
+ Nil) ++
+ (if (node.pure)
+ Seq(MethodToBePurified)
+ else
+ Nil)
+ case node: Predicate[G] =>
+ return Seq(Resources) ++
+ (if (node.inline)
+ Seq(ApplicableToBeInlined)
+ else
+ Nil)
+ case node: InstanceFunction[G] =>
+ return Seq(Classes) ++
+ (if (node.typeArgs.nonEmpty)
+ Seq(TypeValuesAndGenerics)
+ else
+ Nil) ++
+ (if (node.inline)
+ Seq(ApplicableToBeInlined)
+ else
+ Nil)
+ case node: InstanceMethod[G] =>
+ returnTypes :+= node.returnType
+ return Seq(Classes, Methods) ++
+ (if (node.typeArgs.nonEmpty)
+ Seq(TypeValuesAndGenerics)
+ else
+ Nil) ++
+ (if (node.inline)
+ Seq(ApplicableToBeInlined)
+ else
+ Nil) ++
+ (if (node.pure)
+ Seq(MethodToBePurified)
+ else
+ Nil)
+ case node: InstancePredicate[G] =>
+ return Seq(Classes) ++
+ (if (node.inline)
+ Seq(ApplicableToBeInlined)
+ else
+ Nil)
+ case node: Label[G] =>
+ node.stat match {
+ case Block(Nil) => Gotos
+ case _ => return Seq(NonTrivialLabel, Gotos)
+ }
+ case node: TVoid[G] =>
+ if (returnTypes.exists(_ eq node))
+ return Nil
+ else
+ AxiomaticLibraryType
+ case node: Void[G] =>
+ if (returnValues.exists(_ eq node))
+ return Nil
+ else
+ AxiomaticLibraryType
+
+ case node: ValidArray[G] => return Seq(SugarPermissionOperator, Arrays)
+ case node: ValidMatrix[G] => return Seq(SugarPermissionOperator, Arrays)
+ case node: PermPointer[G] => return Seq(SugarPermissionOperator, Pointers)
+ case node: PermPointerIndex[G] =>
+ return Seq(SugarPermissionOperator, Pointers)
+ case node: CLiteralArray[G] => return Seq(CSpecific, Arrays)
+ case node: CCast[G] => return Seq(CSpecific, TypeValuesAndGenerics)
+ case node: CChar[G] => return Seq(CSpecific, TextTypes)
+ case node: CDeclarationStatement[G] =>
+ return Seq(CSpecific, UnscopedDeclaration)
+ case node: CGoto[G] => return Seq(CSpecific, Gotos)
+ case node: CPointer[G] => return Seq(CSpecific, Pointers)
+ case node: CPointerDeclarator[G] => return Seq(CSpecific, Pointers)
+ case node: CPPLiteralArray[G] => return Seq(CPPSpecific, Arrays)
+ case node: CPPChar[G] => return Seq(CPPSpecific, TextTypes)
+ case node: CPPDeclarationStatement[G] =>
+ return Seq(CPPSpecific, UnscopedDeclaration)
+ case node: CPPPointer[G] => return Seq(CPPSpecific, Pointers)
+ case node: CPPReference[G] => return Seq(CPPSpecific, Pointers)
+ case node: Result[G] => return scanFlatly(node.applicable.decl)
+ case node: SilverNewRef[G] => return Seq(Assignment, Resources)
+
+ case _ => return Nil
+ })
}
diff --git a/src/col/vct/col/origin/Blame.scala b/src/col/vct/col/origin/Blame.scala
index b4c003c562..068aa2f893 100644
--- a/src/col/vct/col/origin/Blame.scala
+++ b/src/col/vct/col/origin/Blame.scala
@@ -15,17 +15,23 @@ sealed trait ContractFailure {
case class ContractFalse(node: Expr[_]) extends ContractFailure {
override def code: String = "false"
override def descCompletion: String = "this expression may be false"
- override def inlineDescCompletion: String = s"${node.o.inlineContextText} may be false"
+ override def inlineDescCompletion: String =
+ s"${node.o.inlineContextText} may be false"
}
-case class InsufficientPermissionToExhale(node: Expr[_]) extends ContractFailure {
+case class InsufficientPermissionToExhale(node: Expr[_])
+ extends ContractFailure {
override def code: String = "perm"
- override def descCompletion: String = "there might not be enough permission to exhale this amount"
- override def inlineDescCompletion: String = s"there might be insufficient permission for ${node.o.inlineContextText}"
+ override def descCompletion: String =
+ "there might not be enough permission to exhale this amount"
+ override def inlineDescCompletion: String =
+ s"there might be insufficient permission for ${node.o.inlineContextText}"
}
case class NegativePermissionValue(node: Expr[_]) extends ContractFailure {
override def code: String = "negativePermValue"
- override def descCompletion: String = "the amount of permission in this permission predicate may be negative"
- override def inlineDescCompletion: String = s"${node.o.inlineContextText} may be a negative permission amount"
+ override def descCompletion: String =
+ "the amount of permission in this permission predicate may be negative"
+ override def inlineDescCompletion: String =
+ s"${node.o.inlineContextText} may be a negative permission amount"
}
trait VerificationFailure {
@@ -51,16 +57,20 @@ object TableEntry {
val result = new StringBuilder
result.append("At").append(" ".repeat(posWidth - "At".length)).append(" ")
- result.append("Code").append(" ".repeat(codeWidth - "Code".length)).append(" ")
- result.append("Description").append(" ".repeat(descWidth - "Description".length)).append("\n")
+ result.append("Code").append(" ".repeat(codeWidth - "Code".length))
+ .append(" ")
+ result.append("Description")
+ .append(" ".repeat(descWidth - "Description".length)).append("\n")
result.append("-" * posWidth).append(" ")
result.append("-" * codeWidth).append(" ")
result.append("-" * descWidth).append("\n")
- for(entry <- entries) {
- result.append(entry.position).append(" " * (posWidth - entry.position.length)).append(" ")
- result.append(entry.code).append(" " * (codeWidth - entry.code.length)).append(" ")
+ for (entry <- entries) {
+ result.append(entry.position)
+ .append(" " * (posWidth - entry.position.length)).append(" ")
+ result.append(entry.code).append(" " * (codeWidth - entry.code.length))
+ .append(" ")
result.append(entry.desc).append("\n")
}
@@ -78,7 +88,8 @@ trait NodeVerificationFailure extends VerificationFailure {
override def position: String = node.o.shortPositionText
override def desc: String = node.o.messageInContext(descInContext + errUrl)
- override def inlineDesc: String = inlineDescWithSource(node.o.inlineContextText)
+ override def inlineDesc: String =
+ inlineDescWithSource(node.o.inlineContextText)
}
trait WithContractFailure extends VerificationFailure {
@@ -107,96 +118,146 @@ sealed trait ExpectedErrorFailure extends VerificationFailure {
def err: ExpectedError
}
-case class ExpectedErrorTrippedTwice(err: ExpectedError, left: VerificationFailure, right: VerificationFailure) extends ExpectedErrorFailure {
+case class ExpectedErrorTrippedTwice(
+ err: ExpectedError,
+ left: VerificationFailure,
+ right: VerificationFailure,
+) extends ExpectedErrorFailure {
override def code: String = "trippedTwice"
override def position: String = err.errorRegion.shortPositionText
- override def desc: String = err.errorRegion.messageInContext(s"The expected error with code `${err.errorCode}` occurred multiple times." + errUrl)
- override def inlineDesc: String = s"The expected error with code `${err.errorCode}` occurred multiple times."
+ override def desc: String =
+ err.errorRegion.messageInContext(
+ s"The expected error with code `${err.errorCode}` occurred multiple times." +
+ errUrl
+ )
+ override def inlineDesc: String =
+ s"The expected error with code `${err.errorCode}` occurred multiple times."
}
-case class ExpectedErrorNotTripped(err: ExpectedError) extends ExpectedErrorFailure {
+case class ExpectedErrorNotTripped(err: ExpectedError)
+ extends ExpectedErrorFailure {
override def code: String = "notTripped"
override def position: String = err.errorRegion.shortPositionText
- override def desc: String = err.errorRegion.messageInContext(s"The expected error with code `${err.errorCode}` was not encountered." + errUrl)
- override def inlineDesc: String = s"The expected error with code `${err.errorCode}` was not encountered."
+ override def desc: String =
+ err.errorRegion.messageInContext(
+ s"The expected error with code `${err.errorCode}` was not encountered." +
+ errUrl
+ )
+ override def inlineDesc: String =
+ s"The expected error with code `${err.errorCode}` was not encountered."
}
sealed trait AssignFailed extends NodeVerificationFailure
-case class AssignFieldFailed(node: SilverFieldAssign[_]) extends AssignFailed with NodeVerificationFailure {
+case class AssignFieldFailed(node: SilverFieldAssign[_])
+ extends AssignFailed with NodeVerificationFailure {
override def code: String = "assignFieldFailed"
- override def descInContext: String = "Insufficient permission to assign to field."
- override def inlineDescWithSource(source: String): String = s"Insufficient permission for assignment `$source`."
+ override def descInContext: String =
+ "Insufficient permission to assign to field."
+ override def inlineDescWithSource(source: String): String =
+ s"Insufficient permission for assignment `$source`."
}
-case class CopyStructFailed(node: Expr[_], field: String) extends AssignFailed with NodeVerificationFailure {
+case class CopyStructFailed(node: Expr[_], field: String)
+ extends AssignFailed with NodeVerificationFailure {
override def code: String = "copyStructFailed"
- override def descInContext: String = s"Insufficient read permission for field '$field' to copy struct."
- override def inlineDescWithSource(source: String): String = s"Insufficient permission for assignment `$source`."
+ override def descInContext: String =
+ s"Insufficient read permission for field '$field' to copy struct."
+ override def inlineDescWithSource(source: String): String =
+ s"Insufficient permission for assignment `$source`."
}
-case class CopyStructFailedBeforeCall(node: Expr[_], field: String) extends AssignFailed with FrontendInvocationError with NodeVerificationFailure {
+case class CopyStructFailedBeforeCall(node: Expr[_], field: String)
+ extends AssignFailed
+ with FrontendInvocationError
+ with NodeVerificationFailure {
override def code: String = "copyStructFailedBeforeCall"
- override def descInContext: String = s"Insufficient read permission for field '$field' to copy struct before call."
- override def inlineDescWithSource(source: String): String = s"Insufficient permission for call `$source`."
+ override def descInContext: String =
+ s"Insufficient read permission for field '$field' to copy struct before call."
+ override def inlineDescWithSource(source: String): String =
+ s"Insufficient permission for call `$source`."
}
-case class AssertFailed(failure: ContractFailure, node: Assert[_]) extends WithContractFailure {
+case class AssertFailed(failure: ContractFailure, node: Assert[_])
+ extends WithContractFailure {
override def baseCode: String = "assertFailed"
override def descInContext: String = "Assertion may not hold, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"Assertion `$node` may fail, since $failure."
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"Assertion `$node` may fail, since $failure."
}
case class RefuteFailed(node: Refute[_]) extends NodeVerificationFailure {
override def code: String = "refuteFailed"
- override def descInContext: String = "Assertion holds in all cases where it is reachable."
- override def inlineDescWithSource(source: String): String = s"Assertion `$source` holds in all cases where it is reachable."
+ override def descInContext: String =
+ "Assertion holds in all cases where it is reachable."
+ override def inlineDescWithSource(source: String): String =
+ s"Assertion `$source` holds in all cases where it is reachable."
}
-case class ExhaleFailed(failure: ContractFailure, node: Exhale[_]) extends WithContractFailure {
+case class ExhaleFailed(failure: ContractFailure, node: Exhale[_])
+ extends WithContractFailure {
override def baseCode: String = "exhaleFailed"
override def descInContext: String = "Exhale may fail, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"`$node` may fail, since $failure."
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"`$node` may fail, since $failure."
}
-case class UnfoldFailed(failure: ContractFailure, node: Node[_]) extends WithContractFailure {
+case class UnfoldFailed(failure: ContractFailure, node: Node[_])
+ extends WithContractFailure {
override def baseCode: String = "unfoldFailed"
override def descInContext: String = "Unfold may fail, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"`$node` may fail, since $failure."
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"`$node` may fail, since $failure."
}
-case class FoldFailed(failure: ContractFailure, node: Fold[_]) extends WithContractFailure {
+case class FoldFailed(failure: ContractFailure, node: Fold[_])
+ extends WithContractFailure {
override def baseCode: String = "foldFailed"
override def descInContext: String = "Fold may fail, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"`$node` may fail, since $failure."
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"`$node` may fail, since $failure."
}
trait PackageFailure extends VerificationFailure
-case class PackageThrows(node: WandPackage[_]) extends PackageFailure with NodeVerificationFailure {
+case class PackageThrows(node: WandPackage[_])
+ extends PackageFailure with NodeVerificationFailure {
override def code: String = "packageThrows"
override def descInContext: String = "Package proof may throw an exception"
- override def inlineDescWithSource(source: String): String = s"`$node` may throw an exception."
+ override def inlineDescWithSource(source: String): String =
+ s"`$node` may throw an exception."
}
-case class PackageFailed(failure: ContractFailure, node: WandPackage[_]) extends PackageFailure with WithContractFailure {
+case class PackageFailed(failure: ContractFailure, node: WandPackage[_])
+ extends PackageFailure with WithContractFailure {
override def baseCode: String = "packageFailed"
override def descInContext: String = "Package statement may fail, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"`$node` may fail, since $failure."
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"`$node` may fail, since $failure."
}
-case class WandApplyFailed(failure: ContractFailure, node: WandApply[_]) extends WithContractFailure {
+case class WandApplyFailed(failure: ContractFailure, node: WandApply[_])
+ extends WithContractFailure {
override def baseCode: String = "applyFailed"
override def descInContext: String = "Wand apply may fail, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"`$node` may fail, since $failure."
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"`$node` may fail, since $failure."
}
-case class SendFailed(failure: ContractFailure, node: Send[_]) extends WithContractFailure {
+case class SendFailed(failure: ContractFailure, node: Send[_])
+ extends WithContractFailure {
override def baseCode: String = "sendFailed"
override def descInContext: String = "Send may fail, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"`$node` may fail, since $failure."
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"`$node` may fail, since $failure."
}
sealed trait FramedProofFailure extends VerificationFailure
-case class FramedProofPreFailed(failure: ContractFailure, node: FramedProof[_]) extends FramedProofFailure with WithContractFailure {
+case class FramedProofPreFailed(failure: ContractFailure, node: FramedProof[_])
+ extends FramedProofFailure with WithContractFailure {
override def baseCode: String = "framePre"
- override def descInContext: String = "Precondition of framed statement may fail, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"Precondition of `$node` may fail, since $failure."
+ override def descInContext: String =
+ "Precondition of framed statement may fail, since"
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"Precondition of `$node` may fail, since $failure."
}
-case class FramedProofPostFailed(failure: ContractFailure, node: FramedProof[_]) extends FramedProofFailure with WithContractFailure {
+case class FramedProofPostFailed(failure: ContractFailure, node: FramedProof[_])
+ extends FramedProofFailure with WithContractFailure {
override def baseCode: String = "framePost"
- override def descInContext: String = "Postcondition of framed statement may fail, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"Postcondition of `$node` may fail, since $failure."
+ override def descInContext: String =
+ "Postcondition of framed statement may fail, since"
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"Postcondition of `$node` may fail, since $failure."
}
sealed trait AccountedDirection
@@ -205,109 +266,178 @@ case object FailRight extends AccountedDirection
sealed trait FrontendInvocationError extends VerificationFailure
sealed trait InstanceInvocationFailure extends FrontendInvocationError
-case class InstanceNull(node: InvokingNode[_]) extends InstanceInvocationFailure with NodeVerificationFailure {
+case class InstanceNull(node: InvokingNode[_])
+ extends InstanceInvocationFailure with NodeVerificationFailure {
override def code: String = "invocationObjectNull"
- override def descInContext: String = "The object for this invocation may be null."
- override def inlineDescWithSource(source: String): String = s"The object in the invocation `$source` may be null"
+ override def descInContext: String =
+ "The object for this invocation may be null."
+ override def inlineDescWithSource(source: String): String =
+ s"The object in the invocation `$source` may be null"
}
sealed trait InvocationFailure extends InstanceInvocationFailure
-case class PreconditionFailed(path: Seq[AccountedDirection], failure: ContractFailure, node: InvokingNode[_]) extends InvocationFailure with WithContractFailure {
+case class PreconditionFailed(
+ path: Seq[AccountedDirection],
+ failure: ContractFailure,
+ node: InvokingNode[_],
+) extends InvocationFailure with WithContractFailure {
override def baseCode: String = "preFailed"
override def descInContext: String = "Precondition may not hold, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"Precondition of `$node` may not hold, since $failure."
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"Precondition of `$node` may not hold, since $failure."
}
-case class ContextEverywhereFailedInPre(failure: ContractFailure, node: InvokingNode[_]) extends InvocationFailure with WithContractFailure {
+case class ContextEverywhereFailedInPre(
+ failure: ContractFailure,
+ node: InvokingNode[_],
+) extends InvocationFailure with WithContractFailure {
override def baseCode: String = "contextPreFailed"
- override def descInContext: String = "Context may not hold in precondition, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"Context of `$node` may not hold in the precondition, since $failure."
+ override def descInContext: String =
+ "Context may not hold in precondition, since"
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"Context of `$node` may not hold in the precondition, since $failure."
}
-case class SYCLItemMethodPreconditionFailed(node: InvokingNode[_]) extends NodeVerificationFailure with FrontendInvocationError {
+case class SYCLItemMethodPreconditionFailed(node: InvokingNode[_])
+ extends NodeVerificationFailure with FrontendInvocationError {
override def code: String = "syclItemMethodPreFailed"
override def position: String = node.o.shortPositionText
- override def descInContext: String = "The dimension parameter should be greater or equal to zero and smaller than the number of dimensions in the (nd_)item."
+ override def descInContext: String =
+ "The dimension parameter should be greater or equal to zero and smaller than the number of dimensions in the (nd_)item."
override def inlineDescWithSource(source: String): String =
s"The dimension parameter `$source` should be greater or equal to zero and smaller than the number of dimensions in the (nd_)item."
}
-sealed trait CallableFailure extends ConstructorFailure with JavaConstructorFailure
+sealed trait CallableFailure
+ extends ConstructorFailure with JavaConstructorFailure
sealed trait ContractedFailure extends CallableFailure
-case class PostconditionFailed(path: Seq[AccountedDirection], failure: ContractFailure, node: ContractApplicable[_]) extends ContractedFailure with SeqCallableFailure with WithContractFailure {
+case class PostconditionFailed(
+ path: Seq[AccountedDirection],
+ failure: ContractFailure,
+ node: ContractApplicable[_],
+) extends ContractedFailure with SeqCallableFailure with WithContractFailure {
override def baseCode: String = "postFailed"
override def descInContext: String = "Postcondition may not hold, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"Postcondition of `$node` may not hold, since $failure."
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"Postcondition of `$node` may not hold, since $failure."
}
-case class TerminationMeasureFailed(applicable: ContractApplicable[_], apply: Invocation[_], measure: DecreasesClause[_]) extends ContractedFailure with SeqCallableFailure with VerificationFailure {
+case class TerminationMeasureFailed(
+ applicable: ContractApplicable[_],
+ apply: Invocation[_],
+ measure: DecreasesClause[_],
+) extends ContractedFailure with SeqCallableFailure with VerificationFailure {
override def code: String = "decreasesFailed"
override def position: String = measure.o.shortPositionText
- override def desc: String = Message.messagesInContext(
- applicable.o -> "Applicable may not terminate, since ...",
- apply.o -> "... from this invocation ...",
- measure.o -> "... this measure may not be bounded, or may not decrease.",
- )
+ override def desc: String =
+ Message.messagesInContext(
+ applicable.o -> "Applicable may not terminate, since ...",
+ apply.o -> "... from this invocation ...",
+ measure.o -> "... this measure may not be bounded, or may not decrease.",
+ )
override def inlineDesc: String =
s"${apply.o.inlineContextText} may not terminate, since `${measure.o.inlineContextText}` is not decreased or not bounded"
}
-case class ContextEverywhereFailedInPost(failure: ContractFailure, node: ContractApplicable[_]) extends ContractedFailure with SeqCallableFailure with WithContractFailure {
+case class ContextEverywhereFailedInPost(
+ failure: ContractFailure,
+ node: ContractApplicable[_],
+) extends ContractedFailure with SeqCallableFailure with WithContractFailure {
override def baseCode: String = "contextPostFailed"
- override def descInContext: String = "Context may not hold in postcondition, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"Context of `$node` may not hold in the postcondition, since $failure."
+ override def descInContext: String =
+ "Context may not hold in postcondition, since"
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"Context of `$node` may not hold in the postcondition, since $failure."
}
-case class AutoValueLeakCheckFailed(failure: ContractFailure, node: ContractApplicable[_]) extends ContractedFailure with SeqCallableFailure with WithContractFailure {
+case class AutoValueLeakCheckFailed(
+ failure: ContractFailure,
+ node: ContractApplicable[_],
+) extends ContractedFailure with SeqCallableFailure with WithContractFailure {
override def baseCode: String = "autoValueLeak"
override def descInContext: String = "The AutoValue leak check failed, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"Some of the permission from `$node` was leaked before the postcondition was evaluated, since $failure."
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"Some of the permission from `$node` was leaked before the postcondition was evaluated, since $failure."
}
-case class SignalsFailed(failure: ContractFailure, node: AbstractMethod[_]) extends CallableFailure with WithContractFailure {
+case class SignalsFailed(failure: ContractFailure, node: AbstractMethod[_])
+ extends CallableFailure with WithContractFailure {
override def baseCode: String = "signalsFailed"
override def descInContext: String = "Signals clause may not hold, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"Signals clause of `$node` may not hold, since $failure."
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"Signals clause of `$node` may not hold, since $failure."
}
-case class ExceptionNotInSignals(node: AbstractMethod[_]) extends CallableFailure with NodeVerificationFailure {
+case class ExceptionNotInSignals(node: AbstractMethod[_])
+ extends CallableFailure with NodeVerificationFailure {
override def code: String = "extraExc"
- override def descInContext: String = "Method may throw exception not included in signals clauses."
- override def inlineDescWithSource(source: String): String = s"Method `$source` may throw exception not included in signals clauses."
+ override def descInContext: String =
+ "Method may throw exception not included in signals clauses."
+ override def inlineDescWithSource(source: String): String =
+ s"Method `$source` may throw exception not included in signals clauses."
}
-case class SeqRunPreconditionFailed(path: Seq[AccountedDirection], failure: ContractFailure, node: ChorRun[_]) extends SeqRunFailure with WithContractFailure {
+case class SeqRunPreconditionFailed(
+ path: Seq[AccountedDirection],
+ failure: ContractFailure,
+ node: ChorRun[_],
+) extends SeqRunFailure with WithContractFailure {
override def baseCode: String = "seqRunPreFailed"
override def descInContext: String = "Precondition may not hold, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"Precondition of `$node` may not hold, since $failure."
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"Precondition of `$node` may not hold, since $failure."
}
-case class SeqRunContextEverywhereFailedInPre(failure: ContractFailure, node: ChorRun[_]) extends SeqRunFailure with WithContractFailure {
+case class SeqRunContextEverywhereFailedInPre(
+ failure: ContractFailure,
+ node: ChorRun[_],
+) extends SeqRunFailure with WithContractFailure {
override def baseCode: String = "seqRunContextPreFailed"
- override def descInContext: String = "Context may not hold in precondition, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"Context of `$node` may not hold in the precondition, since $failure."
+ override def descInContext: String =
+ "Context may not hold in precondition, since"
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"Context of `$node` may not hold in the precondition, since $failure."
}
-case class SYCLKernelLambdaFailure(kernelFailure: KernelFailure) extends VerificationFailure {
+case class SYCLKernelLambdaFailure(kernelFailure: KernelFailure)
+ extends VerificationFailure {
override def code: String = "syclKernelLambda" + kernelFailure.code.capitalize
override def position: String = kernelFailure.position
override def desc: String = kernelFailure.desc
override def inlineDesc: String = kernelFailure.inlineDesc
}
sealed trait LoopInvariantFailure extends VerificationFailure
-case class LoopInvariantNotEstablished(failure: ContractFailure, node: LoopInvariant[_]) extends LoopInvariantFailure with WithContractFailure {
+case class LoopInvariantNotEstablished(
+ failure: ContractFailure,
+ node: LoopInvariant[_],
+) extends LoopInvariantFailure with WithContractFailure {
override def baseCode: String = "invariantNotEstablished"
- override def descInContext: String = "This invariant may not be established, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"Invariant of `$node` may not be established, since $failure."
+ override def descInContext: String =
+ "This invariant may not be established, since"
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"Invariant of `$node` may not be established, since $failure."
}
-case class LoopInvariantNotMaintained(failure: ContractFailure, node: LoopInvariant[_]) extends LoopInvariantFailure with WithContractFailure {
+case class LoopInvariantNotMaintained(
+ failure: ContractFailure,
+ node: LoopInvariant[_],
+) extends LoopInvariantFailure with WithContractFailure {
override def baseCode: String = "notMaintained"
- override def descInContext: String = "This invariant may not be maintained, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"Invariant of `$node` may not be maintained, since $failure."
+ override def descInContext: String =
+ "This invariant may not be maintained, since"
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"Invariant of `$node` may not be maintained, since $failure."
}
-case class LoopTerminationMeasureFailed(node: DecreasesClause[_]) extends LoopInvariantFailure with NodeVerificationFailure {
+case class LoopTerminationMeasureFailed(node: DecreasesClause[_])
+ extends LoopInvariantFailure with NodeVerificationFailure {
override def code: String = "loopDecreasesFailed"
override def position: String = node.o.shortPositionText
- override def descInContext: String = "Loop may not terminate, since this measure may not be bounded, or may not decrease."
- override def inlineDescWithSource(source: String): String = s"Loop may not terminate, since ${node.o.inlineContextText} may be unbounded or nondecreasing"
+ override def descInContext: String =
+ "Loop may not terminate, since this measure may not be bounded, or may not decrease."
+ override def inlineDescWithSource(source: String): String =
+ s"Loop may not terminate, since ${node.o.inlineContextText} may be unbounded or nondecreasing"
}
-case class ReceiverNotInjective(quantifier: Starall[_], resource: Expr[_]) extends VerificationFailure with AnyStarError {
+case class ReceiverNotInjective(quantifier: Starall[_], resource: Expr[_])
+ extends VerificationFailure with AnyStarError {
override def code: String = "notInjective"
- override def desc: String = Message.messagesInContext(
- quantifier.o -> "This quantifier causes the resources in its body to be quantified, ...",
- resource.o -> "... but this resource may not be unique with regards to the quantified variables.",
- )
- override def inlineDesc: String = s"The location of the permission predicate in ${resource.o.inlineContextText} may not be unique with regards to the quantified variables."
+ override def desc: String =
+ Message.messagesInContext(
+ quantifier.o ->
+ "This quantifier causes the resources in its body to be quantified, ...",
+ resource.o ->
+ "... but this resource may not be unique with regards to the quantified variables.",
+ )
+ override def inlineDesc: String =
+ s"The location of the permission predicate in ${resource.o.inlineContextText} may not be unique with regards to the quantified variables."
override def position: String = resource.o.shortPositionText
}
@@ -316,205 +446,299 @@ sealed trait DivByZero extends NodeVerificationFailure
case class ScalarDivByZero(node: DividingExpr[_]) extends DivByZero {
override def code: String = "divByZero"
override def descInContext: String = "The divisor may be zero."
- override def inlineDescWithSource(source: String): String = s"The divisor in `$source` may be zero."
+ override def inlineDescWithSource(source: String): String =
+ s"The divisor in `$source` may be zero."
}
case class VectorDivByZero(node: DividingExpr[_], i: Int) extends DivByZero {
override def code: String = "vectorDivByZero"
- override def descInContext: String = f"Element $i of the divisor vector may be zero."
- override def inlineDescWithSource(source: String): String = s"Element $i of the divisor vector in `$source` may be zero."
+ override def descInContext: String =
+ f"Element $i of the divisor vector may be zero."
+ override def inlineDescWithSource(source: String): String =
+ s"Element $i of the divisor vector in `$source` may be zero."
}
sealed trait FrontendDerefError extends VerificationFailure
sealed trait FrontendAdditiveError extends VerificationFailure
sealed trait FrontendSubscriptError extends VerificationFailure
-case class PlusProviderNull(node: Node[_]) extends FrontendAdditiveError with NodeVerificationFailure {
+case class PlusProviderNull(node: Node[_])
+ extends FrontendAdditiveError with NodeVerificationFailure {
override def code: String = "plusProviderNull"
- override def descInContext: String = "This expression might be null, which is prohibited because it is the subject of a custom plus operation."
- override def inlineDescWithSource(source: String): String = s"The expression in $source might be null, which is prohibited for a custom plus operation."
+ override def descInContext: String =
+ "This expression might be null, which is prohibited because it is the subject of a custom plus operation."
+ override def inlineDescWithSource(source: String): String =
+ s"The expression in $source might be null, which is prohibited for a custom plus operation."
}
-case class PlusProviderInvocationFailed(innerFailure: WithContractFailure) extends FrontendAdditiveError with WithContractFailure {
+case class PlusProviderInvocationFailed(innerFailure: WithContractFailure)
+ extends FrontendAdditiveError with WithContractFailure {
override def failure: ContractFailure = innerFailure.failure
override def code: String = failure.code
override def node: Node[_] = innerFailure.node
override def baseCode: String = innerFailure.baseCode
override def descInContext: String = innerFailure.descInContext
- override def inlineDescWithSource(node: String, failure: String): String = innerFailure.inlineDescWithSource(node, failure)
+ override def inlineDescWithSource(node: String, failure: String): String =
+ innerFailure.inlineDescWithSource(node, failure)
}
sealed trait SeqCallableFailure extends VerificationFailure
sealed trait SeqRunFailure extends SeqCallableFailure
sealed trait EndpointFailure extends VerificationFailure
-case class EndpointPreconditionFailed(path: Seq[AccountedDirection], failure: ContractFailure, node: Endpoint[_]) extends EndpointFailure with WithContractFailure {
+case class EndpointPreconditionFailed(
+ path: Seq[AccountedDirection],
+ failure: ContractFailure,
+ node: Endpoint[_],
+) extends EndpointFailure with WithContractFailure {
override def baseCode: String = "endpointPreFailed"
- override def descInContext: String = "Precondition of constructor of this endpoint may not hold, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"Precondition of `$node` may not hold, since $failure."
+ override def descInContext: String =
+ "Precondition of constructor of this endpoint may not hold, since"
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"Precondition of `$node` may not hold, since $failure."
}
-case class EndpointContextEverywhereFailedInPre(failure: ContractFailure, node: Endpoint[_]) extends EndpointFailure with WithContractFailure {
+case class EndpointContextEverywhereFailedInPre(
+ failure: ContractFailure,
+ node: Endpoint[_],
+) extends EndpointFailure with WithContractFailure {
override def baseCode: String = "endpointContextPreFailed"
- override def descInContext: String = "Context may not hold in precondition of endpoint constructor, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"Context of `$node` may not hold in the precondition, since $failure."
+ override def descInContext: String =
+ "Context may not hold in precondition of endpoint constructor, since"
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"Context of `$node` may not hold in the precondition, since $failure."
}
sealed trait FrontendIfFailure extends VerificationFailure
sealed trait SeqBranchFailure extends FrontendIfFailure
-case class BranchUnanimityFailed(guard1: Node[_], guard2: Node[_]) extends SeqBranchFailure {
+case class BranchUnanimityFailed(guard1: Node[_], guard2: Node[_])
+ extends SeqBranchFailure {
override def code: String = "branchNotUnanimous"
- override def desc: String = Message.messagesInContext(
- (guard1.o, "This condition..."),
- (guard2.o, "...should agree with this condition, but this might not be the case")
- )
+ override def desc: String =
+ Message.messagesInContext(
+ (guard1.o, "This condition..."),
+ (
+ guard2.o,
+ "...should agree with this condition, but this might not be the case",
+ ),
+ )
override def position: String = guard1.o.shortPositionText
- override def inlineDesc: String = "Two conditions in this branch might disagree."
+ override def inlineDesc: String =
+ "Two conditions in this branch might disagree."
}
sealed trait FrontEndLoopFailure extends VerificationFailure
sealed trait SeqLoopFailure extends FrontEndLoopFailure
-case class LoopUnanimityNotEstablished(guard1: Node[_], guard2: Node[_]) extends SeqLoopFailure {
+case class LoopUnanimityNotEstablished(guard1: Node[_], guard2: Node[_])
+ extends SeqLoopFailure {
override def code: String = "loopUnanimityNotEstablished"
- override def desc: String = Message.messagesInContext(
- (guard1.o, "This condition..."),
- (guard2.o, "...should agree with this condition, but this could not be established before the loop.")
- )
+ override def desc: String =
+ Message.messagesInContext(
+ (guard1.o, "This condition..."),
+ (
+ guard2.o,
+ "...should agree with this condition, but this could not be established before the loop.",
+ ),
+ )
override def position: String = guard1.o.shortPositionText
- override def inlineDesc: String = "The agreement of two conditions in this branch could not be established before the loop."
+ override def inlineDesc: String =
+ "The agreement of two conditions in this branch could not be established before the loop."
}
-case class LoopUnanimityNotMaintained(guard1: Node[_], guard2: Node[_]) extends SeqLoopFailure {
+case class LoopUnanimityNotMaintained(guard1: Node[_], guard2: Node[_])
+ extends SeqLoopFailure {
override def code: String = "loopUnanimityNotMaintained"
- override def desc: String = Message.messagesInContext(
- (guard1.o, "This condition..."),
- (guard2.o, "...should agree with this condition, but this could not be maintained for an arbitrary loop iteration.")
- )
+ override def desc: String =
+ Message.messagesInContext(
+ (guard1.o, "This condition..."),
+ (
+ guard2.o,
+ "...should agree with this condition, but this could not be maintained for an arbitrary loop iteration.",
+ ),
+ )
override def position: String = guard1.o.shortPositionText
- override def inlineDesc: String = "The agreement of two conditions in this branch could not be maintained for an arbitrary loop iteration."
+ override def inlineDesc: String =
+ "The agreement of two conditions in this branch could not be maintained for an arbitrary loop iteration."
}
sealed trait ChorStatementFailure extends VerificationFailure
sealed trait ChorAssignFailure extends ChorStatementFailure
-case class SeqAssignInsufficientPermission(node: ChorStatement[_]) extends ChorAssignFailure with NodeVerificationFailure {
+case class SeqAssignInsufficientPermission(node: ChorStatement[_])
+ extends ChorAssignFailure with NodeVerificationFailure {
override def code: String = "seqAssignPerm"
- override def descInContext: String = "There may be insufficient permission to access this field on this endpoint."
- override def inlineDescWithSource(source: String): String = s"There may be insufficient permission to access `$source`."
+ override def descInContext: String =
+ "There may be insufficient permission to access this field on this endpoint."
+ override def inlineDescWithSource(source: String): String =
+ s"There may be insufficient permission to access `$source`."
}
sealed trait PVLCommunicateFailure extends VerificationFailure
sealed trait CommunicateFailure extends PVLCommunicateFailure
-case class ParticipantsNotDistinct(node: Communicate[_]) extends CommunicateFailure with NodeVerificationFailure {
+case class ParticipantsNotDistinct(node: Communicate[_])
+ extends CommunicateFailure with NodeVerificationFailure {
override def code: String = "participantsNotDistinct"
- override def descInContext: String = "The participants in this communicate statement might not be distinct."
- override def inlineDescWithSource(source: String): String = s"The participants of `$source` might not be distinct."
+ override def descInContext: String =
+ "The participants in this communicate statement might not be distinct."
+ override def inlineDescWithSource(source: String): String =
+ s"The participants of `$source` might not be distinct."
}
sealed trait DerefInsufficientPermission extends FrontendDerefError
-case class InsufficientPermission(node: HeapDeref[_]) extends DerefInsufficientPermission with NodeVerificationFailure {
+case class InsufficientPermission(node: HeapDeref[_])
+ extends DerefInsufficientPermission with NodeVerificationFailure {
override def code: String = "perm"
- override def descInContext: String = "There may be insufficient permission to access this field here."
- override def inlineDescWithSource(source: String): String = s"There may be insufficient permission to access `$source`."
+ override def descInContext: String =
+ "There may be insufficient permission to access this field here."
+ override def inlineDescWithSource(source: String): String =
+ s"There may be insufficient permission to access `$source`."
}
-case class ModelInsufficientPermission(node: ModelDeref[_]) extends DerefInsufficientPermission with NodeVerificationFailure {
+case class ModelInsufficientPermission(node: ModelDeref[_])
+ extends DerefInsufficientPermission with NodeVerificationFailure {
override def code: String = "modelPerm"
- override def descInContext: String = "There may be insufficient permission to access this model field here."
- override def inlineDescWithSource(source: String): String = s"There may be insufficient permission to access `$source`."
+ override def descInContext: String =
+ "There may be insufficient permission to access this model field here."
+ override def inlineDescWithSource(source: String): String =
+ s"There may be insufficient permission to access `$source`."
}
case class LabelNotReached(node: Old[_]) extends NodeVerificationFailure {
override def code: String = "notReached"
- override def descInContext: String = "The label mentioned in this old expression may not have been reached at the time the old expression is evaluated."
- override def inlineDescWithSource(source: String): String = s"The label in `$source` may not have been reached at the time the old expression is evaluated."
+ override def descInContext: String =
+ "The label mentioned in this old expression may not have been reached at the time the old expression is evaluated."
+ override def inlineDescWithSource(source: String): String =
+ s"The label in `$source` may not have been reached at the time the old expression is evaluated."
}
sealed trait SeqBoundFailure extends FrontendSubscriptError with BuiltinError
-case class SeqBoundNegative(node: SeqSubscript[_]) extends SeqBoundFailure with NodeVerificationFailure {
+case class SeqBoundNegative(node: SeqSubscript[_])
+ extends SeqBoundFailure with NodeVerificationFailure {
override def code: String = "indexNegative"
- override def descInContext: String = "The index in this sequence subscript may be negative."
- override def inlineDescWithSource(source: String): String = s"The index in `$source` may be negative."
+ override def descInContext: String =
+ "The index in this sequence subscript may be negative."
+ override def inlineDescWithSource(source: String): String =
+ s"The index in `$source` may be negative."
}
-case class SeqBoundExceedsLength(node: SeqSubscript[_]) extends SeqBoundFailure with NodeVerificationFailure {
+case class SeqBoundExceedsLength(node: SeqSubscript[_])
+ extends SeqBoundFailure with NodeVerificationFailure {
override def code: String = "indexExceedsLength"
- override def descInContext: String = "The index in this sequence subscript may exceed the length of the sequence."
- override def inlineDescWithSource(source: String): String = s"The index in `$source` may exceed the length of the sequence."
+ override def descInContext: String =
+ "The index in this sequence subscript may exceed the length of the sequence."
+ override def inlineDescWithSource(source: String): String =
+ s"The index in `$source` may exceed the length of the sequence."
}
case class SetEmpty(node: Expr[_]) extends NodeVerificationFailure {
override def code: String = "setEmpty"
override def descInContext: String = "This set may be empty."
- override def inlineDescWithSource(source: String): String = s"`$source` may be empty."
+ override def inlineDescWithSource(source: String): String =
+ s"`$source` may be empty."
}
sealed trait VectorBoundFailure extends FrontendSubscriptError with BuiltinError
-case class VectorBoundNegative(node: Expr[_]) extends VectorBoundFailure with NodeVerificationFailure {
+case class VectorBoundNegative(node: Expr[_])
+ extends VectorBoundFailure with NodeVerificationFailure {
override def code: String = "vecIndexNegative"
- override def descInContext: String = "The index in this vector subscript may be negative."
- override def inlineDescWithSource(source: String): String = s"The index in `$source` may be negative."
+ override def descInContext: String =
+ "The index in this vector subscript may be negative."
+ override def inlineDescWithSource(source: String): String =
+ s"The index in `$source` may be negative."
}
-case class VectorBoundExceedsLength(node: Expr[_]) extends VectorBoundFailure with NodeVerificationFailure {
+case class VectorBoundExceedsLength(node: Expr[_])
+ extends VectorBoundFailure with NodeVerificationFailure {
override def code: String = "vecIndexExceedsLength"
- override def descInContext: String = "The index in this vector subscript may exceed the length of the vector."
- override def inlineDescWithSource(source: String): String = s"The index in `$source` may exceed the length of the vector."
+ override def descInContext: String =
+ "The index in this vector subscript may exceed the length of the vector."
+ override def inlineDescWithSource(source: String): String =
+ s"The index in `$source` may exceed the length of the vector."
}
-
sealed trait ForkFailure extends VerificationFailure
-case class ForkNull(node: Fork[_]) extends ForkFailure with NodeVerificationFailure {
+case class ForkNull(node: Fork[_])
+ extends ForkFailure with NodeVerificationFailure {
override def code: String = "forkNull"
override def descInContext: String = "This runnable may be null."
- override def inlineDescWithSource(source: String): String = s"The runnable in `$source` may be null."
+ override def inlineDescWithSource(source: String): String =
+ s"The runnable in `$source` may be null."
}
-case class RunnableNotIdle(node: Fork[_]) extends ForkFailure with NodeVerificationFailure {
+case class RunnableNotIdle(node: Fork[_])
+ extends ForkFailure with NodeVerificationFailure {
override def code: String = "running"
- override def descInContext: String = "This runnable may not be idle. (Hint: make sure the constructor ensures idle(this))"
- override def inlineDescWithSource(source: String): String = s"The runnable in `$source` may not be idle."
+ override def descInContext: String =
+ "This runnable may not be idle. (Hint: make sure the constructor ensures idle(this))"
+ override def inlineDescWithSource(source: String): String =
+ s"The runnable in `$source` may not be idle."
}
-case class RunnablePreconditionNotEstablished(node: Fork[_], failure: ContractFailure) extends ForkFailure with WithContractFailure {
+case class RunnablePreconditionNotEstablished(
+ node: Fork[_],
+ failure: ContractFailure,
+) extends ForkFailure with WithContractFailure {
override def baseCode: String = "forkPre"
- override def descInContext: String = "The precondition of the runnable may not hold, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"The precondition of the runnable in `$node` may not hold, since $failure."
+ override def descInContext: String =
+ "The precondition of the runnable may not hold, since"
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"The precondition of the runnable in `$node` may not hold, since $failure."
}
sealed trait JoinFailure extends VerificationFailure
-case class JoinNull(node: Join[_]) extends JoinFailure with NodeVerificationFailure {
+case class JoinNull(node: Join[_])
+ extends JoinFailure with NodeVerificationFailure {
override def code: String = "joinNull"
override def descInContext: String = "This runnable may be null."
- override def inlineDescWithSource(source: String): String = s"The runnable in `$source` may be null."
+ override def inlineDescWithSource(source: String): String =
+ s"The runnable in `$source` may be null."
}
-case class RunnableNotRunning(node: Join[_]) extends JoinFailure with NodeVerificationFailure {
+case class RunnableNotRunning(node: Join[_])
+ extends JoinFailure with NodeVerificationFailure {
override def code: String = "idle"
override def descInContext: String = "This runnable may not be running."
- override def inlineDescWithSource(source: String): String = s"The runnable in `$source` may not be running."
+ override def inlineDescWithSource(source: String): String =
+ s"The runnable in `$source` may not be running."
}
sealed trait KernelFailure extends VerificationFailure
-case class KernelPostconditionFailed(failure: ContractFailure, eitherNode: Either[CGpgpuKernelSpecifier[_], CPPLambdaDefinition[_]]) extends KernelFailure with WithContractFailure {
+case class KernelPostconditionFailed(
+ failure: ContractFailure,
+ eitherNode: Either[CGpgpuKernelSpecifier[_], CPPLambdaDefinition[_]],
+) extends KernelFailure with WithContractFailure {
override def baseCode: String = "postFailed"
- override def descInContext: String = "The postcondition of this kernel may not hold, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"The postcondition of `$node` may not hold, since $failure."
- override def node: Node[_] = eitherNode match {
- case Left(cgpuKernelSpec) => cgpuKernelSpec
- case Right(cppLambdaDef) => cppLambdaDef
- }
+ override def descInContext: String =
+ "The postcondition of this kernel may not hold, since"
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"The postcondition of `$node` may not hold, since $failure."
+ override def node: Node[_] =
+ eitherNode match {
+ case Left(cgpuKernelSpec) => cgpuKernelSpec
+ case Right(cppLambdaDef) => cppLambdaDef
+ }
}
-case class KernelPredicateNotInjective(kernel: Either[CGpgpuKernelSpecifier[_], CPPLambdaDefinition[_]], predicate: Expr[_]) extends KernelFailure {
+case class KernelPredicateNotInjective(
+ kernel: Either[CGpgpuKernelSpecifier[_], CPPLambdaDefinition[_]],
+ predicate: Expr[_],
+) extends KernelFailure {
override def code: String = "kernelNotInjective"
override def position: String = predicate.o.shortPositionText
override def desc: String = {
- val kernelOrigin = kernel match {
- case Left(cgpuKernelSpec) => cgpuKernelSpec.o
- case Right(cppLambdaDef) => cppLambdaDef.o
- }
+ val kernelOrigin =
+ kernel match {
+ case Left(cgpuKernelSpec) => cgpuKernelSpec.o
+ case Right(cppLambdaDef) => cppLambdaDef.o
+ }
Message.messagesInContext(
- (kernelOrigin, "This kernel causes the formulas in its body to be quantified over all threads, ..."),
- (predicate.o, "... but this expression could not be simplified, and the Perm location is not injective in the thread variables." + errUrl),
+ (
+ kernelOrigin,
+ "This kernel causes the formulas in its body to be quantified over all threads, ...",
+ ),
+ (
+ predicate.o,
+ "... but this expression could not be simplified, and the Perm location is not injective in the thread variables." +
+ errUrl,
+ ),
)
}
@@ -523,62 +747,111 @@ case class KernelPredicateNotInjective(kernel: Either[CGpgpuKernelSpecifier[_],
}
sealed trait KernelBarrierFailure extends VerificationFailure
-case class KernelBarrierNotEstablished(failure: ContractFailure, node: GpgpuBarrier[_]) extends KernelBarrierFailure with WithContractFailure {
+case class KernelBarrierNotEstablished(
+ failure: ContractFailure,
+ node: GpgpuBarrier[_],
+) extends KernelBarrierFailure with WithContractFailure {
override def baseCode: String = "notEstablished"
- override def descInContext: String = "The precondition of this barrier may not hold, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"The precondition of `$node` may not hold, since $failure."
+ override def descInContext: String =
+ "The precondition of this barrier may not hold, since"
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"The precondition of `$node` may not hold, since $failure."
}
-case class KernelBarrierInconsistent(failure: ContractFailure, node: GpgpuBarrier[_]) extends KernelBarrierFailure with WithContractFailure {
+case class KernelBarrierInconsistent(
+ failure: ContractFailure,
+ node: GpgpuBarrier[_],
+) extends KernelBarrierFailure with WithContractFailure {
override def baseCode: String = "inconsistent"
- override def descInContext: String = "The precondition of this barrier is not consistent with the postcondition, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"The precondition of `$node` is not consistent with its postcondition, since $failure."
+ override def descInContext: String =
+ "The precondition of this barrier is not consistent with the postcondition, since"
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"The precondition of `$node` is not consistent with its postcondition, since $failure."
}
-case class KernelBarrierInvariantBroken(failure: ContractFailure, node: GpgpuBarrier[_]) extends KernelBarrierFailure with WithContractFailure {
+case class KernelBarrierInvariantBroken(
+ failure: ContractFailure,
+ node: GpgpuBarrier[_],
+) extends KernelBarrierFailure with WithContractFailure {
override def baseCode: String = "barrierInvariant"
- override def descInContext: String = "The barrier may not re-establish the used invariants, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"`$node` may not re-established the used invariants, since $failure."
+ override def descInContext: String =
+ "The barrier may not re-establish the used invariants, since"
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"`$node` may not re-established the used invariants, since $failure."
}
-case class ParInvariantNotEstablished(failure: ContractFailure, node: ParInvariant[_]) extends WithContractFailure {
+case class ParInvariantNotEstablished(
+ failure: ContractFailure,
+ node: ParInvariant[_],
+) extends WithContractFailure {
override def baseCode: String = "notEstablished"
- override def descInContext: String = "This parallel invariant may not be established, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"`$node` may not be established, since $failure."
+ override def descInContext: String =
+ "This parallel invariant may not be established, since"
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"`$node` may not be established, since $failure."
}
-case class ParInvariantNotMaintained(failure: ContractFailure, node: ParAtomic[_]) extends WithContractFailure {
+case class ParInvariantNotMaintained(
+ failure: ContractFailure,
+ node: ParAtomic[_],
+) extends WithContractFailure {
override def baseCode: String = "notMaintained"
- override def descInContext: String = "The parallel invariant may not be maintained, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"`$node` may not be maintained, since $failure."
+ override def descInContext: String =
+ "The parallel invariant may not be maintained, since"
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"`$node` may not be maintained, since $failure."
}
sealed trait ParBarrierFailure extends VerificationFailure
-case class ParBarrierNotEstablished(failure: ContractFailure, node: ParBarrier[_]) extends ParBarrierFailure with WithContractFailure {
+case class ParBarrierNotEstablished(
+ failure: ContractFailure,
+ node: ParBarrier[_],
+) extends ParBarrierFailure with WithContractFailure {
override def baseCode: String = "notEstablished"
- override def descInContext: String = "The precondition of this barrier may not hold, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"The precondition of `$node` may not hold, since $failure."
+ override def descInContext: String =
+ "The precondition of this barrier may not hold, since"
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"The precondition of `$node` may not hold, since $failure."
}
-case class ParBarrierInconsistent(failure: ContractFailure, node: ParBarrier[_]) extends ParBarrierFailure with WithContractFailure {
+case class ParBarrierInconsistent(failure: ContractFailure, node: ParBarrier[_])
+ extends ParBarrierFailure with WithContractFailure {
override def baseCode: String = "inconsistent"
- override def descInContext: String = "The precondition of this barrier is not consistent with the postcondition, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"The precondition of `$node` is not consistent with its postcondition, since $failure."
+ override def descInContext: String =
+ "The precondition of this barrier is not consistent with the postcondition, since"
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"The precondition of `$node` is not consistent with its postcondition, since $failure."
}
-case class ParBarrierMayNotThrow(node: ParBarrier[_]) extends ParBarrierFailure with NodeVerificationFailure {
+case class ParBarrierMayNotThrow(node: ParBarrier[_])
+ extends ParBarrierFailure with NodeVerificationFailure {
override def code: String = "barrierThrows"
- override def descInContext: String = "The proof hint for this barrier may throw an exception."
- override def inlineDescWithSource(source: String): String = s"The proof hint of `$source` may throw an exception."
+ override def descInContext: String =
+ "The proof hint for this barrier may throw an exception."
+ override def inlineDescWithSource(source: String): String =
+ s"The proof hint of `$source` may throw an exception."
}
-case class ParBarrierInvariantBroken(failure: ContractFailure, node: ParBarrier[_]) extends ParBarrierFailure with WithContractFailure {
+case class ParBarrierInvariantBroken(
+ failure: ContractFailure,
+ node: ParBarrier[_],
+) extends ParBarrierFailure with WithContractFailure {
override def baseCode: String = "barrierInvariant"
- override def descInContext: String = "The barrier may not re-establish the used invariants, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"`$node` may not re-established the used invariants, since $failure."
+ override def descInContext: String =
+ "The barrier may not re-establish the used invariants, since"
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"`$node` may not re-established the used invariants, since $failure."
}
sealed trait ParBlockFailure extends VerificationFailure
-case class ParPredicateNotInjective(block: ParBlock[_], predicate: Expr[_]) extends ParBlockFailure {
+case class ParPredicateNotInjective(block: ParBlock[_], predicate: Expr[_])
+ extends ParBlockFailure {
override def code: String = "parNotInjective"
override def position: String = predicate.o.shortPositionText
override def desc: String =
Message.messagesInContext(
- (block.o, "This parallel block causes the formulas in its body to be quantified over all threads, ..."),
- (predicate.o, "... but this expression could not be simplified, and the Perm location is not injective in the thread variables." + errUrl),
+ (
+ block.o,
+ "This parallel block causes the formulas in its body to be quantified over all threads, ...",
+ ),
+ (
+ predicate.o,
+ "... but this expression could not be simplified, and the Perm location is not injective in the thread variables." +
+ errUrl,
+ ),
)
override def inlineDesc: String =
@@ -586,78 +859,117 @@ case class ParPredicateNotInjective(block: ParBlock[_], predicate: Expr[_]) exte
}
sealed trait ParBlockContractFailure extends ParBlockFailure
-case class ParPreconditionFailed(failure: ContractFailure, node: ParRegion[_]) extends ParBlockContractFailure with WithContractFailure {
+case class ParPreconditionFailed(failure: ContractFailure, node: ParRegion[_])
+ extends ParBlockContractFailure with WithContractFailure {
override def baseCode: String = "parPreFailed"
- override def descInContext: String = "The precondition of this parallel region may not hold, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"The precondition of `$node` may not hold, since $failure."
+ override def descInContext: String =
+ "The precondition of this parallel region may not hold, since"
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"The precondition of `$node` may not hold, since $failure."
}
-case class ParBlockPostconditionFailed(failure: ContractFailure, node: ParBlock[_]) extends ParBlockContractFailure with WithContractFailure {
+case class ParBlockPostconditionFailed(
+ failure: ContractFailure,
+ node: ParBlock[_],
+) extends ParBlockContractFailure with WithContractFailure {
override def baseCode: String = "parPostFailed"
- override def descInContext: String = "The postcondition of this parallel block may not hold, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"The postcondition of `$node` may not hold, since $failure."
+ override def descInContext: String =
+ "The postcondition of this parallel block may not hold, since"
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"The postcondition of `$node` may not hold, since $failure."
}
-case class ParBlockMayNotThrow(node: ParBlock[_]) extends ParBlockContractFailure with NodeVerificationFailure {
+case class ParBlockMayNotThrow(node: ParBlock[_])
+ extends ParBlockContractFailure with NodeVerificationFailure {
override def code: String = "parThrows"
- override def descInContext: String = s"The body of this parallel block may throw an exception."
- override def inlineDescWithSource(source: String): String = s"The body of `$source` may throw an exception."
+ override def descInContext: String =
+ s"The body of this parallel block may throw an exception."
+ override def inlineDescWithSource(source: String): String =
+ s"The body of `$source` may throw an exception."
}
-sealed trait BuiltinError extends FrontendDerefError with FrontendInvocationError
-case class OptionNone(node: OptGet[_]) extends BuiltinError with NodeVerificationFailure {
+sealed trait BuiltinError
+ extends FrontendDerefError with FrontendInvocationError
+case class OptionNone(node: OptGet[_])
+ extends BuiltinError with NodeVerificationFailure {
override def code: String = "optNone"
override def descInContext: String = "Option may be empty."
- override def inlineDescWithSource(source: String): String = s"Option in `$source` may be empty."
+ override def inlineDescWithSource(source: String): String =
+ s"Option in `$source` may be empty."
}
-case class NotRight(node: GetRight[_]) extends BuiltinError with NodeVerificationFailure {
+case class NotRight(node: GetRight[_])
+ extends BuiltinError with NodeVerificationFailure {
override def code: String = "left"
override def descInContext: String = "Either may be left."
- override def inlineDescWithSource(source: String): String = s"Either in `$source` may be left."
+ override def inlineDescWithSource(source: String): String =
+ s"Either in `$source` may be left."
}
-case class NotLeft(node: GetLeft[_]) extends BuiltinError with NodeVerificationFailure {
+case class NotLeft(node: GetLeft[_])
+ extends BuiltinError with NodeVerificationFailure {
override def code: String = "right"
override def descInContext: String = "Either may be right."
- override def inlineDescWithSource(source: String): String = s"Either in `$source` may be right."
+ override def inlineDescWithSource(source: String): String =
+ s"Either in `$source` may be right."
}
-case class MapKeyError(node: MapGet[_]) extends BuiltinError with FrontendSubscriptError with NodeVerificationFailure {
+case class MapKeyError(node: MapGet[_])
+ extends BuiltinError
+ with FrontendSubscriptError
+ with NodeVerificationFailure {
override def code: String = "mapKey"
override def descInContext: String = "Map may not contain this key."
- override def inlineDescWithSource(source: String): String = s"Map in `$source` may not contain that key."
+ override def inlineDescWithSource(source: String): String =
+ s"Map in `$source` may not contain that key."
}
-case class MallocSize(node: Expr[_]) extends BuiltinError with NodeVerificationFailure {
+case class MallocSize(node: Expr[_])
+ extends BuiltinError with NodeVerificationFailure {
override def code: String = "mallocNegativeSize"
override def descInContext: String = "Argument of malloc may be negative."
- override def inlineDescWithSource(source: String): String = s"Size `$source` in malloc may be negative."
+ override def inlineDescWithSource(source: String): String =
+ s"Size `$source` in malloc may be negative."
}
sealed trait ArraySizeError extends VerificationFailure
sealed trait ArraySubscriptError extends FrontendSubscriptError
sealed trait ArrayLocationError extends ArraySubscriptError
sealed trait AnyStarError extends VerificationFailure
-case class ArrayNull(node: Expr[_]) extends ArrayLocationError with BuiltinError with AnyStarError with NodeVerificationFailure {
+case class ArrayNull(node: Expr[_])
+ extends ArrayLocationError
+ with BuiltinError
+ with AnyStarError
+ with NodeVerificationFailure {
override def code: String = "arrayNull"
override def descInContext: String = "Array may be null."
- override def inlineDescWithSource(source: String): String = s"Array `$source` may be null."
+ override def inlineDescWithSource(source: String): String =
+ s"Array `$source` may be null."
}
-case class ArraySize(node: Expr[_]) extends ArraySizeError with NodeVerificationFailure {
+case class ArraySize(node: Expr[_])
+ extends ArraySizeError with NodeVerificationFailure {
override def code: String = "arraySize"
override def descInContext: String = "Array size may be negative."
- override def inlineDescWithSource(source: String): String = s"Size of `$source` may be negative."
+ override def inlineDescWithSource(source: String): String =
+ s"Size of `$source` may be negative."
}
-case class ArrayBounds(node: Node[_]) extends ArrayLocationError with NodeVerificationFailure {
+case class ArrayBounds(node: Node[_])
+ extends ArrayLocationError with NodeVerificationFailure {
override def code: String = "arrayBounds"
- override def descInContext: String = "Index may be negative, or exceed the length of the array."
- override def inlineDescWithSource(source: String): String = s"Index `$source` may be negative, or exceed the length of the array."
+ override def descInContext: String =
+ "Index may be negative, or exceed the length of the array."
+ override def inlineDescWithSource(source: String): String =
+ s"Index `$source` may be negative, or exceed the length of the array."
}
-case class ArrayInsufficientPermission(node: Expr[_]) extends ArraySubscriptError with NodeVerificationFailure {
+case class ArrayInsufficientPermission(node: Expr[_])
+ extends ArraySubscriptError with NodeVerificationFailure {
override def code: String = "arrayPerm"
- override def descInContext: String = "There may be insufficient permission to access the array."
- override def inlineDescWithSource(source: String): String = s"There may be insufficient permission to access `$source`."
+ override def descInContext: String =
+ "There may be insufficient permission to access the array."
+ override def inlineDescWithSource(source: String): String =
+ s"There may be insufficient permission to access `$source`."
}
sealed trait ArrayValuesError extends NodeVerificationFailure {
def node: Values[_]
- override def descInContext: String = s"Array values invocation may fail, since $reason."
- override def inlineDescWithSource(source: String): String = s"`$source` may fail, since $reason."
+ override def descInContext: String =
+ s"Array values invocation may fail, since $reason."
+ override def inlineDescWithSource(source: String): String =
+ s"`$source` may fail, since $reason."
def reason: String
}
@@ -675,95 +987,138 @@ case class ArrayValuesFromToOrder(node: Values[_]) extends ArrayValuesError {
}
case class ArrayValuesToLength(node: Values[_]) extends ArrayValuesError {
override def code: String = "toLength"
- override def reason = "the end of the range may exceed the length of the array"
+ override def reason =
+ "the end of the range may exceed the length of the array"
}
case class ArrayValuesPerm(node: Values[_]) extends ArrayValuesError {
override def code: String = "valuesPerm"
- override def reason = "there may be insufficient permission to access the array at the specified range"
+ override def reason =
+ "there may be insufficient permission to access the array at the specified range"
}
sealed trait PointerSubscriptError extends FrontendSubscriptError
-sealed trait PointerDerefError extends PointerSubscriptError with FrontendDerefError
+sealed trait PointerDerefError
+ extends PointerSubscriptError with FrontendDerefError
sealed trait PointerLocationError extends PointerDerefError
sealed trait PointerAddError extends FrontendAdditiveError
sealed trait PointerFreeError extends FrontendInvocationError
-case class PointerOffsetNonZero(node: Expr[_]) extends PointerFreeError with NodeVerificationFailure {
+case class PointerOffsetNonZero(node: Expr[_])
+ extends PointerFreeError with NodeVerificationFailure {
override def code: String = "ptrOffsetNonZero"
- override def descInContext: String = "Free can only be called on pointers which are allocated and are at the start of the pointer block."
- override def inlineDescWithSource(source: String): String = s"Pointer in `$source` cannot be freed due to invalid pointer block."
+ override def descInContext: String =
+ "Free can only be called on pointers which are allocated and are at the start of the pointer block."
+ override def inlineDescWithSource(source: String): String =
+ s"Pointer in `$source` cannot be freed due to invalid pointer block."
}
-case class PointerInsufficientFreePermission(node: Expr[_]) extends PointerFreeError with NodeVerificationFailure {
+case class PointerInsufficientFreePermission(node: Expr[_])
+ extends PointerFreeError with NodeVerificationFailure {
override def code: String = "ptrFreePerm"
- override def descInContext: String = "Not enough permission to free the whole pointer block."
- override def inlineDescWithSource(source: String): String = s"Pointer in `$source` cannot be freed due to insufficient permission."
+ override def descInContext: String =
+ "Not enough permission to free the whole pointer block."
+ override def inlineDescWithSource(source: String): String =
+ s"Pointer in `$source` cannot be freed due to insufficient permission."
}
-case class GenericPointerFreeError(node: Expr[_]) extends PointerFreeError with NodeVerificationFailure {
+case class GenericPointerFreeError(node: Expr[_])
+ extends PointerFreeError with NodeVerificationFailure {
override def code: String = "ptrFreeError"
override def descInContext: String = "Pointer block cannot be freed."
- override def inlineDescWithSource(source: String): String = s"Pointer in `$source` cannot be freed."
+ override def inlineDescWithSource(source: String): String =
+ s"Pointer in `$source` cannot be freed."
}
-case class PointerInsufficientFreeFieldPermission(node: Expr[_], field: String) extends PointerFreeError with NodeVerificationFailure {
+case class PointerInsufficientFreeFieldPermission(node: Expr[_], field: String)
+ extends PointerFreeError with NodeVerificationFailure {
override def code: String = "ptrFreeFieldError"
- override def descInContext: String = s"Not enough permission to free the whole pointer block, since we miss permission for field `$field`"
- override def inlineDescWithSource(source: String): String = s"Pointer in `$source` cannot be freed."
+ override def descInContext: String =
+ s"Not enough permission to free the whole pointer block, since we miss permission for field `$field`"
+ override def inlineDescWithSource(source: String): String =
+ s"Pointer in `$source` cannot be freed."
}
-case class PointerNull(node: Expr[_]) extends PointerLocationError with PointerAddError with PointerFreeError with NodeVerificationFailure {
+case class PointerNull(node: Expr[_])
+ extends PointerLocationError
+ with PointerAddError
+ with PointerFreeError
+ with NodeVerificationFailure {
override def code: String = "ptrNull"
override def descInContext: String = "Pointer may be null."
- override def inlineDescWithSource(source: String): String = s"Pointer in `$source` may be null."
+ override def inlineDescWithSource(source: String): String =
+ s"Pointer in `$source` may be null."
}
-case class PointerBounds(node: Node[_]) extends PointerSubscriptError with PointerAddError with NodeVerificationFailure {
+case class PointerBounds(node: Node[_])
+ extends PointerSubscriptError
+ with PointerAddError
+ with NodeVerificationFailure {
override def code: String = "ptrBlock"
- override def descInContext: String = "The offset to the pointer may be outside the bounds of the allocated memory area that the pointer is in."
- override def inlineDescWithSource(source: String): String = s"The offset in `$source` may be outside the bounds of the allocated memory area that the pointer is in."
+ override def descInContext: String =
+ "The offset to the pointer may be outside the bounds of the allocated memory area that the pointer is in."
+ override def inlineDescWithSource(source: String): String =
+ s"The offset in `$source` may be outside the bounds of the allocated memory area that the pointer is in."
}
-case class PointerInsufficientPermission(node: Expr[_]) extends PointerDerefError with NodeVerificationFailure {
+case class PointerInsufficientPermission(node: Expr[_])
+ extends PointerDerefError with NodeVerificationFailure {
override def code: String = "ptrPerm"
- override def descInContext: String = "There may be insufficient permission to dereference the pointer."
- override def inlineDescWithSource(source: String): String = s"There may be insufficient permission to dereference `$source`."
+ override def descInContext: String =
+ "There may be insufficient permission to dereference the pointer."
+ override def inlineDescWithSource(source: String): String =
+ s"There may be insufficient permission to dereference `$source`."
}
sealed trait LockRegionFailure extends VerificationFailure
sealed trait LockFailure extends LockRegionFailure
-case class LockObjectNull(node: Node[_]) extends NodeVerificationFailure with LockFailure {
+case class LockObjectNull(node: Node[_])
+ extends NodeVerificationFailure with LockFailure {
override def code: String = "lockNull"
override def descInContext: String = "Lock target may be null"
- override def inlineDescWithSource(source: String): String = s"Lock target in `$source` may be null."
+ override def inlineDescWithSource(source: String): String =
+ s"Lock target in `$source` may be null."
}
-case class LockNotCommitted(node: Lock[_]) extends NodeVerificationFailure with LockFailure {
+case class LockNotCommitted(node: Lock[_])
+ extends NodeVerificationFailure with LockFailure {
override def code: String = "lockNotCommitted"
- override def descInContext: String = "Lock target may not yet have committed the lock invariant"
- override def inlineDescWithSource(source: String): String = s"Lock target in `$source` may not yet have committed the lock invariant."
+ override def descInContext: String =
+ "Lock target may not yet have committed the lock invariant"
+ override def inlineDescWithSource(source: String): String =
+ s"Lock target in `$source` may not yet have committed the lock invariant."
}
sealed trait UnlockFailure extends LockRegionFailure
-case class UnlockInvariantFailed(node: Unlock[_], failure: ContractFailure) extends UnlockFailure with WithContractFailure {
+case class UnlockInvariantFailed(node: Unlock[_], failure: ContractFailure)
+ extends UnlockFailure with WithContractFailure {
override def baseCode: String = "invariantFailed"
- override def descInContext: String = "The lock invariant may not be exhaled here, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"`$node` may fail, since $failure."
+ override def descInContext: String =
+ "The lock invariant may not be exhaled here, since"
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"`$node` may fail, since $failure."
}
-case class LockTokenNotHeld(node: Unlock[_], failure: ContractFailure) extends UnlockFailure with WithContractFailure {
+case class LockTokenNotHeld(node: Unlock[_], failure: ContractFailure)
+ extends UnlockFailure with WithContractFailure {
override def baseCode: String = "heldFailed"
- override def descInContext: String = "The token that indicates the lock is locked (`held(obj)`) may not be exhaled here, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"`$node` may fail, since the `held` resource may not be exhaled here, since $failure."
+ override def descInContext: String =
+ "The token that indicates the lock is locked (`held(obj)`) may not be exhaled here, since"
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"`$node` may fail, since the `held` resource may not be exhaled here, since $failure."
}
sealed trait ConstructorFailure extends VerificationFailure
-case class CommitFailed(node: Commit[_], failure: ContractFailure) extends ConstructorFailure with WithContractFailure {
+case class CommitFailed(node: Commit[_], failure: ContractFailure)
+ extends ConstructorFailure with WithContractFailure {
override def baseCode: String = "commitFailed"
- override def descInContext: String = "Committing the defined resources to the lock invariant may not be possible here, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"`$node` may not commit the defined resources to the lock invariant, since $failure."
+ override def descInContext: String =
+ "Committing the defined resources to the lock invariant may not be possible here, since"
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"`$node` may not commit the defined resources to the lock invariant, since $failure."
}
-case class NotifyFailed(node: Notify[_], failure: ContractFailure) extends WithContractFailure {
+case class NotifyFailed(node: Notify[_], failure: ContractFailure)
+ extends WithContractFailure {
override def baseCode: String = "heldFailed"
- override def descInContext: String = "The token that indicated the lock is locked (`held(obj)`) may not be asserted here, since"
+ override def descInContext: String =
+ "The token that indicated the lock is locked (`held(obj)`) may not be asserted here, since"
override def inlineDescWithSource(node: String, failure: String): String =
s"`$node` may fail, since the token that indicated the lock is locked (`held(obj)`) may not be asserted here, since $failure."
}
@@ -771,18 +1126,22 @@ case class NotifyFailed(node: Notify[_], failure: ContractFailure) extends WithC
case class ThrowNull(node: Throw[_]) extends NodeVerificationFailure {
override def code: String = "null"
override def descInContext: String = "The value thrown here may be null."
- override def inlineDescWithSource(source: String): String = s"`$source` may throw null."
+ override def inlineDescWithSource(source: String): String =
+ s"`$source` may throw null."
}
case class ScaleNegative(node: Scale[_]) extends NodeVerificationFailure {
override def code: String = "scaleNeg"
override def descInContext: String = "The scale value here may be negative."
- override def inlineDescWithSource(source: String): String = s"The scale in `$source` may be negative."
+ override def inlineDescWithSource(source: String): String =
+ s"The scale in `$source` may be negative."
}
-case class NontrivialUnsatisfiable(node: ApplicableContract[_]) extends NodeVerificationFailure with BipConstructorFailure {
+case class NontrivialUnsatisfiable(node: ApplicableContract[_])
+ extends NodeVerificationFailure with BipConstructorFailure {
override def code: String = "unsatisfiable"
- override def descInContext: String = "The precondition of this contract may be unsatisfiable. If this is intentional, replace it with `requires false`."
+ override def descInContext: String =
+ "The precondition of this contract may be unsatisfiable. If this is intentional, replace it with `requires false`."
override def inlineDescWithSource(source: String): String =
s"The precondition in `$source` may be unsatisfiable."
}
@@ -790,18 +1149,23 @@ case class NontrivialUnsatisfiable(node: ApplicableContract[_]) extends NodeVeri
sealed trait UnsafeCoercion extends NodeVerificationFailure
case class CoerceRatZFracFailed(node: Expr[_]) extends UnsafeCoercion {
override def code: String = "ratZfrac"
- override def descInContext: String = "Rational may exceed the bounds of zfrac: [0, 1]"
- override def inlineDescWithSource(source: String): String = s"`$source` may exceed the bounds of zfrac: [0, 1]."
+ override def descInContext: String =
+ "Rational may exceed the bounds of zfrac: [0, 1]"
+ override def inlineDescWithSource(source: String): String =
+ s"`$source` may exceed the bounds of zfrac: [0, 1]."
}
case class CoerceRatFracFailed(node: Expr[_]) extends UnsafeCoercion {
override def code: String = "ratFrac"
- override def descInContext: String = "Rational may exceed the bounds of frac: (0, 1]"
- override def inlineDescWithSource(source: String): String = s"`$source` may exceed the bounds of frac: (0, 1]."
+ override def descInContext: String =
+ "Rational may exceed the bounds of frac: (0, 1]"
+ override def inlineDescWithSource(source: String): String =
+ s"`$source` may exceed the bounds of frac: (0, 1]."
}
case class CoerceZFracFracFailed(node: Expr[_]) extends UnsafeCoercion {
override def code: String = "zfracFrac"
override def descInContext: String = "zfrac may be zero."
- override def inlineDescWithSource(source: String): String = s"`$source` may be zero."
+ override def inlineDescWithSource(source: String): String =
+ s"`$source` may be zero."
}
sealed trait JavaAnnotationFailure extends VerificationFailure
@@ -811,7 +1175,8 @@ sealed trait JavaImplicitConstructorFailure extends VerificationFailure
sealed trait BipConstructorFailure extends JavaConstructorFailure
sealed trait BipTransitionFailure extends JavaAnnotationFailure
-sealed trait BipTransitionContractFailure extends BipTransitionFailure with WithContractFailure {
+sealed trait BipTransitionContractFailure
+ extends BipTransitionFailure with WithContractFailure {
def transition: BipTransition[_]
def failure: ContractFailure
@@ -826,71 +1191,115 @@ sealed trait BipTransitionContractFailure extends BipTransitionFailure with With
)
}
-case class BipComponentInvariantNotEstablished(failure: ContractFailure, node: BipConstructor[_]) extends BipConstructorFailure with WithContractFailure {
+case class BipComponentInvariantNotEstablished(
+ failure: ContractFailure,
+ node: BipConstructor[_],
+) extends BipConstructorFailure with WithContractFailure {
override def baseCode: String = "bipComponentInvariantNotEstablished"
- override def descInContext: String = "In this constructor the component invariant is not established, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"The component invariant cannot be established in $node, since $failure"
+ override def descInContext: String =
+ "In this constructor the component invariant is not established, since"
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"The component invariant cannot be established in $node, since $failure"
}
-case class BipStateInvariantNotEstablished(failure: ContractFailure, node: BipConstructor[_]) extends BipConstructorFailure with WithContractFailure {
+case class BipStateInvariantNotEstablished(
+ failure: ContractFailure,
+ node: BipConstructor[_],
+) extends BipConstructorFailure with WithContractFailure {
override def baseCode: String = "bipStateInvariantNotEstablished"
- override def descInContext: String = "In this constructor the invariant of the state is not established, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"The state invariant is not established in $node, since $failure"
+ override def descInContext: String =
+ "In this constructor the invariant of the state is not established, since"
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"The state invariant is not established in $node, since $failure"
}
-case class BipComponentInvariantNotMaintained(failure: ContractFailure, transition: BipTransition[_]) extends BipTransitionContractFailure {
+case class BipComponentInvariantNotMaintained(
+ failure: ContractFailure,
+ transition: BipTransition[_],
+) extends BipTransitionContractFailure {
override def baseCode: String = "bipComponentInvariantNotMaintained"
- override def descInContext: String = "the invariant of the component is not maintained, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"The component invariant is not maintained in $node, since $failure"
+ override def descInContext: String =
+ "the invariant of the component is not maintained, since"
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"The component invariant is not maintained in $node, since $failure"
}
-case class BipStateInvariantNotMaintained(failure: ContractFailure, transition: BipTransition[_]) extends BipTransitionContractFailure {
+case class BipStateInvariantNotMaintained(
+ failure: ContractFailure,
+ transition: BipTransition[_],
+) extends BipTransitionContractFailure {
override def baseCode: String = "bipStateInvariantNotMaintained"
- override def descInContext: String = "the invariant of the state is not maintained, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"The state invariant is not maintained in $node, since $failure"
+ override def descInContext: String =
+ "the invariant of the state is not maintained, since"
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"The state invariant is not maintained in $node, since $failure"
}
-case class BipTransitionPostconditionFailure(failure: ContractFailure, transition: BipTransition[_]) extends BipTransitionContractFailure {
+case class BipTransitionPostconditionFailure(
+ failure: ContractFailure,
+ transition: BipTransition[_],
+) extends BipTransitionContractFailure {
override def baseCode: String = "bipTransitionPostconditionFailure"
override def descInContext: String = "the postcondition does not hold, since"
- override def inlineDescWithSource(node: String, failure: String): String = s"The postcondition of $node does not hold, since $failure"
+ override def inlineDescWithSource(node: String, failure: String): String =
+ s"The postcondition of $node does not hold, since $failure"
}
-case class BipTransitionPreconditionUnsatisfiable(node: BipTransition[_]) extends BipTransitionFailure with NodeVerificationFailure {
+case class BipTransitionPreconditionUnsatisfiable(node: BipTransition[_])
+ extends BipTransitionFailure with NodeVerificationFailure {
override def code: String = "bipTransitionPreconditionUnsatisfiable"
- override def descInContext: String = "The precondition of this transition is unsatisfiable"
+ override def descInContext: String =
+ "The precondition of this transition is unsatisfiable"
- override def inlineDescWithSource(source: String): String = s"Precondition unsatisfiable for transition `$source`"
+ override def inlineDescWithSource(source: String): String =
+ s"Precondition unsatisfiable for transition `$source`"
}
-case class BipOutgoingDataPreconditionUnsatisfiable(node: BipOutgoingData[_]) extends JavaAnnotationFailure with NodeVerificationFailure {
+case class BipOutgoingDataPreconditionUnsatisfiable(node: BipOutgoingData[_])
+ extends JavaAnnotationFailure with NodeVerificationFailure {
override def code: String = "bipOutgoingDataPreconditionUnsatisfiable"
- override def descInContext: String = "The precondition of this outgoing data is unsatisfiable"
+ override def descInContext: String =
+ "The precondition of this outgoing data is unsatisfiable"
- override def inlineDescWithSource(source: String): String = s"Precondition unsatisfiable for outgoing data `$source`"
+ override def inlineDescWithSource(source: String): String =
+ s"Precondition unsatisfiable for outgoing data `$source`"
}
-case class BipGuardPreconditionUnsatisfiable(node: BipGuard[_]) extends JavaAnnotationFailure with NodeVerificationFailure {
+case class BipGuardPreconditionUnsatisfiable(node: BipGuard[_])
+ extends JavaAnnotationFailure with NodeVerificationFailure {
override def code: String = "bipGuardPreconditionUnsatisfiable"
- override def descInContext: String = "The precondition of this guard (consisting of only the component invariant) is unsatisfiable"
- override def inlineDescWithSource(source: String): String = s"Precondition unsatisfiable for guard `$source`"
+ override def descInContext: String =
+ "The precondition of this guard (consisting of only the component invariant) is unsatisfiable"
+ override def inlineDescWithSource(source: String): String =
+ s"Precondition unsatisfiable for guard `$source`"
}
sealed trait BipGlueFailure extends VerificationFailure
sealed trait BipSynchronizationFailure extends BipGlueFailure
-case class TransitionPreconditionFailed(synchronization: BipTransitionSynchronization[_], transition: BipTransition[_], failure: ContractFailure)
- extends BipSynchronizationFailure with WithContractFailure {
+case class TransitionPreconditionFailed(
+ synchronization: BipTransitionSynchronization[_],
+ transition: BipTransition[_],
+ failure: ContractFailure,
+) extends BipSynchronizationFailure with WithContractFailure {
override def node: Node[_] = transition.signature
override def baseCode: String = "bipTransitionPreconditionFailed"
override def desc: String =
Message.messagesInContext(
- (synchronization.o, s"In this context there is a synchronization, in which the following ${synchronization.transitions.size} transitions and ${synchronization.wires.size} data wires participate:") +:
- (synchronization.transitions.zipWithIndex.map { case (t, i) => (t.decl.signature.o, s"transition ${i + 1},")} ++
- synchronization.wires.zipWithIndex.map { case (w, i) => (w.o, s"data wire ${i + 1},") }) :+
- (transition.signature.o, "the precondition of this transition does not hold, since") :+
- (failure.node.o, s"${failure.descCompletion} $errUrl")
- : _*
+ (
+ synchronization.o,
+ s"In this context there is a synchronization, in which the following ${synchronization
+ .transitions.size} transitions and ${synchronization.wires.size} data wires participate:",
+ ) +:
+ (synchronization.transitions.zipWithIndex.map { case (t, i) =>
+ (t.decl.signature.o, s"transition ${i + 1},")
+ } ++ synchronization.wires.zipWithIndex.map { case (w, i) =>
+ (w.o, s"data wire ${i + 1},")
+ }) :+
+ (
+ transition.signature.o,
+ "the precondition of this transition does not hold, since",
+ ) :+ (failure.node.o, s"${failure.descCompletion} $errUrl"): _*
)
// Unused
@@ -904,66 +1313,103 @@ trait Blame[-T <: VerificationFailure] {
def blame(error: T): Unit
}
-case class FilterExpectedErrorBlame(otherwise: Blame[VerificationFailure], expectedError: ExpectedError) extends Blame[VerificationFailure] {
+case class FilterExpectedErrorBlame(
+ otherwise: Blame[VerificationFailure],
+ expectedError: ExpectedError,
+) extends Blame[VerificationFailure] {
override def blame(error: VerificationFailure): Unit =
- if(expectedError.errorCode.r.matches(error.code)) {
+ if (expectedError.errorCode.r.matches(error.code)) {
expectedError.trip(error)
- } else {
- otherwise.blame(error)
- }
+ } else { otherwise.blame(error) }
}
case object BlamePathError extends SystemError {
- override def text: String = "The accounting for a pre- or postcondition is wrong: the path is empty before the layered blames are resolved, or an empty path was expected but it is not."
+ override def text: String =
+ "The accounting for a pre- or postcondition is wrong: the path is empty before the layered blames are resolved, or an empty path was expected but it is not."
}
case object PostBlameSplit {
- def apply[T >: PostconditionFailed <: VerificationFailure](blames: Map[AccountedDirection, Blame[PostconditionFailed]], default: Blame[T]): PostBlameSplit[T] =
- new PostBlameSplit(blames, default)
-
- def left[T >: PostconditionFailed <: VerificationFailure](left: Blame[PostconditionFailed], right: Blame[T]): PostBlameSplit[T] =
+ def apply[T >: PostconditionFailed <: VerificationFailure](
+ blames: Map[AccountedDirection, Blame[PostconditionFailed]],
+ default: Blame[T],
+ ): PostBlameSplit[T] = new PostBlameSplit(blames, default)
+
+ def left[T >: PostconditionFailed <: VerificationFailure](
+ left: Blame[PostconditionFailed],
+ right: Blame[T],
+ ): PostBlameSplit[T] =
new PostBlameSplit(Map(FailLeft -> left, FailRight -> right), right)
- def right[T >: PostconditionFailed <: VerificationFailure](left: Blame[T], right: Blame[PostconditionFailed]): PostBlameSplit[T] =
+ def right[T >: PostconditionFailed <: VerificationFailure](
+ left: Blame[T],
+ right: Blame[PostconditionFailed],
+ ): PostBlameSplit[T] =
new PostBlameSplit(Map(FailLeft -> left, FailRight -> right), left)
}
-case class PostBlameSplit[T >: PostconditionFailed <: VerificationFailure](blames: Map[AccountedDirection, Blame[PostconditionFailed]], default: Blame[T]) extends Blame[T] {
- override def blame(error: T): Unit = error match {
- case PostconditionFailed(path, failure, invokable) => path match {
- case Nil => throw BlamePathError
- case FailLeft +: tail => blames(FailLeft).blame(PostconditionFailed(tail, failure, invokable))
- case FailRight +: tail => blames(FailRight).blame(PostconditionFailed(tail, failure, invokable))
+case class PostBlameSplit[T >: PostconditionFailed <: VerificationFailure](
+ blames: Map[AccountedDirection, Blame[PostconditionFailed]],
+ default: Blame[T],
+) extends Blame[T] {
+ override def blame(error: T): Unit =
+ error match {
+ case PostconditionFailed(path, failure, invokable) =>
+ path match {
+ case Nil => throw BlamePathError
+ case FailLeft +: tail =>
+ blames(FailLeft)
+ .blame(PostconditionFailed(tail, failure, invokable))
+ case FailRight +: tail =>
+ blames(FailRight)
+ .blame(PostconditionFailed(tail, failure, invokable))
+ }
+ case other => default.blame(other)
}
- case other => default.blame(other)
- }
}
case object PreBlameSplit {
- def apply[T >: PreconditionFailed <: VerificationFailure](blames: Map[AccountedDirection, Blame[PreconditionFailed]], default: Blame[T]): PreBlameSplit[T] =
- new PreBlameSplit(blames, default)
-
- def left[T >: PreconditionFailed <: VerificationFailure](left: Blame[PreconditionFailed], right: Blame[T]): PreBlameSplit[T] =
+ def apply[T >: PreconditionFailed <: VerificationFailure](
+ blames: Map[AccountedDirection, Blame[PreconditionFailed]],
+ default: Blame[T],
+ ): PreBlameSplit[T] = new PreBlameSplit(blames, default)
+
+ def left[T >: PreconditionFailed <: VerificationFailure](
+ left: Blame[PreconditionFailed],
+ right: Blame[T],
+ ): PreBlameSplit[T] =
new PreBlameSplit(Map(FailLeft -> left, FailRight -> right), right)
- def right[T >: PreconditionFailed <: VerificationFailure](left: Blame[T], right: Blame[PreconditionFailed]): PreBlameSplit[T] =
+ def right[T >: PreconditionFailed <: VerificationFailure](
+ left: Blame[T],
+ right: Blame[PreconditionFailed],
+ ): PreBlameSplit[T] =
new PreBlameSplit(Map(FailLeft -> left, FailRight -> right), left)
}
-case class PreBlameSplit[T >: PreconditionFailed <: VerificationFailure](blames: Map[AccountedDirection, Blame[PreconditionFailed]], default: Blame[T]) extends Blame[T] {
- override def blame(error: T): Unit = error match {
- case PreconditionFailed(path, failure, invokable) => path match {
- case Nil =>
- throw BlamePathError
- case FailLeft +: tail => blames(FailLeft).blame(PreconditionFailed(tail, failure, invokable))
- case FailRight +: tail => blames(FailRight).blame(PreconditionFailed(tail, failure, invokable))
+case class PreBlameSplit[T >: PreconditionFailed <: VerificationFailure](
+ blames: Map[AccountedDirection, Blame[PreconditionFailed]],
+ default: Blame[T],
+) extends Blame[T] {
+ override def blame(error: T): Unit =
+ error match {
+ case PreconditionFailed(path, failure, invokable) =>
+ path match {
+ case Nil => throw BlamePathError
+ case FailLeft +: tail =>
+ blames(FailLeft).blame(PreconditionFailed(tail, failure, invokable))
+ case FailRight +: tail =>
+ blames(FailRight)
+ .blame(PreconditionFailed(tail, failure, invokable))
+ }
+ case other => default.blame(other)
}
- case other => default.blame(other)
- }
}
-case class BlameUnreachable(message: String, failure: VerificationFailure) extends VerificationError.SystemError {
- def text: String = s"An error condition was reached, which should be statically unreachable. $message. Inner failure:\n${failure.toString.split('\n').mkString(" > ", "\n > ", "")}"
+case class BlameUnreachable(message: String, failure: VerificationFailure)
+ extends VerificationError.SystemError {
+ def text: String =
+ s"An error condition was reached, which should be statically unreachable. $message. Inner failure:\n${failure
+ .toString.split('\n').mkString(" > ", "\n > ", "")}"
}
case class PanicBlame(message: String) extends Blame[VerificationFailure] {
@@ -971,40 +1417,110 @@ case class PanicBlame(message: String) extends Blame[VerificationFailure] {
throw BlameUnreachable(message, error)
}
-object NeverNone extends PanicBlame("get in `opt == none ? _ : get(opt)` should always be ok.")
-object FramedSeqIndex extends PanicBlame("access in `∀i. 0 <= i < |xs| ==> ...xs[i]...` should never be out of bounds")
-object FramedArrIndex extends PanicBlame("access in `∀i. 0 <= i < xs.length ==> Perm(xs[i], read) ** ...xs[i]...` should always be ok")
-object FramedVectorIndex extends PanicBlame("access in `∀i. 0 <= i < xs.length ==> ...xs[i]...` should never be out of bounds")
-object IteratedArrayInjective extends PanicBlame("access in `∀*i. 0 <= i < xs.length ==> Perm(xs[i], _)` should always be injective")
-object IteratedPtrInjective extends PanicBlame("access in `∀*i. Perm(xs[i], _)` should always be injective")
+object NeverNone
+ extends PanicBlame(
+ "get in `opt == none ? _ : get(opt)` should always be ok."
+ )
+object FramedSeqIndex
+ extends PanicBlame(
+ "access in `∀i. 0 <= i < |xs| ==> ...xs[i]...` should never be out of bounds"
+ )
+object FramedArrIndex
+ extends PanicBlame(
+ "access in `∀i. 0 <= i < xs.length ==> Perm(xs[i], read) ** ...xs[i]...` should always be ok"
+ )
+object FramedVectorIndex
+ extends PanicBlame(
+ "access in `∀i. 0 <= i < xs.length ==> ...xs[i]...` should never be out of bounds"
+ )
+object IteratedArrayInjective
+ extends PanicBlame(
+ "access in `∀*i. 0 <= i < xs.length ==> Perm(xs[i], _)` should always be injective"
+ )
+object IteratedPtrInjective
+ extends PanicBlame(
+ "access in `∀*i. Perm(xs[i], _)` should always be injective"
+ )
object FramedArrLoc extends PanicBlame("Bounds and non-nullness are ensured.")
-object FramedArrLength extends PanicBlame("length query in `arr == null ? _ : arr.length` should always be ok.")
-object FramedPtrBlockLength extends PanicBlame("length query in `p == null ? _ : \\pointer_block_length(p)` should always be ok.")
-object FramedPtrBlockOffset extends PanicBlame("offset query in `p == null ? _ : \\pointer_block_offset(p)` should always be ok.")
-object FramedMapGet extends PanicBlame("access in `∀k. k \\in m.keys ==> ...m[k]...` should always be ok.")
-object FramedGetLeft extends PanicBlame("left in `e.isLeft ? e.left : ...` should always be ok.")
-object FramedGetRight extends PanicBlame("right in `e.isLeft ? ... : e.right` should always be ok.")
-object AbstractApplicable extends PanicBlame("the postcondition of an abstract applicable is not checked, and hence cannot fail.")
-object TriggerPatternBlame extends PanicBlame("patterns in a trigger are not evaluated, but schematic, so any blame in a trigger is never applied.")
-object TrueSatisfiable extends PanicBlame("`requires true` is always satisfiable.")
-object FramedPtrOffset extends PanicBlame("pointer arithmetic in (0 <= \\pointer_block_offset(p)+i < \\pointer_block_length(p)) ? p+i : _ should always be ok.")
-object FramedByForPerm extends PanicBlame("Heap value access should be ok inside a forperm that frames it.")
+object FramedArrLength
+ extends PanicBlame(
+ "length query in `arr == null ? _ : arr.length` should always be ok."
+ )
+object FramedPtrBlockLength
+ extends PanicBlame(
+ "length query in `p == null ? _ : \\pointer_block_length(p)` should always be ok."
+ )
+object FramedPtrBlockOffset
+ extends PanicBlame(
+ "offset query in `p == null ? _ : \\pointer_block_offset(p)` should always be ok."
+ )
+object FramedMapGet
+ extends PanicBlame(
+ "access in `∀k. k \\in m.keys ==> ...m[k]...` should always be ok."
+ )
+object FramedGetLeft
+ extends PanicBlame("left in `e.isLeft ? e.left : ...` should always be ok.")
+object FramedGetRight
+ extends PanicBlame(
+ "right in `e.isLeft ? ... : e.right` should always be ok."
+ )
+object AbstractApplicable
+ extends PanicBlame(
+ "the postcondition of an abstract applicable is not checked, and hence cannot fail."
+ )
+object TriggerPatternBlame
+ extends PanicBlame(
+ "patterns in a trigger are not evaluated, but schematic, so any blame in a trigger is never applied."
+ )
+object TrueSatisfiable
+ extends PanicBlame("`requires true` is always satisfiable.")
+object FramedPtrOffset
+ extends PanicBlame(
+ "pointer arithmetic in (0 <= \\pointer_block_offset(p)+i < \\pointer_block_length(p)) ? p+i : _ should always be ok."
+ )
+object FramedByForPerm
+ extends PanicBlame(
+ "Heap value access should be ok inside a forperm that frames it."
+ )
object AssignLocalOk extends PanicBlame("Assigning to a local can never fail.")
-object DerefAssignTarget extends PanicBlame("Assigning to a field should trigger an error on the assignment, and not on the dereference.")
-object SubscriptAssignTarget extends PanicBlame("Assigning to a subscript should trigger an error on the assignment, and not on the subscript.")
-object DerefPerm extends PanicBlame("Dereferencing a field in a permission should trigger an error on the permission, not on the dereference.")
-object ArrayPerm extends PanicBlame("Subscripting an array in a permission should trigger an error on the permission, not on the dereference.")
-object UnresolvedDesignProblem extends PanicBlame("The design does not yet accommodate passing a meaningful blame here.")
-object PointsToDeref extends PanicBlame("The permission has already been ensured and thus cannot be insufficient.")
+object DerefAssignTarget
+ extends PanicBlame(
+ "Assigning to a field should trigger an error on the assignment, and not on the dereference."
+ )
+object SubscriptAssignTarget
+ extends PanicBlame(
+ "Assigning to a subscript should trigger an error on the assignment, and not on the subscript."
+ )
+object DerefPerm
+ extends PanicBlame(
+ "Dereferencing a field in a permission should trigger an error on the permission, not on the dereference."
+ )
+object ArrayPerm
+ extends PanicBlame(
+ "Subscripting an array in a permission should trigger an error on the permission, not on the dereference."
+ )
+object UnresolvedDesignProblem
+ extends PanicBlame(
+ "The design does not yet accommodate passing a meaningful blame here."
+ )
+object PointsToDeref
+ extends PanicBlame(
+ "The permission has already been ensured and thus cannot be insufficient."
+ )
-object JavaArrayInitializerBlame extends PanicBlame("The explicit initialization of an array in Java should never generate an assignment that exceeds the bounds of the array")
+object JavaArrayInitializerBlame
+ extends PanicBlame(
+ "The explicit initialization of an array in Java should never generate an assignment that exceeds the bounds of the array"
+ )
object UnsafeDontCare {
- case class Satisfiability(reason: String) extends UnsafeDontCare[NontrivialUnsatisfiable]
+ case class Satisfiability(reason: String)
+ extends UnsafeDontCare[NontrivialUnsatisfiable]
}
-trait UnsafeDontCare[T <: VerificationFailure] extends Blame[T] with LazyLogging {
+trait UnsafeDontCare[T <: VerificationFailure]
+ extends Blame[T] with LazyLogging {
def reason: String
override def blame(error: T): Unit = {
@@ -1013,9 +1529,14 @@ trait UnsafeDontCare[T <: VerificationFailure] extends Blame[T] with LazyLogging
}
}
-case class NoContext(inner: Blame[PreconditionFailed]) extends Blame[InvocationFailure] {
- override def blame(error: InvocationFailure): Unit = error match {
- case pre: PreconditionFailed => inner.blame(pre)
- case ctx: ContextEverywhereFailedInPre => PanicBlame("Function or method does not list any context_everywhere clauses, so cannot fail on a context_everywhere clause.").blame(ctx)
- }
+case class NoContext(inner: Blame[PreconditionFailed])
+ extends Blame[InvocationFailure] {
+ override def blame(error: InvocationFailure): Unit =
+ error match {
+ case pre: PreconditionFailed => inner.blame(pre)
+ case ctx: ContextEverywhereFailedInPre =>
+ PanicBlame(
+ "Function or method does not list any context_everywhere clauses, so cannot fail on a context_everywhere clause."
+ ).blame(ctx)
+ }
}
diff --git a/src/col/vct/col/origin/ExpectedError.scala b/src/col/vct/col/origin/ExpectedError.scala
index cbd027d683..f79e9dedf5 100644
--- a/src/col/vct/col/origin/ExpectedError.scala
+++ b/src/col/vct/col/origin/ExpectedError.scala
@@ -3,24 +3,31 @@ package vct.col.origin
import com.typesafe.scalalogging.LazyLogging
object ExpectedError {
- def apply(errorCode: String, errorRegion: Origin, blame: Blame[ExpectedErrorFailure]): ExpectedError =
- new ExpectedError(errorCode, errorRegion, blame)
+ def apply(
+ errorCode: String,
+ errorRegion: Origin,
+ blame: Blame[ExpectedErrorFailure],
+ ): ExpectedError = new ExpectedError(errorCode, errorRegion, blame)
}
-class ExpectedError(val errorCode: String, val errorRegion: Origin, val blame: Blame[ExpectedErrorFailure]) extends LazyLogging {
+class ExpectedError(
+ val errorCode: String,
+ val errorRegion: Origin,
+ val blame: Blame[ExpectedErrorFailure],
+) extends LazyLogging {
var tripped: Option[VerificationFailure] = None
def trip(failure: VerificationFailure): Unit =
tripped match {
case None =>
- logger.debug(s"Swallowing error code $errorCode at ${errorRegion.shortPositionText}")
+ logger.debug(
+ s"Swallowing error code $errorCode at ${errorRegion.shortPositionText}"
+ )
tripped = Some(failure)
case Some(leftFailure) =>
blame.blame(ExpectedErrorTrippedTwice(this, leftFailure, failure))
}
def signalDone(): Unit =
- if(tripped.isEmpty) {
- blame.blame(ExpectedErrorNotTripped(this))
- }
+ if (tripped.isEmpty) { blame.blame(ExpectedErrorNotTripped(this)) }
}
diff --git a/src/col/vct/col/origin/HideDuringTriggerGeneration.scala b/src/col/vct/col/origin/HideDuringTriggerGeneration.scala
index 7db0dc4a24..e76f407dff 100644
--- a/src/col/vct/col/origin/HideDuringTriggerGeneration.scala
+++ b/src/col/vct/col/origin/HideDuringTriggerGeneration.scala
@@ -1,8 +1,7 @@
package vct.col.origin
-/**
- * Attached to triggers that should be hidden during trigger generation. That is:
- * if there are only triggers with this attached, we should pretend that there
- * are no triggers yet.
- */
+/** Attached to triggers that should be hidden during trigger generation. That
+ * is: if there are only triggers with this attached, we should pretend that
+ * there are no triggers yet.
+ */
object HideDuringTriggerGeneration extends OriginContent
diff --git a/src/col/vct/col/origin/Name.scala b/src/col/vct/col/origin/Name.scala
index ef64a10724..51bd43b0b1 100644
--- a/src/col/vct/col/origin/Name.scala
+++ b/src/col/vct/col/origin/Name.scala
@@ -6,8 +6,7 @@ sealed trait Name {
def camel: String
def ucamel: String
- override def toString: String =
- throw new UnsupportedOperationException()
+ override def toString: String = throw new UnsupportedOperationException()
}
object Name {
@@ -22,7 +21,9 @@ object Name {
assert(parts.nonEmpty)
override def snake: String = parts.map(_.toLowerCase).mkString("_")
override def usnake: String = parts.map(_.toUpperCase).mkString("_")
- override def camel: String = (parts.head.toLowerCase +: parts.tail.map(_.toLowerCase.capitalize)).mkString("")
+ override def camel: String =
+ (parts.head.toLowerCase +: parts.tail.map(_.toLowerCase.capitalize))
+ .mkString("")
override def ucamel: String = camel.capitalize
}
@@ -39,4 +40,4 @@ object Name {
assert(parts.nonEmpty)
parts.reduce(Join)
}
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/origin/Origin.scala b/src/col/vct/col/origin/Origin.scala
index ffab0b4f75..987b16e1f4 100644
--- a/src/col/vct/col/origin/Origin.scala
+++ b/src/col/vct/col/origin/Origin.scala
@@ -9,83 +9,95 @@ import vct.result.Message.HR
import scala.collection.mutable.ArrayBuffer
import scala.reflect.ClassTag
-case object Origin {
+case object Origin {}
-}
-
-/***
- * This trait is used to box information about Origins in a structured manner.
- */
+/** * This trait is used to box information about Origins in a structured
+ * manner.
+ */
trait OriginContent {
- /**
- * Indicates the preferred name or required name for this node. The parts of a preferred name can be joined as
- * desired for the kind of declaration.
- */
+
+ /** Indicates the preferred name or required name for this node. The parts of
+ * a preferred name can be joined as desired for the kind of declaration.
+ */
def name(tail: Origin): Option[Name] = None
- /**
- * The reason that this node exists, typeset in a user-friendly way. The contexts are stacked, so context (i)
- * can say something about (i+1). For example: Seq("interpreted c source", "Interpreted from:", "c source"), or
- * Seq("check_sat method for:", "pvl source"). For this method the messages can be multiline, but should not have
- * a trailing or preceding newline.
- */
+ /** The reason that this node exists, typeset in a user-friendly way. The
+ * contexts are stacked, so context (i) can say something about (i+1). For
+ * example: Seq("interpreted c source", "Interpreted from:", "c source"), or
+ * Seq("check_sat method for:", "pvl source"). For this method the messages
+ * can be multiline, but should not have a trailing or preceding newline.
+ */
def context(tail: Origin): Option[Seq[String]] = None
- /**
- * Should have the same shape as the context method, but instead provides a sequence of breadcrumbs, e.g.:
- * Seq("check_sat", "void test() { }")
- * The part must not contain newlines. Consumers of the inline context should make sure to shorten breadcrumbs and
- * add an ellipsis where approriate, whereas the definition should not try to shorten the breadcrumb (within reason).
- */
- def inlineContext(tail: Origin, compress: Boolean = true): Option[Seq[String]] = None
-
- /**
- * Short description of the source position indicated by this origin. This should refer to the oldest cq original
- * position; not the most recent. If no OriginContent indicates a shortPosition, it should be assumed the node
- * is generated apart from any source input.
- */
+ /** Should have the same shape as the context method, but instead provides a
+ * sequence of breadcrumbs, e.g.: Seq("check_sat", "void test() { }") The
+ * part must not contain newlines. Consumers of the inline context should
+ * make sure to shorten breadcrumbs and add an ellipsis where approriate,
+ * whereas the definition should not try to shorten the breadcrumb (within
+ * reason).
+ */
+ def inlineContext(
+ tail: Origin,
+ compress: Boolean = true,
+ ): Option[Seq[String]] = None
+
+ /** Short description of the source position indicated by this origin. This
+ * should refer to the oldest cq original position; not the most recent. If
+ * no OriginContent indicates a shortPosition, it should be assumed the node
+ * is generated apart from any source input.
+ */
def shortPosition(tail: Origin): Option[String] = None
}
-/**
- * Leaf name provider, should consider modifiers like NamePrefix that follow it.
- */
+/** Leaf name provider, should consider modifiers like NamePrefix that follow
+ * it.
+ */
trait NameStrategy extends OriginContent
case class PreferredName(preferredName: Seq[String]) extends NameStrategy {
override def name(tail: Origin): Option[Name] =
- Some(Name.Preferred(
- tail.span[NameStrategy]._1.originContents.collect {
- case NamePrefix(prefix) => prefix
- }.reverse ++ preferredName
- ))
+ Some(Name.Preferred(tail.span[NameStrategy]._1.originContents.collect {
+ case NamePrefix(prefix) => prefix
+ }.reverse ++ preferredName))
}
case class NamePrefix(prefix: String) extends OriginContent
case class RequiredName(requiredName: String) extends NameStrategy {
- override def name(tail: Origin): Option[Name] = Some(Name.Required(requiredName))
+ override def name(tail: Origin): Option[Name] =
+ Some(Name.Required(requiredName))
}
case class IndirectName(name: Name) extends NameStrategy {
override def name(tail: Origin): Option[Name] =
- Some((prefix(tail).map(Seq(_)).getOrElse(Seq()) ++ Seq(name)).reduce(Name.Join))
+ Some(
+ (prefix(tail).map(Seq(_)).getOrElse(Seq()) ++ Seq(name)).reduce(Name.Join)
+ )
def prefix(tail: Origin): Option[Name] = {
- val prefix = tail.span[NameStrategy]._1.originContents.collect {
- case NamePrefix(prefix) => prefix
- }.reverse
- if(prefix.isEmpty) None else Some(Name.Preferred(prefix))
+ val prefix =
+ tail.span[NameStrategy]._1.originContents.collect {
+ case NamePrefix(prefix) => prefix
+ }.reverse
+ if (prefix.isEmpty)
+ None
+ else
+ Some(Name.Preferred(prefix))
}
}
object SourceName {
- def stringToName(name: String): Name = Name.Preferred(
- if (name.forall(c => !c.isLetter || c.isUpper)) name.split("[_]+").toIndexedSeq
- else name.split("[_]+").toIndexedSeq.flatMap(splitNameRec))
+ def stringToName(name: String): Name =
+ Name.Preferred(
+ if (name.forall(c => !c.isLetter || c.isUpper))
+ name.split("[_]+").toIndexedSeq
+ else
+ name.split("[_]+").toIndexedSeq.flatMap(splitNameRec)
+ )
private def splitNameRec(str: String): Seq[String] =
- if (str.isEmpty) Nil
+ if (str.isEmpty)
+ Nil
else {
val (left, right) = str.tail.span(_.isLower)
(str.head.toString + left) +: splitNameRec(right)
@@ -97,14 +109,17 @@ case class SourceName(name: String) extends NameStrategy {
Some(SourceName.stringToName(name))
}
-/**
- * Content that provides a bit of context here. By default, this assembles further context from the remaining
- * origin. contextHere and inlineContextHere may optionally consume some more contents, otherwise they can just
- * return the tail as is.
- */
+/** Content that provides a bit of context here. By default, this assembles
+ * further context from the remaining origin. contextHere and inlineContextHere
+ * may optionally consume some more contents, otherwise they can just return
+ * the tail as is.
+ */
trait Context extends OriginContent {
protected def contextHere(tail: Origin): (String, Origin)
- protected def inlineContextHere(tail: Origin, compress: Boolean): (String, Origin)
+ protected def inlineContextHere(
+ tail: Origin,
+ compress: Boolean,
+ ): (String, Origin)
protected def shortPositionHere(tail: Origin): (String, Origin)
override def context(tail: Origin): Option[Seq[String]] = {
@@ -112,7 +127,10 @@ trait Context extends OriginContent {
Some(head +: tailAfterContext.context.getOrElse(Nil))
}
- override def inlineContext(tail: Origin, compress: Boolean = true): Option[Seq[String]] = {
+ override def inlineContext(
+ tail: Origin,
+ compress: Boolean = true,
+ ): Option[Seq[String]] = {
val (head, tailAfterContext) = inlineContextHere(tail, compress)
Some(head +: tailAfterContext.inlineContext(compress).getOrElse(Nil))
}
@@ -123,32 +141,48 @@ trait Context extends OriginContent {
}
}
-/**
- * One or two lowercase words define the context, inline context and short position.
- * For more extended explanations you should implement a case of Context yourself.
- */
+/** One or two lowercase words define the context, inline context and short
+ * position. For more extended explanations you should implement a case of
+ * Context yourself.
+ */
case class LabelContext(label: String) extends Context {
- override protected def contextHere(tail: Origin): (String, Origin) = (s"At $label:", tail)
- override protected def inlineContextHere(tail: Origin, compress: Boolean): (String, Origin) = (label, tail)
- override protected def shortPositionHere(tail: Origin): (String, Origin) = (label, tail)
+ override protected def contextHere(tail: Origin): (String, Origin) =
+ (s"At $label:", tail)
+ override protected def inlineContextHere(
+ tail: Origin,
+ compress: Boolean,
+ ): (String, Origin) = (label, tail)
+ override protected def shortPositionHere(tail: Origin): (String, Origin) =
+ (label, tail)
}
trait Source extends Context {
def positionContext(position: PositionRange): String
- def inlinePositionContext(position: PositionRange, compress: Boolean = true): String
+ def inlinePositionContext(
+ position: PositionRange,
+ compress: Boolean = true,
+ ): String
protected def genericContext: String
protected def genericInlineContext: String
def genericShortPosition: String
- override protected def contextHere(tail: Origin): (String, Origin) = (genericContext, tail)
- override protected def inlineContextHere(tail: Origin, compress: Boolean): (String, Origin) = (genericInlineContext, tail)
- override protected def shortPositionHere(tail: Origin): (String, Origin) = (genericShortPosition, tail)
+ override protected def contextHere(tail: Origin): (String, Origin) =
+ (genericContext, tail)
+ override protected def inlineContextHere(
+ tail: Origin,
+ compress: Boolean,
+ ): (String, Origin) = (genericInlineContext, tail)
+ override protected def shortPositionHere(tail: Origin): (String, Origin) =
+ (genericShortPosition, tail)
}
case class ReadableOrigin(readable: Readable) extends Source {
def positionContext(position: PositionRange): String =
genericContext + "\n" + HR + InputOrigin.contextLines(readable, position)
- def inlinePositionContext(position: PositionRange, compress: Boolean): String = InputOrigin.inlineContext(readable, position, compress)
+ def inlinePositionContext(
+ position: PositionRange,
+ compress: Boolean,
+ ): String = InputOrigin.inlineContext(readable, position, compress)
override def genericContext: String = s"At ${readable.fileName}"
override def genericInlineContext: String = s"${readable.fileName}"
override def genericShortPosition: String = s"${readable.fileName}"
@@ -156,27 +190,38 @@ case class ReadableOrigin(readable: Readable) extends Source {
case class OriginFilename(filename: String) extends Source {
def positionContext(position: PositionRange): String = genericContext
- def inlinePositionContext(position: PositionRange, compress: Boolean): String = genericInlineContext
+ def inlinePositionContext(
+ position: PositionRange,
+ compress: Boolean,
+ ): String = genericInlineContext
override def genericContext: String = s"At $filename"
override def genericInlineContext: String = s"$filename"
override def genericShortPosition: String = s"$filename"
}
case class InlineBipContext(bipContext: String) extends Source {
- def positionContext(position: PositionRange): String = InputOrigin.contextLines(LiteralReadable("literal", bipContext), position)
- def inlinePositionContext(position: PositionRange, compress: Boolean): String = InputOrigin.inlineContext(LiteralReadable("literal", bipContext), position)
+ def positionContext(position: PositionRange): String =
+ InputOrigin.contextLines(LiteralReadable("literal", bipContext), position)
+ def inlinePositionContext(
+ position: PositionRange,
+ compress: Boolean,
+ ): String =
+ InputOrigin.inlineContext(LiteralReadable("literal", bipContext), position)
override def genericContext: String = s"From literal"
override def genericInlineContext: String = "literal"
override def genericShortPosition: String = "literal"
}
-case class PositionRange(startLineIdx: Int, endLineIdx: Int, startEndColIdx: Option[(Int, Int)]) extends Context {
+case class PositionRange(
+ startLineIdx: Int,
+ endLineIdx: Int,
+ startEndColIdx: Option[(Int, Int)],
+) extends Context {
def onlyPositionText: String =
startEndColIdx match {
case Some((startColIdx, endColIdx)) =>
- s":${startLineIdx+1}:${startColIdx+1}-:${endLineIdx+1}:${endColIdx+1}"
- case None =>
- s":${startLineIdx+1}-:${endLineIdx+1}"
+ s":${startLineIdx + 1}:${startColIdx + 1}-:${endLineIdx + 1}:${endColIdx + 1}"
+ case None => s":${startLineIdx + 1}-:${endLineIdx + 1}"
}
override protected def contextHere(tail: Origin): (String, Origin) =
@@ -185,35 +230,39 @@ case class PositionRange(startLineIdx: Int, endLineIdx: Int, startEndColIdx: Opt
case (_, None) => ("At broken position", tail)
}
- override protected def inlineContextHere(tail: Origin, compress: Boolean): (String, Origin) =
+ override protected def inlineContextHere(
+ tail: Origin,
+ compress: Boolean,
+ ): (String, Origin) =
tail.spanFind[Source] match {
- case (_, Some((source, tail))) => (source.inlinePositionContext(this, compress), tail)
+ case (_, Some((source, tail))) =>
+ (source.inlinePositionContext(this, compress), tail)
case (_, None) => ("broken position", tail)
}
override protected def shortPositionHere(tail: Origin): (String, Origin) =
tail.spanFind[Source] match {
- case (_, Some((source, tail))) => (s"${source.genericShortPosition}$onlyPositionText", tail)
+ case (_, Some((source, tail))) =>
+ (s"${source.genericShortPosition}$onlyPositionText", tail)
case (_, None) => ("broken position", tail)
}
}
-/**
- * A sequence of OriginContents. This sequence can be mutated (add, remove, replace) for convenience.
-* @param originContents The known origin contents at the time of Origin creation. Can be empty for a new Origin.
- */
-final case class Origin(originContents: Seq[OriginContent]) extends Blame[VerificationFailure] with HasContext {
+/** A sequence of OriginContents. This sequence can be mutated (add, remove,
+ * replace) for convenience.
+ * @param originContents
+ * The known origin contents at the time of Origin creation. Can be empty for
+ * a new Origin.
+ */
+final case class Origin(originContents: Seq[OriginContent])
+ extends Blame[VerificationFailure] with HasContext {
def tail: Origin = Origin(originContents.tail)
def find[T <: OriginContent](implicit tag: ClassTag[T]): Option[T] =
- originContents.collectFirst {
- case t: T => t
- }
+ originContents.collectFirst { case t: T => t }
def findAll[T <: OriginContent](implicit tag: ClassTag[T]): Seq[T] =
- originContents.collect {
- case t: T => t
- }
+ originContents.collect { case t: T => t }
def span[T <: OriginContent](implicit tag: ClassTag[T]): (Origin, Origin) = {
val (left, right) = originContents.span {
@@ -224,7 +273,9 @@ final case class Origin(originContents: Seq[OriginContent]) extends Blame[Verifi
(Origin(left), Origin(right))
}
- def spanFind[T <: OriginContent](implicit tag: ClassTag[T]): (Origin, Option[(T, Origin)]) = {
+ def spanFind[T <: OriginContent](
+ implicit tag: ClassTag[T]
+ ): (Origin, Option[(T, Origin)]) = {
val (left, Origin(right)) = span[T]
right.headOption match {
@@ -240,24 +291,22 @@ final case class Origin(originContents: Seq[OriginContent]) extends Blame[Verifi
Origin(content +: originContents)
def where(
- context: String = null,
- name: String = null,
- prefix: String = null,
- indirect: Name = null,
- ): Origin = Origin(
- Option(context).map(LabelContext).toSeq ++
- Option(name).map(name => PreferredName(Seq(name))).toSeq ++
- Option(indirect).map(name => IndirectName(name)).toSeq ++
- Option(prefix).map(NamePrefix).to(Seq) ++
- originContents
- )
-
- /**
- * Do not use to indicate a preferred name. This is to indicate the formal
- * source name in the input. Use where(name = ...) instead.
- */
- def sourceName(name: String): Origin =
- withContent(SourceName(name))
+ context: String = null,
+ name: String = null,
+ prefix: String = null,
+ indirect: Name = null,
+ ): Origin =
+ Origin(
+ Option(context).map(LabelContext).toSeq ++ Option(name)
+ .map(name => PreferredName(Seq(name))).toSeq ++ Option(indirect)
+ .map(name => IndirectName(name)).toSeq ++ Option(prefix).map(NamePrefix)
+ .to(Seq) ++ originContents
+ )
+
+ /** Do not use to indicate a preferred name. This is to indicate the formal
+ * source name in the input. Use where(name = ...) instead.
+ */
+ def sourceName(name: String): Origin = withContent(SourceName(name))
// def addStartEndLines(startIdx: Int, endIdx: Int): Origin =
// withContent(StartEndLines(startIdx, endIdx))
@@ -266,7 +315,8 @@ final case class Origin(originContents: Seq[OriginContent]) extends Blame[Verifi
// withContent(OriginCols(cols))
def getPreferredName: Option[Name] =
- originContents.headOption.flatMap(_.name(tail).orElse(tail.getPreferredName))
+ originContents.headOption
+ .flatMap(_.name(tail).orElse(tail.getPreferredName))
def getPreferredNameOrElse(name: Seq[String] = Seq("unknown")): Name =
getPreferredName.getOrElse(Name.Preferred(name))
@@ -279,23 +329,25 @@ final case class Origin(originContents: Seq[OriginContent]) extends Blame[Verifi
context.map(_.mkString("\n" + HR)).getOrElse("[unknown context]")
def inlineContext(compress: Boolean = true): Option[Seq[String]] =
- originContents.headOption.flatMap(_.inlineContext(tail, compress).orElse(tail.inlineContext(compress)))
+ originContents.headOption.flatMap(
+ _.inlineContext(tail, compress).orElse(tail.inlineContext(compress))
+ )
def inlineContextText: String =
inlineContext(true).map(_.mkString(" > ")).getOrElse("[unknown context]")
def shortPosition: Option[String] =
- originContents.headOption.flatMap(_.shortPosition(tail).orElse(tail.shortPosition))
+ originContents.headOption
+ .flatMap(_.shortPosition(tail).orElse(tail.shortPosition))
- def shortPositionText: String =
- shortPosition.getOrElse("[unknown position]")
+ def shortPositionText: String = shortPosition.getOrElse("[unknown position]")
override def blame(error: VerificationFailure): Unit = {
Logger("vct").error(error.toString)
}
def renderProgress(message: String, short: Boolean): ProgressRender =
- if(short)
+ if (short)
ProgressRender(s"$message `$inlineContextText`")
else {
val lines = messageInContext(message).split("\n").toSeq
@@ -314,36 +366,51 @@ object InputOrigin {
// ANTLR points past the last line when pointing at an EOF immediately following a newline, hence the extra line.
val lines = readable.readLines().map(_ + " ") :+ " "
- val clamp = (line: Int) => Math.max(0, Math.min(lines.size-1, line))
- val clampCol = (line: Int, col: Int) => Math.max(0, Math.min(lines(line).length-1, col))
- val numberedLine = (text: String, line: Int) => String.format("%" + f"$LINE_NUMBER_WIDTH" + "d %s\n", Int.box(line+1), text.dropRight(2))
- val replacementDash = (c: Char) => c match {
- case '\t' => "\t" // perhaps derive the tab width from terminal information at some point
- case _ => "-"
- }
- val replacementWhitespace = (c: Char) => c match {
- case '\t' => "\t"
- case _ => " "
- }
+ val clamp = (line: Int) => Math.max(0, Math.min(lines.size - 1, line))
+ val clampCol =
+ (line: Int, col: Int) =>
+ Math.max(0, Math.min(lines(line).length - 1, col))
+ val numberedLine =
+ (text: String, line: Int) =>
+ String.format(
+ "%" + f"$LINE_NUMBER_WIDTH" + "d %s\n",
+ Int.box(line + 1),
+ text.dropRight(2),
+ )
+ val replacementDash =
+ (c: Char) =>
+ c match {
+ case '\t' =>
+ "\t" // perhaps derive the tab width from terminal information at some point
+ case _ => "-"
+ }
+ val replacementWhitespace =
+ (c: Char) =>
+ c match {
+ case '\t' => "\t"
+ case _ => " "
+ }
val startLineIdx = clamp(position.startLineIdx)
val endLineIdx = clamp(position.endLineIdx)
- val cols = position.startEndColIdx.map {
- case (startColIdx, endColIdx) => (clampCol(startLineIdx, startColIdx), clampCol(endLineIdx, endColIdx))
+ val cols = position.startEndColIdx.map { case (startColIdx, endColIdx) =>
+ (clampCol(startLineIdx, startColIdx), clampCol(endLineIdx, endColIdx))
}
require(startLineIdx <= endLineIdx)
- require(startLineIdx != endLineIdx || cols.isEmpty || cols.get._1 <= cols.get._2)
+ require(
+ startLineIdx != endLineIdx || cols.isEmpty || cols.get._1 <= cols.get._2
+ )
val firstLineIdx = clamp(startLineIdx - CONTEXT)
val startContextEnd = clamp(startLineIdx + CONTEXT) + 1
val endContextStart = clamp(endLineIdx - CONTEXT)
- val endContextEnd = Math.min(lines.size-1, endLineIdx + CONTEXT) + 1
+ val endContextEnd = Math.min(lines.size - 1, endLineIdx + CONTEXT) + 1
val result = new StringBuilder
// Print any context lines before the first line
- for((line, idx) <- lines.zipWithIndex.slice(firstLineIdx, startLineIdx)) {
+ for ((line, idx) <- lines.zipWithIndex.slice(firstLineIdx, startLineIdx)) {
result.append(numberedLine(line, idx))
}
@@ -358,48 +425,54 @@ object InputOrigin {
result.append("\n")
case Some((startColIdx, endColIdx)) =>
// Leave room for [ if we start at the first character
- if(startColIdx != 0) result.append(" ")
+ if (startColIdx != 0)
+ result.append(" ")
// Print whitespace, but leave room for [ just before the first character
- lines(startLineIdx).take(startColIdx-1).map(replacementWhitespace).foreach(result.append)
+ lines(startLineIdx).take(startColIdx - 1).map(replacementWhitespace)
+ .foreach(result.append)
result.append("[")
// If [ stands in for a tab, follow it with a tab to align again. This is wrong when the tab normalizes to only one space. ¯\_(ツ)_/¯
- if(lines(startLineIdx)(startColIdx) == '\t') result.append('\t')
+ if (lines(startLineIdx)(startColIdx) == '\t')
+ result.append('\t')
- if(startLineIdx == endLineIdx) {
+ if (startLineIdx == endLineIdx) {
// Print dashes until endColIdx, as the start and end line coincide.
- lines(startLineIdx).slice(startColIdx, endColIdx).map(replacementDash).foreach(result.append)
+ lines(startLineIdx).slice(startColIdx, endColIdx).map(replacementDash)
+ .foreach(result.append)
} else {
// If the start and end line are inequal, print dashes until the end of the line.
- lines(startLineIdx).drop(startColIdx).map(replacementDash).foreach(result.append)
+ lines(startLineIdx).drop(startColIdx).map(replacementDash)
+ .foreach(result.append)
}
result.append("\n")
}
- if(startContextEnd < endContextStart) {
+ if (startContextEnd < endContextStart) {
// There are lines between the end of the starting context and the start of the ending context.
// We have to print an ellipsis between them.
// Print the tail of the start context
- for((line, idx) <- lines.zipWithIndex.slice(startLineIdx, startContextEnd)) {
- result.append(numberedLine(line, idx))
- }
+ for (
+ (line, idx) <- lines.zipWithIndex.slice(startLineIdx, startContextEnd)
+ ) { result.append(numberedLine(line, idx)) }
// An ellipsis inbetween...
result.append(" " * LINE_NUMBER_WIDTH)
- result.append(f" ... (${endContextStart - startContextEnd} lines omitted)\n")
+ result
+ .append(f" ... (${endContextStart - startContextEnd} lines omitted)\n")
// And the start of the end context + the end line.
- for((line, idx) <- lines.zipWithIndex.slice(endContextStart, endLineIdx+1)) {
- result.append(numberedLine(line, idx))
- }
+ for (
+ (line, idx) <- lines.zipWithIndex.slice(endContextStart, endLineIdx + 1)
+ ) { result.append(numberedLine(line, idx)) }
} else {
// The start context and end context connect, so just print lines up to and including the ending line
// If the start and end line coincide, this just prints nothing.
- for((line, idx) <- lines.zipWithIndex.slice(startLineIdx, endLineIdx+1)) {
- result.append(numberedLine(line, idx))
- }
+ for (
+ (line, idx) <- lines.zipWithIndex.slice(startLineIdx, endLineIdx + 1)
+ ) { result.append(numberedLine(line, idx)) }
}
// Indent for the ending context
@@ -411,22 +484,25 @@ object InputOrigin {
lines(endLineIdx).toSeq.map(replacementDash).foreach(result.append)
result.append("]\n")
case Some((startColIdx, endColIdx)) =>
- if(startLineIdx == endLineIdx) {
+ if (startLineIdx == endLineIdx) {
// When the start and end line coincide, print whitespace before the dashes until the start column
- lines(endLineIdx).take(startColIdx).map(replacementWhitespace).foreach(result.append)
- lines(endLineIdx).slice(startColIdx, endColIdx).map(replacementDash).foreach(result.append)
+ lines(endLineIdx).take(startColIdx).map(replacementWhitespace)
+ .foreach(result.append)
+ lines(endLineIdx).slice(startColIdx, endColIdx).map(replacementDash)
+ .foreach(result.append)
} else {
// When the start and end line are distinct, just fill the line with dashes until the end column.
- lines(endLineIdx).take(endColIdx).map(replacementDash).foreach(result.append)
+ lines(endLineIdx).take(endColIdx).map(replacementDash)
+ .foreach(result.append)
}
result.append("]\n")
}
// Finally, we have to print the tail of the end context.
- for((line, idx) <- lines.zipWithIndex.slice(endLineIdx+1, endContextEnd)) {
- result.append(numberedLine(line, idx))
- }
+ for (
+ (line, idx) <- lines.zipWithIndex.slice(endLineIdx + 1, endContextEnd)
+ ) { result.append(numberedLine(line, idx)) }
result.toString().stripTrailing()
}
@@ -437,32 +513,42 @@ object InputOrigin {
def compressInlineText(text: String): String = {
val sanitized = sanitizeInlineText(text)
- if(sanitized.length > MAX_INLINE_CONTEXT_WIDTH) {
+ if (sanitized.length > MAX_INLINE_CONTEXT_WIDTH) {
val len = MAX_INLINE_CONTEXT_WIDTH - INLINE_CONTEXT_ELLIPSIS.length
val startLen = len / 2
val endLen = len - startLen
- sanitizeInlineText(sanitized.take(startLen)) +
- INLINE_CONTEXT_ELLIPSIS +
+ sanitizeInlineText(sanitized.take(startLen)) + INLINE_CONTEXT_ELLIPSIS +
sanitizeInlineText(sanitized.takeRight(endLen))
- } else {
- sanitized
- }
+ } else { sanitized }
}
- def inlineContext(readable: Readable, position: PositionRange, compress: Boolean = true): String = {
- def compressF: String => String = if(compress) compressInlineText else identity[String]
- readable.readLines().slice(position.startLineIdx, position.endLineIdx + 1) match {
+ def inlineContext(
+ readable: Readable,
+ position: PositionRange,
+ compress: Boolean = true,
+ ): String = {
+ def compressF: String => String =
+ if (compress)
+ compressInlineText
+ else
+ identity[String]
+ readable.readLines()
+ .slice(position.startLineIdx, position.endLineIdx + 1) match {
case Nil => "(empty source region)"
- case line +: Nil => position.startEndColIdx match {
- case None => compressF(line)
- case Some((start, end)) => compressF(line.slice(start, end))
- }
+ case line +: Nil =>
+ position.startEndColIdx match {
+ case None => compressF(line)
+ case Some((start, end)) => compressF(line.slice(start, end))
+ }
case first +: moreLines =>
val (context, last) = (moreLines.init, moreLines.last)
position.startEndColIdx match {
case None => compressF((first +: context :+ last).mkString("\n"))
- case Some((start, end)) => compressF((first.drop(start) +: context :+ last.take(end)).mkString("\n"))
+ case Some((start, end)) =>
+ compressF(
+ (first.drop(start) +: context :+ last.take(end)).mkString("\n")
+ )
}
}
}
@@ -471,6 +557,5 @@ object InputOrigin {
case class BlameCollector() extends Blame[VerificationFailure] {
val errs: ArrayBuffer[VerificationFailure] = ArrayBuffer()
- override def blame(error: VerificationFailure): Unit =
- errs += error
-}
\ No newline at end of file
+ override def blame(error: VerificationFailure): Unit = errs += error
+}
diff --git a/src/col/vct/col/print/Ctx.scala b/src/col/vct/col/print/Ctx.scala
index ca694ebb34..1962f9f8d6 100644
--- a/src/col/vct/col/print/Ctx.scala
+++ b/src/col/vct/col/print/Ctx.scala
@@ -17,11 +17,11 @@ object Ctx {
}
case class Ctx(
- syntax: Ctx.Syntax = Ctx.PVL,
- width: Int = 120,
- tabWidth: Int = 4,
- names: Map[Declaration[_], String] = Map.empty,
- inSpec: Boolean = false,
+ syntax: Ctx.Syntax = Ctx.PVL,
+ width: Int = 120,
+ tabWidth: Int = 4,
+ names: Map[Declaration[_], String] = Map.empty,
+ inSpec: Boolean = false,
) {
def namesIn[G](node: Node[G]): Ctx =
copy(names = {
@@ -31,9 +31,14 @@ case class Ctx(
})
def name(decl: Declaration[_]): String = {
- val name = names.getOrElse(decl, s"${decl.o.getPreferredNameOrElse().ucamel}_${decl.hashCode()}")
- if((inSpec || syntax == Ctx.PVL) && Keywords.SPEC.contains(name)) "`" + name + "`"
- else name
+ val name = names.getOrElse(
+ decl,
+ s"${decl.o.getPreferredNameOrElse().ucamel}_${decl.hashCode()}",
+ )
+ if ((inSpec || syntax == Ctx.PVL) && Keywords.SPEC.contains(name))
+ "`" + name + "`"
+ else
+ name
}
def name(ref: Ref[_, _ <: Declaration[_]]): String =
diff --git a/src/col/vct/col/print/Doc.scala b/src/col/vct/col/print/Doc.scala
index e433e1dd54..31310bdd4d 100644
--- a/src/col/vct/col/print/Doc.scala
+++ b/src/col/vct/col/print/Doc.scala
@@ -7,9 +7,10 @@ import java.lang
import scala.annotation.tailrec
object Show {
- def lazily(f: Ctx => Doc): Show = new Show {
- override def show(implicit ctx: Ctx): Doc = f(ctx)
- }
+ def lazily(f: Ctx => Doc): Show =
+ new Show {
+ override def show(implicit ctx: Ctx): Doc = f(ctx)
+ }
}
trait Show {
@@ -29,8 +30,7 @@ case object Doc {
def fold(docs: Iterable[Show])(f: (Doc, Doc) => Doc)(implicit ctx: Ctx): Doc =
docs.map(_.show).filter(_.nonEmpty).reduceLeftOption(f).getOrElse(Empty)
- def spread(docs: Iterable[Show])(implicit ctx: Ctx): Doc =
- fold(docs)(_ <+> _)
+ def spread(docs: Iterable[Show])(implicit ctx: Ctx): Doc = fold(docs)(_ <+> _)
def rspread(docs: Iterable[Show])(implicit ctx: Ctx): Doc =
fold(docs.map(_.show <+> Empty))(_ <> _)
@@ -38,65 +38,64 @@ case object Doc {
def lspread(docs: Iterable[Show])(implicit ctx: Ctx): Doc =
fold(docs.map(Empty <+> _.show))(_ <> _)
- def stack(docs: Iterable[Show])(implicit ctx: Ctx): Doc =
- fold(docs)(_ <+/> _)
+ def stack(docs: Iterable[Show])(implicit ctx: Ctx): Doc = fold(docs)(_ <+/> _)
def arg(doc: Show)(implicit ctx: Ctx): Doc =
Nest(NonWsLine <> doc) <> NonWsLine
def args(docs: Iterable[Show])(implicit ctx: Ctx): Doc =
- if(docs.nonEmpty) arg(fold(docs)(_ <> "," <+/> _))
- else Empty
+ if (docs.nonEmpty)
+ arg(fold(docs)(_ <> "," <+/> _))
+ else
+ Empty
def inlineSpec(doc: Show)(implicit ctx: Ctx): Doc =
- if(ctx.syntax == Ctx.PVL) doc.show
- else if(ctx.inSpec) doc.show
+ if (ctx.syntax == Ctx.PVL)
+ doc.show
+ else if (ctx.inSpec)
+ doc.show
else {
val d = doc.show(ctx.copy(inSpec = true))
- if(d.nonEmpty) Text("/*@") <+> d <+> "@*/"
- else Empty
+ if (d.nonEmpty)
+ Text("/*@") <+> d <+> "@*/"
+ else
+ Empty
}
def spec(doc: Show)(implicit ctx: Ctx): Doc =
- if (ctx.syntax == Ctx.PVL) doc.show
- else if (ctx.inSpec) doc.show
+ if (ctx.syntax == Ctx.PVL)
+ doc.show
+ else if (ctx.inSpec)
+ doc.show
else {
val d = doc.show(ctx.copy(inSpec = true))
- if (d.nonEmpty) Text("/*@") <+/> d <+/> "@*/"
- else Empty
+ if (d.nonEmpty)
+ Text("/*@") <+/> d <+/> "@*/"
+ else
+ Empty
}
}
-/**
- * This is an implementation of A prettier printer by Philip Wadler, accessible here:
- * https://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf
+/** This is an implementation of A prettier printer by Philip Wadler, accessible
+ * here: https://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf
*
* We've made a couple modifications to suit our purposes:
*
- * (1) There is a newline that is not flattened into a space, but into no text, to support our layout for invocations
- * that are split over lines:
- * e.g.:
+ * (1) There is a newline that is not flattened into a space, but into no text,
+ * to support our layout for invocations that are split over lines: e.g.:
*
- * someMethod(
- * 1,
- * 2,
- * 3
- * )
+ * someMethod( 1, 2, 3 )
*
- * would otherwise be flattened into someMethod( 1, 2, 3 ), so the initial and last newline are non-whitespace
- * newlines:
+ * would otherwise be flattened into someMethod( 1, 2, 3 ), so the initial and
+ * last newline are non-whitespace newlines:
*
- * someMethod(`>`
- * 1,`<+/>`
- * 2,`<+/>`
- * 3,`>`
- * )
- * (2) Group is an explicit data structure, as defined: Group(x) = flatten x <|> x. Note that contrary to the canonical
- * definition, <+/> does not introduce an alternative - it is typically grouped in a larger expression, to prefer
- * splitting larger trees over lines.
- * (3) be includes additional state to track whether an element needs to be flattened.
- * (4) NodeDoc associates a node in the AST with a Doc in the rendered tree, for additional post-processing of the
- * layout.
+ * someMethod(`>` 1,`<+/>` 2,`<+/>` 3,`>` ) (2) Group is an explicit data
+ * structure, as defined: Group(x) = flatten x <|> x. Note that contrary to the
+ * canonical definition, <+/> does not introduce an alternative - it is
+ * typically grouped in a larger expression, to prefer splitting larger trees
+ * over lines. (3) be includes additional state to track whether an element
+ * needs to be flattened. (4) NodeDoc associates a node in the AST with a Doc
+ * in the rendered tree, for additional post-processing of the layout.
*/
sealed trait Doc extends Show {
def show(implicit ctx: Ctx): Doc = this
@@ -113,90 +112,118 @@ sealed trait Doc extends Show {
def <>>(other: String)(implicit ctx: Ctx): Doc = this <>> Text(other)
sealed trait Elem {
- def write(a: Appendable): Unit = this match {
- case EText(text) => a.append(text)
- case ELine(indent) => a.append("\n").append(" ".repeat(indent))
- case EStart(_) =>
- case EEnd(_) =>
- }
+ def write(a: Appendable): Unit =
+ this match {
+ case EText(text) => a.append(text)
+ case ELine(indent) => a.append("\n").append(" ".repeat(indent))
+ case EStart(_) =>
+ case EEnd(_) =>
+ }
}
case class EText(text: String) extends Elem
case class ELine(indent: Int) extends Elem
case class EStart(node: Node[_]) extends Elem {
override def hashCode(): Int = System.identityHashCode(node)
- override def equals(obj: Any): Boolean = obj match {
- case EStart(other) => node.eq(other)
- case _ => false
- }
+ override def equals(obj: Any): Boolean =
+ obj match {
+ case EStart(other) => node.eq(other)
+ case _ => false
+ }
}
case class EEnd(node: Node[_]) extends Elem {
override def hashCode(): Int = System.identityHashCode(node) ^ 1
- override def equals(obj: Any): Boolean = obj match {
- case EEnd(other) => node.eq(other)
- case _ => false
- }
+ override def equals(obj: Any): Boolean =
+ obj match {
+ case EEnd(other) => node.eq(other)
+ case _ => false
+ }
}
-
- def lazyListLen(list: LazyList[Elem]): Int = list match {
- case LazyList() => 0
- case EText(text) #:: tail => text.length + lazyListLen(tail)
- case EStart(_) #:: tail => lazyListLen(tail)
- case EEnd(_) #:: tail => lazyListLen(tail)
- case ELine(indent) #:: tail => 1 + indent + lazyListLen(tail)
- }
+ def lazyListLen(list: LazyList[Elem]): Int =
+ list match {
+ case LazyList() => 0
+ case EText(text) #:: tail => text.length + lazyListLen(tail)
+ case EStart(_) #:: tail => lazyListLen(tail)
+ case EEnd(_) #:: tail => lazyListLen(tail)
+ case ELine(indent) #:: tail => 1 + indent + lazyListLen(tail)
+ }
@tailrec
- private def fits(spent: Int, elems: LazyList[Elem])(implicit ctx: Ctx): Boolean = elems match {
- case _ if spent > ctx.width => false
- case LazyList() => true
- case EText(t) #:: elems => fits(spent + t.length, elems)
- case ELine(_) #:: _ => true
- case EStart(_) #:: tail => fits(spent, tail)
- case EEnd(_) #:: tail => fits(spent, tail)
- }
-
- private def better(spent: Int, x: LazyList[Elem], y: LazyList[Elem])(implicit ctx: Ctx): LazyList[Elem] =
- if(fits(spent, x)) x else y
+ private def fits(spent: Int, elems: LazyList[Elem])(
+ implicit ctx: Ctx
+ ): Boolean =
+ elems match {
+ case _ if spent > ctx.width => false
+ case LazyList() => true
+ case EText(t) #:: elems => fits(spent + t.length, elems)
+ case ELine(_) #:: _ => true
+ case EStart(_) #:: tail => fits(spent, tail)
+ case EEnd(_) #:: tail => fits(spent, tail)
+ }
- private def be(spent: Int, docs: Seq[(Int, Boolean, Seq[Node[_]], Doc)])(implicit ctx: Ctx): LazyList[Elem] = docs match {
- case Nil => LazyList.empty
- case (_, _, nes, Empty) +: docs => nes.map(EEnd).to(LazyList) #::: be(spent, docs)
- case (i, f, nes, NodeDoc(node, x)) +: docs => EStart(node) #:: be(spent, (i, f, nes :+ node, x) +: docs)
- case (i, f, nes, Cons(x, y)) +: docs => be(spent, (i, f, Nil, x) +: (i, f, nes, y) +: docs)
- case (i, f, nes, Nest(x)) +: docs => be(spent, (i+ctx.tabWidth, f, nes, x) +: docs)
- case (_, _, nes, Text(t)) +: docs => EText(t) #:: nes.map(EEnd).to(LazyList) #::: be(spent + t.length, docs)
- case (i, false, nes, Line | NonWsLine) +: docs => ELine(i) #:: nes.map(EEnd).to(LazyList) #::: be(i, docs)
- case (_, true, nes, Line) +: docs => EText(" ") #:: nes.map(EEnd).to(LazyList) #::: be(spent + 1, docs)
- case (_, true, nes, NonWsLine) +: docs => nes.map(EEnd).to(LazyList) #::: be(spent, docs)
- case (i, true, nes, Group(x)) +: docs => be(spent, (i, true, nes, x) +: docs)
- case (i, false, nes, Group(x)) +: docs => better(
- spent,
- be(spent, (i, true, nes, x) +: docs),
- be(spent, (i, false, nes, x) +: docs),
- )
- }
+ private def better(spent: Int, x: LazyList[Elem], y: LazyList[Elem])(
+ implicit ctx: Ctx
+ ): LazyList[Elem] =
+ if (fits(spent, x))
+ x
+ else
+ y
+
+ private def be(spent: Int, docs: Seq[(Int, Boolean, Seq[Node[_]], Doc)])(
+ implicit ctx: Ctx
+ ): LazyList[Elem] =
+ docs match {
+ case Nil => LazyList.empty
+ case (_, _, nes, Empty) +: docs =>
+ nes.map(EEnd).to(LazyList) #::: be(spent, docs)
+ case (i, f, nes, NodeDoc(node, x)) +: docs =>
+ EStart(node) #:: be(spent, (i, f, nes :+ node, x) +: docs)
+ case (i, f, nes, Cons(x, y)) +: docs =>
+ be(spent, (i, f, Nil, x) +: (i, f, nes, y) +: docs)
+ case (i, f, nes, Nest(x)) +: docs =>
+ be(spent, (i + ctx.tabWidth, f, nes, x) +: docs)
+ case (_, _, nes, Text(t)) +: docs =>
+ EText(t) #:: nes.map(EEnd).to(LazyList) #::: be(spent + t.length, docs)
+ case (i, false, nes, Line | NonWsLine) +: docs =>
+ ELine(i) #:: nes.map(EEnd).to(LazyList) #::: be(i, docs)
+ case (_, true, nes, Line) +: docs =>
+ EText(" ") #:: nes.map(EEnd).to(LazyList) #::: be(spent + 1, docs)
+ case (_, true, nes, NonWsLine) +: docs =>
+ nes.map(EEnd).to(LazyList) #::: be(spent, docs)
+ case (i, true, nes, Group(x)) +: docs =>
+ be(spent, (i, true, nes, x) +: docs)
+ case (i, false, nes, Group(x)) +: docs =>
+ better(
+ spent,
+ be(spent, (i, true, nes, x) +: docs),
+ be(spent, (i, false, nes, x) +: docs),
+ )
+ }
def pretty(implicit ctx: Ctx): LazyList[Elem] =
be(0, Seq((0, false, Nil, this)))
- def nonEmpty: Boolean = this match {
- case Empty => false
- case NonWsLine => true
- case Line => true
- case Cons(left, right) => left.nonEmpty || right.nonEmpty
- case Text(text) => text.nonEmpty
- case Nest(doc) => doc.nonEmpty
- case Group(doc) => doc.nonEmpty
- case NodeDoc(_, doc) => doc.nonEmpty
- }
-
- def splitOn[A](list: LazyList[A])(predicate: A => Boolean): LazyList[LazyList[A]] = {
- def loop(l: LazyList[A], acc: LazyList[A]): LazyList[LazyList[A]] = l match {
- case LazyList() => LazyList(acc)
- case h #:: t if predicate(h) => acc #:: loop(t, LazyList(h))
- case h #:: t => loop(t, acc :+ h)
+ def nonEmpty: Boolean =
+ this match {
+ case Empty => false
+ case NonWsLine => true
+ case Line => true
+ case Cons(left, right) => left.nonEmpty || right.nonEmpty
+ case Text(text) => text.nonEmpty
+ case Nest(doc) => doc.nonEmpty
+ case Group(doc) => doc.nonEmpty
+ case NodeDoc(_, doc) => doc.nonEmpty
}
+
+ def splitOn[A](
+ list: LazyList[A]
+ )(predicate: A => Boolean): LazyList[LazyList[A]] = {
+ def loop(l: LazyList[A], acc: LazyList[A]): LazyList[LazyList[A]] =
+ l match {
+ case LazyList() => LazyList(acc)
+ case h #:: t if predicate(h) => acc #:: loop(t, LazyList(h))
+ case h #:: t => loop(t, acc :+ h)
+ }
loop(list, LazyList())
}
@@ -209,13 +236,12 @@ sealed trait Doc extends Show {
case other => other
})
-
-
def highlight(node: Node[_])(implicit ctx: Ctx): String = {
- val lineNumber = (line: Int) => String.format("%" + f"$LINE_NUMBER_WIDTH" + "d ", line)
+ val lineNumber =
+ (line: Int) => String.format("%" + f"$LINE_NUMBER_WIDTH" + "d ", line)
val sb = new lang.StringBuilder()
- val (prefix, rest)= lines.zipWithIndex.span(!_._1.contains(EStart(node)))
+ val (prefix, rest) = lines.zipWithIndex.span(!_._1.contains(EStart(node)))
val (highlightInit, rest1) = rest.span(!_._1.contains(EEnd(node)))
if (rest1.isEmpty) {
sb.append("⋱\n")
@@ -233,18 +259,30 @@ sealed trait Doc extends Show {
lineWithIndex._1.foreach(_.write(sb))
sb.append("\n")
}
- val indicatorStart = lazyListLen(highlight.map(_._1).head.takeWhile(_ != EStart(node)))
- val indicatorEnd = lazyListLen(highlight.map(_._1).head.takeWhile(_ != EEnd(node)))
- sb.append(" ".repeat(indicatorStart + LINE_NUMBER_WIDTH)).append("[").append("-".repeat(indicatorEnd-indicatorStart))
+ val indicatorStart = lazyListLen(
+ highlight.map(_._1).head.takeWhile(_ != EStart(node))
+ )
+ val indicatorEnd = lazyListLen(
+ highlight.map(_._1).head.takeWhile(_ != EEnd(node))
+ )
+ sb.append(" ".repeat(indicatorStart + LINE_NUMBER_WIDTH)).append("[")
+ .append("-".repeat(indicatorEnd - indicatorStart))
highlight.foreach { lineWithIndex =>
sb.append("\n")
sb.append(lineNumber(lineWithIndex._2 + 1))
lineWithIndex._1.foreach(_.write(sb))
}
- val endIndicatorStart = if (highlight.size == 1) indicatorStart else 0
- val endIndicatorEnd = lazyListLen(highlight.map(_._1).last.takeWhile(_ != EEnd(node)))
+ val endIndicatorStart =
+ if (highlight.size == 1)
+ indicatorStart
+ else
+ 0
+ val endIndicatorEnd = lazyListLen(
+ highlight.map(_._1).last.takeWhile(_ != EEnd(node))
+ )
sb.append("\n")
- sb.append(" ".repeat(endIndicatorStart + LINE_NUMBER_WIDTH + 1)).append("-".repeat(endIndicatorEnd - endIndicatorStart)).append("]")
+ sb.append(" ".repeat(endIndicatorStart + LINE_NUMBER_WIDTH + 1))
+ .append("-".repeat(endIndicatorEnd - endIndicatorStart)).append("]")
suffix.take(2).foreach { lineWithIndex =>
sb.append("\n")
sb.append(lineNumber(lineWithIndex._2 + 1))
diff --git a/src/col/vct/col/print/DocUtil.scala b/src/col/vct/col/print/DocUtil.scala
index 4b1a3b1002..c350806442 100644
--- a/src/col/vct/col/print/DocUtil.scala
+++ b/src/col/vct/col/print/DocUtil.scala
@@ -9,34 +9,73 @@ object DocUtil {
AstBuildHelpers.unfoldStar(e).map(_.show)
def splitClauses(e: AccountedPredicate[_])(implicit ctx: Ctx): Seq[Doc] =
- AstBuildHelpers.unfoldPredicate(e).flatMap(AstBuildHelpers.unfoldStar).map(_.show)
+ AstBuildHelpers.unfoldPredicate(e).flatMap(AstBuildHelpers.unfoldStar)
+ .map(_.show)
def clauses(key: String, e: Expr[_])(implicit ctx: Ctx): Doc =
- Doc.stack(splitClauses(e).map(Text(key) <+> _ <> (if(ctx.syntax == Ctx.Silver) "" else ";")))
+ Doc.stack(splitClauses(e).map(
+ Text(key) <+> _ <>
+ (if (ctx.syntax == Ctx.Silver)
+ ""
+ else
+ ";")
+ ))
def clauses(key: String, e: AccountedPredicate[_])(implicit ctx: Ctx): Doc =
- Doc.stack(splitClauses(e).map(Text(key) <+> _ <> (if(ctx.syntax == Ctx.Silver) "" else ";")))
-
- def givenYieldsMapping(keyword: String, mapping: Seq[(Doc, Doc)])(implicit ctx: Ctx): Doc =
- if(mapping.isEmpty) Empty
- else Nest(Line <> Group(Text(keyword) <+> "{" <> Doc.args(mapping.map(p => p._1 <+> "=" <+> p._2)) <> "}"))
-
- def givenYields[G](given: Seq[(Ref[G, Variable[G]], Expr[G])], yields: Seq[(Expr[G], Ref[G, Variable[G]])])(implicit ctx: Ctx): Doc =
- Doc.inlineSpec(Show.lazily(givenYieldsMapping("given", given.map { case (ref, e) => Text(ctx.name(ref)) -> e.show })(_))) <>
- Doc.inlineSpec(Show.lazily(givenYieldsMapping("yields", yields.map { case (e, ref) => e.show -> Text(ctx.name(ref)) })(_)))
-
- def argsOutArgs[G](args: Seq[Expr[G]], outArgs: Seq[Expr[G]])(implicit ctx: Ctx): Doc = outArgs match {
- case Seq() => Doc.args(args)
- case _ => Doc.args(args) <> ";" <+> Doc.args(outArgs)
- }
-
- def javaGenericArgs[G](args: Seq[Type[G]])(implicit ctx: Ctx): Doc = args match {
- case Seq() => Empty
- case _ => Text("<") <> Doc.args(args) <> ">"
- }
-
- def javaGenericParams[G](args: Seq[Variable[G]])(implicit ctx: Ctx): Doc = args match {
- case Seq() => Empty
- case _ => Text("<") <> Doc.args(args) <> ">"
- }
+ Doc.stack(splitClauses(e).map(
+ Text(key) <+> _ <>
+ (if (ctx.syntax == Ctx.Silver)
+ ""
+ else
+ ";")
+ ))
+
+ def givenYieldsMapping(keyword: String, mapping: Seq[(Doc, Doc)])(
+ implicit ctx: Ctx
+ ): Doc =
+ if (mapping.isEmpty)
+ Empty
+ else
+ Nest(
+ Line <> Group(
+ Text(keyword) <+> "{" <>
+ Doc.args(mapping.map(p => p._1 <+> "=" <+> p._2)) <> "}"
+ )
+ )
+
+ def givenYields[G](
+ given: Seq[(Ref[G, Variable[G]], Expr[G])],
+ yields: Seq[(Expr[G], Ref[G, Variable[G]])],
+ )(implicit ctx: Ctx): Doc =
+ Doc.inlineSpec(Show.lazily(
+ givenYieldsMapping(
+ "given",
+ given.map { case (ref, e) => Text(ctx.name(ref)) -> e.show },
+ )(_)
+ )) <> Doc.inlineSpec(Show.lazily(
+ givenYieldsMapping(
+ "yields",
+ yields.map { case (e, ref) => e.show -> Text(ctx.name(ref)) },
+ )(_)
+ ))
+
+ def argsOutArgs[G](args: Seq[Expr[G]], outArgs: Seq[Expr[G]])(
+ implicit ctx: Ctx
+ ): Doc =
+ outArgs match {
+ case Seq() => Doc.args(args)
+ case _ => Doc.args(args) <> ";" <+> Doc.args(outArgs)
+ }
+
+ def javaGenericArgs[G](args: Seq[Type[G]])(implicit ctx: Ctx): Doc =
+ args match {
+ case Seq() => Empty
+ case _ => Text("<") <> Doc.args(args) <> ">"
+ }
+
+ def javaGenericParams[G](args: Seq[Variable[G]])(implicit ctx: Ctx): Doc =
+ args match {
+ case Seq() => Empty
+ case _ => Text("<") <> Doc.args(args) <> ">"
+ }
}
diff --git a/src/col/vct/col/print/Keywords.scala b/src/col/vct/col/print/Keywords.scala
index 66b6e2455e..9bb78ca3c5 100644
--- a/src/col/vct/col/print/Keywords.scala
+++ b/src/col/vct/col/print/Keywords.scala
@@ -2,47 +2,304 @@ package vct.col.print
object Keywords {
val SPEC: Set[String] = Set(
- "inline", "assert", "true", "false", "package", "resource", "process", "frac", "zfrac", "bool", "ref",
- "rational", "seq", "set", "bag", "pointer", "map", "option", "either", "tuple", "type", "any",
- "nothing", "string", "pure", "thread_local", "bip_annotation", "with", "then", "given", "yields",
- "axiom", "model", "adt", "prover_type", "prover_function", "modifies", "accessible", "requires",
- "ensures", "context_everywhere", "context", "loop_invariant", "kernel_invariant", "lock_invariant",
- "signals", "decreases", "apply", "fold", "unfold", "open", "close", "assume", "inhale", "exhale",
- "label", "extract", "frame", "outline", "refute", "witness", "ghost", "send", "to", "recv", "from",
- "transfer", "csl_subject", "spec_ignore", "action", "atomic", "commit", "Reducible", "AddsTo", "APerm",
- "ArrayPerm", "Contribution", "held", "committed", "HPerm", "idle", "perm", "Perm", "PointsTo",
- "running", "Some", "Left", "Right", "Value", "none", "None", "write", "read", "empty",
+ "inline",
+ "assert",
+ "true",
+ "false",
+ "package",
+ "resource",
+ "process",
+ "frac",
+ "zfrac",
+ "bool",
+ "ref",
+ "rational",
+ "seq",
+ "set",
+ "bag",
+ "pointer",
+ "map",
+ "option",
+ "either",
+ "tuple",
+ "type",
+ "any",
+ "nothing",
+ "string",
+ "pure",
+ "thread_local",
+ "bip_annotation",
+ "with",
+ "then",
+ "given",
+ "yields",
+ "axiom",
+ "model",
+ "adt",
+ "prover_type",
+ "prover_function",
+ "modifies",
+ "accessible",
+ "requires",
+ "ensures",
+ "context_everywhere",
+ "context",
+ "loop_invariant",
+ "kernel_invariant",
+ "lock_invariant",
+ "signals",
+ "decreases",
+ "apply",
+ "fold",
+ "unfold",
+ "open",
+ "close",
+ "assume",
+ "inhale",
+ "exhale",
+ "label",
+ "extract",
+ "frame",
+ "outline",
+ "refute",
+ "witness",
+ "ghost",
+ "send",
+ "to",
+ "recv",
+ "from",
+ "transfer",
+ "csl_subject",
+ "spec_ignore",
+ "action",
+ "atomic",
+ "commit",
+ "Reducible",
+ "AddsTo",
+ "APerm",
+ "ArrayPerm",
+ "Contribution",
+ "held",
+ "committed",
+ "HPerm",
+ "idle",
+ "perm",
+ "Perm",
+ "PointsTo",
+ "running",
+ "Some",
+ "Left",
+ "Right",
+ "Value",
+ "none",
+ "None",
+ "write",
+ "read",
+ "empty",
)
val PVL: Set[String] = Set(
- "inline", "assert", "package", "enum", "class", "seq_program", "seq_run", "kernel", "barrier",
- "invariant", "constructor", "run", "thread", "endpoint", "if", "else", "while", "for", "goto",
- "return", "vec", "par", "and", "parallel", "sequential", "block", "lock", "unlock", "wait", "notify",
- "fork", "join", "communicate", "this", "null", "true", "false", "current_thread", "global", "local",
- "static", "final", "unfolding", "in", "new", "id", "boolean", "void", "int", "char", "float32",
+ "inline",
+ "assert",
+ "package",
+ "enum",
+ "class",
+ "seq_program",
+ "seq_run",
+ "kernel",
+ "barrier",
+ "invariant",
+ "constructor",
+ "run",
+ "thread",
+ "endpoint",
+ "if",
+ "else",
+ "while",
+ "for",
+ "goto",
+ "return",
+ "vec",
+ "par",
+ "and",
+ "parallel",
+ "sequential",
+ "block",
+ "lock",
+ "unlock",
+ "wait",
+ "notify",
+ "fork",
+ "join",
+ "communicate",
+ "this",
+ "null",
+ "true",
+ "false",
+ "current_thread",
+ "global",
+ "local",
+ "static",
+ "final",
+ "unfolding",
+ "in",
+ "new",
+ "id",
+ "boolean",
+ "void",
+ "int",
+ "char",
+ "float32",
"float64",
)
val JAVA: Set[String] = Set(
- "abstract", "assert", "boolean", "break", "byte", "case", "catch", "char", "class", "const",
- "continue", "default", "do", "double", "else", "enum", "extends", "final", "finally", "float", "for",
- "if", "goto", "implements", "import", "instanceof", "int", "interface", "long", "native", "new",
- "package", "private", "protected", "public", "return", "short", "static", "strictfp", "super",
- "switch", "synchronized", "this", "throw", "throws", "transient", "try", "void", "volatile", "while",
+ "abstract",
+ "assert",
+ "boolean",
+ "break",
+ "byte",
+ "case",
+ "catch",
+ "char",
+ "class",
+ "const",
+ "continue",
+ "default",
+ "do",
+ "double",
+ "else",
+ "enum",
+ "extends",
+ "final",
+ "finally",
+ "float",
+ "for",
+ "if",
+ "goto",
+ "implements",
+ "import",
+ "instanceof",
+ "int",
+ "interface",
+ "long",
+ "native",
+ "new",
+ "package",
+ "private",
+ "protected",
+ "public",
+ "return",
+ "short",
+ "static",
+ "strictfp",
+ "super",
+ "switch",
+ "synchronized",
+ "this",
+ "throw",
+ "throws",
+ "transient",
+ "try",
+ "void",
+ "volatile",
+ "while",
)
val C_CPP_GPGPU: Set[String] = Set(
- "_Alignas", "_Alignof", "_Atomic", "_Bool", "_Complex", "_Generic", "_Imaginary", "_Noreturn",
- "_Static_assert", "_Thread_local", "__cuda_kernel__", "__opencl_kernel__", "__vercors_atomic__",
- "__vercors_barrier__", "__vercors_global_mem_fence__", "__vercors_global_memory__",
- "__vercors_local_mem_fence__", "__vercors_local_memory__", "_thread_local", "alignas", "alignof",
- "asm", "auto", "bool", "break", "case", "catch", "char", "char16_t", "char32_t", "class", "const",
- "const_cast", "constexpr", "continue", "decltype", "default", "delete", "do", "double", "dynamic_cast",
- "else", "enum", "explicit", "export", "extern", "false", "final", "float", "for", "friend", "goto",
- "if", "inline", "int", "long", "mutable", "namespace", "new", "noexcept", "nullptr", "operator",
- "override", "private", "protected", "public", "register", "reinterpret_cast", "restrict", "return",
- "short", "signed", "sizeof", "static", "static_assert", "static_cast", "struct", "switch", "template",
- "this", "throw", "true", "try", "typedef", "typeid", "typename", "union", "unsigned", "using",
- "virtual", "void", "volatile", "wchar_t", "while",
+ "_Alignas",
+ "_Alignof",
+ "_Atomic",
+ "_Bool",
+ "_Complex",
+ "_Generic",
+ "_Imaginary",
+ "_Noreturn",
+ "_Static_assert",
+ "_Thread_local",
+ "__cuda_kernel__",
+ "__opencl_kernel__",
+ "__vercors_atomic__",
+ "__vercors_barrier__",
+ "__vercors_global_mem_fence__",
+ "__vercors_global_memory__",
+ "__vercors_local_mem_fence__",
+ "__vercors_local_memory__",
+ "_thread_local",
+ "alignas",
+ "alignof",
+ "asm",
+ "auto",
+ "bool",
+ "break",
+ "case",
+ "catch",
+ "char",
+ "char16_t",
+ "char32_t",
+ "class",
+ "const",
+ "const_cast",
+ "constexpr",
+ "continue",
+ "decltype",
+ "default",
+ "delete",
+ "do",
+ "double",
+ "dynamic_cast",
+ "else",
+ "enum",
+ "explicit",
+ "export",
+ "extern",
+ "false",
+ "final",
+ "float",
+ "for",
+ "friend",
+ "goto",
+ "if",
+ "inline",
+ "int",
+ "long",
+ "mutable",
+ "namespace",
+ "new",
+ "noexcept",
+ "nullptr",
+ "operator",
+ "override",
+ "private",
+ "protected",
+ "public",
+ "register",
+ "reinterpret_cast",
+ "restrict",
+ "return",
+ "short",
+ "signed",
+ "sizeof",
+ "static",
+ "static_assert",
+ "static_cast",
+ "struct",
+ "switch",
+ "template",
+ "this",
+ "throw",
+ "true",
+ "try",
+ "typedef",
+ "typeid",
+ "typename",
+ "union",
+ "unsigned",
+ "using",
+ "virtual",
+ "void",
+ "volatile",
+ "wchar_t",
+ "while",
)
}
diff --git a/src/col/vct/col/print/Namer.scala b/src/col/vct/col/print/Namer.scala
index 35f7b925a7..5f6da6a18f 100644
--- a/src/col/vct/col/print/Namer.scala
+++ b/src/col/vct/col/print/Namer.scala
@@ -9,104 +9,109 @@ case class Namer[G](syntax: Ctx.Syntax) {
private val stack = ScopedStack[Node[G]]()
private val names = mutable.Map[(scala.Any, String, Int), Declaration[G]]()
- private val keywords: Set[String] = syntax match {
- case Ctx.PVL => Keywords.PVL
- case Ctx.Silver => Set()
- case Ctx.Java => Keywords.JAVA
- case Ctx.C => Keywords.C_CPP_GPGPU
- case Ctx.CPP => Keywords.C_CPP_GPGPU
- case Ctx.Cuda => Keywords.C_CPP_GPGPU
- case Ctx.OpenCL => Keywords.C_CPP_GPGPU
- }
+ private val keywords: Set[String] =
+ syntax match {
+ case Ctx.PVL => Keywords.PVL
+ case Ctx.Silver => Set()
+ case Ctx.Java => Keywords.JAVA
+ case Ctx.C => Keywords.C_CPP_GPGPU
+ case Ctx.CPP => Keywords.C_CPP_GPGPU
+ case Ctx.Cuda => Keywords.C_CPP_GPGPU
+ case Ctx.OpenCL => Keywords.C_CPP_GPGPU
+ }
def nearest(f: PartialFunction[Node[G], Unit]): Seq[Node[G]] =
stack.toSeq.filter(n => f.isDefinedAt(n))
- private def nearestClass = nearest {
- case _: Class[G] | _: JavaClass[G] | _: Choreography[G] | _: JavaInterface[G] | _: JavaAnnotationInterface[G] => ()
- }
+ private def nearestClass =
+ nearest {
+ case _: Class[G] | _: JavaClass[G] | _: Choreography[G] |
+ _: JavaInterface[G] | _: JavaAnnotationInterface[G] =>
+ ()
+ }
- private def nearestVariableScope = nearest {
- case _: ParBlock[G] => ()
- case _: VecBlock[G] => ()
- case _: CatchClause[G] => ()
- case _: Scope[G] => ()
- case _: SignalsClause[G] => ()
- case _: AxiomaticDataType[G] => ()
- case _: JavaClass[G] => ()
- case _: JavaInterface[G] => ()
- case _: Predicate[G] => ()
- case _: InstancePredicate[G] => ()
- case _: ModelProcess[G] => ()
- case _: ModelAction[G] => ()
- case _: ADTFunction[G] => ()
- case _: Function[G] => ()
- case _: Procedure[G] => ()
- case _: InstanceFunction[G] => ()
- case _: InstanceMethod[G] => ()
- case _: Constructor[G] => ()
- case _: JavaConstructor[G] => ()
- case _: JavaMethod[G] => ()
- case _: PVLConstructor[G] => ()
- case _: Forall[G] => ()
- case _: Starall[G] => ()
- case _: Exists[G] => ()
- case _: Sum[G] => ()
- case _: Product[G] => ()
- case _: Let[G] => ()
- case _: ScopedExpr[G] => ()
- case _: ForPerm[G] => ()
- }
+ private def nearestVariableScope =
+ nearest {
+ case _: ParBlock[G] => ()
+ case _: VecBlock[G] => ()
+ case _: CatchClause[G] => ()
+ case _: Scope[G] => ()
+ case _: SignalsClause[G] => ()
+ case _: AxiomaticDataType[G] => ()
+ case _: JavaClass[G] => ()
+ case _: JavaInterface[G] => ()
+ case _: Predicate[G] => ()
+ case _: InstancePredicate[G] => ()
+ case _: ModelProcess[G] => ()
+ case _: ModelAction[G] => ()
+ case _: ADTFunction[G] => ()
+ case _: Function[G] => ()
+ case _: Procedure[G] => ()
+ case _: InstanceFunction[G] => ()
+ case _: InstanceMethod[G] => ()
+ case _: Constructor[G] => ()
+ case _: JavaConstructor[G] => ()
+ case _: JavaMethod[G] => ()
+ case _: PVLConstructor[G] => ()
+ case _: Forall[G] => ()
+ case _: Starall[G] => ()
+ case _: Exists[G] => ()
+ case _: Sum[G] => ()
+ case _: Product[G] => ()
+ case _: Let[G] => ()
+ case _: ScopedExpr[G] => ()
+ case _: ForPerm[G] => ()
+ }
- private def nearestCallable = nearest {
- case _: Function[G] => ()
- case _: Procedure[G] => ()
- case _: InstanceFunction[G] => ()
- case _: InstanceMethod[G] => ()
- case _: Constructor[G] => ()
- case _: JavaMethod[G] => ()
- case _: JavaAnnotationMethod[G] => ()
- case _: JavaConstructor[G] => ()
- case _: PVLConstructor[G] => ()
- case _: CFunctionDefinition[G] => ()
- case _: CPPFunctionDefinition[G] => ()
- }
+ private def nearestCallable =
+ nearest {
+ case _: Function[G] => ()
+ case _: Procedure[G] => ()
+ case _: InstanceFunction[G] => ()
+ case _: InstanceMethod[G] => ()
+ case _: Constructor[G] => ()
+ case _: JavaMethod[G] => ()
+ case _: JavaAnnotationMethod[G] => ()
+ case _: JavaConstructor[G] => ()
+ case _: PVLConstructor[G] => ()
+ case _: CFunctionDefinition[G] => ()
+ case _: CPPFunctionDefinition[G] => ()
+ }
def unpackName(name: String): (String, Int) = {
val m = "^(.*?)([1-9][0-9]*)?$".r.findFirstMatchIn(name).get
if (Option(m.group(2)).isDefined) {
(m.group(1), Integer.parseInt(m.group(2)))
- } else {
- (m.group(1), 0)
- }
+ } else { (m.group(1), 0) }
}
def packName(name: String, index: Int): String =
- if (index == 0) name
- else s"$name$index"
+ if (index == 0)
+ name
+ else
+ s"$name$index"
def nameKeyed(keys: Seq[scala.Any], decl: Declaration[G]): Unit = {
- if(keys.isEmpty) {
+ if (keys.isEmpty) {
// Refuse to name this declaration, it is unclear how to distinguish them.
return
}
val name = decl.o.getPreferredNameOrElse()
var (baseName, index) = unpackName(decl match {
- case declaration: GlobalDeclaration[_] => declaration match {
- case _: Applicable[_] => name.camel
- case _ => name.ucamel
- }
+ case declaration: GlobalDeclaration[_] =>
+ declaration match {
+ case _: Applicable[_] => name.camel
+ case _ => name.ucamel
+ }
case constant: EnumConstant[_] => name.usnake
case decl: LabelDecl[_] => name.usnake
case _ => name.camel
})
- if(index == 0 && keywords.contains(baseName)) {
- index = 1
- }
+ if (index == 0 && keywords.contains(baseName)) { index = 1 }
- while(keys.exists(key => names.contains((key, baseName, index)))) {
+ while (keys.exists(key => names.contains((key, baseName, index)))) {
index += 1
}
@@ -117,27 +122,43 @@ case class Namer[G](syntax: Ctx.Syntax) {
stack.having(node) { node.subnodes.foreach(name) }
node match {
- case decl: GlobalDeclaration[G] => nameKeyed(nearest { case _: Program[G] => () }, decl)
+ case decl: GlobalDeclaration[G] =>
+ nameKeyed(nearest { case _: Program[G] => () }, decl)
case decl: ClassDeclaration[G] => nameKeyed(nearestClass, decl)
- case decl: ADTDeclaration[G] => nameKeyed(if(syntax == Ctx.Silver) Seq(3) else nearest { case _: AxiomaticDataType[G] => () }, decl)
- case decl: ModelDeclaration[G] => nameKeyed(nearest { case _: Model[G] => () }, decl)
- case decl: EnumConstant[G] => nameKeyed(nearest { case _: Enum[G] => () }, decl)
+ case decl: ADTDeclaration[G] =>
+ nameKeyed(
+ if (syntax == Ctx.Silver)
+ Seq(3)
+ else
+ nearest { case _: AxiomaticDataType[G] => () },
+ decl,
+ )
+ case decl: ModelDeclaration[G] =>
+ nameKeyed(nearest { case _: Model[G] => () }, decl)
+ case decl: EnumConstant[G] =>
+ nameKeyed(nearest { case _: Enum[G] => () }, decl)
case decl: Variable[G] => nameKeyed(nearestVariableScope, decl)
case decl: LabelDecl[G] => nameKeyed(nearestCallable, decl)
- case decl: SendDecl[G] => nameKeyed(nearest { case _: ParBlock[G] | _: Loop[G] => () }, decl)
- case decl: ParBlockDecl[G] => nameKeyed(nearest { case _: ParBlock[G] => () }, decl)
- case decl: ParInvariantDecl[G] => nameKeyed(nearest { case _: ParInvariant[G] => () }, decl)
+ case decl: SendDecl[G] =>
+ nameKeyed(nearest { case _: ParBlock[G] | _: Loop[G] => () }, decl)
+ case decl: ParBlockDecl[G] =>
+ nameKeyed(nearest { case _: ParBlock[G] => () }, decl)
+ case decl: ParInvariantDecl[G] =>
+ nameKeyed(nearest { case _: ParInvariant[G] => () }, decl)
case decl: CLocalDeclaration[G] => nameKeyed(nearestVariableScope, decl)
case decl: CParam[G] => nameKeyed(nearestCallable, decl)
case decl: CPPLocalDeclaration[G] => nameKeyed(nearestVariableScope, decl)
case decl: CPPParam[G] => nameKeyed(nearestCallable, decl)
case decl: JavaLocalDeclaration[G] => nameKeyed(nearestCallable, decl)
- case decl: Endpoint[G] => nameKeyed(nearest { case _: Choreography[G] => () }, decl)
+ case decl: Endpoint[G] =>
+ nameKeyed(nearest { case _: Choreography[G] => () }, decl)
case decl: JavaParam[G] => nameKeyed(nearestCallable, decl)
case _ =>
}
}
def finish: Map[Declaration[G], String] =
- Map(names.map { case (_, name, index) -> decl => decl -> packName(name, index) }.toSeq: _*)
+ Map(names.map { case (_, name, index) -> decl =>
+ decl -> packName(name, index)
+ }.toSeq: _*)
}
diff --git a/src/col/vct/col/ref/DirectRef.scala b/src/col/vct/col/ref/DirectRef.scala
index d74930525a..34ecda9c3e 100644
--- a/src/col/vct/col/ref/DirectRef.scala
+++ b/src/col/vct/col/ref/DirectRef.scala
@@ -5,9 +5,12 @@ import vct.col.err.MistypedRef
import scala.reflect.ClassTag
-class DirectRef[G, Decl <: Declaration[G]](genericDecl: Declaration[G])(implicit tag: ClassTag[Decl]) extends Ref[G, Decl] {
- override def decl: Decl = genericDecl match {
- case decl: /*tagged*/ Decl => decl
- case other => throw MistypedRef(other, tag)
- }
+class DirectRef[G, Decl <: Declaration[G]](genericDecl: Declaration[G])(
+ implicit tag: ClassTag[Decl]
+) extends Ref[G, Decl] {
+ override def decl: Decl =
+ genericDecl match {
+ case decl: /*tagged*/ Decl => decl
+ case other => throw MistypedRef(other, tag)
+ }
}
diff --git a/src/col/vct/col/ref/LazyRef.scala b/src/col/vct/col/ref/LazyRef.scala
index 5fa43eebe9..b79cde7821 100644
--- a/src/col/vct/col/ref/LazyRef.scala
+++ b/src/col/vct/col/ref/LazyRef.scala
@@ -6,7 +6,11 @@ import vct.col.ref
import scala.reflect.ClassTag
-class LazyRef[G, Decl <: Declaration[G]](lazyDecl: => Declaration[G], eqMeasure: Option[Any] = None)(implicit tag: ClassTag[Decl]) extends Ref[G, Decl] {
+class LazyRef[G, Decl <: Declaration[G]](
+ lazyDecl: => Declaration[G],
+ eqMeasure: Option[Any] = None,
+)(implicit tag: ClassTag[Decl])
+ extends Ref[G, Decl] {
// Sometimes Nothing ends up in Decl, which is never useful, so we try to crash a bit earlier when that happens.
require(tag != ClassTag.Nothing)
@@ -29,14 +33,15 @@ class LazyRef[G, Decl <: Declaration[G]](lazyDecl: => Declaration[G], eqMeasure:
computeDecl = null
_eqMeasure = None
decl
- case other =>
- throw MistypedRef(other, tag)
+ case other => throw MistypedRef(other, tag)
}
}
- override def equals(obj: Any): Boolean = obj match {
- case other: LazyRef[G, Decl] if _eqMeasure.nonEmpty && other._eqMeasure.nonEmpty =>
- _eqMeasure.get == other._eqMeasure.get
- case other => super.equals(other)
- }
+ override def equals(obj: Any): Boolean =
+ obj match {
+ case other: LazyRef[G, Decl]
+ if _eqMeasure.nonEmpty && other._eqMeasure.nonEmpty =>
+ _eqMeasure.get == other._eqMeasure.get
+ case other => super.equals(other)
+ }
}
diff --git a/src/col/vct/col/ref/Ref.scala b/src/col/vct/col/ref/Ref.scala
index c17751b49c..bad778ecaf 100644
--- a/src/col/vct/col/ref/Ref.scala
+++ b/src/col/vct/col/ref/Ref.scala
@@ -5,50 +5,63 @@ import vct.col.ast.Declaration
import scala.reflect.ClassTag
import scala.runtime.ScalaRunTime
-/** NB: While Ref's can be stricter than just any Declaration (e.g. Ref[Function]), we can construct any variant with
- * just a Declaration. This is because:
- * - We cannot prove that the successor of a Declaration is of the correct type when we construct it: then it wouldn't
- * be lazy and we wouldn't be able to cross-reference declarations out of AST order.
- * - We do not want to cast or check refs to be of the correct kind every time we want to use it.
- * The most acceptable solution is then to pretend to have a safe interface that returns a declaration of the right
- * kind, but quietly check the type on first access.
+/** NB: While Ref's can be stricter than just any Declaration (e.g.
+ * Ref[Function]), we can construct any variant with just a Declaration. This
+ * is because:
+ * - We cannot prove that the successor of a Declaration is of the correct
+ * type when we construct it: then it wouldn't be lazy and we wouldn't be
+ * able to cross-reference declarations out of AST order.
+ * - We do not want to cast or check refs to be of the correct kind every
+ * time we want to use it. The most acceptable solution is then to pretend
+ * to have a safe interface that returns a declaration of the right kind,
+ * but quietly check the type on first access.
*/
trait Ref[G, Decl <: Declaration[G]] {
def decl: Decl
def tryResolve(resolver: String => Declaration[G]): Unit = {}
- override def equals(obj: scala.Any): Boolean = obj match {
- case other: Ref[G, _] => decl == other.decl
- }
+ override def equals(obj: scala.Any): Boolean =
+ obj match { case other: Ref[G, _] => decl == other.decl }
- /**
- * LazyRef tries very hard to not actually compute the declaration if it doesn't have to. To be able to compare
- * resolved and unresolved declarations amongst each other, the hashCode cannot be meaningful. Typically Ref's do
- * not end up in datastructures like Maps by themselves: it is probably usually either the Declaration directly, or
- * a composite Expression, in which case the shape will likely be sufficiently different sufficiently often.
- */
+ /** LazyRef tries very hard to not actually compute the declaration if it
+ * doesn't have to. To be able to compare resolved and unresolved
+ * declarations amongst each other, the hashCode cannot be meaningful.
+ * Typically Ref's do not end up in datastructures like Maps by themselves:
+ * it is probably usually either the Declaration directly, or a composite
+ * Expression, in which case the shape will likely be sufficiently different
+ * sufficiently often.
+ */
override final def hashCode(): Int = 0
- def asTransmutable[Decl2[_] <: Declaration[_]](implicit witness: Decl <:< Decl2[G]): Ref.TransmutableRef[G, Decl2] =
- new Ref.TransmutableRef(decl)
+ def asTransmutable[Decl2[_] <: Declaration[_]](
+ implicit witness: Decl <:< Decl2[G]
+ ): Ref.TransmutableRef[G, Decl2] = new Ref.TransmutableRef(decl)
}
object Ref {
- val EXC_MESSAGE = "The AST is in an invalid state: a Ref contains a declaration of the wrong kind."
+ val EXC_MESSAGE =
+ "The AST is in an invalid state: a Ref contains a declaration of the wrong kind."
- def unapply[G, Decl <: Declaration[G]](obj: Ref[G, Decl]): Some[Decl] = Some(obj.decl)
+ def unapply[G, Decl <: Declaration[G]](obj: Ref[G, Decl]): Some[Decl] =
+ Some(obj.decl)
class TransmutableRef[G, Decl[_] <: Declaration[_]](decl: => Decl[G]) {
- def asRegular[Decl2 <: Declaration[G]](implicit witness: Decl[G] <:< Decl2, tag: ClassTag[Decl2]): Ref[G, Decl2] =
- new LazyRef(decl)
+ def asRegular[Decl2 <: Declaration[G]](
+ implicit witness: Decl[G] <:< Decl2,
+ tag: ClassTag[Decl2],
+ ): Ref[G, Decl2] = new LazyRef(decl)
- def unsafeTransmuteGeneration[Post]: TransmutableRef[Post, Decl] = asInstanceOf[TransmutableRef[Post, Decl]]
+ def unsafeTransmuteGeneration[Post]: TransmutableRef[Post, Decl] =
+ asInstanceOf[TransmutableRef[Post, Decl]]
}
- def transmute
- [Pre, Post, Decl[_] <: Declaration[_], DPre <: Declaration[Pre], DPost <: Declaration[Post]]
- (ref: Ref[Pre, DPre])
- (implicit w1: DPre <:< Decl[Pre], w2: Decl[Post] <:< DPost, tag: ClassTag[DPost])
- : Ref[Post, DPost] = ref.asTransmutable[Decl].unsafeTransmuteGeneration.asRegular
-}
\ No newline at end of file
+ def transmute[Pre, Post, Decl[_] <: Declaration[_], DPre <: Declaration[
+ Pre
+ ], DPost <: Declaration[Post]](ref: Ref[Pre, DPre])(
+ implicit w1: DPre <:< Decl[Pre],
+ w2: Decl[Post] <:< DPost,
+ tag: ClassTag[DPost],
+ ): Ref[Post, DPost] =
+ ref.asTransmutable[Decl].unsafeTransmuteGeneration.asRegular
+}
diff --git a/src/col/vct/col/ref/UnresolvedRef.scala b/src/col/vct/col/ref/UnresolvedRef.scala
index 279912c3b6..00f9a8b2e9 100644
--- a/src/col/vct/col/ref/UnresolvedRef.scala
+++ b/src/col/vct/col/ref/UnresolvedRef.scala
@@ -6,19 +6,22 @@ import vct.col.ref
import scala.reflect.ClassTag
-class UnresolvedRef[G, Decl <: Declaration[G]](val name: String)(implicit tag: ClassTag[Decl]) extends Ref[G, Decl] {
+class UnresolvedRef[G, Decl <: Declaration[G]](val name: String)(
+ implicit tag: ClassTag[Decl]
+) extends Ref[G, Decl] {
private var resolvedDecl: Option[Declaration[G]] = None
- override def tryResolve(resolver: String => Declaration[G]): Unit = resolve(resolver(name))
+ override def tryResolve(resolver: String => Declaration[G]): Unit =
+ resolve(resolver(name))
def resolve(decl: Declaration[G]): Unit = resolvedDecl = Some(decl)
def isResolved: Boolean = resolvedDecl.isDefined
- def decl: Decl = resolvedDecl match {
- case None =>
- throw NotResolved(this, tag)
- case Some(decl: /*tagged*/ Decl) => decl
- case Some(other) => throw MistypedRef(other, tag)
- }
+ def decl: Decl =
+ resolvedDecl match {
+ case None => throw NotResolved(this, tag)
+ case Some(decl: /*tagged*/ Decl) => decl
+ case Some(other) => throw MistypedRef(other, tag)
+ }
}
diff --git a/src/col/vct/col/resolve/ResolutionError.scala b/src/col/vct/col/resolve/ResolutionError.scala
index 0527f91dd2..61bef3850e 100644
--- a/src/col/vct/col/resolve/ResolutionError.scala
+++ b/src/col/vct/col/resolve/ResolutionError.scala
@@ -6,82 +6,129 @@ import vct.result.VerificationError.{SystemError, UserError}
trait ResolutionError extends UserError
-case class MultipleForwardDeclarationContractError(declaration: GlobalDeclaration[_]) extends ResolutionError {
+case class MultipleForwardDeclarationContractError(
+ declaration: GlobalDeclaration[_]
+) extends ResolutionError {
override def code: String = "multipleForwardDeclarationContract"
- override def text: String = declaration.o.messageInContext("Cannot simultaneously bind a contract to multiple global declarations.")
+ override def text: String =
+ declaration.o.messageInContext(
+ "Cannot simultaneously bind a contract to multiple global declarations."
+ )
}
-case class NoSuchNameError(kind: String, name: String, use: Node[_]) extends ResolutionError {
- override def text: String = use.o.messageInContext(s"Could not find $kind named $name.")
+case class NoSuchNameError(kind: String, name: String, use: Node[_])
+ extends ResolutionError {
+ override def text: String =
+ use.o.messageInContext(s"Could not find $kind named $name.")
override def code: String = "noSuchName"
}
case class NoSuchConstructor(use: Node[_]) extends ResolutionError {
- override def text: String = use.o.messageInContext("Could not find a constructor matching the supplied arguments.")
+ override def text: String =
+ use.o.messageInContext(
+ "Could not find a constructor matching the supplied arguments."
+ )
override def code: String = "noSuchConstructor"
}
case class NameLost(o: Origin) extends SystemError {
- override def text: String = o.messageInContext("The origin of this node no longer carries its original name.")
+ override def text: String =
+ o.messageInContext(
+ "The origin of this node no longer carries its original name."
+ )
}
-case class AnonymousMethodsUnsupported(decl: CDeclarator[_]) extends ResolutionError {
- override def text: String = decl.o.messageInContext("Anonymous function declarations are not supported.")
+case class AnonymousMethodsUnsupported(decl: CDeclarator[_])
+ extends ResolutionError {
+ override def text: String =
+ decl.o
+ .messageInContext("Anonymous function declarations are not supported.")
override def code: String = "anonFunction"
}
case class HasNoFields(obj: Expr[_]) extends ResolutionError {
- override def text: String = obj.o.messageInContext("This object has no fields.")
+ override def text: String =
+ obj.o.messageInContext("This object has no fields.")
override def code: String = "hasNoFields"
}
case class NotApplicable(obj: Expr[_]) extends ResolutionError {
- override def text: String = obj.o.messageInContext("It is not possible to call this object")
+ override def text: String =
+ obj.o.messageInContext("It is not possible to call this object")
override def code: String = "notApplicable"
}
-case class ResultOutsideMethod(res: AmbiguousResult[_]) extends ResolutionError {
- override def text: String = res.o.messageInContext("\\result may not occur outside a method.")
+case class ResultOutsideMethod(res: AmbiguousResult[_])
+ extends ResolutionError {
+ override def text: String =
+ res.o.messageInContext("\\result may not occur outside a method.")
override def code: String = "resultOutsideMethod"
}
case class NoGivenYields(invocation: Node[_]) extends ResolutionError {
override def code: String = "noGivenYields"
- override def text: String = invocation.o.messageInContext("This kind of application or invocation does not take parameters via given or yields.")
+ override def text: String =
+ invocation.o.messageInContext(
+ "This kind of application or invocation does not take parameters via given or yields."
+ )
}
-case class WrongArrayInitializer(initializer: JavaLiteralArray[_]) extends ResolutionError {
+case class WrongArrayInitializer(initializer: JavaLiteralArray[_])
+ extends ResolutionError {
override def code: String = "wrongArrayInit"
- override def text: String = initializer.o.messageInContext("This initializer does not initialize an array type.")
+ override def text: String =
+ initializer.o
+ .messageInContext("This initializer does not initialize an array type.")
}
-case class OverlappingJavaImports[G](ns: JavaNamespace[G], kind: String, importedName: String) extends ResolutionError {
+case class OverlappingJavaImports[G](
+ ns: JavaNamespace[G],
+ kind: String,
+ importedName: String,
+) extends ResolutionError {
override def code: String = "overlappingJavaImports"
- override def text: String = ns.o.messageInContext(s"The $kind name $importedName is provided by multiple imports in this namespace")
+ override def text: String =
+ ns.o.messageInContext(
+ s"The $kind name $importedName is provided by multiple imports in this namespace"
+ )
}
case class WrongThisPosition[G](diz: AmbiguousThis[G]) extends ResolutionError {
override def code: String = "wrongThisPosition"
- override def text: String = diz.o.messageInContext("The `this` keyword does not refer to anything in this position.")
+ override def text: String =
+ diz.o.messageInContext(
+ "The `this` keyword does not refer to anything in this position."
+ )
}
-case class ForbiddenEndpointNameType(endpoint: Node[_]) extends ResolutionError {
+case class ForbiddenEndpointNameType(endpoint: Node[_])
+ extends ResolutionError {
override def code: String = "forbiddenEndpointNameType"
- override def text: String = endpoint.o.messageInContext(s"In this endpoint position, a name is referred that is not an endpoint")
+ override def text: String =
+ endpoint.o.messageInContext(
+ s"In this endpoint position, a name is referred that is not an endpoint"
+ )
}
-case class ForbiddenEndpointType(endpoint: PVLEndpoint[_]) extends ResolutionError {
+case class ForbiddenEndpointType(endpoint: PVLEndpoint[_])
+ extends ResolutionError {
override def code: String = "forbiddenEndpointType"
- override def text: String = endpoint.o.messageInContext(s"This endpoint is not of class type")
+ override def text: String =
+ endpoint.o.messageInContext(s"This endpoint is not of class type")
}
-case class ConstructorNotFound(endpoint: PVLEndpoint[_]) extends ResolutionError {
+case class ConstructorNotFound(endpoint: PVLEndpoint[_])
+ extends ResolutionError {
override def code: String = "constructorNotFound"
- override def text: String = endpoint.o.messageInContext(s"Could not find a constructor that matches the types of the arguments of this endpoint.")
+ override def text: String =
+ endpoint.o.messageInContext(
+ s"Could not find a constructor that matches the types of the arguments of this endpoint."
+ )
}
case class UnassignableField(node: Node[_]) extends ResolutionError {
override def code: String = "unassignableField"
- override def text: String = node.o.messageInContext(s"The field in this node is not assignable")
+ override def text: String =
+ node.o.messageInContext(s"The field in this node is not assignable")
}
diff --git a/src/col/vct/col/resolve/Resolve.scala b/src/col/vct/col/resolve/Resolve.scala
index 66de804612..1bd8310820 100644
--- a/src/col/vct/col/resolve/Resolve.scala
+++ b/src/col/vct/col/resolve/Resolve.scala
@@ -11,8 +11,23 @@ import vct.col.resolve.ResolveReferences.scanScope
import vct.col.ref.Ref
import vct.col.resolve.ctx._
import vct.col.resolve.lang.{C, CPP, Java, LLVM, PVL, Spec}
-import vct.col.resolve.Resolve.{MalformedBipAnnotation, SpecContractParser, SpecExprParser, getLit, isBip}
-import vct.col.resolve.lang.JavaAnnotationData.{BipComponent, BipData, BipGuard, BipInvariant, BipPort, BipPure, BipStatePredicate, BipTransition}
+import vct.col.resolve.Resolve.{
+ MalformedBipAnnotation,
+ SpecContractParser,
+ SpecExprParser,
+ getLit,
+ isBip,
+}
+import vct.col.resolve.lang.JavaAnnotationData.{
+ BipComponent,
+ BipData,
+ BipGuard,
+ BipInvariant,
+ BipPort,
+ BipPure,
+ BipStatePredicate,
+ BipTransition,
+}
import vct.col.rewrite.InitialGeneration
import vct.result.VerificationError.{Unreachable, UserError}
@@ -26,45 +41,55 @@ case object Resolve {
}
trait SpecContractParser {
- def parse[G](input: LlvmFunctionContract[G], o: Origin): ApplicableContract[G]
+ def parse[G](
+ input: LlvmFunctionContract[G],
+ o: Origin,
+ ): ApplicableContract[G]
def parse[G](input: LlvmGlobal[G], o: Origin): Seq[GlobalDeclaration[G]]
}
- def extractLiteral(e: Expr[_]): Option[String] = e match {
- case JavaStringValue(guardName, _) =>
- Some(guardName)
- case local @ JavaLocal(_) =>
- local.ref match {
- case Some(RefJavaField(decls, id)) =>
- decls.decls(id).init match {
- case Some(JavaStringValue(data, _)) => Some(data)
- case _ => None
- }
- case _ => None
- }
- case _ => None
- }
+ def extractLiteral(e: Expr[_]): Option[String] =
+ e match {
+ case JavaStringValue(guardName, _) => Some(guardName)
+ case local @ JavaLocal(_) =>
+ local.ref match {
+ case Some(RefJavaField(decls, id)) =>
+ decls.decls(id).init match {
+ case Some(JavaStringValue(data, _)) => Some(data)
+ case _ => None
+ }
+ case _ => None
+ }
+ case _ => None
+ }
case class MalformedBipAnnotation(n: Node[_], err: String) extends UserError {
override def code: String = "badBipAnnotation"
- override def text: String = n.o.messageInContext(s"Malformed JavaBIP annotation: $err")
+ override def text: String =
+ n.o.messageInContext(s"Malformed JavaBIP annotation: $err")
}
case class UnexpectedComplicatedExpression(e: Expr[_]) extends UserError {
override def code: String = "unexpectedComplicatedExpression"
- override def text: String = e.o.messageInContext("This expression must either be a string literal or trivially resolve to one")
+ override def text: String =
+ e.o.messageInContext(
+ "This expression must either be a string literal or trivially resolve to one"
+ )
}
def getLit(e: Expr[_]): String =
extractLiteral(e).getOrElse(throw UnexpectedComplicatedExpression(e))
- def isBip(node: Node[_], `type`: String): Boolean = node match {
- case JavaAnnotation(JavaTClass(r, _), _) => isBip(r.decl, `type`)
- case c: JavaClassOrInterface[_] => c.modifiers.contains(JavaBipAnnotation[InitialGeneration]()(DiagnosticOrigin)) && c.name == `type`
- case _ => false
- }
-
+ def isBip(node: Node[_], `type`: String): Boolean =
+ node match {
+ case JavaAnnotation(JavaTClass(r, _), _) => isBip(r.decl, `type`)
+ case c: JavaClassOrInterface[_] =>
+ c.modifiers
+ .contains(JavaBipAnnotation[InitialGeneration]()(DiagnosticOrigin)) &&
+ c.name == `type`
+ case _ => false
+ }
}
@@ -75,8 +100,15 @@ case object ResolveTypes {
case class Path(root: java.nio.file.Path) extends JavaClassPathEntry
}
- def resolve[G](program: Program[G], externalJavaLoader: Option[ExternalJavaLoader] = None, javaClassPath: Seq[JavaClassPathEntry]): Seq[GlobalDeclaration[G]] = {
- val ctx = TypeResolutionContext[G](externalJavaLoader = externalJavaLoader, javaClassPath = javaClassPath)
+ def resolve[G](
+ program: Program[G],
+ externalJavaLoader: Option[ExternalJavaLoader] = None,
+ javaClassPath: Seq[JavaClassPathEntry],
+ ): Seq[GlobalDeclaration[G]] = {
+ val ctx = TypeResolutionContext[G](
+ externalJavaLoader = externalJavaLoader,
+ javaClassPath = javaClassPath,
+ )
resolve(program, ctx)
ctx.externallyLoadedElements.toSeq
}
@@ -87,202 +119,309 @@ case object ResolveTypes {
resolveOne(node, ctx)
}
- def scanImport[G](imp: JavaImport[G], ctx: TypeResolutionContext[G]): Seq[Referrable[G]] /* importable? */ = imp match {
- case imp @ JavaImport(/* static = */ true, JavaName(fullyQualifiedTypeName :+ staticMember), /* star = */ false) =>
- val staticType = Java.findJavaTypeName(fullyQualifiedTypeName, ctx)
- .getOrElse(throw NoSuchNameError("class", fullyQualifiedTypeName.mkString("."), imp))
- Seq(Java.findStaticMember(staticType, staticMember)
- .getOrElse(throw NoSuchNameError("static member", (fullyQualifiedTypeName :+ staticMember).mkString("."), imp)))
- case imp @ JavaImport(/* static = */ true, JavaName(fullyQualifiedTypeName), /* star = */ true) =>
- val typeName = Java.findJavaTypeName(fullyQualifiedTypeName, ctx)
- .getOrElse(throw NoSuchNameError("class", fullyQualifiedTypeName.mkString("."), imp))
- Java.getStaticMembers(typeName)
- // Non-static imports are resolved on demand
- case _ => Seq()
- }
+ def scanImport[G](
+ imp: JavaImport[G],
+ ctx: TypeResolutionContext[G],
+ ): Seq[Referrable[G]] /* importable? */ =
+ imp match {
+ case imp @ JavaImport(
+ /* static = */ true,
+ JavaName(fullyQualifiedTypeName :+ staticMember), /* star = */ false,
+ ) =>
+ val staticType = Java.findJavaTypeName(fullyQualifiedTypeName, ctx)
+ .getOrElse(
+ throw NoSuchNameError(
+ "class",
+ fullyQualifiedTypeName.mkString("."),
+ imp,
+ )
+ )
+ Seq(Java.findStaticMember(staticType, staticMember).getOrElse(
+ throw NoSuchNameError(
+ "static member",
+ (fullyQualifiedTypeName :+ staticMember).mkString("."),
+ imp,
+ )
+ ))
+ case imp @ JavaImport(
+ /* static = */ true,
+ JavaName(fullyQualifiedTypeName), /* star = */ true,
+ ) =>
+ val typeName = Java.findJavaTypeName(fullyQualifiedTypeName, ctx)
+ .getOrElse(
+ throw NoSuchNameError(
+ "class",
+ fullyQualifiedTypeName.mkString("."),
+ imp,
+ )
+ )
+ Java.getStaticMembers(typeName)
+ // Non-static imports are resolved on demand
+ case _ => Seq()
+ }
- def enterContext[G](node: Node[G], ctx: TypeResolutionContext[G]): TypeResolutionContext[G] = node match {
- case Program(decls) =>
- ctx.copy(stack=decls.flatMap(Referrable.from) +: ctx.stack)
- case ns: JavaNamespace[G] =>
- // Static imports need to be imported at this stage, because they influence how names are resolved.
- // E.g.: in the expression f.g, f is either a 1) variable, 2) parameter or 3) field. If none of those, it must be a
- // 4) statically imported field or typename, or 5) a non-static imported typename. If it's not that, it's a package name.
- // ctx.stack needs to be modified for this, and hence this importing is done in enterContext instead of in resolveOne.
- val ctxWithNs = ctx.copy(namespace=Some(ns))
- ctxWithNs.copy(stack=(ns.declarations.flatMap(Referrable.from) ++ ns.imports.flatMap(scanImport(_, ctxWithNs))) +: ctx.stack)
- case Scope(locals, body) => ctx
- .copy(stack = ((locals ++ scanScope(ctx)(body)).flatMap(Referrable.from)) +: ctx.stack)
- case decl: Declarator[G] =>
- ctx.copy(stack=decl.declarations.flatMap(Referrable.from) +: ctx.stack)
- case _ => ctx
- }
+ def enterContext[G](
+ node: Node[G],
+ ctx: TypeResolutionContext[G],
+ ): TypeResolutionContext[G] =
+ node match {
+ case Program(decls) =>
+ ctx.copy(stack = decls.flatMap(Referrable.from) +: ctx.stack)
+ case ns: JavaNamespace[G] =>
+ // Static imports need to be imported at this stage, because they influence how names are resolved.
+ // E.g.: in the expression f.g, f is either a 1) variable, 2) parameter or 3) field. If none of those, it must be a
+ // 4) statically imported field or typename, or 5) a non-static imported typename. If it's not that, it's a package name.
+ // ctx.stack needs to be modified for this, and hence this importing is done in enterContext instead of in resolveOne.
+ val ctxWithNs = ctx.copy(namespace = Some(ns))
+ ctxWithNs.copy(stack =
+ (ns.declarations.flatMap(Referrable.from) ++
+ ns.imports.flatMap(scanImport(_, ctxWithNs))) +: ctx.stack
+ )
+ case Scope(locals, body) =>
+ ctx.copy(stack =
+ ((locals ++ scanScope(ctx)(body)).flatMap(Referrable.from)) +:
+ ctx.stack
+ )
+ case decl: Declarator[G] =>
+ ctx
+ .copy(stack = decl.declarations.flatMap(Referrable.from) +: ctx.stack)
+ case _ => ctx
+ }
- def resolveOne[G](node: Node[G], ctx: TypeResolutionContext[G]): Unit = node match {
- case javaClass @ JavaNamedType(genericNames) =>
- val names = genericNames.map(_._1)
- javaClass.ref = Some(Java.findJavaTypeName(names, ctx)
- .getOrElse(throw NoSuchNameError("class", names.mkString("."), javaClass)))
- case t @ JavaTClass(ref, _) =>
- ref.tryResolve(name => ???)
- case t @ CTypedefName(name) =>
- t.ref = Some(C.findCTypeName(name, ctx).getOrElse(
- throw NoSuchNameError("typedef", name, t)
- ))
- case t@CStructSpecifier(name) =>
- t.ref = Some(C.findCStruct(name, ctx).getOrElse(
- throw NoSuchNameError("struct", name, t)
- ))
- case t@CPPTypedefName(nestedName, _) =>
- t.ref = Some(CPP.findCPPTypeName(nestedName, ctx).getOrElse(
- throw NoSuchNameError("class, struct, or namespace", nestedName, t)
- ))
- case t @ PVLNamedType(name, typeArgs) =>
- t.ref = Some(PVL.findTypeName(name, ctx).getOrElse(
- throw NoSuchNameError("class", name, t)))
- case t @ TModel(ref) =>
- ref.tryResolve(name => Spec.findModel(name, ctx).getOrElse(throw NoSuchNameError("model", name, t)))
- case t @ TClass(ref, _) =>
- ref.tryResolve(name => Spec.findClass(name, ctx).getOrElse(throw NoSuchNameError("class", name, t)))
- case t @ TAxiomatic(ref, _) =>
- ref.tryResolve(name => Spec.findAdt(name, ctx).getOrElse(throw NoSuchNameError("adt", name, t)))
- case t @ SilverPartialTAxiomatic(ref, partialTypeArgs) =>
- ref.tryResolve(name => Spec.findAdt(name, ctx).getOrElse(throw NoSuchNameError("adt", name, t)))
- partialTypeArgs.foreach(mapping => mapping._1.tryResolve(name => Spec.findAdtTypeArg(ref.decl, name).getOrElse(throw NoSuchNameError("type variable", name, t))))
- case local: JavaLocal[G] =>
- Java.findJavaName(local.name, fromStaticContext = false, ctx) match {
- case Some(
- _: RefVariable[G] | _: RefJavaField[G] | _: RefJavaLocalDeclaration[G] | // Regular names
- _ // Statically imported, or regular previously imported typename
- ) => // Nothing to do. Local will get properly resolved next phase
- case None =>
- // Unknown what this local refers though. Try importing it as a type; otherwise, it's the start of a package
- Java.findJavaTypeName(Seq(local.name), ctx) match {
- case Some(_) => // already imported so nothing to do
- case None =>
- local.ref = Some(RefUnloadedJavaNamespace(Seq(local.name)))
+ def resolveOne[G](node: Node[G], ctx: TypeResolutionContext[G]): Unit =
+ node match {
+ case javaClass @ JavaNamedType(genericNames) =>
+ val names = genericNames.map(_._1)
+ javaClass.ref = Some(Java.findJavaTypeName(names, ctx).getOrElse(
+ throw NoSuchNameError("class", names.mkString("."), javaClass)
+ ))
+ case t @ JavaTClass(ref, _) => ref.tryResolve(name => ???)
+ case t @ CTypedefName(name) =>
+ t.ref = Some(
+ C.findCTypeName(name, ctx)
+ .getOrElse(throw NoSuchNameError("typedef", name, t))
+ )
+ case t @ CStructSpecifier(name) =>
+ t.ref = Some(
+ C.findCStruct(name, ctx)
+ .getOrElse(throw NoSuchNameError("struct", name, t))
+ )
+ case t @ CPPTypedefName(nestedName, _) =>
+ t.ref = Some(CPP.findCPPTypeName(nestedName, ctx).getOrElse(
+ throw NoSuchNameError("class, struct, or namespace", nestedName, t)
+ ))
+ case t @ PVLNamedType(name, typeArgs) =>
+ t.ref = Some(
+ PVL.findTypeName(name, ctx)
+ .getOrElse(throw NoSuchNameError("class", name, t))
+ )
+ case t @ TModel(ref) =>
+ ref.tryResolve(name =>
+ Spec.findModel(name, ctx)
+ .getOrElse(throw NoSuchNameError("model", name, t))
+ )
+ case t @ TClass(ref, _) =>
+ ref.tryResolve(name =>
+ Spec.findClass(name, ctx)
+ .getOrElse(throw NoSuchNameError("class", name, t))
+ )
+ case t @ TAxiomatic(ref, _) =>
+ ref.tryResolve(name =>
+ Spec.findAdt(name, ctx)
+ .getOrElse(throw NoSuchNameError("adt", name, t))
+ )
+ case t @ SilverPartialTAxiomatic(ref, partialTypeArgs) =>
+ ref.tryResolve(name =>
+ Spec.findAdt(name, ctx)
+ .getOrElse(throw NoSuchNameError("adt", name, t))
+ )
+ partialTypeArgs.foreach(mapping =>
+ mapping._1.tryResolve(name =>
+ Spec.findAdtTypeArg(ref.decl, name)
+ .getOrElse(throw NoSuchNameError("type variable", name, t))
+ )
+ )
+ case local: JavaLocal[G] =>
+ Java.findJavaName(local.name, fromStaticContext = false, ctx) match {
+ case Some(
+ _: RefVariable[G] | _: RefJavaField[G] |
+ _: RefJavaLocalDeclaration[G] | // Regular names
+ _ // Statically imported, or regular previously imported typename
+ ) => // Nothing to do. Local will get properly resolved next phase
+ case None =>
+ // Unknown what this local refers though. Try importing it as a type; otherwise, it's the start of a package
+ Java.findJavaTypeName(Seq(local.name), ctx) match {
+ case Some(_) => // already imported so nothing to do
+ case None =>
+ local.ref = Some(RefUnloadedJavaNamespace(Seq(local.name)))
+ }
+ }
+ case deref: JavaDeref[G] =>
+ val ref =
+ deref.obj match {
+ case javalocal: JavaLocal[G] => javalocal.ref
+ case javaderef: JavaDeref[G] => javaderef.ref
+ case _ => None
}
- }
- case deref: JavaDeref[G] =>
- val ref = deref.obj match {
- case javalocal : JavaLocal[G] => javalocal.ref
- case javaderef : JavaDeref[G] => javaderef.ref
- case _ => None
- }
- ref match {
- case Some(RefUnloadedJavaNamespace(names)) =>
- Java.findJavaTypeName(names :+ deref.field, ctx) match {
- case Some(_) => // already imported so nothing to do
- case None =>
- deref.ref = Some(RefUnloadedJavaNamespace(names :+ deref.field))
+ ref match {
+ case Some(RefUnloadedJavaNamespace(names)) =>
+ Java.findJavaTypeName(names :+ deref.field, ctx) match {
+ case Some(_) => // already imported so nothing to do
+ case None =>
+ deref.ref = Some(RefUnloadedJavaNamespace(names :+ deref.field))
+ }
+ case _ => // we did not find a package so we don't do anything
+ }
+ case endpoint: PVLEndpoint[G] =>
+ endpoint.cls.tryResolve(name =>
+ PVL.findTypeName(name, ctx) match {
+ case Some(RefClass(cls: Class[G])) => cls
+ case Some(_) => throw ForbiddenEndpointType(endpoint)
+ case None => throw NoSuchNameError("class", name, endpoint)
}
- case _ => // we did not find a package so we don't do anything
- }
- case endpoint: PVLEndpoint[G] =>
- endpoint.cls.tryResolve(name => PVL.findTypeName(name, ctx) match {
- case Some(RefClass(cls: Class[G])) => cls
- case Some(_) => throw ForbiddenEndpointType(endpoint)
- case None => throw NoSuchNameError("class", name, endpoint)
- })
-
- case _ =>
- }
+ )
+
+ case _ =>
+ }
}
case object ResolveReferences extends LazyLogging {
- def resolve[G](program: Program[G], jp: SpecExprParser, lsp: SpecContractParser): Seq[CheckError] = {
+ def resolve[G](
+ program: Program[G],
+ jp: SpecExprParser,
+ lsp: SpecContractParser,
+ ): Seq[CheckError] = {
resolve(program, ReferenceResolutionContext[G](jp, lsp))
}
- def resolve[G](node: Node[G], ctxIn: ReferenceResolutionContext[G]): Seq[CheckError] = {
- val ctx = resolveFlatlyTopDown(node, ctxIn) match {
- case Left(errs) => return errs
- case Right(ctx) => ctx
- }
+ def resolve[G](
+ node: Node[G],
+ ctxIn: ReferenceResolutionContext[G],
+ ): Seq[CheckError] = {
+ val ctx =
+ resolveFlatlyTopDown(node, ctxIn) match {
+ case Left(errs) => return errs
+ case Right(ctx) => ctx
+ }
- val childErrors = node match {
- case l @ Let(binding, value, main) =>
- val innerCtx = enterContext(node, ctx).withCheckContext(l.enterCheckContext(ctx.checkContext))
- resolve(binding, innerCtx) ++
- resolve(value, ctx) ++
- resolve(main, innerCtx)
- case _ =>
- val innerCtx = enterContext(node, ctx)
- node.checkContextRecursor(ctx.checkContext, { (ctx, node) =>
- resolve(node, innerCtx.withCheckContext(ctx))
- }).flatten
- }
+ val childErrors =
+ node match {
+ case l @ Let(binding, value, main) =>
+ val innerCtx = enterContext(node, ctx)
+ .withCheckContext(l.enterCheckContext(ctx.checkContext))
+ resolve(binding, innerCtx) ++ resolve(value, ctx) ++
+ resolve(main, innerCtx)
+ case _ =>
+ val innerCtx = enterContext(node, ctx)
+ node.checkContextRecursor(
+ ctx.checkContext,
+ { (ctx, node) => resolve(node, innerCtx.withCheckContext(ctx)) },
+ ).flatten
+ }
- if(childErrors.nonEmpty) childErrors
+ if (childErrors.nonEmpty)
+ childErrors
else {
resolveFlatly(node, ctx)
node.check(ctx.checkContext)
}
}
- def resolveFlatlyTopDown[G](node: Node[G], ctx: ReferenceResolutionContext[G]): Either[Seq[CheckError], ReferenceResolutionContext[G]] = node match {
- case f: CFunctionDefinition[G] if f.specs.collectFirst{case _: CGpgpuKernelSpecifier[G] => ()}.isDefined =>
- Right(ctx.copy(inGpuKernel = true))
- case p: Program[G] =>
- p.declarations.foreach {
- case glob: LlvmGlobal[G] =>
- val decls = ctx.llvmSpecParser.parse(glob, glob.o)
- glob.data = Some(decls)
- case _ =>
- }
- Right(ctx)
+ def resolveFlatlyTopDown[G](
+ node: Node[G],
+ ctx: ReferenceResolutionContext[G],
+ ): Either[Seq[CheckError], ReferenceResolutionContext[G]] =
+ node match {
+ case f: CFunctionDefinition[G] if f.specs.collectFirst {
+ case _: CGpgpuKernelSpecifier[G] => ()
+ }.isDefined =>
+ Right(ctx.copy(inGpuKernel = true))
+ case p: Program[G] =>
+ p.declarations.foreach {
+ case glob: LlvmGlobal[G] =>
+ val decls = ctx.llvmSpecParser.parse(glob, glob.o)
+ glob.data = Some(decls)
+ case _ =>
+ }
+ Right(ctx)
- case _ => Right(ctx)
- }
+ case _ => Right(ctx)
+ }
- def scanScope[G](ctx: TypeResolutionContext[G])(node: Node[G]): Seq[Declaration[G]] = node match {
- case _: Scope[G] => Nil
- // Remove shared memory locations from the body level of a GPU kernel, we want to reason about them at the top level
- case CDeclarationStatement(decl) if !(ctx.inGpuKernel && decl.decl.specs.collectFirst{case GPULocal() => ()}.isDefined)
- => Seq(decl)
- case CPPDeclarationStatement(decl) => Seq(decl)
- case JavaLocalDeclarationStatement(decl) => Seq(decl)
- case LocalDecl(v) => Seq(v)
- case other => other.subnodes.flatMap(scanScope(ctx))
- }
+ def scanScope[G](
+ ctx: TypeResolutionContext[G]
+ )(node: Node[G]): Seq[Declaration[G]] =
+ node match {
+ case _: Scope[G] => Nil
+ // Remove shared memory locations from the body level of a GPU kernel, we want to reason about them at the top level
+ case CDeclarationStatement(decl)
+ if !(ctx.inGpuKernel &&
+ decl.decl.specs.collectFirst { case GPULocal() => () }.isDefined) =>
+ Seq(decl)
+ case CPPDeclarationStatement(decl) => Seq(decl)
+ case JavaLocalDeclarationStatement(decl) => Seq(decl)
+ case LocalDecl(v) => Seq(v)
+ case other => other.subnodes.flatMap(scanScope(ctx))
+ }
- def scanLabels[G](node: Node[G]): Seq[Declaration[G]] = node.transSubnodes.collect {
- case decl: LabelDecl[G] => decl
- case decl: SendDecl[G] => decl
- }
+ def scanLabels[G](node: Node[G]): Seq[Declaration[G]] =
+ node.transSubnodes.collect {
+ case decl: LabelDecl[G] => decl
+ case decl: SendDecl[G] => decl
+ }
- def scanBlocks[G](node: ParRegion[G]): Seq[ParBlock[G]] = node match {
- case ParParallel(regions) => regions.flatMap(scanBlocks)
- case ParSequential(regions) => regions.flatMap(scanBlocks)
- case block: ParBlock[G] => Seq(block)
- }
+ def scanBlocks[G](node: ParRegion[G]): Seq[ParBlock[G]] =
+ node match {
+ case ParParallel(regions) => regions.flatMap(scanBlocks)
+ case ParSequential(regions) => regions.flatMap(scanBlocks)
+ case block: ParBlock[G] => Seq(block)
+ }
- def scanShared[G](node: Node[G]): Seq[Declaration[G]] = node.transSubnodes.collect {
- case decl: CLocalDeclaration[G] if decl.decl.specs.collectFirst{case GPULocal() => ()}.isDefined => decl
- }
+ def scanShared[G](node: Node[G]): Seq[Declaration[G]] =
+ node.transSubnodes.collect {
+ case decl: CLocalDeclaration[G] if decl.decl.specs.collectFirst {
+ case GPULocal() => ()
+ }.isDefined =>
+ decl
+ }
- def scanJavaBipGuards[G](nodes: Seq[Declaration[G]]): Seq[(Expr[G], JavaMethod[G])] = nodes.collect {
- case m: JavaMethod[G] if BipGuard.getName(m).isDefined => (BipGuard.getName(m).get, m)
- }
+ def scanJavaBipGuards[G](
+ nodes: Seq[Declaration[G]]
+ ): Seq[(Expr[G], JavaMethod[G])] =
+ nodes.collect {
+ case m: JavaMethod[G] if BipGuard.getName(m).isDefined =>
+ (BipGuard.getName(m).get, m)
+ }
- def scanJavaBipStatePredicates[G](nodes: Seq[JavaModifier[G]]): Seq[(Expr[G], JavaAnnotation[G])] = nodes.collect {
- case ann: JavaAnnotation[G] if isBip(ann, "StatePredicate") => (ann.expect("state"), ann)
- }
+ def scanJavaBipStatePredicates[G](
+ nodes: Seq[JavaModifier[G]]
+ ): Seq[(Expr[G], JavaAnnotation[G])] =
+ nodes.collect {
+ case ann: JavaAnnotation[G] if isBip(ann, "StatePredicate") =>
+ (ann.expect("state"), ann)
+ }
- def enterContext[G](node: Node[G], ctx: ReferenceResolutionContext[G], inGPUKernel: Boolean = false): ReferenceResolutionContext[G] = (node match {
- case ns: JavaNamespace[G] => ctx
- .copy(currentJavaNamespace=Some(ns))
- .copy(stack = ns.imports.flatMap(ResolveTypes.scanImport[G](_, ctx.asTypeResolutionContext)) +: ctx.stack)
- .declare(ns.declarations)
- case cls: JavaClassOrInterface[G] => {
- val newCtx = ctx
- .copy(currentJavaClass = Some(cls))
- .copy(currentThis = Some(RefJavaClass(cls)))
- .declare(cls.decls)
- .declareJavaBipGuards(scanJavaBipGuards(cls.decls))
- .declareJavaBipStatePredicates(scanJavaBipStatePredicates(cls.modifiers))
-
- /* JavaBIP _name keys_ of guard annotations/states cut in line because transitions need to refer to them,
+ def enterContext[G](
+ node: Node[G],
+ ctx: ReferenceResolutionContext[G],
+ inGPUKernel: Boolean = false,
+ ): ReferenceResolutionContext[G] =
+ (node match {
+ case ns: JavaNamespace[G] =>
+ ctx.copy(currentJavaNamespace = Some(ns)).copy(stack =
+ ns.imports.flatMap(
+ ResolveTypes.scanImport[G](_, ctx.asTypeResolutionContext)
+ ) +: ctx.stack
+ ).declare(ns.declarations)
+ case cls: JavaClassOrInterface[G] => {
+ val newCtx = ctx.copy(currentJavaClass = Some(cls))
+ .copy(currentThis = Some(RefJavaClass(cls))).declare(cls.decls)
+ .declareJavaBipGuards(scanJavaBipGuards(cls.decls))
+ .declareJavaBipStatePredicates(scanJavaBipStatePredicates(
+ cls.modifiers
+ ))
+
+ /* JavaBIP _name keys_ of guard annotations/states cut in line because transitions need to refer to them,
_by string value_. So they are fully resolved before proceeding.
E.g. the following two annotations on a method are considered equivalent by the current JavaBIP engine implementation,
given that INIT is some static final field containing "initState":
@@ -290,429 +429,735 @@ case object ResolveReferences extends LazyLogging {
@Transition(source = "initState", ...)
To make this stringly lookup work, state predicate names & guard names must be resolved before
anything else in java classes
- */
- newCtx.javaBipGuards.keys.map(resolve(_, newCtx))
- newCtx.javaBipStatePredicates.keys.map(resolve(_, newCtx))
- newCtx
- }
- case deref: JavaDeref[G] => return ctx
- .copy(topLevelJavaDeref = ctx.topLevelJavaDeref.orElse(Some(deref)))
- case cls: Class[G] => ctx
- .copy(currentThis=Some(RefClass(cls)))
- .declare(cls.declarations)
- // Ensure occurrences of type variables within the class that defines them are ignored when substituting
- .appendTypeEnv(cls.typeArgs.map(v => (v, TVar[G](v.ref))).toMap)
- case adt: AxiomaticDataType[G] => ctx
- // Ensure occurrences of type variables within the adt that defines them are ignored when substituting
- .declare(adt.declarations)
- .appendTypeEnv(adt.typeArgs.map(v => (v, TVar[G](v.ref))).toMap)
- case chor: Choreography[G] => ctx
- .copy(currentThis = Some(RefChoreography(chor)))
- .declare(chor.decls)
- .declare(chor.endpoints)
- .declare(chor.params)
- case chor: PVLChoreography[G] => ctx
- .copy(currentThis = Some(RefPVLChoreography(chor)))
- .declare(chor.args)
- .declare(chor.declarations)
- case channelInv: PVLChannelInvariant[G] => ctx
- .copy(currentCommunicate = Some(channelInv.comm.asInstanceOf[PVLCommunicate[G]]))
- case method: JavaMethod[G] => ctx
- .copy(currentResult=Some(RefJavaMethod(method)))
- .copy(inStaticJavaContext=method.modifiers.collectFirst { case _: JavaStatic[_] => () }.nonEmpty)
- .declare(method.declarations ++ method.body.map(scanLabels).getOrElse(Nil))
- case fields: JavaFields[G] => ctx
- .copy(currentInitializerType=Some(fields.t))
- .copy(inStaticJavaContext=fields.modifiers.collectFirst { case _: JavaStatic[_] => () }.nonEmpty)
- case init: JavaSharedInitialization[G] => ctx
- .copy(inStaticJavaContext=init.isStatic)
- case locals: JavaLocalDeclaration[G] => ctx
- .copy(currentInitializerType=Some(locals.t))
- case decl: JavaVariableDeclaration[G] => ctx
- .copy(currentInitializerType=ctx.currentInitializerType.map(t => FuncTools.repeat((t: Type[G]) => TArray(t), decl.moreDims, t)))
- case arr: JavaNewLiteralArray[G] => ctx
- .copy(currentInitializerType=Some(FuncTools.repeat((t: Type[G]) => TArray(t), arr.dims, arr.baseType)))
- case init: JavaLiteralArray[G] => ctx
- .copy(currentInitializerType=Some(ctx.currentInitializerType.get match {
- case TArray(elem) => elem
- case _ => throw WrongArrayInitializer(init)
- }))
- case func: CFunctionDefinition[G] =>
- var res = ctx
- .copy(currentResult=Some(RefCFunctionDefinition(func)))
- .declare(C.paramsFromDeclarator(func.declarator) ++ scanLabels(func.body) ++ func.contract.givenArgs ++ func.contract.yieldsArgs)
- if(func.specs.collectFirst{case _: CGpgpuKernelSpecifier[G] => ()}.isDefined)
- res = res.declare(scanShared(func.body))
- res
- case func: CGlobalDeclaration[G] =>
- if(func.decl.contract.nonEmpty && func.decl.inits.size > 1) {
- throw MultipleForwardDeclarationContractError(func)
+ */
+ newCtx.javaBipGuards.keys.map(resolve(_, newCtx))
+ newCtx.javaBipStatePredicates.keys.map(resolve(_, newCtx))
+ newCtx
}
- func.decl.inits.zipWithIndex.foldLeft(
- ctx.declare(func.decl.contract.givenArgs ++ func.decl.contract.yieldsArgs)
- ) {
- case (ctx, (init, idx)) =>
+ case deref: JavaDeref[G] =>
+ return ctx
+ .copy(topLevelJavaDeref = ctx.topLevelJavaDeref.orElse(Some(deref)))
+ case cls: Class[G] =>
+ ctx.copy(currentThis = Some(RefClass(cls))).declare(cls.declarations)
+ // Ensure occurrences of type variables within the class that defines them are ignored when substituting
+ .appendTypeEnv(cls.typeArgs.map(v => (v, TVar[G](v.ref))).toMap)
+ case adt: AxiomaticDataType[G] =>
+ ctx
+ // Ensure occurrences of type variables within the adt that defines them are ignored when substituting
+ .declare(adt.declarations)
+ .appendTypeEnv(adt.typeArgs.map(v => (v, TVar[G](v.ref))).toMap)
+ case chor: Choreography[G] =>
+ ctx.copy(currentThis = Some(RefChoreography(chor))).declare(chor.decls)
+ .declare(chor.endpoints).declare(chor.params)
+ case chor: PVLChoreography[G] =>
+ ctx.copy(currentThis = Some(RefPVLChoreography(chor)))
+ .declare(chor.args).declare(chor.declarations)
+ case channelInv: PVLChannelInvariant[G] =>
+ ctx.copy(currentCommunicate =
+ Some(channelInv.comm.asInstanceOf[PVLCommunicate[G]])
+ )
+ case method: JavaMethod[G] =>
+ ctx.copy(currentResult = Some(RefJavaMethod(method)))
+ .copy(inStaticJavaContext =
+ method.modifiers.collectFirst { case _: JavaStatic[_] => () }
+ .nonEmpty
+ ).declare(
+ method.declarations ++ method.body.map(scanLabels).getOrElse(Nil)
+ )
+ case fields: JavaFields[G] =>
+ ctx.copy(currentInitializerType = Some(fields.t))
+ .copy(inStaticJavaContext =
+ fields.modifiers.collectFirst { case _: JavaStatic[_] => () }
+ .nonEmpty
+ )
+ case init: JavaSharedInitialization[G] =>
+ ctx.copy(inStaticJavaContext = init.isStatic)
+ case locals: JavaLocalDeclaration[G] =>
+ ctx.copy(currentInitializerType = Some(locals.t))
+ case decl: JavaVariableDeclaration[G] =>
+ ctx.copy(currentInitializerType =
+ ctx.currentInitializerType.map(t =>
+ FuncTools.repeat((t: Type[G]) => TArray(t), decl.moreDims, t)
+ )
+ )
+ case arr: JavaNewLiteralArray[G] =>
+ ctx.copy(currentInitializerType =
+ Some(
+ FuncTools.repeat((t: Type[G]) => TArray(t), arr.dims, arr.baseType)
+ )
+ )
+ case init: JavaLiteralArray[G] =>
+ ctx.copy(currentInitializerType =
+ Some(ctx.currentInitializerType.get match {
+ case TArray(elem) => elem
+ case _ => throw WrongArrayInitializer(init)
+ })
+ )
+ case func: CFunctionDefinition[G] =>
+ var res = ctx.copy(currentResult = Some(RefCFunctionDefinition(func)))
+ .declare(
+ C.paramsFromDeclarator(func.declarator) ++ scanLabels(func.body) ++
+ func.contract.givenArgs ++ func.contract.yieldsArgs
+ )
+ if (
+ func.specs.collectFirst { case _: CGpgpuKernelSpecifier[G] => () }
+ .isDefined
+ )
+ res = res.declare(scanShared(func.body))
+ res
+ case func: CGlobalDeclaration[G] =>
+ if (func.decl.contract.nonEmpty && func.decl.inits.size > 1) {
+ throw MultipleForwardDeclarationContractError(func)
+ }
+ func.decl.inits.zipWithIndex.foldLeft(ctx.declare(
+ func.decl.contract.givenArgs ++ func.decl.contract.yieldsArgs
+ )) { case (ctx, (init, idx)) =>
val info = C.getDeclaratorInfo(init.decl)
- ctx
- .declare(info.params.getOrElse(Nil))
- .copy(currentResult=info.params.map(_ => RefCGlobalDeclaration(func, idx)))
- }
- case func: CPPFunctionDefinition[G] =>
- ctx
- .copy(currentResult = Some(RefCPPFunctionDefinition(func)))
- .declare(CPP.paramsFromDeclarator(func.declarator) ++ scanLabels(func.body) ++ func.contract.givenArgs ++ func.contract.yieldsArgs)
- case func: CPPGlobalDeclaration[G] =>
- if (func.decl.contract.nonEmpty && func.decl.inits.size > 1) {
- throw MultipleForwardDeclarationContractError(func)
- }
- func.decl.inits.zipWithIndex.foldLeft(
- ctx.declare(func.decl.contract.givenArgs ++ func.decl.contract.yieldsArgs)
- ) {
- case (ctx, (init, idx)) =>
+ ctx.declare(info.params.getOrElse(Nil)).copy(currentResult =
+ info.params.map(_ => RefCGlobalDeclaration(func, idx))
+ )
+ }
+ case func: CPPFunctionDefinition[G] =>
+ ctx.copy(currentResult = Some(RefCPPFunctionDefinition(func))).declare(
+ CPP.paramsFromDeclarator(func.declarator) ++ scanLabels(func.body) ++
+ func.contract.givenArgs ++ func.contract.yieldsArgs
+ )
+ case func: CPPGlobalDeclaration[G] =>
+ if (func.decl.contract.nonEmpty && func.decl.inits.size > 1) {
+ throw MultipleForwardDeclarationContractError(func)
+ }
+ func.decl.inits.zipWithIndex.foldLeft(ctx.declare(
+ func.decl.contract.givenArgs ++ func.decl.contract.yieldsArgs
+ )) { case (ctx, (init, idx)) =>
val info = CPP.getDeclaratorInfo(init.decl)
- ctx
- .declare(info.params.getOrElse(Nil))
- .copy(currentResult = info.params.map(_ => RefCPPGlobalDeclaration(func, idx)))
- }
- case func: CPPLambdaDefinition[G] =>
- ctx.declare(CPP.paramsFromDeclarator(func.declarator) ++ scanLabels(func.body) ++ func.contract.givenArgs ++ func.contract.yieldsArgs)
- case func: LlvmFunctionDefinition[G] => ctx
- .copy(currentResult = Some(RefLlvmFunctionDefinition(func)))
- case func: LlvmSpecFunction[G] => ctx
- .copy(currentResult = Some(RefLlvmSpecFunction(func)))
- .declare(func.args)
- case par: ParStatement[G] => ctx
- .declare(scanBlocks(par.impl).map(_.decl))
- case Scope(locals, body) => ctx
- .declare(locals ++ scanScope(ctx.asTypeResolutionContext)(body))
- case app: ContractApplicable[G] => ctx
- .copy(currentResult = Some(Referrable.from(app).head.asInstanceOf[ResultTarget[G]] /* PB TODO: ew */))
- .declare(app.declarations ++ app.body.map(scanLabels).getOrElse(Nil))
- case app: Applicable[G] => ctx
- .declare(app.declarations ++ app.body.map(scanLabels).getOrElse(Nil))
- case declarator: Declarator[G] => ctx
- .declare(declarator.declarations)
- case _ => ctx
- }).copy(topLevelJavaDeref = None)
-
- def resolveFlatly[G](node: Node[G], ctx: ReferenceResolutionContext[G]): Unit = node match {
- case local@CLocal(name) =>
- local.ref = Some(C.findCName(name, ctx).getOrElse(throw NoSuchNameError("local", name, local)))
- case local@CPPLocal(name, arg) =>
- local.ref = Some(CPP.findCPPName(name, ctx).headOption.getOrElse(throw NoSuchNameError("local", name, local)))
- case local @ JavaLocal(name) =>
- val start: Option[JavaNameTarget[G]] = if (ctx.javaBipGuardsEnabled) {
- Java.findJavaBipGuard(ctx, name).map(RefJavaBipGuard(_))
- } else { None }
- local.ref = Some(start.orElse(
- Java.findJavaName(name, fromStaticContext = ctx.inStaticJavaContext, ctx.asTypeResolutionContext)
- .orElse(Java.findJavaTypeName(Seq(name), ctx.asTypeResolutionContext) match {
- case Some(target: JavaNameTarget[G]) => Some(target)
- case Some(_) | None => None
- }))
- .getOrElse(
- if (ctx.topLevelJavaDeref.isEmpty) throw NoSuchNameError("local", name, local)
- else RefUnloadedJavaNamespace(Seq(name))))
- case local @ PVLLocal(name) =>
- local.ref = Some(PVL.findName(name, ctx).getOrElse(throw NoSuchNameError("local", name, local)))
- case local@Local(ref) =>
- ref.tryResolve(name => Spec.findLocal(name, ctx).getOrElse(throw NoSuchNameError("local", name, local)))
- case local@TVar(ref) =>
- ref.tryResolve(name => Spec.findLocal(name, ctx).getOrElse(throw NoSuchNameError("type variable", name, local)))
- case funcOf@FunctionOf(v, vars) =>
- v.tryResolve(name => Spec.findLocal(name, ctx).getOrElse(throw NoSuchNameError("local", name, funcOf)))
- vars.foreach(v => v.tryResolve(name => Spec.findLocal(name, ctx).getOrElse(throw NoSuchNameError("local", name, funcOf))))
- case local@SilverLocalAssign(ref, _) =>
- ref.tryResolve(name => Spec.findLocal(name, ctx).getOrElse(throw NoSuchNameError("local", name, local)))
- case local@PVLEndpointName(name) => PVL.findName(name, ctx) match {
- case Some(ref: RefPVLEndpoint[G]) => local.ref = Some(ref)
- case Some(_) => throw ForbiddenEndpointNameType(local)
- case None => throw NoSuchNameError("endpoint", name, local)
- }
- case endpoint: PVLEndpoint[G] =>
- endpoint.ref = Some(PVL.findConstructor(TClass(endpoint.cls.decl.ref[Class[G]], Seq()), Seq(), endpoint.args).getOrElse(throw ConstructorNotFound(endpoint)))
- case deref@CStructDeref(struct, field) =>
- deref.ref = Some(C.findPointerDeref(struct, field, ctx, deref.blame).getOrElse(throw NoSuchNameError("field", field, deref)))
- case deref@CFieldAccess(obj, field) =>
- deref.ref = Some(C.findDeref(obj, field, ctx, deref.blame).getOrElse(throw NoSuchNameError("field", field, deref)))
- case deref@CPPClassMethodOrFieldAccess(obj, methodOrFieldName) =>
- deref.ref = Some(CPP.findDeref(obj, methodOrFieldName, ctx, deref.blame).headOption.getOrElse(throw NoSuchNameError("field or instance method", methodOrFieldName, deref)))
- case deref@JavaDeref(obj, field) =>
- deref.ref = Some(Java.findDeref(obj, field, ctx, deref.blame).getOrElse(throw NoSuchNameError("field", field, deref)))
- if (ctx.topLevelJavaDeref.contains(deref) && (deref.ref match {
- case Some(RefUnloadedJavaNamespace(_)) => true
- case _ => false
- })) throw NoSuchNameError("field", field, deref)
- case deref @ PVLDeref(obj, field) =>
- deref.ref = Some(PVL.findDeref(obj, field, ctx, deref.blame).getOrElse(throw NoSuchNameError("field", field, deref)))
- case deref@Deref(obj, field) =>
- field.tryResolve(name => Spec.findField(obj, name).getOrElse(throw NoSuchNameError("field", name, deref)))
- case deref@ModelDeref(obj, field) =>
- field.tryResolve(name => Spec.findModelField(obj, name).getOrElse(throw NoSuchNameError("field", name, deref)))
- case deref@SilverDeref(_, field) =>
- field.tryResolve(name => Spec.findSilverField(name, ctx).getOrElse(throw NoSuchNameError("field", name, deref)))
- case deref@SilverFieldLocation(_, field) =>
- field.tryResolve(name => Spec.findSilverField(name, ctx).getOrElse(throw NoSuchNameError("field", name, deref)))
- case deref@SilverCurFieldPerm(_, field) =>
- field.tryResolve(name => Spec.findSilverField(name, ctx).getOrElse(throw NoSuchNameError("field", name, deref)))
- case deref@SilverFieldAssign(_, field, _) =>
- field.tryResolve(name => Spec.findSilverField(name, ctx).getOrElse(throw NoSuchNameError("field", name, deref)))
-
- case inv@CInvocation(obj, _, givenMap, yields) =>
- inv.ref = Some(C.resolveInvocation(obj, ctx))
- Spec.resolveGiven(givenMap, inv.ref.get, inv)
- Spec.resolveYields(ctx, yields, inv.ref.get, inv)
- case inv@CPPInvocation(obj, args, givenMap, yields) =>
- inv.ref = Some(CPP.resolveInvocation(obj, args, ctx))
- Spec.resolveGiven(givenMap, inv.ref.get, inv)
- Spec.resolveYields(ctx, yields, inv.ref.get, inv)
- case inv@GpgpuCudaKernelInvocation(name, blocks, threads, args, givenMap, yields) =>
- val kernel = C.findCName(name, ctx).getOrElse(throw NoSuchNameError("kernel", name, inv))
- inv.ref = Some(kernel match {
- case target: CInvocationTarget[G] => target
- case _ => throw NotApplicable(inv)
- })
- Spec.resolveGiven(givenMap, inv.ref.get, inv)
- Spec.resolveYields(ctx, yields, inv.ref.get, inv)
- case inv@JavaInvocation(obj, _, method, args, givenMap, yields) =>
- inv.ref = Some((obj match {
- case Some(obj) => Java.findMethod(ctx, obj, method, args, inv.blame)
- case None => Java.findMethod(ctx, method, args)
- }).getOrElse(throw NoSuchNameError("method", method, inv)))
- Spec.resolveGiven(givenMap, inv.ref.get, inv)
- Spec.resolveYields(ctx, yields, inv.ref.get, inv)
- case inv@JavaNewClass(args, typeArgs, name, givenMap, yields) =>
- inv.ref = Some(Java.findConstructor(name, args).getOrElse(throw NoSuchConstructor(inv)))
- Spec.resolveGiven(givenMap, inv.ref.get, inv)
- Spec.resolveYields(ctx, yields, inv.ref.get, inv)
- case inv@PVLInvocation(None, method, args, typeArgs, givenMap, yields) =>
- inv.ref = Some(PVL.findMethod(method, args, typeArgs, ctx).getOrElse(throw NoSuchNameError("method", method, inv)))
- Spec.resolveGiven(givenMap, inv.ref.get, inv)
- Spec.resolveYields(ctx, yields, inv.ref.get, inv)
- case inv@PVLInvocation(Some(obj), method, args, typeArgs, givenMap, yields) =>
- inv.ref = Some(PVL.findInstanceMethod(obj, method, args, typeArgs, inv.blame).getOrElse(throw NoSuchNameError("method", method, inv)))
- Spec.resolveGiven(givenMap, inv.ref.get, inv)
- Spec.resolveYields(ctx, yields, inv.ref.get, inv)
- case inv@PVLNew(t, typeArgs, args, givenMap, yields) =>
- inv.ref = Some(PVL.findConstructor(t, typeArgs, args).getOrElse(throw NoSuchConstructor(inv)))
- Spec.resolveGiven(givenMap, inv.ref.get, inv)
- Spec.resolveYields(ctx, yields, inv.ref.get, inv)
- case n@NewObject(ref) =>
- ref.tryResolve(name => Spec.findClass(name, ctx.asTypeResolutionContext).getOrElse(throw NoSuchNameError("class", name, n)))
- case n@ModelNew(ref) =>
- ref.tryResolve(name => Spec.findModel(name, ctx.asTypeResolutionContext).getOrElse(throw NoSuchNameError("model", name, n)))
- case n@SilverNewRef(target, fields) =>
- target.tryResolve(name => Spec.findLocal(name, ctx).getOrElse(throw NoSuchNameError("local", name, n)))
- fields.foreach(_.tryResolve(name => Spec.findSilverField(name, ctx).getOrElse(throw NoSuchNameError("field", name, n))))
- case inv@ADTFunctionInvocation(typeArgs, ref, args) =>
- typeArgs match {
- case Some((adt, typeArgs)) =>
- // Fully-qualified external invocation
- adt.tryResolve(name => Spec.findAdt(name, ctx.asTypeResolutionContext).getOrElse(throw NoSuchNameError("adt", name, inv)))
- ref.tryResolve(name => Spec.findAdtFunction(adt.decl, name).getOrElse(throw NoSuchNameError("function", name, inv)))
- case None =>
- // Non-qualified internal invocation
- ???
- }
- case inv@SilverPartialADTFunctionInvocation(name, args, partialTypeArgs) =>
- inv.ref = Some(Spec.findAdtFunction(name, ctx).getOrElse(throw NoSuchNameError("function", name, inv)))
- partialTypeArgs.foreach(mapping => mapping._1.tryResolve(name => Spec.findAdtTypeArg(inv.adt, name).getOrElse(throw NoSuchNameError("type variable", name, inv))))
- case inv @ InvokeProcedure(ref, _, _, _, givenMap, yields) =>
- ref.tryResolve(name => Spec.findProcedure(name, ctx).getOrElse(throw NoSuchNameError("procedure", name, inv)))
- Spec.resolveGiven(givenMap, RefProcedure(ref.decl), inv)
- Spec.resolveYields(ctx, yields, RefProcedure(ref.decl), inv)
- case inv @ ProcedureInvocation(ref, _, _, _, givenMap, yields) =>
- ref.tryResolve(name => Spec.findProcedure(name, ctx).getOrElse(throw NoSuchNameError("procedure", name, inv)))
- Spec.resolveGiven(givenMap, RefProcedure(ref.decl), inv)
- Spec.resolveYields(ctx, yields, RefProcedure(ref.decl), inv)
- case inv@FunctionInvocation(ref, _, _, givenMap, yields) =>
- ref.tryResolve(name => Spec.findFunction(name, ctx).getOrElse(throw NoSuchNameError("function", name, inv)))
- Spec.resolveGiven(givenMap, RefFunction(ref.decl), inv)
- Spec.resolveYields(ctx, yields, RefFunction(ref.decl), inv)
- case inv@PredicateApply(ref, _, _) =>
- ref.tryResolve(name => Spec.findPredicate(name, ctx).getOrElse(throw NoSuchNameError("predicate", name, inv)))
- case inv@SilverCurPredPerm(ref, _) =>
- ref.tryResolve(name => Spec.findPredicate(name, ctx).getOrElse(throw NoSuchNameError("predicate", name, inv)))
- case inv @ InvokeMethod(obj, ref, _, _, _, givenMap, yields) =>
- ref.tryResolve(name => Spec.findMethod(obj, name).getOrElse(throw NoSuchNameError("method", name, inv)))
- Spec.resolveGiven(givenMap, RefInstanceMethod(ref.decl), inv)
- Spec.resolveYields(ctx, yields, RefInstanceMethod(ref.decl), inv)
- case inv @ MethodInvocation(obj, ref, _, _, _, givenMap, yields) =>
- ref.tryResolve(name => Spec.findMethod(obj, name).getOrElse(throw NoSuchNameError("method", name, inv)))
- Spec.resolveGiven(givenMap, RefInstanceMethod(ref.decl), inv)
- Spec.resolveYields(ctx, yields, RefInstanceMethod(ref.decl), inv)
- case inv@InstanceFunctionInvocation(obj, ref, _, _, givenMap, yields) =>
- ref.tryResolve(name => Spec.findInstanceFunction(obj, name).getOrElse(throw NoSuchNameError("function", name, inv)))
- case inv@InstancePredicateApply(obj, ref, _, _) =>
- ref.tryResolve(name => Spec.findInstancePredicate(obj, name).getOrElse(throw NoSuchNameError("predicate", name, inv)))
- case inv @ CoalesceInstancePredicateApply(obj, ref, _, _) =>
- ref.tryResolve(name => Spec.findInstancePredicate(obj, name).getOrElse(throw NoSuchNameError("predicate", name, inv)))
-
- case defn: CFunctionDefinition[G] =>
- defn.ref = C.findForwardDeclaration(defn.declarator, ctx)
- case decl: CInit[G] =>
- decl.ref = C.findDefinition(decl.decl, ctx)
-
- case defn: CPPFunctionDefinition[G] =>
- defn.ref = CPP.findForwardDeclaration(defn.declarator, ctx)
- case decl: CPPInit[G] =>
- decl.ref = CPP.findDefinition(decl.decl, ctx)
-
- case goto@CGoto(name) =>
- goto.ref = Some(Spec.findLabel(name, ctx).getOrElse(throw NoSuchNameError("label", name, goto)))
- case goto@Goto(lbl) =>
- lbl.tryResolve(name => Spec.findLabel(name, ctx).getOrElse(throw NoSuchNameError("label", name, goto)))
- case brk@Break(Some(lbl)) =>
- lbl.tryResolve(name => Spec.findLabel(name, ctx).getOrElse(throw NoSuchNameError("label", name, brk)))
- case cont@Continue(Some(lbl)) =>
- lbl.tryResolve(name => Spec.findLabel(name, ctx).getOrElse(throw NoSuchNameError("label", name, cont)))
- case old@Old(_, Some(lbl)) =>
- lbl.tryResolve(name => Spec.findLabel(name, ctx).getOrElse(throw NoSuchNameError("label", name, old)))
-
- case recv@Recv(ref) =>
- ref.tryResolve(name => Spec.findSend(name, ctx).getOrElse(throw NoSuchNameError("send statement", name, recv)))
-
- case res@AmbiguousResult() =>
- res.ref = Some(ctx.currentResult.getOrElse(throw ResultOutsideMethod(res)))
- case diz@AmbiguousThis() =>
- diz.ref = Some(ctx.currentThis.getOrElse(throw WrongThisPosition(diz)))
-
- case proc: ModelProcess[G] =>
- proc.modifies.foreach(_.tryResolve(name => Spec.findModelField(name, ctx)
- .getOrElse(throw NoSuchNameError("field", name, proc))))
- proc.accessible.foreach(_.tryResolve(name => Spec.findModelField(name, ctx)
- .getOrElse(throw NoSuchNameError("field", name, proc))))
- case act: ModelAction[G] =>
- act.modifies.foreach(_.tryResolve(name => Spec.findModelField(name, ctx)
- .getOrElse(throw NoSuchNameError("field", name, act))))
- act.accessible.foreach(_.tryResolve(name => Spec.findModelField(name, ctx)
- .getOrElse(throw NoSuchNameError("field", name, act))))
-
- case inv@ProcessApply(ref, _) =>
- ref.tryResolve(name => ???)
- case inv@ActionApply(ref, _) =>
- ref.tryResolve(name => ???)
-
- case atomic@ParAtomic(invs, _) =>
- invs.foreach(_.tryResolve(name => Spec.findParInvariant(name, ctx)
- .getOrElse(throw NoSuchNameError("invariant", name, atomic))))
- case barrier@ParBarrier(block, invs, _, _, _) =>
- block.tryResolve(name => Spec.findParBlock(name, ctx)
- .getOrElse(throw NoSuchNameError("block", name, barrier)))
- invs.foreach(_.tryResolve(name => Spec.findParInvariant(name, ctx)
- .getOrElse(throw NoSuchNameError("invariant", name, barrier))))
-
- case arr@JavaLiteralArray(_) =>
- arr.typeContext = Some(ctx.currentInitializerType.get match {
- case t@TArray(_) => t
- case _ => throw WrongArrayInitializer(arr)
- })
-
- case ann@JavaAnnotation(_, _) if isBip(ann, "Transition") =>
- val guard: Option[Expr[G]] = ann.get("guard").map { g =>
- val expr: Expr[G] = ctx.javaParser.parse(getLit(g), g.o)
- // TODO: What about check errors here?
- resolve(expr, ctx.enableJavaBipGuards())
- expr
- }
+ ctx.declare(info.params.getOrElse(Nil)).copy(currentResult =
+ info.params.map(_ => RefCPPGlobalDeclaration(func, idx))
+ )
+ }
+ case func: CPPLambdaDefinition[G] =>
+ ctx.declare(
+ CPP.paramsFromDeclarator(func.declarator) ++ scanLabels(func.body) ++
+ func.contract.givenArgs ++ func.contract.yieldsArgs
+ )
+ case func: LlvmFunctionDefinition[G] =>
+ ctx.copy(currentResult = Some(RefLlvmFunctionDefinition(func)))
+ case func: LlvmSpecFunction[G] =>
+ ctx.copy(currentResult = Some(RefLlvmSpecFunction(func)))
+ .declare(func.args)
+ case par: ParStatement[G] => ctx.declare(scanBlocks(par.impl).map(_.decl))
+ case Scope(locals, body) =>
+ ctx.declare(locals ++ scanScope(ctx.asTypeResolutionContext)(body))
+ case app: ContractApplicable[G] =>
+ ctx.copy(currentResult =
+ Some(
+ Referrable.from(app).head
+ .asInstanceOf[ResultTarget[G]] /* PB TODO: ew */
+ )
+ ).declare(app.declarations ++ app.body.map(scanLabels).getOrElse(Nil))
+ case app: Applicable[G] =>
+ ctx.declare(app.declarations ++ app.body.map(scanLabels).getOrElse(Nil))
+ case declarator: Declarator[G] => ctx.declare(declarator.declarations)
+ case _ => ctx
+ }).copy(topLevelJavaDeref = None)
- def extractExpr(s: Option[Expr[_]]): (String, Origin) = s match {
- case None => ("true", ann.o)
- case Some(s @ JavaStringValue(data, _)) => (data, s.o)
- case Some(n) => throw MalformedBipAnnotation(n, "pre- and post-conditions must be string literals")
- }
+ def resolveFlatly[G](
+ node: Node[G],
+ ctx: ReferenceResolutionContext[G],
+ ): Unit =
+ node match {
+ case local @ CLocal(name) =>
+ local.ref = Some(
+ C.findCName(name, ctx)
+ .getOrElse(throw NoSuchNameError("local", name, local))
+ )
+ case local @ CPPLocal(name, arg) =>
+ local.ref = Some(
+ CPP.findCPPName(name, ctx).headOption
+ .getOrElse(throw NoSuchNameError("local", name, local))
+ )
+ case local @ JavaLocal(name) =>
+ val start: Option[JavaNameTarget[G]] =
+ if (ctx.javaBipGuardsEnabled) {
+ Java.findJavaBipGuard(ctx, name).map(RefJavaBipGuard(_))
+ } else { None }
+ local.ref = Some(
+ start.orElse(
+ Java.findJavaName(
+ name,
+ fromStaticContext = ctx.inStaticJavaContext,
+ ctx.asTypeResolutionContext,
+ ).orElse(
+ Java
+ .findJavaTypeName(
+ Seq(name),
+ ctx.asTypeResolutionContext,
+ ) match {
+ case Some(target: JavaNameTarget[G]) => Some(target)
+ case Some(_) | None => None
+ }
+ )
+ ).getOrElse(
+ if (ctx.topLevelJavaDeref.isEmpty)
+ throw NoSuchNameError("local", name, local)
+ else
+ RefUnloadedJavaNamespace(Seq(name))
+ )
+ )
+ case local @ PVLLocal(name) =>
+ local.ref = Some(
+ PVL.findName(name, ctx)
+ .getOrElse(throw NoSuchNameError("local", name, local))
+ )
+ case local @ Local(ref) =>
+ ref.tryResolve(name =>
+ Spec.findLocal(name, ctx)
+ .getOrElse(throw NoSuchNameError("local", name, local))
+ )
+ case local @ TVar(ref) =>
+ ref.tryResolve(name =>
+ Spec.findLocal(name, ctx)
+ .getOrElse(throw NoSuchNameError("type variable", name, local))
+ )
+ case funcOf @ FunctionOf(v, vars) =>
+ v.tryResolve(name =>
+ Spec.findLocal(name, ctx)
+ .getOrElse(throw NoSuchNameError("local", name, funcOf))
+ )
+ vars.foreach(v =>
+ v.tryResolve(name =>
+ Spec.findLocal(name, ctx)
+ .getOrElse(throw NoSuchNameError("local", name, funcOf))
+ )
+ )
+ case local @ SilverLocalAssign(ref, _) =>
+ ref.tryResolve(name =>
+ Spec.findLocal(name, ctx)
+ .getOrElse(throw NoSuchNameError("local", name, local))
+ )
+ case local @ PVLEndpointName(name) =>
+ PVL.findName(name, ctx) match {
+ case Some(ref: RefPVLEndpoint[G]) => local.ref = Some(ref)
+ case Some(_) => throw ForbiddenEndpointNameType(local)
+ case None => throw NoSuchNameError("endpoint", name, local)
+ }
+ case endpoint: PVLEndpoint[G] =>
+ endpoint.ref = Some(
+ PVL.findConstructor(
+ TClass(endpoint.cls.decl.ref[Class[G]], Seq()),
+ Seq(),
+ endpoint.args,
+ ).getOrElse(throw ConstructorNotFound(endpoint))
+ )
+ case deref @ CStructDeref(struct, field) =>
+ deref.ref = Some(
+ C.findPointerDeref(struct, field, ctx, deref.blame)
+ .getOrElse(throw NoSuchNameError("field", field, deref))
+ )
+ case deref @ CFieldAccess(obj, field) =>
+ deref.ref = Some(
+ C.findDeref(obj, field, ctx, deref.blame)
+ .getOrElse(throw NoSuchNameError("field", field, deref))
+ )
+ case deref @ CPPClassMethodOrFieldAccess(obj, methodOrFieldName) =>
+ deref.ref = Some(
+ CPP.findDeref(obj, methodOrFieldName, ctx, deref.blame).headOption
+ .getOrElse(
+ throw NoSuchNameError(
+ "field or instance method",
+ methodOrFieldName,
+ deref,
+ )
+ )
+ )
+ case deref @ JavaDeref(obj, field) =>
+ deref.ref = Some(
+ Java.findDeref(obj, field, ctx, deref.blame)
+ .getOrElse(throw NoSuchNameError("field", field, deref))
+ )
+ if (
+ ctx.topLevelJavaDeref.contains(deref) &&
+ (deref.ref match {
+ case Some(RefUnloadedJavaNamespace(_)) => true
+ case _ => false
+ })
+ )
+ throw NoSuchNameError("field", field, deref)
+ case deref @ PVLDeref(obj, field) =>
+ deref.ref = Some(
+ PVL.findDeref(obj, field, ctx, deref.blame)
+ .getOrElse(throw NoSuchNameError("field", field, deref))
+ )
+ case deref @ Deref(obj, field) =>
+ field.tryResolve(name =>
+ Spec.findField(obj, name)
+ .getOrElse(throw NoSuchNameError("field", name, deref))
+ )
+ case deref @ ModelDeref(obj, field) =>
+ field.tryResolve(name =>
+ Spec.findModelField(obj, name)
+ .getOrElse(throw NoSuchNameError("field", name, deref))
+ )
+ case deref @ SilverDeref(_, field) =>
+ field.tryResolve(name =>
+ Spec.findSilverField(name, ctx)
+ .getOrElse(throw NoSuchNameError("field", name, deref))
+ )
+ case deref @ SilverFieldLocation(_, field) =>
+ field.tryResolve(name =>
+ Spec.findSilverField(name, ctx)
+ .getOrElse(throw NoSuchNameError("field", name, deref))
+ )
+ case deref @ SilverCurFieldPerm(_, field) =>
+ field.tryResolve(name =>
+ Spec.findSilverField(name, ctx)
+ .getOrElse(throw NoSuchNameError("field", name, deref))
+ )
+ case deref @ SilverFieldAssign(_, field, _) =>
+ field.tryResolve(name =>
+ Spec.findSilverField(name, ctx)
+ .getOrElse(throw NoSuchNameError("field", name, deref))
+ )
- val (r, ro) = extractExpr(ann.get("requires"))
- val requires: Expr[G] = ctx.javaParser.parse(r, ro)
- resolve(requires, ctx)
-
- val (e, eo) = extractExpr(ann.get("ensures"))
- val ensures: Expr[G] = ctx.javaParser.parse(e, eo)
- resolve(ensures, ctx)
-
- val name = getLit(ann.expect("name"))
- val source = getLit(ann.expect("source"))
- val target = getLit(ann.expect("target"))
- ann.data = Some(BipTransition[G](name,
- Java.findJavaBipStatePredicate(ctx, source),
- Java.findJavaBipStatePredicate(ctx, target),
- ann.get("guard").map(getLit(_)),
- guard, requires, ensures)(ann.o))
-
- case ann@JavaAnnotation(_, _) if isBip(ann, "Invariant") =>
- val expr: Expr[G] = ctx.javaParser.parse(getLit(ann.expect("value")), ann.expect("value").o)
- resolve(expr, ctx)
- ann.data = Some(BipInvariant(expr))
-
- case ann@JavaAnnotation(_, _) if isBip(ann, "StatePredicate") =>
- val expr: Expr[G] = ctx.javaParser.parse(getLit(ann.expect("expr")), ann.expect("expr").o)
- resolve(expr, ctx) // TODO (RR): Throwing away errors here?
- ann.data = Some(BipStatePredicate(getLit(ann.expect("state")), expr)(ann.o))
-
- case ann@JavaAnnotation(_, _) if isBip(ann, "ComponentType") =>
- ann.data = Some(BipComponent(getLit(ann.expect("name")),
- Java.findJavaBipStatePredicate(ctx, getLit(ann.expect("initial")))))
-
- case ann@JavaAnnotation(_, _) if isBip(ann, "Data") =>
- ann.data = Some(BipData(getLit(ann.expect("name")))(ann.o))
-
- case ann@JavaAnnotation(_, _) if isBip(ann, "Guard") =>
- ann.data = Some(BipGuard(getLit(ann.expect("name"))))
-
- case ann: JavaAnnotation[G] if isBip(ann, "Port") =>
- val portType: BipPortType[G] = ann.expect("type") match {
- case p @ JavaDeref(_, "enforceable") => BipEnforceable[G]()(p.o)
- case p @ JavaDeref(_, "spontaneous") => BipSpontaneous[G]()(p.o)
- case p @ JavaDeref(_, "internal") => BipInternal[G]()(p.o)
- case e => throw MalformedBipAnnotation(e, "Can be either PortType.enforceable, spontaneous, or internal")
- }
- ann.data = Some(BipPort[G](getLit(ann.expect("name")), portType)(ann.o))
-
- case ann: JavaAnnotation[G] if isBip(ann, "Pure") =>
- ann.data = Some(BipPure[G]())
-
- case portName @ JavaBipGlueName(JavaTClass(Ref(cls: JavaClass[G]), Nil), name) =>
- portName.data = Some((cls, getLit(name)))
-
- case contract: LlvmFunctionContract[G] =>
- val applicableContract = ctx.llvmSpecParser.parse(contract, contract.o)
- contract.data = Some(applicableContract)
- resolve(applicableContract, ctx)
- case local: LlvmLocal[G] =>
- local.ref = ctx.currentResult.get match {
- case RefLlvmFunctionDefinition(decl) =>
- decl.contract.variableRefs.find(ref => ref._1 == local.name) match {
- case Some(ref) => Some(ref._2)
- case None => throw NoSuchNameError("local", local.name, local)
+ case inv @ CInvocation(obj, _, givenMap, yields) =>
+ inv.ref = Some(C.resolveInvocation(obj, ctx))
+ Spec.resolveGiven(givenMap, inv.ref.get, inv)
+ Spec.resolveYields(ctx, yields, inv.ref.get, inv)
+ case inv @ CPPInvocation(obj, args, givenMap, yields) =>
+ inv.ref = Some(CPP.resolveInvocation(obj, args, ctx))
+ Spec.resolveGiven(givenMap, inv.ref.get, inv)
+ Spec.resolveYields(ctx, yields, inv.ref.get, inv)
+ case inv @ GpgpuCudaKernelInvocation(
+ name,
+ blocks,
+ threads,
+ args,
+ givenMap,
+ yields,
+ ) =>
+ val kernel = C.findCName(name, ctx)
+ .getOrElse(throw NoSuchNameError("kernel", name, inv))
+ inv.ref = Some(kernel match {
+ case target: CInvocationTarget[G] => target
+ case _ => throw NotApplicable(inv)
+ })
+ Spec.resolveGiven(givenMap, inv.ref.get, inv)
+ Spec.resolveYields(ctx, yields, inv.ref.get, inv)
+ case inv @ JavaInvocation(obj, _, method, args, givenMap, yields) =>
+ inv.ref = Some(
+ (obj match {
+ case Some(obj) => Java.findMethod(ctx, obj, method, args, inv.blame)
+ case None => Java.findMethod(ctx, method, args)
+ }).getOrElse(throw NoSuchNameError("method", method, inv))
+ )
+ Spec.resolveGiven(givenMap, inv.ref.get, inv)
+ Spec.resolveYields(ctx, yields, inv.ref.get, inv)
+ case inv @ JavaNewClass(args, typeArgs, name, givenMap, yields) =>
+ inv.ref = Some(
+ Java.findConstructor(name, args)
+ .getOrElse(throw NoSuchConstructor(inv))
+ )
+ Spec.resolveGiven(givenMap, inv.ref.get, inv)
+ Spec.resolveYields(ctx, yields, inv.ref.get, inv)
+ case inv @ PVLInvocation(
+ None,
+ method,
+ args,
+ typeArgs,
+ givenMap,
+ yields,
+ ) =>
+ inv.ref = Some(
+ PVL.findMethod(method, args, typeArgs, ctx)
+ .getOrElse(throw NoSuchNameError("method", method, inv))
+ )
+ Spec.resolveGiven(givenMap, inv.ref.get, inv)
+ Spec.resolveYields(ctx, yields, inv.ref.get, inv)
+ case inv @ PVLInvocation(
+ Some(obj),
+ method,
+ args,
+ typeArgs,
+ givenMap,
+ yields,
+ ) =>
+ inv.ref = Some(
+ PVL.findInstanceMethod(obj, method, args, typeArgs, inv.blame)
+ .getOrElse(throw NoSuchNameError("method", method, inv))
+ )
+ Spec.resolveGiven(givenMap, inv.ref.get, inv)
+ Spec.resolveYields(ctx, yields, inv.ref.get, inv)
+ case inv @ PVLNew(t, typeArgs, args, givenMap, yields) =>
+ inv.ref = Some(
+ PVL.findConstructor(t, typeArgs, args)
+ .getOrElse(throw NoSuchConstructor(inv))
+ )
+ Spec.resolveGiven(givenMap, inv.ref.get, inv)
+ Spec.resolveYields(ctx, yields, inv.ref.get, inv)
+ case n @ NewObject(ref) =>
+ ref.tryResolve(name =>
+ Spec.findClass(name, ctx.asTypeResolutionContext)
+ .getOrElse(throw NoSuchNameError("class", name, n))
+ )
+ case n @ ModelNew(ref) =>
+ ref.tryResolve(name =>
+ Spec.findModel(name, ctx.asTypeResolutionContext)
+ .getOrElse(throw NoSuchNameError("model", name, n))
+ )
+ case n @ SilverNewRef(target, fields) =>
+ target.tryResolve(name =>
+ Spec.findLocal(name, ctx)
+ .getOrElse(throw NoSuchNameError("local", name, n))
+ )
+ fields.foreach(
+ _.tryResolve(name =>
+ Spec.findSilverField(name, ctx)
+ .getOrElse(throw NoSuchNameError("field", name, n))
+ )
+ )
+ case inv @ ADTFunctionInvocation(typeArgs, ref, args) =>
+ typeArgs match {
+ case Some((adt, typeArgs)) =>
+ // Fully-qualified external invocation
+ adt.tryResolve(name =>
+ Spec.findAdt(name, ctx.asTypeResolutionContext)
+ .getOrElse(throw NoSuchNameError("adt", name, inv))
+ )
+ ref.tryResolve(name =>
+ Spec.findAdtFunction(adt.decl, name)
+ .getOrElse(throw NoSuchNameError("function", name, inv))
+ )
+ case None =>
+ // Non-qualified internal invocation
+ ???
+ }
+ case inv @ SilverPartialADTFunctionInvocation(
+ name,
+ args,
+ partialTypeArgs,
+ ) =>
+ inv.ref = Some(
+ Spec.findAdtFunction(name, ctx)
+ .getOrElse(throw NoSuchNameError("function", name, inv))
+ )
+ partialTypeArgs.foreach(mapping =>
+ mapping._1.tryResolve(name =>
+ Spec.findAdtTypeArg(inv.adt, name)
+ .getOrElse(throw NoSuchNameError("type variable", name, inv))
+ )
+ )
+ case inv @ InvokeProcedure(ref, _, _, _, givenMap, yields) =>
+ ref.tryResolve(name =>
+ Spec.findProcedure(name, ctx)
+ .getOrElse(throw NoSuchNameError("procedure", name, inv))
+ )
+ Spec.resolveGiven(givenMap, RefProcedure(ref.decl), inv)
+ Spec.resolveYields(ctx, yields, RefProcedure(ref.decl), inv)
+ case inv @ ProcedureInvocation(ref, _, _, _, givenMap, yields) =>
+ ref.tryResolve(name =>
+ Spec.findProcedure(name, ctx)
+ .getOrElse(throw NoSuchNameError("procedure", name, inv))
+ )
+ Spec.resolveGiven(givenMap, RefProcedure(ref.decl), inv)
+ Spec.resolveYields(ctx, yields, RefProcedure(ref.decl), inv)
+ case inv @ FunctionInvocation(ref, _, _, givenMap, yields) =>
+ ref.tryResolve(name =>
+ Spec.findFunction(name, ctx)
+ .getOrElse(throw NoSuchNameError("function", name, inv))
+ )
+ Spec.resolveGiven(givenMap, RefFunction(ref.decl), inv)
+ Spec.resolveYields(ctx, yields, RefFunction(ref.decl), inv)
+ case inv @ PredicateApply(ref, _, _) =>
+ ref.tryResolve(name =>
+ Spec.findPredicate(name, ctx)
+ .getOrElse(throw NoSuchNameError("predicate", name, inv))
+ )
+ case inv @ SilverCurPredPerm(ref, _) =>
+ ref.tryResolve(name =>
+ Spec.findPredicate(name, ctx)
+ .getOrElse(throw NoSuchNameError("predicate", name, inv))
+ )
+ case inv @ InvokeMethod(obj, ref, _, _, _, givenMap, yields) =>
+ ref.tryResolve(name =>
+ Spec.findMethod(obj, name)
+ .getOrElse(throw NoSuchNameError("method", name, inv))
+ )
+ Spec.resolveGiven(givenMap, RefInstanceMethod(ref.decl), inv)
+ Spec.resolveYields(ctx, yields, RefInstanceMethod(ref.decl), inv)
+ case inv @ MethodInvocation(obj, ref, _, _, _, givenMap, yields) =>
+ ref.tryResolve(name =>
+ Spec.findMethod(obj, name)
+ .getOrElse(throw NoSuchNameError("method", name, inv))
+ )
+ Spec.resolveGiven(givenMap, RefInstanceMethod(ref.decl), inv)
+ Spec.resolveYields(ctx, yields, RefInstanceMethod(ref.decl), inv)
+ case inv @ InstanceFunctionInvocation(obj, ref, _, _, givenMap, yields) =>
+ ref.tryResolve(name =>
+ Spec.findInstanceFunction(obj, name)
+ .getOrElse(throw NoSuchNameError("function", name, inv))
+ )
+ case inv @ InstancePredicateApply(obj, ref, _, _) =>
+ ref.tryResolve(name =>
+ Spec.findInstancePredicate(obj, name)
+ .getOrElse(throw NoSuchNameError("predicate", name, inv))
+ )
+ case inv @ CoalesceInstancePredicateApply(obj, ref, _, _) =>
+ ref.tryResolve(name =>
+ Spec.findInstancePredicate(obj, name)
+ .getOrElse(throw NoSuchNameError("predicate", name, inv))
+ )
+
+ case defn: CFunctionDefinition[G] =>
+ defn.ref = C.findForwardDeclaration(defn.declarator, ctx)
+ case decl: CInit[G] => decl.ref = C.findDefinition(decl.decl, ctx)
+
+ case defn: CPPFunctionDefinition[G] =>
+ defn.ref = CPP.findForwardDeclaration(defn.declarator, ctx)
+ case decl: CPPInit[G] => decl.ref = CPP.findDefinition(decl.decl, ctx)
+
+ case goto @ CGoto(name) =>
+ goto.ref = Some(
+ Spec.findLabel(name, ctx)
+ .getOrElse(throw NoSuchNameError("label", name, goto))
+ )
+ case goto @ Goto(lbl) =>
+ lbl.tryResolve(name =>
+ Spec.findLabel(name, ctx)
+ .getOrElse(throw NoSuchNameError("label", name, goto))
+ )
+ case brk @ Break(Some(lbl)) =>
+ lbl.tryResolve(name =>
+ Spec.findLabel(name, ctx)
+ .getOrElse(throw NoSuchNameError("label", name, brk))
+ )
+ case cont @ Continue(Some(lbl)) =>
+ lbl.tryResolve(name =>
+ Spec.findLabel(name, ctx)
+ .getOrElse(throw NoSuchNameError("label", name, cont))
+ )
+ case old @ Old(_, Some(lbl)) =>
+ lbl.tryResolve(name =>
+ Spec.findLabel(name, ctx)
+ .getOrElse(throw NoSuchNameError("label", name, old))
+ )
+
+ case recv @ Recv(ref) =>
+ ref.tryResolve(name =>
+ Spec.findSend(name, ctx)
+ .getOrElse(throw NoSuchNameError("send statement", name, recv))
+ )
+
+ case res @ AmbiguousResult() =>
+ res.ref = Some(
+ ctx.currentResult.getOrElse(throw ResultOutsideMethod(res))
+ )
+ case diz @ AmbiguousThis() =>
+ diz.ref = Some(ctx.currentThis.getOrElse(throw WrongThisPosition(diz)))
+
+ case proc: ModelProcess[G] =>
+ proc.modifies.foreach(
+ _.tryResolve(name =>
+ Spec.findModelField(name, ctx)
+ .getOrElse(throw NoSuchNameError("field", name, proc))
+ )
+ )
+ proc.accessible.foreach(
+ _.tryResolve(name =>
+ Spec.findModelField(name, ctx)
+ .getOrElse(throw NoSuchNameError("field", name, proc))
+ )
+ )
+ case act: ModelAction[G] =>
+ act.modifies.foreach(
+ _.tryResolve(name =>
+ Spec.findModelField(name, ctx)
+ .getOrElse(throw NoSuchNameError("field", name, act))
+ )
+ )
+ act.accessible.foreach(
+ _.tryResolve(name =>
+ Spec.findModelField(name, ctx)
+ .getOrElse(throw NoSuchNameError("field", name, act))
+ )
+ )
+
+ case inv @ ProcessApply(ref, _) => ref.tryResolve(name => ???)
+ case inv @ ActionApply(ref, _) => ref.tryResolve(name => ???)
+
+ case atomic @ ParAtomic(invs, _) =>
+ invs.foreach(
+ _.tryResolve(name =>
+ Spec.findParInvariant(name, ctx)
+ .getOrElse(throw NoSuchNameError("invariant", name, atomic))
+ )
+ )
+ case barrier @ ParBarrier(block, invs, _, _, _) =>
+ block.tryResolve(name =>
+ Spec.findParBlock(name, ctx)
+ .getOrElse(throw NoSuchNameError("block", name, barrier))
+ )
+ invs.foreach(
+ _.tryResolve(name =>
+ Spec.findParInvariant(name, ctx)
+ .getOrElse(throw NoSuchNameError("invariant", name, barrier))
+ )
+ )
+
+ case arr @ JavaLiteralArray(_) =>
+ arr.typeContext = Some(ctx.currentInitializerType.get match {
+ case t @ TArray(_) => t
+ case _ => throw WrongArrayInitializer(arr)
+ })
+
+ case ann @ JavaAnnotation(_, _) if isBip(ann, "Transition") =>
+ val guard: Option[Expr[G]] = ann.get("guard").map { g =>
+ val expr: Expr[G] = ctx.javaParser.parse(getLit(g), g.o)
+ // TODO: What about check errors here?
+ resolve(expr, ctx.enableJavaBipGuards())
+ expr
+ }
+
+ def extractExpr(s: Option[Expr[_]]): (String, Origin) =
+ s match {
+ case None => ("true", ann.o)
+ case Some(s @ JavaStringValue(data, _)) => (data, s.o)
+ case Some(n) =>
+ throw MalformedBipAnnotation(
+ n,
+ "pre- and post-conditions must be string literals",
+ )
}
- case RefLlvmSpecFunction(_) =>
- Some(Spec.findLocal(local.name, ctx).getOrElse(throw NoSuchNameError("local", local.name, local)).ref)
- case _ => None
- }
- case inv: LlvmAmbiguousFunctionInvocation[G] =>
- inv.ref = LLVM.findCallable(inv.name, ctx) match {
- case Some(callable) => Some(callable.ref)
- case None => throw NoSuchNameError("function", inv.name, inv)
- }
- case glob: LlvmGlobal[G] =>
- glob.data.get.foreach(resolve(_, ctx))
- case comm: PVLCommunicate[G] =>
- /* Endpoint contexts for communicate are resolved early, because otherwise \sender, \receiver, \msg cannot be typed.
- */
- def getEndpoints[G](expr: Expr[G]): Seq[PVLEndpoint[G]] =
- mutable.LinkedHashSet.from(expr.collect { case name: PVLLocal[G] => name.ref.get }.collect { case RefPVLEndpoint(endpoint) => endpoint }).toSeq
-
- def getEndpoint[G](expr: Expr[G]): PVLEndpoint[G] = getEndpoints(expr) match {
- case Seq(endpoint) => endpoint
- // TODO (RR): Proper error
- case Seq() => throw new Exception(expr.o.messageInContext("No endpoints in expr"))
- case _ => throw new Exception(expr.o.messageInContext("Too many endpoints possible"))
- }
- comm.inferredSender = comm.sender.map(_.ref.get.decl).orElse(Some(getEndpoint(comm.msg)))
- comm.inferredReceiver = comm.receiver.map(_.ref.get.decl).orElse(Some(getEndpoint(comm.target)))
- case sender: PVLSender[G] => sender.ref = Some(ctx.currentCommunicate.get)
- case receiver: PVLReceiver[G] => receiver.ref = Some(ctx.currentCommunicate.get)
- case msg: PVLMessage[G] => msg.ref = Some(ctx.currentCommunicate.get)
- case _ =>
- }
+
+ val (r, ro) = extractExpr(ann.get("requires"))
+ val requires: Expr[G] = ctx.javaParser.parse(r, ro)
+ resolve(requires, ctx)
+
+ val (e, eo) = extractExpr(ann.get("ensures"))
+ val ensures: Expr[G] = ctx.javaParser.parse(e, eo)
+ resolve(ensures, ctx)
+
+ val name = getLit(ann.expect("name"))
+ val source = getLit(ann.expect("source"))
+ val target = getLit(ann.expect("target"))
+ ann.data = Some(
+ BipTransition[G](
+ name,
+ Java.findJavaBipStatePredicate(ctx, source),
+ Java.findJavaBipStatePredicate(ctx, target),
+ ann.get("guard").map(getLit(_)),
+ guard,
+ requires,
+ ensures,
+ )(ann.o)
+ )
+
+ case ann @ JavaAnnotation(_, _) if isBip(ann, "Invariant") =>
+ val expr: Expr[G] = ctx.javaParser
+ .parse(getLit(ann.expect("value")), ann.expect("value").o)
+ resolve(expr, ctx)
+ ann.data = Some(BipInvariant(expr))
+
+ case ann @ JavaAnnotation(_, _) if isBip(ann, "StatePredicate") =>
+ val expr: Expr[G] = ctx.javaParser
+ .parse(getLit(ann.expect("expr")), ann.expect("expr").o)
+ resolve(expr, ctx) // TODO (RR): Throwing away errors here?
+ ann.data = Some(
+ BipStatePredicate(getLit(ann.expect("state")), expr)(ann.o)
+ )
+
+ case ann @ JavaAnnotation(_, _) if isBip(ann, "ComponentType") =>
+ ann.data = Some(BipComponent(
+ getLit(ann.expect("name")),
+ Java.findJavaBipStatePredicate(ctx, getLit(ann.expect("initial"))),
+ ))
+
+ case ann @ JavaAnnotation(_, _) if isBip(ann, "Data") =>
+ ann.data = Some(BipData(getLit(ann.expect("name")))(ann.o))
+
+ case ann @ JavaAnnotation(_, _) if isBip(ann, "Guard") =>
+ ann.data = Some(BipGuard(getLit(ann.expect("name"))))
+
+ case ann: JavaAnnotation[G] if isBip(ann, "Port") =>
+ val portType: BipPortType[G] =
+ ann.expect("type") match {
+ case p @ JavaDeref(_, "enforceable") => BipEnforceable[G]()(p.o)
+ case p @ JavaDeref(_, "spontaneous") => BipSpontaneous[G]()(p.o)
+ case p @ JavaDeref(_, "internal") => BipInternal[G]()(p.o)
+ case e =>
+ throw MalformedBipAnnotation(
+ e,
+ "Can be either PortType.enforceable, spontaneous, or internal",
+ )
+ }
+ ann.data = Some(BipPort[G](getLit(ann.expect("name")), portType)(ann.o))
+
+ case ann: JavaAnnotation[G] if isBip(ann, "Pure") =>
+ ann.data = Some(BipPure[G]())
+
+ case portName @ JavaBipGlueName(
+ JavaTClass(Ref(cls: JavaClass[G]), Nil),
+ name,
+ ) =>
+ portName.data = Some((cls, getLit(name)))
+
+ case contract: LlvmFunctionContract[G] =>
+ val applicableContract = ctx.llvmSpecParser.parse(contract, contract.o)
+ contract.data = Some(applicableContract)
+ resolve(applicableContract, ctx)
+ case local: LlvmLocal[G] =>
+ local.ref =
+ ctx.currentResult.get match {
+ case RefLlvmFunctionDefinition(decl) =>
+ decl.contract.variableRefs
+ .find(ref => ref._1 == local.name) match {
+ case Some(ref) => Some(ref._2)
+ case None => throw NoSuchNameError("local", local.name, local)
+ }
+ case RefLlvmSpecFunction(_) =>
+ Some(
+ Spec.findLocal(local.name, ctx)
+ .getOrElse(throw NoSuchNameError("local", local.name, local))
+ .ref
+ )
+ case _ => None
+ }
+ case inv: LlvmAmbiguousFunctionInvocation[G] =>
+ inv.ref =
+ LLVM.findCallable(inv.name, ctx) match {
+ case Some(callable) => Some(callable.ref)
+ case None => throw NoSuchNameError("function", inv.name, inv)
+ }
+ case glob: LlvmGlobal[G] => glob.data.get.foreach(resolve(_, ctx))
+ case comm: PVLCommunicate[G] =>
+ /* Endpoint contexts for communicate are resolved early, because otherwise \sender, \receiver, \msg cannot be typed.
+ */
+ def getEndpoints[G](expr: Expr[G]): Seq[PVLEndpoint[G]] =
+ mutable.LinkedHashSet.from(
+ expr.collect { case name: PVLLocal[G] => name.ref.get }.collect {
+ case RefPVLEndpoint(endpoint) => endpoint
+ }
+ ).toSeq
+
+ def getEndpoint[G](expr: Expr[G]): PVLEndpoint[G] =
+ getEndpoints(expr) match {
+ case Seq(endpoint) => endpoint
+ // TODO (RR): Proper error
+ case Seq() =>
+ throw new Exception(
+ expr.o.messageInContext("No endpoints in expr")
+ )
+ case _ =>
+ throw new Exception(
+ expr.o.messageInContext("Too many endpoints possible")
+ )
+ }
+ comm.inferredSender = comm.sender.map(_.ref.get.decl)
+ .orElse(Some(getEndpoint(comm.msg)))
+ comm.inferredReceiver = comm.receiver.map(_.ref.get.decl)
+ .orElse(Some(getEndpoint(comm.target)))
+ case sender: PVLSender[G] => sender.ref = Some(ctx.currentCommunicate.get)
+ case receiver: PVLReceiver[G] =>
+ receiver.ref = Some(ctx.currentCommunicate.get)
+ case msg: PVLMessage[G] => msg.ref = Some(ctx.currentCommunicate.get)
+ case _ =>
+ }
}
diff --git a/src/col/vct/col/resolve/ctx/ReferenceResolutionContext.scala b/src/col/vct/col/resolve/ctx/ReferenceResolutionContext.scala
index 6962ce1b7c..8a7e0c2a3e 100644
--- a/src/col/vct/col/resolve/ctx/ReferenceResolutionContext.scala
+++ b/src/col/vct/col/resolve/ctx/ReferenceResolutionContext.scala
@@ -9,59 +9,74 @@ import vct.col.util.SuccessionMap
import scala.collection.immutable.{HashMap, ListMap}
import scala.collection.mutable
-case class ReferenceResolutionContext[G]
-(
- javaParser: SpecExprParser,
- llvmSpecParser: SpecContractParser,
- stack: Seq[Seq[Referrable[G]]] = Nil,
- topLevelJavaDeref: Option[JavaDeref[G]] = None,
- externallyLoadedElements: mutable.ArrayBuffer[GlobalDeclaration[G]] = mutable.ArrayBuffer[GlobalDeclaration[G]](),
- checkContext: CheckContext[G] = CheckContext[G](),
- currentJavaNamespace: Option[JavaNamespace[G]] = None,
- currentJavaClass: Option[JavaClassOrInterface[G]] = None,
- currentThis: Option[ThisTarget[G]] = None,
- currentResult: Option[ResultTarget[G]] = None,
- currentInitializerType: Option[Type[G]] = None,
- currentCommunicate: Option[PVLCommunicate[G]] = None,
- inStaticJavaContext: Boolean = false,
- inGpuKernel: Boolean = false,
- javaBipStatePredicates: ListMap[Expr[G], JavaAnnotation[G]] = ListMap[Expr[G], JavaAnnotation[G]](),
- javaBipGuards: ListMap[Expr[G], JavaMethod[G]] = ListMap[Expr[G], JavaMethod[G]](),
- // When true and resolving a local, guard names should also be considered
- javaBipGuardsEnabled: Boolean = false,
- typeEnv: Map[Variable[G], Type[G]] = Map.empty[Variable[G], Type[G]],
+case class ReferenceResolutionContext[G](
+ javaParser: SpecExprParser,
+ llvmSpecParser: SpecContractParser,
+ stack: Seq[Seq[Referrable[G]]] = Nil,
+ topLevelJavaDeref: Option[JavaDeref[G]] = None,
+ externallyLoadedElements: mutable.ArrayBuffer[GlobalDeclaration[G]] =
+ mutable.ArrayBuffer[GlobalDeclaration[G]](),
+ checkContext: CheckContext[G] = CheckContext[G](),
+ currentJavaNamespace: Option[JavaNamespace[G]] = None,
+ currentJavaClass: Option[JavaClassOrInterface[G]] = None,
+ currentThis: Option[ThisTarget[G]] = None,
+ currentResult: Option[ResultTarget[G]] = None,
+ currentInitializerType: Option[Type[G]] = None,
+ currentCommunicate: Option[PVLCommunicate[G]] = None,
+ inStaticJavaContext: Boolean = false,
+ inGpuKernel: Boolean = false,
+ javaBipStatePredicates: ListMap[Expr[G], JavaAnnotation[G]] =
+ ListMap[Expr[G], JavaAnnotation[G]](),
+ javaBipGuards: ListMap[Expr[G], JavaMethod[G]] =
+ ListMap[Expr[G], JavaMethod[G]](),
+ // When true and resolving a local, guard names should also be considered
+ javaBipGuardsEnabled: Boolean = false,
+ typeEnv: Map[Variable[G], Type[G]] = Map.empty[Variable[G], Type[G]],
) {
def asTypeResolutionContext: TypeResolutionContext[G] =
- TypeResolutionContext(stack, currentJavaNamespace, None, Nil, inGpuKernel, externallyLoadedElements)
+ TypeResolutionContext(
+ stack,
+ currentJavaNamespace,
+ None,
+ Nil,
+ inGpuKernel,
+ externallyLoadedElements,
+ )
def declare(decls: Seq[Declaration[G]]): ReferenceResolutionContext[G] =
copy(stack = decls.flatMap(Referrable.from) +: stack)
def withCheckContext(ctx: CheckContext[G]): ReferenceResolutionContext[G] = {
val filter = ctx.undeclared.flatten.flatMap(Referrable.from).toSet
- copy(
- checkContext = ctx,
- stack = stack.map(_.filter(!filter.contains(_)))
- )
+ copy(checkContext = ctx, stack = stack.map(_.filter(!filter.contains(_))))
}
/* State predicates names are saved as expr's here because at the time this method is called, fields are not yet resolved.
E.g. if in the code it says "@Guard(name = INIT)", where INIT is some static field, in the ast INIT is a LocalVariable.
It is only after recursively visiting this annotation that INIT is resolved to a static field. So we save the expr
here so we can later use the resolved value, instead of directly using an unresolved local.
- */
+ */
def declareJavaBipStatePredicates(ps: Seq[(Expr[G], JavaAnnotation[G])]) =
copy(javaBipStatePredicates = javaBipStatePredicates ++ ps.toMap)
/* Guard names are explicitly saved as expr's instead of String. See comment at declareJavaBipStatePredicates. */
- def declareJavaBipGuards(gs: Seq[(Expr[G], JavaMethod[G])]): ReferenceResolutionContext[G] =
+ def declareJavaBipGuards(
+ gs: Seq[(Expr[G], JavaMethod[G])]
+ ): ReferenceResolutionContext[G] =
copy(javaBipGuards = javaBipGuards ++ gs.toMap)
- def enableJavaBipGuards(): ReferenceResolutionContext[G] = copy(javaBipGuardsEnabled = true)
+ def enableJavaBipGuards(): ReferenceResolutionContext[G] =
+ copy(javaBipGuardsEnabled = true)
def currentPkg: Option[JavaName[G]] = currentJavaNamespace.flatMap(_.pkg)
- def currentFqn: Option[JavaName[G]] = currentPkg.map(pkg => JavaName(pkg.names ++ currentJavaClass.map(cls => Seq(cls.name)).getOrElse(Seq()))(DiagnosticOrigin))
+ def currentFqn: Option[JavaName[G]] =
+ currentPkg.map(pkg =>
+ JavaName(
+ pkg.names ++ currentJavaClass.map(cls => Seq(cls.name)).getOrElse(Seq())
+ )(DiagnosticOrigin)
+ )
- def appendTypeEnv(typeEnv: Map[Variable[G], Type[G]]): ReferenceResolutionContext[G] =
- copy(typeEnv = this.typeEnv ++ typeEnv)
+ def appendTypeEnv(
+ typeEnv: Map[Variable[G], Type[G]]
+ ): ReferenceResolutionContext[G] = copy(typeEnv = this.typeEnv ++ typeEnv)
}
diff --git a/src/col/vct/col/resolve/ctx/Referrable.scala b/src/col/vct/col/resolve/ctx/Referrable.scala
index 563c721a89..b146df4d06 100644
--- a/src/col/vct/col/resolve/ctx/Referrable.scala
+++ b/src/col/vct/col/resolve/ctx/Referrable.scala
@@ -5,214 +5,241 @@ import vct.col.origin.SourceName
import vct.col.resolve.NameLost
import vct.col.resolve.lang.{C, CPP}
-/**
- * Collection of all things that can be cross-referenced in the AST. This includes all declarations, indices at
- * multi-declarations, references to implicitly defined constructs, built-in fields and methods, etc. Referrables are
- * briefly used while resolving the AST, and are almost immediately replaced by instances of [[vct.col.ref.Ref]]. See
- * also [[vct.col.resolve.ResolveTypes]] and [[vct.col.resolve.ResolveReferences]].
- * @tparam G The generation marker
- */
+/** Collection of all things that can be cross-referenced in the AST. This
+ * includes all declarations, indices at multi-declarations, references to
+ * implicitly defined constructs, built-in fields and methods, etc. Referrables
+ * are briefly used while resolving the AST, and are almost immediately
+ * replaced by instances of [[vct.col.ref.Ref]]. See also
+ * [[vct.col.resolve.ResolveTypes]] and [[vct.col.resolve.ResolveReferences]].
+ * @tparam G
+ * The generation marker
+ */
sealed trait Referrable[G] {
- def name: String = this match {
- case RefCTranslationUnit(_) => ""
- case RefCParam(decl) => C.nameFromDeclarator(decl.declarator)
- case RefCFunctionDefinition(decl) => C.nameFromDeclarator(decl.declarator)
- case RefCGlobalDeclaration(decls, initIdx) => C.nameFromDeclarator(decls.decl.inits(initIdx).decl)
- case RefCLocalDeclaration(decls, initIdx) => C.nameFromDeclarator(decls.decl.inits(initIdx).decl)
- case RefCPPTranslationUnit(_) => ""
- case RefCPPParam(decl) => CPP.nameFromDeclarator(decl.declarator)
- case RefCPPFunctionDefinition(decl) => CPP.nameFromDeclarator(decl.declarator)
- case RefCPPGlobalDeclaration(decls, initIdx) => CPP.nameFromDeclarator(decls.decl.inits(initIdx).decl)
- case RefCPPCustomType(typeName) => typeName
- case RefCPPLambdaDefinition(decl) => ""
- case RefCPPLocalDeclaration(decls, initIdx) => CPP.nameFromDeclarator(decls.decl.inits(initIdx).decl)
- case RefSYCLAccessMode(decl) => decl.name
- case RefSYCLConstructorDefinition(typ) => typ.namespacePath
- case RefJavaNamespace(_) => ""
- case RefUnloadedJavaNamespace(_) => ""
- case RefCStruct(decl: CGlobalDeclaration[_]) => decl.decl match {
- case CDeclaration(_, _, Seq(defn: CStructDeclaration[G]), Seq()) => defn.name.getOrElse("")
- case _ => ???
- }
- case RefCStruct(_) => ???
- case RefTypeDef(decl: CGlobalDeclaration[_]) =>
- C.nameFromDeclarator(decl.decl.inits.head.decl)
- case RefTypeDef(_) => ???
- case RefCStructField(decls, idx) => C.nameFromDeclarator(decls.decls(idx))
- case RefOpenCLVectorMembers(idxs) => "s" ++ idxs.map { i => f"$i%x"}.mkString
- case RefJavaClass(decl) => decl.name
- case RefSilverField(decl) => Referrable.originName(decl)
- case RefSimplificationRule(decl) => Referrable.originName(decl)
- case RefAxiomaticDataType(decl) => Referrable.originName(decl)
- case RefFunction(decl) => Referrable.originName(decl)
- case RefProcedure(decl) => Referrable.originName(decl)
- case RefVeSUVMainMethod(_) => ""
- case RefPredicate(decl) => Referrable.originName(decl)
- case RefClass(decl) => Referrable.originName(decl)
- case RefModel(decl) => Referrable.originName(decl)
- case RefEnum(decl) => Referrable.originName(decl)
- case RefEnumConstant(_, decl) => Referrable.originName(decl)
- case RefJavaSharedInitialization(decl) => ""
- case RefJavaField(decls, idx) => decls.decls(idx).name
- case RefJavaLocalDeclaration(decls, idx) => decls.decls(idx).name
- case RefJavaConstructor(decl) => decl.name
- case RefJavaMethod(decl) => decl.name
- case RefJavaParam(decl) => decl.name
- case RefJavaAnnotationMethod(decl) => decl.name
- case RefInstanceFunction(decl) => Referrable.originName(decl)
- case RefInstanceMethod(decl) => Referrable.originName(decl)
- case RefInstanceOperatorMethod(decl) => Referrable.originName(decl)
- case RefInstanceOperatorFunction(decl) => Referrable.originName(decl)
- case RefInstancePredicate(decl) => Referrable.originName(decl)
- case RefField(decl) => Referrable.originName(decl)
- case RefVariable(decl) => Referrable.originName(decl)
- case RefLabelDecl(decl) => Referrable.originName(decl)
- case RefSendDecl(decl) => Referrable.originName(decl)
- case RefRunMethod(_) => ""
- case RefParBlockDecl(decl) => Referrable.originNameOrEmpty(decl)
- case RefParInvariantDecl(decl) => Referrable.originNameOrEmpty(decl)
- case RefADTAxiom(decl) => Referrable.originName(decl)
- case RefADTFunction(decl) => Referrable.originName(decl)
- case RefModelField(decl) => Referrable.originName(decl)
- case RefModelProcess(decl) => Referrable.originName(decl)
- case RefModelAction(decl) => Referrable.originName(decl)
- case RefChoreography(decl) => Referrable.originName(decl)
- case RefEndpoint(decl) => Referrable.originName(decl)
- case RefProverType(decl) => Referrable.originName(decl)
- case RefProverFunction(decl) => Referrable.originName(decl)
- case RefJavaBipGuard(decl) => Referrable.originName(decl)
- case RefLlvmFunctionDefinition(decl) => Referrable.originName(decl)
- case RefLlvmGlobal(decl, i) => Referrable.originName(decl.data.get(i))
- case RefLlvmSpecFunction(decl) => Referrable.originName(decl)
- case RefBipComponent(decl) => Referrable.originName(decl)
- case RefBipGlue(decl) => ""
- case RefBipGuard(decl) => Referrable.originName(decl)
- case RefBipIncomingData(decl) => Referrable.originName(decl)
- case RefBipOutgoingData(decl) => Referrable.originName(decl)
- case RefBipPort(decl) => Referrable.originName(decl)
- case RefBipPortSynchronization(decl) => ""
- case RefBipStatePredicate(decl) => Referrable.originName(decl)
- case RefBipTransition(decl) => Referrable.originName(decl)
- case RefBipTransitionSynchronization(decl) => ""
- case RefBipConstructor(decl) => Referrable.originName(decl)
- case RefHeapVariable(decl) => Referrable.originName(decl)
- case RefPVLEndpoint(decl) => decl.name
- case RefPVLChoreography(decl) => decl.name
- case RefPVLChorRun(_) => ""
+ def name: String =
+ this match {
+ case RefCTranslationUnit(_) => ""
+ case RefCParam(decl) => C.nameFromDeclarator(decl.declarator)
+ case RefCFunctionDefinition(decl) => C.nameFromDeclarator(decl.declarator)
+ case RefCGlobalDeclaration(decls, initIdx) =>
+ C.nameFromDeclarator(decls.decl.inits(initIdx).decl)
+ case RefCLocalDeclaration(decls, initIdx) =>
+ C.nameFromDeclarator(decls.decl.inits(initIdx).decl)
+ case RefCPPTranslationUnit(_) => ""
+ case RefCPPParam(decl) => CPP.nameFromDeclarator(decl.declarator)
+ case RefCPPFunctionDefinition(decl) =>
+ CPP.nameFromDeclarator(decl.declarator)
+ case RefCPPGlobalDeclaration(decls, initIdx) =>
+ CPP.nameFromDeclarator(decls.decl.inits(initIdx).decl)
+ case RefCPPCustomType(typeName) => typeName
+ case RefCPPLambdaDefinition(decl) => ""
+ case RefCPPLocalDeclaration(decls, initIdx) =>
+ CPP.nameFromDeclarator(decls.decl.inits(initIdx).decl)
+ case RefSYCLAccessMode(decl) => decl.name
+ case RefSYCLConstructorDefinition(typ) => typ.namespacePath
+ case RefJavaNamespace(_) => ""
+ case RefUnloadedJavaNamespace(_) => ""
+ case RefCStruct(decl: CGlobalDeclaration[_]) =>
+ decl.decl match {
+ case CDeclaration(_, _, Seq(defn: CStructDeclaration[G]), Seq()) =>
+ defn.name.getOrElse("")
+ case _ => ???
+ }
+ case RefCStruct(_) => ???
+ case RefTypeDef(decl: CGlobalDeclaration[_]) =>
+ C.nameFromDeclarator(decl.decl.inits.head.decl)
+ case RefTypeDef(_) => ???
+ case RefCStructField(decls, idx) => C.nameFromDeclarator(decls.decls(idx))
+ case RefOpenCLVectorMembers(idxs) =>
+ "s" ++ idxs.map { i => f"$i%x" }.mkString
+ case RefJavaClass(decl) => decl.name
+ case RefSilverField(decl) => Referrable.originName(decl)
+ case RefSimplificationRule(decl) => Referrable.originName(decl)
+ case RefAxiomaticDataType(decl) => Referrable.originName(decl)
+ case RefFunction(decl) => Referrable.originName(decl)
+ case RefProcedure(decl) => Referrable.originName(decl)
+ case RefVeSUVMainMethod(_) => ""
+ case RefPredicate(decl) => Referrable.originName(decl)
+ case RefClass(decl) => Referrable.originName(decl)
+ case RefModel(decl) => Referrable.originName(decl)
+ case RefEnum(decl) => Referrable.originName(decl)
+ case RefEnumConstant(_, decl) => Referrable.originName(decl)
+ case RefJavaSharedInitialization(decl) => ""
+ case RefJavaField(decls, idx) => decls.decls(idx).name
+ case RefJavaLocalDeclaration(decls, idx) => decls.decls(idx).name
+ case RefJavaConstructor(decl) => decl.name
+ case RefJavaMethod(decl) => decl.name
+ case RefJavaParam(decl) => decl.name
+ case RefJavaAnnotationMethod(decl) => decl.name
+ case RefInstanceFunction(decl) => Referrable.originName(decl)
+ case RefInstanceMethod(decl) => Referrable.originName(decl)
+ case RefInstanceOperatorMethod(decl) => Referrable.originName(decl)
+ case RefInstanceOperatorFunction(decl) => Referrable.originName(decl)
+ case RefInstancePredicate(decl) => Referrable.originName(decl)
+ case RefField(decl) => Referrable.originName(decl)
+ case RefVariable(decl) => Referrable.originName(decl)
+ case RefLabelDecl(decl) => Referrable.originName(decl)
+ case RefSendDecl(decl) => Referrable.originName(decl)
+ case RefRunMethod(_) => ""
+ case RefParBlockDecl(decl) => Referrable.originNameOrEmpty(decl)
+ case RefParInvariantDecl(decl) => Referrable.originNameOrEmpty(decl)
+ case RefADTAxiom(decl) => Referrable.originName(decl)
+ case RefADTFunction(decl) => Referrable.originName(decl)
+ case RefModelField(decl) => Referrable.originName(decl)
+ case RefModelProcess(decl) => Referrable.originName(decl)
+ case RefModelAction(decl) => Referrable.originName(decl)
+ case RefChoreography(decl) => Referrable.originName(decl)
+ case RefEndpoint(decl) => Referrable.originName(decl)
+ case RefProverType(decl) => Referrable.originName(decl)
+ case RefProverFunction(decl) => Referrable.originName(decl)
+ case RefJavaBipGuard(decl) => Referrable.originName(decl)
+ case RefLlvmFunctionDefinition(decl) => Referrable.originName(decl)
+ case RefLlvmGlobal(decl, i) => Referrable.originName(decl.data.get(i))
+ case RefLlvmSpecFunction(decl) => Referrable.originName(decl)
+ case RefBipComponent(decl) => Referrable.originName(decl)
+ case RefBipGlue(decl) => ""
+ case RefBipGuard(decl) => Referrable.originName(decl)
+ case RefBipIncomingData(decl) => Referrable.originName(decl)
+ case RefBipOutgoingData(decl) => Referrable.originName(decl)
+ case RefBipPort(decl) => Referrable.originName(decl)
+ case RefBipPortSynchronization(decl) => ""
+ case RefBipStatePredicate(decl) => Referrable.originName(decl)
+ case RefBipTransition(decl) => Referrable.originName(decl)
+ case RefBipTransitionSynchronization(decl) => ""
+ case RefBipConstructor(decl) => Referrable.originName(decl)
+ case RefHeapVariable(decl) => Referrable.originName(decl)
+ case RefPVLEndpoint(decl) => decl.name
+ case RefPVLChoreography(decl) => decl.name
+ case RefPVLChorRun(_) => ""
- case RefJavaBipGlueContainer() => ""
- case PVLBuiltinInstanceMethod(_) => ""
- case BuiltinField(_) => ""
- case BuiltinInstanceMethod(_) => ""
- case RefPVLConstructor(decl) => ""
- case ImplicitDefaultJavaConstructor(_) => ""
- case ImplicitDefaultPVLConstructor(_) => ""
- case RefCudaThreadIdx() => "threadIdx"
- case RefCudaBlockDim() => "blockDim"
- case RefCudaBlockIdx() => "blockIdx"
- case RefCudaGridDim() => "gridDim"
- case RefCudaVecX(_) => "x"
- case RefCudaVecY(_) => "y"
- case RefCudaVecZ(_) => "z"
- case RefJavaBipStatePredicate(name, _) => name
- case ImplicitDefaultJavaBipStatePredicate(name) => name
- }
+ case RefJavaBipGlueContainer() => ""
+ case PVLBuiltinInstanceMethod(_) => ""
+ case BuiltinField(_) => ""
+ case BuiltinInstanceMethod(_) => ""
+ case RefPVLConstructor(decl) => ""
+ case ImplicitDefaultJavaConstructor(_) => ""
+ case ImplicitDefaultPVLConstructor(_) => ""
+ case RefCudaThreadIdx() => "threadIdx"
+ case RefCudaBlockDim() => "blockDim"
+ case RefCudaBlockIdx() => "blockIdx"
+ case RefCudaGridDim() => "gridDim"
+ case RefCudaVecX(_) => "x"
+ case RefCudaVecY(_) => "y"
+ case RefCudaVecZ(_) => "z"
+ case RefJavaBipStatePredicate(name, _) => name
+ case ImplicitDefaultJavaBipStatePredicate(name) => name
+ }
}
case object Referrable {
- def from[G](decl: Declaration[G]): Seq[Referrable[G]] = Seq[Referrable[G]](decl match {
- case decl: CTranslationUnit[G] => RefCTranslationUnit(decl)
- case decl: CParam[G] => RefCParam(decl)
- case decl: CFunctionDefinition[G] => RefCFunctionDefinition(decl)
- case decl: CStructMemberDeclarator[G] => return decl.decls.indices.map(RefCStructField(decl, _))
- case decl: CGlobalDeclaration[G] => decl.decl match {
- case CDeclaration(_, _, Seq(_ :CStructDeclaration[G]), Seq()) => RefCStruct(decl)
- case CDeclaration(_, _, CTypedef() +: _, _) => RefTypeDef(decl)
- case _ => return decl.decl.inits.indices.map(RefCGlobalDeclaration(decl, _))
- }
- case decl: CPPTranslationUnit[G] => RefCPPTranslationUnit(decl)
- case decl: CPPParam[G] => RefCPPParam(decl)
- case decl: CPPFunctionDefinition[G] => RefCPPFunctionDefinition(decl)
- case decl: CPPGlobalDeclaration[G] => return decl.decl.inits.indices.map(RefCPPGlobalDeclaration(decl, _))
- case decl: JavaNamespace[G] => RefJavaNamespace(decl)
- case decl: JavaClass[G] => RefJavaClass(decl)
- case decl: JavaInterface[G] => RefJavaClass(decl)
- case decl: JavaAnnotationInterface[G] => RefJavaClass(decl)
- case decl: SilverField[G] => RefSilverField(decl)
- case decl: SimplificationRule[G] => RefSimplificationRule(decl)
- case decl: AxiomaticDataType[G] => RefAxiomaticDataType(decl)
- case decl: Function[G] => RefFunction(decl)
- case decl: Procedure[G] => RefProcedure(decl)
- case decl: VeSUVMainMethod[G] => RefVeSUVMainMethod(decl)
- case decl: Predicate[G] => RefPredicate(decl)
- case decl: Class[G] => RefClass(decl)
- case decl: Model[G] => RefModel(decl)
- case decl: Enum[G] => RefEnum(decl)
- case decl: EnumConstant[G] => RefEnumConstant(None, decl)
- case decl: JavaSharedInitialization[G] => RefJavaSharedInitialization(decl)
- case decl: JavaFields[G] => return decl.decls.indices.map(RefJavaField(decl, _))
- case decl: JavaConstructor[G] => RefJavaConstructor(decl)
- case decl: JavaMethod[G] => RefJavaMethod(decl)
- case decl: JavaParam[G] => RefJavaParam(decl)
- case decl: JavaAnnotationMethod[G] => RefJavaAnnotationMethod(decl)
- case decl: InstanceFunction[G] => RefInstanceFunction(decl)
- case decl: InstanceMethod[G] => RefInstanceMethod(decl)
- case decl: InstanceOperatorMethod[G] => RefInstanceOperatorMethod(decl)
- case decl: InstanceOperatorFunction[G] => RefInstanceOperatorFunction(decl)
- case decl: InstancePredicate[G] => RefInstancePredicate(decl)
- case decl: InstanceField[G] => RefField(decl)
- case decl: Variable[G] => RefVariable(decl)
- case decl: LabelDecl[G] => RefLabelDecl(decl)
- case decl: SendDecl[G] => RefSendDecl(decl)
- case decl: RunMethod[G] => RefRunMethod(decl)
- case decl: ParBlockDecl[G] => RefParBlockDecl(decl)
- case decl: ParInvariantDecl[G] => RefParInvariantDecl(decl)
- case decl: ADTAxiom[G] => RefADTAxiom(decl)
- case decl: ADTFunction[G] => RefADTFunction(decl)
- case decl: ModelField[G] => RefModelField(decl)
- case decl: ModelProcess[G] => RefModelProcess(decl)
- case decl: ModelAction[G] => RefModelAction(decl)
- case decl: CLocalDeclaration[G] => return decl.decl.inits.indices.map(RefCLocalDeclaration(decl, _))
- case decl: CPPLocalDeclaration[G] => return decl.decl.inits.indices.map(RefCPPLocalDeclaration(decl, _))
- case decl: JavaLocalDeclaration[G] => return decl.decls.indices.map(RefJavaLocalDeclaration(decl, _))
- case decl: PVLConstructor[G] => RefPVLConstructor(decl)
- case decl: Choreography[G] => RefChoreography(decl)
- case decl: Endpoint[G] => RefEndpoint(decl)
- case decl: LlvmFunctionDefinition[G] => RefLlvmFunctionDefinition(decl)
- case decl: LlvmGlobal[G] => decl.data match {
- case Some(data) => return data.indices.map(RefLlvmGlobal(decl, _))
- case None => RefLlvmGlobal(decl, -1)
- }
- case decl: LlvmSpecFunction[G] => RefLlvmSpecFunction(decl)
- case decl: ProverType[G] => RefProverType(decl)
- case decl: ProverFunction[G] => RefProverFunction(decl)
- case decl: JavaBipGlueContainer[G] => RefJavaBipGlueContainer()
- case decl: BipComponent[G] => RefBipComponent(decl)
- case decl: BipGlue[G] => RefBipGlue(decl)
- case decl: BipGuard[G] => RefBipGuard(decl)
- case decl: BipIncomingData[G] => RefBipIncomingData(decl)
- case decl: BipOutgoingData[G] => RefBipOutgoingData(decl)
- case decl: BipPort[G] => RefBipPort(decl)
- case decl: BipPortSynchronization[G] => RefBipPortSynchronization(decl)
- case decl: BipStatePredicate[G] => RefBipStatePredicate(decl)
- case decl: BipTransition[G] => RefBipTransition(decl)
- case decl: BipTransitionSynchronization[G] => RefBipTransitionSynchronization(decl)
- case decl: BipConstructor[G] => RefBipConstructor(decl)
- case decl: HeapVariable[G] => RefHeapVariable(decl)
- case decl: PVLEndpoint[G] => RefPVLEndpoint(decl)
- case decl: PVLChoreography[G] => RefPVLChoreography(decl)
- case decl: PVLChorRun[G] => RefPVLChorRun(decl)
- })
+ def from[G](decl: Declaration[G]): Seq[Referrable[G]] =
+ Seq[Referrable[G]](decl match {
+ case decl: CTranslationUnit[G] => RefCTranslationUnit(decl)
+ case decl: CParam[G] => RefCParam(decl)
+ case decl: CFunctionDefinition[G] => RefCFunctionDefinition(decl)
+ case decl: CStructMemberDeclarator[G] =>
+ return decl.decls.indices.map(RefCStructField(decl, _))
+ case decl: CGlobalDeclaration[G] =>
+ decl.decl match {
+ case CDeclaration(_, _, Seq(_: CStructDeclaration[G]), Seq()) =>
+ RefCStruct(decl)
+ case CDeclaration(_, _, CTypedef() +: _, _) => RefTypeDef(decl)
+ case _ =>
+ return decl.decl.inits.indices.map(RefCGlobalDeclaration(decl, _))
+ }
+ case decl: CPPTranslationUnit[G] => RefCPPTranslationUnit(decl)
+ case decl: CPPParam[G] => RefCPPParam(decl)
+ case decl: CPPFunctionDefinition[G] => RefCPPFunctionDefinition(decl)
+ case decl: CPPGlobalDeclaration[G] =>
+ return decl.decl.inits.indices.map(RefCPPGlobalDeclaration(decl, _))
+ case decl: JavaNamespace[G] => RefJavaNamespace(decl)
+ case decl: JavaClass[G] => RefJavaClass(decl)
+ case decl: JavaInterface[G] => RefJavaClass(decl)
+ case decl: JavaAnnotationInterface[G] => RefJavaClass(decl)
+ case decl: SilverField[G] => RefSilverField(decl)
+ case decl: SimplificationRule[G] => RefSimplificationRule(decl)
+ case decl: AxiomaticDataType[G] => RefAxiomaticDataType(decl)
+ case decl: Function[G] => RefFunction(decl)
+ case decl: Procedure[G] => RefProcedure(decl)
+ case decl: VeSUVMainMethod[G] => RefVeSUVMainMethod(decl)
+ case decl: Predicate[G] => RefPredicate(decl)
+ case decl: Class[G] => RefClass(decl)
+ case decl: Model[G] => RefModel(decl)
+ case decl: Enum[G] => RefEnum(decl)
+ case decl: EnumConstant[G] => RefEnumConstant(None, decl)
+ case decl: JavaSharedInitialization[G] =>
+ RefJavaSharedInitialization(decl)
+ case decl: JavaFields[G] =>
+ return decl.decls.indices.map(RefJavaField(decl, _))
+ case decl: JavaConstructor[G] => RefJavaConstructor(decl)
+ case decl: JavaMethod[G] => RefJavaMethod(decl)
+ case decl: JavaParam[G] => RefJavaParam(decl)
+ case decl: JavaAnnotationMethod[G] => RefJavaAnnotationMethod(decl)
+ case decl: InstanceFunction[G] => RefInstanceFunction(decl)
+ case decl: InstanceMethod[G] => RefInstanceMethod(decl)
+ case decl: InstanceOperatorMethod[G] => RefInstanceOperatorMethod(decl)
+ case decl: InstanceOperatorFunction[G] =>
+ RefInstanceOperatorFunction(decl)
+ case decl: InstancePredicate[G] => RefInstancePredicate(decl)
+ case decl: InstanceField[G] => RefField(decl)
+ case decl: Variable[G] => RefVariable(decl)
+ case decl: LabelDecl[G] => RefLabelDecl(decl)
+ case decl: SendDecl[G] => RefSendDecl(decl)
+ case decl: RunMethod[G] => RefRunMethod(decl)
+ case decl: ParBlockDecl[G] => RefParBlockDecl(decl)
+ case decl: ParInvariantDecl[G] => RefParInvariantDecl(decl)
+ case decl: ADTAxiom[G] => RefADTAxiom(decl)
+ case decl: ADTFunction[G] => RefADTFunction(decl)
+ case decl: ModelField[G] => RefModelField(decl)
+ case decl: ModelProcess[G] => RefModelProcess(decl)
+ case decl: ModelAction[G] => RefModelAction(decl)
+ case decl: CLocalDeclaration[G] =>
+ return decl.decl.inits.indices.map(RefCLocalDeclaration(decl, _))
+ case decl: CPPLocalDeclaration[G] =>
+ return decl.decl.inits.indices.map(RefCPPLocalDeclaration(decl, _))
+ case decl: JavaLocalDeclaration[G] =>
+ return decl.decls.indices.map(RefJavaLocalDeclaration(decl, _))
+ case decl: PVLConstructor[G] => RefPVLConstructor(decl)
+ case decl: Choreography[G] => RefChoreography(decl)
+ case decl: Endpoint[G] => RefEndpoint(decl)
+ case decl: LlvmFunctionDefinition[G] => RefLlvmFunctionDefinition(decl)
+ case decl: LlvmGlobal[G] =>
+ decl.data match {
+ case Some(data) => return data.indices.map(RefLlvmGlobal(decl, _))
+ case None => RefLlvmGlobal(decl, -1)
+ }
+ case decl: LlvmSpecFunction[G] => RefLlvmSpecFunction(decl)
+ case decl: ProverType[G] => RefProverType(decl)
+ case decl: ProverFunction[G] => RefProverFunction(decl)
+ case decl: JavaBipGlueContainer[G] => RefJavaBipGlueContainer()
+ case decl: BipComponent[G] => RefBipComponent(decl)
+ case decl: BipGlue[G] => RefBipGlue(decl)
+ case decl: BipGuard[G] => RefBipGuard(decl)
+ case decl: BipIncomingData[G] => RefBipIncomingData(decl)
+ case decl: BipOutgoingData[G] => RefBipOutgoingData(decl)
+ case decl: BipPort[G] => RefBipPort(decl)
+ case decl: BipPortSynchronization[G] => RefBipPortSynchronization(decl)
+ case decl: BipStatePredicate[G] => RefBipStatePredicate(decl)
+ case decl: BipTransition[G] => RefBipTransition(decl)
+ case decl: BipTransitionSynchronization[G] =>
+ RefBipTransitionSynchronization(decl)
+ case decl: BipConstructor[G] => RefBipConstructor(decl)
+ case decl: HeapVariable[G] => RefHeapVariable(decl)
+ case decl: PVLEndpoint[G] => RefPVLEndpoint(decl)
+ case decl: PVLChoreography[G] => RefPVLChoreography(decl)
+ case decl: PVLChorRun[G] => RefPVLChorRun(decl)
+ })
- def originName(decl: Declaration[_]): String = decl.o.find[SourceName] match {
- case Some(SourceName(name)) => name
- case _ => throw NameLost(decl.o)
- }
+ def originName(decl: Declaration[_]): String =
+ decl.o.find[SourceName] match {
+ case Some(SourceName(name)) => name
+ case _ => throw NameLost(decl.o)
+ }
- def originNameOrEmpty(decl: Declaration[_]): String = decl.o.find[SourceName] match {
- case Some(SourceName(name)) => name
- case _ => ""
- }
+ def originNameOrEmpty(decl: Declaration[_]): String =
+ decl.o.find[SourceName] match {
+ case Some(SourceName(name)) => name
+ case _ => ""
+ }
}
/*
@@ -225,19 +252,31 @@ sealed trait CTypeNameTarget[G] extends Referrable[G]
sealed trait CStructTarget[G] extends Referrable[G]
sealed trait CPPTypeNameTarget[G] extends Referrable[G]
sealed trait PVLTypeNameTarget[G] extends Referrable[G]
-sealed trait SpecTypeNameTarget[G] extends JavaTypeNameTarget[G] with CTypeNameTarget[G] with CPPTypeNameTarget[G] with PVLTypeNameTarget[G]
+sealed trait SpecTypeNameTarget[G]
+ extends JavaTypeNameTarget[G]
+ with CTypeNameTarget[G]
+ with CPPTypeNameTarget[G]
+ with PVLTypeNameTarget[G]
sealed trait JavaNameTarget[G] extends Referrable[G]
sealed trait CNameTarget[G] extends Referrable[G]
sealed trait CPPNameTarget[G] extends Referrable[G]
sealed trait PVLNameTarget[G] extends Referrable[G]
-sealed trait SpecNameTarget[G] extends CNameTarget[G] with CPPNameTarget[G] with JavaNameTarget[G] with PVLNameTarget[G]
+sealed trait SpecNameTarget[G]
+ extends CNameTarget[G]
+ with CPPNameTarget[G]
+ with JavaNameTarget[G]
+ with PVLNameTarget[G]
sealed trait CDerefTarget[G] extends Referrable[G]
sealed trait CPPDerefTarget[G] extends Referrable[G]
sealed trait JavaDerefTarget[G] extends Referrable[G]
sealed trait PVLDerefTarget[G] extends Referrable[G]
-sealed trait SpecDerefTarget[G] extends CDerefTarget[G] with CPPDerefTarget[G] with JavaDerefTarget[G] with PVLDerefTarget[G]
+sealed trait SpecDerefTarget[G]
+ extends CDerefTarget[G]
+ with CPPDerefTarget[G]
+ with JavaDerefTarget[G]
+ with PVLDerefTarget[G]
sealed trait JavaInvocationTarget[G] extends Referrable[G]
sealed trait CInvocationTarget[G] extends Referrable[G]
@@ -245,11 +284,13 @@ sealed trait CPPInvocationTarget[G] extends Referrable[G]
sealed trait PVLInvocationTarget[G] extends Referrable[G]
sealed trait LlvmInvocationTarget[G] extends Referrable[G]
sealed trait SpecInvocationTarget[G]
- extends JavaInvocationTarget[G]
+ extends JavaInvocationTarget[G]
with CNameTarget[G]
- with CDerefTarget[G] with CInvocationTarget[G]
+ with CDerefTarget[G]
+ with CInvocationTarget[G]
with CPPNameTarget[G]
- with CPPDerefTarget[G] with CPPInvocationTarget[G]
+ with CPPDerefTarget[G]
+ with CPPInvocationTarget[G]
with PVLInvocationTarget[G]
with LlvmInvocationTarget[G]
@@ -262,68 +303,159 @@ sealed trait PVLConstructorTarget[G] extends Referrable[G]
sealed trait JavaBipStatePredicateTarget[G] extends Referrable[G]
-case class RefCTranslationUnit[G](decl: CTranslationUnit[G]) extends Referrable[G]
-case class RefCParam[G](decl: CParam[G]) extends Referrable[G] with CNameTarget[G]
-case class RefOpenCLVectorLiteralCInvocationTarget[G](size: BigInt, innerType: Type[G]) extends CInvocationTarget[G]
-case class RefCFunctionDefinition[G](decl: CFunctionDefinition[G]) extends Referrable[G] with CNameTarget[G] with CInvocationTarget[G] with ResultTarget[G]
-case class RefCGlobalDeclaration[G](decls: CGlobalDeclaration[G], initIdx: Int) extends Referrable[G] with CNameTarget[G] with CInvocationTarget[G] with ResultTarget[G]
-case class RefCLocalDeclaration[G](decls: CLocalDeclaration[G], initIdx: Int) extends Referrable[G] with CNameTarget[G]
-case class RefCPPTranslationUnit[G](decl: CPPTranslationUnit[G]) extends Referrable[G]
-case class RefCPPParam[G](decl: CPPParam[G]) extends Referrable[G] with CPPNameTarget[G]
-case class RefCPPFunctionDefinition[G](decl: CPPFunctionDefinition[G]) extends Referrable[G] with CPPNameTarget[G] with CPPInvocationTarget[G] with ResultTarget[G]
-case class RefCPPLambdaDefinition[G](decl: CPPLambdaDefinition[G]) extends Referrable[G] with CPPInvocationTarget[G] with CPPTypeNameTarget[G]
-case class RefCPPCustomType[G](typeName: String) extends Referrable[G] with CPPTypeNameTarget[G]
-case class RefCPPGlobalDeclaration[G](decls: CPPGlobalDeclaration[G], initIdx: Int) extends Referrable[G] with CPPNameTarget[G] with CPPInvocationTarget[G] with CPPDerefTarget[G] with ResultTarget[G]
-case class RefCPPLocalDeclaration[G](decls: CPPLocalDeclaration[G], initIdx: Int) extends Referrable[G] with CPPNameTarget[G]
-case class RefSYCLAccessMode[G](decl: SYCLAccessMode[G]) extends Referrable[G] with CPPNameTarget[G]
-case class RefSYCLConstructorDefinition[G](typ: SYCLTConstructableClass[G]) extends Referrable[G] with CPPNameTarget[G] with CPPInvocationTarget[G]
+case class RefCTranslationUnit[G](decl: CTranslationUnit[G])
+ extends Referrable[G]
+case class RefCParam[G](decl: CParam[G])
+ extends Referrable[G] with CNameTarget[G]
+case class RefOpenCLVectorLiteralCInvocationTarget[G](
+ size: BigInt,
+ innerType: Type[G],
+) extends CInvocationTarget[G]
+case class RefCFunctionDefinition[G](decl: CFunctionDefinition[G])
+ extends Referrable[G]
+ with CNameTarget[G]
+ with CInvocationTarget[G]
+ with ResultTarget[G]
+case class RefCGlobalDeclaration[G](decls: CGlobalDeclaration[G], initIdx: Int)
+ extends Referrable[G]
+ with CNameTarget[G]
+ with CInvocationTarget[G]
+ with ResultTarget[G]
+case class RefCLocalDeclaration[G](decls: CLocalDeclaration[G], initIdx: Int)
+ extends Referrable[G] with CNameTarget[G]
+case class RefCPPTranslationUnit[G](decl: CPPTranslationUnit[G])
+ extends Referrable[G]
+case class RefCPPParam[G](decl: CPPParam[G])
+ extends Referrable[G] with CPPNameTarget[G]
+case class RefCPPFunctionDefinition[G](decl: CPPFunctionDefinition[G])
+ extends Referrable[G]
+ with CPPNameTarget[G]
+ with CPPInvocationTarget[G]
+ with ResultTarget[G]
+case class RefCPPLambdaDefinition[G](decl: CPPLambdaDefinition[G])
+ extends Referrable[G] with CPPInvocationTarget[G] with CPPTypeNameTarget[G]
+case class RefCPPCustomType[G](typeName: String)
+ extends Referrable[G] with CPPTypeNameTarget[G]
+case class RefCPPGlobalDeclaration[G](
+ decls: CPPGlobalDeclaration[G],
+ initIdx: Int,
+) extends Referrable[G]
+ with CPPNameTarget[G]
+ with CPPInvocationTarget[G]
+ with CPPDerefTarget[G]
+ with ResultTarget[G]
+case class RefCPPLocalDeclaration[G](
+ decls: CPPLocalDeclaration[G],
+ initIdx: Int,
+) extends Referrable[G] with CPPNameTarget[G]
+case class RefSYCLAccessMode[G](decl: SYCLAccessMode[G])
+ extends Referrable[G] with CPPNameTarget[G]
+case class RefSYCLConstructorDefinition[G](typ: SYCLTConstructableClass[G])
+ extends Referrable[G] with CPPNameTarget[G] with CPPInvocationTarget[G]
case class RefJavaNamespace[G](decl: JavaNamespace[G]) extends Referrable[G]
-case class RefUnloadedJavaNamespace[G](names: Seq[String]) extends Referrable[G] with JavaNameTarget[G] with JavaDerefTarget[G]
-case class RefTypeDef[G](decl: CGlobalDeclaration[G]) extends Referrable[G] with CTypeNameTarget[G] with CNameTarget[G]
-case class RefCStruct[G](decl: CGlobalDeclaration[G]) extends Referrable[G] with CStructTarget[G] with CNameTarget[G] with CDerefTarget[G]
-case class RefCStructField[G](decls: CStructMemberDeclarator[G], idx: Int) extends Referrable[G] with CNameTarget[G] with CDerefTarget[G]
-case class RefOpenCLVectorMembers[G](idx: Seq[BigInt]) extends Referrable[G] with CDerefTarget[G]
-case class RefJavaClass[G](decl: JavaClassOrInterface[G]) extends Referrable[G] with JavaTypeNameTarget[G] with JavaNameTarget[G] with JavaDerefTarget[G] with ThisTarget[G]
+case class RefUnloadedJavaNamespace[G](names: Seq[String])
+ extends Referrable[G] with JavaNameTarget[G] with JavaDerefTarget[G]
+case class RefTypeDef[G](decl: CGlobalDeclaration[G])
+ extends Referrable[G] with CTypeNameTarget[G] with CNameTarget[G]
+case class RefCStruct[G](decl: CGlobalDeclaration[G])
+ extends Referrable[G]
+ with CStructTarget[G]
+ with CNameTarget[G]
+ with CDerefTarget[G]
+case class RefCStructField[G](decls: CStructMemberDeclarator[G], idx: Int)
+ extends Referrable[G] with CNameTarget[G] with CDerefTarget[G]
+case class RefOpenCLVectorMembers[G](idx: Seq[BigInt])
+ extends Referrable[G] with CDerefTarget[G]
+case class RefJavaClass[G](decl: JavaClassOrInterface[G])
+ extends Referrable[G]
+ with JavaTypeNameTarget[G]
+ with JavaNameTarget[G]
+ with JavaDerefTarget[G]
+ with ThisTarget[G]
case class RefSilverField[G](decl: SilverField[G]) extends Referrable[G]
-case class RefSimplificationRule[G](decl: SimplificationRule[G]) extends Referrable[G]
-case class RefAxiomaticDataType[G](decl: AxiomaticDataType[G]) extends Referrable[G] with SpecTypeNameTarget[G] with SpecNameTarget[G] with JavaDerefTarget[G]
-case class RefFunction[G](decl: Function[G]) extends Referrable[G] with SpecInvocationTarget[G] with ResultTarget[G]
-case class RefProcedure[G](decl: Procedure[G]) extends Referrable[G] with SpecInvocationTarget[G] with ResultTarget[G]
-case class RefVeSUVMainMethod[G](decl: VeSUVMainMethod[G]) extends Referrable[G] with SpecInvocationTarget[G] with ResultTarget[G]
-case class RefPredicate[G](decl: Predicate[G]) extends Referrable[G] with SpecInvocationTarget[G]
-case class RefClass[G](decl: Class[G]) extends Referrable[G] with PVLTypeNameTarget[G] with SpecNameTarget[G] with ThisTarget[G]
-case class RefModel[G](decl: Model[G]) extends Referrable[G] with SpecTypeNameTarget[G] with ThisTarget[G] with PVLConstructorTarget[G] with JavaConstructorTarget[G]
-case class RefEnum[G](decl: Enum[G]) extends Referrable[G] with SpecTypeNameTarget[G] with SpecNameTarget[G]
-case class RefEnumConstant[G](enum: Option[Enum[G]], decl: EnumConstant[G]) extends Referrable[G] with SpecDerefTarget[G] with SpecNameTarget[G]
-case class RefJavaSharedInitialization[G](decl: JavaSharedInitialization[G]) extends Referrable[G]
-case class RefJavaField[G](decls: JavaFields[G], idx: Int) extends Referrable[G] with JavaNameTarget[G] with JavaDerefTarget[G]
-case class RefJavaLocalDeclaration[G](decls: JavaLocalDeclaration[G], idx: Int) extends Referrable[G] with JavaNameTarget[G]
-case class RefJavaConstructor[G](decl: JavaConstructor[G]) extends Referrable[G] with JavaConstructorTarget[G]
-case class RefJavaMethod[G](decl: JavaMethod[G]) extends Referrable[G] with JavaInvocationTarget[G] with ResultTarget[G]
-case class RefJavaParam[G](decl: JavaParam[G]) extends Referrable[G] with JavaNameTarget[G]
-case class RefJavaAnnotationMethod[G](decl: JavaAnnotationMethod[G]) extends Referrable[G] with JavaInvocationTarget[G] with ResultTarget[G]
-case class RefInstanceFunction[G](decl: InstanceFunction[G]) extends Referrable[G] with SpecInvocationTarget[G] with ResultTarget[G]
-case class RefInstanceMethod[G](decl: InstanceMethod[G]) extends Referrable[G] with SpecInvocationTarget[G] with ResultTarget[G]
-case class RefInstanceOperatorMethod[G](decl: InstanceOperatorMethod[G]) extends Referrable[G] with ResultTarget[G]
-case class RefInstanceOperatorFunction[G](decl: InstanceOperatorFunction[G]) extends Referrable[G] with ResultTarget[G]
-case class RefInstancePredicate[G](decl: InstancePredicate[G]) extends Referrable[G] with SpecInvocationTarget[G]
-case class RefField[G](decl: InstanceField[G]) extends Referrable[G] with PVLNameTarget[G] with PVLDerefTarget[G]
-case class RefVariable[G](decl: Variable[G]) extends Referrable[G] with SpecNameTarget[G] with SpecTypeNameTarget[G]
+case class RefSimplificationRule[G](decl: SimplificationRule[G])
+ extends Referrable[G]
+case class RefAxiomaticDataType[G](decl: AxiomaticDataType[G])
+ extends Referrable[G]
+ with SpecTypeNameTarget[G]
+ with SpecNameTarget[G]
+ with JavaDerefTarget[G]
+case class RefFunction[G](decl: Function[G])
+ extends Referrable[G] with SpecInvocationTarget[G] with ResultTarget[G]
+case class RefProcedure[G](decl: Procedure[G])
+ extends Referrable[G] with SpecInvocationTarget[G] with ResultTarget[G]
+case class RefVeSUVMainMethod[G](decl: VeSUVMainMethod[G])
+ extends Referrable[G] with SpecInvocationTarget[G] with ResultTarget[G]
+case class RefPredicate[G](decl: Predicate[G])
+ extends Referrable[G] with SpecInvocationTarget[G]
+case class RefClass[G](decl: Class[G])
+ extends Referrable[G]
+ with PVLTypeNameTarget[G]
+ with SpecNameTarget[G]
+ with ThisTarget[G]
+case class RefModel[G](decl: Model[G])
+ extends Referrable[G]
+ with SpecTypeNameTarget[G]
+ with ThisTarget[G]
+ with PVLConstructorTarget[G]
+ with JavaConstructorTarget[G]
+case class RefEnum[G](decl: Enum[G])
+ extends Referrable[G] with SpecTypeNameTarget[G] with SpecNameTarget[G]
+case class RefEnumConstant[G](enum: Option[Enum[G]], decl: EnumConstant[G])
+ extends Referrable[G] with SpecDerefTarget[G] with SpecNameTarget[G]
+case class RefJavaSharedInitialization[G](decl: JavaSharedInitialization[G])
+ extends Referrable[G]
+case class RefJavaField[G](decls: JavaFields[G], idx: Int)
+ extends Referrable[G] with JavaNameTarget[G] with JavaDerefTarget[G]
+case class RefJavaLocalDeclaration[G](decls: JavaLocalDeclaration[G], idx: Int)
+ extends Referrable[G] with JavaNameTarget[G]
+case class RefJavaConstructor[G](decl: JavaConstructor[G])
+ extends Referrable[G] with JavaConstructorTarget[G]
+case class RefJavaMethod[G](decl: JavaMethod[G])
+ extends Referrable[G] with JavaInvocationTarget[G] with ResultTarget[G]
+case class RefJavaParam[G](decl: JavaParam[G])
+ extends Referrable[G] with JavaNameTarget[G]
+case class RefJavaAnnotationMethod[G](decl: JavaAnnotationMethod[G])
+ extends Referrable[G] with JavaInvocationTarget[G] with ResultTarget[G]
+case class RefInstanceFunction[G](decl: InstanceFunction[G])
+ extends Referrable[G] with SpecInvocationTarget[G] with ResultTarget[G]
+case class RefInstanceMethod[G](decl: InstanceMethod[G])
+ extends Referrable[G] with SpecInvocationTarget[G] with ResultTarget[G]
+case class RefInstanceOperatorMethod[G](decl: InstanceOperatorMethod[G])
+ extends Referrable[G] with ResultTarget[G]
+case class RefInstanceOperatorFunction[G](decl: InstanceOperatorFunction[G])
+ extends Referrable[G] with ResultTarget[G]
+case class RefInstancePredicate[G](decl: InstancePredicate[G])
+ extends Referrable[G] with SpecInvocationTarget[G]
+case class RefField[G](decl: InstanceField[G])
+ extends Referrable[G] with PVLNameTarget[G] with PVLDerefTarget[G]
+case class RefVariable[G](decl: Variable[G])
+ extends Referrable[G] with SpecNameTarget[G] with SpecTypeNameTarget[G]
case class RefLabelDecl[G](decl: LabelDecl[G]) extends Referrable[G]
case class RefSendDecl[G](decl: SendDecl[G]) extends Referrable[G]
case class RefRunMethod[G](decl: RunMethod[G]) extends Referrable[G]
case class RefParBlockDecl[G](decl: ParBlockDecl[G]) extends Referrable[G]
-case class RefParInvariantDecl[G](decl: ParInvariantDecl[G]) extends Referrable[G]
+case class RefParInvariantDecl[G](decl: ParInvariantDecl[G])
+ extends Referrable[G]
case class RefADTAxiom[G](decl: ADTAxiom[G]) extends Referrable[G]
-case class RefADTFunction[G](decl: ADTFunction[G]) extends Referrable[G] with SpecInvocationTarget[G]
-case class RefModelField[G](decl: ModelField[G]) extends Referrable[G] with SpecDerefTarget[G] with SpecNameTarget[G]
-case class RefModelProcess[G](decl: ModelProcess[G]) extends Referrable[G] with SpecInvocationTarget[G]
-case class RefModelAction[G](decl: ModelAction[G]) extends Referrable[G] with SpecInvocationTarget[G]
-case class RefPVLConstructor[G](decl: PVLConstructor[G]) extends Referrable[G] with PVLConstructorTarget[G]
-case class RefJavaBipStatePredicate[G](state: String, decl: JavaAnnotation[G]) extends Referrable[G] with JavaBipStatePredicateTarget[G]
-case class RefJavaBipGuard[G](decl: JavaMethod[G]) extends Referrable[G] with JavaNameTarget[G]
-case class RefJavaBipGlueContainer[G]() extends Referrable[G] // Bip glue jobs are not actually referrable
-case class RefLlvmFunctionDefinition[G](decl: LlvmFunctionDefinition[G]) extends Referrable[G] with LlvmInvocationTarget[G] with ResultTarget[G]
+case class RefADTFunction[G](decl: ADTFunction[G])
+ extends Referrable[G] with SpecInvocationTarget[G]
+case class RefModelField[G](decl: ModelField[G])
+ extends Referrable[G] with SpecDerefTarget[G] with SpecNameTarget[G]
+case class RefModelProcess[G](decl: ModelProcess[G])
+ extends Referrable[G] with SpecInvocationTarget[G]
+case class RefModelAction[G](decl: ModelAction[G])
+ extends Referrable[G] with SpecInvocationTarget[G]
+case class RefPVLConstructor[G](decl: PVLConstructor[G])
+ extends Referrable[G] with PVLConstructorTarget[G]
+case class RefJavaBipStatePredicate[G](state: String, decl: JavaAnnotation[G])
+ extends Referrable[G] with JavaBipStatePredicateTarget[G]
+case class RefJavaBipGuard[G](decl: JavaMethod[G])
+ extends Referrable[G] with JavaNameTarget[G]
+case class RefJavaBipGlueContainer[G]()
+ extends Referrable[G] // Bip glue jobs are not actually referrable
+case class RefLlvmFunctionDefinition[G](decl: LlvmFunctionDefinition[G])
+ extends Referrable[G] with LlvmInvocationTarget[G] with ResultTarget[G]
case class RefLlvmGlobal[G](decl: LlvmGlobal[G], idx: Int) extends Referrable[G]
case class RefBipComponent[G](decl: BipComponent[G]) extends Referrable[G]
case class RefBipGlue[G](decl: BipGlue[G]) extends Referrable[G]
@@ -331,31 +463,47 @@ case class RefBipGuard[G](decl: BipGuard[G]) extends Referrable[G]
case class RefBipIncomingData[G](decl: BipIncomingData[G]) extends Referrable[G]
case class RefBipOutgoingData[G](decl: BipOutgoingData[G]) extends Referrable[G]
case class RefBipPort[G](decl: BipPort[G]) extends Referrable[G]
-case class RefBipPortSynchronization[G](decl: BipPortSynchronization[G]) extends Referrable[G]
-case class RefBipStatePredicate[G](decl: BipStatePredicate[G]) extends Referrable[G]
+case class RefBipPortSynchronization[G](decl: BipPortSynchronization[G])
+ extends Referrable[G]
+case class RefBipStatePredicate[G](decl: BipStatePredicate[G])
+ extends Referrable[G]
case class RefBipTransition[G](decl: BipTransition[G]) extends Referrable[G]
-case class RefBipTransitionSynchronization[G](decl: BipTransitionSynchronization[G]) extends Referrable[G]
+case class RefBipTransitionSynchronization[G](
+ decl: BipTransitionSynchronization[G]
+) extends Referrable[G]
case class RefBipConstructor[G](decl: BipConstructor[G]) extends Referrable[G]
case class RefHeapVariable[G](decl: HeapVariable[G]) extends Referrable[G]
-case class RefPVLEndpoint[G](decl: PVLEndpoint[G]) extends Referrable[G] with PVLNameTarget[G]
-case class RefPVLChoreography[G](decl: PVLChoreography[G]) extends Referrable[G] with ThisTarget[G]
+case class RefPVLEndpoint[G](decl: PVLEndpoint[G])
+ extends Referrable[G] with PVLNameTarget[G]
+case class RefPVLChoreography[G](decl: PVLChoreography[G])
+ extends Referrable[G] with ThisTarget[G]
case class RefPVLChorRun[G](decl: PVLChorRun[G]) extends Referrable[G]
-case class RefLlvmSpecFunction[G](decl: LlvmSpecFunction[G]) extends Referrable[G] with LlvmInvocationTarget[G] with ResultTarget[G]
-case class RefChoreography[G](decl: Choreography[G]) extends Referrable[G] with ThisTarget[G]
+case class RefLlvmSpecFunction[G](decl: LlvmSpecFunction[G])
+ extends Referrable[G] with LlvmInvocationTarget[G] with ResultTarget[G]
+case class RefChoreography[G](decl: Choreography[G])
+ extends Referrable[G] with ThisTarget[G]
case class RefEndpoint[G](decl: Endpoint[G]) extends Referrable[G]
-case class RefProverType[G](decl: ProverType[G]) extends Referrable[G] with SpecTypeNameTarget[G]
-case class RefProverFunction[G](decl: ProverFunction[G]) extends Referrable[G] with SpecInvocationTarget[G]
+case class RefProverType[G](decl: ProverType[G])
+ extends Referrable[G] with SpecTypeNameTarget[G]
+case class RefProverFunction[G](decl: ProverFunction[G])
+ extends Referrable[G] with SpecInvocationTarget[G]
-case class BuiltinField[G](f: Expr[G] => Expr[G]) extends Referrable[G] with SpecDerefTarget[G]
-case class BuiltinInstanceMethod[G](f: Expr[G] => Seq[Expr[G]] => Expr[G]) extends Referrable[G] with SpecInvocationTarget[G]
+case class BuiltinField[G](f: Expr[G] => Expr[G])
+ extends Referrable[G] with SpecDerefTarget[G]
+case class BuiltinInstanceMethod[G](f: Expr[G] => Seq[Expr[G]] => Expr[G])
+ extends Referrable[G] with SpecInvocationTarget[G]
-case class PVLBuiltinInstanceMethod[G](f: Expr[G] => Seq[Expr[G]] => Expr[G]) extends Referrable[G] with PVLInvocationTarget[G]
+case class PVLBuiltinInstanceMethod[G](f: Expr[G] => Seq[Expr[G]] => Expr[G])
+ extends Referrable[G] with PVLInvocationTarget[G]
-case class ImplicitDefaultJavaConstructor[G](cls: JavaClass[G]) extends Referrable[G] with JavaConstructorTarget[G]
-case class ImplicitDefaultPVLConstructor[G](cls: Class[G]) extends Referrable[G] with PVLConstructorTarget[G]
+case class ImplicitDefaultJavaConstructor[G](cls: JavaClass[G])
+ extends Referrable[G] with JavaConstructorTarget[G]
+case class ImplicitDefaultPVLConstructor[G](cls: Class[G])
+ extends Referrable[G] with PVLConstructorTarget[G]
-case class ImplicitDefaultJavaBipStatePredicate[G](state: String) extends Referrable[G] with JavaBipStatePredicateTarget[G]
+case class ImplicitDefaultJavaBipStatePredicate[G](state: String)
+ extends Referrable[G] with JavaBipStatePredicateTarget[G]
sealed trait RefCudaVec[G] extends Referrable[G] with CNameTarget[G]
case class RefCudaThreadIdx[G]() extends RefCudaVec[G]
diff --git a/src/col/vct/col/resolve/ctx/TypeResolutionContext.scala b/src/col/vct/col/resolve/ctx/TypeResolutionContext.scala
index 9f4b37b8ef..841f337de6 100644
--- a/src/col/vct/col/resolve/ctx/TypeResolutionContext.scala
+++ b/src/col/vct/col/resolve/ctx/TypeResolutionContext.scala
@@ -6,12 +6,12 @@ import vct.col.resolve.ResolveTypes.JavaClassPathEntry
import scala.collection.mutable
-case class TypeResolutionContext[G]
-(
- stack: Seq[Seq[Referrable[G]]] = Nil,
- namespace: Option[JavaNamespace[G]] = None,
- externalJavaLoader: Option[ExternalJavaLoader] = None,
- javaClassPath: Seq[JavaClassPathEntry] = Nil,
- inGpuKernel: Boolean = false,
- externallyLoadedElements: mutable.ArrayBuffer[GlobalDeclaration[G]] = mutable.ArrayBuffer[GlobalDeclaration[G]](),
+case class TypeResolutionContext[G](
+ stack: Seq[Seq[Referrable[G]]] = Nil,
+ namespace: Option[JavaNamespace[G]] = None,
+ externalJavaLoader: Option[ExternalJavaLoader] = None,
+ javaClassPath: Seq[JavaClassPathEntry] = Nil,
+ inGpuKernel: Boolean = false,
+ externallyLoadedElements: mutable.ArrayBuffer[GlobalDeclaration[G]] =
+ mutable.ArrayBuffer[GlobalDeclaration[G]](),
)
diff --git a/src/col/vct/col/resolve/lang/C.scala b/src/col/vct/col/resolve/lang/C.scala
index d00f634d58..720f63286e 100644
--- a/src/col/vct/col/resolve/lang/C.scala
+++ b/src/col/vct/col/resolve/lang/C.scala
@@ -45,98 +45,150 @@ case object C {
case object LP64 extends DataModel
case object LLP64 extends DataModel
- def INT_TYPE_TO_SIZE(dm: DataModel): Map[Seq[CDeclarationSpecifier[_]], Int] = Map(
- (Seq(CShort()) -> 16),
- (Seq(CShort(), CInt()) -> 16),
- (Seq(CInt()) -> 32),
- (Seq(CLong()) -> 64),
- (Seq(CLong(), CInt()) -> (if(dm == LP64) 64 else 32)),
- (Seq(CLong(), CLong()) -> 64),
- (Seq(CLong(), CLong(), CInt()) -> 64),
- )
-
- case class DeclaratorInfo[G](params: Option[Seq[CParam[G]]], typeOrReturnType: Type[G] => Type[G], name: String)
+ def INT_TYPE_TO_SIZE(dm: DataModel): Map[Seq[CDeclarationSpecifier[_]], Int] =
+ Map(
+ (Seq(CShort()) -> 16),
+ (Seq(CShort(), CInt()) -> 16),
+ (Seq(CInt()) -> 32),
+ (Seq(CLong()) -> 64),
+ (Seq(CLong(), CInt()) ->
+ (if (dm == LP64)
+ 64
+ else
+ 32)),
+ (Seq(CLong(), CLong()) -> 64),
+ (Seq(CLong(), CLong(), CInt()) -> 64),
+ )
- def getDeclaratorInfo[G](decl: CDeclarator[G]): DeclaratorInfo[G] = decl match {
- case CPointerDeclarator(pointers, inner) =>
- val innerInfo = getDeclaratorInfo(inner)
- DeclaratorInfo(
- innerInfo.params,
- t => innerInfo.typeOrReturnType(FuncTools.repeat[Type[G]](CTPointer(_), pointers.size, t)),
- innerInfo.name)
- case c @ CArrayDeclarator(_, size, inner) =>
- val innerInfo = getDeclaratorInfo(inner)
- DeclaratorInfo(innerInfo.params, t => innerInfo.typeOrReturnType(CTArray(size, t)(c.blame)), innerInfo.name)
- case CPointerDeclarator(pointers, inner) =>
- val innerInfo = getDeclaratorInfo(inner)
- DeclaratorInfo(
- innerInfo.params,
- t => innerInfo.typeOrReturnType(FuncTools.repeat[Type[G]](CTPointer(_), pointers.size, t)),
- innerInfo.name)
- case CTypeExtensionDeclarator(Seq(CTypeAttribute(name, Seq(size))), inner) if name == "vector_size" || name == "__vector_size__" =>
- val innerInfo = getDeclaratorInfo(inner)
- DeclaratorInfo(
- innerInfo.params,
- t => CTVector(size, innerInfo.typeOrReturnType(t))(decl.o),
- innerInfo.name)
- case typeExtension@CTypeExtensionDeclarator(_, _) => throw CTypeNotSupported(Some(typeExtension))
- case CTypedFunctionDeclarator(params, _, inner) =>
- val innerInfo = getDeclaratorInfo(inner)
- DeclaratorInfo(params=Some(params), typeOrReturnType=(t => t), innerInfo.name)
- case CAnonymousFunctionDeclarator(Nil, inner) =>
- val innerInfo = getDeclaratorInfo(inner)
- DeclaratorInfo(params=Some(Nil), typeOrReturnType=(t => t), innerInfo.name)
- case decl @ CAnonymousFunctionDeclarator(_, _) =>
- throw AnonymousMethodsUnsupported(decl)
- case CName(name) => DeclaratorInfo(params=None, typeOrReturnType=(t => t), name)
- }
+ case class DeclaratorInfo[G](
+ params: Option[Seq[CParam[G]]],
+ typeOrReturnType: Type[G] => Type[G],
+ name: String,
+ )
- def getSpecs[G](decl: CDeclarator[G], acc: Seq[CDeclarationSpecifier[G]] = Nil): Seq[CDeclarationSpecifier[G]] = decl match {
- case CTypeExtensionDeclarator(extensions, inner) => getSpecs(inner, acc :+ CFunctionTypeExtensionModifier(extensions))
- case _ => acc
- }
+ def getDeclaratorInfo[G](decl: CDeclarator[G]): DeclaratorInfo[G] =
+ decl match {
+ case CPointerDeclarator(pointers, inner) =>
+ val innerInfo = getDeclaratorInfo(inner)
+ DeclaratorInfo(
+ innerInfo.params,
+ t =>
+ innerInfo.typeOrReturnType(
+ FuncTools.repeat[Type[G]](CTPointer(_), pointers.size, t)
+ ),
+ innerInfo.name,
+ )
+ case c @ CArrayDeclarator(_, size, inner) =>
+ val innerInfo = getDeclaratorInfo(inner)
+ DeclaratorInfo(
+ innerInfo.params,
+ t => innerInfo.typeOrReturnType(CTArray(size, t)(c.blame)),
+ innerInfo.name,
+ )
+ case CPointerDeclarator(pointers, inner) =>
+ val innerInfo = getDeclaratorInfo(inner)
+ DeclaratorInfo(
+ innerInfo.params,
+ t =>
+ innerInfo.typeOrReturnType(
+ FuncTools.repeat[Type[G]](CTPointer(_), pointers.size, t)
+ ),
+ innerInfo.name,
+ )
+ case CTypeExtensionDeclarator(Seq(CTypeAttribute(name, Seq(size))), inner)
+ if name == "vector_size" || name == "__vector_size__" =>
+ val innerInfo = getDeclaratorInfo(inner)
+ DeclaratorInfo(
+ innerInfo.params,
+ t => CTVector(size, innerInfo.typeOrReturnType(t))(decl.o),
+ innerInfo.name,
+ )
+ case typeExtension @ CTypeExtensionDeclarator(_, _) =>
+ throw CTypeNotSupported(Some(typeExtension))
+ case CTypedFunctionDeclarator(params, _, inner) =>
+ val innerInfo = getDeclaratorInfo(inner)
+ DeclaratorInfo(
+ params = Some(params),
+ typeOrReturnType = (t => t),
+ innerInfo.name,
+ )
+ case CAnonymousFunctionDeclarator(Nil, inner) =>
+ val innerInfo = getDeclaratorInfo(inner)
+ DeclaratorInfo(
+ params = Some(Nil),
+ typeOrReturnType = (t => t),
+ innerInfo.name,
+ )
+ case decl @ CAnonymousFunctionDeclarator(_, _) =>
+ throw AnonymousMethodsUnsupported(decl)
+ case CName(name) =>
+ DeclaratorInfo(params = None, typeOrReturnType = (t => t), name)
+ }
- def getTypeFromTypeDef[G](decl: CDeclaration[G], context: Option[Node[G]] = None): Type[G] = {
- val specs: Seq[CDeclarationSpecifier[G]] = decl.specs match {
- case CTypedef() +: remaining => remaining
- case _ => ???
+ def getSpecs[G](
+ decl: CDeclarator[G],
+ acc: Seq[CDeclarationSpecifier[G]] = Nil,
+ ): Seq[CDeclarationSpecifier[G]] =
+ decl match {
+ case CTypeExtensionDeclarator(extensions, inner) =>
+ getSpecs(inner, acc :+ CFunctionTypeExtensionModifier(extensions))
+ case _ => acc
}
+ def getTypeFromTypeDef[G](
+ decl: CDeclaration[G],
+ context: Option[Node[G]] = None,
+ ): Type[G] = {
+ val specs: Seq[CDeclarationSpecifier[G]] =
+ decl.specs match {
+ case CTypedef() +: remaining => remaining
+ case _ => ???
+ }
+
// Need to get specifications from the init (can only have one init as typedef), since it can contain GCC Type extensions
getPrimitiveType(getSpecs(decl.inits.head.decl) ++ specs, context)
}
+ def getPrimitiveType[G](
+ specs: Seq[CDeclarationSpecifier[G]],
+ context: Option[Node[G]] = None,
+ ): Type[G] = {
+ val vectorSize: Option[Expr[G]] =
+ specs.collect { case ext: CFunctionTypeExtensionModifier[G] =>
+ ext.extensions
+ } match {
+ case Seq(Seq(CTypeAttribute(name, Seq(size: Expr[G]))))
+ if name == "__vector_size__" || name == "vector_size" =>
+ Some(size)
+ case Seq() => None
+ case _ => throw CTypeNotSupported(context)
+ }
- def getPrimitiveType[G](specs: Seq[CDeclarationSpecifier[G]], context: Option[Node[G]] = None): Type[G] = {
- val vectorSize: Option[Expr[G]] = specs.collect { case ext: CFunctionTypeExtensionModifier[G] => ext.extensions} match {
- case Seq(Seq(CTypeAttribute(name, Seq(size: Expr[G])))) if name == "__vector_size__" || name == "vector_size" => Some(size)
- case Seq() => None
- case _ => throw CTypeNotSupported(context)
- }
-
- val filteredSpecs = specs.filter { case _: CFunctionTypeExtensionModifier[G] => false; case _ => true }
- .collect { case spec: CTypeSpecifier[G] => spec }
+ val filteredSpecs = specs.filter {
+ case _: CFunctionTypeExtensionModifier[G] => false; case _ => true
+ }.collect { case spec: CTypeSpecifier[G] => spec }
- val t: Type[G] = filteredSpecs match {
- case Seq(CVoid()) => TVoid()
- case Seq(CChar()) => TChar()
- case CUnsigned() +: t if INTEGER_LIKE_TYPES.contains(t) => TCInt()
- case CSigned() +: t if INTEGER_LIKE_TYPES.contains(t) => TCInt()
- case t if C.INTEGER_LIKE_TYPES.contains(t) => TCInt()
- case Seq(CFloat()) => C_ieee754_32bit()
- case Seq(CDouble()) => C_ieee754_64bit()
- case Seq(CLong(), CDouble()) => C_ieee754_64bit()
- case Seq(CBool()) => TBool()
- case Seq(defn @ CTypedefName(_)) =>
- defn.ref.get match {
- case RefTypeDef(decl) => getTypeFromTypeDef(decl.decl)
- case _ => ???
- }
- case Seq(CSpecificationType(typ)) => typ
- case Seq(defn @ CStructSpecifier(_)) => CTStruct(defn.ref.get.decl.ref)
- case spec +: _ => throw CTypeNotSupported(context.orElse(Some(spec)))
- case _ => throw CTypeNotSupported(context)
- }
+ val t: Type[G] =
+ filteredSpecs match {
+ case Seq(CVoid()) => TVoid()
+ case Seq(CChar()) => TChar()
+ case CUnsigned() +: t if INTEGER_LIKE_TYPES.contains(t) => TCInt()
+ case CSigned() +: t if INTEGER_LIKE_TYPES.contains(t) => TCInt()
+ case t if C.INTEGER_LIKE_TYPES.contains(t) => TCInt()
+ case Seq(CFloat()) => C_ieee754_32bit()
+ case Seq(CDouble()) => C_ieee754_64bit()
+ case Seq(CLong(), CDouble()) => C_ieee754_64bit()
+ case Seq(CBool()) => TBool()
+ case Seq(defn @ CTypedefName(_)) =>
+ defn.ref.get match {
+ case RefTypeDef(decl) => getTypeFromTypeDef(decl.decl)
+ case _ => ???
+ }
+ case Seq(CSpecificationType(typ)) => typ
+ case Seq(defn @ CStructSpecifier(_)) => CTStruct(defn.ref.get.decl.ref)
+ case spec +: _ => throw CTypeNotSupported(context.orElse(Some(spec)))
+ case _ => throw CTypeNotSupported(context)
+ }
vectorSize match {
case None => t
case Some(size) => CTVector(size, t)
@@ -146,67 +198,99 @@ case object C {
def nameFromDeclarator(declarator: CDeclarator[_]): String =
getDeclaratorInfo(declarator).name
- def typeOrReturnTypeFromDeclaration[G](specs: Seq[CDeclarationSpecifier[G]], decl: CDeclarator[G]): Type[G] =
- getDeclaratorInfo(decl).typeOrReturnType(CPrimitiveType(specs))
+ def typeOrReturnTypeFromDeclaration[G](
+ specs: Seq[CDeclarationSpecifier[G]],
+ decl: CDeclarator[G],
+ ): Type[G] = getDeclaratorInfo(decl).typeOrReturnType(CPrimitiveType(specs))
def paramsFromDeclarator[G](declarator: CDeclarator[G]): Seq[CParam[G]] =
getDeclaratorInfo(declarator).params.get
- def findCTypeName[G](name: String, ctx: TypeResolutionContext[G]): Option[CTypeNameTarget[G]] =
+ def findCTypeName[G](
+ name: String,
+ ctx: TypeResolutionContext[G],
+ ): Option[CTypeNameTarget[G]] =
ctx.stack.flatten.collectFirst {
case target: CTypeNameTarget[G] if target.name == name => target
}
- def findCStruct[G](name: String, ctx: TypeResolutionContext[G]): Option[RefCStruct[G]] =
+ def findCStruct[G](
+ name: String,
+ ctx: TypeResolutionContext[G],
+ ): Option[RefCStruct[G]] =
ctx.stack.flatten.collectFirst {
case target: RefCStruct[G] if target.name == name => target
}
- def findCName[G](name: String, ctx: ReferenceResolutionContext[G]): Option[CNameTarget[G]] =
+ def findCName[G](
+ name: String,
+ ctx: ReferenceResolutionContext[G],
+ ): Option[CNameTarget[G]] =
name match {
case "threadIdx" => Some(RefCudaThreadIdx())
case "blockDim" => Some(RefCudaBlockDim())
case "blockIdx" => Some(RefCudaBlockIdx())
case "gridDim" => Some(RefCudaGridDim())
- case _ => ctx.stack.flatten.collectFirst {
- case target: CNameTarget[G] if target.name == name => target
- }
+ case _ =>
+ ctx.stack.flatten.collectFirst {
+ case target: CNameTarget[G] if target.name == name => target
+ }
}
- def findForwardDeclaration[G](declarator: CDeclarator[G], ctx: ReferenceResolutionContext[G]): Option[RefCGlobalDeclaration[G]] =
+ def findForwardDeclaration[G](
+ declarator: CDeclarator[G],
+ ctx: ReferenceResolutionContext[G],
+ ): Option[RefCGlobalDeclaration[G]] =
ctx.stack.flatten.collectFirst {
- case target: RefCGlobalDeclaration[G] if target.name == nameFromDeclarator(declarator) => target
+ case target: RefCGlobalDeclaration[G]
+ if target.name == nameFromDeclarator(declarator) =>
+ target
}
- def findDefinition[G](declarator: CDeclarator[G], ctx: ReferenceResolutionContext[G]): Option[RefCFunctionDefinition[G]] =
+ def findDefinition[G](
+ declarator: CDeclarator[G],
+ ctx: ReferenceResolutionContext[G],
+ ): Option[RefCFunctionDefinition[G]] =
ctx.stack.flatten.collectFirst {
- case target: RefCFunctionDefinition[G] if target.name == nameFromDeclarator(declarator) => target
+ case target: RefCFunctionDefinition[G]
+ if target.name == nameFromDeclarator(declarator) =>
+ target
}
- def stripCPrimitiveType[G](t: Type[G]): Type[G] = t match {
- case CPrimitiveType(specs) => getPrimitiveType(specs)
- case _ => t
- }
-
+ def stripCPrimitiveType[G](t: Type[G]): Type[G] =
+ t match {
+ case CPrimitiveType(specs) => getPrimitiveType(specs)
+ case _ => t
+ }
- def findPointerDeref[G](obj: Expr[G], name: String, ctx: ReferenceResolutionContext[G], blame: Blame[BuiltinError]): Option[CDerefTarget[G]] =
+ def findPointerDeref[G](
+ obj: Expr[G],
+ name: String,
+ ctx: ReferenceResolutionContext[G],
+ blame: Blame[BuiltinError],
+ ): Option[CDerefTarget[G]] =
stripCPrimitiveType(obj.t) match {
- case CTPointer(innerType: TNotAValue[G]) => innerType.decl.get match {
- case RefCStruct(decl) => getCStructDeref(decl, name)
- case _ => None
- }
+ case CTPointer(innerType: TNotAValue[G]) =>
+ innerType.decl.get match {
+ case RefCStruct(decl) => getCStructDeref(decl, name)
+ case _ => None
+ }
case CTPointer(struct: CTStruct[G]) =>
getCStructDeref(struct.ref.decl, name)
- case CTArray(_, innerType: TNotAValue[G]) => innerType.decl.get match {
- case RefCStruct(decl) => getCStructDeref(decl, name)
- case _ => None
- }
+ case CTArray(_, innerType: TNotAValue[G]) =>
+ innerType.decl.get match {
+ case RefCStruct(decl) => getCStructDeref(decl, name)
+ case _ => None
+ }
case CTArray(_, struct: CTStruct[G]) =>
getCStructDeref(struct.ref.decl, name)
case _ => None
}
- def getCStructDeref[G](decl: CGlobalDeclaration[G], name: String): Option[CDerefTarget[G]] =
+ def getCStructDeref[G](
+ decl: CGlobalDeclaration[G],
+ name: String,
+ ): Option[CDerefTarget[G]] =
decl.decl match {
case CDeclaration(_, _, Seq(CStructDeclaration(_, decls)), Seq()) =>
decls.flatMap(Referrable.from).collectFirst {
@@ -215,51 +299,71 @@ case object C {
case _ => None
}
- def openCLVectorAccessString[G](access: String, typeSize: BigInt): Option[Seq[BigInt]] = access match {
- case "lo" if typeSize % 2 == 0 => Some(Seq.tabulate(typeSize.toInt/2)(i => i))
- case "hi" if typeSize % 2 == 0 => Some(Seq.tabulate(typeSize.toInt/2)(i => i + typeSize/2))
- case "even" if typeSize % 2 == 0 => Some(Seq.tabulate(typeSize.toInt/2)(i => 2*i))
- case "odd" if typeSize % 2 == 0 => Some(Seq.tabulate(typeSize.toInt/2)(i => 2*i+1))
- case s if s.head == 's' && s.tail.nonEmpty =>
- val hexToInt = (i: Char) => i match {
- case i if i.isDigit => BigInt(i - '0'.toInt)
- case i if i >= 'a' && i <= 'f' => BigInt(i.toInt - 'a'.toInt + 10)
- case i if i >= 'A' && i <= 'F' => BigInt(i.toInt - 'A'.toInt + 10)
- case _ => return None
- }
- val res = access.tail.map(hexToInt)
- if(res.forall(p => p < typeSize))
- Some(res)
- else
- None
- case _ =>
- val xyzwToInt = (i: Char) => i match {
- case 'x' => BigInt(0)
- case 'y' => BigInt(1)
- case 'z' => BigInt(2)
- case 'w' => BigInt(3)
- case _ => return None
- }
- val res = access.map(xyzwToInt)
- if(res.forall(p => p < typeSize))
- Some(res)
- else
- None
- }
+ def openCLVectorAccessString[G](
+ access: String,
+ typeSize: BigInt,
+ ): Option[Seq[BigInt]] =
+ access match {
+ case "lo" if typeSize % 2 == 0 =>
+ Some(Seq.tabulate(typeSize.toInt / 2)(i => i))
+ case "hi" if typeSize % 2 == 0 =>
+ Some(Seq.tabulate(typeSize.toInt / 2)(i => i + typeSize / 2))
+ case "even" if typeSize % 2 == 0 =>
+ Some(Seq.tabulate(typeSize.toInt / 2)(i => 2 * i))
+ case "odd" if typeSize % 2 == 0 =>
+ Some(Seq.tabulate(typeSize.toInt / 2)(i => 2 * i + 1))
+ case s if s.head == 's' && s.tail.nonEmpty =>
+ val hexToInt =
+ (i: Char) =>
+ i match {
+ case i if i.isDigit => BigInt(i - '0'.toInt)
+ case i if i >= 'a' && i <= 'f' => BigInt(i.toInt - 'a'.toInt + 10)
+ case i if i >= 'A' && i <= 'F' => BigInt(i.toInt - 'A'.toInt + 10)
+ case _ => return None
+ }
+ val res = access.tail.map(hexToInt)
+ if (res.forall(p => p < typeSize))
+ Some(res)
+ else
+ None
+ case _ =>
+ val xyzwToInt =
+ (i: Char) =>
+ i match {
+ case 'x' => BigInt(0)
+ case 'y' => BigInt(1)
+ case 'z' => BigInt(2)
+ case 'w' => BigInt(3)
+ case _ => return None
+ }
+ val res = access.map(xyzwToInt)
+ if (res.forall(p => p < typeSize))
+ Some(res)
+ else
+ None
+ }
- def findDeref[G](obj: Expr[G], name: String, ctx: ReferenceResolutionContext[G], blame: Blame[BuiltinError]): Option[CDerefTarget[G]] =
+ def findDeref[G](
+ obj: Expr[G],
+ name: String,
+ ctx: ReferenceResolutionContext[G],
+ blame: Blame[BuiltinError],
+ ): Option[CDerefTarget[G]] =
(stripCPrimitiveType(obj.t) match {
- case t: TNotAValue[G] => t.decl.get match {
- case RefAxiomaticDataType(decl) => decl.decls.flatMap(Referrable.from).collectFirst {
- case ref: RefADTFunction[G] if ref.name == name => ref
+ case t: TNotAValue[G] =>
+ t.decl.get match {
+ case RefAxiomaticDataType(decl) =>
+ decl.decls.flatMap(Referrable.from).collectFirst {
+ case ref: RefADTFunction[G] if ref.name == name => ref
+ }
+ case RefCStruct(decl: CGlobalDeclaration[G]) =>
+ getCStructDeref(decl, name)
+ case _ => None
}
- case RefCStruct(decl: CGlobalDeclaration[G]) => getCStructDeref(decl, name)
- case _ => None
- }
- case struct: CTStruct[G] =>
- getCStructDeref(struct.ref.decl, name)
+ case struct: CTStruct[G] => getCStructDeref(struct.ref.decl, name)
case CTCudaVec() =>
- val ref = obj.asInstanceOf[CLocal[G]].ref.get.asInstanceOf[RefCudaVec[G]]
+ val ref = obj.asInstanceOf[CLocal[G]].ref.get
+ .asInstanceOf[RefCudaVec[G]]
name match {
case "x" => Some(RefCudaVecX(ref))
case "y" => Some(RefCudaVecY(ref))
@@ -271,14 +375,19 @@ case object C {
case _ => None
}).orElse(Spec.builtinField(obj, name, blame))
- def resolveInvocation[G](obj: Expr[G], ctx: ReferenceResolutionContext[G]): CInvocationTarget[G] =
+ def resolveInvocation[G](
+ obj: Expr[G],
+ ctx: ReferenceResolutionContext[G],
+ ): CInvocationTarget[G] =
obj.t match {
- case t: TNotAValue[G] => t.decl.get match {
- case target: CInvocationTarget[G] => target
- case _ => throw NotApplicable(obj)
- }
+ case t: TNotAValue[G] =>
+ t.decl.get match {
+ case target: CInvocationTarget[G] => target
+ case _ => throw NotApplicable(obj)
+ }
// OpenCL overloads vector literals as function invocations..
- case CPrimitiveType(CSpecificationType(v: TOpenCLVector[G]) +: _) => RefOpenCLVectorLiteralCInvocationTarget[G](v.size, v.innerType)
+ case CPrimitiveType(CSpecificationType(v: TOpenCLVector[G]) +: _) =>
+ RefOpenCLVectorLiteralCInvocationTarget[G](v.size, v.innerType)
case _ => throw NotApplicable(obj)
}
}
diff --git a/src/col/vct/col/resolve/lang/CPP.scala b/src/col/vct/col/resolve/lang/CPP.scala
index 2805d6ee71..515eb67262 100644
--- a/src/col/vct/col/resolve/lang/CPP.scala
+++ b/src/col/vct/col/resolve/lang/CPP.scala
@@ -40,51 +40,85 @@ case object CPP {
for (prefix <- NUMBER_LIKE_PREFIXES; t <- NUMBER_LIKE_TYPES)
yield prefix ++ t
- case class DeclaratorInfo[G](params: Option[Seq[CPPParam[G]]], typeOrReturnType: Type[G] => Type[G], name: String, isReference: Boolean = false)
+ case class DeclaratorInfo[G](
+ params: Option[Seq[CPPParam[G]]],
+ typeOrReturnType: Type[G] => Type[G],
+ name: String,
+ isReference: Boolean = false,
+ )
- def getDeclaratorInfo[G](decl: CPPDeclarator[G], isParam: Boolean = false): DeclaratorInfo[G] = decl match {
- case CPPAddressingDeclarator(operators, inner) =>
- val innerInfo = getDeclaratorInfo(inner)
- if (isParam && operators.size == 1 && operators.head.isInstanceOf[CPPReference[G]]) {
- // Pass by reference parameter, so & can be ignored
+ def getDeclaratorInfo[G](
+ decl: CPPDeclarator[G],
+ isParam: Boolean = false,
+ ): DeclaratorInfo[G] =
+ decl match {
+ case CPPAddressingDeclarator(operators, inner) =>
+ val innerInfo = getDeclaratorInfo(inner)
+ if (
+ isParam && operators.size == 1 &&
+ operators.head.isInstanceOf[CPPReference[G]]
+ ) {
+ // Pass by reference parameter, so & can be ignored
+ DeclaratorInfo(
+ innerInfo.params,
+ t => innerInfo.typeOrReturnType(t),
+ innerInfo.name,
+ isReference = true,
+ )
+ } else if (
+ operators.collectFirst({ case x: CPPReference[G] => x }).isDefined
+ ) {
+ // Do not support multiple &, or & later in the sequence
+ throw CPPTypeNotSupported(Some(decl))
+ } else {
+ DeclaratorInfo(
+ innerInfo.params,
+ t =>
+ innerInfo.typeOrReturnType(
+ FuncTools.repeat[Type[G]](TPointer(_), operators.size, t)
+ ),
+ innerInfo.name,
+ )
+ }
+ case array @ CPPArrayDeclarator(size, inner) =>
+ val innerInfo = getDeclaratorInfo(inner)
DeclaratorInfo(
innerInfo.params,
- t => innerInfo.typeOrReturnType(t),
+ t => innerInfo.typeOrReturnType(CPPTArray(size, t)(array.blame)),
innerInfo.name,
- isReference = true
)
- } else if (operators.collectFirst({ case x: CPPReference[G] => x }).isDefined) {
- // Do not support multiple &, or & later in the sequence
- throw CPPTypeNotSupported(Some(decl))
- } else {
+ case CPPTypedFunctionDeclarator(params, _, inner) =>
+ val innerInfo = getDeclaratorInfo(inner)
DeclaratorInfo(
- innerInfo.params,
- t => innerInfo.typeOrReturnType(FuncTools.repeat[Type[G]](TPointer(_), operators.size, t)),
- innerInfo.name)
- }
- case array@CPPArrayDeclarator(size, inner) =>
- val innerInfo = getDeclaratorInfo(inner)
- DeclaratorInfo(innerInfo.params, t => innerInfo.typeOrReturnType(CPPTArray(size, t)(array.blame)), innerInfo.name)
- case CPPTypedFunctionDeclarator(params, _, inner) =>
- val innerInfo = getDeclaratorInfo(inner)
- DeclaratorInfo(params = Some(params), typeOrReturnType = t => t, innerInfo.name)
- case CPPLambdaDeclarator(params) =>
- DeclaratorInfo(params = Some(params), typeOrReturnType = t => t, "")
- case CPPName(name) =>
- DeclaratorInfo(params = None, typeOrReturnType = t => t, name)
- }
+ params = Some(params),
+ typeOrReturnType = t => t,
+ innerInfo.name,
+ )
+ case CPPLambdaDeclarator(params) =>
+ DeclaratorInfo(params = Some(params), typeOrReturnType = t => t, "")
+ case CPPName(name) =>
+ DeclaratorInfo(params = None, typeOrReturnType = t => t, name)
+ }
- def getBaseTypeFromSpecs[G](specs: Seq[CPPDeclarationSpecifier[G]], context: Option[Node[G]] = None): Type[G] =
+ def getBaseTypeFromSpecs[G](
+ specs: Seq[CPPDeclarationSpecifier[G]],
+ context: Option[Node[G]] = None,
+ ): Type[G] =
specs.collect { case spec: CPPTypeSpecifier[G] => spec } match {
case Seq(CPPVoid()) => TVoid()
case Seq(CPPChar()) => TChar()
case t if CPP.NUMBER_LIKE_SPECIFIERS.contains(t) => TCInt()
- case Seq(CPPSpecificationType(t@TCFloat(_, _))) => t
+ case Seq(CPPSpecificationType(t @ TCFloat(_, _))) => t
case Seq(CPPBool()) => TBool()
case Seq(SYCLClassDefName("event", Seq())) => SYCLTEvent()
case Seq(SYCLClassDefName("handler", Seq())) => SYCLTHandler()
case Seq(SYCLClassDefName("queue", Seq())) => SYCLTQueue()
- case Seq(SYCLClassDefName(name, Seq(CPPExprOrTypeSpecifier(Some(CIntegerValue(dim)), None)))) =>
+ case Seq(
+ SYCLClassDefName(
+ name,
+ Seq(CPPExprOrTypeSpecifier(Some(CIntegerValue(dim)), None)),
+ )
+ ) =>
name match {
case "item" => SYCLTItem(dim.intValue)
case "nd_item" => SYCLTNDItem(dim.intValue)
@@ -92,7 +126,15 @@ case object CPP {
case "nd_range" => SYCLTNDRange(dim.intValue)
case _ => throw CPPTypeNotSupported(context)
}
- case Seq(SYCLClassDefName(name, Seq(CPPExprOrTypeSpecifier(None, Some(typ)), CPPExprOrTypeSpecifier(Some(CIntegerValue(dim)), None)))) =>
+ case Seq(
+ SYCLClassDefName(
+ name,
+ Seq(
+ CPPExprOrTypeSpecifier(None, Some(typ)),
+ CPPExprOrTypeSpecifier(Some(CIntegerValue(dim)), None),
+ ),
+ )
+ ) =>
val baseType = getBaseTypeFromSpecs(Seq(typ))
name match {
case "buffer" => SYCLTBuffer(baseType, dim.intValue)
@@ -100,31 +142,50 @@ case object CPP {
case "local_accessor" => SYCLTLocalAccessor(baseType, dim.intValue)
case _ => throw CPPTypeNotSupported(context)
}
- case Seq(SYCLClassDefName("accessor", Seq(CPPExprOrTypeSpecifier(None, Some(typ)), CPPExprOrTypeSpecifier(Some(CIntegerValue(dim)), None), CPPExprOrTypeSpecifier(None, Some(SYCLClassDefName(accessMode, Nil)))))) =>
+ case Seq(
+ SYCLClassDefName(
+ "accessor",
+ Seq(
+ CPPExprOrTypeSpecifier(None, Some(typ)),
+ CPPExprOrTypeSpecifier(Some(CIntegerValue(dim)), None),
+ CPPExprOrTypeSpecifier(
+ None,
+ Some(SYCLClassDefName(accessMode, Nil)),
+ ),
+ ),
+ )
+ ) =>
val baseType = getBaseTypeFromSpecs(Seq(typ))
accessMode match {
- case "access_mode::read_write" => SYCLTAccessor(baseType, dim.intValue)
- case "access_mode::read" => SYCLTAccessor(baseType, dim.intValue, readOnly = true)
+ case "access_mode::read_write" =>
+ SYCLTAccessor(baseType, dim.intValue)
+ case "access_mode::read" =>
+ SYCLTAccessor(baseType, dim.intValue, readOnly = true)
case _ => throw CPPTypeNotSupported(context)
}
case Seq(CPPTypedefName("VERCORS::LAMBDA", _)) => CPPTLambda()
- case Seq(defn@CPPTypedefName(_, _)) => Types.notAValue(defn.ref.get)
+ case Seq(defn @ CPPTypedefName(_, _)) => Types.notAValue(defn.ref.get)
case Seq(CPPSpecificationType(typ)) => typ
case spec +: _ => throw CPPTypeNotSupported(context.orElse(Some(spec)))
case _ => throw CPPTypeNotSupported(context)
}
- def unwrappedType[G](t: Type[G]): Type[G] = t match {
- case CPPPrimitiveType(specs) => getBaseTypeFromSpecs(specs)
- case _ => t
- }
+ def unwrappedType[G](t: Type[G]): Type[G] =
+ t match {
+ case CPPPrimitiveType(specs) => getBaseTypeFromSpecs(specs)
+ case _ => t
+ }
def nameFromDeclarator(declarator: CPPDeclarator[_]): String =
getDeclaratorInfo(declarator).name
- def typeOrReturnTypeFromDeclarator[G](specs: Seq[CPPDeclarationSpecifier[G]], decl: CPPDeclarator[G]): Type[G] = {
+ def typeOrReturnTypeFromDeclarator[G](
+ specs: Seq[CPPDeclarationSpecifier[G]],
+ decl: CPPDeclarator[G],
+ ): Type[G] = {
getDeclaratorInfo(decl).typeOrReturnType(CPPPrimitiveType(specs)) match {
- case CPPPrimitiveType(returnedSpecs) => getBaseTypeFromSpecs(returnedSpecs)
+ case CPPPrimitiveType(returnedSpecs) =>
+ getBaseTypeFromSpecs(returnedSpecs)
case x => x
}
@@ -133,18 +194,27 @@ case object CPP {
def paramsFromDeclarator[G](declarator: CPPDeclarator[G]): Seq[CPPParam[G]] =
getDeclaratorInfo(declarator).params.get
- def findCPPTypeName[G](name: String, ctx: TypeResolutionContext[G]): Option[CPPTypeNameTarget[G]] = name match {
- case "VERCORS::LAMBDA" | "VERCORS::ARRAY" => Some(RefCPPCustomType(name))
- case _ => ctx.stack.flatten.collectFirst {
- case target: CPPTypeNameTarget[G] if target.name == name => target
+ def findCPPTypeName[G](
+ name: String,
+ ctx: TypeResolutionContext[G],
+ ): Option[CPPTypeNameTarget[G]] =
+ name match {
+ case "VERCORS::LAMBDA" | "VERCORS::ARRAY" => Some(RefCPPCustomType(name))
+ case _ =>
+ ctx.stack.flatten.collectFirst {
+ case target: CPPTypeNameTarget[G] if target.name == name => target
+ }
}
- }
- def findCPPName[G](name: String, ctx: ReferenceResolutionContext[G]): Seq[CPPNameTarget[G]] = {
+ def findCPPName[G](
+ name: String,
+ ctx: ReferenceResolutionContext[G],
+ ): Seq[CPPNameTarget[G]] = {
val targets = ctx.stack.flatten.collect {
case target: CPPNameTarget[G] if target.name == name => target
}
- if (targets.nonEmpty) return targets
+ if (targets.nonEmpty)
+ return targets
name match {
case "sycl::read_write" => Seq(RefSYCLAccessMode(SYCLReadWriteAccess()))
@@ -152,94 +222,144 @@ case object CPP {
case "sycl::range" => Seq(RefSYCLConstructorDefinition(SYCLTRange()))
case "sycl::nd_range" => Seq(RefSYCLConstructorDefinition(SYCLTNDRange()))
case "sycl::buffer" => Seq(RefSYCLConstructorDefinition(SYCLTBuffer()))
- case "sycl::accessor" => Seq(RefSYCLConstructorDefinition(SYCLTAccessor()))
- case "sycl::local_accessor" => Seq(RefSYCLConstructorDefinition(SYCLTLocalAccessor()))
+ case "sycl::accessor" =>
+ Seq(RefSYCLConstructorDefinition(SYCLTAccessor()))
+ case "sycl::local_accessor" =>
+ Seq(RefSYCLConstructorDefinition(SYCLTLocalAccessor()))
case _ => Seq()
}
}
- def findDeref[G](obj: Expr[G], name: String, ctx: ReferenceResolutionContext[G], blame: Blame[BuiltinError]): Seq[CPPDerefTarget[G]] =
+ def findDeref[G](
+ obj: Expr[G],
+ name: String,
+ ctx: ReferenceResolutionContext[G],
+ blame: Blame[BuiltinError],
+ ): Seq[CPPDerefTarget[G]] =
CPP.unwrappedType(obj.t) match {
- case t: TNotAValue[G] => t.decl.get match {
- case RefAxiomaticDataType(decl) => decl.decls.flatMap(Referrable.from).collect {
- case ref: RefADTFunction[G] if ref.name == name => ref
+ case t: TNotAValue[G] =>
+ t.decl.get match {
+ case RefAxiomaticDataType(decl) =>
+ decl.decls.flatMap(Referrable.from).collect {
+ case ref: RefADTFunction[G] if ref.name == name => ref
+ }
+ case _ => Nil
}
- case _ => Nil
- }
- case t: SYCLTClass[G] => findCPPName(t.namespacePath + "::" + name, ctx).collect({
- case decl: CPPDerefTarget[G] if decl.isInstanceOf[CPPInvocationTarget[G]] => decl
- })
+ case t: SYCLTClass[G] =>
+ findCPPName(t.namespacePath + "::" + name, ctx).collect({
+ case decl: CPPDerefTarget[G]
+ if decl.isInstanceOf[CPPInvocationTarget[G]] =>
+ decl
+ })
case _ => Spec.builtinField(obj, name, blame).toSeq
}
- def findForwardDeclaration[G](declarator: CPPDeclarator[G], ctx: ReferenceResolutionContext[G]): Option[RefCPPGlobalDeclaration[G]] =
+ def findForwardDeclaration[G](
+ declarator: CPPDeclarator[G],
+ ctx: ReferenceResolutionContext[G],
+ ): Option[RefCPPGlobalDeclaration[G]] =
ctx.stack.flatten.collectFirst {
- case target: RefCPPGlobalDeclaration[G] if target.name == nameFromDeclarator(declarator) => target
+ case target: RefCPPGlobalDeclaration[G]
+ if target.name == nameFromDeclarator(declarator) =>
+ target
}
- def findDefinition[G](declarator: CPPDeclarator[G], ctx: ReferenceResolutionContext[G]): Option[RefCPPFunctionDefinition[G]] =
+ def findDefinition[G](
+ declarator: CPPDeclarator[G],
+ ctx: ReferenceResolutionContext[G],
+ ): Option[RefCPPFunctionDefinition[G]] =
ctx.stack.flatten.collectFirst {
- case target: RefCPPFunctionDefinition[G] if target.name == nameFromDeclarator(declarator) => target
+ case target: RefCPPFunctionDefinition[G]
+ if target.name == nameFromDeclarator(declarator) =>
+ target
}
- def getParamTypes[G](ref: CPPInvocationTarget[G]): Seq[Type[G]] = ref match {
- case globalDeclRef: RefCPPGlobalDeclaration[G] if globalDeclRef.decls.decl.inits.size == 1 =>
- paramsFromDeclarator(globalDeclRef.decls.decl.inits.head.decl).map(param => getBaseTypeFromSpecs(param.specifiers))
- case functionDeclRef: RefCPPFunctionDefinition[G] =>
- paramsFromDeclarator(functionDeclRef.decl.declarator).map(param => getBaseTypeFromSpecs(param.specifiers))
- case functionRef: RefFunction[G] => functionRef.decl.args.map(variable => variable.t)
- case procedureRef: RefProcedure[G] => procedureRef.decl.args.map(variable => variable.t)
- case predicateRef: RefPredicate[G] => predicateRef.decl.args.map(variable => variable.t)
- case instanceFunctionRef: RefInstanceFunction[G] => instanceFunctionRef.decl.args.map(variable => variable.t)
- case instanceMethodRef: RefInstanceMethod[G] => instanceMethodRef.decl.args.map(variable => variable.t)
- case instancePredicateRef: RefInstancePredicate[G] => instancePredicateRef.decl.args.map(variable => variable.t)
- case aDTFunctionRef: RefADTFunction[G] => aDTFunctionRef.decl.args.map(variable => variable.t)
- case modelProcessRef: RefModelProcess[G] => modelProcessRef.decl.args.map(variable => variable.t)
- case modelActionRef: RefModelAction[G] => modelActionRef.decl.args.map(variable => variable.t)
- case proverFunctionRef: RefProverFunction[G] => proverFunctionRef.decl.args.map(variable => variable.t)
- case _ => Seq()
- }
+ def getParamTypes[G](ref: CPPInvocationTarget[G]): Seq[Type[G]] =
+ ref match {
+ case globalDeclRef: RefCPPGlobalDeclaration[G]
+ if globalDeclRef.decls.decl.inits.size == 1 =>
+ paramsFromDeclarator(globalDeclRef.decls.decl.inits.head.decl)
+ .map(param => getBaseTypeFromSpecs(param.specifiers))
+ case functionDeclRef: RefCPPFunctionDefinition[G] =>
+ paramsFromDeclarator(functionDeclRef.decl.declarator)
+ .map(param => getBaseTypeFromSpecs(param.specifiers))
+ case functionRef: RefFunction[G] =>
+ functionRef.decl.args.map(variable => variable.t)
+ case procedureRef: RefProcedure[G] =>
+ procedureRef.decl.args.map(variable => variable.t)
+ case predicateRef: RefPredicate[G] =>
+ predicateRef.decl.args.map(variable => variable.t)
+ case instanceFunctionRef: RefInstanceFunction[G] =>
+ instanceFunctionRef.decl.args.map(variable => variable.t)
+ case instanceMethodRef: RefInstanceMethod[G] =>
+ instanceMethodRef.decl.args.map(variable => variable.t)
+ case instancePredicateRef: RefInstancePredicate[G] =>
+ instancePredicateRef.decl.args.map(variable => variable.t)
+ case aDTFunctionRef: RefADTFunction[G] =>
+ aDTFunctionRef.decl.args.map(variable => variable.t)
+ case modelProcessRef: RefModelProcess[G] =>
+ modelProcessRef.decl.args.map(variable => variable.t)
+ case modelActionRef: RefModelAction[G] =>
+ modelActionRef.decl.args.map(variable => variable.t)
+ case proverFunctionRef: RefProverFunction[G] =>
+ proverFunctionRef.decl.args.map(variable => variable.t)
+ case _ => Seq()
+ }
- def resolveInvocation[G](applicable: Expr[G], args: Seq[Expr[G]], ctx: ReferenceResolutionContext[G]): CPPInvocationTarget[G] =
+ def resolveInvocation[G](
+ applicable: Expr[G],
+ args: Seq[Expr[G]],
+ ctx: ReferenceResolutionContext[G],
+ ): CPPInvocationTarget[G] =
applicable.t match {
- case t: TNotAValue[G] => (t.decl.get, applicable) match {
- // Do not check arguments for BuiltinInstanceMethods as we do not know the argument types
- case (target: BuiltinInstanceMethod[G], _) => target
- // Resolve the SYCL constructor
- case (RefSYCLConstructorDefinition(typ), CPPLocal(_, genericArgs)) => typ.findConstructor(genericArgs, args) match {
- case Some(constructorRef) => constructorRef
- case None => throw NotApplicable(applicable)
+ case t: TNotAValue[G] =>
+ (t.decl.get, applicable) match {
+ // Do not check arguments for BuiltinInstanceMethods as we do not know the argument types
+ case (target: BuiltinInstanceMethod[G], _) => target
+ // Resolve the SYCL constructor
+ case (RefSYCLConstructorDefinition(typ), CPPLocal(_, genericArgs)) =>
+ typ.findConstructor(genericArgs, args) match {
+ case Some(constructorRef) => constructorRef
+ case None => throw NotApplicable(applicable)
+ }
+ // The previously found method is already the correct one
+ case (target: CPPInvocationTarget[G], _)
+ if Util.compatTypes(args, getParamTypes(target)) =>
+ target
+ case (_, local @ CPPLocal(name, genericArgs)) =>
+ // Currently linked method does not have correct params
+ // So find all declarations with correct name and see if there is
+ // an alternative whose parameters do match the arguments
+ val allDecls = findCPPName(name, ctx).collect({
+ case decl: CPPInvocationTarget[G] => decl
+ })
+ val foundMatch: CPPInvocationTarget[G] =
+ findAlternativeInvocationTarget(applicable, args, allDecls)
+ local.ref = Some(foundMatch.asInstanceOf[CPPNameTarget[G]])
+ t.decl = Some(foundMatch)
+ foundMatch
+ case (_, deref @ CPPClassMethodOrFieldAccess(classInstance, name)) =>
+ // Currently linked method does not have correct params
+ // So find all declarations with correct name and see if there is
+ // an alternative whose parameters do match the arguments
+ val allDecls = findDeref(classInstance, name, ctx, deref.blame)
+ .collect({ case target: CPPInvocationTarget[G] => target })
+ val foundMatch: CPPInvocationTarget[G] =
+ findAlternativeInvocationTarget(applicable, args, allDecls)
+ deref.ref = Some(foundMatch.asInstanceOf[CPPDerefTarget[G]])
+ t.decl = Some(foundMatch)
+ foundMatch
+ case _ => throw NotApplicable(applicable)
}
- // The previously found method is already the correct one
- case (target: CPPInvocationTarget[G], _) if Util.compatTypes(args, getParamTypes(target)) => target
- case (_, local@CPPLocal(name, genericArgs)) =>
- // Currently linked method does not have correct params
- // So find all declarations with correct name and see if there is
- // an alternative whose parameters do match the arguments
- val allDecls = findCPPName(name, ctx).collect({case decl: CPPInvocationTarget[G] => decl})
- val foundMatch: CPPInvocationTarget[G] = findAlternativeInvocationTarget(applicable, args, allDecls)
- local.ref = Some(foundMatch.asInstanceOf[CPPNameTarget[G]])
- t.decl = Some(foundMatch)
- foundMatch
- case (_, deref@CPPClassMethodOrFieldAccess(classInstance, name)) =>
- // Currently linked method does not have correct params
- // So find all declarations with correct name and see if there is
- // an alternative whose parameters do match the arguments
- val allDecls = findDeref(classInstance, name, ctx, deref.blame).collect({
- case target: CPPInvocationTarget[G] => target
- })
- val foundMatch: CPPInvocationTarget[G] = findAlternativeInvocationTarget(applicable, args, allDecls)
- deref.ref = Some(foundMatch.asInstanceOf[CPPDerefTarget[G]])
- t.decl = Some(foundMatch)
- foundMatch
- case _ => throw NotApplicable(applicable)
- }
case _ => throw NotApplicable(applicable)
}
- private def findAlternativeInvocationTarget[G](applicable: Expr[G], args: Seq[Expr[G]], decls: Seq[CPPInvocationTarget[G]]): CPPInvocationTarget[G] = {
- decls.find(
- value => Util.compatTypes(args, getParamTypes(value))
- ).getOrElse(throw NotApplicable(applicable))
+ private def findAlternativeInvocationTarget[G](
+ applicable: Expr[G],
+ args: Seq[Expr[G]],
+ decls: Seq[CPPInvocationTarget[G]],
+ ): CPPInvocationTarget[G] = {
+ decls.find(value => Util.compatTypes(args, getParamTypes(value)))
+ .getOrElse(throw NotApplicable(applicable))
}
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/resolve/lang/Java.scala b/src/col/vct/col/resolve/lang/Java.scala
index 7e66877936..b65ced5463 100644
--- a/src/col/vct/col/resolve/lang/Java.scala
+++ b/src/col/vct/col/resolve/lang/Java.scala
@@ -4,7 +4,69 @@ import com.typesafe.scalalogging.LazyLogging
import hre.util.FuncTools
import vct.col.ast.`type`.typeclass.TFloats
import vct.col.ast.lang.java.JavaAnnotationEx
-import vct.col.ast.{ApplicableContract, AxiomaticDataType, BipPortType, Block, EmptyProcess, Expr, JavaAnnotation, JavaAnnotationInterface, JavaClass, JavaClassDeclaration, JavaClassOrInterface, JavaConstructor, JavaFields, JavaFinal, JavaImport, JavaInterface, JavaMethod, JavaModifier, JavaName, JavaNamedType, JavaNamespace, JavaParam, JavaStatic, JavaTClass, JavaVariableDeclaration, JavaWildcard, LiteralBag, LiteralMap, LiteralSeq, LiteralSet, Node, Null, OptNone, TAnyClass, TArray, TBag, TBool, TChar, TClass, TEnum, TFloat, TInt, TMap, TModel, TNotAValue, TNull, TOption, TPointer, TProcess, TRational, TRef, TSeq, TSet, TString, TUnion, TVoid, TZFraction, Type, UnitAccountedPredicate, Variable, Void}
+import vct.col.ast.{
+ ApplicableContract,
+ AxiomaticDataType,
+ BipPortType,
+ Block,
+ EmptyProcess,
+ Expr,
+ JavaAnnotation,
+ JavaAnnotationInterface,
+ JavaClass,
+ JavaClassDeclaration,
+ JavaClassOrInterface,
+ JavaConstructor,
+ JavaFields,
+ JavaFinal,
+ JavaImport,
+ JavaInterface,
+ JavaMethod,
+ JavaModifier,
+ JavaName,
+ JavaNamedType,
+ JavaNamespace,
+ JavaParam,
+ JavaStatic,
+ JavaTClass,
+ JavaVariableDeclaration,
+ JavaWildcard,
+ LiteralBag,
+ LiteralMap,
+ LiteralSeq,
+ LiteralSet,
+ Node,
+ Null,
+ OptNone,
+ TAnyClass,
+ TArray,
+ TBag,
+ TBool,
+ TChar,
+ TClass,
+ TEnum,
+ TFloat,
+ TInt,
+ TMap,
+ TModel,
+ TNotAValue,
+ TNull,
+ TOption,
+ TPointer,
+ TProcess,
+ TRational,
+ TRef,
+ TSeq,
+ TSet,
+ TString,
+ TUnion,
+ TVoid,
+ TZFraction,
+ Type,
+ UnitAccountedPredicate,
+ Variable,
+ Void,
+}
import vct.col.origin._
import vct.col.ref.Ref
import vct.col.resolve.Resolve.{getLit, isBip}
@@ -23,15 +85,24 @@ import scala.collection.mutable
import scala.reflect.ClassTag
case object Java extends LazyLogging {
- case class UnexpectedJreDefinition(expectedKind: String, fullyQualifiedName: Seq[String]) extends UserError {
- override def text: String = s"Did not get a $expectedKind when resolving $fullyQualifiedName"
+ case class UnexpectedJreDefinition(
+ expectedKind: String,
+ fullyQualifiedName: Seq[String],
+ ) extends UserError {
+ override def text: String =
+ s"Did not get a $expectedKind when resolving $fullyQualifiedName"
override def code: String = "unexpectedJreDefinition"
}
object JRESource extends Source {
- override def positionContext(position: PositionRange): String = genericContext
- override def inlinePositionContext(position: PositionRange, compress: Boolean): String = genericInlineContext
- override protected def genericContext: String = "At node loaded reflectively from the JRE"
+ override def positionContext(position: PositionRange): String =
+ genericContext
+ override def inlinePositionContext(
+ position: PositionRange,
+ compress: Boolean,
+ ): String = genericInlineContext
+ override protected def genericContext: String =
+ "At node loaded reflectively from the JRE"
override protected def genericInlineContext: String = "JRE"
override def genericShortPosition: String = "JRE"
}
@@ -39,30 +110,47 @@ case object Java extends LazyLogging {
private def JavaSystemOrigin(): Origin = Origin(Seq(JRESource))
private implicit val o: Origin = DiagnosticOrigin
- def JAVA_LANG_OBJECT[G]: JavaNamedType[G] = JavaNamedType(Seq(("java", None), ("lang", None), ("Object", None)))
- def JAVA_LANG_ANNOTATION_ANNOTATION[G]: JavaNamedType[G] = JavaNamedType(Seq(("java", None), ("lang", None), ("annotation", None), ("Annotation", None)))
- def JAVA_LANG_STRING_TYPE[G]: JavaNamedType[G] = JavaNamedType(Seq(("java", None), ("lang", None), ("String", None)))
+ def JAVA_LANG_OBJECT[G]: JavaNamedType[G] =
+ JavaNamedType(Seq(("java", None), ("lang", None), ("Object", None)))
+ def JAVA_LANG_ANNOTATION_ANNOTATION[G]: JavaNamedType[G] =
+ JavaNamedType(Seq(
+ ("java", None),
+ ("lang", None),
+ ("annotation", None),
+ ("Annotation", None),
+ ))
+ def JAVA_LANG_STRING_TYPE[G]: JavaNamedType[G] =
+ JavaNamedType(Seq(("java", None), ("lang", None), ("String", None)))
def JAVA_LANG_STRING_NAME[G]: JavaName[G] = JavaName(JAVA_LANG_STRING)
def JAVA_LANG_CLASS: Seq[String] = JAVA_LANG :+ "Class"
def JAVA_LANG_STRING: Seq[String] = JAVA_LANG :+ "String"
def JAVA_LANG: Seq[String] = Seq("java", "lang")
implicit class ModifiersHelpers[G](modifiers: Seq[JavaModifier[G]]) {
- def all[T <: JavaModifier[G]](implicit tag: ClassTag[T]): Seq[T] = modifiers.collect { case t: T => t }
- def first[T <: JavaModifier[G]](implicit tag: ClassTag[T]): Option[T] = modifiers.collectFirst { case t: T => t }
- def is[T <: JavaModifier[G]](implicit tag: ClassTag[T]): Boolean = first[T].nonEmpty
- def isNot[T <: JavaModifier[G]](implicit tag: ClassTag[T]): Boolean = first[T].isEmpty
+ def all[T <: JavaModifier[G]](implicit tag: ClassTag[T]): Seq[T] =
+ modifiers.collect { case t: T => t }
+ def first[T <: JavaModifier[G]](implicit tag: ClassTag[T]): Option[T] =
+ modifiers.collectFirst { case t: T => t }
+ def is[T <: JavaModifier[G]](implicit tag: ClassTag[T]): Boolean =
+ first[T].nonEmpty
+ def isNot[T <: JavaModifier[G]](implicit tag: ClassTag[T]): Boolean =
+ first[T].isEmpty
}
- def findLoadedJavaTypeName[G](potentialFQName: Seq[String], ctx: TypeResolutionContext[G]): Option[JavaTypeNameTarget[G]] = {
- (ctx.stack.lastOption.getOrElse(Seq()) ++ ctx.externallyLoadedElements.flatMap(Referrable.from)).foreach {
+ def findLoadedJavaTypeName[G](
+ potentialFQName: Seq[String],
+ ctx: TypeResolutionContext[G],
+ ): Option[JavaTypeNameTarget[G]] = {
+ (ctx.stack.lastOption.getOrElse(Seq()) ++
+ ctx.externallyLoadedElements.flatMap(Referrable.from)).foreach {
case RefJavaNamespace(ns: JavaNamespace[G]) =>
- for(decl <- ns.declarations) {
+ for (decl <- ns.declarations) {
Referrable.from(decl).foreach {
case target: JavaTypeNameTarget[G] =>
- if(ns.pkg.map(_.names).getOrElse(Nil) :+ target.name == potentialFQName) {
- return Some(target)
- }
+ if (
+ ns.pkg.map(_.names).getOrElse(Nil) :+ target.name ==
+ potentialFQName
+ ) { return Some(target) }
case _ =>
}
}
@@ -72,15 +160,21 @@ case object Java extends LazyLogging {
None
}
- def findLoadedJavaTypeNamesInPackage[G](pkg: Seq[String], ctx: TypeResolutionContext[G]): Seq[JavaTypeNameTarget[G]] =
- (ctx.stack.last ++ ctx.externallyLoadedElements.flatMap(Referrable.from)).collect {
- case RefJavaNamespace(ns: JavaNamespace[G]) if ns.pkg.map(_.names).getOrElse(Nil) == pkg =>
- ns.declarations.flatMap(Referrable.from(_)).collect {
- case target: JavaTypeNameTarget[G] => target
- }
- }.flatten
+ def findLoadedJavaTypeNamesInPackage[G](
+ pkg: Seq[String],
+ ctx: TypeResolutionContext[G],
+ ): Seq[JavaTypeNameTarget[G]] =
+ (ctx.stack.last ++ ctx.externallyLoadedElements.flatMap(Referrable.from))
+ .collect {
+ case RefJavaNamespace(ns: JavaNamespace[G])
+ if ns.pkg.map(_.names).getOrElse(Nil) == pkg =>
+ ns.declarations.flatMap(Referrable.from(_)).collect {
+ case target: JavaTypeNameTarget[G] => target
+ }
+ }.flatten
- private val currentlyLoading = mutable.Map[Seq[String], mutable.ArrayBuffer[JavaNamedType[_ <: Any]]]()
+ private val currentlyLoading = mutable
+ .Map[Seq[String], mutable.ArrayBuffer[JavaNamedType[_ <: Any]]]()
def lazyType[G](t: reflect.Type, ctx: TypeResolutionContext[G]): Type[G] =
t match {
@@ -88,7 +182,12 @@ case object Java extends LazyLogging {
// Blatantly assume generic types are always classes applied to some type arguments
val name = t.getRawType.asInstanceOf[Class[_]].getName
// TODO: DiagnosticOrigin makes no sense here
- lazyType(name, t.getActualTypeArguments.map(translateRuntimeType(_)(DiagnosticOrigin, ctx)).toIndexedSeq, ctx)
+ lazyType(
+ name,
+ t.getActualTypeArguments
+ .map(translateRuntimeType(_)(DiagnosticOrigin, ctx)).toIndexedSeq,
+ ctx,
+ )
case t: java.lang.Class[_] =>
val name = t.getName
lazyType(name, Seq(), ctx)
@@ -98,29 +197,47 @@ case object Java extends LazyLogging {
throw Unreachable(???)
}
- def lazyType[G](name: String, typeArgs: Seq[Type[G]], ctx: TypeResolutionContext[G]): Type[G] =
- lazyType(name.split('.').toIndexedSeq, typeArgs, ctx)
-
- def lazyType[G](name: Seq[String], typeArgs: Seq[Type[G]], ctx: TypeResolutionContext[G]): Type[G] = {
- val result = JavaNamedType[G](name.init.map((_, None)) :+ (name.last, Some(typeArgs)))
+ def lazyType[G](
+ name: String,
+ typeArgs: Seq[Type[G]],
+ ctx: TypeResolutionContext[G],
+ ): Type[G] = lazyType(name.split('.').toIndexedSeq, typeArgs, ctx)
+
+ def lazyType[G](
+ name: Seq[String],
+ typeArgs: Seq[Type[G]],
+ ctx: TypeResolutionContext[G],
+ ): Type[G] = {
+ val result = JavaNamedType[G](
+ name.init.map((_, None)) :+ (name.last, Some(typeArgs))
+ )
currentlyLoading.get(name) match {
case Some(lazyQueue) => lazyQueue += result
- case None => result.ref = Some(findJavaTypeName(name, ctx).getOrElse(
- throw Unreachable(s"Invalid JRE: The type `${name.mkString(".")}` built in to the JRE could not be loaded.")))
+ case None =>
+ result.ref = Some(findJavaTypeName(name, ctx).getOrElse(
+ throw Unreachable(
+ s"Invalid JRE: The type `${name.mkString(".")}` built in to the JRE could not be loaded."
+ )
+ ))
}
result
}
- def findRuntimeJavaType[G](potentialFQName: Seq[String], ctx: TypeResolutionContext[G]): Option[JavaClassOrInterface[G]] = {
- if(currentlyLoading.contains(potentialFQName))
+ def findRuntimeJavaType[G](
+ potentialFQName: Seq[String],
+ ctx: TypeResolutionContext[G],
+ ): Option[JavaClassOrInterface[G]] = {
+ if (currentlyLoading.contains(potentialFQName))
throw Unreachable("Aborting cyclic loading of classes from Java runtime")
implicit val o: Origin = JavaSystemOrigin()
currentlyLoading(potentialFQName) = mutable.ArrayBuffer()
- logger.warn(s"Attempting to load a shim of ${potentialFQName.mkString(".")} via reflection.")
+ logger.warn(
+ s"Attempting to load a shim of ${potentialFQName.mkString(".")} via reflection."
+ )
try {
val classLoader = this.getClass.getClassLoader
@@ -128,13 +245,21 @@ case object Java extends LazyLogging {
val colClass = translateRuntimeClass(cls)(o, ctx)
- ctx.externallyLoadedElements += new JavaNamespace(Some(JavaName(potentialFQName.init)), Nil, Seq(colClass))
+ ctx.externallyLoadedElements += new JavaNamespace(
+ Some(JavaName(potentialFQName.init)),
+ Nil,
+ Seq(colClass),
+ )
- for(t <- currentlyLoading.remove(potentialFQName).get) {
- ((t : JavaNamedType[_]).unsafeTransmuteGeneration[JavaNamedType, G] : JavaNamedType[G]).ref = Some(RefJavaClass(colClass))
+ for (t <- currentlyLoading.remove(potentialFQName).get) {
+ ((t: JavaNamedType[_])
+ .unsafeTransmuteGeneration[JavaNamedType, G]: JavaNamedType[G]).ref =
+ Some(RefJavaClass(colClass))
}
- logger.warn(s"No specification was found for class ${potentialFQName.mkString(".")}, so a shim was loaded from the JRE.")
+ logger.warn(
+ s"No specification was found for class ${potentialFQName.mkString(".")}, so a shim was loaded from the JRE."
+ )
Some(colClass)
} catch {
@@ -144,40 +269,63 @@ case object Java extends LazyLogging {
}
}
- def findRuntimeJavaTypesInPackage[G](pkg: Seq[String], ctx: TypeResolutionContext[G]): Seq[JavaClassOrInterface[G]] = {
+ def findRuntimeJavaTypesInPackage[G](
+ pkg: Seq[String],
+ ctx: TypeResolutionContext[G],
+ ): Seq[JavaClassOrInterface[G]] = {
// TODO...
Nil
}
- def translateRuntimeType[G](t: reflect.Type)(implicit o: Origin, ctx: TypeResolutionContext[G]): Type[G] = t match {
- case java.lang.Boolean.TYPE => TBool()
- case java.lang.Character.TYPE => TChar()
- case java.lang.Byte.TYPE => TInt()
- case java.lang.Short.TYPE => TInt()
- case java.lang.Integer.TYPE => TInt()
- case java.lang.Long.TYPE => TInt()
- case java.lang.Float.TYPE => float
- case java.lang.Double.TYPE => double
- case java.lang.Void.TYPE => TVoid()
- case arr: reflect.GenericArrayType => TArray(translateRuntimeType(arr.getGenericComponentType))
- case t: reflect.WildcardType => JavaWildcard()
- case t: reflect.Type => lazyType(t, ctx)
- }
+ def translateRuntimeType[G](
+ t: reflect.Type
+ )(implicit o: Origin, ctx: TypeResolutionContext[G]): Type[G] =
+ t match {
+ case java.lang.Boolean.TYPE => TBool()
+ case java.lang.Character.TYPE => TChar()
+ case java.lang.Byte.TYPE => TInt()
+ case java.lang.Short.TYPE => TInt()
+ case java.lang.Integer.TYPE => TInt()
+ case java.lang.Long.TYPE => TInt()
+ case java.lang.Float.TYPE => float
+ case java.lang.Double.TYPE => double
+ case java.lang.Void.TYPE => TVoid()
+ case arr: reflect.GenericArrayType =>
+ TArray(translateRuntimeType(arr.getGenericComponentType))
+ case t: reflect.WildcardType => JavaWildcard()
+ case t: reflect.Type => lazyType(t, ctx)
+ }
- def translateRuntimeParameter[G](param: Parameter, t: reflect.Type)(implicit o: Origin, ctx: TypeResolutionContext[G]): JavaParam[G] = {
- new JavaParam(Seq(), param.getName, translateRuntimeType(t))(o.where(name = param.getName))
+ def translateRuntimeParameter[G](
+ param: Parameter,
+ t: reflect.Type,
+ )(implicit o: Origin, ctx: TypeResolutionContext[G]): JavaParam[G] = {
+ new JavaParam(Seq(), param.getName, translateRuntimeType(t))(
+ o.where(name = param.getName)
+ )
}
- def translateTypeParameter[G](param: TypeVariable[_])(implicit o: Origin, ctx: TypeResolutionContext[G]): Variable[G] = {
+ def translateTypeParameter[G](
+ param: TypeVariable[_]
+ )(implicit o: Origin, ctx: TypeResolutionContext[G]): Variable[G] = {
// Guess that bound 0 is the one we want
- val bound = param.getBounds()(0) match {
- case cls: Class[_] => JavaTClass(translateRuntimeClass(cls).ref[JavaClassOrInterface[G]], Seq()) // Pretty sure the seq is not always empty here
- case typeVar: TypeVariable[_] => ??? // We need some extra state here to find where this type var comes from
- }
+ val bound =
+ param.getBounds()(0) match {
+ case cls: Class[_] =>
+ JavaTClass(
+ translateRuntimeClass(cls).ref[JavaClassOrInterface[G]],
+ Seq(),
+ ) // Pretty sure the seq is not always empty here
+ case typeVar: TypeVariable[_] =>
+ ??? // We need some extra state here to find where this type var comes from
+ }
new Variable(bound)(o.where(name = param.getName))
}
- def translateRuntimeClass[G](cls: Class[_])(implicit o: Origin, ctx: TypeResolutionContext[G]): JavaClassOrInterface[G] = {
+ def translateRuntimeClass[G](cls: Class[_])(
+ implicit o: Origin,
+ ctx: TypeResolutionContext[G],
+ ): JavaClassOrInterface[G] = {
val cons = cls.getConstructors.map(cons => {
new JavaConstructor(
modifiers = Nil,
@@ -185,58 +333,94 @@ case object Java extends LazyLogging {
parameters = {
val params = cons.getParameters.toIndexedSeq
val types = cons.getGenericParameterTypes.toIndexedSeq
- params.zip(types).map { case (p, t) => translateRuntimeParameter[G](p, t) }
+ params.zip(types).map { case (p, t) =>
+ translateRuntimeParameter[G](p, t)
+ }
},
typeParameters = Nil,
signals = Nil,
body = Block(Nil),
- contract = ApplicableContract(UnitAccountedPredicate(tt), UnitAccountedPredicate(tt), tt, Nil, Nil, Nil, None)(TrueSatisfiable),
+ contract =
+ ApplicableContract(
+ UnitAccountedPredicate(tt),
+ UnitAccountedPredicate(tt),
+ tt,
+ Nil,
+ Nil,
+ Nil,
+ None,
+ )(TrueSatisfiable),
)(o.where(name = cls.getSimpleName))
})
val methods = cls.getMethods.map(method => {
new JavaMethod(
- modifiers = if((method.getModifiers & Modifier.STATIC) != 0) Seq(JavaStatic[G]()) else Nil,
+ modifiers =
+ if ((method.getModifiers & Modifier.STATIC) != 0)
+ Seq(JavaStatic[G]())
+ else
+ Nil,
returnType = translateRuntimeType(method.getGenericReturnType),
dims = 0,
name = method.getName,
parameters = {
val params = method.getParameters.toIndexedSeq
val types = method.getGenericParameterTypes.toIndexedSeq
- params.zip(types).map { case (p, t) => translateRuntimeParameter[G](p, t) }
+ params.zip(types).map { case (p, t) =>
+ translateRuntimeParameter[G](p, t)
+ }
},
typeParameters = Nil,
signals = Nil,
body = None,
- contract = ApplicableContract(UnitAccountedPredicate(tt), UnitAccountedPredicate(tt), tt, Nil, Nil, Nil, None)(TrueSatisfiable),
+ contract =
+ ApplicableContract(
+ UnitAccountedPredicate(tt),
+ UnitAccountedPredicate(tt),
+ tt,
+ Nil,
+ Nil,
+ Nil,
+ None,
+ )(TrueSatisfiable),
)(AbstractApplicable)(o.where(name = method.getName))
})
val fields = cls.getFields.map(field => {
new JavaFields(
modifiers =
- (if((field.getModifiers & Modifier.STATIC) != 0) Seq(JavaStatic[G]()) else Nil) ++
- (if((field.getModifiers & Modifier.FINAL) != 0) Seq(JavaFinal[G]()) else Nil),
+ (if ((field.getModifiers & Modifier.STATIC) != 0)
+ Seq(JavaStatic[G]())
+ else
+ Nil) ++
+ (if ((field.getModifiers & Modifier.FINAL) != 0)
+ Seq(JavaFinal[G]())
+ else
+ Nil),
t = translateRuntimeType(field.getType),
decls = Seq(JavaVariableDeclaration[G](field.getName, 0, None)),
)
})
- val typeParameters = cls.getTypeParameters.map(translateTypeParameter(_)(o, ctx))
+ val typeParameters = cls.getTypeParameters
+ .map(translateTypeParameter(_)(o, ctx))
- if(cls.isAnnotation) {
+ if (cls.isAnnotation) {
new JavaAnnotationInterface[G](
name = cls.getName.split('.').last,
modifiers = Nil,
- ext = cls.getGenericInterfaces.toIndexedSeq.map(cls => lazyType(cls, ctx))(0),
+ ext =
+ cls.getGenericInterfaces.toIndexedSeq
+ .map(cls => lazyType(cls, ctx))(0),
decls = fields.toIndexedSeq ++ cons.toIndexedSeq ++ methods.toIndexedSeq,
)(o.where(name = cls.getName.split('.').last))
- } else if(cls.isInterface) {
+ } else if (cls.isInterface) {
new JavaInterface[G](
name = cls.getName.split('.').last,
modifiers = Nil,
typeParams = typeParameters,
- ext = cls.getGenericInterfaces.toIndexedSeq.map(cls => lazyType(cls, ctx)),
+ ext = cls.getGenericInterfaces.toIndexedSeq
+ .map(cls => lazyType(cls, ctx)),
decls = fields.toIndexedSeq ++ cons.toIndexedSeq ++ methods.toIndexedSeq,
)(o.where(name = cls.getName.split('.').last))
} else {
@@ -245,120 +429,172 @@ case object Java extends LazyLogging {
modifiers = Nil,
typeParams = typeParameters,
intrinsicLockInvariant = `tt`,
- ext = Option(cls.getGenericSuperclass).map(cls => lazyType(cls, ctx)).getOrElse(JAVA_LANG_OBJECT),
- imp = cls.getGenericInterfaces.toIndexedSeq.map(cls => lazyType(cls, ctx)),
+ ext = Option(cls.getGenericSuperclass).map(cls => lazyType(cls, ctx))
+ .getOrElse(JAVA_LANG_OBJECT),
+ imp = cls.getGenericInterfaces.toIndexedSeq
+ .map(cls => lazyType(cls, ctx)),
decls = fields.toIndexedSeq ++ cons.toIndexedSeq ++ methods.toIndexedSeq,
)(o.where(name = cls.getName.split('.').last))
}
}
- /**
- * Attempt to find a class by its fully qualified name.
- * @param name Fully qualified name of the class
- * @param ctx Queried for the external class loader, and the source class paths
- */
- def findLibraryJavaType[G](name: Seq[String], ctx: TypeResolutionContext[G]): Option[JavaTypeNameTarget[G]] =
+ /** Attempt to find a class by its fully qualified name.
+ * @param name
+ * Fully qualified name of the class
+ * @param ctx
+ * Queried for the external class loader, and the source class paths
+ */
+ def findLibraryJavaType[G](
+ name: Seq[String],
+ ctx: TypeResolutionContext[G],
+ ): Option[JavaTypeNameTarget[G]] =
ctx.externalJavaLoader.flatMap { loader =>
- FuncTools.firstOption(ctx.javaClassPath, (classPath: ResolveTypes.JavaClassPathEntry) => {
- // We have an external class loader and a class path.
- val maybeBasePath: Option[Path] = classPath match {
- case JavaClassPathEntry.SourcePackageRoot =>
- // Try to derive the base path, by the path of the current source file and the package.
- // E.g. /root/pkg/a/Cls.java declaring package pkg.a; -> /root
- for {
- ns <- ctx.namespace
- readableOrigin <- ns.o.find[ReadableOrigin]
- readable <- Some(readableOrigin.readable)
- file <- readable.underlyingPath
- baseFile <- ns.pkg.getOrElse(JavaName(Nil)).names.foldRight[Option[Path]](Option(file.getParent)) {
- case (name, Some(file)) if file.getFileName.toString == name => Option(file.getParent)
- case _ => None
- }
- } yield baseFile
- case JavaClassPathEntry.Path(root) => Some(root)
- }
-
- for {
- basePath <- maybeBasePath
- ns <- loader.load[G](basePath, name)
- cls <- ns.declarations.flatMap(Referrable.from).collectFirst {
- case ref: JavaTypeNameTarget[G] if ref.name == name.last =>
- ctx.externallyLoadedElements += ns
- ResolveTypes.resolve(ns, ctx)
- ref
- }
- } yield cls
- })
+ FuncTools.firstOption(
+ ctx.javaClassPath,
+ (classPath: ResolveTypes.JavaClassPathEntry) => {
+ // We have an external class loader and a class path.
+ val maybeBasePath: Option[Path] =
+ classPath match {
+ case JavaClassPathEntry.SourcePackageRoot =>
+ // Try to derive the base path, by the path of the current source file and the package.
+ // E.g. /root/pkg/a/Cls.java declaring package pkg.a; -> /root
+ for {
+ ns <- ctx.namespace
+ readableOrigin <- ns.o.find[ReadableOrigin]
+ readable <- Some(readableOrigin.readable)
+ file <- readable.underlyingPath
+ baseFile <-
+ ns.pkg.getOrElse(JavaName(Nil)).names
+ .foldRight[Option[Path]](Option(file.getParent)) {
+ case (name, Some(file))
+ if file.getFileName.toString == name =>
+ Option(file.getParent)
+ case _ => None
+ }
+ } yield baseFile
+ case JavaClassPathEntry.Path(root) => Some(root)
+ }
+
+ for {
+ basePath <- maybeBasePath
+ ns <- loader.load[G](basePath, name)
+ cls <- ns.declarations.flatMap(Referrable.from).collectFirst {
+ case ref: JavaTypeNameTarget[G] if ref.name == name.last =>
+ ctx.externallyLoadedElements += ns
+ ResolveTypes.resolve(ns, ctx)
+ ref
+ }
+ } yield cls
+ },
+ )
}
- def findJavaTypeName[G](names: Seq[String], ctx: TypeResolutionContext[G]): Option[JavaTypeNameTarget[G]] = {
- val potentialFQNames: Seq[Seq[String]] = names match {
- case Seq(singleName) =>
- val inThisPackage = ctx.namespace match {
- case Some(ns) => ns.pkg match {
- case Some(pkg) => pkg.names :+ singleName
- case None => Seq(singleName)
- }
- case None => Nil
- }
- val fromImport = ctx.namespace match {
- case Some(ns) => ns.imports.collect {
- case JavaImport(false, name, /*star = */ true) => name.names :+ singleName
- case JavaImport(false, name, /*star = */ false) if name.names.last == singleName => name.names
- }
- case None => Nil
- }
- val fromPredef = Seq("java", "lang", singleName)
- fromImport :+ inThisPackage :+ fromPredef
- case moreNames => Seq(moreNames)
- }
+ def findJavaTypeName[G](
+ names: Seq[String],
+ ctx: TypeResolutionContext[G],
+ ): Option[JavaTypeNameTarget[G]] = {
+ val potentialFQNames: Seq[Seq[String]] =
+ names match {
+ case Seq(singleName) =>
+ val inThisPackage =
+ ctx.namespace match {
+ case Some(ns) =>
+ ns.pkg match {
+ case Some(pkg) => pkg.names :+ singleName
+ case None => Seq(singleName)
+ }
+ case None => Nil
+ }
+ val fromImport =
+ ctx.namespace match {
+ case Some(ns) =>
+ ns.imports.collect {
+ case JavaImport(false, name, /*star = */ true) =>
+ name.names :+ singleName
+ case JavaImport(false, name, /*star = */ false)
+ if name.names.last == singleName =>
+ name.names
+ }
+ case None => Nil
+ }
+ val fromPredef = Seq("java", "lang", singleName)
+ fromImport :+ inThisPackage :+ fromPredef
+ case moreNames => Seq(moreNames)
+ }
FuncTools.firstOption(potentialFQNames, findJavaTypeInStack[G](_, ctx))
- .orElse(FuncTools.firstOption(potentialFQNames, findLoadedJavaTypeName[G](_, ctx)))
- .orElse(FuncTools.firstOption(potentialFQNames, findLibraryJavaType[G](_, ctx)))
- .orElse(FuncTools.firstOption(potentialFQNames, findRuntimeJavaType[G](_, ctx)).map(RefJavaClass[G]))
+ .orElse(FuncTools.firstOption(
+ potentialFQNames,
+ findLoadedJavaTypeName[G](_, ctx),
+ )).orElse(FuncTools.firstOption(
+ potentialFQNames,
+ findLibraryJavaType[G](_, ctx),
+ )).orElse(
+ FuncTools.firstOption(potentialFQNames, findRuntimeJavaType[G](_, ctx))
+ .map(RefJavaClass[G])
+ )
}
-
- def findJavaTypeInStack[G](name: Seq[String], ctx: TypeResolutionContext[G]): Option[JavaTypeNameTarget[G]] = {
- ctx.stack.flatten.collectFirst{
- case ref: JavaTypeNameTarget[G] if Seq(ref.name) == name => ref
- }
+ def findJavaTypeInStack[G](
+ name: Seq[String],
+ ctx: TypeResolutionContext[G],
+ ): Option[JavaTypeNameTarget[G]] = {
+ ctx.stack.flatten.collectFirst {
+ case ref: JavaTypeNameTarget[G] if Seq(ref.name) == name => ref
+ }
}
- def allowedFromStaticContext[G](target: JavaNameTarget[G]): Boolean = target match {
- case RefAxiomaticDataType(_) => true
- case RefClass(_) => true // PB: except maybe in non-static inner classes?
- case RefEnum(_) => true
- case RefEnumConstant(_, _) => true
- case RefJavaClass(decl) => true
- case RefUnloadedJavaNamespace(names) => true
-
- case RefJavaField(decls, _) => decls.modifiers.is[JavaStatic[G]]
- case RefModelField(_) => false
- case RefJavaBipGuard(_) => false
-
- case RefVariable(_) => true
- case RefJavaLocalDeclaration(_, _) => true
- case RefJavaParam(_) => true
- }
+ def allowedFromStaticContext[G](target: JavaNameTarget[G]): Boolean =
+ target match {
+ case RefAxiomaticDataType(_) => true
+ case RefClass(_) => true // PB: except maybe in non-static inner classes?
+ case RefEnum(_) => true
+ case RefEnumConstant(_, _) => true
+ case RefJavaClass(decl) => true
+ case RefUnloadedJavaNamespace(names) => true
+
+ case RefJavaField(decls, _) => decls.modifiers.is[JavaStatic[G]]
+ case RefModelField(_) => false
+ case RefJavaBipGuard(_) => false
+
+ case RefVariable(_) => true
+ case RefJavaLocalDeclaration(_, _) => true
+ case RefJavaParam(_) => true
+ }
- def findJavaName[G](name: String, fromStaticContext: Boolean, ctx: TypeResolutionContext[G]): Option[JavaNameTarget[G]] = {
+ def findJavaName[G](
+ name: String,
+ fromStaticContext: Boolean,
+ ctx: TypeResolutionContext[G],
+ ): Option[JavaNameTarget[G]] = {
ctx.stack.flatten.collectFirst {
- case target: JavaNameTarget[G] if target.name == name && (!fromStaticContext || allowedFromStaticContext(target)) => target
+ case target: JavaNameTarget[G]
+ if target.name == name &&
+ (!fromStaticContext || allowedFromStaticContext(target)) =>
+ target
}.orElse(ctx.namespace.flatMap(ns => {
// PB: I optionified this, but not entirely sure what the intention is here.
- def classOrEnum(target: JavaTypeNameTarget[G]): Option[JavaNameTarget[G]] = target match {
- case r @ RefJavaClass(_) => Some(r)
- case r @ RefEnum(_) => Some(r)
- case _ => None
- }
- val potentialRefs: Seq[JavaNameTarget[G]] = ns.imports.collect {
- case JavaImport(/* static = */ false, JavaName(fqn), /* star = */ false) if fqn.last == name =>
- findJavaTypeName(fqn, ctx).flatMap(classOrEnum)
- case JavaImport(/* static = */ false, JavaName(pkg), /* star = */ true) =>
- findJavaTypeName(pkg :+ name, ctx).flatMap(classOrEnum)
- }.flatten
+ def classOrEnum(
+ target: JavaTypeNameTarget[G]
+ ): Option[JavaNameTarget[G]] =
+ target match {
+ case r @ RefJavaClass(_) => Some(r)
+ case r @ RefEnum(_) => Some(r)
+ case _ => None
+ }
+ val potentialRefs: Seq[JavaNameTarget[G]] =
+ ns.imports.collect {
+ case JavaImport(
+ /* static = */ false,
+ JavaName(fqn), /* star = */ false,
+ ) if fqn.last == name =>
+ findJavaTypeName(fqn, ctx).flatMap(classOrEnum)
+ case JavaImport(
+ /* static = */ false,
+ JavaName(pkg), /* star = */ true,
+ ) =>
+ findJavaTypeName(pkg :+ name, ctx).flatMap(classOrEnum)
+ }.flatten
potentialRefs match {
// If we find only one, or none, then that's good
@@ -369,114 +605,219 @@ case object Java extends LazyLogging {
}))
}
- def findDeref[G](obj: Expr[G], name: String, ctx: ReferenceResolutionContext[G], blame: Blame[BuiltinError]): Option[JavaDerefTarget[G]] =
+ def findDeref[G](
+ obj: Expr[G],
+ name: String,
+ ctx: ReferenceResolutionContext[G],
+ blame: Blame[BuiltinError],
+ ): Option[JavaDerefTarget[G]] =
((obj.t match {
- case t: TNotAValue[G] => t.decl.get match {
- case RefUnloadedJavaNamespace(pkg) =>
- Some(findJavaTypeName(pkg :+ name, ctx.asTypeResolutionContext)
- .getOrElse(RefUnloadedJavaNamespace(pkg :+ name)))
- case RefJavaClass(decl) =>
- decl.decls.flatMap(Referrable.from).collectFirst {
- case ref @ RefJavaField(decls, idx) if ref.name == name && ref.decls.modifiers.is[JavaStatic[G]] => ref
- }
- case RefEnum(enum) =>
- enum.getConstant(name)
- case _ => None
- }
- case TModel(Ref(model)) => model.declarations.flatMap(Referrable.from).collectFirst {
- case ref @ RefModelField(_) if ref.name == name => ref
- }
- case JavaTClass(Ref(cls), _) => cls.decls.flatMap(Referrable.from).collectFirst {
- case ref @ RefJavaField(_, _) if ref.name == name && !ref.decls.modifiers.is[JavaStatic[G]] => ref
- }
+ case t: TNotAValue[G] =>
+ t.decl.get match {
+ case RefUnloadedJavaNamespace(pkg) =>
+ Some(
+ findJavaTypeName(pkg :+ name, ctx.asTypeResolutionContext)
+ .getOrElse(RefUnloadedJavaNamespace(pkg :+ name))
+ )
+ case RefJavaClass(decl) =>
+ decl.decls.flatMap(Referrable.from).collectFirst {
+ case ref @ RefJavaField(decls, idx)
+ if ref.name == name &&
+ ref.decls.modifiers.is[JavaStatic[G]] =>
+ ref
+ }
+ case RefEnum(enum) => enum.getConstant(name)
+ case _ => None
+ }
+ case TModel(Ref(model)) =>
+ model.declarations.flatMap(Referrable.from).collectFirst {
+ case ref @ RefModelField(_) if ref.name == name => ref
+ }
+ case JavaTClass(Ref(cls), _) =>
+ cls.decls.flatMap(Referrable.from).collectFirst {
+ case ref @ RefJavaField(_, _)
+ if ref.name == name && !ref.decls.modifiers.is[JavaStatic[G]] =>
+ ref
+ }
case _ => None
- }) : Option[JavaDerefTarget[G]]).orElse[JavaDerefTarget[G]](Spec.builtinField(obj, name, blame))
-
- def findMethodInClass[G](cls: JavaClassOrInterface[G], fromStaticContext: Boolean, method: String, args: Seq[Expr[G]]): Option[JavaInvocationTarget[G]] =
+ }): Option[JavaDerefTarget[G]])
+ .orElse[JavaDerefTarget[G]](Spec.builtinField(obj, name, blame))
+
+ def findMethodInClass[G](
+ cls: JavaClassOrInterface[G],
+ fromStaticContext: Boolean,
+ method: String,
+ args: Seq[Expr[G]],
+ ): Option[JavaInvocationTarget[G]] =
cls.decls.flatMap(Referrable.from).collectFirst {
- case ref: RefJavaMethod[G] if ref.name == method && Util.compatJavaParams(args, ref.decl.parameters) && (!fromStaticContext || ref.decl.modifiers.is[JavaStatic[G]]) => ref
- case ref: RefJavaAnnotationMethod[G] if ref.name == method && args.isEmpty && !fromStaticContext => ref
- case ref: RefInstanceFunction[G] if ref.name == method && Util.compat(args, ref.decl.args) && !fromStaticContext => ref
- case ref: RefInstanceMethod[G] if ref.name == method && Util.compat(args, ref.decl.args) && !fromStaticContext => ref
- case ref: RefInstancePredicate[G] if ref.name == method && Util.compat(args, ref.decl.args) && !fromStaticContext => ref
+ case ref: RefJavaMethod[G]
+ if ref.name == method &&
+ Util.compatJavaParams(args, ref.decl.parameters) &&
+ (!fromStaticContext || ref.decl.modifiers.is[JavaStatic[G]]) =>
+ ref
+ case ref: RefJavaAnnotationMethod[G]
+ if ref.name == method && args.isEmpty && !fromStaticContext =>
+ ref
+ case ref: RefInstanceFunction[G]
+ if ref.name == method && Util.compat(args, ref.decl.args) &&
+ !fromStaticContext =>
+ ref
+ case ref: RefInstanceMethod[G]
+ if ref.name == method && Util.compat(args, ref.decl.args) &&
+ !fromStaticContext =>
+ ref
+ case ref: RefInstancePredicate[G]
+ if ref.name == method && Util.compat(args, ref.decl.args) &&
+ !fromStaticContext =>
+ ref
}
@tailrec
- final def findMethodOnType[G](ctx: ReferenceResolutionContext[G], t: Type[G], method: String, args: Seq[Expr[G]]): Option[JavaInvocationTarget[G]] =
+ final def findMethodOnType[G](
+ ctx: ReferenceResolutionContext[G],
+ t: Type[G],
+ method: String,
+ args: Seq[Expr[G]],
+ ): Option[JavaInvocationTarget[G]] =
t match {
- case TModel(ref) => ref.decl.declarations.flatMap(Referrable.from).collectFirst {
- case ref: RefModelAction[G] if ref.name == method => ref
- case ref: RefModelProcess[G] if ref.name == method => ref
- }
- case JavaTClass(Ref(cls), Nil) => findMethodInClass(cls, fromStaticContext = false, method, args)
- case TUnion(ts) => findMethodOnType(ctx, Types.leastCommonSuperType(ts), method, args)
- case TNotAValue(RefJavaClass(cls: JavaClassOrInterface[G @unchecked])) => findMethodInClass[G](cls, fromStaticContext = true, method, args)
- case TNotAValue(RefAxiomaticDataType(adt: AxiomaticDataType[G @unchecked])) => adt.decls.flatMap(Referrable.from).collectFirst {
- case ref: RefADTFunction[G] if ref.name == method && Util.compat(args, ref.decl.args) => ref
- }
+ case TModel(ref) =>
+ ref.decl.declarations.flatMap(Referrable.from).collectFirst {
+ case ref: RefModelAction[G] if ref.name == method => ref
+ case ref: RefModelProcess[G] if ref.name == method => ref
+ }
+ case JavaTClass(Ref(cls), Nil) =>
+ findMethodInClass(cls, fromStaticContext = false, method, args)
+ case TUnion(ts) =>
+ findMethodOnType(ctx, Types.leastCommonSuperType(ts), method, args)
+ case TNotAValue(RefJavaClass(cls: JavaClassOrInterface[G @unchecked])) =>
+ findMethodInClass[G](cls, fromStaticContext = true, method, args)
+ case TNotAValue(
+ RefAxiomaticDataType(adt: AxiomaticDataType[G @unchecked])
+ ) =>
+ adt.decls.flatMap(Referrable.from).collectFirst {
+ case ref: RefADTFunction[G]
+ if ref.name == method && Util.compat(args, ref.decl.args) =>
+ ref
+ }
case _ => None
}
- def findMethod[G](ctx: ReferenceResolutionContext[G], obj: Expr[G], method: String, args: Seq[Expr[G]], blame: Blame[BuiltinError]): Option[JavaInvocationTarget[G]] =
- findMethodOnType(ctx, obj.t, method, args).orElse(Spec.builtinInstanceMethod(obj, method, blame))
-
- def matchesStatic(ctx: ReferenceResolutionContext[_], modifiers: Seq[JavaModifier[_]]): Boolean =
- !ctx.inStaticJavaContext || modifiers.collectFirst { case _: JavaStatic[_] => () }.nonEmpty
-
- def findMethod[G](ctx: ReferenceResolutionContext[G], method: String, args: Seq[Expr[G]]): Option[JavaInvocationTarget[G]] = {
- val selectMatchingSignature: PartialFunction[Referrable[G], JavaInvocationTarget[G]] = {
- case ref: RefJavaMethod[G] if ref.name == method && Util.compatJavaParams(args, ref.decl.parameters) && matchesStatic(ctx, ref.decl.modifiers) => ref
- case ref: RefInstanceFunction[G] if ref.name == method && Util.compat(args, ref.decl.args) && !ctx.inStaticJavaContext => ref
- case ref: RefInstanceMethod[G] if ref.name == method && Util.compat(args, ref.decl.args) && !ctx.inStaticJavaContext => ref
- case ref: RefInstancePredicate[G] if ref.name == method && Util.compat(args, ref.decl.args) && !ctx.inStaticJavaContext => ref
- case ref: RefFunction[G] if ref.name == method && Util.compat(args, ref.decl.args) => ref
- case ref: RefProcedure[G] if ref.name == method && Util.compat(args, ref.decl.args) => ref
- case ref: RefPredicate[G] if ref.name == method && Util.compat(args, ref.decl.args) => ref
- case ref: RefADTFunction[G] if ref.name == method && Util.compat(args, ref.decl.args) => ref
- case ref: RefModelProcess[G] if ref.name == method && Util.compat(args, ref.decl.args) => ref
- case ref: RefModelAction[G] if ref.name == method && Util.compat(args, ref.decl.args) => ref
- case ref: RefProverFunction[G] if ref.name == method && Util.compat(args, ref.decl.args) => ref
+ def findMethod[G](
+ ctx: ReferenceResolutionContext[G],
+ obj: Expr[G],
+ method: String,
+ args: Seq[Expr[G]],
+ blame: Blame[BuiltinError],
+ ): Option[JavaInvocationTarget[G]] =
+ findMethodOnType(ctx, obj.t, method, args)
+ .orElse(Spec.builtinInstanceMethod(obj, method, blame))
+
+ def matchesStatic(
+ ctx: ReferenceResolutionContext[_],
+ modifiers: Seq[JavaModifier[_]],
+ ): Boolean =
+ !ctx.inStaticJavaContext || modifiers.collectFirst {
+ case _: JavaStatic[_] => ()
+ }.nonEmpty
+
+ def findMethod[G](
+ ctx: ReferenceResolutionContext[G],
+ method: String,
+ args: Seq[Expr[G]],
+ ): Option[JavaInvocationTarget[G]] = {
+ val selectMatchingSignature
+ : PartialFunction[Referrable[G], JavaInvocationTarget[G]] = {
+ case ref: RefJavaMethod[G]
+ if ref.name == method &&
+ Util.compatJavaParams(args, ref.decl.parameters) &&
+ matchesStatic(ctx, ref.decl.modifiers) =>
+ ref
+ case ref: RefInstanceFunction[G]
+ if ref.name == method && Util.compat(args, ref.decl.args) &&
+ !ctx.inStaticJavaContext =>
+ ref
+ case ref: RefInstanceMethod[G]
+ if ref.name == method && Util.compat(args, ref.decl.args) &&
+ !ctx.inStaticJavaContext =>
+ ref
+ case ref: RefInstancePredicate[G]
+ if ref.name == method && Util.compat(args, ref.decl.args) &&
+ !ctx.inStaticJavaContext =>
+ ref
+ case ref: RefFunction[G]
+ if ref.name == method && Util.compat(args, ref.decl.args) =>
+ ref
+ case ref: RefProcedure[G]
+ if ref.name == method && Util.compat(args, ref.decl.args) =>
+ ref
+ case ref: RefPredicate[G]
+ if ref.name == method && Util.compat(args, ref.decl.args) =>
+ ref
+ case ref: RefADTFunction[G]
+ if ref.name == method && Util.compat(args, ref.decl.args) =>
+ ref
+ case ref: RefModelProcess[G]
+ if ref.name == method && Util.compat(args, ref.decl.args) =>
+ ref
+ case ref: RefModelAction[G]
+ if ref.name == method && Util.compat(args, ref.decl.args) =>
+ ref
+ case ref: RefProverFunction[G]
+ if ref.name == method && Util.compat(args, ref.decl.args) =>
+ ref
}
- ctx.stack.flatten.collectFirst(selectMatchingSignature).orElse(ctx.currentJavaNamespace.flatMap(ns => {
- // First find all classes that belong to each import that we can use
- val potentialClasses: Seq[JavaTypeNameTarget[G]] = ns.imports.collect {
- case JavaImport(true, importName, /* star = */ false) if importName.names.last == method => importName.names.init
- case JavaImport(true, importName, /* star = */ true) => importName.names
- }.flatMap(findJavaTypeName(_, ctx.asTypeResolutionContext))
-
- // From each class, get the method we are looking for
- potentialClasses.collect({
- case RefJavaClass(cls: JavaClass[G]) => cls.getMethods(method)
- }).filter(_.nonEmpty) match { // Discard any classes that have no matches
- // If we find only one set of methods, or no sets at all, then that's good.
- // Just pick the one that matches the signature we're looking for
- case Seq(methods) => methods.collectFirst(selectMatchingSignature)
- case Nil => None
- // If there where multiple classes that had matching definitions, then we error out,
- // because untangling that is not yet supported
- case _ => throw OverlappingJavaImports(ns, "method", method)
- }
- }))
+ ctx.stack.flatten.collectFirst(selectMatchingSignature)
+ .orElse(ctx.currentJavaNamespace.flatMap(ns => {
+ // First find all classes that belong to each import that we can use
+ val potentialClasses: Seq[JavaTypeNameTarget[G]] = ns.imports.collect {
+ case JavaImport(true, importName, /* star = */ false)
+ if importName.names.last == method =>
+ importName.names.init
+ case JavaImport(true, importName, /* star = */ true) =>
+ importName.names
+ }.flatMap(findJavaTypeName(_, ctx.asTypeResolutionContext))
+
+ // From each class, get the method we are looking for
+ potentialClasses.collect({ case RefJavaClass(cls: JavaClass[G]) =>
+ cls.getMethods(method)
+ }).filter(_.nonEmpty) match { // Discard any classes that have no matches
+ // If we find only one set of methods, or no sets at all, then that's good.
+ // Just pick the one that matches the signature we're looking for
+ case Seq(methods) => methods.collectFirst(selectMatchingSignature)
+ case Nil => None
+ // If there where multiple classes that had matching definitions, then we error out,
+ // because untangling that is not yet supported
+ case _ => throw OverlappingJavaImports(ns, "method", method)
+ }
+ }))
}
- def findConstructor[G](t: Type[G], args: Seq[Expr[G]]): Option[JavaConstructorTarget[G]] = t match {
- case JavaTClass(Ref(cls: JavaClass[G]), _) =>
- val definedConstructor = cls.decls.collectFirst {
- case cons: JavaConstructor[G] if Util.compatJavaParams(args, cons.parameters) => RefJavaConstructor(cons)
- }
-
- args match {
- case Nil => definedConstructor.orElse(Some(ImplicitDefaultJavaConstructor(cls)))
- case _ => definedConstructor
- }
- case TModel(Ref(model)) if args.isEmpty =>
- Some(RefModel(model))
- case _ => None
- }
+ def findConstructor[G](
+ t: Type[G],
+ args: Seq[Expr[G]],
+ ): Option[JavaConstructorTarget[G]] =
+ t match {
+ case JavaTClass(Ref(cls: JavaClass[G]), _) =>
+ val definedConstructor = cls.decls.collectFirst {
+ case cons: JavaConstructor[G]
+ if Util.compatJavaParams(args, cons.parameters) =>
+ RefJavaConstructor(cons)
+ }
+ args match {
+ case Nil =>
+ definedConstructor.orElse(Some(ImplicitDefaultJavaConstructor(cls)))
+ case _ => definedConstructor
+ }
+ case TModel(Ref(model)) if args.isEmpty => Some(RefModel(model))
+ case _ => None
+ }
- def findJavaBipStatePredicate[G](ctx: ReferenceResolutionContext[G], state: String): JavaBipStatePredicateTarget[G] = {
+ def findJavaBipStatePredicate[G](
+ ctx: ReferenceResolutionContext[G],
+ state: String,
+ ): JavaBipStatePredicateTarget[G] = {
val m = ctx.javaBipStatePredicates.map { case (k, v) => (getLit(k), v) }
m.get(state) match {
case Some(ann) => RefJavaBipStatePredicate(state, ann)
@@ -484,54 +825,70 @@ case object Java extends LazyLogging {
}
}
- def findJavaBipGuard[G](ctx: ReferenceResolutionContext[G], name: String): Option[JavaMethod[G]] =
+ def findJavaBipGuard[G](
+ ctx: ReferenceResolutionContext[G],
+ name: String,
+ ): Option[JavaMethod[G]] =
ctx.javaBipGuards.map { case (k, v) => (getLit(k), v) }.get(name)
- def getStaticMembers[G](javaTypeName: JavaTypeNameTarget[G]): Seq[Referrable[G]] = javaTypeName match {
- case RefJavaClass(cls) => cls.decls.collect {
- case decl: JavaClassDeclaration[G] if decl.isStatic => Referrable.from(decl)
- }.flatten
- case RefEnum(enum) => enum.constants.map(RefEnumConstant(Some(enum), _))
- case _ => Nil // PB: I guess? Maybe we should support "ghost static importing" adt functions and whatnot :)
- }
+ def getStaticMembers[G](
+ javaTypeName: JavaTypeNameTarget[G]
+ ): Seq[Referrable[G]] =
+ javaTypeName match {
+ case RefJavaClass(cls) =>
+ cls.decls.collect {
+ case decl: JavaClassDeclaration[G] if decl.isStatic =>
+ Referrable.from(decl)
+ }.flatten
+ case RefEnum(enum) => enum.constants.map(RefEnumConstant(Some(enum), _))
+ case _ =>
+ Nil // PB: I guess? Maybe we should support "ghost static importing" adt functions and whatnot :)
+ }
- def findStaticMember[G](javaTypeName: JavaTypeNameTarget[G], name: String): Option[Referrable[G]] =
- getStaticMembers(javaTypeName).find(_.name == name)
+ def findStaticMember[G](
+ javaTypeName: JavaTypeNameTarget[G],
+ name: String,
+ ): Option[Referrable[G]] = getStaticMembers(javaTypeName).find(_.name == name)
case class WrongTypeForDefaultValue(t: Type[_]) extends UserError {
override def code: String = "wrongDefaultType"
override def text: String =
- t.o.messageInContext(s"The type `$t` has no defined default value in VerCors.")
+ t.o.messageInContext(
+ s"The type `$t` has no defined default value in VerCors."
+ )
}
- def zeroValue[G](t: Type[G]): Expr[G] = t match {
- case TArray(_) => Null()
- case TPointer(_) => Null()
- case TSeq(element) => LiteralSeq(element, Nil)
- case TSet(element) => LiteralSet(element, Nil)
- case TBag(element) => LiteralBag(element, Nil)
- case TOption(_) => OptNone()
- case TMap(key, value) => LiteralMap(key, value, Nil)
- case TVoid() => Void()
- case TNull() => Null()
- case TBool() => ff
- case TString() => Null()
- case TRef() => Null()
- case TProcess() => EmptyProcess()
- case TInt() => const(0)
- case t: TFloat[G] => const(0)
- case TRational() => const(0)
- case TZFraction() => const(0)
- case TClass(_, _) => Null()
- case JavaTClass(_, _) => Null()
- case TEnum(_) => Null()
- case TAnyClass() => Null()
-
- case t => throw WrongTypeForDefaultValue(t)
- }
+ def zeroValue[G](t: Type[G]): Expr[G] =
+ t match {
+ case TArray(_) => Null()
+ case TPointer(_) => Null()
+ case TSeq(element) => LiteralSeq(element, Nil)
+ case TSet(element) => LiteralSet(element, Nil)
+ case TBag(element) => LiteralBag(element, Nil)
+ case TOption(_) => OptNone()
+ case TMap(key, value) => LiteralMap(key, value, Nil)
+ case TVoid() => Void()
+ case TNull() => Null()
+ case TBool() => ff
+ case TString() => Null()
+ case TRef() => Null()
+ case TProcess() => EmptyProcess()
+ case TInt() => const(0)
+ case t: TFloat[G] => const(0)
+ case TRational() => const(0)
+ case TZFraction() => const(0)
+ case TClass(_, _) => Null()
+ case JavaTClass(_, _) => Null()
+ case TEnum(_) => Null()
+ case TAnyClass() => Null()
+
+ case t => throw WrongTypeForDefaultValue(t)
+ }
- def double[G](implicit o: Origin = DiagnosticOrigin): TFloat[G] = TFloats.ieee754_64bit
- def float[G](implicit o: Origin = DiagnosticOrigin): TFloat[G] = TFloats.ieee754_32bit
+ def double[G](implicit o: Origin = DiagnosticOrigin): TFloat[G] =
+ TFloats.ieee754_64bit
+ def float[G](implicit o: Origin = DiagnosticOrigin): TFloat[G] =
+ TFloats.ieee754_32bit
}
sealed trait JavaAnnotationData[G]
@@ -539,60 +896,78 @@ case object JavaAnnotationData {
case object BipTransition {
def get[G](m: JavaMethod[G]): Seq[BipTransition[G]] =
- m.modifiers.collect { case ja @ JavaAnnotationEx(_, _, b: BipTransition[G]) => b }
+ m.modifiers.collect {
+ case ja @ JavaAnnotationEx(_, _, b: BipTransition[G]) => b
+ }
}
- final case class BipTransition[G](portName: String,
- source: JavaBipStatePredicateTarget[G],
- target: JavaBipStatePredicateTarget[G],
- guardText: Option[String], guard: Option[Expr[G]], requires: Expr[G], ensures: Expr[G]
- )(implicit val o: Origin) extends JavaAnnotationData[G]
-
+ final case class BipTransition[G](
+ portName: String,
+ source: JavaBipStatePredicateTarget[G],
+ target: JavaBipStatePredicateTarget[G],
+ guardText: Option[String],
+ guard: Option[Expr[G]],
+ requires: Expr[G],
+ ensures: Expr[G],
+ )(implicit val o: Origin)
+ extends JavaAnnotationData[G]
case object BipInvariant {
def get[G](jc: JavaClassOrInterface[G]): Option[BipInvariant[G]] =
- jc.modifiers
- .collect { case ja @ JavaAnnotation(_, _) if ja.data.isDefined => ja.data.get }
- .collectFirst { case bi: BipInvariant[G] => bi }
+ jc.modifiers.collect {
+ case ja @ JavaAnnotation(_, _) if ja.data.isDefined => ja.data.get
+ }.collectFirst { case bi: BipInvariant[G] => bi }
}
final case class BipInvariant[G](expr: Expr[G]) extends JavaAnnotationData[G]
case object BipPort {
def getAll[G](c: JavaClass[G]): Seq[BipPort[G]] =
- c.modifiers.collect { case JavaAnnotationEx(_, _, bp: BipPort[G]) => bp}
+ c.modifiers.collect { case JavaAnnotationEx(_, _, bp: BipPort[G]) => bp }
}
- final case class BipPort[G](name: String, portType: BipPortType[G])(implicit val o: Origin) extends JavaAnnotationData[G]
+ final case class BipPort[G](name: String, portType: BipPortType[G])(
+ implicit val o: Origin
+ ) extends JavaAnnotationData[G]
case object BipComponent {
def get[G](jc: JavaClassOrInterface[G]): Option[BipComponent[G]] =
- jc.modifiers
- .collect { case ja @ JavaAnnotation(_, _) if ja.data.isDefined => ja.data.get }
- .collectFirst { case bct: BipComponent[G] => bct }
+ jc.modifiers.collect {
+ case ja @ JavaAnnotation(_, _) if ja.data.isDefined => ja.data.get
+ }.collectFirst { case bct: BipComponent[G] => bct }
}
- final case class BipComponent[G](name: String, initial: JavaBipStatePredicateTarget[G]) extends JavaAnnotationData[G]
+ final case class BipComponent[G](
+ name: String,
+ initial: JavaBipStatePredicateTarget[G],
+ ) extends JavaAnnotationData[G]
case object BipStatePredicate {
def getAll[G](c: JavaClass[G]): Seq[BipStatePredicate[G]] =
- c.modifiers.collect { case JavaAnnotationEx(_, _, bsp: BipStatePredicate[G]) => bsp}
+ c.modifiers.collect {
+ case JavaAnnotationEx(_, _, bsp: BipStatePredicate[G]) => bsp
+ }
}
- final case class BipStatePredicate[G](name: String, expr: Expr[G])(implicit val o: Origin) extends JavaAnnotationData[G]
+ final case class BipStatePredicate[G](name: String, expr: Expr[G])(
+ implicit val o: Origin
+ ) extends JavaAnnotationData[G]
case object BipData {
def get[G](node: Node[G]): Option[BipData[G]] = {
- val modifiers = node match {
- case p: JavaParam[G] => p.modifiers
- case m: JavaMethod[G] => m.modifiers
- case _ => return None
+ val modifiers =
+ node match {
+ case p: JavaParam[G] => p.modifiers
+ case m: JavaMethod[G] => m.modifiers
+ case _ => return None
+ }
+ modifiers.collectFirst { case JavaAnnotationEx(_, _, d @ BipData(_)) =>
+ d.asInstanceOf[BipData[G]]
}
- modifiers.collectFirst { case JavaAnnotationEx(_, _, d @ BipData(_)) => d.asInstanceOf[BipData[G]] }
}
}
- final case class BipData[G](name: String)(implicit val o: Origin) extends JavaAnnotationData[G]
+ final case class BipData[G](name: String)(implicit val o: Origin)
+ extends JavaAnnotationData[G]
case object BipGuard {
def get[G](m: JavaMethod[G]): Option[JavaAnnotation[G]] =
- m.modifiers
- .collect { case ja @ JavaAnnotation(_, _) => (ja, ja.data) }
+ m.modifiers.collect { case ja @ JavaAnnotation(_, _) => (ja, ja.data) }
.collectFirst { case (ja, Some(_: BipGuard[G])) => ja }
def getName[G](method: JavaMethod[G]): Option[Expr[G]] =
@@ -604,7 +979,9 @@ case object JavaAnnotationData {
case object BipPure {
def isPure[G](m: JavaMethod[G]): Boolean =
- m.modifiers.collectFirst { case ja @ JavaAnnotationEx(_, _, BipPure()) => ja }.isDefined
+ m.modifiers.collectFirst { case ja @ JavaAnnotationEx(_, _, BipPure()) =>
+ ja
+ }.isDefined
}
final case class BipPure[G]() extends JavaAnnotationData[G]
}
diff --git a/src/col/vct/col/resolve/lang/LLVM.scala b/src/col/vct/col/resolve/lang/LLVM.scala
index f042692cb6..e010a9aaec 100644
--- a/src/col/vct/col/resolve/lang/LLVM.scala
+++ b/src/col/vct/col/resolve/lang/LLVM.scala
@@ -7,7 +7,10 @@ import vct.col.resolve.ctx._
object LLVM {
- def findCallable[G](name: String, ctx: ReferenceResolutionContext[G]): Option[LlvmCallable[G]] = {
+ def findCallable[G](
+ name: String,
+ ctx: ReferenceResolutionContext[G],
+ ): Option[LlvmCallable[G]] = {
// look in context
val callable = ctx.stack.flatten.map {
case RefLlvmGlobal(decl, i) =>
@@ -20,16 +23,16 @@ object LLVM {
// if not present in context, might find it in the call site of the current function definition
callable match {
case Some(callable) => Some(callable)
- case None => ctx.currentResult.get match {
- case RefLlvmFunctionDefinition(decl) =>
- decl.contract.invokableRefs.find(ref => ref._1 == name) match {
- case Some(ref) => Some(ref._2.decl)
- case None => None
- }
- case _ => None
- }
+ case None =>
+ ctx.currentResult.get match {
+ case RefLlvmFunctionDefinition(decl) =>
+ decl.contract.invokableRefs.find(ref => ref._1 == name) match {
+ case Some(ref) => Some(ref._2.decl)
+ case None => None
+ }
+ case _ => None
+ }
}
}
-
}
diff --git a/src/col/vct/col/resolve/lang/PVL.scala b/src/col/vct/col/resolve/lang/PVL.scala
index 9a75e57bb8..9a8593e5a4 100644
--- a/src/col/vct/col/resolve/lang/PVL.scala
+++ b/src/col/vct/col/resolve/lang/PVL.scala
@@ -7,15 +7,23 @@ import vct.col.ref.Ref
import vct.col.resolve.ctx._
case object PVL {
- def findConstructor[G](t: Type[G], typeArgs: Seq[Type[G]], args: Seq[Expr[G]]): Option[PVLConstructorTarget[G]] = {
+ def findConstructor[G](
+ t: Type[G],
+ typeArgs: Seq[Type[G]],
+ args: Seq[Expr[G]],
+ ): Option[PVLConstructorTarget[G]] = {
t match {
case t @ TClass(Ref(cls), _) =>
val resolvedCons = cls.decls.collectFirst {
- case cons: PVLConstructor[G] if Util.compat(t.typeEnv, args, typeArgs, cons.args, cons.typeArgs) => RefPVLConstructor(cons)
+ case cons: PVLConstructor[G]
+ if Util
+ .compat(t.typeEnv, args, typeArgs, cons.args, cons.typeArgs) =>
+ RefPVLConstructor(cons)
}
args match {
- case Nil => resolvedCons.orElse(Some(ImplicitDefaultPVLConstructor(cls)))
+ case Nil =>
+ resolvedCons.orElse(Some(ImplicitDefaultPVLConstructor(cls)))
case _ => resolvedCons
}
case TModel(Ref(model)) if args.isEmpty => Some(RefModel(model))
@@ -23,12 +31,18 @@ case object PVL {
}
}
- def findTypeName[G](name: String, ctx: TypeResolutionContext[G]): Option[PVLTypeNameTarget[G]] =
+ def findTypeName[G](
+ name: String,
+ ctx: TypeResolutionContext[G],
+ ): Option[PVLTypeNameTarget[G]] =
ctx.stack.flatten.collectFirst {
case target: PVLTypeNameTarget[G] if target.name == name => target
}
- def findName[G](name: String, ctx: ReferenceResolutionContext[G]): Option[PVLNameTarget[G]] =
+ def findName[G](
+ name: String,
+ ctx: ReferenceResolutionContext[G],
+ ): Option[PVLNameTarget[G]] =
ctx.stack.flatten.collectFirst {
case target: PVLNameTarget[G] if target.name == name => target
}
@@ -38,62 +52,134 @@ case object PVL {
case ref: RefField[G] if ref.name == name => ref
}
- def findDeref[G](obj: Expr[G], name: String, ctx: ReferenceResolutionContext[G], blame: Blame[BuiltinError]): Option[PVLDerefTarget[G]] =
+ def findDeref[G](
+ obj: Expr[G],
+ name: String,
+ ctx: ReferenceResolutionContext[G],
+ blame: Blame[BuiltinError],
+ ): Option[PVLDerefTarget[G]] =
obj.t match {
- case TNotAValue(RefEnum(enum)) => enum.constants.flatMap(Referrable.from).collectFirst {
- case ref: RefEnumConstant[G @unchecked] if ref.name == name => ref.copy(enum = Some(enum))
- }
+ case TNotAValue(RefEnum(enum)) =>
+ enum.constants.flatMap(Referrable.from).collectFirst {
+ case ref: RefEnumConstant[G @unchecked] if ref.name == name =>
+ ref.copy(enum = Some(enum))
+ }
case _: TNotAValue[G] => Spec.builtinField(obj, name, blame)
- case TModel(ref) => ref.decl.declarations.flatMap(Referrable.from).collectFirst {
- case ref: RefModelField[G] if ref.name == name => ref
- }
+ case TModel(ref) =>
+ ref.decl.declarations.flatMap(Referrable.from).collectFirst {
+ case ref: RefModelField[G] if ref.name == name => ref
+ }
case TClass(ref, _) => findDerefOfClass(ref.decl, name)
case _ => Spec.builtinField(obj, name, blame)
}
- def findInstanceMethod[G](obj: Expr[G], method: String, args: Seq[Expr[G]], typeArgs: Seq[Type[G]], blame: Blame[BuiltinError]): Option[PVLInvocationTarget[G]] =
+ def findInstanceMethod[G](
+ obj: Expr[G],
+ method: String,
+ args: Seq[Expr[G]],
+ typeArgs: Seq[Type[G]],
+ blame: Blame[BuiltinError],
+ ): Option[PVLInvocationTarget[G]] =
obj.t match {
- case t: TNotAValue[G] => t.decl.get match {
- case RefAxiomaticDataType(decl) => decl.declarations.flatMap(Referrable.from).collectFirst {
- case ref: RefADTFunction[G] if ref.name == method => ref
+ case t: TNotAValue[G] =>
+ t.decl.get match {
+ case RefAxiomaticDataType(decl) =>
+ decl.declarations.flatMap(Referrable.from).collectFirst {
+ case ref: RefADTFunction[G] if ref.name == method => ref
+ }
+ case _ => Spec.builtinInstanceMethod(obj, method, blame)
+ }
+ case TModel(ref) =>
+ ref.decl.declarations.flatMap(Referrable.from).collectFirst {
+ case ref: RefModelAction[G] if ref.name == method => ref
+ case ref: RefModelProcess[G] if ref.name == method => ref
+ }.orElse(Spec.builtinInstanceMethod(obj, method, blame))
+ case t @ TClass(ref, _) =>
+ ref.decl.declarations.flatMap(Referrable.from).collectFirst {
+ case ref: RefInstanceFunction[G]
+ if ref.name == method &&
+ Util.compat(t.typeEnv, args, typeArgs, ref.decl) =>
+ ref
+ case ref: RefInstanceMethod[G]
+ if ref.name == method &&
+ Util.compat(t.typeEnv, args, typeArgs, ref.decl) =>
+ ref
+ case ref: RefInstancePredicate[G]
+ if ref.name == method &&
+ Util.compat(t.typeEnv, args, ref.decl.args) =>
+ ref
}
- case _ => Spec.builtinInstanceMethod(obj, method, blame)
- }
- case TModel(ref) => ref.decl.declarations.flatMap(Referrable.from).collectFirst {
- case ref: RefModelAction[G] if ref.name == method => ref
- case ref: RefModelProcess[G] if ref.name == method => ref
- }.orElse(Spec.builtinInstanceMethod(obj, method, blame))
- case t @ TClass(ref, _) => ref.decl.declarations.flatMap(Referrable.from).collectFirst {
- case ref: RefInstanceFunction[G] if ref.name == method && Util.compat(t.typeEnv, args, typeArgs, ref.decl) => ref
- case ref: RefInstanceMethod[G] if ref.name == method && Util.compat(t.typeEnv, args, typeArgs, ref.decl) => ref
- case ref: RefInstancePredicate[G] if ref.name == method && Util.compat(t.typeEnv, args, ref.decl.args) => ref
- }
- case _ => PVL.builtinInstanceMethod(obj, method, args).orElse(Spec.builtinInstanceMethod(obj, method, blame))
+ case _ =>
+ PVL.builtinInstanceMethod(obj, method, args)
+ .orElse(Spec.builtinInstanceMethod(obj, method, blame))
}
- def findMethod[G](method: String, args: Seq[Expr[G]], typeArgs: Seq[Type[G]], ctx: ReferenceResolutionContext[G]): Option[PVLInvocationTarget[G]] =
+ def findMethod[G](
+ method: String,
+ args: Seq[Expr[G]],
+ typeArgs: Seq[Type[G]],
+ ctx: ReferenceResolutionContext[G],
+ ): Option[PVLInvocationTarget[G]] =
ctx.stack.flatten.collectFirst {
- case ref: RefFunction[G] if ref.name == method && Util.compat(ctx.typeEnv, args, typeArgs, ref.decl) => ref
- case ref: RefProcedure[G] if ref.name == method && Util.compat(ctx.typeEnv, args, typeArgs, ref.decl) => ref
- case ref: RefPredicate[G] if ref.name == method && Util.compat(ctx.typeEnv, args, ref.decl.args) => ref
- case ref: RefInstanceFunction[G] if ref.name == method && Util.compat(ctx.typeEnv, args, typeArgs, ref.decl) => ref
- case ref: RefInstanceMethod[G] if ref.name == method && Util.compat(ctx.typeEnv, args, typeArgs, ref.decl) => ref
- case ref: RefInstancePredicate[G] if ref.name == method && Util.compat(ctx.typeEnv, args, ref.decl.args) => ref
- case ref: RefADTFunction[G] if ref.name == method && Util.compat(ctx.typeEnv, args, ref.decl.args) => ref
- case ref: RefModelProcess[G] if ref.name == method && Util.compat(ctx.typeEnv, args, ref.decl.args) => ref
- case ref: RefModelAction[G] if ref.name == method && Util.compat(ctx.typeEnv, args, ref.decl.args) => ref
- case ref: RefProverFunction[G] if ref.name == method && Util.compat(ctx.typeEnv, args, ref.decl.args) => ref
+ case ref: RefFunction[G]
+ if ref.name == method &&
+ Util.compat(ctx.typeEnv, args, typeArgs, ref.decl) =>
+ ref
+ case ref: RefProcedure[G]
+ if ref.name == method &&
+ Util.compat(ctx.typeEnv, args, typeArgs, ref.decl) =>
+ ref
+ case ref: RefPredicate[G]
+ if ref.name == method &&
+ Util.compat(ctx.typeEnv, args, ref.decl.args) =>
+ ref
+ case ref: RefInstanceFunction[G]
+ if ref.name == method &&
+ Util.compat(ctx.typeEnv, args, typeArgs, ref.decl) =>
+ ref
+ case ref: RefInstanceMethod[G]
+ if ref.name == method &&
+ Util.compat(ctx.typeEnv, args, typeArgs, ref.decl) =>
+ ref
+ case ref: RefInstancePredicate[G]
+ if ref.name == method &&
+ Util.compat(ctx.typeEnv, args, ref.decl.args) =>
+ ref
+ case ref: RefADTFunction[G]
+ if ref.name == method &&
+ Util.compat(ctx.typeEnv, args, ref.decl.args) =>
+ ref
+ case ref: RefModelProcess[G]
+ if ref.name == method &&
+ Util.compat(ctx.typeEnv, args, ref.decl.args) =>
+ ref
+ case ref: RefModelAction[G]
+ if ref.name == method &&
+ Util.compat(ctx.typeEnv, args, ref.decl.args) =>
+ ref
+ case ref: RefProverFunction[G]
+ if ref.name == method &&
+ Util.compat(ctx.typeEnv, args, ref.decl.args) =>
+ ref
}
- def builtinInstanceMethod[G](obj: Expr[G], method: String, args: Seq[Expr[G]]): Option[PVLBuiltinInstanceMethod[G]] = {
+ def builtinInstanceMethod[G](
+ obj: Expr[G],
+ method: String,
+ args: Seq[Expr[G]],
+ ): Option[PVLBuiltinInstanceMethod[G]] = {
implicit val o: Origin = obj.o
Some((obj.t, method, args) match {
- case (TFloat(_, _), "toFloat32", Seq()) => PVLBuiltinInstanceMethod[G](obj => _ => CastFloat(obj, PVL.float32))
- case (TFloat(_, _), "toFloat64", Seq()) => PVLBuiltinInstanceMethod[G](obj => _ => CastFloat(obj, PVL.float64))
+ case (TFloat(_, _), "toFloat32", Seq()) =>
+ PVLBuiltinInstanceMethod[G](obj => _ => CastFloat(obj, PVL.float32))
+ case (TFloat(_, _), "toFloat64", Seq()) =>
+ PVLBuiltinInstanceMethod[G](obj => _ => CastFloat(obj, PVL.float64))
case _ => return None
})
}
- def float32[G](implicit o: Origin = DiagnosticOrigin): TFloat[G] = TFloats.ieee754_32bit
- def float64[G](implicit o: Origin = DiagnosticOrigin): TFloat[G] = TFloats.ieee754_64bit
+ def float32[G](implicit o: Origin = DiagnosticOrigin): TFloat[G] =
+ TFloats.ieee754_32bit
+ def float64[G](implicit o: Origin = DiagnosticOrigin): TFloat[G] =
+ TFloats.ieee754_64bit
}
diff --git a/src/col/vct/col/resolve/lang/Spec.scala b/src/col/vct/col/resolve/lang/Spec.scala
index e5324bf877..df62509925 100644
--- a/src/col/vct/col/resolve/lang/Spec.scala
+++ b/src/col/vct/col/resolve/lang/Spec.scala
@@ -8,54 +8,77 @@ import vct.col.resolve.ctx._
import vct.result.VerificationError.UserError
case object Spec {
- def getContract[G](target: Referrable[G], blame: Node[G]): ApplicableContract[G] = target match {
- case RefFunction(decl) => decl.contract
- case RefProcedure(decl) => decl.contract
- case RefInstanceFunction(decl) => decl.contract
- case RefInstanceMethod(decl) => decl.contract
- case RefCLocalDeclaration(decls, _) => decls.decl.contract
- case RefCGlobalDeclaration(decls, _) => decls.decl.contract
- case RefCFunctionDefinition(decl) => decl.contract
- case RefCPPLocalDeclaration(decls, _) => decls.decl.contract
- case RefCPPGlobalDeclaration(decls, _) => decls.decl.contract
- case RefCPPFunctionDefinition(decl) => decl.contract
- case RefCPPLambdaDefinition(decl) => decl.contract
- case RefJavaConstructor(decl) => decl.contract
- case RefJavaMethod(decl) => decl.contract
- case RefPVLConstructor(decl) => decl.contract
- case other => throw NoGivenYields(blame)
- }
+ def getContract[G](
+ target: Referrable[G],
+ blame: Node[G],
+ ): ApplicableContract[G] =
+ target match {
+ case RefFunction(decl) => decl.contract
+ case RefProcedure(decl) => decl.contract
+ case RefInstanceFunction(decl) => decl.contract
+ case RefInstanceMethod(decl) => decl.contract
+ case RefCLocalDeclaration(decls, _) => decls.decl.contract
+ case RefCGlobalDeclaration(decls, _) => decls.decl.contract
+ case RefCFunctionDefinition(decl) => decl.contract
+ case RefCPPLocalDeclaration(decls, _) => decls.decl.contract
+ case RefCPPGlobalDeclaration(decls, _) => decls.decl.contract
+ case RefCPPFunctionDefinition(decl) => decl.contract
+ case RefCPPLambdaDefinition(decl) => decl.contract
+ case RefJavaConstructor(decl) => decl.contract
+ case RefJavaMethod(decl) => decl.contract
+ case RefPVLConstructor(decl) => decl.contract
+ case other => throw NoGivenYields(blame)
+ }
- def resolveGiven[G](givenMap: Seq[(Ref[G, Variable[G]], Expr[G])], target: Referrable[G], blame: Node[G]): Unit =
- if(givenMap.nonEmpty) {
+ def resolveGiven[G](
+ givenMap: Seq[(Ref[G, Variable[G]], Expr[G])],
+ target: Referrable[G],
+ blame: Node[G],
+ ): Unit =
+ if (givenMap.nonEmpty) {
val contract = getContract(target, blame)
val args = contract.givenArgs.flatMap(Referrable.from)
- givenMap.foreach {
- case (arg, _) => arg.tryResolve(name => args.collectFirst {
- case ref: RefVariable[G] if ref.name == name => ref.decl
- }.getOrElse(throw NoSuchNameError("'given' argument", name, blame)))
+ givenMap.foreach { case (arg, _) =>
+ arg.tryResolve(name =>
+ args.collectFirst {
+ case ref: RefVariable[G] if ref.name == name => ref.decl
+ }.getOrElse(throw NoSuchNameError("'given' argument", name, blame))
+ )
}
}
- def resolveYields[G](ctx: ReferenceResolutionContext[G], yields: Seq[(Expr[G], Ref[G, Variable[G]])], target: Referrable[G], blame: Node[G]): Unit =
- if(yields.nonEmpty) {
+ def resolveYields[G](
+ ctx: ReferenceResolutionContext[G],
+ yields: Seq[(Expr[G], Ref[G, Variable[G]])],
+ target: Referrable[G],
+ blame: Node[G],
+ ): Unit =
+ if (yields.nonEmpty) {
val contract = getContract(target, blame)
val args = contract.yieldsArgs.flatMap(Referrable.from)
- yields.foreach {
- case (_, res) =>
- res.tryResolve(name => args.collectFirst {
+ yields.foreach { case (_, res) =>
+ res.tryResolve(name =>
+ args.collectFirst {
case ref: RefVariable[G] if ref.name == name => ref.decl
- }.getOrElse(throw NoSuchNameError("'yields' argument", name, blame)))
+ }.getOrElse(throw NoSuchNameError("'yields' argument", name, blame))
+ )
}
}
- case class BuiltinArgumentCountError(obj: Expr[_], expected: Int) extends UserError {
+ case class BuiltinArgumentCountError(obj: Expr[_], expected: Int)
+ extends UserError {
override def text: String =
- obj.o.messageInContext(s"Builtin method invocation has wrong argument count: expected $expected argument(s).")
+ obj.o.messageInContext(
+ s"Builtin method invocation has wrong argument count: expected $expected argument(s)."
+ )
override def code: String = "builtinArgCount"
}
- def builtinField[G](obj: Expr[G], field: String, blame: Blame[BuiltinError]): Option[BuiltinField[G]] = {
+ def builtinField[G](
+ obj: Expr[G],
+ field: String,
+ blame: Blame[BuiltinError],
+ ): Option[BuiltinField[G]] = {
implicit val o: Origin = obj.o
Some(BuiltinField((obj.t, field) match {
case (TArray(_), "length") => Length(_)(blame)
@@ -85,120 +108,203 @@ case object Spec {
}))
}
- def argCount[G](n: Int)(f: Expr[G] => Seq[Expr[G]] => Expr[G]): Expr[G] => Seq[Expr[G]] => Expr[G] =
- obj => args =>
- if(args.size == n) f(obj)(args)
- else throw BuiltinArgumentCountError(obj, n)
-
- def builtinInstanceMethod[G](obj: Expr[G], method: String, blame: Blame[BuiltinError]): Option[BuiltinInstanceMethod[G]] = {
+ def argCount[G](
+ n: Int
+ )(f: Expr[G] => Seq[Expr[G]] => Expr[G]): Expr[G] => Seq[Expr[G]] => Expr[G] =
+ obj =>
+ args =>
+ if (args.size == n)
+ f(obj)(args)
+ else
+ throw BuiltinArgumentCountError(obj, n)
+
+ def builtinInstanceMethod[G](
+ obj: Expr[G],
+ method: String,
+ blame: Blame[BuiltinError],
+ ): Option[BuiltinInstanceMethod[G]] = {
implicit val o: Origin = obj.o
Some(BuiltinInstanceMethod((obj.t, method) match {
- case (t: TNotAValue[G], _) => (t.decl.get, method) match {
- case (RefModel(model), "create") => _ => _ => ModelNew(model.ref)
- case (_, _) => return None
- }
-
- case (TModel(_), "state") => argCount(2)(obj => args => ModelState(obj, args(0), args(1)))
- case (TModel(_), "abstractState") => argCount(1)(obj => args => ModelAbstractState(obj, args.head))
- case (TModel(_), "create") => argCount(1)(obj => args => ModelCreate(obj, args.head))
+ case (t: TNotAValue[G], _) =>
+ (t.decl.get, method) match {
+ case (RefModel(model), "create") => _ => _ => ModelNew(model.ref)
+ case (_, _) => return None
+ }
+
+ case (TModel(_), "state") =>
+ argCount(2)(obj => args => ModelState(obj, args(0), args(1)))
+ case (TModel(_), "abstractState") =>
+ argCount(1)(obj => args => ModelAbstractState(obj, args.head))
+ case (TModel(_), "create") =>
+ argCount(1)(obj => args => ModelCreate(obj, args.head))
case (TModel(_), "destroy") => argCount(0)(obj => _ => ModelDestroy(obj))
- case (TModel(_), "split") => argCount(4)(obj => args => ModelSplit(obj, args(0), args(1), args(2), args(3)))
- case (TModel(_), "merge") => argCount(4)(obj => args => ModelMerge(obj, args(0), args(1), args(2), args(3)))
- case (TModel(_), "choose") => argCount(3)(obj => args => ModelChoose(obj, args(0), args(1), args(2)))
-
- case (TSeq(_), "removeAt") => argCount(1)(obj => args => RemoveAt(obj, args.head))
- case (TSeq(_), "concat") => argCount(1)(obj => args => Concat(obj, args.head))
- case (TSeq(_), "prepend") => argCount(1)(obj => args => Cons(obj, args.head))
+ case (TModel(_), "split") =>
+ argCount(4)(obj =>
+ args => ModelSplit(obj, args(0), args(1), args(2), args(3))
+ )
+ case (TModel(_), "merge") =>
+ argCount(4)(obj =>
+ args => ModelMerge(obj, args(0), args(1), args(2), args(3))
+ )
+ case (TModel(_), "choose") =>
+ argCount(3)(obj => args => ModelChoose(obj, args(0), args(1), args(2)))
+
+ case (TSeq(_), "removeAt") =>
+ argCount(1)(obj => args => RemoveAt(obj, args.head))
+ case (TSeq(_), "concat") =>
+ argCount(1)(obj => args => Concat(obj, args.head))
+ case (TSeq(_), "prepend") =>
+ argCount(1)(obj => args => Cons(obj, args.head))
case (TSeq(_), "drop") => argCount(1)(obj => args => Drop(obj, args.head))
case (TSeq(_), "take") => argCount(1)(obj => args => Take(obj, args.head))
- case (TSeq(_), "slice") => argCount(2)(obj => args => Slice(obj, args(0), args(1)))
- case (TSeq(_), "update") => argCount(2)(obj => args => SeqUpdate(obj, args(0), args(1)))
- case (TSeq(_), "contains") => argCount(1)(obj => args => SeqMember(args.head, obj))
-
- case (TSet(_), "intersect") => argCount(1)(obj => args => SetIntersection(obj, args.head))
- case (TSet(_), "contains") => argCount(1)(obj => args => SetMember(args.head, obj))
- case (TSet(_), "difference") => argCount(1)(obj => args => SetMinus(obj, args.head))
- case (TSet(_), "union") => argCount(1)(obj => args => SetUnion(obj, args.head))
- case (TSet(_), "strictSubsetOf") => argCount(1)(obj => args => SubSet(obj, args.head))
- case (TSet(_), "subsetOf") => argCount(1)(obj => args => SubSetEq(obj, args.head))
-
- case (TBag(_), "sum") => argCount(1)(obj => args => BagAdd(obj, args.head))
- case (TBag(_), "intersect") => argCount(1)(obj => args => BagLargestCommon(obj, args.head))
- case (TBag(_), "count") => argCount(1)(obj => args => BagMemberCount(args.head, obj))
- case (TBag(_), "difference") => argCount(1)(obj => args => BagMinus(obj, args.head))
- case (TBag(_), "subbagOf") => argCount(1)(obj => args => SubBagEq(obj, args.head))
- case (TBag(_), "strictSubbagOf") => argCount(1)(obj => args => SubBag(obj, args.head))
-
- case (TMap(_, _), "add") => argCount(2)(obj => args => MapCons(obj, args(0), args(1)))
- case (TMap(_, _), "remove") => argCount(1)(obj => args => MapRemove(obj, args.head))
- case (TMap(_, _), "get") => argCount(1)(obj => args => MapGet(obj, args.head)(blame))
- case (TMap(_, _), "equals") => argCount(1)(obj => args => MapEq(obj, args.head))
- case (TMap(_, _), "disjoint") => argCount(1)(obj => args => MapDisjoint(obj, args.head))
-
- case (TOption(_), "getOrElse") => argCount(1)(obj => args => OptGetOrElse(obj, args.head))
+ case (TSeq(_), "slice") =>
+ argCount(2)(obj => args => Slice(obj, args(0), args(1)))
+ case (TSeq(_), "update") =>
+ argCount(2)(obj => args => SeqUpdate(obj, args(0), args(1)))
+ case (TSeq(_), "contains") =>
+ argCount(1)(obj => args => SeqMember(args.head, obj))
+
+ case (TSet(_), "intersect") =>
+ argCount(1)(obj => args => SetIntersection(obj, args.head))
+ case (TSet(_), "contains") =>
+ argCount(1)(obj => args => SetMember(args.head, obj))
+ case (TSet(_), "difference") =>
+ argCount(1)(obj => args => SetMinus(obj, args.head))
+ case (TSet(_), "union") =>
+ argCount(1)(obj => args => SetUnion(obj, args.head))
+ case (TSet(_), "strictSubsetOf") =>
+ argCount(1)(obj => args => SubSet(obj, args.head))
+ case (TSet(_), "subsetOf") =>
+ argCount(1)(obj => args => SubSetEq(obj, args.head))
+
+ case (TBag(_), "sum") =>
+ argCount(1)(obj => args => BagAdd(obj, args.head))
+ case (TBag(_), "intersect") =>
+ argCount(1)(obj => args => BagLargestCommon(obj, args.head))
+ case (TBag(_), "count") =>
+ argCount(1)(obj => args => BagMemberCount(args.head, obj))
+ case (TBag(_), "difference") =>
+ argCount(1)(obj => args => BagMinus(obj, args.head))
+ case (TBag(_), "subbagOf") =>
+ argCount(1)(obj => args => SubBagEq(obj, args.head))
+ case (TBag(_), "strictSubbagOf") =>
+ argCount(1)(obj => args => SubBag(obj, args.head))
+
+ case (TMap(_, _), "add") =>
+ argCount(2)(obj => args => MapCons(obj, args(0), args(1)))
+ case (TMap(_, _), "remove") =>
+ argCount(1)(obj => args => MapRemove(obj, args.head))
+ case (TMap(_, _), "get") =>
+ argCount(1)(obj => args => MapGet(obj, args.head)(blame))
+ case (TMap(_, _), "equals") =>
+ argCount(1)(obj => args => MapEq(obj, args.head))
+ case (TMap(_, _), "disjoint") =>
+ argCount(1)(obj => args => MapDisjoint(obj, args.head))
+
+ case (TOption(_), "getOrElse") =>
+ argCount(1)(obj => args => OptGetOrElse(obj, args.head))
case (_, _) => return None
}))
}
- def findLabel[G](name: String, ctx: ReferenceResolutionContext[G]): Option[LabelDecl[G]] =
+ def findLabel[G](
+ name: String,
+ ctx: ReferenceResolutionContext[G],
+ ): Option[LabelDecl[G]] =
ctx.stack.flatten.collectFirst {
case ref @ RefLabelDecl(decl) if ref.name == name => decl
}
- def findSend[G](name: String, ctx: ReferenceResolutionContext[G]): Option[SendDecl[G]] =
+ def findSend[G](
+ name: String,
+ ctx: ReferenceResolutionContext[G],
+ ): Option[SendDecl[G]] =
ctx.stack.flatten.collectFirst {
case ref @ RefSendDecl(decl) if ref.name == name => decl
}
- def findLocal[G](name: String, ctx: ReferenceResolutionContext[G]): Option[Variable[G]] =
+ def findLocal[G](
+ name: String,
+ ctx: ReferenceResolutionContext[G],
+ ): Option[Variable[G]] =
ctx.stack.flatten.collectFirst {
case ref @ RefVariable(decl) if ref.name == name => decl
}
- def findClass[G](name: String, ctx: TypeResolutionContext[G]): Option[Class[G]] =
+ def findClass[G](
+ name: String,
+ ctx: TypeResolutionContext[G],
+ ): Option[Class[G]] =
ctx.stack.flatten.collectFirst {
case ref @ RefClass(decl) if ref.name == name => decl
}
- def findModel[G](name: String, ctx: TypeResolutionContext[G]): Option[Model[G]] =
+ def findModel[G](
+ name: String,
+ ctx: TypeResolutionContext[G],
+ ): Option[Model[G]] =
ctx.stack.flatten.collectFirst {
case ref @ RefModel(decl) if ref.name == name => decl
}
- def findModelField[G](name: String, ctx: ReferenceResolutionContext[G]): Option[ModelField[G]] =
+ def findModelField[G](
+ name: String,
+ ctx: ReferenceResolutionContext[G],
+ ): Option[ModelField[G]] =
ctx.stack.flatten.collectFirst {
case ref @ RefModelField(decl) if ref.name == name => decl
}
- def findParBlock[G](name: String, ctx: ReferenceResolutionContext[G]): Option[ParBlockDecl[G]] =
+ def findParBlock[G](
+ name: String,
+ ctx: ReferenceResolutionContext[G],
+ ): Option[ParBlockDecl[G]] =
ctx.stack.flatten.collectFirst {
case ref @ RefParBlockDecl(decl) if ref.name == name => decl
}
- def findParInvariant[G](name: String, ctx: ReferenceResolutionContext[G]): Option[ParInvariantDecl[G]] =
+ def findParInvariant[G](
+ name: String,
+ ctx: ReferenceResolutionContext[G],
+ ): Option[ParInvariantDecl[G]] =
ctx.stack.flatten.collectFirst {
case ref @ RefParInvariantDecl(decl) if ref.name == name => decl
}
- def findAdt[G](name: String, ctx: TypeResolutionContext[G]): Option[AxiomaticDataType[G]] =
+ def findAdt[G](
+ name: String,
+ ctx: TypeResolutionContext[G],
+ ): Option[AxiomaticDataType[G]] =
ctx.stack.flatten.collectFirst {
case ref @ RefAxiomaticDataType(decl) if ref.name == name => decl
}
- def findAdtFunction[G](decl: AxiomaticDataType[G], name: String): Option[ADTFunction[G]] =
+ def findAdtFunction[G](
+ decl: AxiomaticDataType[G],
+ name: String,
+ ): Option[ADTFunction[G]] =
decl.decls.flatMap(Referrable.from).collectFirst {
case ref @ RefADTFunction(f) if ref.name == name => f
}
- def findAdtFunction[G](adtName: String, functionName: String, ctx: ReferenceResolutionContext[G]): Option[ADTFunction[G]] = {
+ def findAdtFunction[G](
+ adtName: String,
+ functionName: String,
+ ctx: ReferenceResolutionContext[G],
+ ): Option[ADTFunction[G]] = {
ctx.stack.flatten.collectFirst {
case ref @ RefAxiomaticDataType(adt) if ref.name == adtName => adt
}.flatMap(findAdtFunction(_, functionName))
}
- def findAdtFunction[G](name: String, ctx: ReferenceResolutionContext[G]): Option[(AxiomaticDataType[G], ADTFunction[G])] = {
- for(adt <- ctx.stack.flatten.collect { case RefAxiomaticDataType(adt) => adt }) {
+ def findAdtFunction[G](
+ name: String,
+ ctx: ReferenceResolutionContext[G],
+ ): Option[(AxiomaticDataType[G], ADTFunction[G])] = {
+ for (
+ adt <- ctx.stack.flatten.collect { case RefAxiomaticDataType(adt) => adt }
+ ) {
findAdtFunction(adt, name) match {
case Some(func) => return Some((adt, func))
case None =>
@@ -208,70 +314,97 @@ case object Spec {
None
}
- def findProcedure[G](name: String, ctx: ReferenceResolutionContext[G]): Option[Procedure[G]] =
+ def findProcedure[G](
+ name: String,
+ ctx: ReferenceResolutionContext[G],
+ ): Option[Procedure[G]] =
ctx.stack.flatten.collectFirst {
case ref @ RefProcedure(decl) if ref.name == name => decl
}
- def findFunction[G](name: String, ctx: ReferenceResolutionContext[G]): Option[Function[G]] =
+ def findFunction[G](
+ name: String,
+ ctx: ReferenceResolutionContext[G],
+ ): Option[Function[G]] =
ctx.stack.flatten.collectFirst {
case ref @ RefFunction(decl) if ref.name == name => decl
}
- def findPredicate[G](name: String, ctx: ReferenceResolutionContext[G]): Option[Predicate[G]] =
+ def findPredicate[G](
+ name: String,
+ ctx: ReferenceResolutionContext[G],
+ ): Option[Predicate[G]] =
ctx.stack.flatten.collectFirst {
case ref @ RefPredicate(decl) if ref.name == name => decl
}
- def findSilverField[G](name: String, ctx: ReferenceResolutionContext[G]): Option[SilverField[G]] =
+ def findSilverField[G](
+ name: String,
+ ctx: ReferenceResolutionContext[G],
+ ): Option[SilverField[G]] =
ctx.stack.flatten.collectFirst {
case ref @ RefSilverField(decl) if ref.name == name => decl
}
def findMethod[G](obj: Expr[G], name: String): Option[InstanceMethod[G]] =
obj.t match {
- case TClass(Ref(cls), _) => cls.decls.flatMap(Referrable.from).collectFirst {
- case ref @ RefInstanceMethod(decl) if ref.name == name => decl
- }
+ case TClass(Ref(cls), _) =>
+ cls.decls.flatMap(Referrable.from).collectFirst {
+ case ref @ RefInstanceMethod(decl) if ref.name == name => decl
+ }
case _ => None
}
- def findInstanceFunction[G](obj: Expr[G], name: String): Option[InstanceFunction[G]] =
+ def findInstanceFunction[G](
+ obj: Expr[G],
+ name: String,
+ ): Option[InstanceFunction[G]] =
obj.t match {
- case TClass(Ref(cls), _) => cls.decls.flatMap(Referrable.from).collectFirst {
- case ref @ RefInstanceFunction(decl) if ref.name == name => decl
- }
+ case TClass(Ref(cls), _) =>
+ cls.decls.flatMap(Referrable.from).collectFirst {
+ case ref @ RefInstanceFunction(decl) if ref.name == name => decl
+ }
case _ => None
}
- def findInstancePredicate[G](obj: Expr[G], name: String): Option[InstancePredicate[G]] =
+ def findInstancePredicate[G](
+ obj: Expr[G],
+ name: String,
+ ): Option[InstancePredicate[G]] =
obj.t match {
- case TClass(Ref(cls), _) => cls.decls.flatMap(Referrable.from).collectFirst {
- case ref @ RefInstancePredicate(decl) if ref.name == name => decl
- }
- case JavaTClass(Ref(cls), _) => cls.decls.flatMap(Referrable.from).collectFirst {
- case ref @ RefInstancePredicate(decl) if ref.name == name => decl
- }
+ case TClass(Ref(cls), _) =>
+ cls.decls.flatMap(Referrable.from).collectFirst {
+ case ref @ RefInstancePredicate(decl) if ref.name == name => decl
+ }
+ case JavaTClass(Ref(cls), _) =>
+ cls.decls.flatMap(Referrable.from).collectFirst {
+ case ref @ RefInstancePredicate(decl) if ref.name == name => decl
+ }
case _ => None
}
def findField[G](obj: Expr[G], name: String): Option[InstanceField[G]] =
obj.t match {
- case TClass(Ref(cls), _) => cls.decls.flatMap(Referrable.from).collectFirst {
- case ref @ RefField(decl) if ref.name == name => decl
- }
+ case TClass(Ref(cls), _) =>
+ cls.decls.flatMap(Referrable.from).collectFirst {
+ case ref @ RefField(decl) if ref.name == name => decl
+ }
case _ => None
}
def findModelField[G](obj: Expr[G], name: String): Option[ModelField[G]] =
obj.t match {
- case TModel(Ref(model)) => model.declarations.flatMap(Referrable.from).collectFirst {
- case ref @ RefModelField(decl) if ref.name == name => decl
- }
+ case TModel(Ref(model)) =>
+ model.declarations.flatMap(Referrable.from).collectFirst {
+ case ref @ RefModelField(decl) if ref.name == name => decl
+ }
case _ => None
}
- def findAdtTypeArg[G](adt: AxiomaticDataType[G], name: String): Option[Variable[G]] =
+ def findAdtTypeArg[G](
+ adt: AxiomaticDataType[G],
+ name: String,
+ ): Option[Variable[G]] =
adt.typeArgs.flatMap(Referrable.from).collectFirst {
case ref @ RefVariable(decl) if ref.name == name => decl
}
diff --git a/src/col/vct/col/resolve/lang/Util.scala b/src/col/vct/col/resolve/lang/Util.scala
index 3dbf845e66..5f5bbe91f2 100644
--- a/src/col/vct/col/resolve/lang/Util.scala
+++ b/src/col/vct/col/resolve/lang/Util.scala
@@ -3,34 +3,64 @@ package vct.col.resolve.lang
import vct.col.ast.{ContractApplicable, Expr, JavaParam, Type, Variable}
case object Util {
- def compatJavaParams[G](args: Seq[Expr[G]], params: Seq[JavaParam[G]]): Boolean =
- compatTypes(args, params.map(_.t))
+ def compatJavaParams[G](
+ args: Seq[Expr[G]],
+ params: Seq[JavaParam[G]],
+ ): Boolean = compatTypes(args, params.map(_.t))
def compat[G](args: Seq[Expr[G]], params: Seq[Variable[G]]): Boolean =
compatTypes(args, params.map(_.t))
- def compat[G](typeEnv: Map[Variable[G], Type[G]], args: Seq[Expr[G]], params: Seq[Variable[G]]): Boolean =
- compatTypes(typeEnv, args, params.map(_.t))
+ def compat[G](
+ typeEnv: Map[Variable[G], Type[G]],
+ args: Seq[Expr[G]],
+ params: Seq[Variable[G]],
+ ): Boolean = compatTypes(typeEnv, args, params.map(_.t))
def compatTypes[G](args: Seq[Expr[G]], types: Seq[Type[G]]): Boolean =
compatTypes[G](Map.empty[Variable[G], Type[G]], args, types)
- def compatTypes[G](typeEnv: Map[Variable[G], Type[G]], args: Seq[Expr[G]], types: Seq[Type[G]]): Boolean =
- args.size == types.size && types.zip(args).forall {
- case (t, e) => t.particularize(typeEnv).superTypeOf(e.t)
+ def compatTypes[G](
+ typeEnv: Map[Variable[G], Type[G]],
+ args: Seq[Expr[G]],
+ types: Seq[Type[G]],
+ ): Boolean =
+ args.size == types.size && types.zip(args).forall { case (t, e) =>
+ t.particularize(typeEnv).superTypeOf(e.t)
}
- def compat[G](args: Seq[Expr[G]], typeArgs: Seq[Type[G]], genericInvokable: ContractApplicable[G]): Boolean =
+ def compat[G](
+ args: Seq[Expr[G]],
+ typeArgs: Seq[Type[G]],
+ genericInvokable: ContractApplicable[G],
+ ): Boolean =
compat[G](Map.empty[Variable[G], Type[G]], args, typeArgs, genericInvokable)
- def compat[G](typeEnv: Map[Variable[G], Type[G]], args: Seq[Expr[G]], typeArgs: Seq[Type[G]], genericInvokable: ContractApplicable[G]): Boolean =
- compat(typeEnv, args, typeArgs, genericInvokable.args, genericInvokable.typeArgs)
+ def compat[G](
+ typeEnv: Map[Variable[G], Type[G]],
+ args: Seq[Expr[G]],
+ typeArgs: Seq[Type[G]],
+ genericInvokable: ContractApplicable[G],
+ ): Boolean =
+ compat(
+ typeEnv,
+ args,
+ typeArgs,
+ genericInvokable.args,
+ genericInvokable.typeArgs,
+ )
- def compat[G](typeEnv: Map[Variable[G], Type[G]], args: Seq[Expr[G]], typeArgs: Seq[Type[G]], params: Seq[Variable[G]], typeParams: Seq[Variable[G]]): Boolean = {
+ def compat[G](
+ typeEnv: Map[Variable[G], Type[G]],
+ args: Seq[Expr[G]],
+ typeArgs: Seq[Type[G]],
+ params: Seq[Variable[G]],
+ typeParams: Seq[Variable[G]],
+ ): Boolean = {
val env = typeEnv ++ typeParams.zip(typeArgs).toMap
args.size == params.size && typeArgs.size == typeParams.size &&
- params.zip(args).forall {
- case (v, e) => v.t.particularize(env).superTypeOf(e.t)
- }
+ params.zip(args).forall { case (v, e) =>
+ v.t.particularize(env).superTypeOf(e.t)
+ }
}
}
diff --git a/src/col/vct/col/rewrite/NonLatchingRewriter.scala b/src/col/vct/col/rewrite/NonLatchingRewriter.scala
index 4f35df0503..4331b3d127 100644
--- a/src/col/vct/col/rewrite/NonLatchingRewriter.scala
+++ b/src/col/vct/col/rewrite/NonLatchingRewriter.scala
@@ -5,7 +5,8 @@ import vct.col.ast.rewrite.BaseNonLatchingRewriter
import vct.col.util.CurrentRewriteProgramContext
import vct.result.VerificationError
-class NonLatchingRewriter[Pre, Post]() extends BaseNonLatchingRewriter[Pre, Post] {
+class NonLatchingRewriter[Pre, Post]()
+ extends BaseNonLatchingRewriter[Pre, Post] {
override def dispatch(program: Program[Pre]): Program[Post] =
VerificationError.withContext(CurrentRewriteProgramContext(program)) {
program.rewriteDefault()
@@ -13,4 +14,4 @@ class NonLatchingRewriter[Pre, Post]() extends BaseNonLatchingRewriter[Pre, Post
override def dispatch(decl: Declaration[Pre]): Unit =
allScopes.anySucceed(decl, decl.rewriteDefault())
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/rewrite/Rewriter.scala b/src/col/vct/col/rewrite/Rewriter.scala
index ec41101c1e..6a8f1061d5 100644
--- a/src/col/vct/col/rewrite/Rewriter.scala
+++ b/src/col/vct/col/rewrite/Rewriter.scala
@@ -2,6 +2,7 @@ package vct.col.rewrite
import vct.col.ast._
-class Rewriter[Pre <: Generation] extends NonLatchingRewriter[Pre, Rewritten[Pre]] {
+class Rewriter[Pre <: Generation]
+ extends NonLatchingRewriter[Pre, Rewritten[Pre]] {
type Post = Rewritten[Pre]
}
diff --git a/src/col/vct/col/rewrite/RewriterBuilder.scala b/src/col/vct/col/rewrite/RewriterBuilder.scala
index 007b58db4e..99c8893a76 100644
--- a/src/col/vct/col/rewrite/RewriterBuilder.scala
+++ b/src/col/vct/col/rewrite/RewriterBuilder.scala
@@ -2,27 +2,26 @@ package vct.col.rewrite
import vct.col.ast.AbstractRewriter
-/**
- * Defines how to construct a [[Rewriter]] for the transformation stage.
- *
- * If the rewriter needs arguments, refer to [[RewriterBuilderArg]]
- *
- * `key` is a short (user-facing) camelCase identifier for the rewriter.
- *
- * `desc` is a one-sentence description of the rewriter.
- *
- * `apply` defines how to construct the rewriter. Note that for case classes the companion object already defines
- * `apply` implicitly:
- *
- * {{{
- * case object Test extends RewriterBuilder {
- * def key: String = ???
- * def desc: String = ???
- * }
- *
- * case class Test[Pre <: Generation]() extends Rewriter[Pre]
- * }}}
- */
+/** Defines how to construct a [[Rewriter]] for the transformation stage.
+ *
+ * If the rewriter needs arguments, refer to [[RewriterBuilderArg]]
+ *
+ * `key` is a short (user-facing) camelCase identifier for the rewriter.
+ *
+ * `desc` is a one-sentence description of the rewriter.
+ *
+ * `apply` defines how to construct the rewriter. Note that for case classes
+ * the companion object already defines `apply` implicitly:
+ *
+ * {{{
+ * case object Test extends RewriterBuilder {
+ * def key: String = ???
+ * def desc: String = ???
+ * }
+ *
+ * case class Test[Pre <: Generation]() extends Rewriter[Pre]
+ * }}}
+ */
trait RewriterBuilder {
def apply[Pre <: Generation](): AbstractRewriter[Pre, _ <: Generation]
def key: String
diff --git a/src/col/vct/col/rewrite/RewriterBuilderArg.scala b/src/col/vct/col/rewrite/RewriterBuilderArg.scala
index 1a3b5747b4..9e0c8c20f7 100644
--- a/src/col/vct/col/rewrite/RewriterBuilderArg.scala
+++ b/src/col/vct/col/rewrite/RewriterBuilderArg.scala
@@ -2,52 +2,60 @@ package vct.col.rewrite
import vct.col.ast.AbstractRewriter
-/**
- * Defines how to construct a [[Rewriter]] for the transformation stage, when the rewriter takes an argument.
- *
- * Similarly to [[RewriterBuilder]], for case classes this shape of `apply` is implicitly defined:
- *
- * {{{
- * case object Test extends RewriterBuilderArg[Int] {
- * def key: String = ???
- * def desc: String = ???
- * }
- *
- * case class Test[Pre <: Generation](x: Int) extends Rewriter[Pre]
- * }}}
- *
- * @tparam T The type of the argument the rewriter takes.
- */
+/** Defines how to construct a [[Rewriter]] for the transformation stage, when
+ * the rewriter takes an argument.
+ *
+ * Similarly to [[RewriterBuilder]], for case classes this shape of `apply` is
+ * implicitly defined:
+ *
+ * {{{
+ * case object Test extends RewriterBuilderArg[Int] {
+ * def key: String = ???
+ * def desc: String = ???
+ * }
+ *
+ * case class Test[Pre <: Generation](x: Int) extends Rewriter[Pre]
+ * }}}
+ *
+ * @tparam T
+ * The type of the argument the rewriter takes.
+ */
trait RewriterBuilderArg[T] {
def apply[Pre <: Generation](x: T): AbstractRewriter[Pre, _ <: Generation]
def key: String
def desc: String
- /**
- * Constructs a [[RewriterBuilder]] with the argument to the rewriter pinned.
- * @param x The pinned parameter.
- */
+ /** Constructs a [[RewriterBuilder]] with the argument to the rewriter pinned.
+ * @param x
+ * The pinned parameter.
+ */
def withArg(x: T): RewriterBuilder =
new RewriterBuilder {
- override def apply[Pre <: Generation](): AbstractRewriter[Pre, _ <: Generation] = RewriterBuilderArg.this.apply(x)
+ override def apply[Pre <: Generation]()
+ : AbstractRewriter[Pre, _ <: Generation] =
+ RewriterBuilderArg.this.apply(x)
override def key: String = RewriterBuilderArg.this.key
override def desc: String = RewriterBuilderArg.this.desc
}
}
-/**
- * As RewriterBuilderArg, but with 2 parameters.
- * @tparam T
- * @tparam U
- */
+/** As RewriterBuilderArg, but with 2 parameters.
+ * @tparam T
+ * @tparam U
+ */
trait RewriterBuilderArg2[T, U] {
- def apply[Pre <: Generation](t: T, u: U): AbstractRewriter[Pre, _ <: Generation]
+ def apply[Pre <: Generation](
+ t: T,
+ u: U,
+ ): AbstractRewriter[Pre, _ <: Generation]
def key: String
def desc: String
def withArg(t: T, u: U): RewriterBuilder =
new RewriterBuilder {
- override def apply[Pre <: Generation](): AbstractRewriter[Pre, _ <: Generation] = RewriterBuilderArg2.this.apply(t, u)
+ override def apply[Pre <: Generation]()
+ : AbstractRewriter[Pre, _ <: Generation] =
+ RewriterBuilderArg2.this.apply(t, u)
override def key: String = RewriterBuilderArg2.this.key
override def desc: String = RewriterBuilderArg2.this.desc
}
diff --git a/src/col/vct/col/rewrite/SuccessorProvider.scala b/src/col/vct/col/rewrite/SuccessorProvider.scala
index b95f7ff75e..4ca3a9b086 100644
--- a/src/col/vct/col/rewrite/SuccessorProvider.scala
+++ b/src/col/vct/col/rewrite/SuccessorProvider.scala
@@ -5,9 +5,12 @@ import vct.col.ref.{LazyRef, Ref}
import scala.reflect.ClassTag
-trait SuccessorProvider[Pre, Post, PreDecl <: Declaration[Pre], PostDecl <: Declaration[Post]] {
+trait SuccessorProvider[Pre, Post, PreDecl <: Declaration[
+ Pre
+], PostDecl <: Declaration[Post]] {
def computeSucc(decl: PreDecl): Option[PostDecl]
- def succ[RefDecl <: Declaration[Post]](decl: PreDecl)(implicit tag: ClassTag[RefDecl]): Ref[Post, RefDecl] =
- new LazyRef(computeSucc(decl).get)
+ def succ[RefDecl <: Declaration[Post]](decl: PreDecl)(
+ implicit tag: ClassTag[RefDecl]
+ ): Ref[Post, RefDecl] = new LazyRef(computeSucc(decl).get)
}
diff --git a/src/col/vct/col/serialize/NodeMessageView.scala b/src/col/vct/col/serialize/NodeMessageView.scala
index 4171a439d9..fad708d3ae 100644
--- a/src/col/vct/col/serialize/NodeMessageView.scala
+++ b/src/col/vct/col/serialize/NodeMessageView.scala
@@ -4,7 +4,8 @@ import com.google.protobuf.CodedOutputStream
import vct.col.ast.{Declaration, Node}
import vct.serialize.StreamingOpaqueMessageBytes
-class NodeMessageView[G](node: Node[G], decls: Map[Declaration[G], Long]) extends StreamingOpaqueMessageBytes {
+class NodeMessageView[G](node: Node[G], decls: Map[Declaration[G], Long])
+ extends StreamingOpaqueMessageBytes {
lazy val message: scalapb.GeneratedMessage = node.serializeFamily(decls)
override def streamTo(output: CodedOutputStream): Unit =
diff --git a/src/col/vct/col/serialize/SerializeBlame.scala b/src/col/vct/col/serialize/SerializeBlame.scala
index e309225b8d..cd19ca94e1 100644
--- a/src/col/vct/col/serialize/SerializeBlame.scala
+++ b/src/col/vct/col/serialize/SerializeBlame.scala
@@ -6,8 +6,11 @@ import vct.col.ast.{serialize => ser}
import scala.annotation.unused
object SerializeBlame {
- def deserialize[T <: VerificationFailure](@unused blame: ser.Blame, origin: Origin): Blame[T] =
- origin
+ def deserialize[T <: VerificationFailure](
+ @unused
+ blame: ser.Blame,
+ origin: Origin,
+ ): Blame[T] = origin
def serialize(blame: Blame[_]): ser.Blame =
ser.Blame(ser.Blame.Blame.BlameInput(ser.BlameInput()))
diff --git a/src/col/vct/col/serialize/SerializeOrigin.scala b/src/col/vct/col/serialize/SerializeOrigin.scala
index 9e6c837110..86e479728c 100644
--- a/src/col/vct/col/serialize/SerializeOrigin.scala
+++ b/src/col/vct/col/serialize/SerializeOrigin.scala
@@ -6,24 +6,56 @@ import vct.col.origin._
import scala.annotation.unused
object SerializeOrigin {
- def deserialize(@unused origin: ser.Origin): Origin =
+ def deserialize(
+ @unused
+ origin: ser.Origin
+ ): Origin =
Origin(origin.content.map(_.content).map {
case ser.OriginContent.Content.SourceName(name) => SourceName(name.name)
- case ser.OriginContent.Content.PreferredName(name) => PreferredName(name.preferredName)
- case ser.OriginContent.Content.Context(context) => DeserializedContext(context.context, context.inlineContext, context.shortPosition)
+ case ser.OriginContent.Content.PreferredName(name) =>
+ PreferredName(name.preferredName)
+ case ser.OriginContent.Content.Context(context) =>
+ DeserializedContext(
+ context.context,
+ context.inlineContext,
+ context.shortPosition,
+ )
})
- def serialize(@unused origin: Origin): ser.Origin =
- ser.Origin(origin.originContents.flatMap {
- case SourceName(name) => Seq(ser.OriginContent.Content.SourceName(ser.SourceName(name)))
- case PreferredName(preferredName) => Seq(ser.OriginContent.Content.PreferredName(ser.PreferredName(preferredName)))
- case DeserializedContext(context, inlineContext, shortPosition) => Seq(ser.OriginContent.Content.Context(ser.Context(context, inlineContext, shortPosition)))
- case _ => Nil
- }.map(ser.OriginContent(_)))
+ def serialize(
+ @unused
+ origin: Origin
+ ): ser.Origin =
+ ser.Origin(
+ origin.originContents.flatMap {
+ case SourceName(name) =>
+ Seq(ser.OriginContent.Content.SourceName(ser.SourceName(name)))
+ case PreferredName(preferredName) =>
+ Seq(
+ ser.OriginContent.Content
+ .PreferredName(ser.PreferredName(preferredName))
+ )
+ case DeserializedContext(context, inlineContext, shortPosition) =>
+ Seq(
+ ser.OriginContent.Content
+ .Context(ser.Context(context, inlineContext, shortPosition))
+ )
+ case _ => Nil
+ }.map(ser.OriginContent(_))
+ )
}
-case class DeserializedContext(context: String, inlineContext: String, shortPosition: String) extends Context {
- override protected def contextHere(tail: Origin): (String, Origin) = (context, tail)
- override protected def inlineContextHere(tail: Origin, compress: Boolean): (String, Origin) = (inlineContext, tail)
- override protected def shortPositionHere(tail: Origin): (String, Origin) = (shortPosition, tail)
+case class DeserializedContext(
+ context: String,
+ inlineContext: String,
+ shortPosition: String,
+) extends Context {
+ override protected def contextHere(tail: Origin): (String, Origin) =
+ (context, tail)
+ override protected def inlineContextHere(
+ tail: Origin,
+ compress: Boolean,
+ ): (String, Origin) = (inlineContext, tail)
+ override protected def shortPositionHere(tail: Origin): (String, Origin) =
+ (shortPosition, tail)
}
diff --git a/src/col/vct/col/structure/family.scala b/src/col/vct/col/structure/family.scala
index 441cc09dca..f23b373d01 100644
--- a/src/col/vct/col/structure/family.scala
+++ b/src/col/vct/col/structure/family.scala
@@ -1,3 +1,3 @@
package vct.col.structure
-class family extends scala.annotation.Annotation
\ No newline at end of file
+class family extends scala.annotation.Annotation
diff --git a/src/col/vct/col/typerules/CoercingRewriter.scala b/src/col/vct/col/typerules/CoercingRewriter.scala
index ef76470d38..baf88034cf 100644
--- a/src/col/vct/col/typerules/CoercingRewriter.scala
+++ b/src/col/vct/col/typerules/CoercingRewriter.scala
@@ -12,20 +12,26 @@ import vct.col.util.AstBuildHelpers._
import vct.col.util.SuccessionMap
import vct.result.VerificationError.{SystemError, Unreachable}
-case class NopCoercingRewriter[Pre <: Generation]() extends CoercingRewriter[Pre]() {
- override def applyCoercion(e: => Expr[Post], coercion: Coercion[Pre])(implicit o: Origin): Expr[Post] = e
+case class NopCoercingRewriter[Pre <: Generation]()
+ extends CoercingRewriter[Pre]() {
+ override def applyCoercion(e: => Expr[Post], coercion: Coercion[Pre])(
+ implicit o: Origin
+ ): Expr[Post] = e
}
case object CoercingRewriter {
sealed trait CoercionError extends SystemError {
override def text: String =
messageContext(
- "Internal type error: CoercionErrors must not bubble. " + (this match {
- case IncoercibleDummy => "(No alternative matched, see stack trace)"
- case Incoercible(e, target) => s"Expression `$e` could not be coerced to `$target``"
- case IncoercibleText(e, target) => s"Expression `$e` could not be coerced to $target."
- case IncoercibleExplanation(e, message) => s"At `$e`: $message"
- })
+ "Internal type error: CoercionErrors must not bubble. " +
+ (this match {
+ case IncoercibleDummy => "(No alternative matched, see stack trace)"
+ case Incoercible(e, target) =>
+ s"Expression `$e` could not be coerced to `$target``"
+ case IncoercibleText(e, target) =>
+ s"Expression `$e` could not be coerced to $target."
+ case IncoercibleExplanation(e, message) => s"At `$e`: $message"
+ })
)
}
@@ -33,46 +39,66 @@ case object CoercingRewriter {
case class Incoercible(e: Expr[_], target: Type[_]) extends CoercionError
- case class IncoercibleText(e: Expr[_], targetText: String) extends CoercionError
+ case class IncoercibleText(e: Expr[_], targetText: String)
+ extends CoercionError
- case class IncoercibleExplanation(blame: Node[_], message: String) extends CoercionError
+ case class IncoercibleExplanation(blame: Node[_], message: String)
+ extends CoercionError
private def coercionOrigin(of: Expr[_]): Origin = of.o.where(name = "unknown")
}
-abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewriter[Pre, Rewritten[Pre]] with LazyLogging {
+abstract class CoercingRewriter[Pre <: Generation]()
+ extends BaseCoercingRewriter[Pre, Rewritten[Pre]] with LazyLogging {
import CoercingRewriter._
type Post = Rewritten[Pre]
- val coercedDeclaration: SuccessionMap[Declaration[Pre], Declaration[Pre]] = SuccessionMap()
+ val coercedDeclaration: SuccessionMap[Declaration[Pre], Declaration[Pre]] =
+ SuccessionMap()
- class CoercedSuccessorsProvider extends SuccessorsProviderTrafo[Pre, Pre](null) {
- override def preTransform[I <: Declaration[Pre], O <: Declaration[Pre]](pre: I): Option[O] =
- Some(coercedDeclaration(pre).asInstanceOf[O])
+ class CoercedSuccessorsProvider
+ extends SuccessorsProviderTrafo[Pre, Pre](null) {
+ override def preTransform[I <: Declaration[Pre], O <: Declaration[Pre]](
+ pre: I
+ ): Option[O] = Some(coercedDeclaration(pre).asInstanceOf[O])
}
override def succProvider: SuccessorsProvider[Pre, Post] =
SuccessorsProviderChain(new CoercedSuccessorsProvider, allScopes.freeze)
- /**
- * Apply a particular coercion to an expression.
- * SAFETY: all promoting coercions must be injective; otherwise the default mapping coercion of sets is unsound.
- * @param e the expression to coerce
- * @param coercion the coercion
- * @return the coerced expression
+ /** Apply a particular coercion to an expression. SAFETY: all promoting
+ * coercions must be injective; otherwise the default mapping coercion of
+ * sets is unsound.
+ * @param e
+ * the expression to coerce
+ * @param coercion
+ * the coercion
+ * @return
+ * the coerced expression
*/
- def applyCoercion(e: => Expr[Post], coercion: Coercion[Pre])(implicit o: Origin): Expr[Post] = {
+ def applyCoercion(e: => Expr[Post], coercion: Coercion[Pre])(
+ implicit o: Origin
+ ): Expr[Post] = {
coercion match {
case CoerceIdentity(_) => e
- case CoercionSequence(cs) => cs.foldLeft(e) { case (e, c) => applyCoercion(e, c) }
+ case CoercionSequence(cs) =>
+ cs.foldLeft(e) { case (e, c) => applyCoercion(e, c) }
case CoerceNothingSomething(_) => e
case CoerceSomethingAny(_) => e
case CoerceSomethingAnyValue(_) => e
case CoerceMapOption(inner, _, target) =>
- Select(OptEmpty(e), OptNoneTyped(dispatch(target)), OptSomeTyped(dispatch(target), applyCoercion(OptGet(e)(NeverNone), inner)))
+ Select(
+ OptEmpty(e),
+ OptNoneTyped(dispatch(target)),
+ OptSomeTyped(
+ dispatch(target),
+ applyCoercion(OptGet(e)(NeverNone), inner),
+ ),
+ )
case CoerceMapEither((innerLeft, innerRight), _, _) =>
- Select(IsRight(e),
+ Select(
+ IsRight(e),
EitherRight(applyCoercion(GetRight(e)(FramedGetRight), innerRight)),
EitherLeft(applyCoercion(GetLeft(e)(FramedGetLeft), innerLeft)),
)
@@ -89,16 +115,20 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
returnType = TSeq(dispatch(target)),
args = Seq(v),
ensures = UnitAccountedPredicate(
- Eq(Size(v.get), Size(result)) &&
- Forall(Seq(i), Seq(Seq(result_i)),
+ Eq(Size(v.get), Size(result)) && Forall(
+ Seq(i),
+ Seq(Seq(result_i)),
(const[Post](0) <= i.get && i.get < Size(result)) ==>
- (result_i === applyCoercion(v_i, inner)))
+ (result_i === applyCoercion(v_i, inner)),
+ )
),
)
})
globalDeclarations.declare(f)
- FunctionInvocation[Post](f.ref, Seq(e), Nil, Nil, Nil)(PanicBlame("default coercion for seq<_> requires nothing."))
+ FunctionInvocation[Post](f.ref, Seq(e), Nil, Nil, Nil)(PanicBlame(
+ "default coercion for seq<_> requires nothing."
+ ))
case CoerceMapSet(inner, source, target) =>
val f: Function[Post] = withResult((result: Result[Post]) => {
val v = new Variable(TSet(dispatch(source)))
@@ -110,15 +140,22 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
returnType = TSet(dispatch(target)),
args = Seq(v),
ensures = UnitAccountedPredicate(
- Eq(Size(result), Size(v.get)) &&
- Forall(Seq(elem), Seq(Seq(SetMember(elem.get, result))),
- Eq(SetMember(applyCoercion(elem.get, inner), result), SetMember(elem.get, v.get)))
+ Eq(Size(result), Size(v.get)) && Forall(
+ Seq(elem),
+ Seq(Seq(SetMember(elem.get, result))),
+ Eq(
+ SetMember(applyCoercion(elem.get, inner), result),
+ SetMember(elem.get, v.get),
+ ),
+ )
),
)
})
globalDeclarations.declare(f)
- FunctionInvocation[Post](f.ref, Seq(e), Nil, Nil, Nil)(PanicBlame("Default coercion for set<_> requires nothing."))
+ FunctionInvocation[Post](f.ref, Seq(e), Nil, Nil, Nil)(PanicBlame(
+ "Default coercion for set<_> requires nothing."
+ ))
case CoerceMapBag(inner, source, target) =>
val f: Function[Post] = withResult((result: Result[Post]) => {
val v = new Variable(TBag(dispatch(source)))
@@ -130,18 +167,28 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
returnType = TBag(dispatch(target)),
args = Seq(v),
ensures = UnitAccountedPredicate(
- Eq(Size(result), Size(v.get)) &&
- Forall(Seq(elem), Seq(Seq(BagMemberCount(elem.get, result))),
- Eq(BagMemberCount(applyCoercion(elem.get, inner), result), BagMemberCount(elem.get, v.get)))
+ Eq(Size(result), Size(v.get)) && Forall(
+ Seq(elem),
+ Seq(Seq(BagMemberCount(elem.get, result))),
+ Eq(
+ BagMemberCount(applyCoercion(elem.get, inner), result),
+ BagMemberCount(elem.get, v.get),
+ ),
+ )
),
)
})
globalDeclarations.declare(f)
- FunctionInvocation[Post](f.ref, Seq(e), Nil, Nil, Nil)(PanicBlame("Default coercion for bag<_> requires nothing."))
- case CoerceMapMatrix(inner, source, target) =>
- ???
- case CoerceMapMap(inner, (sourceKey, sourceValue), (targetKey, targetValue)) =>
+ FunctionInvocation[Post](f.ref, Seq(e), Nil, Nil, Nil)(PanicBlame(
+ "Default coercion for bag<_> requires nothing."
+ ))
+ case CoerceMapMatrix(inner, source, target) => ???
+ case CoerceMapMap(
+ inner,
+ (sourceKey, sourceValue),
+ (targetKey, targetValue),
+ ) =>
val f: Function[Post] = withResult((result: Result[Post]) => {
val v = new Variable(TMap(dispatch(sourceKey), dispatch(sourceValue)))
val k = new Variable(dispatch(sourceKey))
@@ -152,22 +199,39 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
returnType = TMap(dispatch(targetKey), dispatch(targetValue)),
args = Seq(v),
ensures = UnitAccountedPredicate(
- Eq(MapKeySet(result), MapKeySet(v.get)) &&
- Forall(Seq(k), Seq(Seq(MapGet(result, k.get)(TriggerPatternBlame))),
- SetMember(k.get, MapKeySet(result)) ==> Eq(MapGet(result, k.get)(FramedMapGet), MapGet(v.get, k.get)(FramedMapGet)))
+ Eq(MapKeySet(result), MapKeySet(v.get)) && Forall(
+ Seq(k),
+ Seq(Seq(MapGet(result, k.get)(TriggerPatternBlame))),
+ SetMember(k.get, MapKeySet(result)) ==> Eq(
+ MapGet(result, k.get)(FramedMapGet),
+ MapGet(v.get, k.get)(FramedMapGet),
+ ),
+ )
),
)
})
globalDeclarations.declare(f)
- FunctionInvocation[Post](f.ref, Seq(e), Nil, Nil, Nil)(PanicBlame("Default coercion for map<_, _> requires nothing."))
+ FunctionInvocation[Post](f.ref, Seq(e), Nil, Nil, Nil)(PanicBlame(
+ "Default coercion for map<_, _> requires nothing."
+ ))
case CoerceMapTuple(inner, sourceTypes, targetTypes) =>
- LiteralTuple(targetTypes.map(dispatch), inner.zipWithIndex.map { case (c, i) => applyCoercion(TupGet(e, i), c) })
- case CoerceMapType(inner, source, target) =>
- ???
- case CoerceMapVector(inner, sourceVectorElement, targetVectorElement, size) =>
+ LiteralTuple(
+ targetTypes.map(dispatch),
+ inner.zipWithIndex.map { case (c, i) =>
+ applyCoercion(TupGet(e, i), c)
+ },
+ )
+ case CoerceMapType(inner, source, target) => ???
+ case CoerceMapVector(
+ inner,
+ sourceVectorElement,
+ targetVectorElement,
+ size,
+ ) =>
val f: Function[Post] = withResult((result: Result[Post]) => {
- val v = new Variable[Post](TVector(size, dispatch(sourceVectorElement)))
+ val v =
+ new Variable[Post](TVector(size, dispatch(sourceVectorElement)))
val i = new Variable[Post](TInt())
val result_i = VectorSubscript(result, i.get)(FramedVectorIndex)
val v_i = VectorSubscript(v.get, i.get)(FramedVectorIndex)
@@ -177,16 +241,22 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
contractBlame = TrueSatisfiable,
returnType = TVector(size, dispatch(targetVectorElement)),
args = Seq(v),
- ensures = UnitAccountedPredicate(
- Forall(Seq(i), Seq(Seq(result_i)),
- (const[Post](0) <= i.get && i.get < const(size)) ==>
- (result_i === applyCoercion(v_i, inner)))
- ),
- )(o.where(name= "CoerceMapVector<" + sourceVectorElement.toString + "," + targetVectorElement.toString + ">"))
+ ensures = UnitAccountedPredicate(Forall(
+ Seq(i),
+ Seq(Seq(result_i)),
+ (const[Post](0) <= i.get && i.get < const(size)) ==>
+ (result_i === applyCoercion(v_i, inner)),
+ )),
+ )(o.where(name =
+ "CoerceMapVector<" + sourceVectorElement.toString + "," +
+ targetVectorElement.toString + ">"
+ ))
})
globalDeclarations.declare(f)
- FunctionInvocation[Post](f.ref, Seq(e), Nil, Nil, Nil)(PanicBlame("default coercion for vector<_> requires nothing."))
+ FunctionInvocation[Post](f.ref, Seq(e), Nil, Nil, Nil)(PanicBlame(
+ "default coercion for vector<_> requires nothing."
+ ))
case CoerceBoolResource() => e
case CoerceResourceResourceVal() => e
@@ -234,62 +304,64 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
}
}
- def coerceAny(node: NodeFamily[Pre]): NodeFamily[Pre] = node match {
- case node: Verification[Pre] => node
- case node: VerificationContext[Pre] => node
- case node: Program[Pre] => node
- case node: Statement[Pre] => coerce(node)
- case node: Expr[Pre] => coerce(node)
- case node: Type[Pre] => node
- case node: DecreasesClause[Pre] => node
- case node: AccountedPredicate[Pre] => node
- case node: ApplicableContract[Pre] => node
- case node: LoopContract[Pre] => node
- case node: ParRegion[Pre] => coerce(node)
- case node: CatchClause[Pre] => node
- case node: SignalsClause[Pre] => node
- case node: FieldFlag[Pre] => node
- case node: IterVariable[Pre] => node
- case node: CDeclaration[Pre] => node
- case node: CDeclarator[Pre] => node
- case node: CDeclarationSpecifier[Pre] => node
- case node: CTypeExtensions[Pre] => node
- case node: CTypeQualifier[Pre] => node
- case node: CPointer[Pre] => node
- case node: CInit[Pre] => node
- case node: CPPDeclarator[Pre] => node
- case node: CPPDeclarationSpecifier[Pre] => node
- case node: CPPDeclaration[Pre] => node
- case node: CPPAddressing[Pre] => node
- case node: CPPInit[Pre] => node
- case node: CPPExprOrTypeSpecifier[Pre] => node
- case node: GpuMemoryFence[Pre] => node
- case node: JavaModifier[Pre] => node
- case node: JavaImport[Pre] => node
- case node: JavaName[Pre] => node
- case node: JavaVariableDeclaration[Pre] => node
- case node: Coercion[Pre] => node
- case node: Location[Pre] => node
- case node: Operator[Pre] => node
- case node: BipPortType[Pre] => node
- case node: JavaBipGlueName[Pre] => node
- case node: JavaBipGlueElement[Pre] => node
- case node: BipGlueRequires[Pre] => node
- case node: BipGlueAccepts[Pre] => node
- case node: BipGlueDataWire[Pre] => node
- case node: BipTransitionSignature[Pre] => node
- case node: LlvmFunctionContract[Pre] => node
- case node: LlvmLoopContract[Pre] => node
- case node: ProverLanguage[Pre] => node
- case node: SmtlibFunctionSymbol[Pre] => node
- case node: ChorRun[Pre] => node
- case node: ChorGuard[Pre] => coerce(node)
- case node: PVLEndpointName[Pre] => coerce(node)
- case node: EndpointName[Pre] => coerce(node)
- }
+ def coerceAny(node: NodeFamily[Pre]): NodeFamily[Pre] =
+ node match {
+ case node: Verification[Pre] => node
+ case node: VerificationContext[Pre] => node
+ case node: Program[Pre] => node
+ case node: Statement[Pre] => coerce(node)
+ case node: Expr[Pre] => coerce(node)
+ case node: Type[Pre] => node
+ case node: DecreasesClause[Pre] => node
+ case node: AccountedPredicate[Pre] => node
+ case node: ApplicableContract[Pre] => node
+ case node: LoopContract[Pre] => node
+ case node: ParRegion[Pre] => coerce(node)
+ case node: CatchClause[Pre] => node
+ case node: SignalsClause[Pre] => node
+ case node: FieldFlag[Pre] => node
+ case node: IterVariable[Pre] => node
+ case node: CDeclaration[Pre] => node
+ case node: CDeclarator[Pre] => node
+ case node: CDeclarationSpecifier[Pre] => node
+ case node: CTypeExtensions[Pre] => node
+ case node: CTypeQualifier[Pre] => node
+ case node: CPointer[Pre] => node
+ case node: CInit[Pre] => node
+ case node: CPPDeclarator[Pre] => node
+ case node: CPPDeclarationSpecifier[Pre] => node
+ case node: CPPDeclaration[Pre] => node
+ case node: CPPAddressing[Pre] => node
+ case node: CPPInit[Pre] => node
+ case node: CPPExprOrTypeSpecifier[Pre] => node
+ case node: GpuMemoryFence[Pre] => node
+ case node: JavaModifier[Pre] => node
+ case node: JavaImport[Pre] => node
+ case node: JavaName[Pre] => node
+ case node: JavaVariableDeclaration[Pre] => node
+ case node: Coercion[Pre] => node
+ case node: Location[Pre] => node
+ case node: Operator[Pre] => node
+ case node: BipPortType[Pre] => node
+ case node: JavaBipGlueName[Pre] => node
+ case node: JavaBipGlueElement[Pre] => node
+ case node: BipGlueRequires[Pre] => node
+ case node: BipGlueAccepts[Pre] => node
+ case node: BipGlueDataWire[Pre] => node
+ case node: BipTransitionSignature[Pre] => node
+ case node: LlvmFunctionContract[Pre] => node
+ case node: LlvmLoopContract[Pre] => node
+ case node: ProverLanguage[Pre] => node
+ case node: SmtlibFunctionSymbol[Pre] => node
+ case node: ChorRun[Pre] => node
+ case node: ChorGuard[Pre] => coerce(node)
+ case node: PVLEndpointName[Pre] => coerce(node)
+ case node: EndpointName[Pre] => coerce(node)
+ }
def preCoerce(decl: Declaration[Pre]): Declaration[Pre] = decl
- def postCoerce(decl: Declaration[Pre]): Unit = allScopes.anySucceed(decl, decl.rewriteDefault())
+ def postCoerce(decl: Declaration[Pre]): Unit =
+ allScopes.anySucceed(decl, decl.rewriteDefault())
override final def dispatch(decl: Declaration[Pre]): Unit = {
val coercedDecl = coerce(preCoerce(decl))
coercedDeclaration(decl) = coercedDecl
@@ -300,33 +372,55 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
throw Unreachable("Coercions are rewritten by the Expr dispatch")
}
- def coerce(value: Expr[Pre], target: Type[Pre], canCDemote: Boolean = false): Expr[Pre] =
- ApplyCoercion(value, CoercionUtils.getAnyCoercion(value.t, target) match {
- case Some(coercion) if canCDemote || coercion.isCPromoting => coercion
- case _ => throw Incoercible(value, target)
- })(coercionOrigin(value))
+ def coerce(
+ value: Expr[Pre],
+ target: Type[Pre],
+ canCDemote: Boolean = false,
+ ): Expr[Pre] =
+ ApplyCoercion(
+ value,
+ CoercionUtils.getAnyCoercion(value.t, target) match {
+ case Some(coercion) if canCDemote || coercion.isCPromoting => coercion
+ case _ => throw Incoercible(value, target)
+ },
+ )(coercionOrigin(value))
def coerceArgs(args: Seq[Expr[Pre]], app: Applicable[Pre]): Seq[Expr[Pre]] =
- args.zip(app.args).map {
- case (value, arg) => coerce(value, arg.t)
- }
-
- def coerceArgs(args: Seq[Expr[Pre]], app: ContractApplicable[Pre], typeEnv: Map[Variable[Pre], Type[Pre]] = Map.empty, canCDemote: Boolean = false): Seq[Expr[Pre]] =
- args.zip(app.args).map {
- case (value, arg) => coerce(value, arg.t.particularize(typeEnv), canCDemote)
+ args.zip(app.args).map { case (value, arg) => coerce(value, arg.t) }
+
+ def coerceArgs(
+ args: Seq[Expr[Pre]],
+ app: ContractApplicable[Pre],
+ typeEnv: Map[Variable[Pre], Type[Pre]] = Map.empty,
+ canCDemote: Boolean = false,
+ ): Seq[Expr[Pre]] =
+ args.zip(app.args).map { case (value, arg) =>
+ coerce(value, arg.t.particularize(typeEnv), canCDemote)
}
- def coerceGiven(givenMap: Seq[(Ref[Pre, Variable[Pre]], Expr[Pre])], canCDemote: Boolean = false): Seq[(Ref[Pre, Variable[Pre]], Expr[Pre])] =
- givenMap.map {
- case (Ref(v), e) => (v.ref, coerce(e, v.t, canCDemote))
- }
-
- def coerceYields(yields: Seq[(Expr[Pre], Ref[Pre, Variable[Pre]])], blame: => Expr[_]): Seq[(Expr[Pre], Ref[Pre, Variable[Pre]])] =
- yields.map {
- case (target, Ref(yieldArg)) => CoercionUtils.getCoercion[Pre](yieldArg.t, target.t) match {
- case None => throw IncoercibleExplanation(blame, "The target for a yielded argument does not exactly match the yields type.")
+ def coerceGiven(
+ givenMap: Seq[(Ref[Pre, Variable[Pre]], Expr[Pre])],
+ canCDemote: Boolean = false,
+ ): Seq[(Ref[Pre, Variable[Pre]], Expr[Pre])] =
+ givenMap.map { case (Ref(v), e) => (v.ref, coerce(e, v.t, canCDemote)) }
+
+ def coerceYields(
+ yields: Seq[(Expr[Pre], Ref[Pre, Variable[Pre]])],
+ blame: => Expr[_],
+ ): Seq[(Expr[Pre], Ref[Pre, Variable[Pre]])] =
+ yields.map { case (target, Ref(yieldArg)) =>
+ CoercionUtils.getCoercion[Pre](yieldArg.t, target.t) match {
+ case None =>
+ throw IncoercibleExplanation(
+ blame,
+ "The target for a yielded argument does not exactly match the yields type.",
+ )
case Some(CoerceIdentity(_)) => (target, yieldArg.ref)
- case Some(_) => throw IncoercibleExplanation(blame, "The target for a yielded argument does not exactly match the yields type.")
+ case Some(_) =>
+ throw IncoercibleExplanation(
+ blame,
+ "The target for a yielded argument does not exactly match the yields type.",
+ )
}
}
@@ -336,12 +430,15 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
def int(e: Expr[Pre]): Expr[Pre] = coerce(e, TInt[Pre]())
def string(e: Expr[Pre]): Expr[Pre] = coerce(e, TString[Pre]())
def float(e: Expr[Pre]): Expr[Pre] =
- firstOk(e, "Expected float",
+ firstOk(
+ e,
+ "Expected float",
coerce(e, TFloats.ieee754_32bit[Pre]),
- coerce(e, TFloats.ieee754_64bit[Pre])
+ coerce(e, TFloats.ieee754_64bit[Pre]),
)
def floatOp2[T](e: BinExpr[Pre], f: (Expr[Pre], Expr[Pre]) => T): T = {
- val max = TFloats.getFloatMax(e.left.t, e.right.t).getOrElse(TFloats.ieee754_64bit[Pre])
+ val max = TFloats.getFloatMax(e.left.t, e.right.t)
+ .getOrElse(TFloats.ieee754_64bit[Pre])
f(coerce(e.left, max), coerce(e.right, max))
}
def process(e: Expr[Pre]): Expr[Pre] = coerce(e, TProcess[Pre]())
@@ -349,99 +446,132 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
def cls(e: Expr[Pre]): Expr[Pre] = coerce(e, TAnyClass[Pre]())
def option(e: Expr[Pre]): (Expr[Pre], TOption[Pre]) =
CoercionUtils.getAnyOptionCoercion(e.t) match {
- case Some((coercion, t)) => (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
+ case Some((coercion, t)) =>
+ (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
case None => throw IncoercibleText(e, s"option")
}
def tuple(e: Expr[Pre]): (Expr[Pre], TTuple[Pre]) =
CoercionUtils.getAnyTupleCoercion(e.t) match {
- case Some((coercion, t)) => (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
+ case Some((coercion, t)) =>
+ (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
case None => throw IncoercibleText(e, s"tuple")
}
def seq(e: Expr[Pre]): (Expr[Pre], TSeq[Pre]) =
CoercionUtils.getAnySeqCoercion(e.t) match {
- case Some((coercion, t)) => (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
+ case Some((coercion, t)) =>
+ (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
case None => throw IncoercibleText(e, s"sequence")
}
def set(e: Expr[Pre]): (Expr[Pre], TSet[Pre]) =
CoercionUtils.getAnySetCoercion(e.t) match {
- case Some((coercion, t)) => (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
+ case Some((coercion, t)) =>
+ (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
case None => throw IncoercibleText(e, s"set")
}
def vector(e: Expr[Pre]): (Expr[Pre], TVector[Pre]) =
CoercionUtils.getAnyVectorCoercion(e.t) match {
- case Some((coercion, t)) => (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
+ case Some((coercion, t)) =>
+ (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
case None => throw IncoercibleText(e, s"vector")
}
- def vectorType(e: Expr[Pre], elementType: Type[Pre], typeName: String): (Expr[Pre], TVector[Pre]) =
+ def vectorType(
+ e: Expr[Pre],
+ elementType: Type[Pre],
+ typeName: String,
+ ): (Expr[Pre], TVector[Pre]) =
CoercionUtils.getAnyVectorCoercion(e.t) match {
case Some((coercionOuter, t)) =>
CoercionUtils.getCoercion(t.element, elementType) match {
case Some(CoerceIdentity(_)) => (e, TVector(t.size, elementType))
case Some(coercionInner) =>
- val c = CoerceMapVector(coercionInner, t.element, elementType, t.size)(coercionOrigin(e))
- (ApplyCoercion(e, c)(coercionOrigin(e)), TVector(t.size, elementType))
+ val c =
+ CoerceMapVector(coercionInner, t.element, elementType, t.size)(
+ coercionOrigin(e)
+ )
+ (
+ ApplyCoercion(e, c)(coercionOrigin(e)),
+ TVector(t.size, elementType),
+ )
case None => throw IncoercibleText(e, s"$typeName vector")
}
case None => throw IncoercibleText(e, s"$typeName vector")
}
- def vectorInt(e: Expr[Pre]): (Expr[Pre], TVector[Pre]) = vectorType(e, TInt(), "int")
+ def vectorInt(e: Expr[Pre]): (Expr[Pre], TVector[Pre]) =
+ vectorType(e, TInt(), "int")
def vectorFloat(e: Expr[Pre]): (Expr[Pre], TVector[Pre]) =
- firstOk(e, "Expected float vector",
- vectorType(e, TFloats.ieee754_32bit[Pre], "float"),
- vectorType(e, TFloats.ieee754_64bit[Pre], "float")
+ firstOk(
+ e,
+ "Expected float vector",
+ vectorType(e, TFloats.ieee754_32bit[Pre], "float"),
+ vectorType(e, TFloats.ieee754_64bit[Pre], "float"),
)
- def vectorRational(e: Expr[Pre]): (Expr[Pre], TVector[Pre]) = vectorType(e, TRational(), "rational")
+ def vectorRational(e: Expr[Pre]): (Expr[Pre], TVector[Pre]) =
+ vectorType(e, TRational(), "rational")
def bag(e: Expr[Pre]): (Expr[Pre], TBag[Pre]) =
CoercionUtils.getAnyBagCoercion(e.t) match {
- case Some((coercion, t)) => (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
+ case Some((coercion, t)) =>
+ (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
case None => throw IncoercibleText(e, s"bag")
}
def map(e: Expr[Pre]): (Expr[Pre], TMap[Pre]) =
CoercionUtils.getAnyMapCoercion(e.t) match {
- case Some((coercion, t)) => (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
+ case Some((coercion, t)) =>
+ (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
case None => throw IncoercibleText(e, s"map")
}
def sized(e: Expr[Pre]): (Expr[Pre], SizedType[Pre]) =
CoercionUtils.getAnySizedCoercion(e.t) match {
- case Some((coercion, t)) => (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
+ case Some((coercion, t)) =>
+ (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
case None => throw IncoercibleText(e, s"collection type")
}
def array(e: Expr[Pre]): (Expr[Pre], TArray[Pre]) =
CoercionUtils.getAnyArrayCoercion(e.t) match {
- case Some((coercion, t)) => (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
+ case Some((coercion, t)) =>
+ (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
case None => throw IncoercibleText(e, s"array")
}
def arrayMatrix(e: Expr[Pre]): (Expr[Pre], TArray[Pre]) =
CoercionUtils.getAnyMatrixArrayCoercion(e.t) match {
- case Some((coercion, t)) => (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
+ case Some((coercion, t)) =>
+ (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
case None => throw IncoercibleText(e, s"two-dimensional array")
}
def pointer(e: Expr[Pre]): (Expr[Pre], TPointer[Pre]) =
CoercionUtils.getAnyPointerCoercion(e.t) match {
- case Some((coercion, t)) => (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
+ case Some((coercion, t)) =>
+ (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
case None => throw IncoercibleText(e, s"pointer")
}
def matrix(e: Expr[Pre]): (Expr[Pre], TMatrix[Pre]) =
CoercionUtils.getAnyMatrixCoercion(e.t) match {
- case Some((coercion, t)) => (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
+ case Some((coercion, t)) =>
+ (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
case None => throw IncoercibleText(e, s"matrix")
}
def model(e: Expr[Pre]): (Expr[Pre], TModel[Pre]) =
CoercionUtils.getAnyModelCoercion(e.t) match {
- case Some((coercion, t)) => (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
+ case Some((coercion, t)) =>
+ (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
case None => throw IncoercibleText(e, s"model")
}
def either(e: Expr[Pre]): (Expr[Pre], TEither[Pre]) =
CoercionUtils.getAnyEitherCoercion(e.t) match {
- case Some((coercion, t)) => (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
+ case Some((coercion, t)) =>
+ (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
case None => throw IncoercibleText(e, s"either")
}
def bitvec(e: Expr[Pre]): (Expr[Pre], TSmtlibBitVector[Pre]) =
CoercionUtils.getAnyBitvecCoercion(e.t) match {
- case Some((coercion, t)) => (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
+ case Some((coercion, t)) =>
+ (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
case None => throw IncoercibleText(e, s"(_ BitVec ?)")
}
- def bitvec2[T](e1: Expr[Pre], e2: Expr[Pre], f: (Expr[Pre], Expr[Pre]) => T): T = {
+ def bitvec2[T](
+ e1: Expr[Pre],
+ e2: Expr[Pre],
+ f: (Expr[Pre], Expr[Pre]) => T,
+ ): T = {
val (e1c, t) = bitvec(e1)
val e2c = coerce(e2, t)
f(e1c, e2c)
@@ -449,32 +579,51 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
def vectorIntOp2[T](e: BinExpr[Pre], f: (Expr[Pre], Expr[Pre]) => T): T = {
implicit val o: Origin = e.o
val (left, right) = (vectorInt(e.left), vectorInt(e.right))
- if (left._2.size != right._2.size) throw IncoercibleText(e, "This expression does not have a matching vector lengths")
+ if (left._2.size != right._2.size)
+ throw IncoercibleText(
+ e,
+ "This expression does not have a matching vector lengths",
+ )
f(left._1, right._1)
}
def vectorFloatOp2[T](e: BinExpr[Pre], f: (Expr[Pre], Expr[Pre]) => T): T = {
implicit val o: Origin = e.o
val (left, right) = (vectorFloat(e.left), vectorFloat(e.right))
- if (left._2.size != right._2.size) throw IncoercibleText(e, "This expression does not have a matching vector lengths")
+ if (left._2.size != right._2.size)
+ throw IncoercibleText(
+ e,
+ "This expression does not have a matching vector lengths",
+ )
f(left._1, right._1)
}
def vectorOp2[T](e: BinExpr[Pre], f: (Expr[Pre], Expr[Pre]) => T): T = {
implicit val o: Origin = e.o
- val (left, right) =
- firstOk(e, s"Expected both operands to be of type vector[integer or float or rational], but got ${e.left.t} and ${e.right.t}.",
- (vectorInt(e.left), vectorInt(e.right)),
- (vectorFloat(e.left), vectorFloat(e.right)),
- (vectorRational(e.left), vectorRational(e.right)),
+ val (left, right) = firstOk(
+ e,
+ s"Expected both operands to be of type vector[integer or float or rational], but got ${e
+ .left.t} and ${e.right.t}.",
+ (vectorInt(e.left), vectorInt(e.right)),
+ (vectorFloat(e.left), vectorFloat(e.right)),
+ (vectorRational(e.left), vectorRational(e.right)),
+ )
+ if (left._2.size != right._2.size)
+ throw IncoercibleText(
+ e,
+ "This expression does not have a matching vector lengths",
)
- if (left._2.size != right._2.size) throw IncoercibleText(e, "This expression does not have a matching vector lengths")
f(left._1, right._1)
}
def fp(e: Expr[Pre]): (Expr[Pre], TSmtlibFloatingPoint[Pre]) =
CoercionUtils.getAnySmtlibFloatCoercion(e.t) match {
- case Some((coercion, t)) => (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
+ case Some((coercion, t)) =>
+ (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
case None => throw IncoercibleText(e, s"(_ FloatingPoint ? ?)")
}
- def fp2[T](e1: Expr[Pre], e2: Expr[Pre], f: (Expr[Pre], Expr[Pre]) => T): T = {
+ def fp2[T](
+ e1: Expr[Pre],
+ e2: Expr[Pre],
+ f: (Expr[Pre], Expr[Pre]) => T,
+ ): T = {
val (e1c, t) = fp(e1)
val e2c = coerce(e2, t)
f(e1c, e2c)
@@ -483,91 +632,98 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
def smtstr(e: Expr[Pre]): Expr[Pre] = coerce(e, TSmtlibString())
def smtarr(e: Expr[Pre]): (Expr[Pre], TSmtlibArray[Pre]) =
CoercionUtils.getAnySmtlibArrayCoercion(e.t) match {
- case Some((coercion, t)) => (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
+ case Some((coercion, t)) =>
+ (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
case None => throw IncoercibleText(e, s"(Array ? ?)")
}
def z3seq(e: Expr[Pre]): (Expr[Pre], TSmtlibSeq[Pre]) =
CoercionUtils.getAnySmtlibSeqCoercion(e.t) match {
- case Some((coercion, t)) => (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
+ case Some((coercion, t)) =>
+ (ApplyCoercion(e, coercion)(coercionOrigin(e)), t)
case None => throw IncoercibleText(e, s"(Seq ?)")
}
def arity(t: TClass[Pre]): TClass[Pre] =
- if (t.cls.decl.typeArgs.length == t.typeArgs.length) t
- else throw IncoercibleExplanation(t, s"type has ${t.typeArgs.length} type arguments, but class definition has ${t.cls.decl.typeArgs.length} type arguments")
+ if (t.cls.decl.typeArgs.length == t.typeArgs.length)
+ t
+ else
+ throw IncoercibleExplanation(
+ t,
+ s"type has ${t.typeArgs.length} type arguments, but class definition has ${t
+ .cls.decl.typeArgs.length} type arguments",
+ )
def arity(inv: Invocation[Pre]): Invocation[Pre] = {
if (inv.ref.decl.typeArgs.length != inv.typeArgs.length) {
- throw IncoercibleExplanation(inv, s"expected ${inv.ref.decl.typeArgs.length} type arguments, got ${inv.typeArgs.length} type arguments")
+ throw IncoercibleExplanation(
+ inv,
+ s"expected ${inv.ref.decl.typeArgs.length} type arguments, got ${inv.typeArgs.length} type arguments",
+ )
}
if (inv.ref.decl.args.length != inv.args.length) {
- throw IncoercibleExplanation(inv, s"expected ${inv.ref.decl.typeArgs.length} type arguments, got ${inv.typeArgs.length} type arguments")
+ throw IncoercibleExplanation(
+ inv,
+ s"expected ${inv.ref.decl.typeArgs.length} type arguments, got ${inv.typeArgs.length} type arguments",
+ )
}
inv
}
- def firstOkHelper[T](thing: Either[Seq[CoercionError], T], onError: => T): Either[Seq[CoercionError], T] =
+ def firstOkHelper[T](
+ thing: Either[Seq[CoercionError], T],
+ onError: => T,
+ ): Either[Seq[CoercionError], T] =
thing match {
- case Left(errs) => try {
- Right(onError)
- } catch {
- case err: CoercionError => Left(errs :+ err)
- }
+ case Left(errs) =>
+ try { Right(onError) }
+ catch { case err: CoercionError => Left(errs :+ err) }
case Right(value) => Right(value)
}
implicit class FirstOkHelper[T](res: Either[Seq[CoercionError], T]) {
def onCoercionError(f: => T): Either[Seq[CoercionError], T] =
res match {
- case Left(errs) => try {
- Right(f)
- } catch {
- case err: CoercionError => Left(errs :+ err)
- }
+ case Left(errs) =>
+ try { Right(f) }
+ catch { case err: CoercionError => Left(errs :+ err) }
case Right(value) => Right(value)
}
}
- def firstOk[T](expr: Expr[Pre], message: => String,
- alt1: => T = throw IncoercibleDummy,
- alt2: => T = throw IncoercibleDummy,
- alt3: => T = throw IncoercibleDummy,
- alt4: => T = throw IncoercibleDummy,
- alt5: => T = throw IncoercibleDummy,
- alt6: => T = throw IncoercibleDummy,
- alt7: => T = throw IncoercibleDummy,
- alt8: => T = throw IncoercibleDummy,
- alt9: => T = throw IncoercibleDummy,
- alt10: => T = throw IncoercibleDummy,
- alt11: => T = throw IncoercibleDummy,
- alt12: => T = throw IncoercibleDummy) : T = {
- Left(Nil)
- .onCoercionError(alt1)
- .onCoercionError(alt2)
- .onCoercionError(alt3)
- .onCoercionError(alt4)
- .onCoercionError(alt5)
- .onCoercionError(alt6)
- .onCoercionError(alt7)
- .onCoercionError(alt8)
- .onCoercionError(alt9)
- .onCoercionError(alt10)
- .onCoercionError(alt11)
- .onCoercionError(alt12)
- match {
+ def firstOk[T](
+ expr: Expr[Pre],
+ message: => String,
+ alt1: => T = throw IncoercibleDummy,
+ alt2: => T = throw IncoercibleDummy,
+ alt3: => T = throw IncoercibleDummy,
+ alt4: => T = throw IncoercibleDummy,
+ alt5: => T = throw IncoercibleDummy,
+ alt6: => T = throw IncoercibleDummy,
+ alt7: => T = throw IncoercibleDummy,
+ alt8: => T = throw IncoercibleDummy,
+ alt9: => T = throw IncoercibleDummy,
+ alt10: => T = throw IncoercibleDummy,
+ alt11: => T = throw IncoercibleDummy,
+ alt12: => T = throw IncoercibleDummy,
+ ): T = {
+ Left(Nil).onCoercionError(alt1).onCoercionError(alt2).onCoercionError(alt3)
+ .onCoercionError(alt4).onCoercionError(alt5).onCoercionError(alt6)
+ .onCoercionError(alt7).onCoercionError(alt8).onCoercionError(alt9)
+ .onCoercionError(alt10).onCoercionError(alt11)
+ .onCoercionError(alt12) match {
case Left(errs) =>
- for(err <- errs) {
- logger.debug(err.text)
- }
+ for (err <- errs) { logger.debug(err.text) }
throw IncoercibleExplanation(expr, message)
case Right(value) => value
}
}
- override def postCoerce(e: Expr[Pre]): Expr[Post] = e match {
- case ApplyCoercion(e, coercion) => applyCoercion(dispatch(e), coercion)(e.o)
- case e => e.rewriteDefault()
- }
+ override def postCoerce(e: Expr[Pre]): Expr[Post] =
+ e match {
+ case ApplyCoercion(e, coercion) =>
+ applyCoercion(dispatch(e), coercion)(e.o)
+ case e => e.rewriteDefault()
+ }
def coerce(e: Expr[Pre]): Expr[Pre] = {
implicit val o: Origin = e.o
@@ -577,288 +733,438 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
case ActionApply(action, args) =>
ActionApply(action, coerceArgs(args, action.decl))
- case ActionPerm(loc, perm) =>
- ActionPerm(loc, rat(perm))
- case AddrOf(e) =>
- AddrOf(e)
- case ADTFunctionInvocation(typeArgs, ref, args) => typeArgs match {
- case Some((adt, typeArgs)) =>
- ADTFunctionInvocation(Some((adt, typeArgs)), ref, args.zip(ref.decl.args).map {
- case (value, arg) =>
- try {
- coerce(value, arg.t.particularize(adt.decl.typeArgs.zip(typeArgs).toMap))
- } catch {
- case x: CoercionError =>
- println(x.text)
- ???
- }
- })
- case None =>
- ADTFunctionInvocation(None, ref, coerceArgs(args, ref.decl))
- }
+ case ActionPerm(loc, perm) => ActionPerm(loc, rat(perm))
+ case AddrOf(e) => AddrOf(e)
+ case ADTFunctionInvocation(typeArgs, ref, args) =>
+ typeArgs match {
+ case Some((adt, typeArgs)) =>
+ ADTFunctionInvocation(
+ Some((adt, typeArgs)),
+ ref,
+ args.zip(ref.decl.args).map { case (value, arg) =>
+ try {
+ coerce(
+ value,
+ arg.t.particularize(adt.decl.typeArgs.zip(typeArgs).toMap),
+ )
+ } catch {
+ case x: CoercionError =>
+ println(x.text)
+ ???
+ }
+ },
+ )
+ case None =>
+ ADTFunctionInvocation(None, ref, coerceArgs(args, ref.decl))
+ }
case AmbiguousComputationalAnd(left, right) =>
- firstOk(e, s"Expected both operands to be of type integer or boolean, but got ${left.t} and ${right.t}.",
+ firstOk(
+ e,
+ s"Expected both operands to be of type integer or boolean, but got ${left
+ .t} and ${right.t}.",
AmbiguousComputationalAnd(int(left), int(right)),
AmbiguousComputationalAnd(bool(left), bool(right)),
)
case AmbiguousComputationalOr(left, right) =>
- firstOk(e, s"Expected both operands to be of type integer or boolean, but got ${left.t} and ${right.t}.",
+ firstOk(
+ e,
+ s"Expected both operands to be of type integer or boolean, but got ${left
+ .t} and ${right.t}.",
AmbiguousComputationalOr(int(left), int(right)),
AmbiguousComputationalOr(bool(left), bool(right)),
)
case AmbiguousComputationalXor(left, right) =>
- firstOk(e, s"Expected both operands to be of type integer or boolean, but got ${left.t} and ${right.t}.",
+ firstOk(
+ e,
+ s"Expected both operands to be of type integer or boolean, but got ${left
+ .t} and ${right.t}.",
AmbiguousComputationalXor(int(left), int(right)),
AmbiguousComputationalXor(bool(left), bool(right)),
)
- case div@AmbiguousDiv(left, right) =>
- firstOk(e, s"Expected both operands to be int, float, vector[int] or vector[float], but got ${left.t} and ${right.t}.",
+ case div @ AmbiguousDiv(left, right) =>
+ firstOk(
+ e,
+ s"Expected both operands to be int, float, vector[int] or vector[float], but got ${left
+ .t} and ${right.t}.",
AmbiguousDiv(int(left), int(right))(div.blame),
- floatOp2(div, (l,r) => AmbiguousDiv(l, r)(div.blame)),
- vectorIntOp2(div, (l,r) => AmbiguousDiv(l ,r)(div.blame)),
- vectorFloatOp2(div, (l,r) => AmbiguousDiv(l ,r)(div.blame)),
+ floatOp2(div, (l, r) => AmbiguousDiv(l, r)(div.blame)),
+ vectorIntOp2(div, (l, r) => AmbiguousDiv(l, r)(div.blame)),
+ vectorFloatOp2(div, (l, r) => AmbiguousDiv(l, r)(div.blame)),
)
case AmbiguousEq(left, right, vectorInnerType) =>
val sharedType = Types.leastCommonSuperType(left.t, right.t)
- AmbiguousEq(coerce(left, sharedType), coerce(right, sharedType), vectorInnerType)
- case g@AmbiguousGreater(left, right) =>
- firstOk(e, s"Expected both operands to be numeric, a set, or a bag, but got ${left.t} and ${right.t}.",
+ AmbiguousEq(
+ coerce(left, sharedType),
+ coerce(right, sharedType),
+ vectorInnerType,
+ )
+ case g @ AmbiguousGreater(left, right) =>
+ firstOk(
+ e,
+ s"Expected both operands to be numeric, a set, or a bag, but got ${left
+ .t} and ${right.t}.",
AmbiguousGreater(int(left), int(right)),
- floatOp2(g, (l,r) => AmbiguousGreater(l, r)),
+ floatOp2(g, (l, r) => AmbiguousGreater(l, r)),
AmbiguousGreater(rat(left), rat(right)), {
val (coercedLeft, leftSet) = set(left)
val (coercedRight, rightSet) = set(right)
- val sharedType = Types.leastCommonSuperType(leftSet.element, rightSet.element)
- AmbiguousGreater(coerce(coercedLeft, TSet(sharedType)), coerce(coercedRight, TSet(sharedType)))
+ val sharedType = Types
+ .leastCommonSuperType(leftSet.element, rightSet.element)
+ AmbiguousGreater(
+ coerce(coercedLeft, TSet(sharedType)),
+ coerce(coercedRight, TSet(sharedType)),
+ )
}, {
val (coercedLeft, leftBag) = bag(left)
val (coercedRight, rightBag) = bag(right)
- val sharedType = Types.leastCommonSuperType(leftBag.element, rightBag.element)
- AmbiguousGreater(coerce(coercedLeft, TBag(sharedType)), coerce(coercedRight, TBag(sharedType)))
+ val sharedType = Types
+ .leastCommonSuperType(leftBag.element, rightBag.element)
+ AmbiguousGreater(
+ coerce(coercedLeft, TBag(sharedType)),
+ coerce(coercedRight, TBag(sharedType)),
+ )
},
)
- case g@AmbiguousGreaterEq(left, right) =>
- firstOk(e, s"Expected both operands to be numeric, a set, or a bag, but got ${left.t} and ${right.t}.",
+ case g @ AmbiguousGreaterEq(left, right) =>
+ firstOk(
+ e,
+ s"Expected both operands to be numeric, a set, or a bag, but got ${left
+ .t} and ${right.t}.",
AmbiguousGreaterEq(int(left), int(right)),
- floatOp2(g, (l,r) => AmbiguousGreaterEq(l, r)),
+ floatOp2(g, (l, r) => AmbiguousGreaterEq(l, r)),
AmbiguousGreaterEq(rat(left), rat(right)), {
val (coercedLeft, leftSet) = set(left)
val (coercedRight, rightSet) = set(right)
- val sharedType = Types.leastCommonSuperType(leftSet.element, rightSet.element)
- AmbiguousGreaterEq(coerce(coercedLeft, TSet(sharedType)), coerce(coercedRight, TSet(sharedType)))
+ val sharedType = Types
+ .leastCommonSuperType(leftSet.element, rightSet.element)
+ AmbiguousGreaterEq(
+ coerce(coercedLeft, TSet(sharedType)),
+ coerce(coercedRight, TSet(sharedType)),
+ )
}, {
val (coercedLeft, leftBag) = bag(left)
val (coercedRight, rightBag) = bag(right)
- val sharedType = Types.leastCommonSuperType(leftBag.element, rightBag.element)
- AmbiguousGreaterEq(coerce(coercedLeft, TBag(sharedType)), coerce(coercedRight, TBag(sharedType)))
+ val sharedType = Types
+ .leastCommonSuperType(leftBag.element, rightBag.element)
+ AmbiguousGreaterEq(
+ coerce(coercedLeft, TBag(sharedType)),
+ coerce(coercedRight, TBag(sharedType)),
+ )
},
)
- case l@AmbiguousLess(left, right) =>
- firstOk(e, s"Expected both operands to be numeric, a set, or a bag, but got ${left.t} and ${right.t}.",
+ case l @ AmbiguousLess(left, right) =>
+ firstOk(
+ e,
+ s"Expected both operands to be numeric, a set, or a bag, but got ${left
+ .t} and ${right.t}.",
AmbiguousLess(int(left), int(right)),
- floatOp2(l, (l,r) => AmbiguousLess(l, r)),
+ floatOp2(l, (l, r) => AmbiguousLess(l, r)),
AmbiguousLess(rat(left), rat(right)), {
val (coercedLeft, leftSet) = set(left)
val (coercedRight, rightSet) = set(right)
- val sharedType = Types.leastCommonSuperType(leftSet.element, rightSet.element)
- AmbiguousLess(coerce(coercedLeft, TSet(sharedType)), coerce(coercedRight, TSet(sharedType)))
+ val sharedType = Types
+ .leastCommonSuperType(leftSet.element, rightSet.element)
+ AmbiguousLess(
+ coerce(coercedLeft, TSet(sharedType)),
+ coerce(coercedRight, TSet(sharedType)),
+ )
}, {
val (coercedLeft, leftBag) = bag(left)
val (coercedRight, rightBag) = bag(right)
- val sharedType = Types.leastCommonSuperType(leftBag.element, rightBag.element)
- AmbiguousLess(coerce(coercedLeft, TBag(sharedType)), coerce(coercedRight, TBag(sharedType)))
+ val sharedType = Types
+ .leastCommonSuperType(leftBag.element, rightBag.element)
+ AmbiguousLess(
+ coerce(coercedLeft, TBag(sharedType)),
+ coerce(coercedRight, TBag(sharedType)),
+ )
},
)
- case l@AmbiguousLessEq(left, right) =>
- firstOk(e, s"Expected both operands to be numeric, a set, or a bag, but got ${left.t} and ${right.t}.",
+ case l @ AmbiguousLessEq(left, right) =>
+ firstOk(
+ e,
+ s"Expected both operands to be numeric, a set, or a bag, but got ${left
+ .t} and ${right.t}.",
AmbiguousLessEq(int(left), int(right)),
- floatOp2(l, (l,r) => AmbiguousLessEq(l, r)),
+ floatOp2(l, (l, r) => AmbiguousLessEq(l, r)),
AmbiguousLessEq(rat(left), rat(right)), {
val (coercedLeft, leftSet) = set(left)
val (coercedRight, rightSet) = set(right)
- val sharedType = Types.leastCommonSuperType(leftSet.element, rightSet.element)
- AmbiguousLessEq(coerce(coercedLeft, TSet(sharedType)), coerce(coercedRight, TSet(sharedType)))
+ val sharedType = Types
+ .leastCommonSuperType(leftSet.element, rightSet.element)
+ AmbiguousLessEq(
+ coerce(coercedLeft, TSet(sharedType)),
+ coerce(coercedRight, TSet(sharedType)),
+ )
}, {
val (coercedLeft, leftBag) = bag(left)
val (coercedRight, rightBag) = bag(right)
- val sharedType = Types.leastCommonSuperType(leftBag.element, rightBag.element)
- AmbiguousLessEq(coerce(coercedLeft, TBag(sharedType)), coerce(coercedRight, TBag(sharedType)))
+ val sharedType = Types
+ .leastCommonSuperType(leftBag.element, rightBag.element)
+ AmbiguousLessEq(
+ coerce(coercedLeft, TBag(sharedType)),
+ coerce(coercedRight, TBag(sharedType)),
+ )
},
)
case minus @ AmbiguousMinus(left, right) =>
- firstOk(e, s"Expected both operands to be numeric, a numeric vector, a set or a bag; or a pointer and integer, but got ${left.t} and ${right.t}.",
+ firstOk(
+ e,
+ s"Expected both operands to be numeric, a numeric vector, a set or a bag; or a pointer and integer, but got ${left
+ .t} and ${right.t}.",
Minus(int(left), int(right)),
- floatOp2(minus, (l,r) => Minus(l, r)),
- Minus(rat(left), rat(right)), {
- vectorOp2(minus, (l,r) => AmbiguousMinus(l,r)(minus.blame))
- },
+ floatOp2(minus, (l, r) => Minus(l, r)),
+ Minus(rat(left), rat(right)),
+ { vectorOp2(minus, (l, r) => AmbiguousMinus(l, r)(minus.blame)) },
AmbiguousMinus(pointer(left)._1, int(right))(minus.blame), {
val (coercedLeft, TSet(elementLeft)) = set(left)
val (coercedRight, TSet(elementRight)) = set(right)
- val sharedType = Types.leastCommonSuperType(elementLeft, elementRight)
- AmbiguousMinus(coerce(coercedLeft, TSet(sharedType)), coerce(coercedRight, TSet(sharedType)))(minus.blame)
+ val sharedType = Types
+ .leastCommonSuperType(elementLeft, elementRight)
+ AmbiguousMinus(
+ coerce(coercedLeft, TSet(sharedType)),
+ coerce(coercedRight, TSet(sharedType)),
+ )(minus.blame)
}, {
val (coercedLeft, TBag(elementLeft)) = bag(left)
val (coercedRight, TBag(elementRight)) = bag(right)
- val sharedType = Types.leastCommonSuperType(elementLeft, elementRight)
- AmbiguousMinus(coerce(coercedLeft, TBag(sharedType)), coerce(coercedRight, TBag(sharedType)))(minus.blame)
- }
+ val sharedType = Types
+ .leastCommonSuperType(elementLeft, elementRight)
+ AmbiguousMinus(
+ coerce(coercedLeft, TBag(sharedType)),
+ coerce(coercedRight, TBag(sharedType)),
+ )(minus.blame)
+ },
)
case AmbiguousMember(x, xs) =>
- firstOk(xs, s"Expected collection to be a sequence, set, bag or map, but got ${xs.t}.", {
- val (coercedXs, TSeq(element)) = seq(xs)
- val sharedType = Types.leastCommonSuperType(x.t, element)
- AmbiguousMember(coerce(x, sharedType), coerce(coercedXs, TSeq(sharedType)))
- }, {
- val (coercedXs, TSet(element)) = set(xs)
- val sharedType = Types.leastCommonSuperType(x.t, element)
- AmbiguousMember(coerce(x, sharedType), coerce(coercedXs, TSet(sharedType)))
- }, {
- val (coercedXs, TBag(element)) = bag(xs)
- val sharedType = Types.leastCommonSuperType(x.t, element)
- AmbiguousMember(coerce(x, sharedType), coerce(coercedXs, TBag(sharedType)))
- }, {
- val (coercedXs, TMap(element, _)) = map(xs)
- AmbiguousMember(coerce(x, element), coercedXs)
- })
- case mod@AmbiguousMod(left, right) =>
- firstOk(e, s"Expected both operands to be ints or vector[int], but got ${left.t} and ${right.t}.",
+ firstOk(
+ xs,
+ s"Expected collection to be a sequence, set, bag or map, but got ${xs.t}.", {
+ val (coercedXs, TSeq(element)) = seq(xs)
+ val sharedType = Types.leastCommonSuperType(x.t, element)
+ AmbiguousMember(
+ coerce(x, sharedType),
+ coerce(coercedXs, TSeq(sharedType)),
+ )
+ }, {
+ val (coercedXs, TSet(element)) = set(xs)
+ val sharedType = Types.leastCommonSuperType(x.t, element)
+ AmbiguousMember(
+ coerce(x, sharedType),
+ coerce(coercedXs, TSet(sharedType)),
+ )
+ }, {
+ val (coercedXs, TBag(element)) = bag(xs)
+ val sharedType = Types.leastCommonSuperType(x.t, element)
+ AmbiguousMember(
+ coerce(x, sharedType),
+ coerce(coercedXs, TBag(sharedType)),
+ )
+ }, {
+ val (coercedXs, TMap(element, _)) = map(xs)
+ AmbiguousMember(coerce(x, element), coercedXs)
+ },
+ )
+ case mod @ AmbiguousMod(left, right) =>
+ firstOk(
+ e,
+ s"Expected both operands to be ints or vector[int], but got ${left
+ .t} and ${right.t}.",
AmbiguousMod(int(left), int(right))(mod.blame),
- vectorIntOp2(mod, (l,r) => AmbiguousMod(l ,r)(mod.blame))
+ vectorIntOp2(mod, (l, r) => AmbiguousMod(l, r)(mod.blame)),
)
- case mult@AmbiguousMult(left, right) =>
- firstOk(e, s"Expected both operands to be numeric, a numeric vector, a process, a set or a bag but got ${left.t} and ${right.t}.",
+ case mult @ AmbiguousMult(left, right) =>
+ firstOk(
+ e,
+ s"Expected both operands to be numeric, a numeric vector, a process, a set or a bag but got ${left
+ .t} and ${right.t}.",
AmbiguousMult(int(left), int(right)),
- floatOp2(mult, (l,r) => AmbiguousMult(l, r)),
- AmbiguousMult(rat(left), rat(right)), {
- vectorOp2(mult, (l,r) => AmbiguousMult(l,r))
- },
+ floatOp2(mult, (l, r) => AmbiguousMult(l, r)),
+ AmbiguousMult(rat(left), rat(right)),
+ { vectorOp2(mult, (l, r) => AmbiguousMult(l, r)) },
AmbiguousMult(process(left), process(right)), {
val (coercedLeft, TSet(elementLeft)) = set(left)
val (coercedRight, TSet(elementRight)) = set(right)
- val sharedType = Types.leastCommonSuperType(elementLeft, elementRight)
- AmbiguousMult(coerce(coercedLeft, TSet(sharedType)), coerce(coercedRight, TSet(sharedType)))
+ val sharedType = Types
+ .leastCommonSuperType(elementLeft, elementRight)
+ AmbiguousMult(
+ coerce(coercedLeft, TSet(sharedType)),
+ coerce(coercedRight, TSet(sharedType)),
+ )
}, {
val (coercedLeft, TBag(elementLeft)) = bag(left)
val (coercedRight, TBag(elementRight)) = bag(right)
- val sharedType = Types.leastCommonSuperType(elementLeft, elementRight)
- AmbiguousMult(coerce(coercedLeft, TBag(sharedType)), coerce(coercedRight, TBag(sharedType)))
- }
+ val sharedType = Types
+ .leastCommonSuperType(elementLeft, elementRight)
+ AmbiguousMult(
+ coerce(coercedLeft, TBag(sharedType)),
+ coerce(coercedRight, TBag(sharedType)),
+ )
+ },
)
case AmbiguousNeq(left, right, vectorInnerType) =>
val sharedType = Types.leastCommonSuperType(left.t, right.t)
- AmbiguousNeq(coerce(left, sharedType), coerce(right, sharedType), vectorInnerType)
+ AmbiguousNeq(
+ coerce(left, sharedType),
+ coerce(right, sharedType),
+ vectorInnerType,
+ )
case AmbiguousOr(left, right) =>
- firstOk(e, s"Expected both operands to be boolean or a process, but got ${left.t} and ${right.t}.",
+ firstOk(
+ e,
+ s"Expected both operands to be boolean or a process, but got ${left
+ .t} and ${right.t}.",
AmbiguousOr(bool(left), bool(right)),
AmbiguousOr(process(left), process(right)),
)
case plus @ AmbiguousPlus(left, right) =>
- firstOk(e, s"Expected both operands to be numeric, a process, a sequence, set, bag, numeric vector, or string; or a pointer and integer, but got ${left.t} and ${right.t}.",
+ firstOk(
+ e,
+ s"Expected both operands to be numeric, a process, a sequence, set, bag, numeric vector, or string; or a pointer and integer, but got ${left
+ .t} and ${right.t}.",
AmbiguousPlus(int(left), int(right))(plus.blame),
- floatOp2(plus, (l,r) => AmbiguousPlus(l, r)(plus.blame)),
+ floatOp2(plus, (l, r) => AmbiguousPlus(l, r)(plus.blame)),
AmbiguousPlus(rat(left), rat(right))(plus.blame),
AmbiguousPlus(process(left), process(right))(plus.blame),
AmbiguousPlus(string(left), string(right))(plus.blame),
AmbiguousPlus(pointer(left)._1, int(right))(plus.blame), {
val (coercedLeft, TSeq(elementLeft)) = seq(left)
val (coercedRight, TSeq(elementRight)) = seq(right)
- val sharedType = Types.leastCommonSuperType(elementLeft, elementRight)
- AmbiguousPlus(coerce(coercedLeft, TSeq(sharedType)), coerce(coercedRight, TSeq(sharedType)))(plus.blame)
+ val sharedType = Types
+ .leastCommonSuperType(elementLeft, elementRight)
+ AmbiguousPlus(
+ coerce(coercedLeft, TSeq(sharedType)),
+ coerce(coercedRight, TSeq(sharedType)),
+ )(plus.blame)
}, {
val (coercedLeft, TSet(elementLeft)) = set(left)
val (coercedRight, TSet(elementRight)) = set(right)
- val sharedType = Types.leastCommonSuperType(elementLeft, elementRight)
- AmbiguousPlus(coerce(coercedLeft, TSet(sharedType)), coerce(coercedRight, TSet(sharedType)))(plus.blame)
+ val sharedType = Types
+ .leastCommonSuperType(elementLeft, elementRight)
+ AmbiguousPlus(
+ coerce(coercedLeft, TSet(sharedType)),
+ coerce(coercedRight, TSet(sharedType)),
+ )(plus.blame)
}, {
val (coercedLeft, TBag(elementLeft)) = bag(left)
val (coercedRight, TBag(elementRight)) = bag(right)
- val sharedType = Types.leastCommonSuperType(elementLeft, elementRight)
- AmbiguousPlus(coerce(coercedLeft, TBag(sharedType)), coerce(coercedRight, TBag(sharedType)))(plus.blame)
- }, {
- vectorOp2(plus, (l,r) => AmbiguousPlus(l,r)(plus.blame))
- }, {
+ val sharedType = Types
+ .leastCommonSuperType(elementLeft, elementRight)
+ AmbiguousPlus(
+ coerce(coercedLeft, TBag(sharedType)),
+ coerce(coercedRight, TBag(sharedType)),
+ )(plus.blame)
+ },
+ { vectorOp2(plus, (l, r) => AmbiguousPlus(l, r)(plus.blame)) }, {
val validOperators = plus.getValidOperatorsOf(OperatorLeftPlus())
validOperators match {
- case Some(Seq(op)) => AmbiguousPlus(cls(left), coerce(right, op.args.head.t))(plus.blame)
- case _ => throw IncoercibleText(left, "This expression does not have a matching custom plus operator")
+ case Some(Seq(op)) =>
+ AmbiguousPlus(cls(left), coerce(right, op.args.head.t))(
+ plus.blame
+ )
+ case _ =>
+ throw IncoercibleText(
+ left,
+ "This expression does not have a matching custom plus operator",
+ )
}
}, {
// TODO: Definition of operators should be type checked for arity
val validOperators = plus.getValidOperatorsOf(OperatorRightPlus())
validOperators match {
- case Some(Seq(op)) => AmbiguousPlus(cls(right), coerce(left, op.args.head.t))(plus.blame)
- case _ => throw IncoercibleText(right, "This expression does not have a matching custom right plus operator")
+ case Some(Seq(op)) =>
+ AmbiguousPlus(cls(right), coerce(left, op.args.head.t))(
+ plus.blame
+ )
+ case _ =>
+ throw IncoercibleText(
+ right,
+ "This expression does not have a matching custom right plus operator",
+ )
}
- }
+ },
)
case AmbiguousResult() => e
case sub @ AmbiguousSubscript(collection, index) =>
- firstOk(e, s"Expected collection to be a sequence, vector, array, pointer or map, but got ${collection.t}.",
+ firstOk(
+ e,
+ s"Expected collection to be a sequence, vector, array, pointer or map, but got ${collection.t}.",
AmbiguousSubscript(seq(collection)._1, int(index))(sub.blame),
AmbiguousSubscript(vector(collection)._1, int(index))(sub.blame),
AmbiguousSubscript(array(collection)._1, int(index))(sub.blame),
AmbiguousSubscript(pointer(collection)._1, int(index))(sub.blame),
- AmbiguousSubscript(map(collection)._1, coerce(index, map(collection)._2.key))(sub.blame),
+ AmbiguousSubscript(
+ map(collection)._1,
+ coerce(index, map(collection)._2.key),
+ )(sub.blame),
)
case AmbiguousThis() => e
- case div@AmbiguousTruncDiv(left, right) =>
- firstOk(e, s"Expected both operands to be int, float, vector[int] or vector[float], but got ${left.t} and ${right.t}.",
+ case div @ AmbiguousTruncDiv(left, right) =>
+ firstOk(
+ e,
+ s"Expected both operands to be int, float, vector[int] or vector[float], but got ${left
+ .t} and ${right.t}.",
AmbiguousTruncDiv(int(left), int(right))(div.blame),
- floatOp2(div, (l,r) => AmbiguousTruncDiv(l, r)(div.blame)),
- vectorIntOp2(div, (l,r) => AmbiguousTruncDiv(l ,r)(div.blame)),
- vectorFloatOp2(div, (l,r) => AmbiguousTruncDiv(l ,r)(div.blame)),
+ floatOp2(div, (l, r) => AmbiguousTruncDiv(l, r)(div.blame)),
+ vectorIntOp2(div, (l, r) => AmbiguousTruncDiv(l, r)(div.blame)),
+ vectorFloatOp2(div, (l, r) => AmbiguousTruncDiv(l, r)(div.blame)),
)
- case mod@AmbiguousTruncMod(left, right) =>
- firstOk(e, s"Expected both operands to be ints or vector[int], but got ${left.t} and ${right.t}.",
+ case mod @ AmbiguousTruncMod(left, right) =>
+ firstOk(
+ e,
+ s"Expected both operands to be ints or vector[int], but got ${left
+ .t} and ${right.t}.",
AmbiguousTruncMod(int(left), int(right))(mod.blame),
- vectorIntOp2(mod, (l,r) => AmbiguousTruncMod(l ,r)(mod.blame))
+ vectorIntOp2(mod, (l, r) => AmbiguousTruncMod(l, r)(mod.blame)),
)
- case And(left, right) =>
- And(bool(left), bool(right))
- case any @ Any() =>
- Any()(any.blame)
+ case And(left, right) => And(bool(left), bool(right))
+ case any @ Any() => Any()(any.blame)
case a @ ArraySubscript(arr, index) =>
ArraySubscript(array(arr)._1, int(index))(a.blame)
case BagAdd(xs, ys) =>
val (left, TBag(leftT)) = bag(xs)
val (right, TBag(rightT)) = bag(ys)
val sharedElement = Types.leastCommonSuperType(leftT, rightT)
- BagAdd(coerce(left, TBag(sharedElement)), coerce(right, TBag(sharedElement)))
+ BagAdd(
+ coerce(left, TBag(sharedElement)),
+ coerce(right, TBag(sharedElement)),
+ )
case BagLargestCommon(xs, ys) =>
val (left, TBag(leftT)) = bag(xs)
val (right, TBag(rightT)) = bag(ys)
val sharedElement = Types.leastCommonSuperType(leftT, rightT)
- BagLargestCommon(coerce(left, TBag(sharedElement)), coerce(right, TBag(sharedElement)))
+ BagLargestCommon(
+ coerce(left, TBag(sharedElement)),
+ coerce(right, TBag(sharedElement)),
+ )
case BagMemberCount(x, xs) =>
val (coercedBag, TBag(element)) = bag(xs)
val sharedType = Types.leastCommonSuperType(x.t, element)
- BagMemberCount(coerce(x, sharedType), coerce(coercedBag, TBag(sharedType)))
+ BagMemberCount(
+ coerce(x, sharedType),
+ coerce(coercedBag, TBag(sharedType)),
+ )
case BagMinus(xs, ys) =>
val (left, TBag(leftT)) = bag(xs)
val (right, TBag(rightT)) = bag(ys)
val sharedElement = Types.leastCommonSuperType(leftT, rightT)
- BagMinus(coerce(left, TBag(sharedElement)), coerce(right, TBag(sharedElement)))
+ BagMinus(
+ coerce(left, TBag(sharedElement)),
+ coerce(right, TBag(sharedElement)),
+ )
case bgi @ BipGuardInvocation(obj, ref) =>
BipGuardInvocation(cls(obj), ref)
- case BitAnd(left, right) =>
- BitAnd(int(left), int(right))
- case BitNot(arg) =>
- BitNot(int(arg))
- case BitOr(left, right) =>
- BitOr(int(left), int(right))
- case BitShl(left, right) =>
- BitShl(int(left), int(right))
- case BitShr(left, right) =>
- BitShr(int(left), int(right))
- case BitUShr(left, right) =>
- BitUShr(int(left), int(right))
- case BitXor(left, right) =>
- BitXor(int(left), int(right))
- case Cast(value, typeValue) =>
- Cast(value, typeValue)
+ case BitAnd(left, right) => BitAnd(int(left), int(right))
+ case BitNot(arg) => BitNot(int(arg))
+ case BitOr(left, right) => BitOr(int(left), int(right))
+ case BitShl(left, right) => BitShl(int(left), int(right))
+ case BitShr(left, right) => BitShr(int(left), int(right))
+ case BitUShr(left, right) => BitUShr(int(left), int(right))
+ case BitXor(left, right) => BitXor(int(left), int(right))
+ case Cast(value, typeValue) => Cast(value, typeValue)
case CastFloat(e, t) =>
- firstOk(e, s"Can only cast between integer and float or float and float.",
+ firstOk(
+ e,
+ s"Can only cast between integer and float or float and float.",
CastFloat(float(e), t),
CastFloat(int(e), t),
)
@@ -866,16 +1172,13 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
case c @ CharValue(_) => c
case inv @ CInvocation(applicable, args, givenArgs, yields) =>
CInvocation(applicable, args, givenArgs, yields)(inv.blame)
- case choose @ Choose(xs) =>
- Choose(set(xs)._1)(choose.blame)
- case choose @ ChooseFresh(xs) =>
- ChooseFresh(set(xs)._1)(choose.blame)
- case p @ ChorPerm(endpoint, loc, perm) => ChorPerm(endpoint, loc, rat(perm))
- case CLiteralArray(exprs) =>
- CLiteralArray(exprs)
+ case choose @ Choose(xs) => Choose(set(xs)._1)(choose.blame)
+ case choose @ ChooseFresh(xs) => ChooseFresh(set(xs)._1)(choose.blame)
+ case p @ ChorPerm(endpoint, loc, perm) =>
+ ChorPerm(endpoint, loc, rat(perm))
+ case CLiteralArray(exprs) => CLiteralArray(exprs)
case CLocal(name) => e
- case c @ Committed(obj) =>
- Committed(cls(obj))(c.blame)
+ case c @ Committed(obj) => Committed(cls(obj))(c.blame)
case ComputationalAnd(left, right) =>
ComputationalAnd(bool(left), bool(right))
case ComputationalOr(left, right) =>
@@ -891,121 +1194,184 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
val (coercedXs, TSeq(element)) = seq(xs)
val sharedType = Types.leastCommonSuperType(x.t, element)
Cons(coerce(x, sharedType), coerce(xs, TSeq(sharedType)))
- case cfa@CPPClassMethodOrFieldAccess(classInstance, methodOrFieldName) => CPPClassMethodOrFieldAccess(classInstance, methodOrFieldName)(cfa.blame)
- case defn@CPPLambdaDefinition(contract, declarator, body) =>
+ case cfa @ CPPClassMethodOrFieldAccess(
+ classInstance,
+ methodOrFieldName,
+ ) =>
+ CPPClassMethodOrFieldAccess(classInstance, methodOrFieldName)(cfa.blame)
+ case defn @ CPPLambdaDefinition(contract, declarator, body) =>
CPPLambdaDefinition(contract, declarator, body)(defn.blame)
case CPPLambdaRef() => e
- case inv@CPPInvocation(applicable, args, givenArgs, yields) =>
+ case inv @ CPPInvocation(applicable, args, givenArgs, yields) =>
CPPInvocation(applicable, args, givenArgs, yields)(inv.blame)
- case CPPLiteralArray(exprs) =>
- CPPLiteralArray(exprs)
+ case CPPLiteralArray(exprs) => CPPLiteralArray(exprs)
case CPPLocal(_, _) => e
case SYCLReadWriteAccess() => e
case SYCLReadOnlyAccess() => e
case SYCLRange(dims) => SYCLRange(dims)
- case SYCLNDRange(globalRange, localRange) => SYCLNDRange(globalRange, localRange)
+ case SYCLNDRange(globalRange, localRange) =>
+ SYCLNDRange(globalRange, localRange)
case StringConcat(left, right) =>
StringConcat(string(left), string(right))
- case inv @ ConstructorInvocation(ref, classTypeArgs, args, outArgs, typeArgs, givenMap, yields) =>
- arity(ConstructorInvocation(ref, classTypeArgs, coerceArgs(args, ref.decl, inv.typeEnv, canCDemote = true), outArgs, typeArgs, coerceGiven(givenMap, canCDemote = true), coerceYields(yields, args.head))(inv.blame))
+ case inv @ ConstructorInvocation(
+ ref,
+ classTypeArgs,
+ args,
+ outArgs,
+ typeArgs,
+ givenMap,
+ yields,
+ ) =>
+ arity(
+ ConstructorInvocation(
+ ref,
+ classTypeArgs,
+ coerceArgs(args, ref.decl, inv.typeEnv, canCDemote = true),
+ outArgs,
+ typeArgs,
+ coerceGiven(givenMap, canCDemote = true),
+ coerceYields(yields, args.head),
+ )(inv.blame)
+ )
case acc @ CFieldAccess(struct, field) =>
CFieldAccess(struct, field)(acc.blame)
case deref @ CStructDeref(struct, field) =>
CStructDeref(struct, field)(deref.blame)
- case CurPerm(loc) =>
- CurPerm(loc)
- case CurrentThreadId() =>
- CurrentThreadId()
- //case deref @ DerefVeyMontThread(ref) =>
- //DerefVeyMontThread( TVeyMontThread[Pre](ref))
- case deref @ Deref(obj, ref) =>
- Deref(cls(obj), ref)(deref.blame)
- case deref @ DerefHeapVariable(ref) =>
- DerefHeapVariable(ref)(deref.blame)
- case deref @ DerefPointer(p) =>
- DerefPointer(pointer(p)._1)(deref.blame)
- case Drop(xs, count) =>
- Drop(seq(xs)._1, int(count))
- case Empty(obj) =>
- Empty(sized(obj)._1)
+ case CurPerm(loc) => CurPerm(loc)
+ case CurrentThreadId() => CurrentThreadId()
+ // case deref @ DerefVeyMontThread(ref) =>
+ // DerefVeyMontThread( TVeyMontThread[Pre](ref))
+ case deref @ Deref(obj, ref) => Deref(cls(obj), ref)(deref.blame)
+ case deref @ DerefHeapVariable(ref) => DerefHeapVariable(ref)(deref.blame)
+ case deref @ DerefPointer(p) => DerefPointer(pointer(p)._1)(deref.blame)
+ case Drop(xs, count) => Drop(seq(xs)._1, int(count))
+ case Empty(obj) => Empty(sized(obj)._1)
case EmptyProcess() => EmptyProcess()
case use @ EnumUse(enum, const) => use
case Eq(left, right) =>
val sharedType = Types.leastCommonSuperType(left.t, right.t)
Eq(coerce(left, sharedType), coerce(right, sharedType))
- case EitherLeft(e) =>
- EitherLeft(e)
- case EitherRight(e) =>
- EitherRight(e)
+ case EitherLeft(e) => EitherLeft(e)
+ case EitherRight(e) => EitherRight(e)
case EndpointName(ref) => EndpointName(ref)
case Exists(bindings, triggers, body) =>
Exists(bindings, triggers, bool(body))
- case exp@Exp(left, right) =>
- firstOk(e, s"Expected both operands to be numeric, but got ${left.t} and ${right.t}.",
+ case exp @ Exp(left, right) =>
+ firstOk(
+ e,
+ s"Expected both operands to be numeric, but got ${left.t} and ${right.t}.",
Exp(int(left), int(right)),
- floatOp2(exp, (l,r) => Exp(l, r)),
+ floatOp2(exp, (l, r) => Exp(l, r)),
Exp(rat(left), rat(right)),
)
- case div@FloatDiv(left, right) =>
- floatOp2(div, (l,r) => FloatDiv(l, r)(div.blame))
- case div @ FloorDiv(left, right) => FloorDiv(int(left), int(right))(div.blame)
+ case div @ FloatDiv(left, right) =>
+ floatOp2(div, (l, r) => FloatDiv(l, r)(div.blame))
+ case div @ FloorDiv(left, right) =>
+ FloorDiv(int(left), int(right))(div.blame)
case Forall(bindings, triggers, body) =>
Forall(bindings, triggers, bool(body))
- case ForPerm(bindings, loc, body) =>
- ForPerm(bindings, loc, bool(body))
+ case ForPerm(bindings, loc, body) => ForPerm(bindings, loc, bool(body))
case ForPermWithValue(binding, body) =>
ForPermWithValue(binding, bool(body))
case inv @ FunctionInvocation(ref, args, typeArgs, givenMap, yields) =>
- arity(FunctionInvocation(ref, coerceArgs(args, ref.decl, inv.typeEnv, canCDemote=true), typeArgs, coerceGiven(givenMap, canCDemote=true), coerceYields(yields, inv))(inv.blame))
- case get @ GetLeft(e) =>
- GetLeft(either(e)._1)(get.blame)
- case get @ GetRight(e) =>
- GetRight(either(e)._1)(get.blame)
- case GlobalThreadId() =>
- GlobalThreadId()
- case e @ GpgpuCudaKernelInvocation(kernel, blocks, threads, args, givenArgs, yields) =>
- GpgpuCudaKernelInvocation(kernel, int(blocks), int(threads), args, givenArgs, yields)(e.blame)
- case g@Greater(left, right) =>
- firstOk(e, s"Expected both operands to be numeric, but got ${left.t} and ${right.t}.",
+ arity(
+ FunctionInvocation(
+ ref,
+ coerceArgs(args, ref.decl, inv.typeEnv, canCDemote = true),
+ typeArgs,
+ coerceGiven(givenMap, canCDemote = true),
+ coerceYields(yields, inv),
+ )(inv.blame)
+ )
+ case get @ GetLeft(e) => GetLeft(either(e)._1)(get.blame)
+ case get @ GetRight(e) => GetRight(either(e)._1)(get.blame)
+ case GlobalThreadId() => GlobalThreadId()
+ case e @ GpgpuCudaKernelInvocation(
+ kernel,
+ blocks,
+ threads,
+ args,
+ givenArgs,
+ yields,
+ ) =>
+ GpgpuCudaKernelInvocation(
+ kernel,
+ int(blocks),
+ int(threads),
+ args,
+ givenArgs,
+ yields,
+ )(e.blame)
+ case g @ Greater(left, right) =>
+ firstOk(
+ e,
+ s"Expected both operands to be numeric, but got ${left.t} and ${right.t}.",
Greater(int(left), int(right)),
- floatOp2(g, (l,r) => Greater(l, r)),
+ floatOp2(g, (l, r) => Greater(l, r)),
Greater(rat(left), rat(right)),
)
- case g@GreaterEq(left, right) =>
- firstOk(e, s"Expected both operands to be numeric, but got ${left.t} and ${right.t}.",
+ case g @ GreaterEq(left, right) =>
+ firstOk(
+ e,
+ s"Expected both operands to be numeric, but got ${left.t} and ${right.t}.",
GreaterEq(int(left), int(right)),
- floatOp2(g, (l,r) => GreaterEq(l, r)),
+ floatOp2(g, (l, r) => GreaterEq(l, r)),
GreaterEq(rat(left), rat(right)),
)
- case head @ Head(xs) =>
- Head(seq(xs)._1)(head.blame)
- case Held(obj) =>
- Held(cls(obj))
- case IdleToken(thread) =>
- IdleToken(cls(thread))
- case Implies(left, right) =>
- Implies(bool(left), res(right))
- case FunctionOf(e, ref) =>
- FunctionOf(e, ref)
+ case head @ Head(xs) => Head(seq(xs)._1)(head.blame)
+ case Held(obj) => Held(cls(obj))
+ case IdleToken(thread) => IdleToken(cls(thread))
+ case Implies(left, right) => Implies(bool(left), res(right))
+ case FunctionOf(e, ref) => FunctionOf(e, ref)
case f @ FreePointer(p) => FreePointer(pointer(p)._1)(f.blame)
case InlinePattern(inner, parent, group) =>
InlinePattern(inner, parent, group)
- case inv @ InstanceFunctionInvocation(obj, ref, args, typeArgs, givenMap, yields) =>
- arity(InstanceFunctionInvocation(cls(obj), ref, coerceArgs(args, ref.decl, inv.typeEnv, canCDemote=true), typeArgs, coerceGiven(givenMap, canCDemote=true), coerceYields(yields, inv))(inv.blame))
- case InstanceOf(value, typeValue) =>
- InstanceOf(value, typeValue)
+ case inv @ InstanceFunctionInvocation(
+ obj,
+ ref,
+ args,
+ typeArgs,
+ givenMap,
+ yields,
+ ) =>
+ arity(
+ InstanceFunctionInvocation(
+ cls(obj),
+ ref,
+ coerceArgs(args, ref.decl, inv.typeEnv, canCDemote = true),
+ typeArgs,
+ coerceGiven(givenMap, canCDemote = true),
+ coerceYields(yields, inv),
+ )(inv.blame)
+ )
+ case InstanceOf(value, typeValue) => InstanceOf(value, typeValue)
case InstancePredicateApply(obj, ref, args, perm) =>
- InstancePredicateApply(cls(obj), ref, coerceArgs(args, ref.decl), rat(perm))
+ InstancePredicateApply(
+ cls(obj),
+ ref,
+ coerceArgs(args, ref.decl),
+ rat(perm),
+ )
case CoalesceInstancePredicateApply(obj, ref, args, perm) =>
- CoalesceInstancePredicateApply(cls(obj), ref, coerceArgs(args, ref.decl), rat(perm))
- case IsLeft(e) =>
- IsLeft(either(e)._1)
- case IsRight(e) =>
- IsRight(either(e)._1)
+ CoalesceInstancePredicateApply(
+ cls(obj),
+ ref,
+ coerceArgs(args, ref.decl),
+ rat(perm),
+ )
+ case IsLeft(e) => IsLeft(either(e)._1)
+ case IsRight(e) => IsRight(either(e)._1)
case deref @ JavaDeref(obj, field) => e
- case inv @ JavaInvocation(obj, typeParams, method, arguments, givenArgs, yields) => e
- case JavaLiteralArray(exprs) =>
- JavaLiteralArray(exprs)
+ case inv @ JavaInvocation(
+ obj,
+ typeParams,
+ method,
+ arguments,
+ givenArgs,
+ yields,
+ ) =>
+ e
+ case JavaLiteralArray(exprs) => JavaLiteralArray(exprs)
case JavaLocal(name) => e
case JavaNewClass(args, typeArgs, name, givenMap, yields) => e
case JavaNewDefaultArray(baseType, specifiedDims, moreDims) => e
@@ -1013,19 +1379,21 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
case str @ JavaStringValue(_, _) => str
case sizeof @ SizeOf(_) => sizeof
case str @ StringValue(_) => str
- case JoinToken(thread) =>
- JoinToken(cls(thread))
- case length @ Length(arr) =>
- Length(array(arr)._1)(length.blame)
+ case JoinToken(thread) => JoinToken(cls(thread))
+ case length @ Length(arr) => Length(array(arr)._1)(length.blame)
case Less(left, right) =>
- firstOk(e, s"Expected both operands to be numeric, but got ${left.t} and ${right.t}.",
+ firstOk(
+ e,
+ s"Expected both operands to be numeric, but got ${left.t} and ${right.t}.",
Less(int(left), int(right)),
Less(rat(left), rat(right)),
)
- case l@LessEq(left, right) =>
- firstOk(e, s"Expected both operands to be numeric, but got ${left.t} and ${right.t}.",
+ case l @ LessEq(left, right) =>
+ firstOk(
+ e,
+ s"Expected both operands to be numeric, but got ${left.t} and ${right.t}.",
LessEq(int(left), int(right)),
- floatOp2(l, (l,r) => LessEq(l, r)),
+ floatOp2(l, (l, r) => LessEq(l, r)),
LessEq(rat(left), rat(right)),
)
case Let(binding, value, main) =>
@@ -1033,9 +1401,13 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
case LiteralBag(element, values) =>
LiteralBag(element, values.map(coerce(_, element)))
case LiteralMap(k, v, values) =>
- LiteralMap(k, v, values.map {
- case (valueK, valueV) => (coerce(valueK, k), coerce(valueV, v))
- })
+ LiteralMap(
+ k,
+ v,
+ values.map { case (valueK, valueV) =>
+ (coerce(valueK, k), coerce(valueV, v))
+ },
+ )
case LiteralSeq(element, values) =>
LiteralSeq(element, values.map(coerce(_, element)))
case LiteralSet(element, values) =>
@@ -1043,102 +1415,147 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
case LiteralVector(element, values) =>
LiteralVector(element, values.map(coerce(_, element)))
case LiteralTuple(ts, values) =>
- LiteralTuple(ts, values.zip(ts).map {
- case (v, t) => coerce(v, t)
- })
- case Local(ref) =>
- Local(ref)
- case LocalThreadId() =>
- LocalThreadId()
+ LiteralTuple(ts, values.zip(ts).map { case (v, t) => coerce(v, t) })
+ case Local(ref) => Local(ref)
+ case LocalThreadId() => LocalThreadId()
case MapCons(m, k, v) =>
val (coercedMap, mapType) = map(m)
val sharedType = Types.leastCommonSuperType(mapType.value, v.t)
- MapCons(coerce(coercedMap, TMap(mapType.key, sharedType)), coerce(k, mapType.key), coerce(v, sharedType))
+ MapCons(
+ coerce(coercedMap, TMap(mapType.key, sharedType)),
+ coerce(k, mapType.key),
+ coerce(v, sharedType),
+ )
case MapDisjoint(left, right) =>
val (coercedLeft, leftType) = map(left)
val (coercedRight, rightType) = map(right)
- if(leftType.key != rightType.key)
- throw IncoercibleExplanation(e, s"Expected both operands to have a map type of which the key type is equal, " +
- s"but got ${leftType.key} and ${rightType.key}")
+ if (leftType.key != rightType.key)
+ throw IncoercibleExplanation(
+ e,
+ s"Expected both operands to have a map type of which the key type is equal, " +
+ s"but got ${leftType.key} and ${rightType.key}",
+ )
- val sharedType = Types.leastCommonSuperType(leftType.value, rightType.value)
+ val sharedType = Types
+ .leastCommonSuperType(leftType.value, rightType.value)
val mapType = TMap(leftType.key, sharedType)
MapDisjoint(coerce(coercedLeft, mapType), coerce(coercedRight, mapType))
case MapEq(left, right) =>
val (coercedLeft, leftType) = map(left)
val (coercedRight, rightType) = map(right)
- if(leftType.key != rightType.key)
- throw IncoercibleExplanation(e, s"Expected both operands to have a map type of which the key type is equal, " +
- s"but got ${leftType.key} and ${rightType.key}")
+ if (leftType.key != rightType.key)
+ throw IncoercibleExplanation(
+ e,
+ s"Expected both operands to have a map type of which the key type is equal, " +
+ s"but got ${leftType.key} and ${rightType.key}",
+ )
- val sharedType = Types.leastCommonSuperType(leftType.value, rightType.value)
+ val sharedType = Types
+ .leastCommonSuperType(leftType.value, rightType.value)
val mapType = TMap(leftType.key, sharedType)
MapEq(coerce(coercedLeft, mapType), coerce(coercedRight, mapType))
case get @ MapGet(m, k) =>
val (coercedMap, mapType) = map(m)
MapGet(coercedMap, coerce(k, mapType.key))(get.blame)
- case MapItemSet(m) =>
- MapItemSet(map(m)._1)
- case MapKeySet(m) =>
- MapKeySet(map(m)._1)
+ case MapItemSet(m) => MapItemSet(map(m)._1)
+ case MapKeySet(m) => MapKeySet(map(m)._1)
case MapMember(x, xs) =>
val (coercedMap, mapType) = map(xs)
MapMember(coerce(x, mapType.key), coercedMap)
case MapRemove(m, k) =>
val (coercedMap, mapType) = map(m)
MapRemove(coercedMap, coerce(k, mapType.key))
- case MapValueSet(m) =>
- MapValueSet(map(m)._1)
+ case MapValueSet(m) => MapValueSet(map(m)._1)
case MatrixCompare(left, right) =>
val (coercedLeft, leftType) = matrix(left)
val (coercedRight, rightType) = matrix(right)
- val sharedType = Types.leastCommonSuperType(leftType.element, rightType.element)
- MatrixCompare(coerce(coercedLeft, TMatrix(sharedType)), coerce(coercedRight, TMatrix(sharedType)))
- case MatrixRepeat(e) =>
- MatrixRepeat(e)
+ val sharedType = Types
+ .leastCommonSuperType(leftType.element, rightType.element)
+ MatrixCompare(
+ coerce(coercedLeft, TMatrix(sharedType)),
+ coerce(coercedRight, TMatrix(sharedType)),
+ )
+ case MatrixRepeat(e) => MatrixRepeat(e)
case MatrixSum(indices, mat) =>
- MatrixSum(coerce(indices, TSeq[Pre](TInt())), coerce(mat, TSeq[Pre](TRational())))
- case inv @ MethodInvocation(obj, ref, args, outArgs, typeArgs, givenMap, yields) =>
- arity(MethodInvocation(obj, ref, coerceArgs(args, ref.decl, inv.typeEnv, canCDemote=true), outArgs, typeArgs, coerceGiven(givenMap, canCDemote=true), coerceYields(yields, inv))(inv.blame))
+ MatrixSum(
+ coerce(indices, TSeq[Pre](TInt())),
+ coerce(mat, TSeq[Pre](TRational())),
+ )
+ case inv @ MethodInvocation(
+ obj,
+ ref,
+ args,
+ outArgs,
+ typeArgs,
+ givenMap,
+ yields,
+ ) =>
+ arity(
+ MethodInvocation(
+ obj,
+ ref,
+ coerceArgs(args, ref.decl, inv.typeEnv, canCDemote = true),
+ outArgs,
+ typeArgs,
+ coerceGiven(givenMap, canCDemote = true),
+ coerceYields(yields, inv),
+ )(inv.blame)
+ )
case minus @ Minus(left, right) =>
- firstOk(e, s"Expected both operands to be numeric, but got ${left.t} and ${right.t}.",
+ firstOk(
+ e,
+ s"Expected both operands to be numeric, but got ${left.t} and ${right.t}.",
Minus(int(left), int(right)),
- floatOp2(minus, (l,r) => Minus(l, r)),
+ floatOp2(minus, (l, r) => Minus(l, r)),
Minus(rat(left), rat(right)),
)
case div @ Mod(left, right) => Mod(int(left), int(right))(div.blame)
case ModelAbstractState(m, state) =>
ModelAbstractState(model(m)._1, bool(state))
case ModelChoose(m, perm, totalProcess, choice) =>
- ModelChoose(model(m)._1, rat(perm), process(totalProcess), process(choice))
- case ModelCreate(m, init) =>
- ModelCreate(model(m)._1, process(init))
+ ModelChoose(
+ model(m)._1,
+ rat(perm),
+ process(totalProcess),
+ process(choice),
+ )
+ case ModelCreate(m, init) => ModelCreate(model(m)._1, process(init))
case deref @ ModelDeref(obj, ref) =>
ModelDeref(model(obj)._1, ref)(deref.blame)
- case ModelDestroy(m) =>
- ModelDestroy(model(m)._1)
+ case ModelDestroy(m) => ModelDestroy(model(m)._1)
case ModelMerge(m, leftPerm, leftProcess, rightPerm, rightProcess) =>
- ModelMerge(model(m)._1, rat(leftPerm), process(leftProcess), rat(rightPerm), process(rightProcess))
- case ModelNew(ref) =>
- ModelNew(ref)
- case ModelPerm(loc, perm) =>
- ModelPerm(loc, rat(perm))
+ ModelMerge(
+ model(m)._1,
+ rat(leftPerm),
+ process(leftProcess),
+ rat(rightPerm),
+ process(rightProcess),
+ )
+ case ModelNew(ref) => ModelNew(ref)
+ case ModelPerm(loc, perm) => ModelPerm(loc, rat(perm))
case ModelSplit(m, leftPerm, leftProcess, rightPerm, rightProcess) =>
- ModelSplit(model(m)._1, rat(leftPerm), process(leftProcess), rat(rightPerm), process(rightProcess))
+ ModelSplit(
+ model(m)._1,
+ rat(leftPerm),
+ process(leftProcess),
+ rat(rightPerm),
+ process(rightProcess),
+ )
case ModelState(m, perm, state) =>
ModelState(model(m)._1, rat(perm), process(state))
case mult @ Mult(left, right) =>
- firstOk(e, s"Expected both operands to be numeric, but got ${left.t} and ${right.t}.",
+ firstOk(
+ e,
+ s"Expected both operands to be numeric, but got ${left.t} and ${right.t}.",
Mult(int(left), int(right)),
- floatOp2(mult, (l,r) => Mult(l, r)),
+ floatOp2(mult, (l, r) => Mult(l, r)),
Mult(rat(left), rat(right)),
)
case NdIndex(indices, dimensions) =>
NdIndex(indices.map(int), dimensions.map(int))
- case NdLength(dimensions) =>
- NdLength(dimensions.map(int))
+ case NdLength(dimensions) => NdLength(dimensions.map(int))
case NdPartialIndex(indices, linearIndex, dimensions) =>
NdPartialIndex(indices.map(int), int(linearIndex), dimensions.map(int))
case Neq(left, right) =>
@@ -1146,38 +1563,28 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
Neq(coerce(left, sharedType), coerce(right, sharedType))
case na @ NewArray(element, dims, moreDims, initialize) =>
NewArray(element, dims.map(int), moreDims, initialize)(na.blame)
- case na@NewPointerArray(element, size) =>
+ case na @ NewPointerArray(element, size) =>
NewPointerArray(element, size)(na.blame)
- case NewObject(cls) =>
- NewObject(cls)
- case NoPerm() =>
- NoPerm()
- case Not(arg) =>
- Not(bool(arg))
- case Null() =>
- Null()
- case old @ Old(expr, at) =>
- Old(expr, at)(old.blame)
- case OptEmpty(opt) =>
- OptEmpty(option(opt)._1)
- case get @ OptGet(opt) =>
- OptGet(option(opt)._1)(get.blame)
+ case NewObject(cls) => NewObject(cls)
+ case NoPerm() => NoPerm()
+ case Not(arg) => Not(bool(arg))
+ case Null() => Null()
+ case old @ Old(expr, at) => Old(expr, at)(old.blame)
+ case OptEmpty(opt) => OptEmpty(option(opt)._1)
+ case get @ OptGet(opt) => OptGet(option(opt)._1)(get.blame)
case OptGetOrElse(opt, alt) =>
val (coercedOpt, optType) = option(opt)
val sharedType = Types.leastCommonSuperType(alt.t, optType.element)
- OptGetOrElse(coerce(coercedOpt, TOption(sharedType)), coerce(alt, sharedType))
- case OptNone() =>
- OptNone()
- case OptNoneTyped(t) =>
- OptNoneTyped(t)
- case OptSome(e) =>
- OptSome(e)
- case OptSomeTyped(t, e) =>
- OptSomeTyped(t, coerce(e, t))
- case Or(left, right) =>
- Or(bool(left), bool(right))
- case Perm(loc, perm) =>
- Perm(loc, rat(perm))
+ OptGetOrElse(
+ coerce(coercedOpt, TOption(sharedType)),
+ coerce(alt, sharedType),
+ )
+ case OptNone() => OptNone()
+ case OptNoneTyped(t) => OptNoneTyped(t)
+ case OptSome(e) => OptSome(e)
+ case OptSomeTyped(t, e) => OptSomeTyped(t, coerce(e, t))
+ case Or(left, right) => Or(bool(left), bool(right))
+ case Perm(loc, perm) => Perm(loc, rat(perm))
case PermPointer(p, len, perm) =>
PermPointer(pointer(p)._1, int(len), rat(perm))
case PermPointerIndex(p, idx, perm) =>
@@ -1185,12 +1592,18 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
case Permutation(left, right) =>
val (coercedLeft, leftType) = seq(left)
val (coercedRight, rightType) = seq(right)
- val sharedType = Types.leastCommonSuperType(leftType.element, rightType.element)
- Permutation(coerce(left, TSeq(sharedType)), coerce(right, TSeq(sharedType)))
+ val sharedType = Types
+ .leastCommonSuperType(leftType.element, rightType.element)
+ Permutation(
+ coerce(left, TSeq(sharedType)),
+ coerce(right, TSeq(sharedType)),
+ )
case plus @ Plus(left, right) =>
- firstOk(e, s"Expected both operands to be numeric, but got ${left.t} and ${right.t}.",
+ firstOk(
+ e,
+ s"Expected both operands to be numeric, but got ${left.t} and ${right.t}.",
Plus(int(left), int(right)),
- floatOp2(plus, (l,r) => Plus(l, r)),
+ floatOp2(plus, (l, r) => Plus(l, r)),
Plus(rat(left), rat(right)),
)
case add @ PointerAdd(p, offset) =>
@@ -1199,8 +1612,7 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
PointerBlockLength(pointer(p)._1)(len.blame)
case off @ PointerBlockOffset(p) =>
PointerBlockOffset(pointer(p)._1)(off.blame)
- case len @ PointerLength(p) =>
- PointerLength(pointer(p)._1)(len.blame)
+ case len @ PointerLength(p) => PointerLength(pointer(p)._1)(len.blame)
case get @ PointerSubscript(p, index) =>
PointerSubscript(pointer(p)._1, int(index))(get.blame)
case PointsTo(loc, perm, value) =>
@@ -1208,67 +1620,89 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
case PolarityDependent(onInhale, onExhale) =>
PolarityDependent(res(onInhale), res(onExhale))
case ass @ PostAssignExpression(target, value) =>
- PostAssignExpression(target, coerce(value, target.t, canCDemote=true))(ass.blame)
+ PostAssignExpression(
+ target,
+ coerce(value, target.t, canCDemote = true),
+ )(ass.blame)
case ass @ PreAssignExpression(target, value) =>
- PreAssignExpression(target, coerce(value, target.t, canCDemote=true))(ass.blame)
+ PreAssignExpression(target, coerce(value, target.t, canCDemote = true))(
+ ass.blame
+ )
case PredicateApply(ref, args, perm) =>
PredicateApply(ref, coerceArgs(args, ref.decl), rat(perm))
- case inv @ ProcedureInvocation(ref, args, outArgs, typeArgs, givenMap, yields) =>
- arity(ProcedureInvocation(ref, coerceArgs(args, ref.decl, inv.typeEnv, canCDemote=true), outArgs, typeArgs, coerceGiven(givenMap, canCDemote=true), coerceYields(yields, inv))(inv.blame))
+ case inv @ ProcedureInvocation(
+ ref,
+ args,
+ outArgs,
+ typeArgs,
+ givenMap,
+ yields,
+ ) =>
+ arity(
+ ProcedureInvocation(
+ ref,
+ coerceArgs(args, ref.decl, inv.typeEnv, canCDemote = true),
+ outArgs,
+ typeArgs,
+ coerceGiven(givenMap, canCDemote = true),
+ coerceYields(yields, inv),
+ )(inv.blame)
+ )
case inv @ LlvmFunctionInvocation(ref, args, givenMap, yields) =>
LlvmFunctionInvocation(ref, args, givenMap, yields)(inv.blame)
- case inv @ LlvmAmbiguousFunctionInvocation(name, args, givenMap, yields) =>
+ case inv @ LlvmAmbiguousFunctionInvocation(
+ name,
+ args,
+ givenMap,
+ yields,
+ ) =>
LlvmAmbiguousFunctionInvocation(name, args, givenMap, yields)(inv.blame)
case ProcessApply(process, args) =>
ProcessApply(process, coerceArgs(args, process.decl))
case ProcessChoice(left, right) =>
ProcessChoice(process(left), process(right))
- case ProcessPar(left, right) =>
- ProcessPar(process(left), process(right))
+ case ProcessPar(left, right) => ProcessPar(process(left), process(right))
case ProcessSelect(cond, whenTrue, whenFalse) =>
ProcessSelect(bool(cond), process(whenTrue), process(whenFalse))
- case ProcessSeq(left, right) =>
- ProcessSeq(process(left), process(right))
+ case ProcessSeq(left, right) => ProcessSeq(process(left), process(right))
case Product(bindings, condition, main) =>
Product(bindings, bool(condition), int(main))
case ProverFunctionInvocation(ref, args) =>
ProverFunctionInvocation(ref, coerceArgs(args, ref.decl))
- case p @ PVLChorPerm(endpoint, loc, perm) => PVLChorPerm(endpoint, loc, rat(perm))
+ case p @ PVLChorPerm(endpoint, loc, perm) =>
+ PVLChorPerm(endpoint, loc, rat(perm))
case PVLDeref(obj, field) => e
case PVLInvocation(obj, method, args, typeArgs, givenArgs, yields) => e
case PVLLocal(name) => e
case PVLNew(t, typeArgs, args, givenMap, yields) => e
- case Range(from, to) =>
- Range(int(from), int(to))
- case RangeSet(from, to) =>
- RangeSet(int(from), int(to))
- case div@RatDiv(left, right) =>
- firstOk(e, s"Expected both operands to be rational.",
+ case Range(from, to) => Range(int(from), int(to))
+ case RangeSet(from, to) => RangeSet(int(from), int(to))
+ case div @ RatDiv(left, right) =>
+ firstOk(
+ e,
+ s"Expected both operands to be rational.",
// PB: horrible hack: Div ends up being silver.PermDiv, which expects an integer divisor. In other cases,
// we just hope the silver type-check doesn't complain, since in z3 it is uniformly `/` for mixed integers
// and rationals.
RatDiv(rat(left), int(right))(div.blame),
RatDiv(rat(left), rat(right))(div.blame),
)
- case ReadPerm() =>
- ReadPerm()
- case RemoveAt(xs, i) =>
- RemoveAt(seq(xs)._1, int(i))
+ case ReadPerm() => ReadPerm()
+ case RemoveAt(xs, i) => RemoveAt(seq(xs)._1, int(i))
case ResourceOfResourceValue(r) =>
ResourceOfResourceValue(coerce(r, TResourceVal()))
- case ResourceValue(r) =>
- ResourceValue(res(r))
- case Result(ref) =>
- Result(ref)
- case s @ Scale(scale, r) =>
- Scale(rat(scale), res(r))(s.blame)
- case ScaleByParBlock(ref, r) =>
- ScaleByParBlock(ref, res(r))
- case ScopedExpr(locals, body) =>
- ScopedExpr(locals, body)
+ case ResourceValue(r) => ResourceValue(res(r))
+ case Result(ref) => Result(ref)
+ case s @ Scale(scale, r) => Scale(rat(scale), res(r))(s.blame)
+ case ScaleByParBlock(ref, r) => ScaleByParBlock(ref, res(r))
+ case ScopedExpr(locals, body) => ScopedExpr(locals, body)
case Select(condition, whenTrue, whenFalse) =>
val sharedType = Types.leastCommonSuperType(whenTrue.t, whenFalse.t)
- Select(bool(condition), coerce(whenTrue, sharedType), coerce(whenFalse, sharedType))
+ Select(
+ bool(condition),
+ coerce(whenTrue, sharedType),
+ coerce(whenFalse, sharedType),
+ )
case SeqMember(x, xs) =>
val (coercedSeq, seqType) = seq(xs)
val sharedType = Types.leastCommonSuperType(x.t, seqType.element)
@@ -1278,12 +1712,19 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
case update @ SeqUpdate(xs, i, x) =>
val (coercedSeq, seqType) = seq(xs)
val sharedType = Types.leastCommonSuperType(x.t, seqType.element)
- SeqUpdate(coerce(coercedSeq, TSeq(sharedType)), int(i), coerce(x, sharedType))
+ SeqUpdate(
+ coerce(coercedSeq, TSeq(sharedType)),
+ int(i),
+ coerce(x, sharedType),
+ )
case SetIntersection(xs, ys) =>
val (left, TSet(leftT)) = set(xs)
val (right, TSet(rightT)) = set(ys)
val sharedElement = Types.leastCommonSuperType(leftT, rightT)
- SetIntersection(coerce(left, TSet(sharedElement)), coerce(right, TSet(sharedElement)))
+ SetIntersection(
+ coerce(left, TSet(sharedElement)),
+ coerce(right, TSet(sharedElement)),
+ )
case SetMember(x, xs) =>
val (coercedSet, setType) = set(xs)
val sharedType = Types.leastCommonSuperType(x.t, setType.element)
@@ -1292,42 +1733,41 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
val (left, TSet(leftT)) = set(xs)
val (right, TSet(rightT)) = set(ys)
val sharedElement = Types.leastCommonSuperType(leftT, rightT)
- SetMinus(coerce(left, TSet(sharedElement)), coerce(right, TSet(sharedElement)))
+ SetMinus(
+ coerce(left, TSet(sharedElement)),
+ coerce(right, TSet(sharedElement)),
+ )
case SetUnion(xs, ys) =>
val (left, TSet(leftT)) = set(xs)
val (right, TSet(rightT)) = set(ys)
val sharedElement = Types.leastCommonSuperType(leftT, rightT)
- SetUnion(coerce(left, TSet(sharedElement)), coerce(right, TSet(sharedElement)))
+ SetUnion(
+ coerce(left, TSet(sharedElement)),
+ coerce(right, TSet(sharedElement)),
+ )
case SharedMemSize(xs) =>
- firstOk(e, s"Expected operand to be a pointer or array, but got ${xs.t}.",
+ firstOk(
+ e,
+ s"Expected operand to be a pointer or array, but got ${xs.t}.",
SharedMemSize(array(xs)._1),
SharedMemSize(pointer(xs)._1),
)
- case SilverBagSize(xs) =>
- SilverBagSize(bag(xs)._1)
- case SilverCurFieldPerm(obj, field) =>
- SilverCurFieldPerm(ref(obj), field)
+ case SilverBagSize(xs) => SilverBagSize(bag(xs)._1)
+ case SilverCurFieldPerm(obj, field) => SilverCurFieldPerm(ref(obj), field)
case SilverCurPredPerm(ref, args) =>
SilverCurPredPerm(ref, coerceArgs(args, ref.decl))
case deref @ SilverDeref(obj, field) =>
SilverDeref(ref(obj), field)(deref.blame)
- case SilverIntToRat(perm) =>
- SilverIntToRat(int(perm))
- case SilverMapSize(xs) =>
- SilverMapSize(map(xs)._1)
- case SilverNull() =>
- SilverNull()
+ case SilverIntToRat(perm) => SilverIntToRat(int(perm))
+ case SilverMapSize(xs) => SilverMapSize(map(xs)._1)
+ case SilverNull() => SilverNull()
case SilverPartialADTFunctionInvocation(name, args, partialTypeArgs) => e
- case SilverSetSize(xs) =>
- SilverSetSize(set(xs)._1)
- case SilverSeqSize(xs) =>
- SilverSeqSize(seq(xs)._1)
+ case SilverSetSize(xs) => SilverSetSize(set(xs)._1)
+ case SilverSeqSize(xs) => SilverSeqSize(seq(xs)._1)
case SilverUntypedNonemptyLiteralMap(values) =>
SilverUntypedNonemptyLiteralMap(values)
- case Size(obj) =>
- Size(sized(obj)._1)
- case Slice(xs, from, to) =>
- Slice(seq(xs)._1, int(from), int(to))
+ case Size(obj) => Size(sized(obj)._1)
+ case Slice(xs, from, to) => Slice(seq(xs)._1, int(from), int(to))
case SmtlibBitvecLiteral(data) => SmtlibBitvecLiteral(data)
case SmtlibBvAdd(left, right) => bitvec2(left, right, SmtlibBvAdd(_, _))
case SmtlibBvAnd(left, right) => bitvec2(left, right, SmtlibBvAnd(_, _))
@@ -1342,9 +1782,17 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
case SmtlibBvURem(left, right) => bitvec2(left, right, SmtlibBvURem(_, _))
case SmtlibConcat(left, right) => bitvec2(left, right, SmtlibConcat(_, _))
case SmtlibExtract(inclusiveEndIndexFromRight, startIndexFromRight, bv) =>
- SmtlibExtract(inclusiveEndIndexFromRight, startIndexFromRight, bitvec(bv)._1)
+ SmtlibExtract(
+ inclusiveEndIndexFromRight,
+ startIndexFromRight,
+ bitvec(bv)._1,
+ )
case SmtlibFp(sign, exponent, mantissa) =>
- SmtlibFp(coerce(sign, TSmtlibBitVector(1)), bitvec(exponent)._1, bitvec(mantissa)._1)
+ SmtlibFp(
+ coerce(sign, TSmtlibBitVector(1)),
+ bitvec(exponent)._1,
+ bitvec(mantissa)._1,
+ )
case SmtlibFpAbs(arg) => SmtlibFpAbs(fp(arg)._1)
case SmtlibFpAdd(left, right) => fp2(left, right, SmtlibFpAdd(_, _))
case SmtlibFpCast(arg, exponentBits, mantissaAndSignBits) =>
@@ -1380,35 +1828,46 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
case SmtlibFpToSInt(arg, bits) => SmtlibFpToSInt(fp(arg)._1, bits)
case SmtlibFpToUInt(arg, bits) => SmtlibFpToUInt(fp(arg)._1, bits)
case SmtlibIsInt(arg) =>
- firstOk(e, s"Expected operand to be floating, but got ${arg.t}.",
+ firstOk(
+ e,
+ s"Expected operand to be floating, but got ${arg.t}.",
SmtlibIsInt(float(arg)),
SmtlibIsInt(rat(arg)),
)
case SmtlibToInt(arg) => SmtlibToInt(rat(arg))
case SmtlibToReal(arg) => SmtlibToReal(int(arg))
case pow @ SmtlibPow(left, right) =>
- firstOk(e, s"Expected args to be numerical, but got ${left.t} and ${right.t}.",
+ firstOk(
+ e,
+ s"Expected args to be numerical, but got ${left.t} and ${right.t}.",
SmtlibPow(int(left), int(right)),
- floatOp2(pow, (l,r) => SmtlibPow(l, r)),
+ floatOp2(pow, (l, r) => SmtlibPow(l, r)),
SmtlibPow(rat(left), rat(right)),
)
case SmtlibLiteralString(data) => SmtlibLiteralString(data)
case SmtlibReAll() => SmtlibReAll()
case SmtlibReAllChar() => SmtlibReAllChar()
case SmtlibReComp(arg) => SmtlibReComp(reglan(arg))
- case SmtlibReConcat(left, right) => SmtlibReConcat(reglan(left), reglan(right))
- case SmtlibReContains(re, str) => SmtlibReContains(reglan(re), smtstr(str))
- case SmtlibReDiff(left, right) => SmtlibReDiff(reglan(left), reglan(right))
+ case SmtlibReConcat(left, right) =>
+ SmtlibReConcat(reglan(left), reglan(right))
+ case SmtlibReContains(re, str) =>
+ SmtlibReContains(reglan(re), smtstr(str))
+ case SmtlibReDiff(left, right) =>
+ SmtlibReDiff(reglan(left), reglan(right))
case SmtlibReFromStr(arg) => SmtlibReFromStr(smtstr(arg))
- case SmtlibReInter(left, right) => SmtlibReInter(reglan(left), reglan(right))
+ case SmtlibReInter(left, right) =>
+ SmtlibReInter(reglan(left), reglan(right))
case SmtlibReNone() => SmtlibReNone()
case SmtlibReOpt(arg) => SmtlibReOpt(reglan(arg))
case SmtlibRePlus(arg) => SmtlibRePlus(reglan(arg))
- case SmtlibReRange(left, right) => SmtlibReRange(smtstr(left), smtstr(right))
+ case SmtlibReRange(left, right) =>
+ SmtlibReRange(smtstr(left), smtstr(right))
case SmtlibReRepeat(count, arg) => SmtlibReRepeat(count, reglan(arg))
- case SmtlibReRepeatRange(from, to, arg) => SmtlibReRepeatRange(from, to, reglan(arg))
+ case SmtlibReRepeatRange(from, to, arg) =>
+ SmtlibReRepeatRange(from, to, reglan(arg))
case SmtlibReStar(arg) => SmtlibReStar(reglan(arg))
- case SmtlibReUnion(left, right) => SmtlibReUnion(reglan(left), reglan(right))
+ case SmtlibReUnion(left, right) =>
+ SmtlibReUnion(reglan(left), reglan(right))
case SmtlibRNA() => SmtlibRNA()
case SmtlibRNE() => SmtlibRNE()
case SmtlibRTN() => SmtlibRTN()
@@ -1419,85 +1878,111 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
SmtlibSelect(e, i.zip(t.index).map { case (e, t) => coerce(e, t) })
case SmtlibStore(arr, i, x) =>
val (e, t) = smtarr(arr)
- SmtlibStore(e, i.zip(t.index).map { case (e, t) => coerce(e, t) }, coerce(x, t.value))
+ SmtlibStore(
+ e,
+ i.zip(t.index).map { case (e, t) => coerce(e, t) },
+ coerce(x, t.value),
+ )
case SmtlibStrAt(str, i) => SmtlibStrAt(smtstr(str), int(i))
- case SmtlibStrConcat(left, right) => SmtlibStrConcat(smtstr(left), smtstr(right))
- case SmtlibStrContains(left, right) => SmtlibStrContains(smtstr(left), smtstr(right))
+ case SmtlibStrConcat(left, right) =>
+ SmtlibStrConcat(smtstr(left), smtstr(right))
+ case SmtlibStrContains(left, right) =>
+ SmtlibStrContains(smtstr(left), smtstr(right))
case SmtlibStrFromCode(arg) => SmtlibStrFromCode(int(arg))
case SmtlibStrFromInt(arg) => SmtlibStrFromInt(int(arg))
- case SmtlibStrIndexOf(haystack, needle, fromIndex) => SmtlibStrIndexOf(smtstr(haystack), smtstr(needle), int(fromIndex))
+ case SmtlibStrIndexOf(haystack, needle, fromIndex) =>
+ SmtlibStrIndexOf(smtstr(haystack), smtstr(needle), int(fromIndex))
case SmtlibStrIsDigit(arg) => SmtlibStrIsDigit(smtstr(arg))
case SmtlibStrLen(arg) => SmtlibStrLen(smtstr(arg))
- case SmtlibStrLeq(left, right) => SmtlibStrLeq(smtstr(left), smtstr(right))
+ case SmtlibStrLeq(left, right) =>
+ SmtlibStrLeq(smtstr(left), smtstr(right))
case SmtlibStrLt(left, right) => SmtlibStrLt(smtstr(left), smtstr(right))
- case SmtlibStrPrefixOf(left, right) => SmtlibStrPrefixOf(smtstr(left), smtstr(right))
- case SmtlibStrReplace(haystack, needle, replacement) => SmtlibStrReplace(smtstr(haystack), smtstr(needle), smtstr(replacement))
- case SmtlibStrReplaceAll(haystack, needle, replacement) => SmtlibStrReplaceAll(smtstr(haystack), smtstr(needle), smtstr(replacement))
- case SmtlibStrReplaceRe(haystack, re, replacement) => SmtlibStrReplaceRe(smtstr(haystack), reglan(re), smtstr(replacement))
- case SmtlibStrReplaceReAll(haystack, re, replacement) => SmtlibStrReplaceReAll(smtstr(haystack), reglan(re), smtstr(replacement))
- case SmtlibStrSuffixOf(left, right) => SmtlibStrSuffixOf(smtstr(left), smtstr(right))
+ case SmtlibStrPrefixOf(left, right) =>
+ SmtlibStrPrefixOf(smtstr(left), smtstr(right))
+ case SmtlibStrReplace(haystack, needle, replacement) =>
+ SmtlibStrReplace(smtstr(haystack), smtstr(needle), smtstr(replacement))
+ case SmtlibStrReplaceAll(haystack, needle, replacement) =>
+ SmtlibStrReplaceAll(
+ smtstr(haystack),
+ smtstr(needle),
+ smtstr(replacement),
+ )
+ case SmtlibStrReplaceRe(haystack, re, replacement) =>
+ SmtlibStrReplaceRe(smtstr(haystack), reglan(re), smtstr(replacement))
+ case SmtlibStrReplaceReAll(haystack, re, replacement) =>
+ SmtlibStrReplaceReAll(smtstr(haystack), reglan(re), smtstr(replacement))
+ case SmtlibStrSuffixOf(left, right) =>
+ SmtlibStrSuffixOf(smtstr(left), smtstr(right))
case SmtlibStrToCode(arg) => SmtlibStrToCode(smtstr(arg))
case SmtlibStrToInt(arg) => SmtlibStrToInt(smtstr(arg))
case SmtlibSubstr(str, i, n) => SmtlibSubstr(smtstr(str), int(i), int(n))
- case SmtlibToFp(bv, e, m) => SmtlibToFp(coerce(bv, TSmtlibBitVector(e + m)), e, m)
- case Star(left, right) =>
- Star(res(left), res(right))
+ case SmtlibToFp(bv, e, m) =>
+ SmtlibToFp(coerce(bv, TSmtlibBitVector(e + m)), e, m)
+ case Star(left, right) => Star(res(left), res(right))
case starall @ Starall(bindings, triggers, body) =>
Starall(bindings, triggers, res(body))(starall.blame)
case SubBag(left, right) =>
val (coercedLeft, leftBag) = bag(left)
val (coercedRight, rightBag) = bag(right)
- val sharedType = Types.leastCommonSuperType(leftBag.element, rightBag.element)
- SubBag(coerce(coercedLeft, TBag(sharedType)), coerce(coercedRight, TBag(sharedType)))
+ val sharedType = Types
+ .leastCommonSuperType(leftBag.element, rightBag.element)
+ SubBag(
+ coerce(coercedLeft, TBag(sharedType)),
+ coerce(coercedRight, TBag(sharedType)),
+ )
case SubBagEq(left, right) =>
val (coercedLeft, leftBag) = bag(left)
val (coercedRight, rightBag) = bag(right)
- val sharedType = Types.leastCommonSuperType(leftBag.element, rightBag.element)
- SubBagEq(coerce(coercedLeft, TBag(sharedType)), coerce(coercedRight, TBag(sharedType)))
+ val sharedType = Types
+ .leastCommonSuperType(leftBag.element, rightBag.element)
+ SubBagEq(
+ coerce(coercedLeft, TBag(sharedType)),
+ coerce(coercedRight, TBag(sharedType)),
+ )
case SubSet(left, right) =>
val (coercedLeft, leftSet) = set(left)
val (coercedRight, rightSet) = set(right)
- val sharedType = Types.leastCommonSuperType(leftSet.element, rightSet.element)
- SubSet(coerce(coercedLeft, TSet(sharedType)), coerce(coercedRight, TSet(sharedType)))
+ val sharedType = Types
+ .leastCommonSuperType(leftSet.element, rightSet.element)
+ SubSet(
+ coerce(coercedLeft, TSet(sharedType)),
+ coerce(coercedRight, TSet(sharedType)),
+ )
case SubSetEq(left, right) =>
val (coercedLeft, leftSet) = set(left)
val (coercedRight, rightSet) = set(right)
- val sharedType = Types.leastCommonSuperType(leftSet.element, rightSet.element)
- SubSetEq(coerce(coercedLeft, TSet(sharedType)), coerce(coercedRight, TSet(sharedType)))
- case SubType(left, right) =>
- SubType(left, right)
+ val sharedType = Types
+ .leastCommonSuperType(leftSet.element, rightSet.element)
+ SubSetEq(
+ coerce(coercedLeft, TSet(sharedType)),
+ coerce(coercedRight, TSet(sharedType)),
+ )
+ case SubType(left, right) => SubType(left, right)
case Sum(bindings, condition, main) =>
Sum(bindings, bool(condition), int(main))
- case SuperType(left, right) =>
- SuperType(left, right)
- case Tail(xs) =>
- Tail(seq(xs)._1)
- case Take(xs, count) =>
- Take(seq(xs)._1, int(count))
- case Then(value, post) =>
- Then(value, post)
- case ThisModel(ref) =>
- ThisModel(ref)
- case ThisChoreography(ref) =>
- ThisChoreography(ref)
- case ThisObject(ref) =>
- ThisObject(ref)
- case div@TruncMod(left, right) => TruncMod(int(left), int(right))(div.blame)
- case div@TruncDiv(left, right) => TruncDiv(int(left), int(right))(div.blame)
- case TupGet(tup, index) =>
- TupGet(tuple(tup)._1, index)
- case TypeOf(expr) =>
- TypeOf(expr)
- case TypeValue(value) =>
- TypeValue(value)
+ case SuperType(left, right) => SuperType(left, right)
+ case Tail(xs) => Tail(seq(xs)._1)
+ case Take(xs, count) => Take(seq(xs)._1, int(count))
+ case Then(value, post) => Then(value, post)
+ case ThisModel(ref) => ThisModel(ref)
+ case ThisChoreography(ref) => ThisChoreography(ref)
+ case ThisObject(ref) => ThisObject(ref)
+ case div @ TruncMod(left, right) =>
+ TruncMod(int(left), int(right))(div.blame)
+ case div @ TruncDiv(left, right) =>
+ TruncDiv(int(left), int(right))(div.blame)
+ case TupGet(tup, index) => TupGet(tuple(tup)._1, index)
+ case TypeOf(expr) => TypeOf(expr)
+ case TypeValue(value) => TypeValue(value)
case UMinus(arg) =>
- firstOk(e, s"Expected operand to be numeric, but got ${arg.t}.",
+ firstOk(
+ e,
+ s"Expected operand to be numeric, but got ${arg.t}.",
UMinus(int(arg)),
UMinus(float(arg)),
UMinus(rat(arg)),
)
- case u @ Unfolding(pred, body) =>
- Unfolding(res(pred), body)(u.blame)
+ case u @ Unfolding(pred, body) => Unfolding(res(pred), body)(u.blame)
case UntypedLiteralBag(values) =>
val sharedType = Types.leastCommonSuperType(values.map(_.t))
UntypedLiteralBag(values.map(coerce(_, sharedType)))
@@ -1507,70 +1992,82 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
case UntypedLiteralSet(values) =>
val sharedType = Types.leastCommonSuperType(values.map(_.t))
UntypedLiteralSet(values.map(coerce(_, sharedType)))
- case ValidArray(arr, len) =>
- ValidArray(array(arr)._1, int(len))
+ case ValidArray(arr, len) => ValidArray(array(arr)._1, int(len))
case ValidMatrix(mat, w, h) =>
ValidMatrix(arrayMatrix(mat)._1, int(w), int(h))
case value: BooleanValue[Pre] => e
case value: CIntegerValue[Pre] => e
case value: IntegerValue[Pre] => e
case value: FloatValue[Pre] => e
- case value @ Value(loc) =>
- Value(loc)
- case value @ AutoValue(loc) =>
- value
+ case value @ Value(loc) => Value(loc)
+ case value @ AutoValue(loc) => value
case values @ Values(arr, from, to) =>
Values(array(arr)._1, int(from), int(to))(values.blame)
case VectorCompare(left, right) =>
val (coercedLeft, leftType) = seq(left)
val (coercedRight, rightType) = seq(right)
- val sharedType = Types.leastCommonSuperType(leftType.element, rightType.element)
+ val sharedType = Types
+ .leastCommonSuperType(leftType.element, rightType.element)
val seqType = TSeq(sharedType)
- VectorCompare(coerce(coercedLeft, seqType), coerce(coercedRight, seqType))
+ VectorCompare(
+ coerce(coercedLeft, seqType),
+ coerce(coercedRight, seqType),
+ )
case VectorEq(left, right) =>
val (coercedLeft, leftType) = vector(left)
val (coercedRight, rightType) = vector(right)
- if(leftType.size != rightType.size)
- throw IncoercibleExplanation(e, s"Expected both operands to have a vector type of equal size, " +
- s"but got ${leftType} and ${rightType}")
+ if (leftType.size != rightType.size)
+ throw IncoercibleExplanation(
+ e,
+ s"Expected both operands to have a vector type of equal size, " +
+ s"but got ${leftType} and ${rightType}",
+ )
- val sharedType = Types.leastCommonSuperType(leftType.element, rightType.element)
+ val sharedType = Types
+ .leastCommonSuperType(leftType.element, rightType.element)
val vectorType = TVector(leftType.size, sharedType)
VectorEq(coerce(left, vectorType), coerce(right, vectorType))
- case div @ VectorFloatDiv(_, _) => vectorFloatOp2(div, (l,r) => VectorFloatDiv(l,r)(div.blame))
- case div @ VectorFloorDiv(_, _) => vectorIntOp2(div, (l,r) => VectorFloorDiv(l,r)(div.blame))
+ case div @ VectorFloatDiv(_, _) =>
+ vectorFloatOp2(div, (l, r) => VectorFloatDiv(l, r)(div.blame))
+ case div @ VectorFloorDiv(_, _) =>
+ vectorIntOp2(div, (l, r) => VectorFloorDiv(l, r)(div.blame))
case minus @ VectorMinus(_, _) =>
- vectorOp2(minus, (l,r) => VectorMinus(l,r))
- case mod@ VectorMod(_, _) => vectorIntOp2(mod, (l,r) => VectorMod(l,r)(mod.blame))
+ vectorOp2(minus, (l, r) => VectorMinus(l, r))
+ case mod @ VectorMod(_, _) =>
+ vectorIntOp2(mod, (l, r) => VectorMod(l, r)(mod.blame))
case mult @ VectorMult(_, _) =>
- vectorOp2(mult, (l,r) => VectorMult(l,r))
+ vectorOp2(mult, (l, r) => VectorMult(l, r))
case VectorNeq(left, right) =>
val sharedType = Types.leastCommonSuperType(left.t, right.t)
VectorNeq(coerce(left, sharedType), coerce(right, sharedType))
case plus @ VectorPlus(_, _) =>
- vectorOp2(plus, (l,r) => VectorPlus(l,r))
- case VectorRepeat(e) =>
- VectorRepeat(e)
+ vectorOp2(plus, (l, r) => VectorPlus(l, r))
+ case VectorRepeat(e) => VectorRepeat(e)
case get @ VectorSubscript(xs, index) =>
VectorSubscript(vector(xs)._1, int(index))(get.blame)
case VectorSum(indices, vec) =>
- VectorSum(coerce(indices, TSeq[Pre](TInt())), coerce(vec, TSeq[Pre](TRational())))
- case div @ VectorTruncDiv(_, _) => vectorIntOp2(div, (l,r) => VectorTruncDiv(l,r)(div.blame))
- case mod @ VectorTruncMod(_, _) => vectorIntOp2(mod, (l,r) => VectorTruncMod(l,r)(mod.blame))
- case Void() =>
- Void()
- case Wand(left, right) =>
- Wand(res(left), res(right))
- case With(pre, value) =>
- With(pre, value)
- case WritePerm() =>
- WritePerm()
- case Z3ArrayConst(domain, codomain, value) => Z3ArrayConst(domain, codomain, coerce(value, codomain))
+ VectorSum(
+ coerce(indices, TSeq[Pre](TInt())),
+ coerce(vec, TSeq[Pre](TRational())),
+ )
+ case div @ VectorTruncDiv(_, _) =>
+ vectorIntOp2(div, (l, r) => VectorTruncDiv(l, r)(div.blame))
+ case mod @ VectorTruncMod(_, _) =>
+ vectorIntOp2(mod, (l, r) => VectorTruncMod(l, r)(mod.blame))
+ case Void() => Void()
+ case Wand(left, right) => Wand(res(left), res(right))
+ case With(pre, value) => With(pre, value)
+ case WritePerm() => WritePerm()
+ case Z3ArrayConst(domain, codomain, value) =>
+ Z3ArrayConst(domain, codomain, coerce(value, codomain))
case Z3ArrayMap(ref, arg +: args) =>
val (_, TSmtlibArray(keyType, _)) = smtarr(arg)
val ts = ref.ref.decl.args.map(_.t).map(TSmtlibArray(keyType, _))
- Z3ArrayMap(ref, (arg +: args).zip(ts).map { case (e, t) => coerce(e, t) })
+ Z3ArrayMap(
+ ref,
+ (arg +: args).zip(ts).map { case (e, t) => coerce(e, t) },
+ )
case Z3ArrayMap(ref, _) => Z3ArrayMap(ref, Nil)
case Z3ArrayOfFunction(ref) => Z3ArrayOfFunction(ref)
case Z3BvNand(left, right) => bitvec2(left, right, Z3BvNand(_, _))
@@ -1581,31 +2078,53 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
case Z3BvSub(left, right) => bitvec2(left, right, Z3BvSub(_, _))
case Z3BvXnor(left, right) => bitvec2(left, right, Z3BvXnor(_, _))
case Z3SeqAt(seq, offset) => Z3SeqAt(z3seq(seq)._1, int(offset))
- case Z3SeqConcat(left, right) => Z3SeqConcat(z3seq(left)._1, z3seq(right)._1)
- case Z3SeqContains(seq, subseq) => Z3SeqContains(z3seq(seq)._1, z3seq(subseq)._1)
+ case Z3SeqConcat(left, right) =>
+ Z3SeqConcat(z3seq(left)._1, z3seq(right)._1)
+ case Z3SeqContains(seq, subseq) =>
+ Z3SeqContains(z3seq(seq)._1, z3seq(subseq)._1)
case Z3SeqEmpty(elementType) => Z3SeqEmpty(elementType)
- case Z3SeqExtract(seq, offset, len) => Z3SeqExtract(z3seq(seq)._1, int(offset), int(len))
+ case Z3SeqExtract(seq, offset, len) =>
+ Z3SeqExtract(z3seq(seq)._1, int(offset), int(len))
case Z3SeqFoldl(f, base, seq) =>
val (cseq, seqt) = z3seq(seq)
- Z3SeqFoldl(coerce(f, TSmtlibArray(Seq(base.t, seqt.element), base.t)), base, cseq)
+ Z3SeqFoldl(
+ coerce(f, TSmtlibArray(Seq(base.t, seqt.element), base.t)),
+ base,
+ cseq,
+ )
case Z3SeqFoldlI(f, offset, base, seq) =>
val (cseq, seqt) = z3seq(seq)
- Z3SeqFoldlI(coerce(f, TSmtlibArray(Seq(TInt(), base.t, seqt.element), base.t)), int(offset), base, cseq)
+ Z3SeqFoldlI(
+ coerce(f, TSmtlibArray(Seq(TInt(), base.t, seqt.element), base.t)),
+ int(offset),
+ base,
+ cseq,
+ )
case Z3SeqLen(arg) => Z3SeqLen(z3seq(arg)._1)
case Z3SeqMap(f, seq) =>
val (cf, arrt) = smtarr(f)
- if(arrt.index.size != 1) coerce(f, TSmtlibArray(Seq(TAnyValue()), arrt.value))
+ if (arrt.index.size != 1)
+ coerce(f, TSmtlibArray(Seq(TAnyValue()), arrt.value))
Z3SeqMap(cf, coerce(seq, TSmtlibSeq(arrt.index.head)))
case Z3SeqMapI(f, offset, seq) =>
val (cf, arrt) = smtarr(f)
- if(arrt.index.size != 2) coerce(f, TSmtlibArray(Seq(TInt(), TAnyValue()), arrt.value))
+ if (arrt.index.size != 2)
+ coerce(f, TSmtlibArray(Seq(TInt(), TAnyValue()), arrt.value))
Z3SeqMapI(cf, int(offset), coerce(seq, TSmtlibSeq(arrt.index(1))))
case Z3SeqNth(seq, offset) => Z3SeqNth(z3seq(seq)._1, int(offset))
- case Z3SeqPrefixOf(pre, subseq) => Z3SeqPrefixOf(z3seq(pre)._1, z3seq(subseq)._1)
- case Z3SeqReplace(haystack, needle, replacement) => Z3SeqReplace(z3seq(haystack)._1, z3seq(needle)._1, z3seq(replacement)._1)
- case Z3SeqSuffixOf(post, seq) => Z3SeqSuffixOf(z3seq(post)._1, z3seq(seq)._1)
+ case Z3SeqPrefixOf(pre, subseq) =>
+ Z3SeqPrefixOf(z3seq(pre)._1, z3seq(subseq)._1)
+ case Z3SeqReplace(haystack, needle, replacement) =>
+ Z3SeqReplace(
+ z3seq(haystack)._1,
+ z3seq(needle)._1,
+ z3seq(replacement)._1,
+ )
+ case Z3SeqSuffixOf(post, seq) =>
+ Z3SeqSuffixOf(z3seq(post)._1, z3seq(seq)._1)
case Z3SeqUnit(arg) => Z3SeqUnit(arg)
- case Z3TransitiveClosure(ref, args) => Z3TransitiveClosure(ref, coerceArgs(args, ref.ref.decl))
+ case Z3TransitiveClosure(ref, args) =>
+ Z3TransitiveClosure(ref, coerceArgs(args, ref.ref.decl))
case localIncoming: BipLocalIncomingData[Pre] => localIncoming
case glue: JavaBipGlue[Pre] => glue
case LlvmLocal(name) => e
@@ -1623,14 +2142,17 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
stat match {
case a @ Assert(assn) => Assert(res(assn))(a.blame)
case a @ Assign(target, value) =>
- try { Assign(target, coerce(value, target.t, canCDemote=true))(a.blame) } catch {
+ try {
+ Assign(target, coerce(value, target.t, canCDemote = true))(a.blame)
+ } catch {
case err: Incoercible =>
println(err.text)
throw err
}
case Assume(assn) => Assume(bool(assn))
case Block(statements) => Block(statements)
- case Branch(branches) => Branch(branches.map { case (cond, effect) => (bool(cond), effect) })
+ case Branch(branches) =>
+ Branch(branches.map { case (cond, effect) => (bool(cond), effect) })
case Break(label) => Break(label)
case Case(pattern) => Case(pattern)
case CDeclarationStatement(decl) => CDeclarationStatement(decl)
@@ -1645,69 +2167,147 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
case Extract(body) => Extract(body)
case f @ Fold(assn) => Fold(res(assn))(f.blame)
case f @ Fork(obj) => Fork(cls(obj))(f.blame)
- case proof @ FramedProof(pre, body, post) => FramedProof(res(pre), body, res(post))(proof.blame)
+ case proof @ FramedProof(pre, body, post) =>
+ FramedProof(res(pre), body, res(post))(proof.blame)
case Goto(lbl) => Goto(lbl)
case GpgpuAtomic(impl, before, after) => GpgpuAtomic(impl, before, after)
- case b @ GpgpuBarrier(requires, ensures, specifier) => GpgpuBarrier(res(requires), res(ensures), specifier)(b.blame)
+ case b @ GpgpuBarrier(requires, ensures, specifier) =>
+ GpgpuBarrier(res(requires), res(ensures), specifier)(b.blame)
case Havoc(loc) => Havoc(loc)
case IndetBranch(branches) => IndetBranch(branches)
case Inhale(assn) => Inhale(res(assn))
case Instantiate(cls, dest) => Instantiate(cls, dest)
- case inv @ InvokeConstructor(ref, classTypeArgs, out, args, outArgs, typeArgs, givenMap, yields) =>
+ case inv @ InvokeConstructor(
+ ref,
+ classTypeArgs,
+ out,
+ args,
+ outArgs,
+ typeArgs,
+ givenMap,
+ yields,
+ ) =>
val cls = TClass(ref.decl.cls, classTypeArgs)
- InvokeConstructor(ref, classTypeArgs, out, coerceArgs(args, ref.decl, inv.typeEnv, canCDemote = true), outArgs, typeArgs, coerceGiven(givenMap, canCDemote = true), coerceYields(yields, args.head))(inv.blame)
- case inv @ InvokeProcedure(ref, args, outArgs, typeArgs, givenMap, yields) =>
- InvokeProcedure(ref, coerceArgs(args, ref.decl, inv.typeEnv, canCDemote=true), outArgs, typeArgs, coerceGiven(givenMap,canCDemote=true), coerceYields(yields, args.head))(inv.blame)
- case inv @ InvokeMethod(obj, ref, args, outArgs, typeArgs, givenMap, yields) =>
- InvokeMethod(cls(obj), ref, coerceArgs(args, ref.decl, inv.typeEnv, canCDemote=true), outArgs, typeArgs, coerceGiven(givenMap,canCDemote=true), coerceYields(yields, args.head))(inv.blame)
- case JavaLocalDeclarationStatement(decl) => JavaLocalDeclarationStatement(decl)
+ InvokeConstructor(
+ ref,
+ classTypeArgs,
+ out,
+ coerceArgs(args, ref.decl, inv.typeEnv, canCDemote = true),
+ outArgs,
+ typeArgs,
+ coerceGiven(givenMap, canCDemote = true),
+ coerceYields(yields, args.head),
+ )(inv.blame)
+ case inv @ InvokeProcedure(
+ ref,
+ args,
+ outArgs,
+ typeArgs,
+ givenMap,
+ yields,
+ ) =>
+ InvokeProcedure(
+ ref,
+ coerceArgs(args, ref.decl, inv.typeEnv, canCDemote = true),
+ outArgs,
+ typeArgs,
+ coerceGiven(givenMap, canCDemote = true),
+ coerceYields(yields, args.head),
+ )(inv.blame)
+ case inv @ InvokeMethod(
+ obj,
+ ref,
+ args,
+ outArgs,
+ typeArgs,
+ givenMap,
+ yields,
+ ) =>
+ InvokeMethod(
+ cls(obj),
+ ref,
+ coerceArgs(args, ref.decl, inv.typeEnv, canCDemote = true),
+ outArgs,
+ typeArgs,
+ coerceGiven(givenMap, canCDemote = true),
+ coerceYields(yields, args.head),
+ )(inv.blame)
+ case JavaLocalDeclarationStatement(decl) =>
+ JavaLocalDeclarationStatement(decl)
case j @ Join(obj) => Join(cls(obj))(j.blame)
case Label(decl, stat) => Label(decl, stat)
case LocalDecl(local) => LocalDecl(local)
case l @ Lock(obj) => Lock(cls(obj))(l.blame)
- case Loop(init, cond, update, contract, body) => Loop(init, bool(cond), update, contract, body)
- case LlvmLoop(cond, contract, body) => LlvmLoop(bool(cond), contract, body)
- case ModelDo(model, perm, after, action, impl) => ModelDo(model, rat(perm), after, action, impl)
+ case Loop(init, cond, update, contract, body) =>
+ Loop(init, bool(cond), update, contract, body)
+ case LlvmLoop(cond, contract, body) =>
+ LlvmLoop(bool(cond), contract, body)
+ case ModelDo(model, perm, after, action, impl) =>
+ ModelDo(model, rat(perm), after, action, impl)
case n @ Notify(obj) => Notify(cls(obj))(n.blame)
case at @ ParAtomic(inv, content) => ParAtomic(inv, content)(at.blame)
- case bar @ ParBarrier(block, invs, requires, ensures, content) => ParBarrier(block, invs, res(requires), res(ensures), content)(bar.blame)
- case p @ ParInvariant(decl, inv, content) => ParInvariant(decl, res(inv), content)(p.blame)
+ case bar @ ParBarrier(block, invs, requires, ensures, content) =>
+ ParBarrier(block, invs, res(requires), res(ensures), content)(bar.blame)
+ case p @ ParInvariant(decl, inv, content) =>
+ ParInvariant(decl, res(inv), content)(p.blame)
case ParStatement(impl) => ParStatement(impl)
case RangedFor(iter, contract, body) => RangedFor(iter, contract, body)
case Recv(ref) => Recv(ref)
case r @ Refute(assn) => Refute(res(assn))(r.blame)
- case Return(result) => Return(result) // TODO coerce return, make AmbiguousReturn?
+ case Return(result) =>
+ Return(result) // TODO coerce return, make AmbiguousReturn?
case Scope(locals, body) => Scope(locals, body)
- case send @ Send(decl, offset, resource) => Send(decl, offset, res(resource))(send.blame)
- case ass @ SilverFieldAssign(obj, field, value) => SilverFieldAssign(ref(obj), field, coerce(value, field.decl.t))(ass.blame)
- case SilverLocalAssign(v, value) => SilverLocalAssign(v, coerce(value, v.decl.t))
+ case send @ Send(decl, offset, resource) =>
+ Send(decl, offset, res(resource))(send.blame)
+ case ass @ SilverFieldAssign(obj, field, value) =>
+ SilverFieldAssign(ref(obj), field, coerce(value, field.decl.t))(
+ ass.blame
+ )
+ case SilverLocalAssign(v, value) =>
+ SilverLocalAssign(v, coerce(value, v.decl.t))
case SilverNewRef(v, fields) => SilverNewRef(v, fields)
case SpecIgnoreEnd() => SpecIgnoreEnd()
case SpecIgnoreStart() => SpecIgnoreStart()
case Switch(expr, body) => Switch(expr, body)
case s @ Synchronized(obj, body) => Synchronized(cls(obj), body)(s.blame)
case t @ Throw(obj) => Throw(cls(obj))(t.blame)
- case TryCatchFinally(body, after, catches) => TryCatchFinally(body, after, catches)
+ case TryCatchFinally(body, after, catches) =>
+ TryCatchFinally(body, after, catches)
case u @ Unfold(assn) => Unfold(res(assn))(u.blame)
case u @ Unlock(obj) => Unlock(cls(obj))(u.blame)
- case VecBlock(iters, requires, ensures, content) => VecBlock(iters, res(requires), res(ensures), content)
+ case VecBlock(iters, requires, ensures, content) =>
+ VecBlock(iters, res(requires), res(ensures), content)
case w @ Wait(obj) => Wait(cls(obj))(w.blame)
case w @ WandApply(assn) => WandApply(res(assn))(w.blame)
case w @ WandPackage(expr, stat) => WandPackage(res(expr), stat)(w.blame)
- case VeyMontAssignExpression(t,a) => VeyMontAssignExpression(t,a)
- case CommunicateX(r,s,t,a) => CommunicateX(r,s,t,a)
- case c @ PVLCommunicate(receiver, target, sender, msg) if target.t == msg.t => PVLCommunicate(receiver, target, sender, msg)(c.blame)
- case comm@PVLCommunicate(receiver, target, sender, msg) => throw IncoercibleExplanation(comm, s"The message should have type ${target.t}, but actually has type ${msg.t}.")
+ case VeyMontAssignExpression(t, a) => VeyMontAssignExpression(t, a)
+ case CommunicateX(r, s, t, a) => CommunicateX(r, s, t, a)
+ case c @ PVLCommunicate(receiver, target, sender, msg)
+ if target.t == msg.t =>
+ PVLCommunicate(receiver, target, sender, msg)(c.blame)
+ case comm @ PVLCommunicate(receiver, target, sender, msg) =>
+ throw IncoercibleExplanation(
+ comm,
+ s"The message should have type ${target.t}, but actually has type ${msg.t}.",
+ )
case PVLChannelInvariant(comm, inv) => PVLChannelInvariant(comm, res(inv))
case s: PVLChorStatement[Pre] => s
case s: ChorBranch[Pre] => s
case s: ChorLoop[Pre] => s
case c: ChorStatement[Pre] => c
case c: CommunicateStatement[Pre] => c
- case branch@UnresolvedChorBranch(branches) => UnresolvedChorBranch(branches.map { case (cond, effect) => (bool(cond), effect) })(branch.blame)
- case branch@PVLBranch(branches) => PVLBranch(branches.map { case (cond, effect) => (bool(cond), effect) })(branch.blame)
- case loop@UnresolvedChorLoop(cond, contract, body) => UnresolvedChorLoop(bool(cond), contract, body)(loop.blame)
- case loop@PVLLoop(init, cond, update, contract, body) => PVLLoop(init, bool(cond), update, contract, body)(loop.blame)
+ case branch @ UnresolvedChorBranch(branches) =>
+ UnresolvedChorBranch(branches.map { case (cond, effect) =>
+ (bool(cond), effect)
+ })(branch.blame)
+ case branch @ PVLBranch(branches) =>
+ PVLBranch(branches.map { case (cond, effect) => (bool(cond), effect) })(
+ branch.blame
+ )
+ case loop @ UnresolvedChorLoop(cond, contract, body) =>
+ UnresolvedChorLoop(bool(cond), contract, body)(loop.blame)
+ case loop @ PVLLoop(init, cond, update, contract, body) =>
+ PVLLoop(init, bool(cond), update, contract, body)(loop.blame)
}
}
@@ -1718,128 +2318,185 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
new CTranslationUnit(unit.declarations)
case unit: CPPTranslationUnit[Pre] =>
new CPPTranslationUnit(unit.declarations)
- case variable: HeapVariable[Pre] =>
- new HeapVariable(variable.t)
+ case variable: HeapVariable[Pre] => new HeapVariable(variable.t)
case rule: SimplificationRule[Pre] =>
new SimplificationRule[Pre](bool(rule.axiom))
- case dataType: AxiomaticDataType[Pre] =>
- dataType
+ case dataType: AxiomaticDataType[Pre] => dataType
case clazz: Class[Pre] =>
- new Class[Pre](clazz.typeArgs, clazz.decls, clazz.supports, res(clazz.intrinsicLockInvariant))
- case enum: Enum[Pre] =>
- enum
- case enumConstant: EnumConstant[Pre] =>
- enumConstant
- case model: Model[Pre] =>
- model
+ new Class[Pre](
+ clazz.typeArgs,
+ clazz.decls,
+ clazz.supports,
+ res(clazz.intrinsicLockInvariant),
+ )
+ case enum: Enum[Pre] => enum
+ case enumConstant: EnumConstant[Pre] => enumConstant
+ case model: Model[Pre] => model
case function: Function[Pre] =>
- new Function[Pre](function.returnType, function.args, function.typeArgs, function.body.map(coerce(_, function.returnType)), function.contract, function.inline, function.threadLocal)(function.blame)
- case procedure: Procedure[Pre] =>
- procedure
- case main_method: VeSUVMainMethod[Pre] =>
- main_method
+ new Function[Pre](
+ function.returnType,
+ function.args,
+ function.typeArgs,
+ function.body.map(coerce(_, function.returnType)),
+ function.contract,
+ function.inline,
+ function.threadLocal,
+ )(function.blame)
+ case procedure: Procedure[Pre] => procedure
+ case main_method: VeSUVMainMethod[Pre] => main_method
case predicate: Predicate[Pre] =>
- new Predicate[Pre](predicate.args, predicate.body.map(res), predicate.threadLocal, predicate.inline)
- case definition: CFunctionDefinition[Pre] =>
- definition
- case declaration: CGlobalDeclaration[Pre] =>
- declaration
- case declaration: CStructMemberDeclarator[Pre] =>
- declaration
- case cons: Constructor[Pre] =>
- cons
- case definition: CPPFunctionDefinition[Pre] =>
- definition
- case declaration: CPPGlobalDeclaration[Pre] =>
- declaration
- case namespace: JavaNamespace[Pre] =>
- namespace
+ new Predicate[Pre](
+ predicate.args,
+ predicate.body.map(res),
+ predicate.threadLocal,
+ predicate.inline,
+ )
+ case definition: CFunctionDefinition[Pre] => definition
+ case declaration: CGlobalDeclaration[Pre] => declaration
+ case declaration: CStructMemberDeclarator[Pre] => declaration
+ case cons: Constructor[Pre] => cons
+ case definition: CPPFunctionDefinition[Pre] => definition
+ case declaration: CPPGlobalDeclaration[Pre] => declaration
+ case namespace: JavaNamespace[Pre] => namespace
case clazz: JavaClass[Pre] =>
- new JavaClass[Pre](clazz.name, clazz.modifiers, clazz.typeParams, res(clazz.intrinsicLockInvariant), clazz.ext, clazz.imp, clazz.decls)(clazz.blame)
- case interface: JavaInterface[Pre] =>
- interface
- case interface: JavaAnnotationInterface[Pre] =>
- interface
- case field: SilverField[Pre] =>
- field
+ new JavaClass[Pre](
+ clazz.name,
+ clazz.modifiers,
+ clazz.typeParams,
+ res(clazz.intrinsicLockInvariant),
+ clazz.ext,
+ clazz.imp,
+ clazz.decls,
+ )(clazz.blame)
+ case interface: JavaInterface[Pre] => interface
+ case interface: JavaAnnotationInterface[Pre] => interface
+ case field: SilverField[Pre] => field
case function: InstanceFunction[Pre] =>
- new InstanceFunction[Pre](function.returnType, function.args, function.typeArgs, function.body.map(coerce(_, function.returnType)), function.contract, function.inline, function.threadLocal)(function.blame)
- case method: InstanceMethod[Pre] =>
- method
+ new InstanceFunction[Pre](
+ function.returnType,
+ function.args,
+ function.typeArgs,
+ function.body.map(coerce(_, function.returnType)),
+ function.contract,
+ function.inline,
+ function.threadLocal,
+ )(function.blame)
+ case method: InstanceMethod[Pre] => method
case predicate: InstancePredicate[Pre] =>
- new InstancePredicate[Pre](predicate.args, predicate.body.map(res), predicate.threadLocal, predicate.inline)
- case field: InstanceField[Pre] =>
- field
- case method: RunMethod[Pre] =>
- method
- case method: InstanceOperatorMethod[Pre] =>
- method
+ new InstancePredicate[Pre](
+ predicate.args,
+ predicate.body.map(res),
+ predicate.threadLocal,
+ predicate.inline,
+ )
+ case field: InstanceField[Pre] => field
+ case method: RunMethod[Pre] => method
+ case method: InstanceOperatorMethod[Pre] => method
case function: InstanceOperatorFunction[Pre] =>
- new InstanceOperatorFunction[Pre](function.returnType, function.operator, function.args, function.body.map(coerce(_, function.returnType)), function.contract, function.inline, function.threadLocal)(function.o)
- case initialization: JavaSharedInitialization[Pre] =>
- initialization
+ new InstanceOperatorFunction[Pre](
+ function.returnType,
+ function.operator,
+ function.args,
+ function.body.map(coerce(_, function.returnType)),
+ function.contract,
+ function.inline,
+ function.threadLocal,
+ )(function.o)
+ case initialization: JavaSharedInitialization[Pre] => initialization
case fields: JavaFields[Pre] =>
- new JavaFields[Pre](fields.modifiers, fields.t, fields.decls.map {
- case JavaVariableDeclaration(name, dims, None) => JavaVariableDeclaration(name, dims, None)
- case JavaVariableDeclaration(name, dims, Some(v)) =>
- JavaVariableDeclaration(name, dims, Some(coerce(v, FuncTools.repeat[Type[Pre]](TArray(_), dims, fields.t))))
- })
- case constructor: JavaConstructor[Pre] =>
- constructor
- case method: JavaMethod[Pre] =>
- method
- case param: JavaParam[Pre] =>
- param
- case method: JavaAnnotationMethod[Pre] =>
- method
- case constructor: PVLConstructor[Pre] =>
- constructor
- case field: ModelField[Pre] =>
- field
+ new JavaFields[Pre](
+ fields.modifiers,
+ fields.t,
+ fields.decls.map {
+ case JavaVariableDeclaration(name, dims, None) =>
+ JavaVariableDeclaration(name, dims, None)
+ case JavaVariableDeclaration(name, dims, Some(v)) =>
+ JavaVariableDeclaration(
+ name,
+ dims,
+ Some(coerce(
+ v,
+ FuncTools.repeat[Type[Pre]](TArray(_), dims, fields.t),
+ )),
+ )
+ },
+ )
+ case constructor: JavaConstructor[Pre] => constructor
+ case method: JavaMethod[Pre] => method
+ case param: JavaParam[Pre] => param
+ case method: JavaAnnotationMethod[Pre] => method
+ case constructor: PVLConstructor[Pre] => constructor
+ case field: ModelField[Pre] => field
case proc: ModelProcess[Pre] =>
- new ModelProcess[Pre](proc.args, process(proc.impl), bool(proc.requires), bool(proc.ensures), proc.modifies, proc.accessible)(proc.blame)
+ new ModelProcess[Pre](
+ proc.args,
+ process(proc.impl),
+ bool(proc.requires),
+ bool(proc.ensures),
+ proc.modifies,
+ proc.accessible,
+ )(proc.blame)
case action: ModelAction[Pre] =>
- new ModelAction[Pre](action.args, bool(action.requires), bool(action.ensures), action.modifies, action.accessible)
- case axiom: ADTAxiom[Pre] =>
- new ADTAxiom[Pre](bool(axiom.axiom))
- case function: ADTFunction[Pre] =>
- function
- case variable: Variable[Pre] =>
- variable
- case decl: LabelDecl[Pre] =>
- decl
- case decl: SendDecl[Pre] =>
- decl
- case decl: ParBlockDecl[Pre] =>
- decl
- case decl: ParInvariantDecl[Pre] =>
- decl
- case param: CParam[Pre] =>
- param
- case decl: CLocalDeclaration[Pre] =>
- decl
- case param: CPPParam[Pre] =>
- param
- case decl: CPPLocalDeclaration[Pre] =>
- decl
+ new ModelAction[Pre](
+ action.args,
+ bool(action.requires),
+ bool(action.ensures),
+ action.modifies,
+ action.accessible,
+ )
+ case axiom: ADTAxiom[Pre] => new ADTAxiom[Pre](bool(axiom.axiom))
+ case function: ADTFunction[Pre] => function
+ case variable: Variable[Pre] => variable
+ case decl: LabelDecl[Pre] => decl
+ case decl: SendDecl[Pre] => decl
+ case decl: ParBlockDecl[Pre] => decl
+ case decl: ParInvariantDecl[Pre] => decl
+ case param: CParam[Pre] => param
+ case decl: CLocalDeclaration[Pre] => decl
+ case param: CPPParam[Pre] => param
+ case decl: CPPLocalDeclaration[Pre] => decl
case declaration: JavaLocalDeclaration[Pre] =>
- new JavaLocalDeclaration[Pre](declaration.modifiers, declaration.t, declaration.decls.map {
- case JavaVariableDeclaration(name, dims, None) => JavaVariableDeclaration(name, dims, None)
- case JavaVariableDeclaration(name, dims, Some(v)) =>
- JavaVariableDeclaration(name, dims, Some(coerce(v, FuncTools.repeat[Type[Pre]](TArray(_), dims, declaration.t))))
- })
+ new JavaLocalDeclaration[Pre](
+ declaration.modifiers,
+ declaration.t,
+ declaration.decls.map {
+ case JavaVariableDeclaration(name, dims, None) =>
+ JavaVariableDeclaration(name, dims, None)
+ case JavaVariableDeclaration(name, dims, Some(v)) =>
+ JavaVariableDeclaration(
+ name,
+ dims,
+ Some(coerce(
+ v,
+ FuncTools.repeat[Type[Pre]](TArray(_), dims, declaration.t),
+ )),
+ )
+ },
+ )
case chor: Choreography[Pre] => chor
- case endpoint: Endpoint[Pre] => new Endpoint(endpoint.cls, endpoint.typeArgs, endpoint.constructor, endpoint.args)(endpoint.blame)
- case bc: BipConstructor[Pre] => new BipConstructor(bc.args, bc.body, bc.requires)(bc.blame)
+ case endpoint: Endpoint[Pre] =>
+ new Endpoint(
+ endpoint.cls,
+ endpoint.typeArgs,
+ endpoint.constructor,
+ endpoint.args,
+ )(endpoint.blame)
+ case bc: BipConstructor[Pre] =>
+ new BipConstructor(bc.args, bc.body, bc.requires)(bc.blame)
case bc: BipComponent[Pre] =>
new BipComponent(bc.fqn, res(bc.invariant), bc.initial)
- case bsp: BipStatePredicate[Pre] =>
- new BipStatePredicate(bool(bsp.expr))
+ case bsp: BipStatePredicate[Pre] => new BipStatePredicate(bool(bsp.expr))
case trans: BipTransition[Pre] =>
- new BipTransition(trans.signature, trans.port, trans.source, trans.target, trans.data, trans.guard,
+ new BipTransition(
+ trans.signature,
+ trans.port,
+ trans.source,
+ trans.target,
+ trans.data,
+ trans.guard,
bool(trans.requires),
bool(trans.ensures),
- trans.body
+ trans.body,
)(trans.blame)
case data: BipIncomingData[Pre] => data
case data: BipOutgoingData[Pre] => data
@@ -1854,23 +2511,58 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
case typ: ProverType[Pre] => typ
case func: ProverFunction[Pre] => func
case function: LlvmSpecFunction[Pre] =>
- new LlvmSpecFunction[Pre](function.name, function.returnType, function.args, function.typeArgs, function.body.map(coerce(_, function.returnType)), function.contract, function.inline, function.threadLocal)(function.blame)
+ new LlvmSpecFunction[Pre](
+ function.name,
+ function.returnType,
+ function.args,
+ function.typeArgs,
+ function.body.map(coerce(_, function.returnType)),
+ function.contract,
+ function.inline,
+ function.threadLocal,
+ )(function.blame)
case glob: LlvmGlobal[Pre] => glob
case endpoint: PVLEndpoint[Pre] => endpoint
case seqProg: PVLChoreography[Pre] => seqProg
case seqRun: PVLChorRun[Pre] => seqRun
- case c: Communicate[Pre] if c.target.t == c.msg.t => new Communicate(res(c.invariant), c.receiver, c.target, c.sender, c.msg)(c.blame)
- case c: Communicate[Pre] => throw IncoercibleExplanation(c, s"The message should have type ${c.target.t}, but actually has type ${c.msg.t}.")
- }
+ case c: Communicate[Pre] if c.target.t == c.msg.t =>
+ new Communicate(
+ res(c.invariant),
+ c.receiver,
+ c.target,
+ c.sender,
+ c.msg,
+ )(c.blame)
+ case c: Communicate[Pre] =>
+ throw IncoercibleExplanation(
+ c,
+ s"The message should have type ${c.target.t}, but actually has type ${c.msg.t}.",
+ )
+ }
}
def coerce(region: ParRegion[Pre]): ParRegion[Pre] = {
implicit val o: Origin = region.o
region match {
case region @ ParParallel(regions) => ParParallel(regions)(region.blame)
- case region @ ParSequential(regions) => ParSequential(regions)(region.blame)
- case region @ ParBlock(decl, iters, context_everywhere, requires, ensures, content) =>
- ParBlock(decl, iters, res(context_everywhere), res(requires), res(ensures), content)(region.blame)
+ case region @ ParSequential(regions) =>
+ ParSequential(regions)(region.blame)
+ case region @ ParBlock(
+ decl,
+ iters,
+ context_everywhere,
+ requires,
+ ensures,
+ content,
+ ) =>
+ ParBlock(
+ decl,
+ iters,
+ res(context_everywhere),
+ res(requires),
+ res(ensures),
+ content,
+ )(region.blame)
}
}
@@ -1893,10 +2585,11 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
}
// PB: types may very well contain expressions eventually, but for now they don't.
- def coerce(node: Type[Pre]): Type[Pre] = node match {
- case t @ TClass(cls, args) => arity(TClass(cls, args))
- case _ => node
- }
+ def coerce(node: Type[Pre]): Type[Pre] =
+ node match {
+ case t @ TClass(cls, args) => arity(TClass(cls, args))
+ case _ => node
+ }
def coerce(node: LoopContract[Pre]): LoopContract[Pre] = {
implicit val o: Origin = node.o
@@ -1904,7 +2597,9 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
case li @ LoopInvariant(invariant, decreases) =>
LoopInvariant(res(invariant), decreases)(li.blame)
case ic @ IterationContract(requires, ensures, context_everywhere) =>
- IterationContract(res(requires), res(ensures), res(context_everywhere))(ic.blame)
+ IterationContract(res(requires), res(ensures), res(context_everywhere))(
+ ic.blame
+ )
}
}
@@ -1929,26 +2624,41 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
def coerce(node: DecreasesClause[Pre]): DecreasesClause[Pre] = {
implicit val o: Origin = node.o
node match {
- case DecreasesClauseAssume() =>
- DecreasesClauseAssume()
- case DecreasesClauseNoRecursion() =>
- DecreasesClauseNoRecursion()
+ case DecreasesClauseAssume() => DecreasesClauseAssume()
+ case DecreasesClauseNoRecursion() => DecreasesClauseNoRecursion()
case DecreasesClauseTuple(exprs) =>
- DecreasesClauseTuple(exprs.map(int)) // Since we currently only support integers
+ DecreasesClauseTuple(
+ exprs.map(int)
+ ) // Since we currently only support integers
}
}
def coerce(node: ApplicableContract[Pre]): ApplicableContract[Pre] = {
implicit val o: Origin = node.o
- val ApplicableContract(requires, ensures, context_everywhere, signals, givenArgs, yieldsArgs, decreases) = node
- ApplicableContract(requires, ensures, res(context_everywhere), signals, givenArgs, yieldsArgs, decreases)(node.blame)
+ val ApplicableContract(
+ requires,
+ ensures,
+ context_everywhere,
+ signals,
+ givenArgs,
+ yieldsArgs,
+ decreases,
+ ) = node
+ ApplicableContract(
+ requires,
+ ensures,
+ res(context_everywhere),
+ signals,
+ givenArgs,
+ yieldsArgs,
+ decreases,
+ )(node.blame)
}
def coerce(node: AccountedPredicate[Pre]): AccountedPredicate[Pre] = {
implicit val o: Origin = node.o
node match {
- case UnitAccountedPredicate(pred) =>
- UnitAccountedPredicate(res(pred))
+ case UnitAccountedPredicate(pred) => UnitAccountedPredicate(res(pred))
case SplitAccountedPredicate(left, right) =>
SplitAccountedPredicate(left, right)
}
@@ -1956,21 +2666,15 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
def coerce(node: FieldFlag[Pre]): FieldFlag[Pre] = {
implicit val o: Origin = node.o
- node match {
- case value: Final[_] => value
- }
+ node match { case value: Final[_] => value }
}
-
def coerce(node: Location[Pre]): Location[Pre] = {
implicit val o: Origin = node.o
node match {
- case HeapVariableLocation(ref) =>
- HeapVariableLocation(ref)
- case FieldLocation(obj, field) =>
- FieldLocation(cls(obj), field)
- case ModelLocation(obj, field) =>
- ModelLocation(model(obj)._1, field)
+ case HeapVariableLocation(ref) => HeapVariableLocation(ref)
+ case FieldLocation(obj, field) => FieldLocation(cls(obj), field)
+ case ModelLocation(obj, field) => ModelLocation(model(obj)._1, field)
case SilverFieldLocation(obj, field) =>
SilverFieldLocation(ref(obj), field)
case a @ ArrayLocation(arrayObj, subscript) =>
@@ -1980,9 +2684,12 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
case PredicateLocation(predicate, args) =>
PredicateLocation(predicate, coerceArgs(args, predicate.decl))
case InstancePredicateLocation(predicate, obj, args) =>
- InstancePredicateLocation(predicate, cls(obj), coerceArgs(args, predicate.decl))
- case al @ AmbiguousLocation(expr) =>
- AmbiguousLocation(expr)(al.blame)
+ InstancePredicateLocation(
+ predicate,
+ cls(obj),
+ coerceArgs(args, predicate.decl),
+ )
+ case al @ AmbiguousLocation(expr) => AmbiguousLocation(expr)(al.blame)
case patLoc @ InLinePatternLocation(loc, pat) =>
InLinePatternLocation(loc, pat)
}
@@ -2031,7 +2738,9 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
}
}
- def coerce(node: CStructMemberDeclarator[Pre]): CStructMemberDeclarator[Pre] = {
+ def coerce(
+ node: CStructMemberDeclarator[Pre]
+ ): CStructMemberDeclarator[Pre] = {
implicit val o: Origin = node.o
val CStructMemberDeclarator(specs, decls) = node
CStructMemberDeclarator(specs, decls)
@@ -2045,10 +2754,7 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
def coerce(node: CTypeExtensions[Pre]): CTypeExtensions[Pre] = {
implicit val o: Origin = node.o
- node match {
- case CTypeAttribute(name, args) =>
- CTypeAttribute(name, args)
- }
+ node match { case CTypeAttribute(name, args) => CTypeAttribute(name, args) }
}
def coerce(node: CDeclarator[Pre]): CDeclarator[Pre] = {
@@ -2062,8 +2768,7 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
CTypedFunctionDeclarator(params, varargs, inner)
case CAnonymousFunctionDeclarator(params, inner) =>
CAnonymousFunctionDeclarator(params, inner)
- case CName(name) =>
- CName(name)
+ case CName(name) => CName(name)
}
}
@@ -2097,14 +2802,14 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
CPPArrayDeclarator(size.map(int), inner)(array.blame)
case CPPTypedFunctionDeclarator(params, varargs, inner) =>
CPPTypedFunctionDeclarator(params, varargs, inner)
- case CPPLambdaDeclarator(params) =>
- CPPLambdaDeclarator(params)
- case CPPName(name) =>
- CPPName(name)
+ case CPPLambdaDeclarator(params) => CPPLambdaDeclarator(params)
+ case CPPName(name) => CPPName(name)
}
}
- def coerce(node: CPPDeclarationSpecifier[Pre]): CPPDeclarationSpecifier[Pre] = {
+ def coerce(
+ node: CPPDeclarationSpecifier[Pre]
+ ): CPPDeclarationSpecifier[Pre] = {
implicit val o: Origin = node.o
node match {
case CPPPure() => CPPPure()
@@ -2175,14 +2880,17 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
case js @ JavaSynchronized() => JavaSynchronized()(js.blame)
case JavaTransient() => JavaTransient()
case JavaVolatile() => JavaVolatile()
- case annotation @ JavaAnnotation(name, args) => JavaAnnotation(name, args)(annotation.blame)
+ case annotation @ JavaAnnotation(name, args) =>
+ JavaAnnotation(name, args)(annotation.blame)
case JavaPure() => JavaPure()
case JavaInline() => JavaInline()
case JavaBipAnnotation() => JavaBipAnnotation()
}
}
- def coerce(node: JavaVariableDeclaration[Pre]): JavaVariableDeclaration[Pre] = {
+ def coerce(
+ node: JavaVariableDeclaration[Pre]
+ ): JavaVariableDeclaration[Pre] = {
implicit val o: Origin = node.o
val JavaVariableDeclaration(name, dim, init) = node
JavaVariableDeclaration(name, dim, init)
@@ -2199,13 +2907,14 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
def coerce(node: BipPortType[Pre]): BipPortType[Pre] = {
implicit val o: Origin = node.o
node match {
- case BipEnforceable() => BipEnforceable()
+ case BipEnforceable() => BipEnforceable()
case BipSpontaneous() => BipSpontaneous()
case BipInternal() => BipInternal()
}
}
- def coerce(node: BipTransitionSignature[Pre]): BipTransitionSignature[Pre] = node
+ def coerce(node: BipTransitionSignature[Pre]): BipTransitionSignature[Pre] =
+ node
def coerce(node: BipGlueDataWire[Pre]): BipGlueDataWire[Pre] = node
def coerce(node: BipGlueRequires[Pre]): BipGlueRequires[Pre] = node
def coerce(node: BipGlueAccepts[Pre]): BipGlueAccepts[Pre] = node
@@ -2220,10 +2929,12 @@ abstract class CoercingRewriter[Pre <: Generation]() extends BaseCoercingRewrite
def coerce(node: SmtlibFunctionSymbol[Pre]): SmtlibFunctionSymbol[Pre] = node
def coerce(node: ChorRun[Pre]): ChorRun[Pre] = node
- def coerce(node: ChorGuard[Pre]): ChorGuard[Pre] = node match {
- case EndpointGuard(endpoint, cond) => EndpointGuard(endpoint, bool(cond))(node.o)
- case UnpointedGuard(cond) => UnpointedGuard(bool(cond))(node.o)
- }
+ def coerce(node: ChorGuard[Pre]): ChorGuard[Pre] =
+ node match {
+ case EndpointGuard(endpoint, cond) =>
+ EndpointGuard(endpoint, bool(cond))(node.o)
+ case UnpointedGuard(cond) => UnpointedGuard(bool(cond))(node.o)
+ }
def coerce(node: PVLEndpointName[Pre]): PVLEndpointName[Pre] = node
def coerce(node: EndpointName[Pre]): EndpointName[Pre] = node
diff --git a/src/col/vct/col/typerules/CoercionUtils.scala b/src/col/vct/col/typerules/CoercionUtils.scala
index 5f5dfa0c64..47295af0af 100644
--- a/src/col/vct/col/typerules/CoercionUtils.scala
+++ b/src/col/vct/col/typerules/CoercionUtils.scala
@@ -13,26 +13,42 @@ case object CoercionUtils {
def getCoercion[G](source: Type[G], target: Type[G]): Option[Coercion[G]] =
getAnyCoercion(source, target).filter(_.isCPromoting)
- def getAnyCoercion[G](source: Type[G], target: Type[G]): Option[Coercion[G]] = {
+ def getAnyCoercion[G](
+ source: Type[G],
+ target: Type[G],
+ ): Option[Coercion[G]] = {
Some((source, target) match {
case (_: TNotAValue[_], _) => return None
case (_, _: TNotAValue[_]) => return None
- case (source, target) if source == target => return Some(CoerceIdentity(source))
+ case (source, target) if source == target =>
+ return Some(CoerceIdentity(source))
case (TNothing(), _) => CoerceNothingSomething(target)
case (_, TAny()) => CoerceSomethingAny(source)
- case (TResource(), TAnyValue()) => CoercionSequence(Seq(CoerceResourceResourceVal(), CoerceSomethingAnyValue(TResourceVal())))
+ case (TResource(), TAnyValue()) =>
+ CoercionSequence(Seq(
+ CoerceResourceResourceVal(),
+ CoerceSomethingAnyValue(TResourceVal()),
+ ))
case (TResource(), TResourceVal()) => CoerceResourceResourceVal()
case (TResourceVal(), TResource()) => CoerceResourceValResource()
case (TBool(), TResource()) => CoerceBoolResource()
- case (TBool(), TResourceVal()) => CoercionSequence(Seq(CoerceBoolResource(), CoerceResourceResourceVal()))
+ case (TBool(), TResourceVal()) =>
+ CoercionSequence(Seq(CoerceBoolResource(), CoerceResourceResourceVal()))
case (_, TAnyValue()) => CoerceSomethingAnyValue(source)
case (source @ TOption(innerSource), target @ TOption(innerTarget)) =>
- CoerceMapOption(getAnyCoercion(innerSource, innerTarget).getOrElse(return None), innerSource, innerTarget)
- case (source @ TTuple(Seq(leftSource, rightSource)), target @ TTuple(Seq(leftTarget, rightTarget))) =>
+ CoerceMapOption(
+ getAnyCoercion(innerSource, innerTarget).getOrElse(return None),
+ innerSource,
+ innerTarget,
+ )
+ case (
+ source @ TTuple(Seq(leftSource, rightSource)),
+ target @ TTuple(Seq(leftTarget, rightTarget)),
+ ) =>
CoerceMapTuple(
inner = Seq(
getAnyCoercion(leftSource, leftTarget).getOrElse(return None),
@@ -41,30 +57,68 @@ case object CoercionUtils {
sourceTypes = Seq(leftSource, rightSource),
targetTypes = Seq(leftTarget, rightTarget),
)
- case (source @ TEither(leftSource, rightSource), target @ TEither(leftTarget, rightTarget)) =>
+ case (
+ source @ TEither(leftSource, rightSource),
+ target @ TEither(leftTarget, rightTarget),
+ ) =>
CoerceMapEither(
- (getAnyCoercion(leftSource, leftTarget).getOrElse(return None), getAnyCoercion(rightSource, rightTarget).getOrElse(return None)),
+ (
+ getAnyCoercion(leftSource, leftTarget).getOrElse(return None),
+ getAnyCoercion(rightSource, rightTarget).getOrElse(return None),
+ ),
(leftSource, rightSource),
(leftTarget, rightTarget),
)
case (TSeq(innerSource), TSeq(innerTarget)) =>
- CoerceMapSeq(getAnyCoercion(innerSource, innerTarget).getOrElse(return None), innerSource, innerTarget)
+ CoerceMapSeq(
+ getAnyCoercion(innerSource, innerTarget).getOrElse(return None),
+ innerSource,
+ innerTarget,
+ )
case (TSet(innerSource), TSet(innerTarget)) =>
- CoerceMapSet(getPromotion(innerSource, innerTarget).getOrElse(return None), innerSource, innerTarget)
- case (TVector(sizeSource, innerSource), TVector(sizeTarget, innerTarget)) if sizeSource == sizeTarget =>
- CoerceMapVector(getPromotion(innerSource, innerTarget).getOrElse(return None), innerSource, innerTarget, sizeTarget)
+ CoerceMapSet(
+ getPromotion(innerSource, innerTarget).getOrElse(return None),
+ innerSource,
+ innerTarget,
+ )
+ case (TVector(sizeSource, innerSource), TVector(sizeTarget, innerTarget))
+ if sizeSource == sizeTarget =>
+ CoerceMapVector(
+ getPromotion(innerSource, innerTarget).getOrElse(return None),
+ innerSource,
+ innerTarget,
+ sizeTarget,
+ )
case (TBag(innerSource), TBag(innerTarget)) =>
- CoerceMapBag(getPromotion(innerSource, innerTarget).getOrElse(return None), innerSource, innerTarget)
+ CoerceMapBag(
+ getPromotion(innerSource, innerTarget).getOrElse(return None),
+ innerSource,
+ innerTarget,
+ )
case (TMatrix(innerSource), TMatrix(innerTarget)) =>
- CoerceMapMatrix(getAnyCoercion(innerSource, innerTarget).getOrElse(return None), innerSource, innerTarget)
- case (TMap(sourceKey, innerSource), TMap(targetKey, innerTarget)) if sourceKey == targetKey =>
- CoerceMapMap(getAnyCoercion(innerSource, innerTarget).getOrElse(return None), (sourceKey, innerSource), (sourceKey, innerTarget))
+ CoerceMapMatrix(
+ getAnyCoercion(innerSource, innerTarget).getOrElse(return None),
+ innerSource,
+ innerTarget,
+ )
+ case (TMap(sourceKey, innerSource), TMap(targetKey, innerTarget))
+ if sourceKey == targetKey =>
+ CoerceMapMap(
+ getAnyCoercion(innerSource, innerTarget).getOrElse(return None),
+ (sourceKey, innerSource),
+ (sourceKey, innerTarget),
+ )
case (TType(innerSource), TType(innerTarget)) =>
- CoerceMapType(getAnyCoercion(innerSource, innerTarget).getOrElse(return None), innerSource, innerTarget)
+ CoerceMapType(
+ getAnyCoercion(innerSource, innerTarget).getOrElse(return None),
+ innerSource,
+ innerTarget,
+ )
case (TNull(), TRef()) => CoerceNullRef()
case (TNull(), TArray(target)) => CoerceNullArray(target)
- case (TNull(), TClass(target, typeArgs)) => CoerceNullClass(target, typeArgs)
+ case (TNull(), TClass(target, typeArgs)) =>
+ CoerceNullClass(target, typeArgs)
case (TNull(), JavaTClass(target, _)) => CoerceNullJavaClass(target)
case (TNull(), TAnyClass()) => CoerceNullAnyClass()
case (TNull(), TPointer(target)) => CoerceNullPointer(target)
@@ -75,86 +129,135 @@ case object CoercionUtils {
CoerceCArrayPointer(element)
case (CPPTArray(_, innerType), TArray(element)) if element == innerType =>
CoerceCPPArrayPointer(element)
- case (source@CTVector(_, innerType), TVector(rSize, element)) if element == innerType && source.intSize == rSize =>
+ case (source @ CTVector(_, innerType), TVector(rSize, element))
+ if element == innerType && source.intSize == rSize =>
CoerceCVectorVector(rSize, element)
- case (source@TOpenCLVector(lSize, innerType), TVector(rSize, element)) if element == innerType && lSize == rSize =>
+ case (source @ TOpenCLVector(lSize, innerType), TVector(rSize, element))
+ if element == innerType && lSize == rSize =>
CoerceCVectorVector(rSize, element)
- case (CTPointer(innerType), TPointer(element)) => //if element == innerType =>
+ case (
+ CTPointer(innerType),
+ TPointer(element),
+ ) => // if element == innerType =>
getAnyCoercion(element, innerType).getOrElse(return None)
- case (TPointer(element), CTPointer(innerType)) => //if element == innerType =>
+ case (
+ TPointer(element),
+ CTPointer(innerType),
+ ) => // if element == innerType =>
getAnyCoercion(element, innerType).getOrElse(return None)
case (CTArray(_, innerType), CTPointer(element)) =>
- if(element == innerType){
- CoerceCArrayPointer(innerType)
- } else {
+ if (element == innerType) { CoerceCArrayPointer(innerType) }
+ else {
CoercionSequence(Seq(
CoerceCArrayPointer(element),
- getAnyCoercion(element, innerType).getOrElse(return None)
+ getAnyCoercion(element, innerType).getOrElse(return None),
))
}
case (TFraction(), TZFraction()) => CoerceFracZFrac()
- case (TFraction(), TRational()) => CoercionSequence(Seq(CoerceFracZFrac(), CoerceZFracRat()))
+ case (TFraction(), TRational()) =>
+ CoercionSequence(Seq(CoerceFracZFrac(), CoerceZFracRat()))
case (TZFraction(), TRational()) => CoerceZFracRat()
case (source: FloatType[G], TRational()) => CoerceFloatRat(source)
- case (source @ TFloat(exponentL, mantissaL), target @ TFloat(exponentR, mantissaR)) if exponentL <= exponentR && mantissaL <= mantissaR =>
+ case (
+ source @ TFloat(exponentL, mantissaL),
+ target @ TFloat(exponentR, mantissaR),
+ ) if exponentL <= exponentR && mantissaL <= mantissaR =>
CoerceIncreasePrecision(source, target)
- case (source@TCFloat(exponentL, mantissaL), target@TCFloat(exponentR, mantissaR)) if exponentL <= exponentR && mantissaL <= mantissaR =>
+ case (
+ source @ TCFloat(exponentL, mantissaL),
+ target @ TCFloat(exponentR, mantissaR),
+ ) if exponentL <= exponentR && mantissaL <= mantissaR =>
CoerceIncreasePrecision(source, target)
- case (source@TCFloat(_, _), target@TCFloat(_, _)) =>
+ case (source @ TCFloat(_, _), target @ TCFloat(_, _)) =>
CoerceDecreasePrecision(source, target)
// Allow to go from C float to normal float and C Int to Int
- case (source@TCFloat(exponentL, mantissaL), target@TFloat(exponentR, mantissaR)) if exponentL == exponentR && mantissaL == mantissaR =>
+ case (
+ source @ TCFloat(exponentL, mantissaL),
+ target @ TFloat(exponentR, mantissaR),
+ ) if exponentL == exponentR && mantissaL == mantissaR =>
CoerceCFloatFloat(source, target)
- case (source@TCFloat(exponentL, mantissaL), target@TFloat(exponentR, mantissaR)) if exponentL < exponentR && mantissaL < mantissaR =>
+ case (
+ source @ TCFloat(exponentL, mantissaL),
+ target @ TFloat(exponentR, mantissaR),
+ ) if exponentL < exponentR && mantissaL < mantissaR =>
val coercedCFloat = TCFloat[G](exponentR, mantissaR)
- CoercionSequence(Seq(CoerceIncreasePrecision(source, coercedCFloat), CoerceCFloatFloat(coercedCFloat, target)))
- case (source@TCFloat(_, _), target@TFloat(exponentR, mantissaR)) =>
+ CoercionSequence(Seq(
+ CoerceIncreasePrecision(source, coercedCFloat),
+ CoerceCFloatFloat(coercedCFloat, target),
+ ))
+ case (source @ TCFloat(_, _), target @ TFloat(exponentR, mantissaR)) =>
val coercedCFloat = TCFloat[G](exponentR, mantissaR)
- CoercionSequence(Seq(CoerceDecreasePrecision(source, coercedCFloat), CoerceCFloatFloat(coercedCFloat, target)))
+ CoercionSequence(Seq(
+ CoerceDecreasePrecision(source, coercedCFloat),
+ CoerceCFloatFloat(coercedCFloat, target),
+ ))
case (TCInt(), TInt()) => CoerceCIntInt()
- case (TBoundedInt(gte, lt), TFraction()) if gte >= 1 && lt <= 2 => CoerceBoundIntFrac()
- case (source @ TBoundedInt(gte, lt), TZFraction()) if gte >= 0 && lt <= 2 => CoerceBoundIntZFrac(source)
- case (source @ TBoundedInt(_, _), target: TFloat[G]) => CoerceBoundIntFloat(source, target)
+ case (TBoundedInt(gte, lt), TFraction()) if gte >= 1 && lt <= 2 =>
+ CoerceBoundIntFrac()
+ case (source @ TBoundedInt(gte, lt), TZFraction())
+ if gte >= 0 && lt <= 2 =>
+ CoerceBoundIntZFrac(source)
+ case (source @ TBoundedInt(_, _), target: TFloat[G]) =>
+ CoerceBoundIntFloat(source, target)
- case (source @ TBoundedInt(gte, lt), target @ TBoundedInt(t_gte, t_lt)) if t_gte <= gte && t_lt >= lt =>
+ case (source @ TBoundedInt(gte, lt), target @ TBoundedInt(t_gte, t_lt))
+ if t_gte <= gte && t_lt >= lt =>
CoerceWidenBound(source, target)
- case (source: TBoundedInt[G], target: TInt[G]) => CoerceUnboundInt(source, target)
- case (source: TBoundedInt[G], TRational()) => CoercionSequence(Seq(CoerceUnboundInt(source, TInt()), CoerceIntRat()))
+ case (source: TBoundedInt[G], target: TInt[G]) =>
+ CoerceUnboundInt(source, target)
+ case (source: TBoundedInt[G], TRational()) =>
+ CoercionSequence(Seq(CoerceUnboundInt(source, TInt()), CoerceIntRat()))
case (_: IntType[G], TRational()) => CoerceIntRat()
- case (source @ TClass(sourceClass, Seq()), target @ TClass(targetClass, Seq()))
- if source.transSupportArrows.exists { case (_, supp) => supp.cls.decl == targetClass.decl } =>
+ case (
+ source @ TClass(sourceClass, Seq()),
+ target @ TClass(targetClass, Seq()),
+ ) if source.transSupportArrows.exists { case (_, supp) =>
+ supp.cls.decl == targetClass.decl
+ } =>
CoerceSupports(sourceClass, targetClass)
case (source @ TClass(sourceClass, typeArgs), TAnyClass()) =>
CoerceClassAnyClass(sourceClass, typeArgs)
- case (source @ JavaTClass(sourceClass, Nil), target @ JavaTClass(targetClass, Nil))
- if sourceClass.decl.transSupportArrows(Set.empty).exists { case (_, supp) => supp == targetClass.decl } =>
+ case (
+ source @ JavaTClass(sourceClass, Nil),
+ target @ JavaTClass(targetClass, Nil),
+ ) if sourceClass.decl.transSupportArrows(Set.empty).exists {
+ case (_, supp) => supp == targetClass.decl
+ } =>
CoerceJavaSupports(sourceClass, targetClass)
case (source @ JavaTClass(sourceClass, Nil), TAnyClass()) =>
CoerceJavaClassAnyClass(sourceClass)
case (source @ TUnion(ts), target) =>
- CoerceJoinUnion(ts.map(getAnyCoercion(_, target)).map {
- case Some(coercion) => coercion
- case None => return None
- }, source.types, target)
+ CoerceJoinUnion(
+ ts.map(getAnyCoercion(_, target)).map {
+ case Some(coercion) => coercion
+ case None => return None
+ },
+ source.types,
+ target,
+ )
case (source, target @ TUnion(ts)) =>
- return ts.map(getAnyCoercion(source, _)).zipWithIndex.collectFirst {
- case (Some(coercion), index) =>
+ return ts.map(getAnyCoercion(source, _)).zipWithIndex
+ .collectFirst { case (Some(coercion), index) =>
CoerceSelectUnion(coercion, source, target.types, index)
- }
+ }
case (source @ TCFloat(_, _), TCInt()) => CoerceCFloatCInt(source)
- case (TCInt() , target @ TCFloat(_, _)) => CoerceCIntCFloat(target)
+ case (TCInt(), target @ TCFloat(_, _)) => CoerceCIntCFloat(target)
- case (source @ TCFloat(_, _), TInt()) => CoercionSequence(Seq(CoerceCFloatCInt(source), CoerceCIntInt()))
- case (TCInt() , target @ TFloat(exponent, mantissa)) =>
+ case (source @ TCFloat(_, _), TInt()) =>
+ CoercionSequence(Seq(CoerceCFloatCInt(source), CoerceCIntInt()))
+ case (TCInt(), target @ TFloat(exponent, mantissa)) =>
val coercedCFloat = TCFloat[G](exponent, mantissa)
- CoercionSequence(Seq(CoerceCIntCFloat(coercedCFloat), CoerceCFloatFloat(coercedCFloat, target)))
+ CoercionSequence(Seq(
+ CoerceCIntCFloat(coercedCFloat),
+ CoerceCFloatFloat(coercedCFloat, target),
+ ))
case (source @ CPrimitiveType(specs), target) =>
specs.collectFirst { case spec: CSpecificationType[G] => spec } match {
case Some(CSpecificationType(t)) =>
@@ -175,8 +278,9 @@ case object CoercionUtils {
case None => return None
}
- case (source@CPPPrimitiveType(specs), target) =>
- specs.collectFirst { case spec: CPPSpecificationType[G] => spec } match {
+ case (source @ CPPPrimitiveType(specs), target) =>
+ specs
+ .collectFirst { case spec: CPPSpecificationType[G] => spec } match {
case Some(CPPSpecificationType(t)) =>
CoercionSequence(Seq(
CoerceCPPPrimitiveToCol(source, t),
@@ -185,8 +289,9 @@ case object CoercionUtils {
case None => return None
}
- case (source, target@CPPPrimitiveType(specs)) =>
- specs.collectFirst { case spec: CPPSpecificationType[G] => spec } match {
+ case (source, target @ CPPPrimitiveType(specs)) =>
+ specs
+ .collectFirst { case spec: CPPSpecificationType[G] => spec } match {
case Some(CPPSpecificationType(t)) =>
CoercionSequence(Seq(
getAnyCoercion(source, t).getOrElse(return None),
@@ -195,12 +300,12 @@ case object CoercionUtils {
case None => return None
}
-
// Something with TVar?
// Unsafe coercions
case (TRational(), TZFraction()) => CoerceRatZFrac()
- case (TRational(), TFraction()) => CoercionSequence(Seq(CoerceRatZFrac(), CoerceZFracFrac()))
+ case (TRational(), TFraction()) =>
+ CoercionSequence(Seq(CoerceRatZFrac(), CoerceZFracFrac()))
case (TZFraction(), TFraction()) => CoerceZFracFrac()
case (_, _) => return None
@@ -213,231 +318,325 @@ case object CoercionUtils {
case _ => None
}
- def getAnyCCoercion[G](source: Type[G]): Option[(Coercion[G], Type[G])] = source match {
- case t: CPrimitiveType[G] =>
- t.specifiers.collectFirst { case spec: CSpecificationType[G] => spec }.map {
- case CSpecificationType(inner) => (CoerceCPrimitiveToCol(t, inner), inner)
- }
- case _ => None
- }
+ def getAnyCCoercion[G](source: Type[G]): Option[(Coercion[G], Type[G])] =
+ source match {
+ case t: CPrimitiveType[G] =>
+ t.specifiers.collectFirst { case spec: CSpecificationType[G] => spec }
+ .map { case CSpecificationType(inner) =>
+ (CoerceCPrimitiveToCol(t, inner), inner)
+ }
+ case _ => None
+ }
- def chainCCoercion[G, T](source: CPrimitiveType[G], next: Type[G] => Option[(Coercion[G], T)]): Option[(Coercion[G], T)] =
+ def chainCCoercion[G, T](
+ source: CPrimitiveType[G],
+ next: Type[G] => Option[(Coercion[G], T)],
+ ): Option[(Coercion[G], T)] =
getAnyCCoercion(source) match {
- case Some(inner) => next(inner._2) match {
- case Some((coercion, finalType)) =>
- Some((CoercionSequence(Seq(coercion, inner._1)), finalType))
- case None => None
- }
+ case Some(inner) =>
+ next(inner._2) match {
+ case Some((coercion, finalType)) =>
+ Some((CoercionSequence(Seq(coercion, inner._1)), finalType))
+ case None => None
+ }
case None => None
}
- def getAnyCPPCoercion[G](source: Type[G]): Option[(Coercion[G], Type[G])] = source match {
- case t: CPPPrimitiveType[G] =>
- t.specifiers.collectFirst { case spec: CPPSpecificationType[G] => spec }.map {
- case CPPSpecificationType(inner) => (CoerceCPPPrimitiveToCol(t, inner), inner)
- }
- case _ => None
- }
+ def getAnyCPPCoercion[G](source: Type[G]): Option[(Coercion[G], Type[G])] =
+ source match {
+ case t: CPPPrimitiveType[G] =>
+ t.specifiers.collectFirst { case spec: CPPSpecificationType[G] => spec }
+ .map { case CPPSpecificationType(inner) =>
+ (CoerceCPPPrimitiveToCol(t, inner), inner)
+ }
+ case _ => None
+ }
- def chainCPPCoercion[G, T](source: CPPPrimitiveType[G], next: Type[G] => Option[(Coercion[G], T)]): Option[(Coercion[G], T)] =
+ def chainCPPCoercion[G, T](
+ source: CPPPrimitiveType[G],
+ next: Type[G] => Option[(Coercion[G], T)],
+ ): Option[(Coercion[G], T)] =
getAnyCPPCoercion(source) match {
- case Some(inner) => next(inner._2) match {
- case Some((coercion, finalType)) =>
- Some((CoercionSequence(Seq(coercion, inner._1)), finalType))
- case None => None
- }
+ case Some(inner) =>
+ next(inner._2) match {
+ case Some((coercion, finalType)) =>
+ Some((CoercionSequence(Seq(coercion, inner._1)), finalType))
+ case None => None
+ }
case None => None
}
- def getAnySeqCoercion[G](source: Type[G]): Option[(Coercion[G], TSeq[G])] = source match {
- case t: CPrimitiveType[G] => chainCCoercion(t, getAnySeqCoercion)
- case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnySeqCoercion)
- case t: TSeq[G] => Some((CoerceIdentity(source), t))
- case _ => None
- }
+ def getAnySeqCoercion[G](source: Type[G]): Option[(Coercion[G], TSeq[G])] =
+ source match {
+ case t: CPrimitiveType[G] => chainCCoercion(t, getAnySeqCoercion)
+ case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnySeqCoercion)
+ case t: TSeq[G] => Some((CoerceIdentity(source), t))
+ case _ => None
+ }
- def getAnySetCoercion[G](source: Type[G]): Option[(Coercion[G], TSet[G])] = source match {
- case t: CPrimitiveType[G] => chainCCoercion(t, getAnySetCoercion)
- case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnySetCoercion)
- case t: TSet[G] => Some((CoerceIdentity(source), t))
- case _ => None
- }
+ def getAnySetCoercion[G](source: Type[G]): Option[(Coercion[G], TSet[G])] =
+ source match {
+ case t: CPrimitiveType[G] => chainCCoercion(t, getAnySetCoercion)
+ case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnySetCoercion)
+ case t: TSet[G] => Some((CoerceIdentity(source), t))
+ case _ => None
+ }
- def getAnyVectorCoercion[G](source: Type[G]): Option[(Coercion[G], TVector[G])] = source match {
- case t: CPrimitiveType[G] => chainCCoercion(t, getAnyVectorCoercion)
- case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnyVectorCoercion)
- case t: CTVector[G] => Some((CoerceCVectorVector(t.intSize, t.innerType), TVector(t.intSize, t.innerType)()))
- case t: TOpenCLVector[G] => Some((CoerceCVectorVector(t.size, t.innerType), TVector(t.size, t.innerType)()))
- case t: TVector[G] => Some((CoerceIdentity(source), t))
- case _ => None
- }
+ def getAnyVectorCoercion[G](
+ source: Type[G]
+ ): Option[(Coercion[G], TVector[G])] =
+ source match {
+ case t: CPrimitiveType[G] => chainCCoercion(t, getAnyVectorCoercion)
+ case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnyVectorCoercion)
+ case t: CTVector[G] =>
+ Some((
+ CoerceCVectorVector(t.intSize, t.innerType),
+ TVector(t.intSize, t.innerType)(),
+ ))
+ case t: TOpenCLVector[G] =>
+ Some((
+ CoerceCVectorVector(t.size, t.innerType),
+ TVector(t.size, t.innerType)(),
+ ))
+ case t: TVector[G] => Some((CoerceIdentity(source), t))
+ case _ => None
+ }
- def getAnyBagCoercion[G](source: Type[G]): Option[(Coercion[G], TBag[G])] = source match {
- case t: CPrimitiveType[G] => chainCCoercion(t, getAnyBagCoercion)
- case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnyBagCoercion)
- case t: TBag[G] => Some((CoerceIdentity(source), t))
- case _ => None
- }
+ def getAnyBagCoercion[G](source: Type[G]): Option[(Coercion[G], TBag[G])] =
+ source match {
+ case t: CPrimitiveType[G] => chainCCoercion(t, getAnyBagCoercion)
+ case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnyBagCoercion)
+ case t: TBag[G] => Some((CoerceIdentity(source), t))
+ case _ => None
+ }
- def getAnySizedCoercion[G](source: Type[G]): Option[(Coercion[G], SizedType[G])] = source match {
- case t: CPrimitiveType[G] => chainCCoercion(t, getAnySizedCoercion)
- case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnySizedCoercion)
- case t: TSeq[G] => Some((CoerceIdentity(source), t))
- case t: TSet[G] => Some((CoerceIdentity(source), t))
- case t: TBag[G] => Some((CoerceIdentity(source), t))
- case t: TMap[G] => Some((CoerceIdentity(source), t))
- case _ => None
- }
+ def getAnySizedCoercion[G](
+ source: Type[G]
+ ): Option[(Coercion[G], SizedType[G])] =
+ source match {
+ case t: CPrimitiveType[G] => chainCCoercion(t, getAnySizedCoercion)
+ case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnySizedCoercion)
+ case t: TSeq[G] => Some((CoerceIdentity(source), t))
+ case t: TSet[G] => Some((CoerceIdentity(source), t))
+ case t: TBag[G] => Some((CoerceIdentity(source), t))
+ case t: TMap[G] => Some((CoerceIdentity(source), t))
+ case _ => None
+ }
- def getAnyPointerCoercion[G](source: Type[G]): Option[(Coercion[G], TPointer[G])] = source match {
- case t: CPrimitiveType[G] => chainCCoercion(t, getAnyPointerCoercion)
- case t: TPointer[G] => Some((CoerceIdentity(source), t))
- case t: CTPointer[G] => Some((CoerceIdentity(source), TPointer(t.innerType)))
- case t: CTArray[G] => Some((CoerceCArrayPointer(t.innerType), TPointer(t.innerType)))
- case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnyPointerCoercion)
- case t: CPPTArray[G] => Some((CoerceCPPArrayPointer(t.innerType), TPointer(t.innerType)))
- case _: TNull[G] =>
- val t = TPointer[G](TAnyValue())
- Some((CoerceNullPointer(t), t))
- case _ => None
- }
+ def getAnyPointerCoercion[G](
+ source: Type[G]
+ ): Option[(Coercion[G], TPointer[G])] =
+ source match {
+ case t: CPrimitiveType[G] => chainCCoercion(t, getAnyPointerCoercion)
+ case t: TPointer[G] => Some((CoerceIdentity(source), t))
+ case t: CTPointer[G] =>
+ Some((CoerceIdentity(source), TPointer(t.innerType)))
+ case t: CTArray[G] =>
+ Some((CoerceCArrayPointer(t.innerType), TPointer(t.innerType)))
+ case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnyPointerCoercion)
+ case t: CPPTArray[G] =>
+ Some((CoerceCPPArrayPointer(t.innerType), TPointer(t.innerType)))
+ case _: TNull[G] =>
+ val t = TPointer[G](TAnyValue())
+ Some((CoerceNullPointer(t), t))
+ case _ => None
+ }
- def getAnyCArrayCoercion[G](source: Type[G]): Option[(Coercion[G], CTArray[G])] = source match {
- case t: CPrimitiveType[G] => chainCCoercion(t, getAnyCArrayCoercion)
- case t: CTArray[G] => Some((CoerceIdentity(source), t))
- case _ => None
- }
+ def getAnyCArrayCoercion[G](
+ source: Type[G]
+ ): Option[(Coercion[G], CTArray[G])] =
+ source match {
+ case t: CPrimitiveType[G] => chainCCoercion(t, getAnyCArrayCoercion)
+ case t: CTArray[G] => Some((CoerceIdentity(source), t))
+ case _ => None
+ }
- def getAnyCPPArrayCoercion[G](source: Type[G]): Option[(Coercion[G], CPPTArray[G])] = source match {
- case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnyCPPArrayCoercion)
- case t: CPPTArray[G] => Some((CoerceIdentity(source), t))
- case _ => None
- }
+ def getAnyCPPArrayCoercion[G](
+ source: Type[G]
+ ): Option[(Coercion[G], CPPTArray[G])] =
+ source match {
+ case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnyCPPArrayCoercion)
+ case t: CPPTArray[G] => Some((CoerceIdentity(source), t))
+ case _ => None
+ }
- def getAnyArrayCoercion[G](source: Type[G]): Option[(Coercion[G], TArray[G])] = source match {
- case t: CPrimitiveType[G] => chainCCoercion(t, getAnyArrayCoercion)
- case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnyArrayCoercion)
- case acc: SYCLTAccessor[G] => Some((
- CoerceIdentity(source),
- FuncTools.repeat(TArray[G](_), acc.dimCount, acc.typ).asInstanceOf[TArray[G]]
- ))
- case acc: SYCLTLocalAccessor[G] => Some((
- CoerceIdentity(source),
- FuncTools.repeat(TArray[G](_), acc.dimCount, acc.typ).asInstanceOf[TArray[G]]
- ))
- case t: TArray[G] => Some((CoerceIdentity(source), t))
- case _: TNull[G] =>
- val t = TArray[G](TAnyValue())
- Some((CoerceNullArray(t), t))
- case _ => None
- }
+ def getAnyArrayCoercion[G](
+ source: Type[G]
+ ): Option[(Coercion[G], TArray[G])] =
+ source match {
+ case t: CPrimitiveType[G] => chainCCoercion(t, getAnyArrayCoercion)
+ case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnyArrayCoercion)
+ case acc: SYCLTAccessor[G] =>
+ Some((
+ CoerceIdentity(source),
+ FuncTools.repeat(TArray[G](_), acc.dimCount, acc.typ)
+ .asInstanceOf[TArray[G]],
+ ))
+ case acc: SYCLTLocalAccessor[G] =>
+ Some((
+ CoerceIdentity(source),
+ FuncTools.repeat(TArray[G](_), acc.dimCount, acc.typ)
+ .asInstanceOf[TArray[G]],
+ ))
+ case t: TArray[G] => Some((CoerceIdentity(source), t))
+ case _: TNull[G] =>
+ val t = TArray[G](TAnyValue())
+ Some((CoerceNullArray(t), t))
+ case _ => None
+ }
- def getAnyMatrixArrayCoercion[G](source: Type[G]): Option[(Coercion[G], TArray[G])] = source match {
- case t: CPrimitiveType[G] => chainCCoercion(t, getAnyMatrixArrayCoercion)
- case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnyMatrixArrayCoercion)
- case acc: SYCLTAccessor[G] if acc.dimCount >= 2 => Some((
- CoerceIdentity(source),
- FuncTools.repeat(TArray[G](_), acc.dimCount, acc.typ).asInstanceOf[TArray[G]]
- ))
- case acc: SYCLTLocalAccessor[G] if acc.dimCount >= 2 => Some((
- CoerceIdentity(source),
- FuncTools.repeat(TArray[G](_), acc.dimCount, acc.typ).asInstanceOf[TArray[G]]
- ))
- case t @ TArray(TArray(_)) => Some((CoerceIdentity(source), t))
- case TArray(TNull()) => Some(???)
- case TNull() =>
- val t = TArray[G](TArray[G](TAnyValue()))
- Some((CoerceNullArray(t), t))
- case _ => None
- }
+ def getAnyMatrixArrayCoercion[G](
+ source: Type[G]
+ ): Option[(Coercion[G], TArray[G])] =
+ source match {
+ case t: CPrimitiveType[G] => chainCCoercion(t, getAnyMatrixArrayCoercion)
+ case t: CPPPrimitiveType[G] =>
+ chainCPPCoercion(t, getAnyMatrixArrayCoercion)
+ case acc: SYCLTAccessor[G] if acc.dimCount >= 2 =>
+ Some((
+ CoerceIdentity(source),
+ FuncTools.repeat(TArray[G](_), acc.dimCount, acc.typ)
+ .asInstanceOf[TArray[G]],
+ ))
+ case acc: SYCLTLocalAccessor[G] if acc.dimCount >= 2 =>
+ Some((
+ CoerceIdentity(source),
+ FuncTools.repeat(TArray[G](_), acc.dimCount, acc.typ)
+ .asInstanceOf[TArray[G]],
+ ))
+ case t @ TArray(TArray(_)) => Some((CoerceIdentity(source), t))
+ case TArray(TNull()) => Some(???)
+ case TNull() =>
+ val t = TArray[G](TArray[G](TAnyValue()))
+ Some((CoerceNullArray(t), t))
+ case _ => None
+ }
- def getAnyOptionCoercion[G](source: Type[G]): Option[(Coercion[G], TOption[G])] = source match {
- case t: CPrimitiveType[G] => chainCCoercion(t, getAnyOptionCoercion)
- case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnyOptionCoercion)
- case t: TOption[G] => Some((CoerceIdentity(source), t))
- case _ => None
- }
+ def getAnyOptionCoercion[G](
+ source: Type[G]
+ ): Option[(Coercion[G], TOption[G])] =
+ source match {
+ case t: CPrimitiveType[G] => chainCCoercion(t, getAnyOptionCoercion)
+ case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnyOptionCoercion)
+ case t: TOption[G] => Some((CoerceIdentity(source), t))
+ case _ => None
+ }
- def getAnyMapCoercion[G](source: Type[G]): Option[(Coercion[G], TMap[G])] = source match {
- case t: CPrimitiveType[G] => chainCCoercion(t, getAnyMapCoercion)
- case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnyMapCoercion)
- case t: TMap[G] => Some((CoerceIdentity(source), t))
- case _ => None
- }
+ def getAnyMapCoercion[G](source: Type[G]): Option[(Coercion[G], TMap[G])] =
+ source match {
+ case t: CPrimitiveType[G] => chainCCoercion(t, getAnyMapCoercion)
+ case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnyMapCoercion)
+ case t: TMap[G] => Some((CoerceIdentity(source), t))
+ case _ => None
+ }
- def getAnyTupleCoercion[G](source: Type[G]): Option[(Coercion[G], TTuple[G])] = source match {
- case t: CPrimitiveType[G] => chainCCoercion(t, getAnyTupleCoercion)
- case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnyTupleCoercion)
- case t: TTuple[G] => Some((CoerceIdentity(source), t))
- case _ => None
- }
+ def getAnyTupleCoercion[G](
+ source: Type[G]
+ ): Option[(Coercion[G], TTuple[G])] =
+ source match {
+ case t: CPrimitiveType[G] => chainCCoercion(t, getAnyTupleCoercion)
+ case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnyTupleCoercion)
+ case t: TTuple[G] => Some((CoerceIdentity(source), t))
+ case _ => None
+ }
- def getAnyMatrixCoercion[G](source: Type[G]): Option[(Coercion[G], TMatrix[G])] = source match {
- case t: CPrimitiveType[G] => chainCCoercion(t, getAnyMatrixCoercion)
- case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnyMatrixCoercion)
- case t: TMatrix[G] => Some((CoerceIdentity(source), t))
- case _ => None
- }
+ def getAnyMatrixCoercion[G](
+ source: Type[G]
+ ): Option[(Coercion[G], TMatrix[G])] =
+ source match {
+ case t: CPrimitiveType[G] => chainCCoercion(t, getAnyMatrixCoercion)
+ case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnyMatrixCoercion)
+ case t: TMatrix[G] => Some((CoerceIdentity(source), t))
+ case _ => None
+ }
- def getAnyModelCoercion[G](source: Type[G]): Option[(Coercion[G], TModel[G])] = source match {
- case t: CPrimitiveType[G] => chainCCoercion(t, getAnyModelCoercion)
- case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnyModelCoercion)
- case t: TModel[G] => Some((CoerceIdentity(source), t))
- case _ => None
- }
+ def getAnyModelCoercion[G](
+ source: Type[G]
+ ): Option[(Coercion[G], TModel[G])] =
+ source match {
+ case t: CPrimitiveType[G] => chainCCoercion(t, getAnyModelCoercion)
+ case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnyModelCoercion)
+ case t: TModel[G] => Some((CoerceIdentity(source), t))
+ case _ => None
+ }
- def getAnyClassCoercion[G](source: Type[G]): Option[(Coercion[G], TClass[G])] = source match {
- case t: CPrimitiveType[G] => chainCCoercion(t, getAnyClassCoercion)
- case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnyClassCoercion)
- case t: TClass[G] => Some((CoerceIdentity(source), t))
-
- case t: TUnion[G] =>
- val superType = Types.leastCommonSuperType(t.types)
- getAnyClassCoercion(superType) match {
- case Some((coercion, target)) =>
- val joinedCoercion = CoercionSequence(Seq(
- CoerceJoinUnion(t.types.map(getCoercion(_, superType).get), t.types, superType),
- coercion,
- ))
- Some((joinedCoercion, target))
- case None => None
- }
+ def getAnyClassCoercion[G](
+ source: Type[G]
+ ): Option[(Coercion[G], TClass[G])] =
+ source match {
+ case t: CPrimitiveType[G] => chainCCoercion(t, getAnyClassCoercion)
+ case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnyClassCoercion)
+ case t: TClass[G] => Some((CoerceIdentity(source), t))
+
+ case t: TUnion[G] =>
+ val superType = Types.leastCommonSuperType(t.types)
+ getAnyClassCoercion(superType) match {
+ case Some((coercion, target)) =>
+ val joinedCoercion = CoercionSequence(Seq(
+ CoerceJoinUnion(
+ t.types.map(getCoercion(_, superType).get),
+ t.types,
+ superType,
+ ),
+ coercion,
+ ))
+ Some((joinedCoercion, target))
+ case None => None
+ }
- case _ => None
- }
+ case _ => None
+ }
- def getAnyEitherCoercion[G](source: Type[G]): Option[(Coercion[G], TEither[G])] = source match {
- case t: CPrimitiveType[G] => chainCCoercion(t, getAnyEitherCoercion)
- case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnyEitherCoercion)
- case t: TEither[G] => Some((CoerceIdentity(source), t))
- case _ => None
- }
+ def getAnyEitherCoercion[G](
+ source: Type[G]
+ ): Option[(Coercion[G], TEither[G])] =
+ source match {
+ case t: CPrimitiveType[G] => chainCCoercion(t, getAnyEitherCoercion)
+ case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnyEitherCoercion)
+ case t: TEither[G] => Some((CoerceIdentity(source), t))
+ case _ => None
+ }
- def getAnyBitvecCoercion[G](source: Type[G]): Option[(Coercion[G], TSmtlibBitVector[G])] = source match {
- case t: CPrimitiveType[G] => chainCCoercion(t, getAnyBitvecCoercion)
- case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnyBitvecCoercion)
- case t: TSmtlibBitVector[G] => Some((CoerceIdentity(source), t))
- case _ => None
- }
+ def getAnyBitvecCoercion[G](
+ source: Type[G]
+ ): Option[(Coercion[G], TSmtlibBitVector[G])] =
+ source match {
+ case t: CPrimitiveType[G] => chainCCoercion(t, getAnyBitvecCoercion)
+ case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnyBitvecCoercion)
+ case t: TSmtlibBitVector[G] => Some((CoerceIdentity(source), t))
+ case _ => None
+ }
- def getAnySmtlibFloatCoercion[G](source: Type[G]): Option[(Coercion[G], TSmtlibFloatingPoint[G])] = source match {
- case t: CPrimitiveType[G] => chainCCoercion(t, getAnySmtlibFloatCoercion)
- case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnySmtlibFloatCoercion)
- case t: TSmtlibFloatingPoint[G] => Some((CoerceIdentity(source), t))
- case _ => None
- }
+ def getAnySmtlibFloatCoercion[G](
+ source: Type[G]
+ ): Option[(Coercion[G], TSmtlibFloatingPoint[G])] =
+ source match {
+ case t: CPrimitiveType[G] => chainCCoercion(t, getAnySmtlibFloatCoercion)
+ case t: CPPPrimitiveType[G] =>
+ chainCPPCoercion(t, getAnySmtlibFloatCoercion)
+ case t: TSmtlibFloatingPoint[G] => Some((CoerceIdentity(source), t))
+ case _ => None
+ }
- def getAnySmtlibArrayCoercion[G](source: Type[G]): Option[(Coercion[G], TSmtlibArray[G])] = source match {
- case t: CPrimitiveType[G] => chainCCoercion(t, getAnySmtlibArrayCoercion)
- case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnySmtlibArrayCoercion)
- case t: TSmtlibArray[G] => Some((CoerceIdentity(source), t))
- case _ => None
- }
+ def getAnySmtlibArrayCoercion[G](
+ source: Type[G]
+ ): Option[(Coercion[G], TSmtlibArray[G])] =
+ source match {
+ case t: CPrimitiveType[G] => chainCCoercion(t, getAnySmtlibArrayCoercion)
+ case t: CPPPrimitiveType[G] =>
+ chainCPPCoercion(t, getAnySmtlibArrayCoercion)
+ case t: TSmtlibArray[G] => Some((CoerceIdentity(source), t))
+ case _ => None
+ }
- def getAnySmtlibSeqCoercion[G](source: Type[G]): Option[(Coercion[G], TSmtlibSeq[G])] = source match {
- case t: CPrimitiveType[G] => chainCCoercion(t, getAnySmtlibSeqCoercion)
- case t: CPPPrimitiveType[G] => chainCPPCoercion(t, getAnySmtlibSeqCoercion)
- case t: TSmtlibSeq[G] => Some((CoerceIdentity(source), t))
- case _ => None
- }
-}
\ No newline at end of file
+ def getAnySmtlibSeqCoercion[G](
+ source: Type[G]
+ ): Option[(Coercion[G], TSmtlibSeq[G])] =
+ source match {
+ case t: CPrimitiveType[G] => chainCCoercion(t, getAnySmtlibSeqCoercion)
+ case t: CPPPrimitiveType[G] =>
+ chainCPPCoercion(t, getAnySmtlibSeqCoercion)
+ case t: TSmtlibSeq[G] => Some((CoerceIdentity(source), t))
+ case _ => None
+ }
+}
diff --git a/src/col/vct/col/typerules/Types.scala b/src/col/vct/col/typerules/Types.scala
index 8a43c6321a..c06bdb2e45 100644
--- a/src/col/vct/col/typerules/Types.scala
+++ b/src/col/vct/col/typerules/Types.scala
@@ -16,79 +16,90 @@ object Types {
def leastCommonSuperType[G](ts: Seq[Type[G]]): Type[G] =
ts.foldLeft[Type[G]](TNothing())(leastCommonSuperType[G])
- def leastCommonSuperType[G](left: Type[G], right: Type[G]): Type[G] = (left, right) match {
- // The result for NotAValue should not matter, since they should be filtered out by LangSpecificToCol.
- case (left: TNotAValue[_], _) => left
- case (_, right: TNotAValue[_]) => right
+ def leastCommonSuperType[G](left: Type[G], right: Type[G]): Type[G] =
+ (left, right) match {
+ // The result for NotAValue should not matter, since they should be filtered out by LangSpecificToCol.
+ case (left: TNotAValue[_], _) => left
+ case (_, right: TNotAValue[_]) => right
- // Any other types are below Any, so we can safely default to that from here.
- // First the simple case where either type is a supertype of the other
- case (left, right) if left.superTypeOf(right) => left
- case (left, right) if right.superTypeOf(left) => right
+ // Any other types are below Any, so we can safely default to that from here.
+ // First the simple case where either type is a supertype of the other
+ case (left, right) if left.superTypeOf(right) => left
+ case (left, right) if right.superTypeOf(left) => right
- // Covariant types can apply the least common supertype in their type argument
- case (TOption(left), TOption(right)) =>
- TOption(leastCommonSuperType(left, right))
- case (TEither(leftLeft, leftRight), TEither(rightLeft, rightRight)) =>
- TEither(
- leastCommonSuperType(leftLeft, rightLeft),
- leastCommonSuperType(leftRight, rightRight),
- )
- case (TTuple(left), TTuple(right)) if left.size == right.size =>
- TTuple(left.zip(right).map { case (l, r) => leastCommonSuperType(l, r) })
- case (TSeq(left), TSeq(right)) =>
- TSeq(leastCommonSuperType(left, right))
- case (TSet(left), TSet(right)) =>
- TSet(leastCommonSuperType(left, right))
- case (TVector(sizeLeft, left), TVector(sizeRight, right)) if sizeLeft == sizeRight =>
- TVector(sizeLeft, leastCommonSuperType(left, right))()
- case (TBag(left), TBag(right)) =>
- TBag(leastCommonSuperType(left, right))
- case (TMatrix(left), TMatrix(right)) =>
- TMatrix(leastCommonSuperType(left, right))
- case (TMap(leftK, leftV), TMap(rightK, rightV)) =>
- // Map is not covariant in the key, so if the keys are inequal the best we can do is Any
- if(leftK == rightK) TMap(leftK, leastCommonSuperType(leftV, rightV))
- else TAnyValue()
- case (TType(left), TType(right)) =>
- TType(leastCommonSuperType(left, right))
+ // Covariant types can apply the least common supertype in their type argument
+ case (TOption(left), TOption(right)) =>
+ TOption(leastCommonSuperType(left, right))
+ case (TEither(leftLeft, leftRight), TEither(rightLeft, rightRight)) =>
+ TEither(
+ leastCommonSuperType(leftLeft, rightLeft),
+ leastCommonSuperType(leftRight, rightRight),
+ )
+ case (TTuple(left), TTuple(right)) if left.size == right.size =>
+ TTuple(left.zip(right).map { case (l, r) =>
+ leastCommonSuperType(l, r)
+ })
+ case (TSeq(left), TSeq(right)) => TSeq(leastCommonSuperType(left, right))
+ case (TSet(left), TSet(right)) => TSet(leastCommonSuperType(left, right))
+ case (TVector(sizeLeft, left), TVector(sizeRight, right))
+ if sizeLeft == sizeRight =>
+ TVector(sizeLeft, leastCommonSuperType(left, right))()
+ case (TBag(left), TBag(right)) => TBag(leastCommonSuperType(left, right))
+ case (TMatrix(left), TMatrix(right)) =>
+ TMatrix(leastCommonSuperType(left, right))
+ case (TMap(leftK, leftV), TMap(rightK, rightV)) =>
+ // Map is not covariant in the key, so if the keys are inequal the best we can do is Any
+ if (leftK == rightK)
+ TMap(leftK, leastCommonSuperType(leftV, rightV))
+ else
+ TAnyValue()
+ case (TType(left), TType(right)) =>
+ TType(leastCommonSuperType(left, right))
- case (left @ TClass(_, _), right @ TClass(_, _)) =>
- val leftArrows = left.transSupportArrows
- val rightArrows = right.transSupportArrows
- // Shared support are classes where there is an incoming left-arrow and right-arrow
- // If left supports right (or vice-versa), there would be a problem, since right will not have a self-arrow
- // However, this is caught by the simple sub-typing relation above already.
- val shared = leftArrows.collect { case (_, sup) if rightArrows.exists { case (_, rsup) => rsup == sup } => sup }
- // We are not interested in types that occur above shared types
- val nonBottom = leftArrows.intersect(rightArrows).map { case (sub, sup) => sup }
- val classes = (shared.toSet -- nonBottom.toSet).toSeq
- classes match {
- case Nil => TAnyClass()
- case Seq(t) => t
- case other => TUnion(other)
- }
+ case (left @ TClass(_, _), right @ TClass(_, _)) =>
+ val leftArrows = left.transSupportArrows
+ val rightArrows = right.transSupportArrows
+ // Shared support are classes where there is an incoming left-arrow and right-arrow
+ // If left supports right (or vice-versa), there would be a problem, since right will not have a self-arrow
+ // However, this is caught by the simple sub-typing relation above already.
+ val shared = leftArrows.collect {
+ case (_, sup) if rightArrows.exists { case (_, rsup) =>
+ rsup == sup
+ } =>
+ sup
+ }
+ // We are not interested in types that occur above shared types
+ val nonBottom = leftArrows.intersect(rightArrows).map {
+ case (sub, sup) => sup
+ }
+ val classes = (shared.toSet -- nonBottom.toSet).toSeq
+ classes match {
+ case Nil => TAnyClass()
+ case Seq(t) => t
+ case other => TUnion(other)
+ }
- case (TClass(_, _), TAnyClass()) | (TAnyClass(), TClass(_, _)) =>
- TAnyClass()
+ case (TClass(_, _), TAnyClass()) | (TAnyClass(), TClass(_, _)) =>
+ TAnyClass()
- // TODO similar stuff for JavaClass
+ // TODO similar stuff for JavaClass
- case (TUnion(left), TUnion(right)) => TUnion((left ++ right).distinct)
- case (TUnion(left), right) => TUnion((left :+ right).distinct)
- case (left, TUnion(right)) => TUnion((left +: right).distinct)
+ case (TUnion(left), TUnion(right)) => TUnion((left ++ right).distinct)
+ case (TUnion(left), right) => TUnion((left :+ right).distinct)
+ case (left, TUnion(right)) => TUnion((left +: right).distinct)
- case (TBoundedInt(leftGte, leftLt), TBoundedInt(rightGte, rightLt)) =>
- TBoundedInt(leftGte.min(rightGte), leftLt.max(rightLt))
+ case (TBoundedInt(leftGte, leftLt), TBoundedInt(rightGte, rightLt)) =>
+ TBoundedInt(leftGte.min(rightGte), leftLt.max(rightLt))
- // Unrelated types below rational are simply a rational
- case (left, right) if TRational().superTypeOf(left) && TRational().superTypeOf(right) =>
- TRational()
+ // Unrelated types below rational are simply a rational
+ case (left, right)
+ if TRational().superTypeOf(left) && TRational().superTypeOf(right) =>
+ TRational()
- case (left, right) if TAnyValue().superTypeOf(left) && TAnyValue().superTypeOf(right) =>
- TAnyValue()
+ case (left, right)
+ if TAnyValue().superTypeOf(left) && TAnyValue().superTypeOf(right) =>
+ TAnyValue()
- case (_, _) =>
- TAny()
- }
-}
\ No newline at end of file
+ case (_, _) => TAny()
+ }
+}
diff --git a/src/col/vct/col/util/AstBuildHelpers.scala b/src/col/vct/col/util/AstBuildHelpers.scala
index 33da4dd2b5..0618c8caaa 100644
--- a/src/col/vct/col/util/AstBuildHelpers.scala
+++ b/src/col/vct/col/util/AstBuildHelpers.scala
@@ -8,46 +8,51 @@ import vct.col.ref.{DirectRef, Ref}
import vct.col.rewrite.Rewritten
import vct.result.VerificationError.{Unreachable, UserError}
-/**
- * Collection of general AST building utilities. This is meant to organically grow, so add helpers as you see fit.
- */
+/** Collection of general AST building utilities. This is meant to organically
+ * grow, so add helpers as you see fit.
+ */
object AstBuildHelpers {
val ZERO: BigInt = BigInt(0)
val ONE: BigInt = BigInt(1)
- case class NumericDividingError(left: Expr[_], right: Expr[_]) extends UserError {
- override def text: String = f"Expected types to numeric, but got: ${left.t} and ${right.t} for $left and $right"
+ case class NumericDividingError(left: Expr[_], right: Expr[_])
+ extends UserError {
+ override def text: String =
+ f"Expected types to numeric, but got: ${left.t} and ${right.t} for $left and $right"
override def code: String = "numericDividingError"
}
- /**
- * IMPORTANT: operators that end with a colon (`:`) are right-associative. For example:
- *
- * {{{
- * trait Exp {
- * // wrong assumption: this /: right is Divide(this, right)
- * def /:(right: Exp) = Divide(this, right)
- * }
- *
- * case class Number(x: Int) extends Exp
- * case class Divide(left: Exp, right: Exp)
- *
- * val one = Number(1)
- * val two = Number(2)
- * assert( (one /: two) == Divide(two, one) ) // !!!
- * assert( (one /: two) == two./:(one) )
- * }}}
- *
- * Also take into account how scala defines
- * operator precedence
- * when using or defining operators here. The precedence generally does not match e.g. the syntax
- * of PVL.
- */
+ /** IMPORTANT: operators that end with a colon (`:`) are
+ * right-associative. For example:
+ *
+ * {{{
+ * trait Exp {
+ * // wrong assumption: this /: right is Divide(this, right)
+ * def /:(right: Exp) = Divide(this, right)
+ * }
+ *
+ * case class Number(x: Int) extends Exp
+ * case class Divide(left: Exp, right: Exp)
+ *
+ * val one = Number(1)
+ * val two = Number(2)
+ * assert( (one /: two) == Divide(two, one) ) // !!!
+ * assert( (one /: two) == two./:(one) )
+ * }}}
+ *
+ * Also take into account how scala defines operator
+ * precedence when using or defining operators here. The precedence
+ * generally does not match e.g. the syntax of PVL.
+ */
implicit class ExprBuildHelpers[G](left: Expr[G]) {
def +(right: Expr[G])(implicit origin: Origin): Plus[G] = Plus(left, right)
- def -(right: Expr[G])(implicit origin: Origin): Minus[G] = Minus(left, right)
+ def -(right: Expr[G])(implicit origin: Origin): Minus[G] =
+ Minus(left, right)
def *(right: Expr[G])(implicit origin: Origin): Mult[G] = Mult(left, right)
- def /(right: Expr[G])(implicit origin: Origin, blame: Blame[DivByZero]): DividingExpr[G] = {
+ def /(
+ right: Expr[G]
+ )(implicit origin: Origin, blame: Blame[DivByZero]): DividingExpr[G] = {
(left.t, right.t) match {
case (_: IntType[G], _: IntType[G]) => FloorDiv(left, right)(blame)
case (_: FloatType[G], _: FloatType[G]) => FloatDiv(left, right)(blame)
@@ -56,217 +61,481 @@ object AstBuildHelpers {
case _ => throw NumericDividingError(left, right)
}
}
- def /:/(right: Expr[G])(implicit origin: Origin, blame: Blame[DivByZero]): RatDiv[G] = RatDiv(left, right)(blame)
- def %(right: Expr[G])(implicit origin: Origin, blame: Blame[DivByZero]): Mod[G] = Mod(left, right)(blame)
+ def /:/(
+ right: Expr[G]
+ )(implicit origin: Origin, blame: Blame[DivByZero]): RatDiv[G] =
+ RatDiv(left, right)(blame)
+ def %(
+ right: Expr[G]
+ )(implicit origin: Origin, blame: Blame[DivByZero]): Mod[G] =
+ Mod(left, right)(blame)
def ===(right: Expr[G])(implicit origin: Origin): Eq[G] = Eq(left, right)
def !==(right: Expr[G])(implicit origin: Origin): Neq[G] = Neq(left, right)
def <(right: Expr[G])(implicit origin: Origin): Less[G] = Less(left, right)
- def >(right: Expr[G])(implicit origin: Origin): Greater[G] = Greater(left, right)
- def <=(right: Expr[G])(implicit origin: Origin): LessEq[G] = LessEq(left, right)
- def >=(right: Expr[G])(implicit origin: Origin): GreaterEq[G] = GreaterEq(left, right)
+ def >(right: Expr[G])(implicit origin: Origin): Greater[G] =
+ Greater(left, right)
+ def <=(right: Expr[G])(implicit origin: Origin): LessEq[G] =
+ LessEq(left, right)
+ def >=(right: Expr[G])(implicit origin: Origin): GreaterEq[G] =
+ GreaterEq(left, right)
def unary_!(implicit origin: Origin): Not[G] = Not(left)
def &&(right: Expr[G])(implicit origin: Origin): And[G] = And(left, right)
def ||(right: Expr[G])(implicit origin: Origin): Or[G] = Or(left, right)
def &*(right: Expr[G])(implicit origin: Origin): Star[G] = Star(left, right)
- def ==>(right: Expr[G])(implicit origin: Origin): Implies[G] = Implies(left, right)
+ def ==>(right: Expr[G])(implicit origin: Origin): Implies[G] =
+ Implies(left, right)
- def ~>(field: SilverField[G])(implicit blame: Blame[InsufficientPermission], origin: Origin): SilverDeref[G] = SilverDeref[G](left, field.ref)(blame)
+ def ~>(field: SilverField[G])(
+ implicit blame: Blame[InsufficientPermission],
+ origin: Origin,
+ ): SilverDeref[G] = SilverDeref[G](left, field.ref)(blame)
- def @@(index: Expr[G])(implicit blame: Blame[SeqBoundFailure], origin: Origin): SeqSubscript[G] = SeqSubscript(left, index)(blame)
+ def @@(
+ index: Expr[G]
+ )(implicit blame: Blame[SeqBoundFailure], origin: Origin): SeqSubscript[G] =
+ SeqSubscript(left, index)(blame)
}
implicit class VarBuildHelpers[G](left: Variable[G]) {
def get(implicit origin: Origin): Local[G] = Local(new DirectRef(left))
- def <~(right: Expr[G])(implicit origin: Origin): SilverLocalAssign[G] = SilverLocalAssign(new DirectRef(left), right)
+ def <~(right: Expr[G])(implicit origin: Origin): SilverLocalAssign[G] =
+ SilverLocalAssign(new DirectRef(left), right)
}
implicit class FieldBuildHelpers[G](left: SilverDeref[G]) {
- def <~(right: Expr[G])(implicit blame: Blame[AssignFailed], origin: Origin): SilverFieldAssign[G] = SilverFieldAssign(left.obj, left.field, right)(blame)
+ def <~(right: Expr[G])(
+ implicit blame: Blame[AssignFailed],
+ origin: Origin,
+ ): SilverFieldAssign[G] =
+ SilverFieldAssign(left.obj, left.field, right)(blame)
}
- implicit class ApplicableBuildHelpers[Pre, Post](applicable: Applicable[Pre])(implicit rewriter: AbstractRewriter[Pre, Post]) {
- def rewrite(args: => Seq[Variable[Post]] = rewriter.variables.dispatch(applicable.args),
- ): Applicable[Post] = applicable match {
- case inlineable: InlineableApplicable[Pre] =>
- new InlineableApplicableBuildHelpers(inlineable).rewrite(args = args)
- case function: ADTFunction[Pre] =>
- function.rewrite(args = args)
- case process: ModelProcess[Pre] =>
- process.rewrite(args = args)
- case action: ModelAction[Pre] =>
- action.rewrite(args = args)
- case llvm: LlvmFunctionDefinition[Pre] =>
- llvm.rewrite(args = args)
- case prover: ProverFunction[Pre] =>
- prover.rewrite(args = args)
- }
+ implicit class ApplicableBuildHelpers[Pre, Post](applicable: Applicable[Pre])(
+ implicit rewriter: AbstractRewriter[Pre, Post]
+ ) {
+ def rewrite(
+ args: => Seq[Variable[Post]] = rewriter.variables
+ .dispatch(applicable.args)
+ ): Applicable[Post] =
+ applicable match {
+ case inlineable: InlineableApplicable[Pre] =>
+ new InlineableApplicableBuildHelpers(inlineable).rewrite(args = args)
+ case function: ADTFunction[Pre] => function.rewrite(args = args)
+ case process: ModelProcess[Pre] => process.rewrite(args = args)
+ case action: ModelAction[Pre] => action.rewrite(args = args)
+ case llvm: LlvmFunctionDefinition[Pre] => llvm.rewrite(args = args)
+ case prover: ProverFunction[Pre] => prover.rewrite(args = args)
+ }
}
- implicit class InlineableApplicableBuildHelpers[Pre, Post](inlineable: InlineableApplicable[Pre])(implicit rewriter: AbstractRewriter[Pre, Post]) {
- def rewrite(args: => Seq[Variable[Post]] = rewriter.variables.dispatch(inlineable.args),
- inline: => Boolean = inlineable.inline,
- ): InlineableApplicable[Post] = inlineable match {
- case pred: AbstractPredicate[Pre] =>
- new PredicateBuildHelpers(pred).rewrite(args = args, inline = inline)
- case contracted: ContractApplicable[Pre] =>
- new ContractApplicableBuildHelpers(contracted).rewrite(args = args, inline = inline)
- }
+ implicit class InlineableApplicableBuildHelpers[Pre, Post](
+ inlineable: InlineableApplicable[Pre]
+ )(implicit rewriter: AbstractRewriter[Pre, Post]) {
+ def rewrite(
+ args: => Seq[Variable[Post]] = rewriter.variables
+ .dispatch(inlineable.args),
+ inline: => Boolean = inlineable.inline,
+ ): InlineableApplicable[Post] =
+ inlineable match {
+ case pred: AbstractPredicate[Pre] =>
+ new PredicateBuildHelpers(pred).rewrite(args = args, inline = inline)
+ case contracted: ContractApplicable[Pre] =>
+ new ContractApplicableBuildHelpers(contracted)
+ .rewrite(args = args, inline = inline)
+ }
}
- implicit class ContractApplicableBuildHelpers[Pre, Post](contracted: ContractApplicable[Pre])(implicit rewriter: AbstractRewriter[Pre, Post]) {
- def rewrite(args: => Seq[Variable[Post]] = rewriter.variables.dispatch(contracted.args),
- returnType: => Type[Post] = rewriter.dispatch(contracted.returnType),
- typeArgs: => Seq[Variable[Post]] = rewriter.variables.dispatch(contracted.typeArgs),
- contract: => ApplicableContract[Post] = rewriter.dispatch(contracted.contract),
- inline: => Boolean = contracted.inline,
- ): ContractApplicable[Post] = contracted match {
- case function: Function[Pre] =>
- function.rewrite(args = args, returnType = returnType, typeArgs = typeArgs, inline = Some(inline), contract = contract)
- case function: InstanceFunction[Pre] =>
- function.rewrite(args = args, returnType = returnType, typeArgs = typeArgs, inline = Some(inline), contract = contract)
- case function: InstanceOperatorFunction[Pre] =>
- function.rewrite(args = args, returnType = returnType, inline = Some(inline), contract = contract)
- case function: LlvmSpecFunction[Pre] =>
- function.rewrite(args = args, returnType = returnType, typeArgs = typeArgs, inline = Some(inline), contract = contract)
- case method: AbstractMethod[Pre] =>
- new MethodBuildHelpers(method).rewrite(args = args, returnType = returnType, typeArgs = typeArgs, inline = inline, contract = contract)
- }
+ implicit class ContractApplicableBuildHelpers[Pre, Post](
+ contracted: ContractApplicable[Pre]
+ )(implicit rewriter: AbstractRewriter[Pre, Post]) {
+ def rewrite(
+ args: => Seq[Variable[Post]] = rewriter.variables
+ .dispatch(contracted.args),
+ returnType: => Type[Post] = rewriter.dispatch(contracted.returnType),
+ typeArgs: => Seq[Variable[Post]] = rewriter.variables
+ .dispatch(contracted.typeArgs),
+ contract: => ApplicableContract[Post] = rewriter
+ .dispatch(contracted.contract),
+ inline: => Boolean = contracted.inline,
+ ): ContractApplicable[Post] =
+ contracted match {
+ case function: Function[Pre] =>
+ function.rewrite(
+ args = args,
+ returnType = returnType,
+ typeArgs = typeArgs,
+ inline = Some(inline),
+ contract = contract,
+ )
+ case function: InstanceFunction[Pre] =>
+ function.rewrite(
+ args = args,
+ returnType = returnType,
+ typeArgs = typeArgs,
+ inline = Some(inline),
+ contract = contract,
+ )
+ case function: InstanceOperatorFunction[Pre] =>
+ function.rewrite(
+ args = args,
+ returnType = returnType,
+ inline = Some(inline),
+ contract = contract,
+ )
+ case function: LlvmSpecFunction[Pre] =>
+ function.rewrite(
+ args = args,
+ returnType = returnType,
+ typeArgs = typeArgs,
+ inline = Some(inline),
+ contract = contract,
+ )
+ case method: AbstractMethod[Pre] =>
+ new MethodBuildHelpers(method).rewrite(
+ args = args,
+ returnType = returnType,
+ typeArgs = typeArgs,
+ inline = inline,
+ contract = contract,
+ )
+ }
}
- implicit class MethodBuildHelpers[Pre, Post](method: AbstractMethod[Pre])(implicit rewriter: AbstractRewriter[Pre, Post]) {
- def rewrite(args: => Seq[Variable[Post]] = rewriter.variables.dispatch(method.args),
- returnType: => Type[Post] = rewriter.dispatch(method.returnType),
- outArgs: => Seq[Variable[Post]] = rewriter.variables.dispatch(method.outArgs),
- body: => Option[Statement[Post]] = method.body.map(rewriter.dispatch),
- contract: => ApplicableContract[Post] = rewriter.dispatch(method.contract),
- typeArgs: => Seq[Variable[Post]] = rewriter.variables.dispatch(method.typeArgs),
- inline: => Boolean = method.inline,
- pure: => Boolean = method.pure,
- blame: Blame[CallableFailure] = method.blame,
- ): AbstractMethod[Post] = method match {
- case procedure: Procedure[Pre] =>
- procedure.rewrite(args = args, returnType = returnType, body = body, inline = Some(inline), contract = contract, typeArgs = typeArgs, outArgs = outArgs, pure = Some(pure), blame = blame)
- case method: InstanceMethod[Pre] =>
- method.rewrite(args = args, returnType = returnType, body = body, inline = Some(inline), contract = contract, typeArgs = typeArgs, outArgs = outArgs, pure = Some(pure), blame = blame)
- case method: InstanceOperatorMethod[Pre] =>
- method.rewrite(returnType = returnType, operator = rewriter.dispatch(method.operator), args = args, body = body, contract = contract, inline = Some(inline), pure = Some(pure), blame = blame)
- case cons: Constructor[Pre] =>
- cons.rewrite(args = args, outArgs = outArgs, typeArgs = typeArgs, body = body, contract = contract, inline = Some(inline), blame = blame)
- }
+ implicit class MethodBuildHelpers[Pre, Post](method: AbstractMethod[Pre])(
+ implicit rewriter: AbstractRewriter[Pre, Post]
+ ) {
+ def rewrite(
+ args: => Seq[Variable[Post]] = rewriter.variables.dispatch(method.args),
+ returnType: => Type[Post] = rewriter.dispatch(method.returnType),
+ outArgs: => Seq[Variable[Post]] = rewriter.variables
+ .dispatch(method.outArgs),
+ body: => Option[Statement[Post]] = method.body.map(rewriter.dispatch),
+ contract: => ApplicableContract[Post] = rewriter
+ .dispatch(method.contract),
+ typeArgs: => Seq[Variable[Post]] = rewriter.variables
+ .dispatch(method.typeArgs),
+ inline: => Boolean = method.inline,
+ pure: => Boolean = method.pure,
+ blame: Blame[CallableFailure] = method.blame,
+ ): AbstractMethod[Post] =
+ method match {
+ case procedure: Procedure[Pre] =>
+ procedure.rewrite(
+ args = args,
+ returnType = returnType,
+ body = body,
+ inline = Some(inline),
+ contract = contract,
+ typeArgs = typeArgs,
+ outArgs = outArgs,
+ pure = Some(pure),
+ blame = blame,
+ )
+ case method: InstanceMethod[Pre] =>
+ method.rewrite(
+ args = args,
+ returnType = returnType,
+ body = body,
+ inline = Some(inline),
+ contract = contract,
+ typeArgs = typeArgs,
+ outArgs = outArgs,
+ pure = Some(pure),
+ blame = blame,
+ )
+ case method: InstanceOperatorMethod[Pre] =>
+ method.rewrite(
+ returnType = returnType,
+ operator = rewriter.dispatch(method.operator),
+ args = args,
+ body = body,
+ contract = contract,
+ inline = Some(inline),
+ pure = Some(pure),
+ blame = blame,
+ )
+ case cons: Constructor[Pre] =>
+ cons.rewrite(
+ args = args,
+ outArgs = outArgs,
+ typeArgs = typeArgs,
+ body = body,
+ contract = contract,
+ inline = Some(inline),
+ blame = blame,
+ )
+ }
}
- implicit class FunctionBuildHelpers[Pre, Post](function: AbstractFunction[Pre])(implicit rewriter: AbstractRewriter[Pre, Post]) {
- def rewrite(args: => Seq[Variable[Post]] = rewriter.variables.dispatch(function.args),
- returnType: => Type[Post] = rewriter.dispatch(function.returnType),
- body: => Option[Expr[Post]] = function.body.map(rewriter.dispatch),
- contract: => ApplicableContract[Post] = rewriter.dispatch(function.contract),
- typeArgs: => Seq[Variable[Post]] = rewriter.variables.dispatch(function.typeArgs),
- inline: => Boolean = function.inline,
- threadLocal: => Boolean = function.threadLocal,
- blame: => Blame[ContractedFailure] = function.blame,
- ): ContractApplicable[Post] = function match {
- case function: Function[Pre] =>
- function.rewrite(args = args, returnType = returnType, body = body, inline = Some(inline), threadLocal = Some(threadLocal), contract = contract, typeArgs = typeArgs, blame = blame)
- case function: InstanceFunction[Pre] =>
- function.rewrite(args = args, returnType = returnType, body = body, inline = Some(inline), threadLocal = Some(threadLocal), contract = contract, typeArgs = typeArgs, blame = blame)
- case function: InstanceOperatorFunction[Pre] =>
- function.rewrite(returnType = returnType, args = args, body = body, contract = contract, inline = Some(inline), threadLocal = Some(threadLocal), blame = blame)
- case function: LlvmSpecFunction[Pre] =>
- function.rewrite(returnType = returnType, args = args, body = body, contract = contract, inline = Some(inline), threadLocal = Some(threadLocal), blame = blame)
- }
+ implicit class FunctionBuildHelpers[Pre, Post](
+ function: AbstractFunction[Pre]
+ )(implicit rewriter: AbstractRewriter[Pre, Post]) {
+ def rewrite(
+ args: => Seq[Variable[Post]] = rewriter.variables
+ .dispatch(function.args),
+ returnType: => Type[Post] = rewriter.dispatch(function.returnType),
+ body: => Option[Expr[Post]] = function.body.map(rewriter.dispatch),
+ contract: => ApplicableContract[Post] = rewriter
+ .dispatch(function.contract),
+ typeArgs: => Seq[Variable[Post]] = rewriter.variables
+ .dispatch(function.typeArgs),
+ inline: => Boolean = function.inline,
+ threadLocal: => Boolean = function.threadLocal,
+ blame: => Blame[ContractedFailure] = function.blame,
+ ): ContractApplicable[Post] =
+ function match {
+ case function: Function[Pre] =>
+ function.rewrite(
+ args = args,
+ returnType = returnType,
+ body = body,
+ inline = Some(inline),
+ threadLocal = Some(threadLocal),
+ contract = contract,
+ typeArgs = typeArgs,
+ blame = blame,
+ )
+ case function: InstanceFunction[Pre] =>
+ function.rewrite(
+ args = args,
+ returnType = returnType,
+ body = body,
+ inline = Some(inline),
+ threadLocal = Some(threadLocal),
+ contract = contract,
+ typeArgs = typeArgs,
+ blame = blame,
+ )
+ case function: InstanceOperatorFunction[Pre] =>
+ function.rewrite(
+ returnType = returnType,
+ args = args,
+ body = body,
+ contract = contract,
+ inline = Some(inline),
+ threadLocal = Some(threadLocal),
+ blame = blame,
+ )
+ case function: LlvmSpecFunction[Pre] =>
+ function.rewrite(
+ returnType = returnType,
+ args = args,
+ body = body,
+ contract = contract,
+ inline = Some(inline),
+ threadLocal = Some(threadLocal),
+ blame = blame,
+ )
+ }
}
- implicit class PredicateBuildHelpers[Pre, Post](predicate: AbstractPredicate[Pre])(implicit rewriter: AbstractRewriter[Pre, Post]) {
- def rewrite(args: => Seq[Variable[Post]] = rewriter.variables.dispatch(predicate.args),
- inline: => Boolean = predicate.inline,
- threadLocal: => Boolean = predicate.threadLocal,
- ): AbstractPredicate[Post] = predicate match {
- case predicate: Predicate[Pre] =>
- predicate.rewrite(args = args, inline = Some(inline), threadLocal = Some(threadLocal))
- case predicate: InstancePredicate[Pre] =>
- predicate.rewrite(args = args, inline = Some(inline), threadLocal = Some(threadLocal))
- }
+ implicit class PredicateBuildHelpers[Pre, Post](
+ predicate: AbstractPredicate[Pre]
+ )(implicit rewriter: AbstractRewriter[Pre, Post]) {
+ def rewrite(
+ args: => Seq[Variable[Post]] = rewriter.variables
+ .dispatch(predicate.args),
+ inline: => Boolean = predicate.inline,
+ threadLocal: => Boolean = predicate.threadLocal,
+ ): AbstractPredicate[Post] =
+ predicate match {
+ case predicate: Predicate[Pre] =>
+ predicate.rewrite(
+ args = args,
+ inline = Some(inline),
+ threadLocal = Some(threadLocal),
+ )
+ case predicate: InstancePredicate[Pre] =>
+ predicate.rewrite(
+ args = args,
+ inline = Some(inline),
+ threadLocal = Some(threadLocal),
+ )
+ }
}
- implicit class ApplyBuildHelpers[Pre, Post](apply: Apply[Pre])(implicit rewriter: AbstractRewriter[Pre, Post]) {
- def rewrite(args: => Seq[Expr[Post]] = apply.args.map(rewriter.dispatch)): Apply[Post] = apply match {
- case inv: ADTFunctionInvocation[Pre] =>
- inv.rewrite(args = args)
- case inv: ProverFunctionInvocation[Pre] =>
- inv.rewrite(args = args)
- case inv: LlvmFunctionInvocation[Pre] =>
- inv.rewrite(args = args)
- case apply: ApplyAnyPredicate[Pre] =>
- new ApplyAnyPredicateBuildHelpers(apply).rewrite(args = args)
- case inv: Invocation[Pre] =>
- new InvocationBuildHelpers(inv).rewrite(args = args)
- }
+ implicit class ApplyBuildHelpers[Pre, Post](apply: Apply[Pre])(
+ implicit rewriter: AbstractRewriter[Pre, Post]
+ ) {
+ def rewrite(
+ args: => Seq[Expr[Post]] = apply.args.map(rewriter.dispatch)
+ ): Apply[Post] =
+ apply match {
+ case inv: ADTFunctionInvocation[Pre] => inv.rewrite(args = args)
+ case inv: ProverFunctionInvocation[Pre] => inv.rewrite(args = args)
+ case inv: LlvmFunctionInvocation[Pre] => inv.rewrite(args = args)
+ case apply: ApplyAnyPredicate[Pre] =>
+ new ApplyAnyPredicateBuildHelpers(apply).rewrite(args = args)
+ case inv: Invocation[Pre] =>
+ new InvocationBuildHelpers(inv).rewrite(args = args)
+ }
}
- implicit class ApplyAnyPredicateBuildHelpers[Pre, Post](apply: ApplyAnyPredicate[Pre])(implicit rewriter: AbstractRewriter[Pre, Post]) {
- def rewrite(args: => Seq[Expr[Post]] = apply.args.map(rewriter.dispatch), perm: => Expr[Post] = rewriter.dispatch(apply.perm)): ApplyAnyPredicate[Post] = apply match {
- case inv: PredicateApply[Pre] =>
- inv.rewrite(args = args, perm = perm)
- case inv: InstancePredicateApply[Pre] =>
- inv.rewrite(args = args, perm = perm)
- case inv: CoalesceInstancePredicateApply[Pre] =>
- inv.rewrite(args = args, perm = perm)
- }
+ implicit class ApplyAnyPredicateBuildHelpers[Pre, Post](
+ apply: ApplyAnyPredicate[Pre]
+ )(implicit rewriter: AbstractRewriter[Pre, Post]) {
+ def rewrite(
+ args: => Seq[Expr[Post]] = apply.args.map(rewriter.dispatch),
+ perm: => Expr[Post] = rewriter.dispatch(apply.perm),
+ ): ApplyAnyPredicate[Post] =
+ apply match {
+ case inv: PredicateApply[Pre] => inv.rewrite(args = args, perm = perm)
+ case inv: InstancePredicateApply[Pre] =>
+ inv.rewrite(args = args, perm = perm)
+ case inv: CoalesceInstancePredicateApply[Pre] =>
+ inv.rewrite(args = args, perm = perm)
+ }
}
- implicit class InvocationBuildHelpers[Pre, Post](apply: Invocation[Pre])(implicit rewriter: AbstractRewriter[Pre, Post]) {
- def rewrite(args: => Seq[Expr[Post]] = apply.args.map(rewriter.dispatch), givenMap: => Seq[(Ref[Post, Variable[Post]], Expr[Post])] = apply.givenMap.map { case (Ref(v), e) => (rewriter.succ(v), rewriter.dispatch(e)) }, yields: Seq[(Expr[Post], Ref[Post, Variable[Post]])] = apply.yields.map { case (a, b) => (rewriter.dispatch(a), rewriter.succ(b.decl)) }): Invocation[Post] = apply match {
- case apply: AnyFunctionInvocation[Pre] =>
- new ApplyAnyFunctionBuildHelpers(apply).rewrite(args = args, givenMap = givenMap, yields = yields)
- case apply: AnyMethodInvocation[Pre] =>
- new ApplyAnyMethodBuildHelpers(apply).rewrite(args = args, givenMap = givenMap, yields = yields)
- }
+ implicit class InvocationBuildHelpers[Pre, Post](apply: Invocation[Pre])(
+ implicit rewriter: AbstractRewriter[Pre, Post]
+ ) {
+ def rewrite(
+ args: => Seq[Expr[Post]] = apply.args.map(rewriter.dispatch),
+ givenMap: => Seq[(Ref[Post, Variable[Post]], Expr[Post])] = apply
+ .givenMap.map { case (Ref(v), e) =>
+ (rewriter.succ(v), rewriter.dispatch(e))
+ },
+ yields: Seq[(Expr[Post], Ref[Post, Variable[Post]])] = apply.yields
+ .map { case (a, b) => (rewriter.dispatch(a), rewriter.succ(b.decl)) },
+ ): Invocation[Post] =
+ apply match {
+ case apply: AnyFunctionInvocation[Pre] =>
+ new ApplyAnyFunctionBuildHelpers(apply)
+ .rewrite(args = args, givenMap = givenMap, yields = yields)
+ case apply: AnyMethodInvocation[Pre] =>
+ new ApplyAnyMethodBuildHelpers(apply)
+ .rewrite(args = args, givenMap = givenMap, yields = yields)
+ }
}
- implicit class ApplyAnyFunctionBuildHelpers[Pre, Post](apply: AnyFunctionInvocation[Pre])(implicit rewriter: AbstractRewriter[Pre, Post]) {
- def rewrite(args: => Seq[Expr[Post]] = apply.args.map(rewriter.dispatch), typeArgs: => Seq[Type[Post]] = apply.typeArgs.map(rewriter.dispatch), givenMap: => Seq[(Ref[Post, Variable[Post]], Expr[Post])] = apply.givenMap.map { case (Ref(v), e) => (rewriter.succ(v), rewriter.dispatch(e)) }, yields: Seq[(Expr[Post], Ref[Post, Variable[Post]])] = apply.yields.map { case (a, b) => (rewriter.dispatch(a), rewriter.succ(b.decl)) }): AnyFunctionInvocation[Post] = apply match {
- case inv: FunctionInvocation[Pre] =>
- inv.rewrite(args = args, typeArgs = typeArgs, givenMap = givenMap, yields = yields)
- case inv: InstanceFunctionInvocation[Pre] =>
- inv.rewrite(args = args, typeArgs = typeArgs, givenMap = givenMap, yields = yields)
- }
+ implicit class ApplyAnyFunctionBuildHelpers[Pre, Post](
+ apply: AnyFunctionInvocation[Pre]
+ )(implicit rewriter: AbstractRewriter[Pre, Post]) {
+ def rewrite(
+ args: => Seq[Expr[Post]] = apply.args.map(rewriter.dispatch),
+ typeArgs: => Seq[Type[Post]] = apply.typeArgs.map(rewriter.dispatch),
+ givenMap: => Seq[(Ref[Post, Variable[Post]], Expr[Post])] = apply
+ .givenMap.map { case (Ref(v), e) =>
+ (rewriter.succ(v), rewriter.dispatch(e))
+ },
+ yields: Seq[(Expr[Post], Ref[Post, Variable[Post]])] = apply.yields
+ .map { case (a, b) => (rewriter.dispatch(a), rewriter.succ(b.decl)) },
+ ): AnyFunctionInvocation[Post] =
+ apply match {
+ case inv: FunctionInvocation[Pre] =>
+ inv.rewrite(
+ args = args,
+ typeArgs = typeArgs,
+ givenMap = givenMap,
+ yields = yields,
+ )
+ case inv: InstanceFunctionInvocation[Pre] =>
+ inv.rewrite(
+ args = args,
+ typeArgs = typeArgs,
+ givenMap = givenMap,
+ yields = yields,
+ )
+ }
}
- implicit class ApplyAnyMethodBuildHelpers[Pre, Post](apply: AnyMethodInvocation[Pre])(implicit rewriter: AbstractRewriter[Pre, Post]) {
- def rewrite(args: => Seq[Expr[Post]] = apply.args.map(rewriter.dispatch), outArgs: => Seq[Expr[Post]] = apply.outArgs.map(rewriter.dispatch), typeArgs: => Seq[Type[Post]] = apply.typeArgs.map(rewriter.dispatch), givenMap: => Seq[(Ref[Post, Variable[Post]], Expr[Post])] = apply.givenMap.map { case (Ref(v), e) => (rewriter.succ(v), rewriter.dispatch(e)) }, yields: => Seq[(Expr[Post], Ref[Post, Variable[Post]])] = apply.yields.map { case (a, b) => (rewriter.dispatch(a), rewriter.succ(b.decl)) }): AnyMethodInvocation[Post] = apply match {
- case inv: ProcedureInvocation[Pre] =>
- inv.rewrite(args = args, outArgs = outArgs, typeArgs = typeArgs, givenMap = givenMap, yields = yields)
- case inv: MethodInvocation[Pre] =>
- inv.rewrite(args = args, outArgs = outArgs, typeArgs = typeArgs, givenMap = givenMap, yields = yields)
- case inv: ConstructorInvocation[Pre] =>
- inv.rewrite(args = args, outArgs = outArgs, typeArgs = typeArgs, givenMap = givenMap, yields = yields)
- }
+ implicit class ApplyAnyMethodBuildHelpers[Pre, Post](
+ apply: AnyMethodInvocation[Pre]
+ )(implicit rewriter: AbstractRewriter[Pre, Post]) {
+ def rewrite(
+ args: => Seq[Expr[Post]] = apply.args.map(rewriter.dispatch),
+ outArgs: => Seq[Expr[Post]] = apply.outArgs.map(rewriter.dispatch),
+ typeArgs: => Seq[Type[Post]] = apply.typeArgs.map(rewriter.dispatch),
+ givenMap: => Seq[(Ref[Post, Variable[Post]], Expr[Post])] = apply
+ .givenMap.map { case (Ref(v), e) =>
+ (rewriter.succ(v), rewriter.dispatch(e))
+ },
+ yields: => Seq[(Expr[Post], Ref[Post, Variable[Post]])] = apply.yields
+ .map { case (a, b) => (rewriter.dispatch(a), rewriter.succ(b.decl)) },
+ ): AnyMethodInvocation[Post] =
+ apply match {
+ case inv: ProcedureInvocation[Pre] =>
+ inv.rewrite(
+ args = args,
+ outArgs = outArgs,
+ typeArgs = typeArgs,
+ givenMap = givenMap,
+ yields = yields,
+ )
+ case inv: MethodInvocation[Pre] =>
+ inv.rewrite(
+ args = args,
+ outArgs = outArgs,
+ typeArgs = typeArgs,
+ givenMap = givenMap,
+ yields = yields,
+ )
+ case inv: ConstructorInvocation[Pre] =>
+ inv.rewrite(
+ args = args,
+ outArgs = outArgs,
+ typeArgs = typeArgs,
+ givenMap = givenMap,
+ yields = yields,
+ )
+ }
}
- implicit class InvocationStatementBuildHelpers[Pre, Post](apply: InvocationStatement[Pre])(implicit rewriter: AbstractRewriter[Pre, Post]) {
- def rewrite(args: => Seq[Expr[Post]] = apply.args.map(rewriter.dispatch), outArgs: => Seq[Expr[Post]] = apply.outArgs.map(rewriter.dispatch), typeArgs: => Seq[Type[Post]] = apply.typeArgs.map(rewriter.dispatch), givenMap: => Seq[(Ref[Post, Variable[Post]], Expr[Post])] = apply.givenMap.map { case (Ref(v), e) => (rewriter.succ(v), rewriter.dispatch(e)) }, yields: => Seq[(Expr[Post], Ref[Post, Variable[Post]])] = apply.yields.map { case (a, b) => (rewriter.dispatch(a), rewriter.succ(b.decl)) }): InvocationStatement[Post] = apply match {
- case inv: InvokeProcedure[Pre] =>
- inv.rewrite(args = args, outArgs = outArgs, typeArgs = typeArgs, givenMap = givenMap, yields = yields)
- case inv: InvokeMethod[Pre] =>
- inv.rewrite(args = args, outArgs = outArgs, typeArgs = typeArgs, givenMap = givenMap, yields = yields)
- case inv: InvokeConstructor[Pre] =>
- inv.rewrite(args = args, outArgs = outArgs, typeArgs = typeArgs, givenMap = givenMap, yields = yields)
- }
+ implicit class InvocationStatementBuildHelpers[Pre, Post](
+ apply: InvocationStatement[Pre]
+ )(implicit rewriter: AbstractRewriter[Pre, Post]) {
+ def rewrite(
+ args: => Seq[Expr[Post]] = apply.args.map(rewriter.dispatch),
+ outArgs: => Seq[Expr[Post]] = apply.outArgs.map(rewriter.dispatch),
+ typeArgs: => Seq[Type[Post]] = apply.typeArgs.map(rewriter.dispatch),
+ givenMap: => Seq[(Ref[Post, Variable[Post]], Expr[Post])] = apply
+ .givenMap.map { case (Ref(v), e) =>
+ (rewriter.succ(v), rewriter.dispatch(e))
+ },
+ yields: => Seq[(Expr[Post], Ref[Post, Variable[Post]])] = apply.yields
+ .map { case (a, b) => (rewriter.dispatch(a), rewriter.succ(b.decl)) },
+ ): InvocationStatement[Post] =
+ apply match {
+ case inv: InvokeProcedure[Pre] =>
+ inv.rewrite(
+ args = args,
+ outArgs = outArgs,
+ typeArgs = typeArgs,
+ givenMap = givenMap,
+ yields = yields,
+ )
+ case inv: InvokeMethod[Pre] =>
+ inv.rewrite(
+ args = args,
+ outArgs = outArgs,
+ typeArgs = typeArgs,
+ givenMap = givenMap,
+ yields = yields,
+ )
+ case inv: InvokeConstructor[Pre] =>
+ inv.rewrite(
+ args = args,
+ outArgs = outArgs,
+ typeArgs = typeArgs,
+ givenMap = givenMap,
+ yields = yields,
+ )
+ }
}
- private def constOrigin(value: scala.Any): Origin = Origin(Seq(LabelContext(s"constant ${value}")))
+ private def constOrigin(value: scala.Any): Origin =
+ Origin(Seq(LabelContext(s"constant ${value}")))
def tt[G]: BooleanValue[G] = BooleanValue(true)(constOrigin(true))
def ff[G]: BooleanValue[G] = BooleanValue(false)(constOrigin(false))
- def const[G](i: Int)(implicit o: Origin): IntegerValue[G] =
- IntegerValue(i)
+ def const[G](i: Int)(implicit o: Origin): IntegerValue[G] = IntegerValue(i)
- def const[G](i: BigInt)(implicit o: Origin): IntegerValue[G] =
- IntegerValue(i)
+ def const[G](i: BigInt)(implicit o: Origin): IntegerValue[G] = IntegerValue(i)
def c_const[G](i: Int)(implicit o: Origin): CIntegerValue[G] =
CIntegerValue(i)
@@ -274,26 +543,38 @@ object AstBuildHelpers {
def c_const[G](i: BigInt)(implicit o: Origin): CIntegerValue[G] =
CIntegerValue(i)
- def contract[G]
- (blame: Blame[NontrivialUnsatisfiable],
- requires: AccountedPredicate[G] = UnitAccountedPredicate(tt[G])(constOrigin(true)),
- ensures: AccountedPredicate[G] = UnitAccountedPredicate(tt[G])(constOrigin(true)),
- contextEverywhere: Expr[G] = tt[G],
- signals: Seq[SignalsClause[G]] = Nil,
- givenArgs: Seq[Variable[G]] = Nil, yieldsArgs: Seq[Variable[G]] = Nil,
- decreases: Option[DecreasesClause[G]] = None,
- )
- (implicit o: Origin): ApplicableContract[G] =
- ApplicableContract(requires, ensures, contextEverywhere, signals, givenArgs, yieldsArgs, decreases)(blame)
-
- def loopInvariant[G]
- (blame: Blame[LoopInvariantFailure],
- invariant: Expr[G] = null,
- decreases: Option[DecreasesClause[G]] = None)
- (implicit o: Origin): LoopContract[G] =
+ def contract[G](
+ blame: Blame[NontrivialUnsatisfiable],
+ requires: AccountedPredicate[G] =
+ UnitAccountedPredicate(tt[G])(constOrigin(true)),
+ ensures: AccountedPredicate[G] =
+ UnitAccountedPredicate(tt[G])(constOrigin(true)),
+ contextEverywhere: Expr[G] = tt[G],
+ signals: Seq[SignalsClause[G]] = Nil,
+ givenArgs: Seq[Variable[G]] = Nil,
+ yieldsArgs: Seq[Variable[G]] = Nil,
+ decreases: Option[DecreasesClause[G]] = None,
+ )(implicit o: Origin): ApplicableContract[G] =
+ ApplicableContract(
+ requires,
+ ensures,
+ contextEverywhere,
+ signals,
+ givenArgs,
+ yieldsArgs,
+ decreases,
+ )(blame)
+
+ def loopInvariant[G](
+ blame: Blame[LoopInvariantFailure],
+ invariant: Expr[G] = null,
+ decreases: Option[DecreasesClause[G]] = None,
+ )(implicit o: Origin): LoopContract[G] =
LoopInvariant(invariant, decreases)(blame)
- def withResult[G, T <: ContractApplicable[G]](builder: Result[G] => T)(implicit o: Origin): T = {
+ def withResult[G, T <: ContractApplicable[G]](
+ builder: Result[G] => T
+ )(implicit o: Origin): T = {
val box = SuccessionMap[Unit, ContractApplicable[G]]()
val result = Result[G](box.ref(()))
val applicable = builder(result)
@@ -301,141 +582,176 @@ object AstBuildHelpers {
applicable
}
- def procedure[G]
- (blame: Blame[CallableFailure],
- contractBlame: Blame[NontrivialUnsatisfiable],
- returnType: Type[G] = TVoid[G](),
- args: Seq[Variable[G]] = Nil, outArgs: Seq[Variable[G]] = Nil, typeArgs: Seq[Variable[G]] = Nil,
- body: Option[Statement[G]] = None,
- requires: AccountedPredicate[G] = UnitAccountedPredicate(tt[G])(constOrigin(true)),
- ensures: AccountedPredicate[G] = UnitAccountedPredicate(tt[G])(constOrigin(true)),
- contextEverywhere: Expr[G] = tt[G],
- signals: Seq[SignalsClause[G]] = Nil,
- givenArgs: Seq[Variable[G]] = Nil, yieldsArgs: Seq[Variable[G]] = Nil,
- decreases: Option[DecreasesClause[G]] = None,
- inline: Boolean = false, pure: Boolean = false)
- (implicit o: Origin): Procedure[G] =
- new Procedure(returnType, args, outArgs, typeArgs, body,
- ApplicableContract(requires, ensures, contextEverywhere, signals, givenArgs, yieldsArgs, decreases)(contractBlame),
- inline, pure)(blame)
-
- def function[G]
- (blame: Blame[ContractedFailure],
- contractBlame: Blame[NontrivialUnsatisfiable],
- returnType: Type[G] = TVoid(),
- args: Seq[Variable[G]] = Nil, typeArgs: Seq[Variable[G]] = Nil,
- body: Option[Expr[G]] = None,
- requires: AccountedPredicate[G] = UnitAccountedPredicate(tt[G])(constOrigin(true)),
- ensures: AccountedPredicate[G] = UnitAccountedPredicate(tt[G])(constOrigin(true)),
- contextEverywhere: Expr[G] = tt[G],
- signals: Seq[SignalsClause[G]] = Nil,
- givenArgs: Seq[Variable[G]] = Nil, yieldsArgs: Seq[Variable[G]] = Nil,
- decreases: Option[DecreasesClause[G]] = Some(DecreasesClauseNoRecursion[G]()(constOrigin("decreases"))),
- inline: Boolean = false)(implicit o: Origin): Function[G] =
- new Function(returnType, args, typeArgs, body,
- ApplicableContract(requires, ensures, contextEverywhere, signals, givenArgs, yieldsArgs, decreases)(contractBlame),
- inline)(blame)
-
- def functionInvocation[G]
- (blame: Blame[InvocationFailure],
- ref: Ref[G, Function[G]],
- args: Seq[Expr[G]] = Nil,
- typeArgs: Seq[Type[G]] = Nil,
- givenMap: Seq[(Ref[G, Variable[G]], Expr[G])] = Nil,
- yields: Seq[(Expr[G], Ref[G, Variable[G]])] = Nil)(implicit o: Origin): FunctionInvocation[G] =
+ def procedure[G](
+ blame: Blame[CallableFailure],
+ contractBlame: Blame[NontrivialUnsatisfiable],
+ returnType: Type[G] = TVoid[G](),
+ args: Seq[Variable[G]] = Nil,
+ outArgs: Seq[Variable[G]] = Nil,
+ typeArgs: Seq[Variable[G]] = Nil,
+ body: Option[Statement[G]] = None,
+ requires: AccountedPredicate[G] =
+ UnitAccountedPredicate(tt[G])(constOrigin(true)),
+ ensures: AccountedPredicate[G] =
+ UnitAccountedPredicate(tt[G])(constOrigin(true)),
+ contextEverywhere: Expr[G] = tt[G],
+ signals: Seq[SignalsClause[G]] = Nil,
+ givenArgs: Seq[Variable[G]] = Nil,
+ yieldsArgs: Seq[Variable[G]] = Nil,
+ decreases: Option[DecreasesClause[G]] = None,
+ inline: Boolean = false,
+ pure: Boolean = false,
+ )(implicit o: Origin): Procedure[G] =
+ new Procedure(
+ returnType,
+ args,
+ outArgs,
+ typeArgs,
+ body,
+ ApplicableContract(
+ requires,
+ ensures,
+ contextEverywhere,
+ signals,
+ givenArgs,
+ yieldsArgs,
+ decreases,
+ )(contractBlame),
+ inline,
+ pure,
+ )(blame)
+
+ def function[G](
+ blame: Blame[ContractedFailure],
+ contractBlame: Blame[NontrivialUnsatisfiable],
+ returnType: Type[G] = TVoid(),
+ args: Seq[Variable[G]] = Nil,
+ typeArgs: Seq[Variable[G]] = Nil,
+ body: Option[Expr[G]] = None,
+ requires: AccountedPredicate[G] =
+ UnitAccountedPredicate(tt[G])(constOrigin(true)),
+ ensures: AccountedPredicate[G] =
+ UnitAccountedPredicate(tt[G])(constOrigin(true)),
+ contextEverywhere: Expr[G] = tt[G],
+ signals: Seq[SignalsClause[G]] = Nil,
+ givenArgs: Seq[Variable[G]] = Nil,
+ yieldsArgs: Seq[Variable[G]] = Nil,
+ decreases: Option[DecreasesClause[G]] = Some(
+ DecreasesClauseNoRecursion[G]()(constOrigin("decreases"))
+ ),
+ inline: Boolean = false,
+ )(implicit o: Origin): Function[G] =
+ new Function(
+ returnType,
+ args,
+ typeArgs,
+ body,
+ ApplicableContract(
+ requires,
+ ensures,
+ contextEverywhere,
+ signals,
+ givenArgs,
+ yieldsArgs,
+ decreases,
+ )(contractBlame),
+ inline,
+ )(blame)
+
+ def functionInvocation[G](
+ blame: Blame[InvocationFailure],
+ ref: Ref[G, Function[G]],
+ args: Seq[Expr[G]] = Nil,
+ typeArgs: Seq[Type[G]] = Nil,
+ givenMap: Seq[(Ref[G, Variable[G]], Expr[G])] = Nil,
+ yields: Seq[(Expr[G], Ref[G, Variable[G]])] = Nil,
+ )(implicit o: Origin): FunctionInvocation[G] =
FunctionInvocation(ref, args, typeArgs, givenMap, yields)(blame)
- def methodInvocation[G]
- (blame: Blame[InstanceInvocationFailure],
- obj: Expr[G],
- ref: Ref[G, InstanceMethod[G]],
- args: Seq[Expr[G]] = Nil,
- outArgs: Seq[Expr[G]] = Nil,
- typeArgs: Seq[Type[G]] = Nil,
- givenMap: Seq[(Ref[G, Variable[G]], Expr[G])] = Nil,
- yields: Seq[(Expr[G], Ref[G, Variable[G]])] = Nil)(implicit o: Origin): MethodInvocation[G] =
+ def methodInvocation[G](
+ blame: Blame[InstanceInvocationFailure],
+ obj: Expr[G],
+ ref: Ref[G, InstanceMethod[G]],
+ args: Seq[Expr[G]] = Nil,
+ outArgs: Seq[Expr[G]] = Nil,
+ typeArgs: Seq[Type[G]] = Nil,
+ givenMap: Seq[(Ref[G, Variable[G]], Expr[G])] = Nil,
+ yields: Seq[(Expr[G], Ref[G, Variable[G]])] = Nil,
+ )(implicit o: Origin): MethodInvocation[G] =
MethodInvocation(obj, ref, args, outArgs, typeArgs, givenMap, yields)(blame)
- def procedureInvocation[G]
- (blame: Blame[InvocationFailure],
- ref: Ref[G, Procedure[G]],
- args: Seq[Expr[G]] = Nil,
- outArgs: Seq[Expr[G]] = Nil,
- typeArgs: Seq[Type[G]] = Nil,
- givenMap: Seq[(Ref[G, Variable[G]], Expr[G])] = Nil,
- yields: Seq[(Expr[G], Ref[G, Variable[G]])] = Nil)(implicit o: Origin): ProcedureInvocation[G] =
+ def procedureInvocation[G](
+ blame: Blame[InvocationFailure],
+ ref: Ref[G, Procedure[G]],
+ args: Seq[Expr[G]] = Nil,
+ outArgs: Seq[Expr[G]] = Nil,
+ typeArgs: Seq[Type[G]] = Nil,
+ givenMap: Seq[(Ref[G, Variable[G]], Expr[G])] = Nil,
+ yields: Seq[(Expr[G], Ref[G, Variable[G]])] = Nil,
+ )(implicit o: Origin): ProcedureInvocation[G] =
ProcedureInvocation(ref, args, outArgs, typeArgs, givenMap, yields)(blame)
- def constructorInvocation[G]
- (blame: Blame[InvocationFailure],
- ref: Ref[G, Constructor[G]],
- classTypeArgs: Seq[Type[G]] = Nil,
- args: Seq[Expr[G]] = Nil,
- outArgs: Seq[Expr[G]] = Nil,
- typeArgs: Seq[Type[G]] = Nil,
- givenMap: Seq[(Ref[G, Variable[G]], Expr[G])] = Nil,
- yields: Seq[(Expr[G], Ref[G, Variable[G]])] = Nil)(implicit o: Origin): ConstructorInvocation[G] =
- ConstructorInvocation(ref, classTypeArgs, args, outArgs, typeArgs, givenMap, yields)(blame)
-
- private def GeneratedQuantifier: Origin = Origin(
- Seq(
- PreferredName(Seq("i")),
- LabelContext("generated quantifier"),
- )
- )
-
- def starall[G]
- (blame: Blame[ReceiverNotInjective],
- t: Type[G],
- body: Local[G] => Expr[G],
- triggers: Local[G] => Seq[Seq[Expr[G]]] = (_: Local[G]) => Nil,
- ): Starall[G] = {
+ def constructorInvocation[G](
+ blame: Blame[InvocationFailure],
+ ref: Ref[G, Constructor[G]],
+ classTypeArgs: Seq[Type[G]] = Nil,
+ args: Seq[Expr[G]] = Nil,
+ outArgs: Seq[Expr[G]] = Nil,
+ typeArgs: Seq[Type[G]] = Nil,
+ givenMap: Seq[(Ref[G, Variable[G]], Expr[G])] = Nil,
+ yields: Seq[(Expr[G], Ref[G, Variable[G]])] = Nil,
+ )(implicit o: Origin): ConstructorInvocation[G] =
+ ConstructorInvocation(
+ ref,
+ classTypeArgs,
+ args,
+ outArgs,
+ typeArgs,
+ givenMap,
+ yields,
+ )(blame)
+
+ private def GeneratedQuantifier: Origin =
+ Origin(Seq(PreferredName(Seq("i")), LabelContext("generated quantifier")))
+
+ def starall[G](
+ blame: Blame[ReceiverNotInjective],
+ t: Type[G],
+ body: Local[G] => Expr[G],
+ triggers: Local[G] => Seq[Seq[Expr[G]]] = (_: Local[G]) => Nil,
+ ): Starall[G] = {
implicit val o: Origin = GeneratedQuantifier
val i_var = new Variable[G](t)
val i = Local[G](i_var.ref)
- Starall(
- bindings = Seq(i_var),
- triggers = triggers(i),
- body = body(i),
- )(blame)
+ Starall(bindings = Seq(i_var), triggers = triggers(i), body = body(i))(
+ blame
+ )
}
- def forall[G]
- (t: Type[G],
- body: Local[G] => Expr[G],
- triggers: Local[G] => Seq[Seq[Expr[G]]] = (_: Local[G]) => Nil,
- ): Forall[G] = {
+ def forall[G](
+ t: Type[G],
+ body: Local[G] => Expr[G],
+ triggers: Local[G] => Seq[Seq[Expr[G]]] = (_: Local[G]) => Nil,
+ ): Forall[G] = {
implicit val o: Origin = GeneratedQuantifier
val i_var = new Variable[G](t)
val i = Local[G](i_var.ref)
- Forall(
- bindings = Seq(i_var),
- triggers = triggers(i),
- body = body(i),
- )
+ Forall(bindings = Seq(i_var), triggers = triggers(i), body = body(i))
}
- def foralls[G]
- (ts: Seq[Type[G]],
- body: Seq[Local[G]] => Expr[G],
- triggers: Seq[Local[G]] => Seq[Seq[Expr[G]]] = (_: Seq[Local[G]]) => Nil,
- ): Forall[G] = {
+ def foralls[G](
+ ts: Seq[Type[G]],
+ body: Seq[Local[G]] => Expr[G],
+ triggers: Seq[Local[G]] => Seq[Seq[Expr[G]]] = (_: Seq[Local[G]]) => Nil,
+ ): Forall[G] = {
implicit val o: Origin = GeneratedQuantifier
val i_vars: Seq[Variable[G]] = ts.map(new Variable[G](_))
val is: Seq[Local[G]] = i_vars.map((x: Variable[G]) => Local[G](x.ref))
- Forall(
- bindings = i_vars,
- triggers = triggers(is),
- body = body(is),
- )
+ Forall(bindings = i_vars, triggers = triggers(is), body = body(is))
}
- private def GeneratedLet: Origin = Origin(
- Seq(
- PreferredName(Seq("x")),
- LabelContext("generated let"),
- )
- )
+ private def GeneratedLet: Origin =
+ Origin(Seq(PreferredName(Seq("x")), LabelContext("generated let")))
def let[G](t: Type[G], x: Expr[G], body: Local[G] => Expr[G]): Let[G] = {
implicit val o: Origin = GeneratedQuantifier
@@ -444,69 +760,113 @@ object AstBuildHelpers {
Let(x_var, x, body(x_local))
}
- def assignLocal[G](local: Local[G], value: Expr[G])(implicit o: Origin): Assign[G] =
- Assign(local, value)(AssignLocalOk)
+ def assignLocal[G](local: Local[G], value: Expr[G])(
+ implicit o: Origin
+ ): Assign[G] = Assign(local, value)(AssignLocalOk)
- def assignField[G](obj: Expr[G], field: Ref[G, InstanceField[G]], value: Expr[G], blame: Blame[AssignFailed])(implicit o: Origin): Assign[G] =
+ def assignField[G](
+ obj: Expr[G],
+ field: Ref[G, InstanceField[G]],
+ value: Expr[G],
+ blame: Blame[AssignFailed],
+ )(implicit o: Origin): Assign[G] =
Assign(Deref(obj, field)(DerefAssignTarget), value)(blame)
- def fieldPerm[G](obj: Expr[G], field: Ref[G, InstanceField[G]], amount: Expr[G])(implicit o: Origin): Perm[G] =
- Perm(FieldLocation(obj, field), amount)
-
- def arrayPerm[G](arr: Expr[G], index: Expr[G], amount: Expr[G], arrayLocationError: Blame[ArrayLocationError])(implicit o: Origin): Perm[G] =
+ def fieldPerm[G](
+ obj: Expr[G],
+ field: Ref[G, InstanceField[G]],
+ amount: Expr[G],
+ )(implicit o: Origin): Perm[G] = Perm(FieldLocation(obj, field), amount)
+
+ def arrayPerm[G](
+ arr: Expr[G],
+ index: Expr[G],
+ amount: Expr[G],
+ arrayLocationError: Blame[ArrayLocationError],
+ )(implicit o: Origin): Perm[G] =
Perm(ArrayLocation(arr, index)(arrayLocationError), amount)
def foldAnd[G](exprs: Iterable[Expr[G]])(implicit o: Origin): Expr[G] =
exprs.reduceOption(And(_, _)).getOrElse(tt)
- def implies[G](conds: Seq[Expr[G]], body: Expr[G])(implicit o: Origin): Expr[G] = conds match {
- case Nil => body
- case conds => Implies(foldAnd(conds), body)
- }
+ def implies[G](conds: Seq[Expr[G]], body: Expr[G])(
+ implicit o: Origin
+ ): Expr[G] =
+ conds match {
+ case Nil => body
+ case conds => Implies(foldAnd(conds), body)
+ }
- def unfoldPredicate[G](p: AccountedPredicate[G]): Seq[Expr[G]] = p match {
- case UnitAccountedPredicate(pred) => Seq(pred)
- case SplitAccountedPredicate(left, right) => unfoldPredicate(left) ++ unfoldPredicate(right)
- }
+ def unfoldPredicate[G](p: AccountedPredicate[G]): Seq[Expr[G]] =
+ p match {
+ case UnitAccountedPredicate(pred) => Seq(pred)
+ case SplitAccountedPredicate(left, right) =>
+ unfoldPredicate(left) ++ unfoldPredicate(right)
+ }
- def mapPredicate[G1, G2](p: AccountedPredicate[G1], f: Expr[G1] => Expr[G2]): AccountedPredicate[G2] = p match {
- case UnitAccountedPredicate(pred) => UnitAccountedPredicate(f(pred))(p.o)
- case SplitAccountedPredicate(left, right) => SplitAccountedPredicate(mapPredicate(left, f), mapPredicate(right, f))(p.o)
- }
+ def mapPredicate[G1, G2](
+ p: AccountedPredicate[G1],
+ f: Expr[G1] => Expr[G2],
+ ): AccountedPredicate[G2] =
+ p match {
+ case UnitAccountedPredicate(pred) => UnitAccountedPredicate(f(pred))(p.o)
+ case SplitAccountedPredicate(left, right) =>
+ SplitAccountedPredicate(mapPredicate(left, f), mapPredicate(right, f))(
+ p.o
+ )
+ }
- def unfoldImplies[G](expr: Expr[G]): (Seq[Expr[G]], Expr[G]) = expr match {
- case Implies(left, right) =>
- val (antecedent, consequent) = AstBuildHelpers.unfoldImplies(right)
- (unfoldStar(left) ++ antecedent, consequent)
- case other => (Nil, other)
- }
+ def unfoldImplies[G](expr: Expr[G]): (Seq[Expr[G]], Expr[G]) =
+ expr match {
+ case Implies(left, right) =>
+ val (antecedent, consequent) = AstBuildHelpers.unfoldImplies(right)
+ (unfoldStar(left) ++ antecedent, consequent)
+ case other => (Nil, other)
+ }
- def unfoldStar[G](expr: Expr[G]): Seq[Expr[G]] = expr match {
- case Star(left, right) => AstBuildHelpers.unfoldStar(left) ++ AstBuildHelpers.unfoldStar(right)
- case And(left, right) => AstBuildHelpers.unfoldStar(left) ++ AstBuildHelpers.unfoldStar(right)
- case BooleanValue(true) => Nil
- case other => Seq(other)
- }
+ def unfoldStar[G](expr: Expr[G]): Seq[Expr[G]] =
+ expr match {
+ case Star(left, right) =>
+ AstBuildHelpers.unfoldStar(left) ++ AstBuildHelpers.unfoldStar(right)
+ case And(left, right) =>
+ AstBuildHelpers.unfoldStar(left) ++ AstBuildHelpers.unfoldStar(right)
+ case BooleanValue(true) => Nil
+ case other => Seq(other)
+ }
// For if you want to be fussy about origins
- def mapUnfoldedStar[G1, G2](expr: Expr[G1], f: Expr[G1] => Expr[G2]): Expr[G2] = expr match {
- case Star(left, right) => Star(mapUnfoldedStar(left, f), mapUnfoldedStar(right, f))(expr.o)
- case And(left, right) => And(mapUnfoldedStar(left, f), mapUnfoldedStar(right, f))(expr.o)
- case other => f(other)
- }
+ def mapUnfoldedStar[G1, G2](
+ expr: Expr[G1],
+ f: Expr[G1] => Expr[G2],
+ ): Expr[G2] =
+ expr match {
+ case Star(left, right) =>
+ Star(mapUnfoldedStar(left, f), mapUnfoldedStar(right, f))(expr.o)
+ case And(left, right) =>
+ And(mapUnfoldedStar(left, f), mapUnfoldedStar(right, f))(expr.o)
+ case other => f(other)
+ }
def foldStar[G](exprs: Seq[Expr[G]])(implicit o: Origin): Expr[G] =
exprs.reduceOption(Star(_, _)).getOrElse(tt)
- def foldStar[G](predicate: AccountedPredicate[G])(implicit o: Origin): Expr[G] = predicate match {
- case UnitAccountedPredicate(pred) => pred
- case SplitAccountedPredicate(left, right) => Star(foldStar(left), foldStar(right))
- }
+ def foldStar[G](
+ predicate: AccountedPredicate[G]
+ )(implicit o: Origin): Expr[G] =
+ predicate match {
+ case UnitAccountedPredicate(pred) => pred
+ case SplitAccountedPredicate(left, right) =>
+ Star(foldStar(left), foldStar(right))
+ }
- def foldPredicate[G](exprs: Seq[Expr[G]])(implicit o: Origin): AccountedPredicate[G] = exprs match {
- case x :: Seq() => UnitAccountedPredicate(x)
- case x :: xs => SplitAccountedPredicate(UnitAccountedPredicate(x), foldPredicate(xs))
- }
+ def foldPredicate[G](
+ exprs: Seq[Expr[G]]
+ )(implicit o: Origin): AccountedPredicate[G] =
+ exprs match {
+ case x :: Seq() => UnitAccountedPredicate(x)
+ case x :: xs =>
+ SplitAccountedPredicate(UnitAccountedPredicate(x), foldPredicate(xs))
+ }
def foldOr[G](exprs: Seq[Expr[G]])(implicit o: Origin): Expr[G] =
exprs.reduceOption(Or(_, _)).getOrElse(ff)
@@ -514,17 +874,19 @@ object AstBuildHelpers {
def foldAnd[G](exprs: Seq[Expr[G]])(implicit o: Origin): Expr[G] =
exprs.reduceOption(And(_, _)).getOrElse(tt)
- def loop[G](cond: Expr[G],
- body: Statement[G],
- init: Statement[G] = null,
- update: Statement[G] = null,
- contract: LoopContract[G] = null
- )(implicit o: Origin): Loop[G] =
+ def loop[G](
+ cond: Expr[G],
+ body: Statement[G],
+ init: Statement[G] = null,
+ update: Statement[G] = null,
+ contract: LoopContract[G] = null,
+ )(implicit o: Origin): Loop[G] =
Loop(
init = Option(init).getOrElse(Block(Seq())),
- contract = Option(contract).getOrElse(loopInvariant(blame = PanicBlame("Trivial contract"))),
+ contract = Option(contract)
+ .getOrElse(loopInvariant(blame = PanicBlame("Trivial contract"))),
cond = cond,
body = body,
- update = Option(update).getOrElse(Block(Seq()))
+ update = Option(update).getOrElse(Block(Seq())),
)
}
diff --git a/src/col/vct/col/util/ConstructingSuccessorOfContext.scala b/src/col/vct/col/util/ConstructingSuccessorOfContext.scala
index 31c07f0c3d..1ff67bd63f 100644
--- a/src/col/vct/col/util/ConstructingSuccessorOfContext.scala
+++ b/src/col/vct/col/util/ConstructingSuccessorOfContext.scala
@@ -4,8 +4,12 @@ import vct.col.ast.Declaration
import vct.col.print.Doc
import vct.result.{Message, VerificationError}
-case class ConstructingSuccessorOfContext(decl: Declaration[_]) extends VerificationError.Context {
- override def tryMessageContext(message: String, err: VerificationError): Option[String] =
+case class ConstructingSuccessorOfContext(decl: Declaration[_])
+ extends VerificationError.Context {
+ override def tryMessageContext(
+ message: String,
+ err: VerificationError,
+ ): Option[String] =
err.context[CurrentRewriteProgramContext].map { ctx =>
ctx.program.highlight(decl).messageInContext(message)
}
diff --git a/src/col/vct/col/util/CurrentCheckNodeContext.scala b/src/col/vct/col/util/CurrentCheckNodeContext.scala
index 12dad08564..016d34839b 100644
--- a/src/col/vct/col/util/CurrentCheckNodeContext.scala
+++ b/src/col/vct/col/util/CurrentCheckNodeContext.scala
@@ -4,8 +4,12 @@ import vct.col.ast.Node
import vct.col.print.Doc
import vct.result.VerificationError
-case class CurrentCheckNodeContext(node: Node[_]) extends VerificationError.Context {
- override def tryMessageContext(message: String, err: VerificationError): Option[String] =
+case class CurrentCheckNodeContext(node: Node[_])
+ extends VerificationError.Context {
+ override def tryMessageContext(
+ message: String,
+ err: VerificationError,
+ ): Option[String] =
err.context[CurrentCheckProgramContext].map { ctx =>
ctx.program.highlight(node).messageInContext(message)
}
diff --git a/src/col/vct/col/util/CurrentCheckProgramContext.scala b/src/col/vct/col/util/CurrentCheckProgramContext.scala
index 6b7844d581..169441c425 100644
--- a/src/col/vct/col/util/CurrentCheckProgramContext.scala
+++ b/src/col/vct/col/util/CurrentCheckProgramContext.scala
@@ -4,4 +4,5 @@ import vct.col.ast.Program
import vct.col.print.Doc
import vct.result.VerificationError
-case class CurrentCheckProgramContext(program: Program[_]) extends CurrentProgramContext
\ No newline at end of file
+case class CurrentCheckProgramContext(program: Program[_])
+ extends CurrentProgramContext
diff --git a/src/col/vct/col/util/CurrentRewriteNodeContext.scala b/src/col/vct/col/util/CurrentRewriteNodeContext.scala
index 9aff76973c..95620f80c5 100644
--- a/src/col/vct/col/util/CurrentRewriteNodeContext.scala
+++ b/src/col/vct/col/util/CurrentRewriteNodeContext.scala
@@ -4,8 +4,12 @@ import vct.col.ast.Node
import vct.col.print.Doc
import vct.result.VerificationError
-case class CurrentRewriteNodeContext(node: Node[_]) extends VerificationError.Context {
- override def tryMessageContext(message: String, err: VerificationError): Option[String] =
+case class CurrentRewriteNodeContext(node: Node[_])
+ extends VerificationError.Context {
+ override def tryMessageContext(
+ message: String,
+ err: VerificationError,
+ ): Option[String] =
err.context[CurrentRewriteProgramContext].map { ctx =>
ctx.program.highlight(node).messageInContext(message)
}
diff --git a/src/col/vct/col/util/CurrentRewriteProgramContext.scala b/src/col/vct/col/util/CurrentRewriteProgramContext.scala
index d529e68400..1e8a3f7d07 100644
--- a/src/col/vct/col/util/CurrentRewriteProgramContext.scala
+++ b/src/col/vct/col/util/CurrentRewriteProgramContext.scala
@@ -4,4 +4,5 @@ import vct.col.ast.Program
import vct.col.print.Doc
import vct.result.VerificationError
-case class CurrentRewriteProgramContext(program: Program[_]) extends CurrentProgramContext
\ No newline at end of file
+case class CurrentRewriteProgramContext(program: Program[_])
+ extends CurrentProgramContext
diff --git a/src/col/vct/col/util/DeclarationBox.scala b/src/col/vct/col/util/DeclarationBox.scala
index b4b1ff81ef..59c7e64e7b 100644
--- a/src/col/vct/col/util/DeclarationBox.scala
+++ b/src/col/vct/col/util/DeclarationBox.scala
@@ -5,7 +5,9 @@ import vct.col.ref.{LazyRef, Ref}
import scala.reflect.ClassTag
-case class DeclarationBox[G, Decl <: Declaration[G]]()(implicit tag: ClassTag[Decl]) {
+case class DeclarationBox[G, Decl <: Declaration[G]]()(
+ implicit tag: ClassTag[Decl]
+) {
private var decl: Option[Decl] = None
def ref: Ref[G, Decl] = new LazyRef(decl.get)
diff --git a/src/col/vct/col/util/EqualityMeasure.scala b/src/col/vct/col/util/EqualityMeasure.scala
index ca7095b645..29628720d6 100644
--- a/src/col/vct/col/util/EqualityMeasure.scala
+++ b/src/col/vct/col/util/EqualityMeasure.scala
@@ -2,20 +2,26 @@ package vct.col.util
import vct.col.ast.Declaration
-case class EqualityMeasure[Pre, Post, PreDecl <: Declaration[Pre], PostDecl <: Declaration[Post]](scopes: FrozenScopes[Pre, Post, PreDecl, PostDecl], decl: PreDecl) {
- override def equals(obj: Any): Boolean = obj match {
- case other: EqualityMeasure[Pre, Post, PreDecl, PostDecl] =>
- decl == other.decl &&
+case class EqualityMeasure[Pre, Post, PreDecl <: Declaration[
+ Pre
+], PostDecl <: Declaration[Post]](
+ scopes: FrozenScopes[Pre, Post, PreDecl, PostDecl],
+ decl: PreDecl,
+) {
+ override def equals(obj: Any): Boolean =
+ obj match {
+ case other: EqualityMeasure[Pre, Post, PreDecl, PostDecl] =>
+ decl == other.decl &&
// Assumption: the pre-declaration must occur in one of the maps for both frozenscopes, we don't care about
// the equality value if they don't end up there (since that's a bug).
// We can ignore identical maps in the tails, since whether the declaration is in there does not matter
// Non-identical maps in the init must not contain the pre-declaration, since the successor will not be visible
// to the other frozen scope stack, and hence the post-declaration cannot be equal.
- scopes.scopes.reverse.zip(other.scopes.scopes.reverse).dropWhile { case (l, r) => l == r }.forall {
- case (l, r) => !l.contains(decl) && !r.contains(decl)
- }
- case _ => false
- }
+ scopes.scopes.reverse.zip(other.scopes.scopes.reverse).dropWhile {
+ case (l, r) => l == r
+ }.forall { case (l, r) => !l.contains(decl) && !r.contains(decl) }
+ case _ => false
+ }
override def hashCode(): Int = 0
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/util/FrozenScopes.scala b/src/col/vct/col/util/FrozenScopes.scala
index 8f99752558..962b19e523 100644
--- a/src/col/vct/col/util/FrozenScopes.scala
+++ b/src/col/vct/col/util/FrozenScopes.scala
@@ -9,22 +9,33 @@ import vct.result.VerificationError
import scala.collection.mutable
import scala.reflect.ClassTag
-/**
- * When constructing a lazy reference, it is important that the stack of scopes is recorded *before* we enter a lazy
- * context. For example, this is wrong:
- *
- * new LazyRef(successors.toSeq.collectFirst(_(decl)).get)
- *
- * since everything between the LazyRef parentheses is evaluated lazily, and only the value of successors is captured
- * in the closure.
- */
-class FrozenScopes[Pre, Post, PreDecl <: Declaration[Pre], PostDecl <: Declaration[Post]](val scopes: Seq[mutable.Map[PreDecl, PostDecl]]) extends SuccessorProvider[Pre, Post, PreDecl, PostDecl] {
- override def computeSucc(decl: PreDecl): Option[PostDecl] = scopes.collectFirst { case m if m.contains(decl) => m(decl) }
+/** When constructing a lazy reference, it is important that the stack of scopes
+ * is recorded *before* we enter a lazy context. For example, this is wrong:
+ *
+ * new LazyRef(successors.toSeq.collectFirst(_(decl)).get)
+ *
+ * since everything between the LazyRef parentheses is evaluated lazily, and
+ * only the value of successors is captured in the closure.
+ */
+class FrozenScopes[Pre, Post, PreDecl <: Declaration[
+ Pre
+], PostDecl <: Declaration[Post]](
+ val scopes: Seq[mutable.Map[PreDecl, PostDecl]]
+) extends SuccessorProvider[Pre, Post, PreDecl, PostDecl] {
+ override def computeSucc(decl: PreDecl): Option[PostDecl] =
+ scopes.collectFirst { case m if m.contains(decl) => m(decl) }
- override def succ[RefDecl <: Declaration[Post]](decl: PreDecl)(implicit tag: ClassTag[RefDecl]): Ref[Post, RefDecl] =
+ override def succ[RefDecl <: Declaration[Post]](
+ decl: PreDecl
+ )(implicit tag: ClassTag[RefDecl]): Ref[Post, RefDecl] =
VerificationError.withContext(ConstructingSuccessorOfContext(decl)) {
TimeTravel.cause { causeIdx =>
- new LazyRef(computeSucc(decl).getOrElse(TimeTravel.badEffect(causeIdx, throw Scopes.NoSuccessor(decl))), Some(EqualityMeasure(this, decl)))
+ new LazyRef(
+ computeSucc(decl).getOrElse(
+ TimeTravel.badEffect(causeIdx, throw Scopes.NoSuccessor(decl))
+ ),
+ Some(EqualityMeasure(this, decl)),
+ )
}
}
-}
\ No newline at end of file
+}
diff --git a/src/col/vct/col/util/Scopes.scala b/src/col/vct/col/util/Scopes.scala
index fb06620546..80a9bcf968 100644
--- a/src/col/vct/col/util/Scopes.scala
+++ b/src/col/vct/col/util/Scopes.scala
@@ -13,21 +13,33 @@ import scala.reflect.ClassTag
import scala.util.Try
object Scopes {
- case class WrongDeclarationCount(kind: ClassTag[_], count: Int) extends SystemError {
+ case class WrongDeclarationCount(kind: ClassTag[_], count: Int)
+ extends SystemError {
override def text: String =
- messageContext(s"Expected exactly one declaration of kind ${kind.runtimeClass.getSimpleName}, but got $count.")
+ messageContext(
+ s"Expected exactly one declaration of kind ${kind.runtimeClass.getSimpleName}, but got $count."
+ )
}
case class NoScope(kind: ClassTag[_]) extends SystemError {
override def text: String =
- messageContext(s"There is no scope to place a declaration of kind ${kind.runtimeClass.getSimpleName} in.")
+ messageContext(
+ s"There is no scope to place a declaration of kind ${kind.runtimeClass.getSimpleName} in."
+ )
}
- case class DuplicateSuccessor(pre: Declaration[_], firstPost: Declaration[_], secondPost: Declaration[_]) extends SystemError {
+ case class DuplicateSuccessor(
+ pre: Declaration[_],
+ firstPost: Declaration[_],
+ secondPost: Declaration[_],
+ ) extends SystemError {
override def text: String =
Message.messagesInContext(
- firstPost.highlight(firstPost) -> "This declaration already succeeds ...",
- context[CurrentProgramContext].map(_.program).getOrElse(pre).highlight(pre) -> "... this declaration, but is additionally succeeded by ...",
+ firstPost.highlight(firstPost) ->
+ "This declaration already succeeds ...",
+ context[CurrentProgramContext].map(_.program).getOrElse(pre)
+ .highlight(pre) ->
+ "... this declaration, but is additionally succeeded by ...",
secondPost.highlight(secondPost) -> "... this declaration.",
)
}
@@ -40,24 +52,36 @@ object Scopes {
val predProgram = getContext[CurrentRewriteProgramContext].program
val predDecl = getContext[ConstructingSuccessorOfContext].decl
Message.messagesInContext(
- (predProgram.highlight(predDecl), "A reference to the successor of this declaration was made, ..."),
- (useProgram.highlight(useNode), "... but it has no successor in this position.")
+ (
+ predProgram.highlight(predDecl),
+ "A reference to the successor of this declaration was made, ...",
+ ),
+ (
+ useProgram.highlight(useNode),
+ "... but it has no successor in this position.",
+ ),
)
} getOrElse {
- pre.o.messageInContext("A reference to the successor of this declaration was made, but it has no successor.")
+ pre.o.messageInContext(
+ "A reference to the successor of this declaration was made, but it has no successor."
+ )
}
}
}
}
-case class Scopes[Pre, Post, PreDecl <: Declaration[Pre], PostDecl <: Declaration[Post]]()(implicit tag: ClassTag[PostDecl]) {
- private val successors: ScopedStack[mutable.Map[PreDecl, PostDecl]] = ScopedStack()
- private val collectionBuffer: ScopedStack[mutable.ArrayBuffer[PostDecl]] = ScopedStack()
+case class Scopes[Pre, Post, PreDecl <: Declaration[
+ Pre
+], PostDecl <: Declaration[Post]]()(implicit tag: ClassTag[PostDecl]) {
+ private val successors: ScopedStack[mutable.Map[PreDecl, PostDecl]] =
+ ScopedStack()
+ private val collectionBuffer: ScopedStack[mutable.ArrayBuffer[PostDecl]] =
+ ScopedStack()
- def freeze: FrozenScopes[Pre, Post, PreDecl, PostDecl] = new FrozenScopes(successors.toSeq)
+ def freeze: FrozenScopes[Pre, Post, PreDecl, PostDecl] =
+ new FrozenScopes(successors.toSeq)
- def scope[T](f: => T): T =
- successors.having(mutable.Map())(f)
+ def scope[T](f: => T): T = successors.having(mutable.Map())(f)
def isEmpty: Boolean = collectionBuffer.isEmpty
def nonEmpty: Boolean = !isEmpty
@@ -70,8 +94,7 @@ case class Scopes[Pre, Post, PreDecl <: Declaration[Pre], PostDecl <: Declaratio
(buffer.toSeq, result)
}
- def collectScoped[T](f: => T): (Seq[PostDecl], T) =
- scope { collect(f) }
+ def collectScoped[T](f: => T): (Seq[PostDecl], T) = scope { collect(f) }
def declare[T <: PostDecl](decl: T): T = {
collectionBuffer.topOption match {
@@ -80,19 +103,25 @@ case class Scopes[Pre, Post, PreDecl <: Declaration[Pre], PostDecl <: Declaratio
}
}
- def succeedOnly[T <: PostDecl](pre: PreDecl, post: T)(implicit tag: ClassTag[T]): T =
+ def succeedOnly[T <: PostDecl](pre: PreDecl, post: T)(
+ implicit tag: ClassTag[T]
+ ): T =
successors.topOption match {
case Some(map) if !map.contains(pre) => map(pre) = post; post
case Some(map) => throw DuplicateSuccessor(pre, map(pre), post)
case None => throw NoScope(tag)
}
- def succeed[T <: PostDecl](pre: PreDecl, post: T)(implicit tag: ClassTag[T]): T = {
+ def succeed[T <: PostDecl](pre: PreDecl, post: T)(
+ implicit tag: ClassTag[T]
+ ): T = {
declare(post)
succeedOnly(pre, post)
}
- def dispatch(decl: PreDecl)(implicit rw: AbstractRewriter[Pre, Post]): PostDecl = {
+ def dispatch(
+ decl: PreDecl
+ )(implicit rw: AbstractRewriter[Pre, Post]): PostDecl = {
val result = collect { rw.dispatch(decl.asInstanceOf[Declaration[Pre]]) }
result._1 match {
case Seq(decl) => decl
@@ -100,9 +129,17 @@ case class Scopes[Pre, Post, PreDecl <: Declaration[Pre], PostDecl <: Declaratio
}
}
- def dispatch(decls: Iterable[PreDecl])(implicit rw: AbstractRewriter[Pre, Post]): Seq[PostDecl] =
- collect { decls.foreach((decl: PreDecl) => rw.dispatch(decl.asInstanceOf[Declaration[Pre]])) }._1
+ def dispatch(
+ decls: Iterable[PreDecl]
+ )(implicit rw: AbstractRewriter[Pre, Post]): Seq[PostDecl] =
+ collect {
+ decls.foreach((decl: PreDecl) =>
+ rw.dispatch(decl.asInstanceOf[Declaration[Pre]])
+ )
+ }._1
- def dispatch[PreRefDecl <: PreDecl, PostRefDecl <: PostDecl](ref: Ref[Pre, PreRefDecl])(implicit tag: ClassTag[PostRefDecl]): Ref[Post, PostRefDecl] =
+ def dispatch[PreRefDecl <: PreDecl, PostRefDecl <: PostDecl](
+ ref: Ref[Pre, PreRefDecl]
+ )(implicit tag: ClassTag[PostRefDecl]): Ref[Post, PostRefDecl] =
freeze.succ(ref.decl)
}
diff --git a/src/col/vct/col/util/Substitute.scala b/src/col/vct/col/util/Substitute.scala
index 43ce32e24a..9f54a1e9da 100644
--- a/src/col/vct/col/util/Substitute.scala
+++ b/src/col/vct/col/util/Substitute.scala
@@ -4,36 +4,44 @@ import vct.col.ast._
import vct.col.origin.Origin
import vct.col.rewrite.NonLatchingRewriter
-/**
- * Apply a substitution map to expressions
- */
-case class Substitute[G](subs: Map[Expr[G], Expr[G]],
- typeSubs: Map[TVar[G], Type[G]] = Map.empty[TVar[G], Type[G]],
- bindingSubs: Map[Variable[G], Variable[G]] = Map.empty[Variable[G], Variable[G]],
- originTrafo: Origin => Origin = identity)
- extends NonLatchingRewriter[G, G] {
-
- case class SuccOrIdentity() extends SuccessorsProviderTrafo[G, G](allScopes.freeze) {
- override def postTransform[T <: Declaration[G]](pre: Declaration[G], post: Option[T]): Option[T] =
- Some(post.getOrElse(pre.asInstanceOf[T]))
+/** Apply a substitution map to expressions
+ */
+case class Substitute[G](
+ subs: Map[Expr[G], Expr[G]],
+ typeSubs: Map[TVar[G], Type[G]] = Map.empty[TVar[G], Type[G]],
+ bindingSubs: Map[Variable[G], Variable[G]] = Map
+ .empty[Variable[G], Variable[G]],
+ originTrafo: Origin => Origin = identity,
+) extends NonLatchingRewriter[G, G] {
+
+ case class SuccOrIdentity()
+ extends SuccessorsProviderTrafo[G, G](allScopes.freeze) {
+ override def postTransform[T <: Declaration[G]](
+ pre: Declaration[G],
+ post: Option[T],
+ ): Option[T] = Some(post.getOrElse(pre.asInstanceOf[T]))
}
override def succProvider: SuccessorsProvider[G, G] = SuccOrIdentity()
override def dispatch(o: Origin): Origin = originTrafo(o)
- override def dispatch(e: Expr[G]): Expr[G] = e match {
- case expr if subs.contains(expr) => subs(expr)
- case other => other.rewriteDefault()
- }
-
- override def dispatch(t: Type[G]): Type[G] = t match {
- case v @ TVar(_) if typeSubs.contains(v) => dispatch(typeSubs(v))
- case other => other.rewriteDefault()
- }
-
- override def dispatch(v: Declaration[G]): Unit = v match {
- case decl: Variable[G] if bindingSubs.contains(decl) => dispatch(bindingSubs(decl))
- case other => super.dispatch(other)
- }
+ override def dispatch(e: Expr[G]): Expr[G] =
+ e match {
+ case expr if subs.contains(expr) => subs(expr)
+ case other => other.rewriteDefault()
+ }
+
+ override def dispatch(t: Type[G]): Type[G] =
+ t match {
+ case v @ TVar(_) if typeSubs.contains(v) => dispatch(typeSubs(v))
+ case other => other.rewriteDefault()
+ }
+
+ override def dispatch(v: Declaration[G]): Unit =
+ v match {
+ case decl: Variable[G] if bindingSubs.contains(decl) =>
+ dispatch(bindingSubs(decl))
+ case other => super.dispatch(other)
+ }
}
diff --git a/src/col/vct/col/util/SuccessionMap.scala b/src/col/vct/col/util/SuccessionMap.scala
index c93cd9d94d..01b7c4aaea 100644
--- a/src/col/vct/col/util/SuccessionMap.scala
+++ b/src/col/vct/col/util/SuccessionMap.scala
@@ -13,16 +13,17 @@ import scala.reflect.ClassTag
case object SuccessionMap {
case class Scope(var idx: Int = 0, var triggerIdx: Option[Int] = None) {
- def next(): Int = this.synchronized {
- val result = idx
+ def next(): Int =
+ this.synchronized {
+ val result = idx
- if(triggerIdx.nonEmpty && triggerIdx.get == result) {
- throw MissingPredecessor
- }
+ if (triggerIdx.nonEmpty && triggerIdx.get == result) {
+ throw MissingPredecessor
+ }
- idx += 1
- result
- }
+ idx += 1
+ result
+ }
}
val scopes: ScopedStack[Scope] = ScopedStack()
@@ -50,15 +51,21 @@ case object SuccessionMap {
}
case object NonDeterminsticEvaluation extends SystemError {
- override def text: String = "We tried to derive the creation of a reference pointing to a successor that will not be populated, " +
- "but the second computation does not yield the same error. Is the function supplied to breakOnMissingPredecessor not deterministic?"
+ override def text: String =
+ "We tried to derive the creation of a reference pointing to a successor that will not be populated, " +
+ "but the second computation does not yield the same error. Is the function supplied to breakOnMissingPredecessor not deterministic?"
}
case object MissingPredecessor extends SystemError {
- override def text: String = "Stack trace for the location that creates a reference for a successor that will not be populated."
+ override def text: String =
+ "Stack trace for the location that creates a reference for a successor that will not be populated."
}
- case class NoSuchSuccessor[K, V <: Declaration[_]](map: SuccessionMap[K, V], missingKey: K, debugIdx: Int) extends SystemError {
+ case class NoSuchSuccessor[K, V <: Declaration[_]](
+ map: SuccessionMap[K, V],
+ missingKey: K,
+ debugIdx: Int,
+ ) extends SystemError {
override def text: String = s"Key not found: $missingKey"
}
}
@@ -67,39 +74,44 @@ case class SuccessionMap[K, V <: Declaration[_]]() {
private val collapsedStorage: mutable.HashMap[K, V] = mutable.HashMap()
private val storages: ArrayBuffer[mutable.HashMap[K, V]] = ArrayBuffer()
- private val localStorage: ThreadLocal[mutable.HashMap[K, V]] =
- ThreadLocal.withInitial(() => storages.synchronized {
- val store = mutable.HashMap[K, V]()
- storages += store
- store
- })
+ private val localStorage: ThreadLocal[mutable.HashMap[K, V]] = ThreadLocal
+ .withInitial(() =>
+ storages.synchronized {
+ val store = mutable.HashMap[K, V]()
+ storages += store
+ store
+ }
+ )
// Hint to GC: move as much data as possible out of pinned ThreadLocal
override def finalize(): Unit = collapse()
private def storage: mutable.HashMap[K, V] = localStorage.get()
- private def collapse(): Unit = storages.synchronized {
- for(storage <- storages) {
- collapsedStorage.addAll(storage)
- storage.clear()
+ private def collapse(): Unit =
+ storages.synchronized {
+ for (storage <- storages) {
+ collapsedStorage.addAll(storage)
+ storage.clear()
+ }
}
- }
- def get(k: K): Option[V] = storages.synchronized {
- collapse()
- collapsedStorage.get(k)
- }
+ def get(k: K): Option[V] =
+ storages.synchronized {
+ collapse()
+ collapsedStorage.get(k)
+ }
def apply(k: K): V = get(k).get
- def getOrElseUpdate(k: K, v: => V): V = storages.synchronized {
- get(k).getOrElse {
- val computed = v
- storage(k) = computed
- computed
+ def getOrElseUpdate(k: K, v: => V): V =
+ storages.synchronized {
+ get(k).getOrElse {
+ val computed = v
+ storage(k) = computed
+ computed
+ }
}
- }
def update(k: K, v: V): Unit = {
k match {
@@ -112,14 +124,15 @@ case class SuccessionMap[K, V <: Declaration[_]]() {
def contains(k: K): Boolean = get(k).isDefined
- def ref[G, V2 <: Declaration[G]](k: K)(implicit tag: ClassTag[V2], witness: V <:< Declaration[G]): LazyRef[G, V2] = {
+ def ref[G, V2 <: Declaration[G]](k: K)(
+ implicit tag: ClassTag[V2],
+ witness: V <:< Declaration[G],
+ ): LazyRef[G, V2] = {
val debugIdx = SuccessionMap.scopes.topOption.map(_.next()).getOrElse(-1)
- new LazyRef[G, V2](
- get(k) match {
- case Some(value) => value
- case None => throw NoSuchSuccessor(this, k, debugIdx)
- }
- )
+ new LazyRef[G, V2](get(k) match {
+ case Some(value) => value
+ case None => throw NoSuchSuccessor(this, k, debugIdx)
+ })
}
}
diff --git a/src/helpers/scala/meta/ResultStream.scala b/src/helpers/scala/meta/ResultStream.scala
index 9434a6d2b1..6420f782a2 100644
--- a/src/helpers/scala/meta/ResultStream.scala
+++ b/src/helpers/scala/meta/ResultStream.scala
@@ -9,10 +9,10 @@ import scala.meta.dialects.Scala213
import scala.util.Using
object ResultStream {
- /**
- * Forwards all writes to the inner Appendable, but stores the two last written
- * characters.
- */
+
+ /** Forwards all writes to the inner Appendable, but stores the two last
+ * written characters.
+ */
class MiniContextAppendable(inner: Appendable) extends Appendable {
private var last: Char = ' '
private var prelast: Char = ' '
@@ -24,10 +24,10 @@ object ResultStream {
_position += cs.length()
inner.append(cs)
- if(cs.length() > 1) {
+ if (cs.length() > 1) {
prelast = cs.charAt(cs.length() - 2)
last = cs.charAt(cs.length() - 1)
- } else if(cs.length() > 0) {
+ } else if (cs.length() > 0) {
prelast = last
last = cs.charAt(cs.length() - 1)
}
@@ -35,14 +35,14 @@ object ResultStream {
}
override def append(cs: CharSequence, start: Int, end: Int): Appendable = {
- if(end > start)
+ if (end > start)
_position += end - start
inner.append(cs, start, end)
- if(end - start > 1) {
+ if (end - start > 1) {
prelast = cs.charAt(end - 2)
last = cs.charAt(end - 1)
- } else if(end - start > 0) {
+ } else if (end - start > 0) {
prelast = last
last = cs.charAt(end - 1)
}
@@ -58,8 +58,7 @@ object ResultStream {
this
}
- def miniContext: String =
- s"$prelast$last"
+ def miniContext: String = s"$prelast$last"
}
def newline(out: Appendable, indentation: Int): Unit = {
@@ -77,14 +76,18 @@ object ResultStream {
def write(out: Appendable, result: Result): Unit =
write(new MiniContextAppendable(out), result, 0)
- /**
- * @see [[Result.toString]]
- */
- def write(out: MiniContextAppendable, result: Result, indentation: Int): Unit =
+ /** @see
+ * [[Result.toString]]
+ */
+ def write(
+ out: MiniContextAppendable,
+ result: Result,
+ indentation: Int,
+ ): Unit =
result match {
case None =>
case Str(text) => out.append(text)
- case Sequence(xs@_*) => xs.foreach(write(out, _, indentation))
+ case Sequence(xs @ _*) => xs.foreach(write(out, _, indentation))
case Repeat(first +: tail, sep) =>
write(out, first, indentation)
tail.foreach { x =>
@@ -98,15 +101,16 @@ object ResultStream {
case Newline(res) =>
newline(out, indentation)
write(out, res, indentation)
- case Meta(_, res) =>
- write(out, res, indentation)
+ case Meta(_, res) => write(out, res, indentation)
case Wrap(prefix, res, suffix) =>
val text = res.toString
- if(text.nonEmpty) {
- out.append(prefix).append(text).append(suffix)
- }
+ if (text.nonEmpty) { out.append(prefix).append(text).append(suffix) }
case Function(fn) =>
- if(fn.getClass.getName.startsWith("scala.meta.internal.prettyprinters.TreeSyntax$SyntaxInstances$$Lambda$")) {
+ if (
+ fn.getClass.getName.startsWith(
+ "scala.meta.internal.prettyprinters.TreeSyntax$SyntaxInstances$$Lambda$"
+ )
+ ) {
// Currently the only instance: prepends a space if the surrounding output is dangerous.
// Luckily it considers only the preceding two characters, so that's all the buffer we'll store
val sb = new StringBuilder(out.miniContext)
diff --git a/src/helpers/vct/col/ast/helpers/defn/Constants.scala b/src/helpers/vct/col/ast/helpers/defn/Constants.scala
index 0267d9ed49..3e36978740 100644
--- a/src/helpers/vct/col/ast/helpers/defn/Constants.scala
+++ b/src/helpers/vct/col/ast/helpers/defn/Constants.scala
@@ -28,19 +28,23 @@ object Constants {
val LeftObj: Term = q"_root_.scala.util.Left"
val RightObj: Term = q"_root_.scala.util.Right"
- val copyByteStringFrom: Term = q"_root_.com.google.protobuf.ByteString.copyFrom"
+ val copyByteStringFrom: Term =
+ q"_root_.com.google.protobuf.ByteString.copyFrom"
val Node: Type = typ(RootNodeName)
val Declaration: Type = typ(DeclarationName)
- val ExprName: structure.Name = structure.Name(Seq("_root_", "vct", "col", "ast", "Expr"))
+ val ExprName: structure.Name = structure
+ .Name(Seq("_root_", "vct", "col", "ast", "Expr"))
val Expr: Type = typ(ExprName)
val Coercion: Type = t"_root_.vct.col.ast.Coercion"
- val ApplyCoercionPat: (Pat, Pat) => Pat = (e, c) => p"_root_.vct.col.ast.ApplyCoercion($e, $c)"
+ val ApplyCoercionPat: (Pat, Pat) => Pat =
+ (e, c) => p"_root_.vct.col.ast.ApplyCoercion($e, $c)"
val Origin: Type = t"_root_.vct.col.origin.Origin"
val OriginObj: Term = q"_root_.vct.col.origin.Origin"
val Blame: Type = t"_root_.vct.col.origin.Blame"
val VerificationFailure: Type = t"_root_.vct.col.origin.VerificationFailure"
- val InconsistentSuccessionTypesObj: Term = q"_root_.vct.col.err.InconsistentSuccessionTypes"
+ val InconsistentSuccessionTypesObj: Term =
+ q"_root_.vct.col.err.InconsistentSuccessionTypes"
val RefType: Type = t"_root_.vct.col.ref.Ref"
val LazyRef: Type = t"_root_.vct.col.ref.LazyRef"
diff --git a/src/helpers/vct/col/ast/helpers/defn/Naming.scala b/src/helpers/vct/col/ast/helpers/defn/Naming.scala
index 0cda3a8543..455b42735d 100644
--- a/src/helpers/vct/col/ast/helpers/defn/Naming.scala
+++ b/src/helpers/vct/col/ast/helpers/defn/Naming.scala
@@ -1,6 +1,14 @@
package vct.col.ast.helpers.defn
-import vct.col.ast.helpers.defn.Constants.{ComparePackage, DeclarePackage, DeserializePackage, RefType, RewritePackage, SerializePackage, SubnodesPackage}
+import vct.col.ast.helpers.defn.Constants.{
+ ComparePackage,
+ DeclarePackage,
+ DeserializePackage,
+ RefType,
+ RewritePackage,
+ SerializePackage,
+ SubnodesPackage,
+}
import vct.col.ast.structure
import vct.col.ast.structure.NodeDefinition
@@ -13,43 +21,51 @@ object Naming {
}
def typ(name: structure.Name): Type =
- if(name.parts.size == 1) Type.Name(name.base)
- else Type.Select(term(name.initName), Type.Name(name.base))
+ if (name.parts.size == 1)
+ Type.Name(name.base)
+ else
+ Type.Select(term(name.initName), Type.Name(name.base))
def typ(node: structure.NodeDefinition): Type = typ(node.name)
- def typ(t: structure.Type, g: Type): Type = t match {
- case structure.Type.Node(name) => t"${typ(name)}[$g]"
- case structure.Type.Declaration(name) => t"${typ(name)}[$g]"
- case structure.Type.DeclarationSeq(name) => t"_root_.scala.Seq[${typ(name)}[$g]]"
- case structure.Type.Ref(node) => t"$RefType[$g, ${typ(node.name)}[$g]]"
- case structure.Type.MultiRef(node) => t"$RefType[$g, ${typ(node.name)}[$g]]"
- case structure.Type.Tuple(args) => t"(..${args.toList.map(typ(_, g))})"
- case structure.Type.Seq(arg) => t"_root_.scala.Seq[${typ(arg, g)}]"
- case structure.Type.Option(arg) => t"_root_.scala.Option[${typ(arg, g)}]"
- case structure.Type.Either(left, right) => t"_root_.scala.util.Either[${typ(left, g)}, ${typ(right, g)}]"
- case structure.Type.Nothing => t"_root_.scala.Nothing"
- case structure.Type.Unit => t"_root_.scala.Unit"
- case structure.Type.String => t"_root_.java.lang.String"
- case structure.Type.BigInt => t"_root_.scala.BigInt"
- case structure.Type.BigDecimal => t"_root_.scala.BigDecimal"
- case structure.Type.BitString => t"_root_.hre.data.BitString"
- case structure.Type.ExpectedError => t"_root_.vct.col.origin.ExpectedError"
- case structure.Type.Boolean => t"_root_.scala.Boolean"
- case structure.Type.Byte => t"_root_.scala.Byte"
- case structure.Type.Short => t"_root_.scala.Short"
- case structure.Type.Int => t"_root_.scala.Int"
- case structure.Type.Long => t"_root_.scala.Long"
- case structure.Type.Float => t"_root_.scala.Float"
- case structure.Type.Double => t"_root_.scala.Double"
- case structure.Type.Char => t"_root_.scala.Char"
- }
+ def typ(t: structure.Type, g: Type): Type =
+ t match {
+ case structure.Type.Node(name) => t"${typ(name)}[$g]"
+ case structure.Type.Declaration(name) => t"${typ(name)}[$g]"
+ case structure.Type.DeclarationSeq(name) =>
+ t"_root_.scala.Seq[${typ(name)}[$g]]"
+ case structure.Type.Ref(node) => t"$RefType[$g, ${typ(node.name)}[$g]]"
+ case structure.Type.MultiRef(node) =>
+ t"$RefType[$g, ${typ(node.name)}[$g]]"
+ case structure.Type.Tuple(args) => t"(..${args.toList.map(typ(_, g))})"
+ case structure.Type.Seq(arg) => t"_root_.scala.Seq[${typ(arg, g)}]"
+ case structure.Type.Option(arg) => t"_root_.scala.Option[${typ(arg, g)}]"
+ case structure.Type.Either(left, right) =>
+ t"_root_.scala.util.Either[${typ(left, g)}, ${typ(right, g)}]"
+ case structure.Type.Nothing => t"_root_.scala.Nothing"
+ case structure.Type.Unit => t"_root_.scala.Unit"
+ case structure.Type.String => t"_root_.java.lang.String"
+ case structure.Type.BigInt => t"_root_.scala.BigInt"
+ case structure.Type.BigDecimal => t"_root_.scala.BigDecimal"
+ case structure.Type.BitString => t"_root_.hre.data.BitString"
+ case structure.Type.ExpectedError =>
+ t"_root_.vct.col.origin.ExpectedError"
+ case structure.Type.Boolean => t"_root_.scala.Boolean"
+ case structure.Type.Byte => t"_root_.scala.Byte"
+ case structure.Type.Short => t"_root_.scala.Short"
+ case structure.Type.Int => t"_root_.scala.Int"
+ case structure.Type.Long => t"_root_.scala.Long"
+ case structure.Type.Float => t"_root_.scala.Float"
+ case structure.Type.Double => t"_root_.scala.Double"
+ case structure.Type.Char => t"_root_.scala.Char"
+ }
- def packageFromRoot(t: Term): Term.Ref = t match {
- case name: Term.Name => q"_root_.$name"
- case Term.Select(base, name) => q"${packageFromRoot(base)}.$name"
- case _ => ???
- }
+ def packageFromRoot(t: Term): Term.Ref =
+ t match {
+ case name: Term.Name => q"_root_.$name"
+ case Term.Select(base, name) => q"${packageFromRoot(base)}.$name"
+ case _ => ???
+ }
def scopes(family: String): Term.Name =
Term.Name(family.charAt(0).toLower.toString + family.substring(1) + "s")
@@ -61,26 +77,38 @@ object Naming {
structure.Name(pkg :+ baseName)
}
- def scalapbType(node: structure.Name): Type =
- typ(scalapbName(node))
+ def scalapbType(node: structure.Name): Type = typ(scalapbName(node))
def opsTrait(node: NodeDefinition) = Type.Name(node.name.base + "Ops")
def opsFamilyTrait(node: structure.Name) = Type.Name(node.base + "FamilyOps")
def compareTrait(node: NodeDefinition) = Type.Name(node.name.base + "Compare")
- def compareType(node: NodeDefinition) = t"${packageFromRoot(ComparePackage)}.${compareTrait(node)}"
+ def compareType(node: NodeDefinition) =
+ t"${packageFromRoot(ComparePackage)}.${compareTrait(node)}"
def rewriteTrait(node: NodeDefinition) = Type.Name(node.name.base + "Rewrite")
- def rewriteType(node: NodeDefinition) = t"${packageFromRoot(RewritePackage)}.${rewriteTrait(node)}"
- def subnodesTrait(node: NodeDefinition) = Type.Name(node.name.base + "Subnodes")
- def subnodesType(node: NodeDefinition) = t"${packageFromRoot(SubnodesPackage)}.${subnodesTrait(node)}"
- def serializeTrait(node: NodeDefinition) = Type.Name(node.name.base + "Serialize")
- def serializeType(node: NodeDefinition) = t"${packageFromRoot(SerializePackage)}.${serializeTrait(node)}"
+ def rewriteType(node: NodeDefinition) =
+ t"${packageFromRoot(RewritePackage)}.${rewriteTrait(node)}"
+ def subnodesTrait(node: NodeDefinition) =
+ Type.Name(node.name.base + "Subnodes")
+ def subnodesType(node: NodeDefinition) =
+ t"${packageFromRoot(SubnodesPackage)}.${subnodesTrait(node)}"
+ def serializeTrait(node: NodeDefinition) =
+ Type.Name(node.name.base + "Serialize")
+ def serializeType(node: NodeDefinition) =
+ t"${packageFromRoot(SerializePackage)}.${serializeTrait(node)}"
def deserializeName(node: structure.Name) = "Deserialize" + node.base
- def deserializeFamilyName(node: structure.Name) = "DeserializeFamily" + node.base
- def deserializeType(node: NodeDefinition) = Type.Name(deserializeName(node.name))
- def deserializeObjectName(node: NodeDefinition) = Term.Name(deserializeName(node.name))
- def deserializeObject(node: structure.Name) = q"${packageFromRoot(DeserializePackage)}.${Term.Name(deserializeName(node))}"
- def deserializeFamilyObject(name: structure.Name) = q"${packageFromRoot(DeserializePackage)}.${Term.Name(deserializeFamilyName(name))}"
- def declareTrait(node: structure.Name) = Type.Name(node.base + "FamilyDeclare")
- def declareType(node: structure.Name) = t"${packageFromRoot(DeclarePackage)}.${declareTrait(node)}"
+ def deserializeFamilyName(node: structure.Name) =
+ "DeserializeFamily" + node.base
+ def deserializeType(node: NodeDefinition) =
+ Type.Name(deserializeName(node.name))
+ def deserializeObjectName(node: NodeDefinition) =
+ Term.Name(deserializeName(node.name))
+ def deserializeObject(node: structure.Name) =
+ q"${packageFromRoot(DeserializePackage)}.${Term.Name(deserializeName(node))}"
+ def deserializeFamilyObject(name: structure.Name) =
+ q"${packageFromRoot(DeserializePackage)}.${Term.Name(deserializeFamilyName(name))}"
+ def declareTrait(node: structure.Name) =
+ Type.Name(node.base + "FamilyDeclare")
+ def declareType(node: structure.Name) =
+ t"${packageFromRoot(DeclarePackage)}.${declareTrait(node)}"
}
diff --git a/src/helpers/vct/col/ast/helpers/defn/Proto.scala b/src/helpers/vct/col/ast/helpers/defn/Proto.scala
index 5890e9ffc6..574bdf8892 100644
--- a/src/helpers/vct/col/ast/helpers/defn/Proto.scala
+++ b/src/helpers/vct/col/ast/helpers/defn/Proto.scala
@@ -16,9 +16,9 @@ object Proto {
"no_default_values_in_constructor" -> "true",
)
- val OPAQUE_SUBMESSAGES_OPTIONS: Map[String, String] = STANDARD_OPTIONS ++ ListMap(
- "bytes_type" -> "\"_root_.vct.serialize.OpaqueMessageBytes\"",
- )
+ val OPAQUE_SUBMESSAGES_OPTIONS: Map[String, String] =
+ STANDARD_OPTIONS ++
+ ListMap("bytes_type" -> "\"_root_.vct.serialize.OpaqueMessageBytes\"")
def renderOptions(options: Map[String, String]): String =
s"""option (scalapb.options) = {
@@ -26,25 +26,27 @@ object Proto {
|};""".stripMargin
sealed trait PrimitiveType {
- def write(out: Appendable): Unit = this match {
- case Int => out.append("sint32")
- case Float => out.append("float")
- case Long => out.append("sint64")
- case Double => out.append("double")
- case Bool => out.append("bool")
- case String => out.append("string")
- case Bytes => out.append("bytes")
- case t: NamedType =>
- for(part <- t.fqName) {
- out.append('.')
- out.append(part)
- }
- }
+ def write(out: Appendable): Unit =
+ this match {
+ case Int => out.append("sint32")
+ case Float => out.append("float")
+ case Long => out.append("sint64")
+ case Double => out.append("double")
+ case Bool => out.append("bool")
+ case String => out.append("string")
+ case Bytes => out.append("bytes")
+ case t: NamedType =>
+ for (part <- t.fqName) {
+ out.append('.')
+ out.append(part)
+ }
+ }
- def opaqueNodes: PrimitiveType = this match {
- case FamilyType(_) => Bytes
- case other => other
- }
+ def opaqueNodes: PrimitiveType =
+ this match {
+ case FamilyType(_) => Bytes
+ case other => other
+ }
}
case object Int extends PrimitiveType
@@ -54,7 +56,9 @@ object Proto {
case object Bool extends PrimitiveType
case object String extends PrimitiveType
case object Bytes extends PrimitiveType
- sealed trait NamedType extends PrimitiveType { def fqName: Seq[String] }
+ sealed trait NamedType extends PrimitiveType {
+ def fqName: Seq[String]
+ }
case class StandardType(fqName: Seq[String]) extends NamedType
case class AuxType(fqName: Seq[String]) extends NamedType
case class FamilyType(fqName: Seq[String]) extends NamedType
@@ -66,25 +70,28 @@ object Proto {
sealed trait Type {
def t: PrimitiveType
- def write(out: Appendable): Unit = this match {
- case Option(t) => out.append("optional "); t.write(out)
- case Repeated(t) => out.append("repeated "); t.write(out)
- case Required(t) => out.append("required "); t.write(out)
- case UnspecifiedArity(t) => t.write(out)
- }
+ def write(out: Appendable): Unit =
+ this match {
+ case Option(t) => out.append("optional "); t.write(out)
+ case Repeated(t) => out.append("repeated "); t.write(out)
+ case Required(t) => out.append("required "); t.write(out)
+ case UnspecifiedArity(t) => t.write(out)
+ }
- def writeOption(out: Appendable): Unit = this match {
- case Repeated(Int) | Repeated(Long) | Repeated(Bool) =>
- out.append(" [packed = true]")
- case _ => // Do nothing
- }
+ def writeOption(out: Appendable): Unit =
+ this match {
+ case Repeated(Int) | Repeated(Long) | Repeated(Bool) =>
+ out.append(" [packed = true]")
+ case _ => // Do nothing
+ }
- def map(f: PrimitiveType => PrimitiveType): Type = this match {
- case Option(t) => Option(f(t))
- case Repeated(t) => Repeated(f(t))
- case Required(t) => Required(f(t))
- case UnspecifiedArity(t) => UnspecifiedArity(f(t))
- }
+ def map(f: PrimitiveType => PrimitiveType): Type =
+ this match {
+ case Option(t) => Option(f(t))
+ case Repeated(t) => Repeated(f(t))
+ case Required(t) => Required(f(t))
+ case UnspecifiedArity(t) => UnspecifiedArity(f(t))
+ }
}
case class Option(t: PrimitiveType) extends Type
@@ -103,33 +110,30 @@ object Proto {
out.append(";")
}
- def opaqueNodes: Field =
- copy(t = t.map(_.opaqueNodes))
+ def opaqueNodes: Field = copy(t = t.map(_.opaqueNodes))
}
sealed trait MessageBody {
def fields: Seq[Field]
def namedTypes: Seq[NamedType] =
- fields.collect {
- case Field(_, _, Type(name: NamedType)) => name
- }
+ fields.collect { case Field(_, _, Type(name: NamedType)) => name }
private def writeFields(out: Appendable, indent: String): Unit =
- for(field <- fields) {
+ for (field <- fields) {
out.append(indent)
field.write(out)
out.append("\n")
}
- def write(out: Appendable): Unit = this match {
- case MessageFields(_) =>
- writeFields(out, " ")
- case MessageOneOf(oneOfName, _) =>
- out.append(" oneof ").append(oneOfName).append(" {\n")
- writeFields(out, " ")
- out.append(" }\n")
- }
+ def write(out: Appendable): Unit =
+ this match {
+ case MessageFields(_) => writeFields(out, " ")
+ case MessageOneOf(oneOfName, _) =>
+ out.append(" oneof ").append(oneOfName).append(" {\n")
+ writeFields(out, " ")
+ out.append(" }\n")
+ }
def opaqueNodes: MessageBody
}
@@ -138,7 +142,8 @@ object Proto {
def opaqueNodes: MessageFields = copy(fields = fields.map(_.opaqueNodes))
}
- case class MessageOneOf(oneOfName: String, fields: Seq[Field]) extends MessageBody {
+ case class MessageOneOf(oneOfName: String, fields: Seq[Field])
+ extends MessageBody {
def opaqueNodes: MessageOneOf = copy(fields = fields.map(_.opaqueNodes))
}
@@ -151,8 +156,7 @@ object Proto {
out.append("}\n")
}
- def opaqueNodes: Message =
- copy(body = body.opaqueNodes)
+ def opaqueNodes: Message = copy(body = body.opaqueNodes)
def namedTypes: Seq[NamedType] = body.namedTypes
@@ -160,48 +164,63 @@ object Proto {
}
object Source {
- def apply(imports: Seq[Seq[String]], options: String, message: Message): Source =
- Source(imports, options, Seq(message))
+ def apply(
+ imports: Seq[Seq[String]],
+ options: String,
+ message: Message,
+ ): Source = Source(imports, options, Seq(message))
}
- case class Source(imports: Seq[Seq[String]], options: String, messages: Seq[Message]) {
+ case class Source(
+ imports: Seq[Seq[String]],
+ options: String,
+ messages: Seq[Message],
+ ) {
require(messages.nonEmpty)
def write(out: Appendable): Unit = {
out.append("syntax = \"proto2\";\n")
out.append("\n")
- if(messages.exists(_.name.size > 1)) {
- val pkg = messages.collectFirst { case msg if msg.name.size > 1 => msg.name.init }.get
-
- val wrongPackageMessages = messages.filter(msg => msg.name.size != pkg.size + 1 || msg.name.init != pkg)
- require(wrongPackageMessages.isEmpty,
- out.append(s"Messages rendered jointly in one source must have the same package. Wrong: ${
- wrongPackageMessages.map(_.name.mkString(".")).mkString("{", ", ", "}")}"))
+ if (messages.exists(_.name.size > 1)) {
+ val pkg =
+ messages.collectFirst {
+ case msg if msg.name.size > 1 => msg.name.init
+ }.get
+
+ val wrongPackageMessages = messages
+ .filter(msg => msg.name.size != pkg.size + 1 || msg.name.init != pkg)
+ require(
+ wrongPackageMessages.isEmpty,
+ out.append(
+ s"Messages rendered jointly in one source must have the same package. Wrong: ${wrongPackageMessages
+ .map(_.name.mkString(".")).mkString("{", ", ", "}")}"
+ ),
+ )
out.append("package ").append(pkg.mkString(".")).append(";\n")
out.append("\n")
}
- if(imports.nonEmpty) {
- for(imp <- imports) {
- out.append("import \"").append(imp.mkString("/")).append(".proto\";\n")
+ if (imports.nonEmpty) {
+ for (imp <- imports) {
+ out.append("import \"").append(imp.mkString("/"))
+ .append(".proto\";\n")
}
out.append("\n")
}
- if(!options.isBlank) {
+ if (!options.isBlank) {
out.append(options)
out.append("\n")
}
- for(message <- messages) {
+ for (message <- messages) {
out.append("\n")
message.write(out)
}
}
- def opaqueNodes: Source =
- copy(messages = messages.map(_.opaqueNodes))
+ def opaqueNodes: Source = copy(messages = messages.map(_.opaqueNodes))
}
}
diff --git a/src/helpers/vct/col/ast/helpers/defn/ProtoNaming.scala b/src/helpers/vct/col/ast/helpers/defn/ProtoNaming.scala
index dede529183..6d231d8830 100644
--- a/src/helpers/vct/col/ast/helpers/defn/ProtoNaming.scala
+++ b/src/helpers/vct/col/ast/helpers/defn/ProtoNaming.scala
@@ -12,7 +12,8 @@ object ProtoNaming {
@tailrec
def explodeCamel(name: String, acc: Seq[String] = Nil): Seq[String] = {
- if (name.isEmpty) return acc
+ if (name.isEmpty)
+ return acc
val (leftUpper, rem0) = name.span(_.isUpper)
@@ -22,7 +23,10 @@ object ProtoNaming {
explodeCamel(rem1, acc :+ (leftUpper + leftLower).toLowerCase)
} else {
// ADTFunctionInvocation -> ADT +: explodeCamel("FunctionInvocation")
- explodeCamel(s"${leftUpper.last}${rem0}", acc :+ leftUpper.init.toLowerCase)
+ explodeCamel(
+ s"${leftUpper.last}${rem0}",
+ acc :+ leftUpper.init.toLowerCase,
+ )
}
}
@@ -37,19 +41,18 @@ object ProtoNaming {
val parts = explode(name)
if (bannedParts.contains(parts))
"vct" +: parts
- else parts
+ else
+ parts
}
- def snake(name: String): String =
- parts(name).mkString("_")
+ def snake(name: String): String = parts(name).mkString("_")
def camel(name: String): String = {
val ps = parts(name)
(ps.head +: ps.tail.map(_.capitalize)).mkString("")
}
- def ucamel(name: String): String =
- camel(name).capitalize
+ def ucamel(name: String): String = camel(name).capitalize
def getTypeName(t: structure.Name): Seq[String] =
t.parts.tail.init.map(snake) :+ ucamel(t.parts.last)
@@ -67,114 +70,155 @@ object ProtoNaming {
case class TypeResult(t: Type, auxs: Seq[Message] = Nil)
- def typeText(t: structure.Type): String = t match {
- case structure.Type.Node(name) => name.tailName.parts.flatMap(parts).map(_.capitalize).mkString("")
- case structure.Type.Declaration(name) => typeText(structure.Type.Node(name))
- case structure.Type.DeclarationSeq(name) => typeText(structure.Type.Seq(structure.Type.Node(name)))
- case structure.Type.Ref(node) => s"Ref_${typeText(node)}"
- case structure.Type.MultiRef(node) => s"Ref_${typeText(node)}"
- case structure.Type.Tuple(args) => s"Tuple${args.size}_${args.map(typeText).mkString("_")}"
- case structure.Type.Option(arg) => s"Option_${typeText(arg)}"
- case structure.Type.Seq(arg) => s"Seq_${typeText(arg)}"
- case structure.Type.Either(left, right) => s"Either_${typeText(left)}_${typeText(right)}"
- case other: structure.Type.PrimitiveType => other.getClass.getSimpleName.replace("$", "")
- }
+ def typeText(t: structure.Type): String =
+ t match {
+ case structure.Type.Node(name) =>
+ name.tailName.parts.flatMap(parts).map(_.capitalize).mkString("")
+ case structure.Type.Declaration(name) =>
+ typeText(structure.Type.Node(name))
+ case structure.Type.DeclarationSeq(name) =>
+ typeText(structure.Type.Seq(structure.Type.Node(name)))
+ case structure.Type.Ref(node) => s"Ref_${typeText(node)}"
+ case structure.Type.MultiRef(node) => s"Ref_${typeText(node)}"
+ case structure.Type.Tuple(args) =>
+ s"Tuple${args.size}_${args.map(typeText).mkString("_")}"
+ case structure.Type.Option(arg) => s"Option_${typeText(arg)}"
+ case structure.Type.Seq(arg) => s"Seq_${typeText(arg)}"
+ case structure.Type.Either(left, right) =>
+ s"Either_${typeText(left)}_${typeText(right)}"
+ case other: structure.Type.PrimitiveType =>
+ other.getClass.getSimpleName.replace("$", "")
+ }
- private val _getTupleAux = mutable.Map[Seq[structure.Type], PrimitiveTypeResult]()
+ private val _getTupleAux = mutable
+ .Map[Seq[structure.Type], PrimitiveTypeResult]()
def getTupleAux(ts: Seq[structure.Type]): PrimitiveTypeResult =
- _getTupleAux.getOrElseUpdate(ts, {
- val fieldTypeResults = ts.map(getType)
- val auxs = fieldTypeResults.flatMap(_.auxs)
- val fieldTypes = fieldTypeResults.map(_.t)
- val fields = MessageFields(fieldTypes.zipWithIndex.map {
- case (t, i) => Field(s"v${i + 1}", i + 1, t)
- })
- val message = Message(auxBase :+ typeText(structure.Type.Tuple(ts)), fields)
- PrimitiveTypeResult(AuxType(message.name), auxs :+ message)
- })
+ _getTupleAux.getOrElseUpdate(
+ ts, {
+ val fieldTypeResults = ts.map(getType)
+ val auxs = fieldTypeResults.flatMap(_.auxs)
+ val fieldTypes = fieldTypeResults.map(_.t)
+ val fields = MessageFields(fieldTypes.zipWithIndex.map { case (t, i) =>
+ Field(s"v${i + 1}", i + 1, t)
+ })
+ val message = Message(
+ auxBase :+ typeText(structure.Type.Tuple(ts)),
+ fields,
+ )
+ PrimitiveTypeResult(AuxType(message.name), auxs :+ message)
+ },
+ )
private val _getOptionAux = mutable.Map[structure.Type, PrimitiveTypeResult]()
def getOptionAux(t: structure.Type): PrimitiveTypeResult =
- _getOptionAux.getOrElseUpdate(t, {
- val typeResult = getPrimitiveType(t)
- val field = Field("value", 1, Option(typeResult.t))
- val message = Message(auxBase :+ ("Option_" + typeText(t)), MessageFields(Seq(field)))
- PrimitiveTypeResult(AuxType(message.name), typeResult.auxs :+ message)
- })
+ _getOptionAux.getOrElseUpdate(
+ t, {
+ val typeResult = getPrimitiveType(t)
+ val field = Field("value", 1, Option(typeResult.t))
+ val message = Message(
+ auxBase :+ ("Option_" + typeText(t)),
+ MessageFields(Seq(field)),
+ )
+ PrimitiveTypeResult(AuxType(message.name), typeResult.auxs :+ message)
+ },
+ )
private val _getSeqAux = mutable.Map[structure.Type, PrimitiveTypeResult]()
def getSeqAux(t: structure.Type): PrimitiveTypeResult =
- _getSeqAux.getOrElseUpdate(t, {
- val typeResult = getPrimitiveType(t)
- val field = Field("value", 1, Repeated(typeResult.t))
- val message = Message(auxBase :+ ("Seq_" + typeText(t)), MessageFields(Seq(field)))
- PrimitiveTypeResult(AuxType(message.name), typeResult.auxs :+ message)
- })
-
- private val _getEitherAux = mutable.Map[(structure.Type, structure.Type), PrimitiveTypeResult]()
-
- def getEitherAux(left: structure.Type, right: structure.Type): PrimitiveTypeResult =
- _getEitherAux.getOrElseUpdate((left, right), {
- val leftTypeResult = getPrimitiveType(left)
- val rightTypeResult = getPrimitiveType(right)
- val leftField = Field("left", 1, Required(leftTypeResult.t))
- val rightField = Field("right", 2, Required(rightTypeResult.t))
- val fields = MessageOneOf("either", Seq(leftField, rightField))
- val message = Message(auxBase :+ s"Either_${typeText(left)}_${typeText(right)}", fields)
- PrimitiveTypeResult(
- AuxType(message.name),
- (leftTypeResult.auxs ++ rightTypeResult.auxs) :+ message,
- )
- })
+ _getSeqAux.getOrElseUpdate(
+ t, {
+ val typeResult = getPrimitiveType(t)
+ val field = Field("value", 1, Repeated(typeResult.t))
+ val message = Message(
+ auxBase :+ ("Seq_" + typeText(t)),
+ MessageFields(Seq(field)),
+ )
+ PrimitiveTypeResult(AuxType(message.name), typeResult.auxs :+ message)
+ },
+ )
+
+ private val _getEitherAux = mutable
+ .Map[(structure.Type, structure.Type), PrimitiveTypeResult]()
+
+ def getEitherAux(
+ left: structure.Type,
+ right: structure.Type,
+ ): PrimitiveTypeResult =
+ _getEitherAux.getOrElseUpdate(
+ (left, right), {
+ val leftTypeResult = getPrimitiveType(left)
+ val rightTypeResult = getPrimitiveType(right)
+ val leftField = Field("left", 1, Required(leftTypeResult.t))
+ val rightField = Field("right", 2, Required(rightTypeResult.t))
+ val fields = MessageOneOf("either", Seq(leftField, rightField))
+ val message = Message(
+ auxBase :+ s"Either_${typeText(left)}_${typeText(right)}",
+ fields,
+ )
+ PrimitiveTypeResult(
+ AuxType(message.name),
+ (leftTypeResult.auxs ++ rightTypeResult.auxs) :+ message,
+ )
+ },
+ )
def getStandardType(name: String): PrimitiveTypeResult =
PrimitiveTypeResult(StandardType(auxBase :+ name))
- private val _getPrimitiveType = mutable.Map[structure.Type, PrimitiveTypeResult]()
+ private val _getPrimitiveType = mutable
+ .Map[structure.Type, PrimitiveTypeResult]()
def getPrimitiveType(t: structure.Type): PrimitiveTypeResult =
- _getPrimitiveType.getOrElseUpdate(t, {
- t match {
- case structure.Type.Node(name) =>
- PrimitiveTypeResult(FamilyType(getTypeName(name)))
- case structure.Type.Declaration(name) =>
- PrimitiveTypeResult(FamilyType(getTypeName(name)))
- case structure.Type.Ref(_) | structure.Type.MultiRef(_) => getStandardType("Ref")
- case structure.Type.Tuple(args) => getTupleAux(args)
-
- case structure.Type.Nothing => PrimitiveTypeResult(Bool)
- case structure.Type.Unit => PrimitiveTypeResult(Bool)
- case structure.Type.String => PrimitiveTypeResult(String)
- case structure.Type.BigInt => getStandardType("BigInt")
- case structure.Type.BigDecimal => getStandardType("BigDecimal")
- case structure.Type.BitString => getStandardType("BitString")
- case structure.Type.ExpectedError => getStandardType("ExpectedError")
- case structure.Type.Boolean => PrimitiveTypeResult(Bool)
- case structure.Type.Byte => PrimitiveTypeResult(Int)
- case structure.Type.Short => PrimitiveTypeResult(Int)
- case structure.Type.Int => PrimitiveTypeResult(Int)
- case structure.Type.Long => PrimitiveTypeResult(Long)
- case structure.Type.Float => PrimitiveTypeResult(Float)
- case structure.Type.Double => PrimitiveTypeResult(Double)
- case structure.Type.Char => PrimitiveTypeResult(Int)
-
- case structure.Type.Seq(t) => getSeqAux(t)
- case structure.Type.DeclarationSeq(name) => getSeqAux(structure.Type.Declaration(name))
- case structure.Type.Option(t) => getOptionAux(t)
- case structure.Type.Either(left, right) => getEitherAux(left, right)
- }
- })
+ _getPrimitiveType.getOrElseUpdate(
+ t, {
+ t match {
+ case structure.Type.Node(name) =>
+ PrimitiveTypeResult(FamilyType(getTypeName(name)))
+ case structure.Type.Declaration(name) =>
+ PrimitiveTypeResult(FamilyType(getTypeName(name)))
+ case structure.Type.Ref(_) | structure.Type.MultiRef(_) =>
+ getStandardType("Ref")
+ case structure.Type.Tuple(args) => getTupleAux(args)
+
+ case structure.Type.Nothing => PrimitiveTypeResult(Bool)
+ case structure.Type.Unit => PrimitiveTypeResult(Bool)
+ case structure.Type.String => PrimitiveTypeResult(String)
+ case structure.Type.BigInt => getStandardType("BigInt")
+ case structure.Type.BigDecimal => getStandardType("BigDecimal")
+ case structure.Type.BitString => getStandardType("BitString")
+ case structure.Type.ExpectedError => getStandardType("ExpectedError")
+ case structure.Type.Boolean => PrimitiveTypeResult(Bool)
+ case structure.Type.Byte => PrimitiveTypeResult(Int)
+ case structure.Type.Short => PrimitiveTypeResult(Int)
+ case structure.Type.Int => PrimitiveTypeResult(Int)
+ case structure.Type.Long => PrimitiveTypeResult(Long)
+ case structure.Type.Float => PrimitiveTypeResult(Float)
+ case structure.Type.Double => PrimitiveTypeResult(Double)
+ case structure.Type.Char => PrimitiveTypeResult(Int)
+
+ case structure.Type.Seq(t) => getSeqAux(t)
+ case structure.Type.DeclarationSeq(name) =>
+ getSeqAux(structure.Type.Declaration(name))
+ case structure.Type.Option(t) => getOptionAux(t)
+ case structure.Type.Either(left, right) => getEitherAux(left, right)
+ }
+ },
+ )
private val _getType = mutable.Map[structure.Type, TypeResult]()
def getType(t: structure.Type): TypeResult =
- _getType.getOrElseUpdate(t, t match {
- case structure.Type.Seq(t) => getPrimitiveType(t).result(Repeated)
- case structure.Type.DeclarationSeq(name) => getPrimitiveType(structure.Type.Declaration(name)).result(Repeated)
- case structure.Type.Option(t) => getPrimitiveType(t).result(Option)
- case _ => getPrimitiveType(t).result(Required)
- })
+ _getType.getOrElseUpdate(
+ t,
+ t match {
+ case structure.Type.Seq(t) => getPrimitiveType(t).result(Repeated)
+ case structure.Type.DeclarationSeq(name) =>
+ getPrimitiveType(structure.Type.Declaration(name)).result(Repeated)
+ case structure.Type.Option(t) => getPrimitiveType(t).result(Option)
+ case _ => getPrimitiveType(t).result(Required)
+ },
+ )
}
diff --git a/src/helpers/vct/col/ast/helpers/defn/Simplify.scala b/src/helpers/vct/col/ast/helpers/defn/Simplify.scala
index 2c1ca19197..85f8af0fc8 100644
--- a/src/helpers/vct/col/ast/helpers/defn/Simplify.scala
+++ b/src/helpers/vct/col/ast/helpers/defn/Simplify.scala
@@ -9,84 +9,94 @@ import scala.meta._
object Simplify {
def simplify(t: Term): Term = simplifyFlatly(recurse(t))
- private def recurse(term: Term): Term = term match {
- // Exception: immediately push .to(LazyList) inwards, since we can further simplify the subterms.
- case q"(if($cond) $whenTrue else $whenFalse).to(${`LazyListObj`})" =>
- simplify(q"if($cond) $whenTrue.to($LazyListObj) else $whenFalse.to($LazyListObj)")
-
- case q"if($cond) $whenTrue else $whenFalse" =>
- q"if(${simplify(cond)}) ${simplify(whenTrue)} else ${simplify(whenFalse)}"
- case q"$xs.flatMap($arg => $exp)" =>
- q"${simplify(xs)}.flatMap($arg => ${simplify(exp)})"
- case q"$zipped.flatMap({ case ($l, $r) => $exp })" =>
- q"${simplify(zipped)}.flatMap({ case ($l, $r) => ${simplify(exp)} })"
- case q"$xs.map($arg => $exp)" =>
- q"${simplify(xs)}.map($arg => ${simplify(exp)})"
- case q"$zipped.map({ case ($l, $r) => $exp })" =>
- q"${simplify(zipped)}.map({ case ($l, $r) => ${simplify(exp)} })"
- case q"$zipped.forall({ case($l, $r) => $exp })" =>
- q"${simplify(zipped)}.forall({ case($l, $r) => ${simplify(exp)} })"
- case q"$_.LazyList(..$terms)" => q"$LazyListObj(..${terms.map(simplify)})"
- case q"$_.Seq(..$terms)" => q"$SeqObj(..${terms.map(simplify)})"
- case q"$l #:: $r" => q"${simplify(l)} #:: ${simplify(r)}"
- case q"$l #::: $r" => q"${simplify(l)} #::: ${simplify(r)}"
- case q"$l ++ $r" => q"${simplify(l)} ++ ${simplify(r)}"
- case q"$l && $r" => q"${simplify(l)} && ${simplify(r)}"
- case q"$l || $r" => q"${simplify(l)} || ${simplify(r)}"
- case q"$l == $r" => q"${simplify(l)} == ${simplify(r)}"
- case q"$l.$r" => q"${simplify(l)}.$r"
- case q"($l, $r)" => q"(${simplify(l)}, ${simplify(r)})"
- case q"$inner.to($_.LazyList)" => q"${simplify(inner)}.to($LazyListObj)"
- case q"$l.zip($r)" => q"${simplify(l)}.zip(${simplify(r)})"
-
- case q"$_.Seq.empty[$_]" => term
- case _: Term.Name | q"true" | q"false" | q"this" => term
- case q"$_.compare($_)" => term
- case q"$_.MatchingDeclaration(..$_)" => term
- case q"$_.MatchingReference(..$_)" => term
- case q"$_.StructuralDifference(..$_)" => term
- case other =>
- println(s"[warn] [ColHelper] Not recursing simplifier into unknown term $term")
- other
- }
+ private def recurse(term: Term): Term =
+ term match {
+ // Exception: immediately push .to(LazyList) inwards, since we can further simplify the subterms.
+ case q"(if($cond) $whenTrue else $whenFalse).to(${`LazyListObj`})" =>
+ simplify(
+ q"if($cond) $whenTrue.to($LazyListObj) else $whenFalse.to($LazyListObj)"
+ )
+
+ case q"if($cond) $whenTrue else $whenFalse" =>
+ q"if(${simplify(cond)}) ${simplify(whenTrue)} else ${simplify(whenFalse)}"
+ case q"$xs.flatMap($arg => $exp)" =>
+ q"${simplify(xs)}.flatMap($arg => ${simplify(exp)})"
+ case q"$zipped.flatMap({ case ($l, $r) => $exp })" =>
+ q"${simplify(zipped)}.flatMap({ case ($l, $r) => ${simplify(exp)} })"
+ case q"$xs.map($arg => $exp)" =>
+ q"${simplify(xs)}.map($arg => ${simplify(exp)})"
+ case q"$zipped.map({ case ($l, $r) => $exp })" =>
+ q"${simplify(zipped)}.map({ case ($l, $r) => ${simplify(exp)} })"
+ case q"$zipped.forall({ case($l, $r) => $exp })" =>
+ q"${simplify(zipped)}.forall({ case($l, $r) => ${simplify(exp)} })"
+ case q"$_.LazyList(..$terms)" => q"$LazyListObj(..${terms.map(simplify)})"
+ case q"$_.Seq(..$terms)" => q"$SeqObj(..${terms.map(simplify)})"
+ case q"$l #:: $r" => q"${simplify(l)} #:: ${simplify(r)}"
+ case q"$l #::: $r" => q"${simplify(l)} #::: ${simplify(r)}"
+ case q"$l ++ $r" => q"${simplify(l)} ++ ${simplify(r)}"
+ case q"$l && $r" => q"${simplify(l)} && ${simplify(r)}"
+ case q"$l || $r" => q"${simplify(l)} || ${simplify(r)}"
+ case q"$l == $r" => q"${simplify(l)} == ${simplify(r)}"
+ case q"$l.$r" => q"${simplify(l)}.$r"
+ case q"($l, $r)" => q"(${simplify(l)}, ${simplify(r)})"
+ case q"$inner.to($_.LazyList)" => q"${simplify(inner)}.to($LazyListObj)"
+ case q"$l.zip($r)" => q"${simplify(l)}.zip(${simplify(r)})"
+
+ case q"$_.Seq.empty[$_]" => term
+ case _: Term.Name | q"true" | q"false" | q"this" => term
+ case q"$_.compare($_)" => term
+ case q"$_.MatchingDeclaration(..$_)" => term
+ case q"$_.MatchingReference(..$_)" => term
+ case q"$_.StructuralDifference(..$_)" => term
+ case other =>
+ println(
+ s"[warn] [ColHelper] Not recursing simplifier into unknown term $term"
+ )
+ other
+ }
@tailrec
- private def simplifyFlatly(term: Term): Term = simplifyFlatly(term match {
- case q"true && $bool" => bool
- case q"$bool && true" => bool
- case q"false && $bool" => q"false"
- case q"$bool && false" => q"false"
-
- case q"true || $bool" => q"true"
- case q"$bool || true" => q"true"
- case q"false || $bool" => bool
- case q"$bool || false" => bool
-
- case q"$_.LazyList() #::: $xs" => xs
- case q"$xs #::: $_.LazyList()" => xs
- case q"$_.Seq.empty[$_] ++ $xs" => xs
- case q"$xs ++ $_.Seq.empty[$_]" => xs
-
- case q"if(true) $whenTrue else $_" => whenTrue
- case q"if(false) $_ else $whenFalse" => whenFalse
-
- case q"$_.flatMap({ case ($l, $r) => $_.LazyList() })" => q"$LazyListObj()"
- case q"$_.flatMap($_ => $_.Seq.empty[$t])" => q"$SeqObj.empty[$t]"
- case q"$xs.flatMap($arg => $_.Seq($y))" => q"$xs.map($arg => $y)"
- case q"$_.forall({ case ($l, $r) => true })" => q"true"
-
- case q"if($cond) $whenTrue else $whenFalse" if whenTrue.getClass == whenFalse.getClass && whenTrue.show[Structure] == whenFalse.show[Structure] =>
- whenTrue
-
- case q"$xs.map(${Term.Param(_, Term.Name(x), _, _)} => ${Term.Name(y)})" if x == y =>
- xs
-
- case q"($a #::: $b) #::: $c" => q"$a #::: $b #::: $c"
- case q"$a ++ ($b ++ $c)" => q"$a ++ $b ++ $c"
-
- case q"$_.LazyList($x) #::: $xs" => q"$x #:: $xs"
- case q"$_.Seq($x) ++ $xs" => q"$x +: $xs"
-
- case other => return other
- })
+ private def simplifyFlatly(term: Term): Term =
+ simplifyFlatly(term match {
+ case q"true && $bool" => bool
+ case q"$bool && true" => bool
+ case q"false && $bool" => q"false"
+ case q"$bool && false" => q"false"
+
+ case q"true || $bool" => q"true"
+ case q"$bool || true" => q"true"
+ case q"false || $bool" => bool
+ case q"$bool || false" => bool
+
+ case q"$_.LazyList() #::: $xs" => xs
+ case q"$xs #::: $_.LazyList()" => xs
+ case q"$_.Seq.empty[$_] ++ $xs" => xs
+ case q"$xs ++ $_.Seq.empty[$_]" => xs
+
+ case q"if(true) $whenTrue else $_" => whenTrue
+ case q"if(false) $_ else $whenFalse" => whenFalse
+
+ case q"$_.flatMap({ case ($l, $r) => $_.LazyList() })" =>
+ q"$LazyListObj()"
+ case q"$_.flatMap($_ => $_.Seq.empty[$t])" => q"$SeqObj.empty[$t]"
+ case q"$xs.flatMap($arg => $_.Seq($y))" => q"$xs.map($arg => $y)"
+ case q"$_.forall({ case ($l, $r) => true })" => q"true"
+
+ case q"if($cond) $whenTrue else $whenFalse"
+ if whenTrue.getClass == whenFalse.getClass &&
+ whenTrue.show[Structure] == whenFalse.show[Structure] =>
+ whenTrue
+
+ case q"$xs.map(${Term.Param(_, Term.Name(x), _, _)} => ${Term.Name(y)})"
+ if x == y =>
+ xs
+
+ case q"($a #::: $b) #::: $c" => q"$a #::: $b #::: $c"
+ case q"$a ++ ($b ++ $c)" => q"$a ++ $b ++ $c"
+
+ case q"$_.LazyList($x) #::: $xs" => q"$x #:: $xs"
+ case q"$_.Seq($x) ++ $xs" => q"$x +: $xs"
+
+ case other => return other
+ })
}
diff --git a/src/helpers/vct/col/ast/helpers/generator/AbstractRewriter.scala b/src/helpers/vct/col/ast/helpers/generator/AbstractRewriter.scala
index d3daaa3dd1..9e80121191 100644
--- a/src/helpers/vct/col/ast/helpers/generator/AbstractRewriter.scala
+++ b/src/helpers/vct/col/ast/helpers/generator/AbstractRewriter.scala
@@ -9,11 +9,21 @@ import java.nio.file.Path
import scala.meta._
class AbstractRewriter extends AllFamiliesGenerator {
- override def generate(out: Path, declaredFamilies: Seq[structure.Name], structuralFamilies: Seq[structure.Name]): Unit =
- ResultStream.write(out.resolve("AbstractRewriter.scala"), getArw(declaredFamilies, structuralFamilies))
+ override def generate(
+ out: Path,
+ declaredFamilies: Seq[structure.Name],
+ structuralFamilies: Seq[structure.Name],
+ ): Unit =
+ ResultStream.write(
+ out.resolve("AbstractRewriter.scala"),
+ getArw(declaredFamilies, structuralFamilies),
+ )
// TODO: anySucc should probably use the succProvider - how?
- def getArw(declaredFamilies: Seq[structure.Name], structuralFamilies: Seq[structure.Name]): Source =
+ def getArw(
+ declaredFamilies: Seq[structure.Name],
+ structuralFamilies: Seq[structure.Name],
+ ): Source =
source"""
package vct.col.ast
diff --git a/src/helpers/vct/col/ast/helpers/generator/AllFrozenScopes.scala b/src/helpers/vct/col/ast/helpers/generator/AllFrozenScopes.scala
index c685c7807f..cc87d17d19 100644
--- a/src/helpers/vct/col/ast/helpers/generator/AllFrozenScopes.scala
+++ b/src/helpers/vct/col/ast/helpers/generator/AllFrozenScopes.scala
@@ -9,8 +9,15 @@ import java.nio.file.Path
import scala.meta._
class AllFrozenScopes extends AllFamiliesGenerator {
- override def generate(out: Path, declaredFamilies: Seq[structure.Name], structuralFamilies: Seq[structure.Name]): Unit =
- ResultStream.write(out.resolve("AllFrozenScopes.scala"), allFrozenScopes(declaredFamilies))
+ override def generate(
+ out: Path,
+ declaredFamilies: Seq[structure.Name],
+ structuralFamilies: Seq[structure.Name],
+ ): Unit =
+ ResultStream.write(
+ out.resolve("AllFrozenScopes.scala"),
+ allFrozenScopes(declaredFamilies),
+ )
def allFrozenScopes(declaredFamilies: Seq[structure.Name]): Source =
source"""
@@ -19,7 +26,9 @@ class AllFrozenScopes extends AllFamiliesGenerator {
class AllFrozenScopes[Pre, Post](`~scopes`: $AllScopes[Pre, Post]) extends ${Init(t"$SuccessorsProvider[Pre, Post]", Name.Anonymous(), List.empty)} {
override def equals(`~obj`: $Any): $Boolean = `~obj` match {
case other: $AllFrozenScopes[_, _] =>
- ${declaredFamilies.map(name => q"this.${scopes(name.base)} == other.${scopes(name.base)}").reduce[Term] { case (l, r) => q"$l && $r" } }
+ ${declaredFamilies
+ .map(name => q"this.${scopes(name.base)} == other.${scopes(name.base)}")
+ .reduce[Term] { case (l, r) => q"$l && $r" }}
case _ => false
}
diff --git a/src/helpers/vct/col/ast/helpers/generator/AllScopes.scala b/src/helpers/vct/col/ast/helpers/generator/AllScopes.scala
index 904330915f..e3a5b85b90 100644
--- a/src/helpers/vct/col/ast/helpers/generator/AllScopes.scala
+++ b/src/helpers/vct/col/ast/helpers/generator/AllScopes.scala
@@ -9,8 +9,13 @@ import java.nio.file.Path
import scala.meta._
class AllScopes extends AllFamiliesGenerator {
- override def generate(out: Path, declaredFamilies: Seq[structure.Name], structuralFamilies: Seq[structure.Name]): Unit =
- ResultStream.write(out.resolve("AllScopes.scala"), allScopes(declaredFamilies))
+ override def generate(
+ out: Path,
+ declaredFamilies: Seq[structure.Name],
+ structuralFamilies: Seq[structure.Name],
+ ): Unit =
+ ResultStream
+ .write(out.resolve("AllScopes.scala"), allScopes(declaredFamilies))
def allScopes(declaredFamilies: Seq[structure.Name]): Source =
source"""
@@ -20,14 +25,15 @@ class AllScopes extends AllFamiliesGenerator {
def freeze: $AllFrozenScopes[Pre, Post] = new $AllFrozenScopes(this)
def anyDeclare[T <: $Declaration[Post]](`~decl`: T): T =
- ${Term.Match(q"`~decl`", declaredFamilies.map(name =>
- Case(p"decl: ${typ(name)}[Post]", None, q"${scopes(name.base)}.declare(decl); `~decl`")
- ).toList)}
+ ${Term.Match(q"`~decl`", declaredFamilies.map(name => Case(p"decl: ${typ(name)}[Post]", None, q"${scopes(name.base)}.declare(decl); `~decl`")).toList)}
def anySucceedOnly[T <: $Declaration[Post]](`~pre`: $Declaration[Pre], `~post`: T)(implicit tag: $ClassTag[T]): T =
- ${Term.Match(q"(`~pre`, `~post`)", declaredFamilies.map(name =>
- Case(p"(pre: ${typ(name)}[Pre], post: ${typ(name)}[Post])", None, q"${scopes(name.base)}.succeedOnly(pre, post); `~post`")
- ).toList :+ Case(p"(pre, post)", None, q"throw $InconsistentSuccessionTypesObj(pre, post)"))}
+ ${Term.Match(
+ q"(`~pre`, `~post`)",
+ declaredFamilies.map(name =>
+ Case(p"(pre: ${typ(name)}[Pre], post: ${typ(name)}[Post])", None, q"${scopes(name.base)}.succeedOnly(pre, post); `~post`")
+ ).toList :+ Case(p"(pre, post)", None, q"throw $InconsistentSuccessionTypesObj(pre, post)"),
+ )}
def anySucceed[T <: $Declaration[Post]](`~pre`: $Declaration[Pre], `~post`: T)(implicit tag: $ClassTag[T]): T = {
anyDeclare(`~post`)
@@ -44,4 +50,4 @@ class AllScopes extends AllFamiliesGenerator {
""").toList}
}
"""
-}
\ No newline at end of file
+}
diff --git a/src/helpers/vct/col/ast/helpers/generator/BaseCoercingRewriter.scala b/src/helpers/vct/col/ast/helpers/generator/BaseCoercingRewriter.scala
index 3a05a6db70..045c517e98 100644
--- a/src/helpers/vct/col/ast/helpers/generator/BaseCoercingRewriter.scala
+++ b/src/helpers/vct/col/ast/helpers/generator/BaseCoercingRewriter.scala
@@ -1,6 +1,13 @@
package vct.col.ast.helpers.generator
-import vct.col.ast.helpers.defn.Constants.{AbstractRewriter, ApplyCoercionPat, Coercion, Expr, ExprName, Origin}
+import vct.col.ast.helpers.defn.Constants.{
+ AbstractRewriter,
+ ApplyCoercionPat,
+ Coercion,
+ Expr,
+ ExprName,
+ Origin,
+}
import vct.col.ast.helpers.defn.Naming.typ
import vct.col.ast.structure
import vct.col.ast.structure.AllFamiliesGenerator
@@ -9,8 +16,13 @@ import java.nio.file.Path
import scala.meta._
class BaseCoercingRewriter extends AllFamiliesGenerator {
- override def generate(out: Path, declaredFamilies: Seq[structure.Name], structuralFamilies: Seq[structure.Name]): Unit =
- ResultStream.write(out.resolve("BaseCoercingRewriter.scala"), crw(structuralFamilies))
+ override def generate(
+ out: Path,
+ declaredFamilies: Seq[structure.Name],
+ structuralFamilies: Seq[structure.Name],
+ ): Unit =
+ ResultStream
+ .write(out.resolve("BaseCoercingRewriter.scala"), crw(structuralFamilies))
def crw(families: Seq[structure.Name]): Source =
source"""
@@ -27,8 +39,10 @@ class BaseCoercingRewriter extends AllFamiliesGenerator {
"""
def dispatch(family: structure.Name): Defn.Def =
- if(family == ExprName) dispatchExpr
- else dispatchNonExpr(family)
+ if (family == ExprName)
+ dispatchExpr
+ else
+ dispatchNonExpr(family)
def dispatchExpr: Defn.Def =
q"""
diff --git a/src/helpers/vct/col/ast/helpers/generator/BaseNonLatchingRewriter.scala b/src/helpers/vct/col/ast/helpers/generator/BaseNonLatchingRewriter.scala
index 99d25b8a94..3ee6b5721c 100644
--- a/src/helpers/vct/col/ast/helpers/generator/BaseNonLatchingRewriter.scala
+++ b/src/helpers/vct/col/ast/helpers/generator/BaseNonLatchingRewriter.scala
@@ -9,10 +9,20 @@ import java.nio.file.Path
import scala.meta._
class BaseNonLatchingRewriter extends AllFamiliesGenerator {
- override def generate(out: Path, declaredFamilies: Seq[structure.Name], structuralFamilies: Seq[structure.Name]): Unit =
- ResultStream.write(out.resolve("BaseNonLatchingRewriter.scala"), rw(declaredFamilies, structuralFamilies))
+ override def generate(
+ out: Path,
+ declaredFamilies: Seq[structure.Name],
+ structuralFamilies: Seq[structure.Name],
+ ): Unit =
+ ResultStream.write(
+ out.resolve("BaseNonLatchingRewriter.scala"),
+ rw(declaredFamilies, structuralFamilies),
+ )
- def rw(declaredFamilies: Seq[structure.Name], structuralFamilies: Seq[structure.Name]): Source =
+ def rw(
+ declaredFamilies: Seq[structure.Name],
+ structuralFamilies: Seq[structure.Name],
+ ): Source =
source"""
package vct.col.ast.rewrite
diff --git a/src/helpers/vct/col/ast/helpers/generator/Compare.scala b/src/helpers/vct/col/ast/helpers/generator/Compare.scala
index 5b177d54b9..4928efb198 100644
--- a/src/helpers/vct/col/ast/helpers/generator/Compare.scala
+++ b/src/helpers/vct/col/ast/helpers/generator/Compare.scala
@@ -1,6 +1,15 @@
package vct.col.ast.helpers.generator
-import vct.col.ast.helpers.defn.Constants.{ComparePackage, CompareResult, LazyList, LazyListObj, MatchingDeclarationObj, MatchingReferenceObj, Node, StructuralDifferenceObj}
+import vct.col.ast.helpers.defn.Constants.{
+ ComparePackage,
+ CompareResult,
+ LazyList,
+ LazyListObj,
+ MatchingDeclarationObj,
+ MatchingReferenceObj,
+ Node,
+ StructuralDifferenceObj,
+}
import vct.col.ast.helpers.defn.Naming.{compareTrait, typ}
import vct.col.ast.helpers.defn.Simplify.simplify
import vct.col.ast.structure
@@ -13,7 +22,8 @@ import scala.util.Using
class Compare extends NodeGenerator {
override def generate(out: Path, node: NodeDefinition): Unit =
- ResultStream.write(out.resolve(s"${node.name.base}Compare.scala"), getTree(node))
+ ResultStream
+ .write(out.resolve(s"${node.name.base}Compare.scala"), getTree(node))
def getTree(node: NodeDefinition): Source = {
source"""
@@ -35,33 +45,30 @@ class Compare extends NodeGenerator {
val refs = compareRefs(left, right, node)
val subnodes = compareSubnodes(left, right, node)
- simplify(
- q"""
- if($valuesEqual) ${
- if(node.kind == DeclaredNode) q"$MatchingDeclarationObj($left, $right) #:: $refs #::: $subnodes"
- else q"$refs #::: $subnodes"
- } else $LazyListObj($StructuralDifferenceObj($left, $right))
- """
- )
+ simplify(q"""
+ if($valuesEqual) ${if (node.kind == DeclaredNode)
+ q"$MatchingDeclarationObj($left, $right) #:: $refs #::: $subnodes"
+ else
+ q"$refs #::: $subnodes"} else $LazyListObj($StructuralDifferenceObj($left, $right))
+ """)
}
def compareValues(left: Term, right: Term, node: NodeDefinition): Term =
- node.fields.map {
- case (fieldName, t) =>
- val field = Term.Name(fieldName)
- compareValues(q"$left.$field", q"$right.$field", t)
+ node.fields.map { case (fieldName, t) =>
+ val field = Term.Name(fieldName)
+ compareValues(q"$left.$field", q"$right.$field", t)
}.reduceOption((l, r) => q"$l && $r").getOrElse(q"true")
def compareValues(left: Term, right: Term, t: structure.Type): Term =
t match {
- case structure.Type.Node(_) |
- structure.Type.Declaration(_) => q"true"
+ case structure.Type.Node(_) | structure.Type.Declaration(_) => q"true"
case structure.Type.Ref(_) | structure.Type.MultiRef(_) => q"true"
case _: structure.Type.PrimitiveType => q"$left == $right"
- case structure.Type.Option(t) => q"$left.isEmpty == $right.isEmpty && ($left.isEmpty || ${compareValues(q"$left.get", q"$right.get", t)})"
+ case structure.Type.Option(t) =>
+ q"$left.isEmpty == $right.isEmpty && ($left.isEmpty || ${compareValues(q"$left.get", q"$right.get", t)})"
case structure.Type.Either(l, r) =>
q"""
@@ -73,62 +80,76 @@ class Compare extends NodeGenerator {
"""
case structure.Type.Tuple(ts) =>
- ts.zipWithIndex.map {
- case (t, i) =>
- val field = Term.Name(s"_${i+1}")
- compareValues(q"$left.$field", q"$right.$field", t)
+ ts.zipWithIndex.map { case (t, i) =>
+ val field = Term.Name(s"_${i + 1}")
+ compareValues(q"$left.$field", q"$right.$field", t)
}.reduce((l, r) => q"$l && $r")
- case structure.Type.Seq(t) => q"$left.size == $right.size && $left.zip($right).forall { case (l0, r0) => ${compareValues(q"l0", q"r0", t)} }"
+ case structure.Type.Seq(t) =>
+ q"$left.size == $right.size && $left.zip($right).forall { case (l0, r0) => ${compareValues(q"l0", q"r0", t)} }"
case structure.Type.DeclarationSeq(_) => q"$left.size == $right.size"
}
def compareRefs(left: Term, right: Term, node: NodeDefinition): Term =
- node.fields.foldRight[Term](q"$LazyListObj()") {
- case ((field, t), acc) =>
- val fieldValues = compareRefs(q"$left.${Term.Name(field)}", q"$right.${Term.Name(field)}", t)
- q"$fieldValues #::: $acc"
+ node.fields.foldRight[Term](q"$LazyListObj()") { case ((field, t), acc) =>
+ val fieldValues = compareRefs(
+ q"$left.${Term.Name(field)}",
+ q"$right.${Term.Name(field)}",
+ t,
+ )
+ q"$fieldValues #::: $acc"
}
def compareRefs(left: Term, right: Term, t: structure.Type): Term =
t match {
- case structure.Type.Node(_) | structure.Type.Declaration(_) | structure.Type.DeclarationSeq(_) => q"$LazyListObj()"
- case structure.Type.Ref(_) | structure.Type.MultiRef(_) => q"$LazyListObj($MatchingReferenceObj($left.decl, $right.decl))"
+ case structure.Type.Node(_) | structure.Type.Declaration(_) | structure
+ .Type.DeclarationSeq(_) =>
+ q"$LazyListObj()"
+ case structure.Type.Ref(_) | structure.Type.MultiRef(_) =>
+ q"$LazyListObj($MatchingReferenceObj($left.decl, $right.decl))"
case _: structure.Type.PrimitiveType => q"$LazyListObj()"
- case structure.Type.Option(t) => q"if($left.isDefined) ${compareRefs(q"$left.get", q"$right.get", t)} else $LazyListObj()"
+ case structure.Type.Option(t) =>
+ q"if($left.isDefined) ${compareRefs(q"$left.get", q"$right.get", t)} else $LazyListObj()"
case structure.Type.Either(l, r) =>
q"if($left.isLeft) ${compareRefs(q"$left.left", q"$right.left", l)} else ${compareRefs(q"$left.right", q"$right.right", r)}"
case structure.Type.Tuple(ts) =>
- ts.zipWithIndex.map {
- case (t, i) =>
- val field = Term.Name(s"_${i+1}")
- compareRefs(q"$left.$field", q"$right.$field", t)
+ ts.zipWithIndex.map { case (t, i) =>
+ val field = Term.Name(s"_${i + 1}")
+ compareRefs(q"$left.$field", q"$right.$field", t)
}.reduce((l, r) => q"$l #::: $r")
- case structure.Type.Seq(t) => q"$left.zip($right).to($LazyListObj).flatMap { case (l0, r0) => ${compareRefs(q"l0", q"r0", t)} }"
+ case structure.Type.Seq(t) =>
+ q"$left.zip($right).to($LazyListObj).flatMap { case (l0, r0) => ${compareRefs(q"l0", q"r0", t)} }"
}
def compareSubnodes(left: Term, right: Term, node: NodeDefinition): Term =
- node.fields.foldRight[Term](q"$LazyListObj()") {
- case ((field, t), acc) =>
- val fieldValues = compareSubnodes(q"$left.${Term.Name(field)}", q"$right.${Term.Name(field)}", t)
- q"$fieldValues #::: $acc"
+ node.fields.foldRight[Term](q"$LazyListObj()") { case ((field, t), acc) =>
+ val fieldValues = compareSubnodes(
+ q"$left.${Term.Name(field)}",
+ q"$right.${Term.Name(field)}",
+ t,
+ )
+ q"$fieldValues #::: $acc"
}
def compareSubnodes(left: Term, right: Term, t: structure.Type): Term =
t match {
- case structure.Type.Node(_) | structure.Type.Declaration(_) => q"$left.compare($right)"
- case structure.Type.Ref(_) | structure.Type.MultiRef(_) => q"$LazyListObj()"
+ case structure.Type.Node(_) | structure.Type.Declaration(_) =>
+ q"$left.compare($right)"
+ case structure.Type.Ref(_) | structure.Type.MultiRef(_) =>
+ q"$LazyListObj()"
case _: structure.Type.PrimitiveType => q"$LazyListObj()"
- case structure.Type.Option(t) => q"if($left.isDefined) ${compareSubnodes(q"$left.get", q"$right.get", t)} else $LazyListObj()"
+ case structure.Type.Option(t) =>
+ q"if($left.isDefined) ${compareSubnodes(q"$left.get", q"$right.get", t)} else $LazyListObj()"
case structure.Type.Either(l, r) =>
q"if($left.isLeft) ${compareSubnodes(q"$left.left", q"$right.left", l)} else ${compareSubnodes(q"$left.right", q"$right.right", r)}"
case structure.Type.Tuple(ts) =>
- ts.zipWithIndex.map {
- case (t, i) =>
- val field = Term.Name(s"_${i+1}")
- compareSubnodes(q"$left.$field", q"$right.$field", t)
+ ts.zipWithIndex.map { case (t, i) =>
+ val field = Term.Name(s"_${i + 1}")
+ compareSubnodes(q"$left.$field", q"$right.$field", t)
}.reduce((l, r) => q"$l #::: $r")
- case structure.Type.Seq(t) => q"$left.zip($right).to($LazyListObj).flatMap { case (l0, r0) => ${compareSubnodes(q"l0", q"r0", t)} }"
- case structure.Type.DeclarationSeq(t) => q"$left.zip($right).to($LazyListObj).flatMap { case (l0, r0) => l0.compare(r0) }"
+ case structure.Type.Seq(t) =>
+ q"$left.zip($right).to($LazyListObj).flatMap { case (l0, r0) => ${compareSubnodes(q"l0", q"r0", t)} }"
+ case structure.Type.DeclarationSeq(t) =>
+ q"$left.zip($right).to($LazyListObj).flatMap { case (l0, r0) => l0.compare(r0) }"
}
}
diff --git a/src/helpers/vct/col/ast/helpers/generator/DeclareFamily.scala b/src/helpers/vct/col/ast/helpers/generator/DeclareFamily.scala
index 3ff210c43d..9e9397d316 100644
--- a/src/helpers/vct/col/ast/helpers/generator/DeclareFamily.scala
+++ b/src/helpers/vct/col/ast/helpers/generator/DeclareFamily.scala
@@ -9,9 +9,17 @@ import java.nio.file.Path
import scala.meta._
class DeclareFamily extends FamilyGenerator {
- override def generate(out: Path, family: structure.Name, kind: NodeKind, nodes: Seq[structure.Name]): Unit =
- if(kind == DeclaredNode) {
- ResultStream.write(out.resolve(s"${family.base}FamilyDeclare.scala"), getDeclare(family))
+ override def generate(
+ out: Path,
+ family: structure.Name,
+ kind: NodeKind,
+ nodes: Seq[structure.Name],
+ ): Unit =
+ if (kind == DeclaredNode) {
+ ResultStream.write(
+ out.resolve(s"${family.base}FamilyDeclare.scala"),
+ getDeclare(family),
+ )
}
def getDeclare(name: structure.Name): Source =
diff --git a/src/helpers/vct/col/ast/helpers/generator/Deserialize.scala b/src/helpers/vct/col/ast/helpers/generator/Deserialize.scala
index 96413ec22a..e74528ce42 100644
--- a/src/helpers/vct/col/ast/helpers/generator/Deserialize.scala
+++ b/src/helpers/vct/col/ast/helpers/generator/Deserialize.scala
@@ -3,14 +3,23 @@ package vct.col.ast.helpers.generator
import vct.col.ast.helpers.defn.Constants._
import vct.col.ast.helpers.defn.Naming._
import vct.col.ast.helpers.defn.{Proto, ProtoNaming}
-import vct.col.ast.structure.{DeclaredNode, NodeDefinition, NodeGenerator, NodeKind, Type => ST}
+import vct.col.ast.structure.{
+ DeclaredNode,
+ NodeDefinition,
+ NodeGenerator,
+ NodeKind,
+ Type => ST,
+}
import java.nio.file.Path
import scala.meta._
class Deserialize extends NodeGenerator {
override def generate(out: Path, node: NodeDefinition): Unit =
- ResultStream.write(out.resolve("Deserialize" + node.name.base + ".scala"), deserialize(node))
+ ResultStream.write(
+ out.resolve("Deserialize" + node.name.base + ".scala"),
+ deserialize(node),
+ )
def deserialize(node: NodeDefinition): Source =
source"""
@@ -23,16 +32,16 @@ class Deserialize extends NodeGenerator {
"""
def deserializeNode(term: Term, node: NodeDefinition): Term = {
- val fields = node.fields.map {
- case (name, structuralType) =>
+ val fields =
+ node.fields.map { case (name, structuralType) =>
val scalapbName = ProtoNaming.camel(ProtoNaming.snake(name))
val fieldTerm = q"$term.${Term.Name(scalapbName)}"
val protoType = ProtoNaming.getType(structuralType).t
deserializeTerm(fieldTerm, protoType, structuralType)
- }.toList
+ }.toList
val instance =
- if(node.blameType.isEmpty)
+ if (node.blameType.isEmpty)
q"new ${t"${typ(node)}[G]"}(..$fields)($SerializeOrigin.deserialize($term.origin))"
else
q"""
@@ -42,7 +51,7 @@ class Deserialize extends NodeGenerator {
}
"""
- if(node.kind == DeclaredNode)
+ if (node.kind == DeclaredNode)
q"{ val res = $instance; decls($term.id) = res; res }"
else
instance
@@ -55,24 +64,29 @@ class Deserialize extends NodeGenerator {
throw new IllegalArgumentException()
}
- def deserializeTerm(term: Term, protoType: Proto.Type, structuralType: ST): Term =
+ def deserializeTerm(
+ term: Term,
+ protoType: Proto.Type,
+ structuralType: ST,
+ ): Term =
(protoType, structuralType) match {
- case (Proto.Required(pt), st) =>
- deserializeTerm(term, pt, st)
+ case (Proto.Required(pt), st) => deserializeTerm(term, pt, st)
case (Proto.Option(pt), ST.Option(st)) =>
q"$term.map(`~x` => ${deserializeTerm(q"`~x`", pt, st)})"
case (Proto.Repeated(pt), ST.Seq(st)) =>
q"$term.map(`~x` => ${deserializeTerm(q"`~x`", pt, st)})"
case (Proto.Repeated(_), ST.DeclarationSeq(name)) =>
q"$term.map(`~x` => ${deserializeFamilyObject(name)}.deserialize[G](`~x`.parseAs[${scalapbType(name)}], decls))"
- case (pt, st) =>
- err(pt, st)
+ case (pt, st) => err(pt, st)
}
- def deserializeTerm(term: Term, protoType: Proto.PrimitiveType, structuralType: ST): Term =
+ def deserializeTerm(
+ term: Term,
+ protoType: Proto.PrimitiveType,
+ structuralType: ST,
+ ): Term =
(protoType, structuralType) match {
- case (_, ST.Seq(ST.ExpectedError)) =>
- q"$SeqObj.empty"
+ case (_, ST.Seq(ST.ExpectedError)) => q"$SeqObj.empty"
case (Proto.FamilyType(_), ST.Node(name)) =>
q"${deserializeFamilyObject(name)}.deserialize[G]($term.parseAs[${scalapbType(name)}], decls)"
@@ -83,16 +97,9 @@ class Deserialize extends NodeGenerator {
case (Proto.StandardType(_), ST.MultiRef(node)) =>
q"new ${Init(t"$LazyRef[G, ${typ(node.name)}[G]]", Name.Anonymous(), List(List(q"decls($term.id)")))}"
case (Proto.AuxType(_), ST.Tuple(args)) =>
- q"(..${
- args.zipWithIndex.map {
- case (structuralType, index) =>
- deserializeTerm(
- q"$term.${Term.Name(s"v${index + 1}")}",
- ProtoNaming.getType(structuralType).t,
- structuralType
- )
- }.toList
- })"
+ q"(..${args.zipWithIndex.map { case (structuralType, index) =>
+ deserializeTerm(q"$term.${Term.Name(s"v${index + 1}")}", ProtoNaming.getType(structuralType).t, structuralType)
+ }.toList})"
case (Proto.AuxType(_), ST.Seq(structuralType)) =>
q"$term.value.map(`~x` => ${deserializeTerm(q"`~x`", ProtoNaming.getType(structuralType).t, structuralType)})"
case (Proto.AuxType(_), ST.DeclarationSeq(name)) =>
@@ -104,38 +111,25 @@ class Deserialize extends NodeGenerator {
if($term.either.isLeft) ${deserializeTerm(q"$term.left.get.value", ProtoNaming.getPrimitiveType(left).t, left)}
else ${deserializeTerm(q"$term.right.get.value", ProtoNaming.getPrimitiveType(right).t, right)}
"""
- case (Proto.Bool, ST.Nothing) =>
- q"???"
- case (Proto.Bool, ST.Unit) =>
- q"()"
- case (Proto.String, ST.String) =>
- term
+ case (Proto.Bool, ST.Nothing) => q"???"
+ case (Proto.Bool, ST.Unit) => q"()"
+ case (Proto.String, ST.String) => term
case (Proto.StandardType(_), ST.BigInt) =>
q"new $BigInt(new $BigInteger($term.data.toByteArray))"
case (Proto.StandardType(_), ST.BigDecimal) =>
q"new $BigDecimal(new $JBigDecimal(new $BigInteger($term.unscaledValue.data.toByteArray), $term.scale))"
case (Proto.StandardType(_), ST.BitString) =>
q"new $BitString($term.data.toByteArray, $term.skipAtLastByte)"
- case (Proto.StandardType(_), ST.ExpectedError) =>
- q"???"
- case (Proto.Bool, ST.Boolean) =>
- term
- case (Proto.Int, ST.Byte) =>
- q"$term.toByte"
- case (Proto.Int, ST.Short) =>
- q"$term.toShort"
- case (Proto.Int, ST.Int) =>
- term
- case (Proto.Long, ST.Long) =>
- term
- case (Proto.Float, ST.Float) =>
- term
- case (Proto.Double, ST.Double) =>
- term
- case (Proto.Int, ST.Char) =>
- q"$term.toChar"
- case (pt, st) =>
- err(pt, st)
+ case (Proto.StandardType(_), ST.ExpectedError) => q"???"
+ case (Proto.Bool, ST.Boolean) => term
+ case (Proto.Int, ST.Byte) => q"$term.toByte"
+ case (Proto.Int, ST.Short) => q"$term.toShort"
+ case (Proto.Int, ST.Int) => term
+ case (Proto.Long, ST.Long) => term
+ case (Proto.Float, ST.Float) => term
+ case (Proto.Double, ST.Double) => term
+ case (Proto.Int, ST.Char) => q"$term.toChar"
+ case (pt, st) => err(pt, st)
}
}
diff --git a/src/helpers/vct/col/ast/helpers/generator/DeserializeFamily.scala b/src/helpers/vct/col/ast/helpers/generator/DeserializeFamily.scala
index 301b582b49..d074374663 100644
--- a/src/helpers/vct/col/ast/helpers/generator/DeserializeFamily.scala
+++ b/src/helpers/vct/col/ast/helpers/generator/DeserializeFamily.scala
@@ -8,8 +8,16 @@ import java.nio.file.Path
import scala.meta._
class DeserializeFamily extends FamilyGenerator {
- override def generate(out: Path, family: Name, kind: NodeKind, nodes: Seq[Name]): Unit =
- ResultStream.write(out.resolve("DeserializeFamily" + family.base + ".scala"), deserializeFamily(family, nodes))
+ override def generate(
+ out: Path,
+ family: Name,
+ kind: NodeKind,
+ nodes: Seq[Name],
+ ): Unit =
+ ResultStream.write(
+ out.resolve("DeserializeFamily" + family.base + ".scala"),
+ deserializeFamily(family, nodes),
+ )
def deserializeFamily(name: Name, nodes: Seq[Name]): Source =
source"""
@@ -17,16 +25,25 @@ class DeserializeFamily extends FamilyGenerator {
object ${Term.Name(deserializeFamilyName(name))} {
def deserialize[G](node: ${scalapbType(name)}, decls: $MutMap[$Long, $Declaration[G]]): ${typ(name)}[G] =
- ${if(nodes == Seq(name)) q"${Term.Name(deserializeName(name))}.deserialize[G](node, decls)" else deserializeOneof(q"node.v", name, nodes)}
+ ${if (nodes == Seq(name))
+ q"${Term.Name(deserializeName(name))}.deserialize[G](node, decls)"
+ else
+ deserializeOneof(q"node.v", name, nodes)}
}
"""
def deserializeOneof(term: Term, name: Name, nodes: Seq[Name]): Term =
Term.Match(
q"$term.number: @_root_.scala.annotation.switch",
- nodes.zipWithIndex.map { case (node, index) => deserializeCase(term, node, number = index+1) }.toList,
+ nodes.zipWithIndex.map { case (node, index) =>
+ deserializeCase(term, node, number = index + 1)
+ }.toList,
)
def deserializeCase(term: Term, node: Name, number: Int): Case =
- Case(Lit.Int(number), None, q"${deserializeObject(node)}.deserialize[G]($term.value.asInstanceOf[${scalapbType(node)}], decls)")
+ Case(
+ Lit.Int(number),
+ None,
+ q"${deserializeObject(node)}.deserialize[G]($term.value.asInstanceOf[${scalapbType(node)}], decls)",
+ )
}
diff --git a/src/helpers/vct/col/ast/helpers/generator/ImplTrait.scala b/src/helpers/vct/col/ast/helpers/generator/ImplTrait.scala
index f7b4d58645..408e526ab3 100644
--- a/src/helpers/vct/col/ast/helpers/generator/ImplTrait.scala
+++ b/src/helpers/vct/col/ast/helpers/generator/ImplTrait.scala
@@ -32,65 +32,59 @@ class ImplTrait extends ImplTraitGenerator {
// Parsing rules
val stableId = s"(?:$id(?:$period$id)*)"
val selectorRule = s"(?:$underscore|$id)"
- val selectors = s"(?:$selectorRule|$acc_open$selectorRule(?:$comma$selectorRule)*$acc_close)"
+ val selectors =
+ s"(?:$selectorRule|$acc_open$selectorRule(?:$comma$selectorRule)*$acc_close)"
val importExprRule = s"(?:$stableId$period$selectors)"
val importRule = s"(?:$kwd_import($importExprRule(?:$comma$importExprRule)*))"
val lazyTyp = s"(?:$w[^\\s]+$w)"
val traitParents = s"(?:$lazyTyp($kwd_with$lazyTyp)*)"
- val traitRule = s"(?:$kwd_trait$id$brack_open$kwd_gen$brack_close(($kwd_extends$traitParents)?$acc_open))"
+ val traitRule =
+ s"(?:$kwd_trait$id$brack_open$kwd_gen$brack_close(($kwd_extends$traitParents)?$acc_open))"
val `import`: Regex = importRule.r
val `trait`: Regex = traitRule.r
val importExpr: Regex = importExprRule.r
val selector: Regex = selectorRule.r
- /**
- * This method is fragile: we attempt to do some useful fixing up by applying
- * a regex to find import lines and the declaration line. If the file becomes
- * invalid or we make wrong conclusions that's ok: the user can fix it. The
- * method won't do anything if the string {NodeName}Ops already occurs.
- *
- * I think this method should be removed once all forks/branches are in line
- * with extending the correct Ops traits, and only leave generate (which
- * should always be correct).
- */
+ /** This method is fragile: we attempt to do some useful fixing up by applying
+ * a regex to find import lines and the declaration line. If the file becomes
+ * invalid or we make wrong conclusions that's ok: the user can fix it. The
+ * method won't do anything if the string {NodeName}Ops already occurs.
+ *
+ * I think this method should be removed once all forks/branches are in line
+ * with extending the correct Ops traits, and only leave generate (which
+ * should always be correct).
+ */
def fix(p: Path, opsNames: Seq[String]): Unit = {
- if(opsNames.isEmpty)
+ if (opsNames.isEmpty)
return // obsolete or renamed impl, don't try anything.
val data = Files.readString(p)
- if(opsNames.forall(name => data.contains(name)))
+ if (opsNames.forall(name => data.contains(name)))
return // exit early if most likely the file is already fixed
val maybeTraitMatch = `trait`.findFirstMatchIn(data)
- if(maybeTraitMatch.isEmpty)
+ if (maybeTraitMatch.isEmpty)
return // silently fail if we can't detect a trait
val traitMatch = maybeTraitMatch.get
- val exts: Seq[String] =
- Option(traitMatch.group(2))
- .map(
- _.strip()
- .split("\\s+")
- .to(List)
- .map(_.strip())
- .filterNot(_ == "extends")
- .filterNot(_ == "with")
- )
- .getOrElse(Nil)
+ val exts: Seq[String] = Option(traitMatch.group(2)).map(
+ _.strip().split("\\s+").to(List).map(_.strip()).filterNot(_ == "extends")
+ .filterNot(_ == "with")
+ ).getOrElse(Nil)
val opsExts = opsNames.map(_ + "[G]")
- if(opsExts.forall(ext => exts.contains(ext)))
+ if (opsExts.forall(ext => exts.contains(ext)))
return
val allImportLines = `import`.findAllMatchIn(data).toSeq
- if(traitMatch.start < allImportLines.lastOption.map(_.end).getOrElse(-1))
+ if (traitMatch.start < allImportLines.lastOption.map(_.end).getOrElse(-1))
return // the trait is defined before the last import: give up
// Decide whether the ops thing is already included. Might happen if you
@@ -103,18 +97,25 @@ class ImplTrait extends ImplTraitGenerator {
val pkg = parts.init
val select = selector.findAllIn(parts.last).map(_.strip()).toSeq
- if(pkg == Seq("vct", "col", "ast", "ops") && (select.contains("_") || opsNames.forall(name => select.contains(name)))) {
- mkImport = false
- }
+ if (
+ pkg == Seq("vct", "col", "ast", "ops") &&
+ (select.contains("_") ||
+ opsNames.forall(name => select.contains(name)))
+ ) { mkImport = false }
}
}
val outExts = exts ++ opsExts.filterNot(ext => exts.contains(ext))
val outImport =
- if(mkImport) {
- val selector = if(opsNames.size == 1) opsNames.head else opsNames.mkString("{", ", ", "}")
+ if (mkImport) {
+ val selector =
+ if (opsNames.size == 1)
+ opsNames.head
+ else
+ opsNames.mkString("{", ", ", "}")
s"import vct.col.ast.ops.$selector"
- } else ""
+ } else
+ ""
// Time to be careful: re-output the entire file except bits we for sure
// can do ourselves
@@ -147,22 +148,34 @@ class ImplTrait extends ImplTraitGenerator {
}
}
- def generate(p: Path, node: String, concrete: Boolean, family: Boolean): Unit = {
+ def generate(
+ p: Path,
+ node: String,
+ concrete: Boolean,
+ family: Boolean,
+ ): Unit = {
Using(Files.newBufferedWriter(p)) { writer =>
val ext =
- if (concrete && family) s"${node}Ops[G] with ${node}FamilyOps[G]"
- else if (concrete) s"${node}Ops[G]"
- else if (family) s"${node}FamilyOps[G]"
- else "???"
+ if (concrete && family)
+ s"${node}Ops[G] with ${node}FamilyOps[G]"
+ else if (concrete)
+ s"${node}Ops[G]"
+ else if (family)
+ s"${node}FamilyOps[G]"
+ else
+ "???"
val opsImport =
- if (concrete && family) s"{${node}Ops, ${node}FamilyOps}"
- else if(concrete) s"${node}Ops"
- else if(family) s"${node}FamilyOps"
- else "???"
-
- writer.write(
- s"""|package vct.col.ast.unsorted
+ if (concrete && family)
+ s"{${node}Ops, ${node}FamilyOps}"
+ else if (concrete)
+ s"${node}Ops"
+ else if (family)
+ s"${node}FamilyOps"
+ else
+ "???"
+
+ writer.write(s"""|package vct.col.ast.unsorted
|
|import vct.col.ast.$node
|import vct.col.ast.ops.$opsImport
@@ -171,8 +184,7 @@ class ImplTrait extends ImplTraitGenerator {
|trait ${node}Impl[G] extends $ext { this: $node[G] =>
| // override def layout(implicit ctx: Ctx): Doc = ???
|}
- |""".stripMargin
- )
+ |""".stripMargin)
}
}
}
diff --git a/src/helpers/vct/col/ast/helpers/generator/MegaCol.scala b/src/helpers/vct/col/ast/helpers/generator/MegaCol.scala
index ce6510809a..617490140a 100644
--- a/src/helpers/vct/col/ast/helpers/generator/MegaCol.scala
+++ b/src/helpers/vct/col/ast/helpers/generator/MegaCol.scala
@@ -16,13 +16,18 @@ class MegaCol extends AllNodesGenerator {
val messages =
definitions.map(node => genNode.message(node)) ++
- families.flatMap(family => genFamily.message(family._1, family._2.map(_.name)).toSeq) ++
- genAux.messages(definitions)
+ families.flatMap(family =>
+ genFamily.message(family._1, family._2.map(_.name)).toSeq
+ ) ++ genAux.messages(definitions)
Files.createDirectories(out.resolve(Paths.get("vct", "col", "ast")))
- Using(Files.newBufferedWriter(out.resolve(Paths.get("vct", "col", "ast", "col.proto")))) { writer =>
+ Using(Files.newBufferedWriter(
+ out.resolve(Paths.get("vct", "col", "ast", "col.proto"))
+ )) { writer =>
Proto.Source(
- messages.flatMap(_.namedTypes.collect { case t: Proto.StandardType => t.fqName }).distinct,
+ messages.flatMap(_.namedTypes.collect { case t: Proto.StandardType =>
+ t.fqName
+ }).distinct,
options = "",
messages = messages,
).write(writer)
diff --git a/src/helpers/vct/col/ast/helpers/generator/Ops.scala b/src/helpers/vct/col/ast/helpers/generator/Ops.scala
index 03c972facf..93d882b9d3 100644
--- a/src/helpers/vct/col/ast/helpers/generator/Ops.scala
+++ b/src/helpers/vct/col/ast/helpers/generator/Ops.scala
@@ -9,7 +9,8 @@ import scala.meta._
class Ops extends NodeGenerator {
override def generate(out: Path, node: NodeDefinition): Unit =
- ResultStream.write(out.resolve(s"${node.name.base}Ops.scala"),
+ ResultStream.write(
+ out.resolve(s"${node.name.base}Ops.scala"),
source"""
package $OpsPackage
@@ -19,6 +20,6 @@ class Ops extends NodeGenerator {
with ${Init(t"${subnodesType(node)}[G]", Name.Anonymous(), Nil)}
with ${Init(t"${serializeType(node)}[G]", Name.Anonymous(), Nil)}
{ this: ${typ(node)}[G] => }
- """
+ """,
)
}
diff --git a/src/helpers/vct/col/ast/helpers/generator/OpsFamily.scala b/src/helpers/vct/col/ast/helpers/generator/OpsFamily.scala
index 2504d02936..70f672f400 100644
--- a/src/helpers/vct/col/ast/helpers/generator/OpsFamily.scala
+++ b/src/helpers/vct/col/ast/helpers/generator/OpsFamily.scala
@@ -1,7 +1,18 @@
package vct.col.ast.helpers.generator
-import vct.col.ast.helpers.defn.Constants.{AbstractRewriter, OpsPackage, Declaration, Long, Map}
-import vct.col.ast.helpers.defn.Naming.{declareType, opsFamilyTrait, scalapbType, typ}
+import vct.col.ast.helpers.defn.Constants.{
+ AbstractRewriter,
+ OpsPackage,
+ Declaration,
+ Long,
+ Map,
+}
+import vct.col.ast.helpers.defn.Naming.{
+ declareType,
+ opsFamilyTrait,
+ scalapbType,
+ typ,
+}
import vct.col.ast.structure
import vct.col.ast.structure.{DeclaredNode, FamilyGenerator, StructuralNode}
@@ -9,8 +20,14 @@ import java.nio.file.Path
import scala.meta._
class OpsFamily extends FamilyGenerator {
- override def generate(out: Path, family: structure.Name, kind: structure.NodeKind, nodes: Seq[structure.Name]): Unit =
- ResultStream.write(out.resolve(s"${family.base}FamilyOps.scala"),
+ override def generate(
+ out: Path,
+ family: structure.Name,
+ kind: structure.NodeKind,
+ nodes: Seq[structure.Name],
+ ): Unit =
+ ResultStream.write(
+ out.resolve(s"${family.base}FamilyOps.scala"),
source"""
package $OpsPackage
@@ -20,14 +37,13 @@ class OpsFamily extends FamilyGenerator {
override def rewriteDefault[Post]()(implicit rw: $AbstractRewriter[G, Post]): ${typ(family)}[Post]
override def serializeFamily(decls: $Map[$Declaration[G], $Long]): ${scalapbType(family)}
}
- """
+ """,
)
def templates(name: structure.Name, kind: structure.NodeKind): List[Init] =
kind match {
case StructuralNode => List.empty
- case DeclaredNode => List(
- Init(t"${declareType(name)}[G]", Name.Anonymous(), List.empty),
- )
+ case DeclaredNode =>
+ List(Init(t"${declareType(name)}[G]", Name.Anonymous(), List.empty))
}
}
diff --git a/src/helpers/vct/col/ast/helpers/generator/ProtoAuxTypes.scala b/src/helpers/vct/col/ast/helpers/generator/ProtoAuxTypes.scala
index 33742500dc..065e466f0d 100644
--- a/src/helpers/vct/col/ast/helpers/generator/ProtoAuxTypes.scala
+++ b/src/helpers/vct/col/ast/helpers/generator/ProtoAuxTypes.scala
@@ -8,27 +8,26 @@ import scala.util.Using
class ProtoAuxTypes extends AllNodesGenerator {
def messages(definitions: Seq[NodeDefinition]): Seq[Proto.Message] =
- definitions
- .flatMap(_.fields)
- .map(_._2)
- .map(ProtoNaming.getType)
- .flatMap(_.auxs)
- .distinct
- .sortBy(_.name.headOption)
+ definitions.flatMap(_.fields).map(_._2).map(ProtoNaming.getType)
+ .flatMap(_.auxs).distinct.sortBy(_.name.headOption)
override def generate(out: Path, definitions: Seq[NodeDefinition]): Unit = {
val auxs = messages(definitions).map(_.opaqueNodes)
- for(aux <- auxs) {
+ for (aux <- auxs) {
val dir = aux.name.init.foldLeft(out)(_.resolve(_))
Files.createDirectories(dir)
- Using(Files.newBufferedWriter(dir.resolve(aux.name.last + ".proto"))) { writer =>
- Proto.Source(
- Seq("scalapb", "scalapb") +: aux.imports,
- Proto.renderOptions(Proto.OPAQUE_SUBMESSAGES_OPTIONS.updated("package_name", ProtoNaming.scalaPackageOption(aux.name))),
- aux,
- ).write(writer)
+ Using(Files.newBufferedWriter(dir.resolve(aux.name.last + ".proto"))) {
+ writer =>
+ Proto.Source(
+ Seq("scalapb", "scalapb") +: aux.imports,
+ Proto.renderOptions(Proto.OPAQUE_SUBMESSAGES_OPTIONS.updated(
+ "package_name",
+ ProtoNaming.scalaPackageOption(aux.name),
+ )),
+ aux,
+ ).write(writer)
}
}
}
diff --git a/src/helpers/vct/col/ast/helpers/generator/ProtoFamily.scala b/src/helpers/vct/col/ast/helpers/generator/ProtoFamily.scala
index e0591c797d..cc5d5bb9c4 100644
--- a/src/helpers/vct/col/ast/helpers/generator/ProtoFamily.scala
+++ b/src/helpers/vct/col/ast/helpers/generator/ProtoFamily.scala
@@ -8,33 +8,46 @@ import scala.util.Using
class ProtoFamily extends FamilyGenerator {
def message(family: Name, nodes: Seq[Name]): Option[Proto.Message] = {
- if(nodes == Seq(family))
+ if (nodes == Seq(family))
return None
val fqNames = nodes.map(ProtoNaming.getTypeName)
val name = ProtoNaming.getTypeName(family)
- Some(Proto.Message(name, Proto.MessageOneOf(
- oneOfName = "v",
- fields = fqNames.zipWithIndex.map {
- case (name, idx) => Proto.Field(
- name = ProtoNaming.snake(name.last),
- index = idx + 1,
- t = Proto.UnspecifiedArity(Proto.FamilyType(name))
- )
- }
- )))
+ Some(Proto.Message(
+ name,
+ Proto.MessageOneOf(
+ oneOfName = "v",
+ fields = fqNames.zipWithIndex.map { case (name, idx) =>
+ Proto.Field(
+ name = ProtoNaming.snake(name.last),
+ index = idx + 1,
+ t = Proto.UnspecifiedArity(Proto.FamilyType(name)),
+ )
+ },
+ ),
+ ))
}
- override def generate(out: Path, family: Name, kind: NodeKind, nodes: Seq[Name]): Unit = {
+ override def generate(
+ out: Path,
+ family: Name,
+ kind: NodeKind,
+ nodes: Seq[Name],
+ ): Unit = {
message(family, nodes).foreach { message =>
val dir = message.name.init.foldLeft(out)(_.resolve(_))
Files.createDirectories(dir)
- Using(Files.newBufferedWriter(dir.resolve(message.name.last + ".proto"))) { writer =>
+ Using(
+ Files.newBufferedWriter(dir.resolve(message.name.last + ".proto"))
+ ) { writer =>
Proto.Source(
imports = Seq("scalapb", "scalapb") +: message.imports,
- options = Proto.renderOptions(Proto.STANDARD_OPTIONS.updated("package_name", ProtoNaming.scalaPackageOption(message.name))),
+ options = Proto.renderOptions(Proto.STANDARD_OPTIONS.updated(
+ "package_name",
+ ProtoNaming.scalaPackageOption(message.name),
+ )),
message = message,
).write(writer)
}
diff --git a/src/helpers/vct/col/ast/helpers/generator/ProtoNode.scala b/src/helpers/vct/col/ast/helpers/generator/ProtoNode.scala
index 85ab611d75..bc6a343293 100644
--- a/src/helpers/vct/col/ast/helpers/generator/ProtoNode.scala
+++ b/src/helpers/vct/col/ast/helpers/generator/ProtoNode.scala
@@ -1,7 +1,12 @@
package vct.col.ast.helpers.generator
import vct.col.ast.helpers.defn.{Proto, ProtoNaming}
-import vct.col.ast.structure.{DeclaredNode, NodeDefinition, NodeGenerator, StructuralNode}
+import vct.col.ast.structure.{
+ DeclaredNode,
+ NodeDefinition,
+ NodeGenerator,
+ StructuralNode,
+}
import java.nio.charset.StandardCharsets
import java.nio.file.{Files, Path}
@@ -14,17 +19,23 @@ class ProtoNode extends NodeGenerator {
val fields = node.fields.map(_._1).zip(typeResults).map {
case (name, res) => ProtoNaming.snake(name) -> res.t
}
- val blame = "blame" -> Proto.Required(Proto.StandardType(Proto.auxBase :+ "Blame"))
- val origin = "origin" -> Proto.Required(Proto.StandardType(Proto.auxBase :+ "Origin"))
+ val blame =
+ "blame" -> Proto.Required(Proto.StandardType(Proto.auxBase :+ "Blame"))
+ val origin =
+ "origin" -> Proto.Required(Proto.StandardType(Proto.auxBase :+ "Origin"))
val allFieldDecls =
- (if(node.kind == DeclaredNode) Seq(id) else Nil) ++
- fields ++
- (if(node.blameType.isDefined) Seq(blame) else Nil) ++
- Seq(origin)
+ (if (node.kind == DeclaredNode)
+ Seq(id)
+ else
+ Nil) ++ fields ++
+ (if (node.blameType.isDefined)
+ Seq(blame)
+ else
+ Nil) ++ Seq(origin)
- val allFields = allFieldDecls.zipWithIndex.map {
- case (name -> t, idx) => Proto.Field(name, idx+1, t)
+ val allFields = allFieldDecls.zipWithIndex.map { case (name -> t, idx) =>
+ Proto.Field(name, idx + 1, t)
}
val name = ProtoNaming.getTypeName(node.name)
@@ -36,15 +47,19 @@ class ProtoNode extends NodeGenerator {
val source = Proto.Source(
Seq("scalapb", "scalapb") +: message.imports,
- Proto.renderOptions(Proto.OPAQUE_SUBMESSAGES_OPTIONS.updated("package_name", ProtoNaming.scalaPackageOption(message.name))),
+ Proto.renderOptions(
+ Proto.OPAQUE_SUBMESSAGES_OPTIONS
+ .updated("package_name", ProtoNaming.scalaPackageOption(message.name))
+ ),
message,
)
val dir = message.name.init.foldLeft(out)(_.resolve(_))
Files.createDirectories(dir)
- Using(Files.newBufferedWriter(dir.resolve(message.name.last + ".proto"), StandardCharsets.UTF_8)) { writer =>
- source.write(writer)
- }
+ Using(Files.newBufferedWriter(
+ dir.resolve(message.name.last + ".proto"),
+ StandardCharsets.UTF_8,
+ )) { writer => source.write(writer) }
}
}
diff --git a/src/helpers/vct/col/ast/helpers/generator/Rewrite.scala b/src/helpers/vct/col/ast/helpers/generator/Rewrite.scala
index e5316d03e1..4ba174d880 100644
--- a/src/helpers/vct/col/ast/helpers/generator/Rewrite.scala
+++ b/src/helpers/vct/col/ast/helpers/generator/Rewrite.scala
@@ -11,7 +11,8 @@ import scala.meta._
class Rewrite extends NodeGenerator {
override def generate(out: Path, node: NodeDefinition): Unit =
- ResultStream.write(out.resolve(s"${node.name.base}Rewrite.scala"), getTree(node))
+ ResultStream
+ .write(out.resolve(s"${node.name.base}Rewrite.scala"), getTree(node))
def getTree(node: NodeDefinition): Tree =
source"""
@@ -27,17 +28,13 @@ class Rewrite extends NodeGenerator {
"""
def args(node: NodeDefinition): List[Term.Param] = {
- val fieldParams = node.fields.map {
- case (name, t) => arg(name, t)
- }
+ val fieldParams = node.fields.map { case (name, t) => arg(name, t) }
val originParam = param"o: $Origin = null"
(node.blameType match {
- case Some(blameType) =>
- fieldParams :+ blameArg(blameType) :+ originParam
- case None =>
- fieldParams :+ originParam
+ case Some(blameType) => fieldParams :+ blameArg(blameType) :+ originParam
+ case None => fieldParams :+ originParam
}).toList
}
@@ -45,8 +42,7 @@ class Rewrite extends NodeGenerator {
t match {
case _: structure.Type.ValueType =>
param"${Name(name)}: => Option[${typ(t, t"Post")}] = None"
- case _ =>
- param"${Name(name)}: => ${typ(t, t"Post")} = null"
+ case _ => param"${Name(name)}: => ${typ(t, t"Post")} = null"
}
def blameArg(blameType: structure.Name): Term.Param =
@@ -54,8 +50,7 @@ class Rewrite extends NodeGenerator {
def scopes(node: NodeDefinition, make: Term): Term =
node.scopes.foldLeft[Term](make) {
- case (acc, structure.Type.Declaration(name)) =>
- q"""
+ case (acc, structure.Type.Declaration(name)) => q"""
`~rw`.${Naming.scopes(name.base)}.scope {
$acc
}
@@ -63,23 +58,29 @@ class Rewrite extends NodeGenerator {
}
def make(node: NodeDefinition): Term = {
- val fieldValues = node.fields.map {
- case (name, t) => makeField(name, t)
- }
-
- val valuess = node.blameType match {
- case Some(_) =>
- List(fieldValues.toList, List(q"if(blame ne null) blame else `~rw`.dispatch(this.blame)"), List(q"if(o ne null) o else `~rw`.dispatch(this.o)"))
- case None =>
- List(fieldValues.toList, List(q"if(o ne null) o else `~rw`.dispatch(this.o)"))
- }
+ val fieldValues = node.fields.map { case (name, t) => makeField(name, t) }
+
+ val valuess =
+ node.blameType match {
+ case Some(_) =>
+ List(
+ fieldValues.toList,
+ List(q"if(blame ne null) blame else `~rw`.dispatch(this.blame)"),
+ List(q"if(o ne null) o else `~rw`.dispatch(this.o)"),
+ )
+ case None =>
+ List(
+ fieldValues.toList,
+ List(q"if(o ne null) o else `~rw`.dispatch(this.o)"),
+ )
+ }
q"new ${Init(typ(node.name), Name.Anonymous(), valuess)}"
}
def makeField(fieldName: String, t: structure.Type): Term = {
val field = Term.Name(fieldName)
- if(t.isInstanceOf[structure.Type.ValueType])
+ if (t.isInstanceOf[structure.Type.ValueType])
q"$field.getOrElse(${rewriteDefault(q"this.$field", t)})"
else
q"_root_.scala.Predef.locally({ val `~x` = $field; if(`~x` ne null) `~x` else ${rewriteDefault(q"this.$field", t)} })"
@@ -88,23 +89,27 @@ class Rewrite extends NodeGenerator {
def rewriteDefault(term: Term, t: structure.Type): Term =
t match {
case structure.Type.Node(_) => q"`~rw`.dispatch($term)"
- case structure.Type.Declaration(name) => q"`~rw`.${Naming.scopes(name.base)}.dispatch($term)"
- case structure.Type.DeclarationSeq(name) => q"`~rw`.${Naming.scopes(name.base)}.dispatch($term)"
+ case structure.Type.Declaration(name) =>
+ q"`~rw`.${Naming.scopes(name.base)}.dispatch($term)"
+ case structure.Type.DeclarationSeq(name) =>
+ q"`~rw`.${Naming.scopes(name.base)}.dispatch($term)"
case structure.Type.Ref(kind) =>
q"`~rw`.porcelainRefSucc[${typ(kind.name)}[Post]]($term).getOrElse(`~rw`.succ[${typ(kind.name)}[Post]]($term.decl))"
case structure.Type.MultiRef(kind) =>
q"`~rw`.porcelainRefSucc[${typ(kind.name)}[Post]]($term).getOrElse(`~rw`.anySucc[${typ(kind.name)}[Post]]($term.decl))"
case _: structure.Type.PrimitiveType => term
- case structure.Type.Option(t) => q"$term.map(`~x` => ${rewriteDefault(q"`~x`", t)})"
+ case structure.Type.Option(t) =>
+ q"$term.map(`~x` => ${rewriteDefault(q"`~x`", t)})"
case structure.Type.Either(l, r) =>
q"$term.fold(`~x` => $LeftObj(${rewriteDefault(q"`~x`", l)}), `~x` => $RightObj(${rewriteDefault(q"`~x`", r)}))"
- case structure.Type.Seq(t) => q"$term.map(`~x` => ${rewriteDefault(q"`~x`", t)})"
+ case structure.Type.Seq(t) =>
+ q"$term.map(`~x` => ${rewriteDefault(q"`~x`", t)})"
case structure.Type.Tuple(ts) =>
- val elems = ts.zipWithIndex.map {
- case (t, i) =>
- val field = Term.Name(s"_${i+1}")
+ val elems =
+ ts.zipWithIndex.map { case (t, i) =>
+ val field = Term.Name(s"_${i + 1}")
rewriteDefault(q"$term.$field", t)
- }.toList
+ }.toList
q"(..$elems)"
}
diff --git a/src/helpers/vct/col/ast/helpers/generator/RewriteHelpers.scala b/src/helpers/vct/col/ast/helpers/generator/RewriteHelpers.scala
index ca63eba1b1..5239dc8466 100644
--- a/src/helpers/vct/col/ast/helpers/generator/RewriteHelpers.scala
+++ b/src/helpers/vct/col/ast/helpers/generator/RewriteHelpers.scala
@@ -7,19 +7,20 @@ import scala.meta._
class RewriteHelpers extends AllNodesGenerator {
override def generate(out: Path, definitions: Seq[NodeDefinition]): Unit =
- ResultStream.write(out.resolve("RewriteHelpers.scala"),
+ ResultStream.write(
+ out.resolve("RewriteHelpers.scala"),
source"""
package vct.col.ast
@deprecated("node.rewrite(...) methods are defined directly on nodes now, so importing this does nothing.")
object RewriteHelpers {
..${definitions.map(defn => {
- q"""
+ q"""
@deprecated("node.rewrite(...) methods are defined directly on nodes now, so importing this does nothing.")
object ${Term.Name("Rewrite" + defn.name.base)}
"""
- }).toList}
+ }).toList}
}
- """
+ """,
)
}
diff --git a/src/helpers/vct/col/ast/helpers/generator/Serialize.scala b/src/helpers/vct/col/ast/helpers/generator/Serialize.scala
index 7a1ab74276..38d8544138 100644
--- a/src/helpers/vct/col/ast/helpers/generator/Serialize.scala
+++ b/src/helpers/vct/col/ast/helpers/generator/Serialize.scala
@@ -4,14 +4,20 @@ import vct.col.ast.helpers.defn.Constants._
import vct.col.ast.helpers.defn.Naming._
import vct.col.ast.helpers.defn.{Naming, Proto, ProtoNaming}
import vct.col.ast.structure
-import vct.col.ast.structure.{DeclaredNode, NodeDefinition, NodeGenerator, Type => ST}
+import vct.col.ast.structure.{
+ DeclaredNode,
+ NodeDefinition,
+ NodeGenerator,
+ Type => ST,
+}
import java.nio.file.Path
import scala.meta._
class Serialize extends NodeGenerator {
override def generate(out: Path, node: NodeDefinition): Unit =
- ResultStream.write(out.resolve(s"${node.name.base}Serialize.scala"), serialize(node))
+ ResultStream
+ .write(out.resolve(s"${node.name.base}Serialize.scala"), serialize(node))
def serialize(node: NodeDefinition): Source =
source"""
@@ -39,9 +45,17 @@ class Serialize extends NodeGenerator {
"""
def data(node: NodeDefinition): Seq[Term] = {
- val id = if(node.kind == DeclaredNode) Seq(q"decls(this)") else Nil
+ val id =
+ if (node.kind == DeclaredNode)
+ Seq(q"decls(this)")
+ else
+ Nil
val fields = node.fields.map { case (name, t) => serializeField(name, t) }
- val blame = if(node.blameType.isDefined) Seq(q"$SerializeBlame.serialize(this.blame)") else Nil
+ val blame =
+ if (node.blameType.isDefined)
+ Seq(q"$SerializeBlame.serialize(this.blame)")
+ else
+ Nil
val origin = Seq(q"$SerializeOrigin.serialize(this.o)")
id ++ fields ++ blame ++ origin
@@ -60,24 +74,30 @@ class Serialize extends NodeGenerator {
serializeTerm(value, structureType, protoType)
}
- def serializeTerm(term: Term, structureType: structure.Type, protoType: Proto.Type): Term =
+ def serializeTerm(
+ term: Term,
+ structureType: structure.Type,
+ protoType: Proto.Type,
+ ): Term =
(structureType, protoType) match {
- case (st, Proto.Required(pt)) =>
- serializeTerm(term, st, pt)
+ case (st, Proto.Required(pt)) => serializeTerm(term, st, pt)
case (ST.Option(st), Proto.Option(pt)) =>
q"$term.map(`~x` => ${serializeTerm(q"`~x`", st, pt)})"
case (ST.Seq(st), Proto.Repeated(pt)) =>
q"$term.map(`~x` => ${serializeTerm(q"`~x`", st, pt)})"
case (ST.DeclarationSeq(name), Proto.Repeated(pt)) =>
q"$term.map(`~x` => new $NodeMessageView(`~x`, decls))"
- case (st, pt) =>
- err(st, pt)
+ case (st, pt) => err(st, pt)
}
def mk(name: Seq[String], args: Term*): Term =
q"new ${typ(structure.Name(ProtoNaming.scalaPackage(name) :+ name.last))}(..${args.toList})"
- def serializeTerm(term: Term, structureType: ST, protoType: Proto.PrimitiveType): Term =
+ def serializeTerm(
+ term: Term,
+ structureType: ST,
+ protoType: Proto.PrimitiveType,
+ ): Term =
(structureType, protoType) match {
case (ST.Node(_), Proto.FamilyType(_)) =>
q"new $NodeMessageView($term, decls)"
@@ -90,54 +110,62 @@ class Serialize extends NodeGenerator {
case (ST.MultiRef(_), Proto.StandardType(name)) =>
mk(name, q"decls($term.decl)")
case (ST.Tuple(args), Proto.AuxType(name)) =>
- mk(name, args.zipWithIndex.map { case (structureType, idx) =>
- val protoType = ProtoNaming.getType(structureType).t
- val field = Term.Name(s"_${idx+1}")
- serializeTerm(q"$term.$field", structureType, protoType)
- }: _*)
+ mk(
+ name,
+ args.zipWithIndex.map { case (structureType, idx) =>
+ val protoType = ProtoNaming.getType(structureType).t
+ val field = Term.Name(s"_${idx + 1}")
+ serializeTerm(q"$term.$field", structureType, protoType)
+ }: _*
+ )
case (ST.Seq(structureType), Proto.AuxType(name)) =>
val protoType = ProtoNaming.getType(structureType).t
- mk(name, q"$term.map(`~x` => ${serializeTerm(q"`~x`", structureType, protoType)})")
+ mk(
+ name,
+ q"$term.map(`~x` => ${serializeTerm(q"`~x`", structureType, protoType)})",
+ )
case (ST.Option(structureType), Proto.AuxType(name)) =>
val protoType = ProtoNaming.getType(structureType).t
- mk(name, q"$term.map(`~x` => ${serializeTerm(q"`~x`", structureType, protoType)})")
+ mk(
+ name,
+ q"$term.map(`~x` => ${serializeTerm(q"`~x`", structureType, protoType)})",
+ )
case (ST.Either(left, right), Proto.AuxType(name)) =>
- mk(name, q"""
+ mk(
+ name,
+ q"""
$term.fold(
`~x` => ${mk(name :+ "V" :+ "Left", serializeTerm(q"`~x`", left, ProtoNaming.getPrimitiveType(left).t))},
`~x` => ${mk(name :+ "V" :+ "Right", serializeTerm(q"`~x`", right, ProtoNaming.getPrimitiveType(right).t))},
)
- """)
- case (ST.Nothing, Proto.Bool) =>
- term
- case (ST.Unit, Proto.Bool) =>
- q"true"
- case (ST.String, Proto.String) =>
- term
+ """,
+ )
+ case (ST.Nothing, Proto.Bool) => term
+ case (ST.Unit, Proto.Bool) => q"true"
+ case (ST.String, Proto.String) => term
case (ST.BigInt, Proto.StandardType(name)) =>
mk(name, q"$copyByteStringFrom($term.toByteArray)")
case (ST.BigDecimal, Proto.StandardType(name)) =>
- mk(name, q"$term.scale", serializeTerm(q"$term.underlying.unscaledValue", ST.BigInt, ProtoNaming.getStandardType("BigInt").t))
+ mk(
+ name,
+ q"$term.scale",
+ serializeTerm(
+ q"$term.underlying.unscaledValue",
+ ST.BigInt,
+ ProtoNaming.getStandardType("BigInt").t,
+ ),
+ )
case (ST.BitString, Proto.StandardType(name)) =>
mk(name, q"$copyByteStringFrom($term.rawData)", q"$term.skipAtLastByte")
- case (ST.ExpectedError, Proto.StandardType(name)) =>
- mk(name)
- case (ST.Boolean, Proto.Bool) =>
- term
- case (ST.Byte, Proto.Int) =>
- term
- case (ST.Short, Proto.Int) =>
- term
- case (ST.Int, Proto.Int) =>
- term
- case (ST.Long, Proto.Long) =>
- term
- case (ST.Float, Proto.Float) =>
- term
- case (ST.Double, Proto.Double) =>
- term
- case (ST.Char, Proto.Int) =>
- term
+ case (ST.ExpectedError, Proto.StandardType(name)) => mk(name)
+ case (ST.Boolean, Proto.Bool) => term
+ case (ST.Byte, Proto.Int) => term
+ case (ST.Short, Proto.Int) => term
+ case (ST.Int, Proto.Int) => term
+ case (ST.Long, Proto.Long) => term
+ case (ST.Float, Proto.Float) => term
+ case (ST.Double, Proto.Double) => term
+ case (ST.Char, Proto.Int) => term
case (st, pt) => err(st, pt)
}
}
diff --git a/src/helpers/vct/col/ast/helpers/generator/Subnodes.scala b/src/helpers/vct/col/ast/helpers/generator/Subnodes.scala
index 36e69d39fb..ba39fa60ff 100644
--- a/src/helpers/vct/col/ast/helpers/generator/Subnodes.scala
+++ b/src/helpers/vct/col/ast/helpers/generator/Subnodes.scala
@@ -11,7 +11,8 @@ import scala.meta._
class Subnodes extends NodeGenerator {
override def generate(out: Path, node: NodeDefinition): Unit =
- ResultStream.write(out.resolve(s"${node.name.base}Subnodes.scala"), subnodes(node))
+ ResultStream
+ .write(out.resolve(s"${node.name.base}Subnodes.scala"), subnodes(node))
def subnodes(node: NodeDefinition): Source =
source"""
@@ -23,40 +24,33 @@ class Subnodes extends NodeGenerator {
}
"""
- def noNodes: Term =
- q"$SeqObj.empty[$Node[G]]"
+ def noNodes: Term = q"$SeqObj.empty[$Node[G]]"
def concat(terms: Seq[Term]): Term =
terms.reduceOption((l, r) => q"$l ++ $r").getOrElse(noNodes)
def subnodesFields(node: NodeDefinition): Term =
- concat(node.fields.map {
- case (name, t) =>
- val term = q"this.${Term.Name(name)}"
- subnodes(term, t)
+ concat(node.fields.map { case (name, t) =>
+ val term = q"this.${Term.Name(name)}"
+ subnodes(term, t)
})
def subnodes(term: Term, typ: structure.Type): Term =
typ match {
- case _: Type.Node | _: Type.Declaration =>
- q"$SeqObj($term)"
- case _: Type.DeclarationSeq =>
- term
+ case _: Type.Node | _: Type.Declaration => q"$SeqObj($term)"
+ case _: Type.DeclarationSeq => term
case _: Type.Ref => noNodes
case _: Type.MultiRef => noNodes
case Type.Tuple(ts) =>
- concat(ts.zipWithIndex.map {
- case (typ, i) =>
- val field = Term.Name(s"_${i+1}")
- subnodes(q"$term.$field", typ)
+ concat(ts.zipWithIndex.map { case (typ, i) =>
+ val field = Term.Name(s"_${i + 1}")
+ subnodes(q"$term.$field", typ)
})
- case Type.Seq(arg) =>
- q"$term.flatMap(`x` => ${subnodes(q"`x`", arg)})"
+ case Type.Seq(arg) => q"$term.flatMap(`x` => ${subnodes(q"`x`", arg)})"
case Type.Option(arg) =>
q"if($term.isDefined) ${subnodes(q"$term.get", arg)} else $noNodes"
case Type.Either(left, right) =>
q"if($term.isLeft) ${subnodes(q"$term.left", left)} else ${subnodes(q"$term.right", right)}"
- case _: Type.PrimitiveType =>
- noNodes
+ case _: Type.PrimitiveType => noNodes
}
}
diff --git a/src/helpers/vct/col/ast/helpers/generator/SuccessorsProvider.scala b/src/helpers/vct/col/ast/helpers/generator/SuccessorsProvider.scala
index 0fa9834b3a..48aa1e1f3c 100644
--- a/src/helpers/vct/col/ast/helpers/generator/SuccessorsProvider.scala
+++ b/src/helpers/vct/col/ast/helpers/generator/SuccessorsProvider.scala
@@ -9,8 +9,13 @@ import java.nio.file.Path
import scala.meta._
class SuccessorsProvider extends AllFamiliesGenerator {
- override def generate(out: Path, declaredFamilies: Seq[structure.Name], structuralFamilies: Seq[structure.Name]): Unit =
- ResultStream.write(out.resolve("SuccessorsProvider.scala"), source(declaredFamilies))
+ override def generate(
+ out: Path,
+ declaredFamilies: Seq[structure.Name],
+ structuralFamilies: Seq[structure.Name],
+ ): Unit =
+ ResultStream
+ .write(out.resolve("SuccessorsProvider.scala"), source(declaredFamilies))
def source(declaredFamilies: Seq[structure.Name]): Source =
source"""
@@ -25,9 +30,7 @@ class SuccessorsProvider extends AllFamiliesGenerator {
q"""
trait SuccessorsProvider[Pre, Post] {
def anySucc[RefDecl <: $Declaration[Post]](`~decl`: $Declaration[Pre])(implicit tag: $ClassTag[RefDecl]): $RefType[Post, RefDecl] =
- ${Term.Match(q"`~decl`", declaredFamilies.map(name =>
- Case(p"(decl: ${typ(name)}[Pre])", None, q"succ(decl)")
- ).toList)}
+ ${Term.Match(q"`~decl`", declaredFamilies.map(name => Case(p"(decl: ${typ(name)}[Pre])", None, q"succ(decl)")).toList)}
..${declaredFamilies.map(name => q"""
def computeSucc(decl: ${typ(name)}[Pre]): $OptionType[${typ(name)}[Post]]
@@ -40,7 +43,9 @@ class SuccessorsProvider extends AllFamiliesGenerator {
}
"""
- def successorsProviderChain(declaredFamilies: Seq[structure.Name]): Defn.Class =
+ def successorsProviderChain(
+ declaredFamilies: Seq[structure.Name]
+ ): Defn.Class =
q"""
case class SuccessorsProviderChain[A, B, C](left: $SuccessorsProvider[A, B], right: $SuccessorsProvider[B, C]) extends ${Init(t"SuccessorsProvider[A, C]", Name.Anonymous(), List.empty)} {
..${declaredFamilies.map(name => q"""
@@ -50,7 +55,9 @@ class SuccessorsProvider extends AllFamiliesGenerator {
}
"""
- def successorsProviderTrafo(declaredFamilies: Seq[structure.Name]): Defn.Class =
+ def successorsProviderTrafo(
+ declaredFamilies: Seq[structure.Name]
+ ): Defn.Class =
q"""
abstract class SuccessorsProviderTrafo[Pre, Post](inner: $SuccessorsProvider[Pre, Post]) extends ${Init(t"$SuccessorsProvider[Pre, Post]", Name.Anonymous(), List.empty)} {
def preTransform[I <: $Declaration[Pre], O <: $Declaration[Post]](pre: I): $OptionType[O] = None
diff --git a/src/hre/hre/cache/Cache.scala b/src/hre/hre/cache/Cache.scala
index fc6a0826ba..eb9c10de7a 100644
--- a/src/hre/hre/cache/Cache.scala
+++ b/src/hre/hre/cache/Cache.scala
@@ -14,29 +14,39 @@ case object Cache {
private def hash(keys: Seq[String]): String = {
val hashes = ("" +: keys).map(_.getBytes).map(sha256)
- val res = hashes.tail.foldLeft(hashes.head) {
- case (acc, hash) => sha256(acc ++ hash)
- }
+ val res =
+ hashes.tail.foldLeft(hashes.head) { case (acc, hash) =>
+ sha256(acc ++ hash)
+ }
res.map("%02x" format _).mkString("")
}
private var variateTempDir: Option[Path] = None
- /**
- * Get or create a platform-appropriate cache data directory, keyed by a sequence of keys. If variate is set, the
- * returned directory will be unique for this JVM instance / VerCors run, rather than unique for the set of keys.
- * @param variate Whether or not this process should be considered unique in the cache
- * @param keys The set of keys to determine the cache directory by.
- * @return The path to the cache directory
- */
+ /** Get or create a platform-appropriate cache data directory, keyed by a
+ * sequence of keys. If variate is set, the returned directory will be unique
+ * for this JVM instance / VerCors run, rather than unique for the set of
+ * keys.
+ * @param variate
+ * Whether or not this process should be considered unique in the cache
+ * @param keys
+ * The set of keys to determine the cache directory by.
+ * @return
+ * The path to the cache directory
+ */
def getDirectory(variate: Boolean, keys: Seq[String]): Path = {
- if(variate) {
- if(variateTempDir.isEmpty)
- variateTempDir = Some(Files.createTempDirectory("vercors").toAbsolutePath)
+ if (variate) {
+ if (variateTempDir.isEmpty)
+ variateTempDir = Some(
+ Files.createTempDirectory("vercors").toAbsolutePath
+ )
variateTempDir.get
} else {
- Paths.get(AppDirsFactory.getInstance().getUserCacheDir("vercors", hash(keys), "utwente"))
+ Paths.get(
+ AppDirsFactory.getInstance()
+ .getUserCacheDir("vercors", hash(keys), "utwente")
+ )
}
}
-}
\ No newline at end of file
+}
diff --git a/src/hre/hre/data/BitString.scala b/src/hre/hre/data/BitString.scala
index b4071d2e30..3a43176d11 100644
--- a/src/hre/hre/data/BitString.scala
+++ b/src/hre/hre/data/BitString.scala
@@ -2,19 +2,51 @@ package hre.data
object BitString {
def apply(input: String): BitString = {
- val bytes = if(input.length % 8 == 0) input.length / 8 else input.length / 8 + 1
- val skip = if(input.length % 8 == 0) 0 else 8 - (input.length % 8)
+ val bytes =
+ if (input.length % 8 == 0)
+ input.length / 8
+ else
+ input.length / 8 + 1
+ val skip =
+ if (input.length % 8 == 0)
+ 0
+ else
+ 8 - (input.length % 8)
val buf = new Array[Byte](bytes)
- for(i <- 0 until bytes) {
+ for (i <- 0 until bytes) {
val value =
- (if(input(i*8+0) == '1') -128 else 0) +
- (if(input(i*8+1) == '1') 64 else 0) +
- (if(input(i*8+2) == '1') 32 else 0) +
- (if(input(i*8+3) == '1') 16 else 0) +
- (if(input(i*8+4) == '1') 8 else 0) +
- (if(input(i*8+5) == '1') 4 else 0) +
- (if(input(i*8+6) == '1') 2 else 0) +
- (if(input(i*8+7) == '1') 1 else 0)
+ (if (input(i * 8 + 0) == '1')
+ -128
+ else
+ 0) +
+ (if (input(i * 8 + 1) == '1')
+ 64
+ else
+ 0) +
+ (if (input(i * 8 + 2) == '1')
+ 32
+ else
+ 0) +
+ (if (input(i * 8 + 3) == '1')
+ 16
+ else
+ 0) +
+ (if (input(i * 8 + 4) == '1')
+ 8
+ else
+ 0) +
+ (if (input(i * 8 + 5) == '1')
+ 4
+ else
+ 0) +
+ (if (input(i * 8 + 6) == '1')
+ 2
+ else
+ 0) +
+ (if (input(i * 8 + 7) == '1')
+ 1
+ else
+ 0)
buf(i) = value.toByte
}
@@ -22,13 +54,17 @@ object BitString {
}
}
-class BitString(val rawData: Array[Byte], val skipAtLastByte: Int) extends Seq[Boolean] { bitString =>
+class BitString(val rawData: Array[Byte], val skipAtLastByte: Int)
+ extends Seq[Boolean] {
+ bitString =>
require(0 <= skipAtLastByte && skipAtLastByte < 8)
def toSmt: String =
- if(skipAtLastByte == 0 || skipAtLastByte == 4) toHexSmt
- else toBinSmt
+ if (skipAtLastByte == 0 || skipAtLastByte == 4)
+ toHexSmt
+ else
+ toBinSmt
def toHexSmt: String = {
val digit = "0123456789abcdef"
@@ -43,12 +79,10 @@ class BitString(val rawData: Array[Byte], val skipAtLastByte: Int) extends Seq[B
if (rawData.length > 0) {
val b = rawData.last
- if(skipAtLastByte == 0) {
+ if (skipAtLastByte == 0) {
sb += digit((b >> 4) & 0xf)
sb += digit((b >> 0) & 0xf)
- } else {
- sb += digit((b >> 4) & 0xf)
- }
+ } else { sb += digit((b >> 4) & 0xf) }
}
sb.result()
@@ -58,7 +92,7 @@ class BitString(val rawData: Array[Byte], val skipAtLastByte: Int) extends Seq[B
val bit = "01"
val sb = new StringBuilder("#b")
- for(i <- 0 until rawData.length - 1) {
+ for (i <- 0 until rawData.length - 1) {
val b = rawData(i)
sb += bit((b >> 7) & 1)
sb += bit((b >> 6) & 1)
@@ -70,9 +104,9 @@ class BitString(val rawData: Array[Byte], val skipAtLastByte: Int) extends Seq[B
sb += bit((b >> 0) & 1)
}
- if(rawData.length > 0) {
+ if (rawData.length > 0) {
val b = rawData.last
- for(offset <- (skipAtLastByte until 8).reverse) {
+ for (offset <- (skipAtLastByte until 8).reverse) {
sb += bit((b >> offset) & 1)
}
}
@@ -81,7 +115,7 @@ class BitString(val rawData: Array[Byte], val skipAtLastByte: Int) extends Seq[B
}
override def apply(i: Int): Boolean = {
- if(i < 0 || i >= length)
+ if (i < 0 || i >= length)
throw new IndexOutOfBoundsException(i)
(rawData(i / 8) >> (i % 8)) > 0
@@ -94,12 +128,9 @@ class BitString(val rawData: Array[Byte], val skipAtLastByte: Int) extends Seq[B
override def hasNext: Boolean = index < bitString.length
override def next(): Boolean =
- try {
- bitString(index)
- } finally {
- index += 1
- }
+ try { bitString(index) }
+ finally { index += 1 }
}
override def iterator: Iterator[Boolean] = new BitStringIterator
-}
\ No newline at end of file
+}
diff --git a/src/hre/hre/debug/TimeTravel.scala b/src/hre/hre/debug/TimeTravel.scala
index 831be75cfa..42c204e3dd 100644
--- a/src/hre/hre/debug/TimeTravel.scala
+++ b/src/hre/hre/debug/TimeTravel.scala
@@ -4,20 +4,22 @@ import hre.util.ScopedStack
import vct.result.VerificationError
import vct.result.VerificationError.SystemError
-/**
- * Thread-local counter that can associate errors with counted causes.
- */
+/** Thread-local counter that can associate errors with counted causes.
+ */
object TimeTravel {
- case class RepeatUntilCause(causeIndex: Long, exception: VerificationError) extends SystemError {
+ case class RepeatUntilCause(causeIndex: Long, exception: VerificationError)
+ extends SystemError {
override def text: String = exception.text
}
case class CauseWithBadEffect(effect: VerificationError) extends SystemError {
- override def text: String = s"This trace causes an error later on: \n${effect.getMessage}"
+ override def text: String =
+ s"This trace causes an error later on: \n${effect.getMessage}"
}
private val causeIndex: ThreadLocal[Long] = ThreadLocal.withInitial(() => 0L)
- private val repeatingUntil: ScopedStack[(Long, VerificationError)] = ScopedStack()
+ private val repeatingUntil: ScopedStack[(Long, VerificationError)] =
+ ScopedStack()
private def nextIndex(): Long = {
val index = causeIndex.get()
@@ -27,15 +29,13 @@ object TimeTravel {
def safelyRepeatable[T](f: => T): T = {
val start = causeIndex.get()
- try {
- f
- } catch {
+ try { f }
+ catch {
case r @ RepeatUntilCause(idx, t) if idx >= start =>
t.contexts ++= r.contexts
causeIndex.set(start)
- try {
- repeatingUntil.having((idx, t)) { f }
- } catch {
+ try { repeatingUntil.having((idx, t)) { f } }
+ catch {
case c @ CauseWithBadEffect(effect) =>
effect.contexts ++= c.contexts
throw c
@@ -45,17 +45,12 @@ object TimeTravel {
def cause[T](f: Long => T): T = {
val idx = nextIndex()
- if(repeatingUntil.topOption.exists(_._1 == idx)) {
+ if (repeatingUntil.topOption.exists(_._1 == idx)) {
throw CauseWithBadEffect(repeatingUntil.top._2)
- } else {
- f(idx)
- }
+ } else { f(idx) }
}
def badEffect[T](idx: Long, f: => Nothing): Nothing =
- try {
- f
- } catch {
- case t: VerificationError => throw RepeatUntilCause(idx, t)
- }
+ try { f }
+ catch { case t: VerificationError => throw RepeatUntilCause(idx, t) }
}
diff --git a/src/hre/hre/io/InMemoryCachedReadable.scala b/src/hre/hre/io/InMemoryCachedReadable.scala
index 16692895ca..6588657233 100644
--- a/src/hre/hre/io/InMemoryCachedReadable.scala
+++ b/src/hre/hre/io/InMemoryCachedReadable.scala
@@ -13,7 +13,12 @@ trait InMemoryCachedReadable extends Readable {
Watch.enroll(this)
val scanner = new Scanner(getReaderImpl)
scanner.useDelimiter("\\A")
- cache = Some(if (scanner.hasNext()) scanner.next() else "")
+ cache = Some(
+ if (scanner.hasNext())
+ scanner.next()
+ else
+ ""
+ )
}
override protected def getReader: Reader = {
@@ -29,9 +34,7 @@ trait InMemoryCachedReadable extends Readable {
protected var linesCache: Option[Seq[String]] = None
override def readLines(): Seq[String] = {
- if(linesCache.isEmpty) {
- linesCache = Some(super.readLines())
- }
+ if (linesCache.isEmpty) { linesCache = Some(super.readLines()) }
linesCache.get
}
diff --git a/src/hre/hre/io/InterruptibleInputStream.scala b/src/hre/hre/io/InterruptibleInputStream.scala
index 0c517e769b..1e035e716b 100644
--- a/src/hre/hre/io/InterruptibleInputStream.scala
+++ b/src/hre/hre/io/InterruptibleInputStream.scala
@@ -7,7 +7,9 @@ object InterruptibleInputStream {
val BUFFER_BLOCKS = 2
}
-class InterruptibleInputStream(val underlying: InputStream) extends InputStream { outer =>
+class InterruptibleInputStream(val underlying: InputStream)
+ extends InputStream {
+ outer =>
import InterruptibleInputStream._
private def BUFFER_SIZE = BLOCK_SIZE * BUFFER_BLOCKS
@@ -25,100 +27,92 @@ class InterruptibleInputStream(val underlying: InputStream) extends InputStream
class TransferThread extends Thread {
override def run(): Unit =
- while(!eof) {
- if(outer.synchronized(spaceAvailable) >= BLOCK_SIZE) {
- val toRead = outer.synchronized(Math.min(BLOCK_SIZE, BUFFER_SIZE - writeCursor))
+ while (!eof) {
+ if (outer.synchronized(spaceAvailable) >= BLOCK_SIZE) {
+ val toRead = outer
+ .synchronized(Math.min(BLOCK_SIZE, BUFFER_SIZE - writeCursor))
val res = underlying.read(buffer, writeCursor, toRead)
- if(res == -1) {
- eof = true
- } else {
- writeCursor = (writeCursor + res) % BUFFER_SIZE
- }
+ if (res == -1) { eof = true }
+ else { writeCursor = (writeCursor + res) % BUFFER_SIZE }
outer.synchronized(outer.notifyAll())
- } else {
- outer.synchronized(outer.wait())
- }
+ } else { outer.synchronized(outer.wait()) }
}
}
- override final def read: Int = synchronized {
- while(true) {
- if(available > 0) {
- val result = buffer(readCursor)
- readCursor = (readCursor + 1) % BUFFER_SIZE
- notifyAll()
- return result
- } else if(eof) {
- return -1
- } else {
- wait()
+ override final def read: Int =
+ synchronized {
+ while (true) {
+ if (available > 0) {
+ val result = buffer(readCursor)
+ readCursor = (readCursor + 1) % BUFFER_SIZE
+ notifyAll()
+ return result
+ } else if (eof) { return -1 }
+ else { wait() }
}
- }
-
- ???
- }
- override def read(bufferOut: Array[Byte], off: Int, len: Int): Int = synchronized {
- var written = 0
+ ???
+ }
- while(written < len) {
- if(writeCursor > readCursor) {
- val toCopy = Math.min(writeCursor - readCursor, len - written)
- System.arraycopy(buffer, readCursor, bufferOut, off + written, toCopy)
- readCursor += toCopy
- notifyAll()
- written += toCopy
- } else if(writeCursor < readCursor) {
- val toCopy = Math.min(BUFFER_SIZE - readCursor, len - written)
- System.arraycopy(buffer, readCursor, bufferOut, off + written, toCopy)
- readCursor = (readCursor + toCopy) % BUFFER_SIZE
- notifyAll()
- written += toCopy
- } else if(eof) {
- return if (written == 0) -1 else written
- } else if(written > 0) {
- return written
- } else {
- wait()
+ override def read(bufferOut: Array[Byte], off: Int, len: Int): Int =
+ synchronized {
+ var written = 0
+
+ while (written < len) {
+ if (writeCursor > readCursor) {
+ val toCopy = Math.min(writeCursor - readCursor, len - written)
+ System.arraycopy(buffer, readCursor, bufferOut, off + written, toCopy)
+ readCursor += toCopy
+ notifyAll()
+ written += toCopy
+ } else if (writeCursor < readCursor) {
+ val toCopy = Math.min(BUFFER_SIZE - readCursor, len - written)
+ System.arraycopy(buffer, readCursor, bufferOut, off + written, toCopy)
+ readCursor = (readCursor + toCopy) % BUFFER_SIZE
+ notifyAll()
+ written += toCopy
+ } else if (eof) {
+ return if (written == 0)
+ -1
+ else
+ written
+ } else if (written > 0) { return written }
+ else { wait() }
}
- }
- written
- }
+ written
+ }
override def skip(n: Long): Long = {
var skipped = 0L
- while(skipped < n) {
+ while (skipped < n) {
val avail = available
- if(avail > 0 && avail < n - skipped) {
+ if (avail > 0 && avail < n - skipped) {
skipped += avail
readCursor = writeCursor
notifyAll()
- } else if(avail > 0) {
+ } else if (avail > 0) {
readCursor = (readCursor + (n - skipped).toInt) % BUFFER_SIZE
notifyAll()
skipped = n
- } else if(eof) {
- return skipped
- } else {
- wait()
- }
+ } else if (eof) { return skipped }
+ else { wait() }
}
skipped
}
override def available: Int =
- if(writeCursor >= readCursor)
+ if (writeCursor >= readCursor)
writeCursor - readCursor
else
(writeCursor - readCursor) + BUFFER_SIZE
def spaceAvailable: Int =
- if(readCursor > writeCursor)
+ if (readCursor > writeCursor)
readCursor - writeCursor - 1
else
(readCursor - writeCursor - 1) + BUFFER_SIZE
diff --git a/src/hre/hre/io/LiteralReadable.scala b/src/hre/hre/io/LiteralReadable.scala
index 132b0896fb..9d0682920a 100644
--- a/src/hre/hre/io/LiteralReadable.scala
+++ b/src/hre/hre/io/LiteralReadable.scala
@@ -5,8 +5,7 @@ import java.io.{Reader, StringReader}
case class LiteralReadable(fileName: String, data: String) extends Readable {
override def isRereadable: Boolean = true
- override protected def getReader: Reader =
- new StringReader(data)
+ override protected def getReader: Reader = new StringReader(data)
override def enroll(watch: Watch): Unit = {
// A literal string cannot change, so there is nothing to do.
diff --git a/src/hre/hre/io/RWFile.scala b/src/hre/hre/io/RWFile.scala
index 3011f3ff70..c7071e0277 100644
--- a/src/hre/hre/io/RWFile.scala
+++ b/src/hre/hre/io/RWFile.scala
@@ -4,7 +4,8 @@ import java.io.{Reader, Writer}
import java.nio.charset.StandardCharsets
import java.nio.file.{Files, Path}
-case class RWFile(file: Path, doWatch: Boolean = true) extends InMemoryCachedReadable with Writeable {
+case class RWFile(file: Path, doWatch: Boolean = true)
+ extends InMemoryCachedReadable with Writeable {
override def underlyingPath: Option[Path] = Some(file)
override def fileName: String = file.toString
override def isRereadable: Boolean = true
@@ -19,7 +20,8 @@ case class RWFile(file: Path, doWatch: Boolean = true) extends InMemoryCachedRea
}
override def enroll(watch: Watch): Unit = {
- if(doWatch) watch.enroll(file)
+ if (doWatch)
+ watch.enroll(file)
watch.invalidate(this)
}
}
diff --git a/src/hre/hre/io/Readable.scala b/src/hre/hre/io/Readable.scala
index 20128cbc44..e7b7767468 100644
--- a/src/hre/hre/io/Readable.scala
+++ b/src/hre/hre/io/Readable.scala
@@ -18,18 +18,18 @@ trait Readable {
def read[T](f: Reader => T): T = {
Watch.enroll(this)
val r = getReader
- try {
- f(r)
- } finally {
- r.close()
- }
+ try { f(r) }
+ finally { r.close() }
}
def readToCompletion(): String =
read { reader =>
val scanner = new Scanner(reader)
scanner.useDelimiter("\\A")
- if(scanner.hasNext()) scanner.next() else ""
+ if (scanner.hasNext())
+ scanner.next()
+ else
+ ""
}
def readLines(): Seq[String] =
@@ -42,23 +42,28 @@ trait Readable {
var previousPosition = 0
var position = 0
- while(length > 0) {
+ while (length > 0) {
val token = new StringBuilder
- while(position < length && buffer(position) != '\n')
+ while (position < length && buffer(position) != '\n')
position += 1
- while(length > 0 && position == length) {
- token.append(CharBuffer.wrap(buffer, previousPosition, position - previousPosition))
+ while (length > 0 && position == length) {
+ token.append(
+ CharBuffer
+ .wrap(buffer, previousPosition, position - previousPosition)
+ )
length = reader.read(buffer)
previousPosition = 0
position = 0
- while(position < length && buffer(position) != '\n')
+ while (position < length && buffer(position) != '\n')
position += 1
}
- token.append(CharBuffer.wrap(buffer, previousPosition, position - previousPosition))
+ token.append(
+ CharBuffer.wrap(buffer, previousPosition, position - previousPosition)
+ )
result += token.toString()
position += 1
previousPosition = position
diff --git a/src/hre/hre/io/ReaderReadable.scala b/src/hre/hre/io/ReaderReadable.scala
index 1e8e899822..927d8a6208 100644
--- a/src/hre/hre/io/ReaderReadable.scala
+++ b/src/hre/hre/io/ReaderReadable.scala
@@ -1,10 +1,10 @@
package hre.io
import java.io.Reader
-/**
- * Constructs a readable from a [[java.io.Reader]]. If this reader is for a file, use [[RWFile]] instead: otherwise
- * it will mess up the watch file tracking.
- */
+/** Constructs a readable from a [[java.io.Reader]]. If this reader is for a
+ * file, use [[RWFile]] instead: otherwise it will mess up the watch file
+ * tracking.
+ */
case class ReaderReadable(fileName: String, reader: Reader) extends Readable {
override def isRereadable: Boolean = false
diff --git a/src/hre/hre/io/Watch.scala b/src/hre/hre/io/Watch.scala
index 4b53d6f645..993496f4e1 100644
--- a/src/hre/hre/io/Watch.scala
+++ b/src/hre/hre/io/Watch.scala
@@ -3,37 +3,45 @@ package hre.io
import com.typesafe.scalalogging.LazyLogging
import sun.misc.{Signal, SignalHandler}
-import java.nio.file.{ClosedWatchServiceException, FileSystem, FileSystems, Path, StandardWatchEventKinds, WatchEvent, WatchKey, WatchService}
+import java.nio.file.{
+ ClosedWatchServiceException,
+ FileSystem,
+ FileSystems,
+ Path,
+ StandardWatchEventKinds,
+ WatchEvent,
+ WatchKey,
+ WatchService,
+}
import java.util.concurrent.TimeUnit
import scala.collection.mutable
import scala.jdk.CollectionConverters.CollectionHasAsScala
import scala.util.control.Breaks.{break, breakable}
-/**
- * Watch facilitates that VerCors can automatically re-run when external input
- * changes. Implementors of [[Readable]] can vary how we detect external
- * changes, but typically we just listen to the change of a file just before
- * VerCors reads it.
- */
+/** Watch facilitates that VerCors can automatically re-run when external input
+ * changes. Implementors of [[Readable]] can vary how we detect external
+ * changes, but typically we just listen to the change of a file just before
+ * VerCors reads it.
+ */
object Watch {
private var currentWatch: Option[Watch] = None
def booleanWithWatch[T](doWatch: Boolean, default: T)(f: => T): T =
- if(doWatch) {
+ if (doWatch) {
val watch = new Watch(Thread.currentThread())
currentWatch = Some(watch)
val sigint = new Signal("INT")
- val previousHandler = Signal.handle(sigint, _ => Watch.currentWatch.get.mainThread.interrupt())
+ val previousHandler = Signal
+ .handle(sigint, _ => Watch.currentWatch.get.mainThread.interrupt())
var result: T = default
try {
- while(true) {
- try {
- result = f
- } catch {
+ while (true) {
+ try { result = f }
+ catch {
case _: InterruptedException =>
- // f was interrupted - wait until something changes.
+ // f was interrupted - wait until something changes.
}
watch.await()
}
@@ -47,16 +55,15 @@ object Watch {
Signal.handle(sigint, previousHandler)
currentWatch = None
}
- } else {
- f
- }
+ } else { f }
def enroll(readable: Readable): Unit = {
currentWatch.foreach { watch => readable.enroll(watch) }
}
}
-class Watch(val mainThread: Thread) extends LazyLogging { watch =>
+class Watch(val mainThread: Thread) extends LazyLogging {
+ watch =>
private val watchServices = mutable.Map[FileSystem, WatchService]()
private val watchedDirs = mutable.Set[Path]()
private val watchedFiles = mutable.Set[Path]()
@@ -69,13 +76,12 @@ class Watch(val mainThread: Thread) extends LazyLogging { watch =>
private var debounceInterrupt = true
- def watchCount: Int =
- watchedFiles.size
+ def watchCount: Int = watchedFiles.size
def enroll(dirtyPath: Path): Unit = {
val path = dirtyPath.toAbsolutePath.normalize()
val parent = Option(path.getParent).getOrElse(path)
- if(!watchedDirs.contains(parent)) {
+ if (!watchedDirs.contains(parent)) {
watchedDirs += parent
val fs = parent.getFileSystem
val ws = watchServices.getOrElseUpdate(fs, fs.newWatchService())
@@ -98,10 +104,10 @@ class Watch(val mainThread: Thread) extends LazyLogging { watch =>
val parent = key.watchable().asInstanceOf[Path]
val events = key.pollEvents().asScala.toSeq
key.reset()
- for(event <- events) {
+ for (event <- events) {
val relPath = event.context().asInstanceOf[Path]
val path = parent.resolve(relPath)
- if(watchedFiles.contains(path) || watchedFiles.contains(parent)) {
+ if (watchedFiles.contains(path) || watchedFiles.contains(parent)) {
return true
}
}
@@ -109,59 +115,64 @@ class Watch(val mainThread: Thread) extends LazyLogging { watch =>
false
}
- private def fileWatchThread() = new Thread {
- override def run(): Unit = try {
- watchServices.values.toSeq match {
- case Nil => return
- case Seq(ws) =>
- // Typical: normally all plain files belong to one file system.
- while(!isWatchedFile(ws.take())) {}
- case watchServices =>
- breakable {
- while (true) {
- // We spend approximately 0.1s per pass over all [[WatchService]]s
- for (ws <- watchServices) {
- val key = Option(ws.poll(100_000 / watchServices.size, TimeUnit.MICROSECONDS))
-
- key match {
- case Some(key) if isWatchedFile(key) => break()
- case _ => // continue
+ private def fileWatchThread() =
+ new Thread {
+ override def run(): Unit =
+ try {
+ watchServices.values.toSeq match {
+ case Nil => return
+ case Seq(ws) =>
+ // Typical: normally all plain files belong to one file system.
+ while (!isWatchedFile(ws.take())) {}
+ case watchServices =>
+ breakable {
+ while (true) {
+ // We spend approximately 0.1s per pass over all [[WatchService]]s
+ for (ws <- watchServices) {
+ val key = Option(ws.poll(
+ 100_000 / watchServices.size,
+ TimeUnit.MICROSECONDS,
+ ))
+
+ key match {
+ case Some(key) if isWatchedFile(key) => break()
+ case _ => // continue
+ }
+ }
}
}
- }
}
- }
- watch.signal()
- } catch {
- case _: InterruptedException => // do nothing
- case _: ClosedWatchServiceException => // do nothing
+ watch.signal()
+ } catch {
+ case _: InterruptedException => // do nothing
+ case _: ClosedWatchServiceException => // do nothing
+ }
}
- }
- private def stdinWatchThread() = new Thread {
- override def run(): Unit = try {
- var res = System.in.read()
+ private def stdinWatchThread() =
+ new Thread {
+ override def run(): Unit =
+ try {
+ var res = System.in.read()
- while(res != -1 && res != '\n'.toInt) {
- res = System.in.read()
- }
+ while (res != -1 && res != '\n'.toInt) { res = System.in.read() }
- if(res == '\n'.toInt) {
- watch.signal()
- }
- } catch {
- case _: InterruptedException => // do nothing
+ if (res == '\n'.toInt) { watch.signal() }
+ } catch {
+ case _: InterruptedException => // do nothing
+ }
}
- }
- private def disableDebounceThread() = new Thread {
- override def run(): Unit = try {
- Thread.sleep(1000)
- debounceInterrupt = false
- } catch {
- case _: InterruptedException => // do nothing
+ private def disableDebounceThread() =
+ new Thread {
+ override def run(): Unit =
+ try {
+ Thread.sleep(1000)
+ debounceInterrupt = false
+ } catch {
+ case _: InterruptedException => // do nothing
+ }
}
- }
private def addThread(t: Thread): Unit = {
threads = t +: threads
@@ -170,33 +181,26 @@ class Watch(val mainThread: Thread) extends LazyLogging { watch =>
t.start()
}
- private def signal(): Unit = synchronized {
- triggered = true
- notifyAll()
- }
+ private def signal(): Unit =
+ synchronized {
+ triggered = true
+ notifyAll()
+ }
private def reset(): Unit = {
- for(ws <- watchServices.values) {
- ws.close()
- }
+ for (ws <- watchServices.values) { ws.close() }
watchServices.clear()
watchedDirs.clear()
watchedFiles.clear()
- for(inv <- toInvalidate) {
- inv.invalidate()
- }
+ for (inv <- toInvalidate) { inv.invalidate() }
toInvalidate = Nil
- for(thread <- threads) {
- thread.interrupt()
- }
+ for (thread <- threads) { thread.interrupt() }
- for(thread <- threads) {
- thread.join()
- }
+ for (thread <- threads) { thread.join() }
threads = Nil
@@ -205,28 +209,28 @@ class Watch(val mainThread: Thread) extends LazyLogging { watch =>
debounceInterrupt = true
}
- def await(): Unit = synchronized {
- addThread(fileWatchThread())
- addThread(stdinWatchThread())
+ def await(): Unit =
+ synchronized {
+ addThread(fileWatchThread())
+ addThread(stdinWatchThread())
- addThread(disableDebounceThread())
+ addThread(disableDebounceThread())
- logger.info(s"[Waiting for $watchCount external inputs to change - press ENTER to run again manually]")
+ logger.info(
+ s"[Waiting for $watchCount external inputs to change - press ENTER to run again manually]"
+ )
- while(!triggered) {
- try {
- wait()
- } catch {
- case _: InterruptedException =>
- if(debounceInterrupt) {
- logger.info(s"[Press Ctrl+C again to exit VerCors]")
- debounceInterrupt = false
- } else {
- throw new InterruptedException()
- }
+ while (!triggered) {
+ try { wait() }
+ catch {
+ case _: InterruptedException =>
+ if (debounceInterrupt) {
+ logger.info(s"[Press Ctrl+C again to exit VerCors]")
+ debounceInterrupt = false
+ } else { throw new InterruptedException() }
+ }
}
- }
- reset()
- }
-}
\ No newline at end of file
+ reset()
+ }
+}
diff --git a/src/hre/hre/io/Writeable.scala b/src/hre/hre/io/Writeable.scala
index 7a763c5937..9c2657f76f 100644
--- a/src/hre/hre/io/Writeable.scala
+++ b/src/hre/hre/io/Writeable.scala
@@ -8,10 +8,7 @@ trait Writeable {
def write[T](f: Writer => T): T = {
val writer = getWriter
- try {
- f(writer)
- } finally {
- writer.close()
- }
+ try { f(writer) }
+ finally { writer.close() }
}
}
diff --git a/src/hre/hre/log/LogHistory.scala b/src/hre/hre/log/LogHistory.scala
index 259f4165df..778383719b 100644
--- a/src/hre/hre/log/LogHistory.scala
+++ b/src/hre/hre/log/LogHistory.scala
@@ -12,12 +12,12 @@ object LogHistory {
class LogHistory extends AppenderBase[ILoggingEvent] {
override def append(e: ILoggingEvent): Unit = {
- if(!e.getMessage.isBlank)
- LogHistory.messages.append(new String(enc.encode(e), StandardCharsets.UTF_8))
+ if (!e.getMessage.isBlank)
+ LogHistory.messages
+ .append(new String(enc.encode(e), StandardCharsets.UTF_8))
}
var enc: Encoder[ILoggingEvent] = null
- def setEncoder(encoder: Encoder[ILoggingEvent]): Unit =
- enc = encoder
+ def setEncoder(encoder: Encoder[ILoggingEvent]): Unit = enc = encoder
}
diff --git a/src/hre/hre/perf/Profile.scala b/src/hre/hre/perf/Profile.scala
index 43e2ce8ada..fbf7cace60 100644
--- a/src/hre/hre/perf/Profile.scala
+++ b/src/hre/hre/perf/Profile.scala
@@ -11,9 +11,14 @@ case object Profile {
private var currentProfile: Option[Profile] = None
def install(profile: Boolean): Unit =
- if(profile) currentProfile = Some(Profile())
-
- def update(stack: Seq[String], ownUsage: ResourceUsage, doUpdateChildUsage: Boolean): Unit =
+ if (profile)
+ currentProfile = Some(Profile())
+
+ def update(
+ stack: Seq[String],
+ ownUsage: ResourceUsage,
+ doUpdateChildUsage: Boolean,
+ ): Unit =
currentProfile.foreach(_.update(stack, ownUsage, doUpdateChildUsage))
def finish(): Unit = {
@@ -44,35 +49,39 @@ case class Profile() {
private val samples = mutable.ArrayBuffer[Sample]()
- def update(stack: Seq[String], ownUsage: ResourceUsage, doUpdateChildUsage: Boolean): Unit = synchronized {
- val deltaChild = if (doUpdateChildUsage) {
- val childUsage = ResourceUsage.getAggregateChildren
- val deltaChild = childUsage - lastChildUsage
- lastChildUsage = childUsage
- deltaChild
- } else {
- ResourceUsage.zero
+ def update(
+ stack: Seq[String],
+ ownUsage: ResourceUsage,
+ doUpdateChildUsage: Boolean,
+ ): Unit =
+ synchronized {
+ val deltaChild =
+ if (doUpdateChildUsage) {
+ val childUsage = ResourceUsage.getAggregateChildren
+ val deltaChild = childUsage - lastChildUsage
+ lastChildUsage = childUsage
+ deltaChild
+ } else { ResourceUsage.zero }
+
+ val deltaAgg = deltaChild + ownUsage
+
+ val locations = stack.map(loc)
+
+ samples += Sample(
+ locationId = locations,
+ value = Seq(
+ deltaAgg.userTime + deltaAgg.systemTime,
+ deltaAgg.userTime,
+ deltaAgg.systemTime,
+ ownUsage.userTime,
+ ownUsage.systemTime,
+ deltaChild.userTime,
+ deltaChild.systemTime,
+ ownUsage.wallTime,
+ ),
+ )
}
- val deltaAgg = deltaChild + ownUsage
-
- val locations = stack.map(loc)
-
- samples += Sample(
- locationId = locations,
- value = Seq(
- deltaAgg.userTime + deltaAgg.systemTime,
- deltaAgg.userTime,
- deltaAgg.systemTime,
- ownUsage.userTime,
- ownUsage.systemTime,
- deltaChild.userTime,
- deltaChild.systemTime,
- ownUsage.wallTime,
- ),
- )
- }
-
def finish(): Unit = {
val result = perftools.profiles.Profile(
sampleType = valueTypes,
@@ -84,7 +93,8 @@ case class Profile() {
timeNanos = epochStartNanos,
defaultSampleType = builder.str("agg"),
)
- val out = new GZIPOutputStream(Files.newOutputStream(Paths.get("profile.pprof.gz")))
+ val out =
+ new GZIPOutputStream(Files.newOutputStream(Paths.get("profile.pprof.gz")))
result.writeTo(out)
out.close()
}
diff --git a/src/hre/hre/perf/ProfileBuilder.scala b/src/hre/hre/perf/ProfileBuilder.scala
index 5036bac1cb..94441247cf 100644
--- a/src/hre/hre/perf/ProfileBuilder.scala
+++ b/src/hre/hre/perf/ProfileBuilder.scala
@@ -9,10 +9,12 @@ class ProfileBuilder {
private val stringTable = mutable.ArrayBuffer[String]("")
def str(s: String): Long =
- stringIndex.getOrElseUpdate(s, {
- stringTable += s
- stringIndex.size
- })
+ stringIndex.getOrElseUpdate(
+ s, {
+ stringTable += s
+ stringIndex.size
+ },
+ )
def finishStringTable(): Seq[String] = stringTable.toIndexedSeq
@@ -21,15 +23,16 @@ class ProfileBuilder {
private val functionTable = mutable.ArrayBuffer[Function]()
def loc(s: String): Long =
- locationIndex.getOrElseUpdate(s, {
- val id = functionTable.size + 1
- functionTable += Function(id = id, name = str(s))
- locationTable += Location(id = id, line = Seq(Line(functionId = id)))
- id
- })
+ locationIndex.getOrElseUpdate(
+ s, {
+ val id = functionTable.size + 1
+ functionTable += Function(id = id, name = str(s))
+ locationTable += Location(id = id, line = Seq(Line(functionId = id)))
+ id
+ },
+ )
def finishLocationTable(): Seq[Location] = locationTable.toIndexedSeq
def finishFunctionTable(): Seq[Function] = functionTable.toIndexedSeq
-
}
diff --git a/src/hre/hre/perf/ResourceUsage.scala b/src/hre/hre/perf/ResourceUsage.scala
index fa3fb6342c..dd662eb782 100644
--- a/src/hre/hre/perf/ResourceUsage.scala
+++ b/src/hre/hre/perf/ResourceUsage.scala
@@ -17,11 +17,18 @@ object ResourceUsage {
case Platform.Unix | Platform.Mac =>
try {
val usage = new RUsage()
- if (LibC.INSTANCE.getrusage(who, usage) != 0) return fallback()
- ResourceUsage(usage.ru_utime.toUsec, usage.ru_stime.toUsec, usage.ru_inblock, usage.ru_oublock, usage.ru_nvcsw, usage.ru_nivcsw, System.nanoTime() / 1000L - boot)
- } catch {
- case _: UnsatisfiedLinkError => fallback()
- }
+ if (LibC.INSTANCE.getrusage(who, usage) != 0)
+ return fallback()
+ ResourceUsage(
+ usage.ru_utime.toUsec,
+ usage.ru_stime.toUsec,
+ usage.ru_inblock,
+ usage.ru_oublock,
+ usage.ru_nvcsw,
+ usage.ru_nivcsw,
+ System.nanoTime() / 1000L - boot,
+ )
+ } catch { case _: UnsatisfiedLinkError => fallback() }
case _ => fallback()
}
}
@@ -34,13 +41,13 @@ object ResourceUsage {
}
case class ResourceUsage(
- userTime: Microseconds,
- systemTime: Microseconds,
- readBlocks: Long,
- writtenBlocks: Long,
- voluntaryContextSwitches: Long,
- involuntaryContextSwitches: Long,
- wallTime: Microseconds,
+ userTime: Microseconds,
+ systemTime: Microseconds,
+ readBlocks: Long,
+ writtenBlocks: Long,
+ voluntaryContextSwitches: Long,
+ involuntaryContextSwitches: Long,
+ wallTime: Microseconds,
) {
override def toString: String =
s"user=${userTime}μs sys=${systemTime}μs in=${readBlocks}blocks out=${writtenBlocks}blocks voluntaryYield=${voluntaryContextSwitches} involuntaryYield=${involuntaryContextSwitches}"
@@ -51,8 +58,14 @@ case class ResourceUsage(
systemTime = op(systemTime, other.systemTime),
readBlocks = op(readBlocks, other.readBlocks),
writtenBlocks = op(writtenBlocks, other.writtenBlocks),
- voluntaryContextSwitches = op(voluntaryContextSwitches, other.voluntaryContextSwitches),
- involuntaryContextSwitches = op(involuntaryContextSwitches, other.involuntaryContextSwitches),
+ voluntaryContextSwitches = op(
+ voluntaryContextSwitches,
+ other.voluntaryContextSwitches,
+ ),
+ involuntaryContextSwitches = op(
+ involuntaryContextSwitches,
+ other.involuntaryContextSwitches,
+ ),
wallTime = op(wallTime, other.wallTime),
)
assert(result.userTime >= 0)
@@ -72,4 +85,4 @@ case class ResourceUsage(
def -(other: ResourceUsage): ResourceUsage = applyOp(_ - _)(other)
def +(other: ResourceUsage): ResourceUsage = applyOp(_ + _)(other)
-}
\ No newline at end of file
+}
diff --git a/src/hre/hre/platform/Platform.scala b/src/hre/hre/platform/Platform.scala
index 1ed04b56f2..5669eeb59b 100644
--- a/src/hre/hre/platform/Platform.scala
+++ b/src/hre/hre/platform/Platform.scala
@@ -10,16 +10,22 @@ case object Platform {
case object Mac extends Platform
case class UnknownPlatform(name: String) extends UserError {
- override def text: String = s"Unknown platform: $name. Please specify paths to binaries for z3 and boogie."
+ override def text: String =
+ s"Unknown platform: $name. Please specify paths to binaries for z3 and boogie."
override def code: String = "unknownPlatform"
}
val getCurrent: Platform = {
val name = System.getProperty("os.name").toLowerCase
- if(name.contains("win")) Platform.Windows
- else if(name.contains("linux")) Platform.Unix
- else if(name.contains("nix")) Platform.Unix
- else if(name.contains("mac")) Platform.Mac
- else throw UnknownPlatform(name)
+ if (name.contains("win"))
+ Platform.Windows
+ else if (name.contains("linux"))
+ Platform.Unix
+ else if (name.contains("nix"))
+ Platform.Unix
+ else if (name.contains("mac"))
+ Platform.Mac
+ else
+ throw UnknownPlatform(name)
}
}
diff --git a/src/hre/hre/progress/Layout.scala b/src/hre/hre/progress/Layout.scala
index 2960b555ef..64360ed6d2 100644
--- a/src/hre/hre/progress/Layout.scala
+++ b/src/hre/hre/progress/Layout.scala
@@ -13,30 +13,38 @@ case object Layout extends LazyLogging {
AnsiConsole.systemInstall()
}
- private def wantProgress: Boolean = AnsiConsole.out().getType match {
- case AnsiType.Native | AnsiType.VirtualTerminal | AnsiType.Emulation => true
- case AnsiType.Unsupported | AnsiType.Redirected => forceProgress
- }
+ private def wantProgress: Boolean =
+ AnsiConsole.out().getType match {
+ case AnsiType.Native | AnsiType.VirtualTerminal | AnsiType.Emulation =>
+ true
+ case AnsiType.Unsupported | AnsiType.Redirected => forceProgress
+ }
- private def wantPrettyProgress: Boolean = AnsiConsole.out().getType match {
- case AnsiType.Native | AnsiType.VirtualTerminal | AnsiType.Emulation => true
- case AnsiType.Unsupported | AnsiType.Redirected => false
- }
+ private def wantPrettyProgress: Boolean =
+ AnsiConsole.out().getType match {
+ case AnsiType.Native | AnsiType.VirtualTerminal | AnsiType.Emulation =>
+ true
+ case AnsiType.Unsupported | AnsiType.Redirected => false
+ }
- def maxWidth: Int = (AnsiConsole.out().getTerminalWidth match {
- case 0 => 80
- case other => other
- }) - 2
+ def maxWidth: Int =
+ (AnsiConsole.out().getTerminalWidth match {
+ case 0 => 80
+ case other => other
+ }) - 2
def maxHeight: Int = 32
- def esc(command: Char, args: String = ""): String =
- "\u001b[" + args + command
+ def esc(command: Char, args: String = ""): String = "\u001b[" + args + command
def osc(command: String, arg: String): String =
"\u001b]" + command + ";" + arg + "\u001b\\"
- def upBy(n: Int): String = if(n==0) "" else esc('A', n.toString)
+ def upBy(n: Int): String =
+ if (n == 0)
+ ""
+ else
+ esc('A', n.toString)
def clearLine: String = esc('K')
def clearToEnd: String = esc('J', "0")
@@ -50,64 +58,71 @@ case object Layout extends LazyLogging {
def undoProgressMessage: String =
if (wantProgress) {
- if (wantPrettyProgress) {
- upBy(printedLines) + clearToEnd
- } else {
- "\r" + " ".repeat(maxWidth) + "\r"
- }
- } else ""
+ if (wantPrettyProgress) { upBy(printedLines) + clearToEnd }
+ else { "\r" + " ".repeat(maxWidth) + "\r" }
+ } else
+ ""
def progressEstimate: Double = TaskRegistry.getRootTask.progress
- def progressBadge: String =
- f"[${progressEstimate * 100}%.1f%%]"
+ def progressBadge: String = f"[${progressEstimate * 100}%.1f%%]"
def progressBar: String = {
val prefix = progressBadge + " ["
val postfix = "]"
val maxProgressBarWidth = maxWidth - prefix.length - postfix.length
val bumpedProgress = progressEstimate * 0.99 + 0.01
- val progress = (bumpedProgress * maxProgressBarWidth * PROGRESS_BLOCKS.length).toInt
+ val progress =
+ (bumpedProgress * maxProgressBarWidth * PROGRESS_BLOCKS.length).toInt
val fullBlocks = progress / PROGRESS_BLOCKS.length
val halfBlockIdx = progress % PROGRESS_BLOCKS.length
- prefix + (
- if (halfBlockIdx == 0) PROGRESS_BLOCKS.last.toString.repeat(fullBlocks) + " ".repeat(maxProgressBarWidth - fullBlocks)
- else PROGRESS_BLOCKS.last.toString.repeat(fullBlocks) + PROGRESS_BLOCKS(halfBlockIdx) + " ".repeat(maxProgressBarWidth - fullBlocks - 1)
- ) + postfix
+ prefix +
+ (if (halfBlockIdx == 0)
+ PROGRESS_BLOCKS.last.toString.repeat(fullBlocks) +
+ " ".repeat(maxProgressBarWidth - fullBlocks)
+ else
+ PROGRESS_BLOCKS.last.toString.repeat(fullBlocks) +
+ PROGRESS_BLOCKS(halfBlockIdx) +
+ " ".repeat(maxProgressBarWidth - fullBlocks - 1)) + postfix
}
def updateProgressMessage(): Unit =
- currentProgressMessage = if (TaskRegistry.rootTask.nonEmpty && TaskRegistry.getRootTask.nonEmpty) {
- if (wantProgress) {
- if (wantPrettyProgress) {
- val lines = TaskRegistry.getRootTask.render(maxWidth, maxHeight-1)
- progressMessageLines = lines.size + 1
- (progressBar +: lines).mkString("", f"%n", f"%n")
- } else {
- val lines = TaskRegistry.getRootTask.render(maxWidth, 1)
- s"$progressBadge ${lines.last}"
- }
- } else ""
- } else {
- progressMessageLines = 0
- ""
- }
+ currentProgressMessage =
+ if (TaskRegistry.rootTask.nonEmpty && TaskRegistry.getRootTask.nonEmpty) {
+ if (wantProgress) {
+ if (wantPrettyProgress) {
+ val lines = TaskRegistry.getRootTask.render(maxWidth, maxHeight - 1)
+ progressMessageLines = lines.size + 1
+ (progressBar +: lines).mkString("", f"%n", f"%n")
+ } else {
+ val lines = TaskRegistry.getRootTask.render(maxWidth, 1)
+ s"$progressBadge ${lines.last}"
+ }
+ } else
+ ""
+ } else {
+ progressMessageLines = 0
+ ""
+ }
- /**
- * Print an updated progress message to stdout
- * @return whether the number of printed progress lines changed
- */
- def update(): Boolean = synchronized {
- val lastPrintedLines = printedLines
- updateProgressMessage()
- logger.info("")
- printedLines > lastPrintedLines
- }
+ /** Print an updated progress message to stdout
+ * @return
+ * whether the number of printed progress lines changed
+ */
+ def update(): Boolean =
+ synchronized {
+ val lastPrintedLines = printedLines
+ updateProgressMessage()
+ logger.info("")
+ printedLines > lastPrintedLines
+ }
- def commitProgressMessage(outputBeforeProgress: String): String = synchronized {
- val toPrint = undoProgressMessage + outputBeforeProgress + currentProgressMessage
- printedLines = progressMessageLines
- toPrint
- }
+ def commitProgressMessage(outputBeforeProgress: String): String =
+ synchronized {
+ val toPrint =
+ undoProgressMessage + outputBeforeProgress + currentProgressMessage
+ printedLines = progressMessageLines
+ toPrint
+ }
}
diff --git a/src/hre/hre/progress/Progress.scala b/src/hre/hre/progress/Progress.scala
index 1a5f1c7f2b..4d229197d6 100644
--- a/src/hre/hre/progress/Progress.scala
+++ b/src/hre/hre/progress/Progress.scala
@@ -17,29 +17,31 @@ case object Progress {
Profile.install(profile)
}
- def finish(): Unit = synchronized {
- blockLayoutUpdateTask.foreach(_.cancel())
- blockLayoutUpdateTimer.foreach { timer =>
- timer.purge()
- timer.cancel()
+ def finish(): Unit =
+ synchronized {
+ blockLayoutUpdateTask.foreach(_.cancel())
+ blockLayoutUpdateTimer.foreach { timer =>
+ timer.purge()
+ timer.cancel()
+ }
+ blockLayoutUpdateTimer = None
+ TaskRegistry.finish()
+ Layout.update()
+ Profile.finish()
}
- blockLayoutUpdateTimer = None
- TaskRegistry.finish()
- Layout.update()
- Profile.finish()
- }
- def abort(): Unit = synchronized {
- blockLayoutUpdateTask.foreach(_.cancel())
- blockLayoutUpdateTimer.foreach { timer =>
- timer.purge()
- timer.cancel()
+ def abort(): Unit =
+ synchronized {
+ blockLayoutUpdateTask.foreach(_.cancel())
+ blockLayoutUpdateTimer.foreach { timer =>
+ timer.purge()
+ timer.cancel()
+ }
+ blockLayoutUpdateTimer = None
+ TaskRegistry.abort()
+ Layout.update()
+ Profile.finish()
}
- blockLayoutUpdateTimer = None
- TaskRegistry.abort()
- Layout.update()
- Profile.finish()
- }
private var blockLayoutUpdateTimer: Option[Timer] = None
private var blockLayoutUpdateTask: Option[TimerTask] = None
@@ -51,69 +53,73 @@ case object Progress {
blockLayoutUpdateTask.foreach(_.cancel())
blockLayoutUpdateTimer.get.purge()
blockLayoutUpdateTask = Some(new TimerTask {
- override def run(): Unit = Progress.synchronized {
- if (newLayoutAfterTimeout) {
- val printedLinesDidChange = Layout.update()
- newLayoutAfterTimeout = false
- delayNextUpdate(longDelay = printedLinesDidChange)
- } else {
- blockLayoutUpdate = false
+ override def run(): Unit =
+ Progress.synchronized {
+ if (newLayoutAfterTimeout) {
+ val printedLinesDidChange = Layout.update()
+ newLayoutAfterTimeout = false
+ delayNextUpdate(longDelay = printedLinesDidChange)
+ } else { blockLayoutUpdate = false }
}
- }
})
- val updateInterval = if(longDelay) UPDATE_INTERAL_LONG_MS else UPDATE_INTERVAL_MS
- blockLayoutUpdateTimer.get.schedule(blockLayoutUpdateTask.get, updateInterval)
+ val updateInterval =
+ if (longDelay)
+ UPDATE_INTERAL_LONG_MS
+ else
+ UPDATE_INTERVAL_MS
+ blockLayoutUpdateTimer.get
+ .schedule(blockLayoutUpdateTask.get, updateInterval)
}
- def update(): Unit = Progress.synchronized {
- if(blockLayoutUpdate) {
- newLayoutAfterTimeout = true
- } else {
- val printedLinesDidChange = Layout.update()
- newLayoutAfterTimeout = false
- delayNextUpdate(longDelay = printedLinesDidChange)
+ def update(): Unit =
+ Progress.synchronized {
+ if (blockLayoutUpdate) { newLayoutAfterTimeout = true }
+ else {
+ val printedLinesDidChange = Layout.update()
+ newLayoutAfterTimeout = false
+ delayNextUpdate(longDelay = printedLinesDidChange)
+ }
}
- }
private def tryWeight(xs: IterableOnce[_]): Option[Double] =
- if(xs.knownSize > 0) Some(1.0 / xs.knownSize)
- else None
+ if (xs.knownSize > 0)
+ Some(1.0 / xs.knownSize)
+ else
+ None
def foreach[T](xs: IterableOnce[T], desc: T => String)(f: T => Unit): Unit =
- if(TaskRegistry.enabled) {
+ if (TaskRegistry.enabled) {
val superTask = TaskRegistry.currentTaskInThread
xs.iterator.foreach(x => {
- SimpleNamedTask(superTask, desc(x), tryWeight(xs)).frame {
- f(x)
- }
+ SimpleNamedTask(superTask, desc(x), tryWeight(xs)).frame { f(x) }
})
- } else {
- xs.iterator.foreach(f)
- }
+ } else { xs.iterator.foreach(f) }
- def map[T, S](xs: IterableOnce[T], desc: T => String)(f: T => S): IterableOnce[S] =
- if(TaskRegistry.enabled) {
+ def map[T, S](xs: IterableOnce[T], desc: T => String)(
+ f: T => S
+ ): IterableOnce[S] =
+ if (TaskRegistry.enabled) {
val superTask = TaskRegistry.currentTaskInThread
xs.iterator.map(x => {
- SimpleNamedTask(superTask, desc(x), tryWeight(xs)).frame {
- f(x)
- }
+ SimpleNamedTask(superTask, desc(x), tryWeight(xs)).frame { f(x) }
})
- } else {
- xs.iterator.map(f)
- }
+ } else { xs.iterator.map(f) }
def stages[T](names: Seq[(String, Int)])(f: (() => Unit) => T): T =
- if(TaskRegistry.enabled) {
+ if (TaskRegistry.enabled) {
val sum = names.map(_._2).sum
val weights = names.map(_._2.toDouble / sum)
- NameSequenceTask(TaskRegistry.currentTaskInThread, names.map(_._1), weights).scope(f)
+ NameSequenceTask(
+ TaskRegistry.currentTaskInThread,
+ names.map(_._1),
+ weights,
+ ).scope(f)
} else
f(() => {})
def dynamicMessages[T](count: Int)(f: (String => Unit) => T): T =
- if(TaskRegistry.enabled)
+ if (TaskRegistry.enabled)
UpdateableTask(TaskRegistry.currentTaskInThread, Some(count)).scope(f)
else
f(_ => {})
-}
\ No newline at end of file
+}
diff --git a/src/hre/hre/progress/ProgressAwareLogbackLayout.scala b/src/hre/hre/progress/ProgressAwareLogbackLayout.scala
index a5532eb51c..37a8a97962 100644
--- a/src/hre/hre/progress/ProgressAwareLogbackLayout.scala
+++ b/src/hre/hre/progress/ProgressAwareLogbackLayout.scala
@@ -16,14 +16,12 @@ class ProgressAwareLogbackLayout extends LayoutBase[ILoggingEvent] {
System.out.flush()
val message = event.getFormattedMessage
val baseMessage =
- if(message.isBlank)
+ if (message.isBlank)
""
- else if(message.contains('\n'))
- event.getFormattedMessage.strip +
- CoreConstants.LINE_SEPARATOR
+ else if (message.contains('\n'))
+ event.getFormattedMessage.strip + CoreConstants.LINE_SEPARATOR
else
- s"[${event.getLevel}] " +
- event.getFormattedMessage +
+ s"[${event.getLevel}] " + event.getFormattedMessage +
CoreConstants.LINE_SEPARATOR
Layout.commitProgressMessage(baseMessage + tpc.convert(event))
diff --git a/src/hre/hre/progress/ProgressLogicError.scala b/src/hre/hre/progress/ProgressLogicError.scala
index 64f04c3e2f..fdfcb97d0b 100644
--- a/src/hre/hre/progress/ProgressLogicError.scala
+++ b/src/hre/hre/progress/ProgressLogicError.scala
@@ -2,6 +2,9 @@ package hre.progress
import vct.result.VerificationError.SystemError
-class ProgressLogicError(trail: Seq[String], amount: Double) extends SystemError {
- override def text: String = s"The amount of progress ($amount) exceeds the range [0; 1] at trail: ${trail.reverse.mkString(" > ")}"
+class ProgressLogicError(trail: Seq[String], amount: Double)
+ extends SystemError {
+ override def text: String =
+ s"The amount of progress ($amount) exceeds the range [0; 1] at trail: ${trail
+ .reverse.mkString(" > ")}"
}
diff --git a/src/hre/hre/progress/ProgressRender.scala b/src/hre/hre/progress/ProgressRender.scala
index fdb547fea5..0376817060 100644
--- a/src/hre/hre/progress/ProgressRender.scala
+++ b/src/hre/hre/progress/ProgressRender.scala
@@ -12,27 +12,30 @@ case object ProgressRender {
val BRANCH = "├"
val HOOK = "â””"
- def apply(label: String): ProgressRender =
- ProgressRender(Seq(label), 0)
+ def apply(label: String): ProgressRender = ProgressRender(Seq(label), 0)
}
case class ProgressRender(lines: Seq[String], primaryLineIndex: Int) {
def prefix(prefix: String): ProgressRender =
- copy(lines = lines.take(primaryLineIndex) ++ Seq(prefix + lines(primaryLineIndex)) ++ lines.drop(primaryLineIndex+1))
+ copy(lines =
+ lines.take(primaryLineIndex) ++ Seq(prefix + lines(primaryLineIndex)) ++
+ lines.drop(primaryLineIndex + 1)
+ )
def postfix(postfix: String): ProgressRender =
- copy(lines = lines.take(primaryLineIndex) ++ Seq(lines(primaryLineIndex) + postfix) ++ lines.drop(primaryLineIndex+1))
+ copy(lines =
+ lines.take(primaryLineIndex) ++ Seq(lines(primaryLineIndex) + postfix) ++
+ lines.drop(primaryLineIndex + 1)
+ )
def subRenders(renders: Seq[(String, ProgressRender)]): ProgressRender = {
- val prefixedInit = renders.init.map {
- case (badge, unbadgedRender) =>
- val render = unbadgedRender.prefix(badge)
- render.lines.zipWithIndex.map {
- case (line, idx) if idx == render.primaryLineIndex =>
- BRANCH + HORIZONTAL_LINE + " " + line
- case (line, _) =>
- VERTICAL_LINE + " " + " " + line
- }
+ val prefixedInit = renders.init.map { case (badge, unbadgedRender) =>
+ val render = unbadgedRender.prefix(badge)
+ render.lines.zipWithIndex.map {
+ case (line, idx) if idx == render.primaryLineIndex =>
+ BRANCH + HORIZONTAL_LINE + " " + line
+ case (line, _) => VERTICAL_LINE + " " + " " + line
+ }
}
val prefixedLast = {
@@ -43,11 +46,13 @@ case class ProgressRender(lines: Seq[String], primaryLineIndex: Int) {
VERTICAL_LINE + " " + " " + line
case (line, idx) if idx == render.primaryLineIndex =>
HOOK + HORIZONTAL_LINE + " " + line
- case (line, _) =>
- " ".repeat(3) + line
+ case (line, _) => " ".repeat(3) + line
}
}
- ProgressRender(lines ++ prefixedInit.flatten ++ prefixedLast, primaryLineIndex)
+ ProgressRender(
+ lines ++ prefixedInit.flatten ++ prefixedLast,
+ primaryLineIndex,
+ )
}
-}
\ No newline at end of file
+}
diff --git a/src/hre/hre/progress/TaskRegistry.scala b/src/hre/hre/progress/TaskRegistry.scala
index 5ae1d66839..1913fb6150 100644
--- a/src/hre/hre/progress/TaskRegistry.scala
+++ b/src/hre/hre/progress/TaskRegistry.scala
@@ -8,55 +8,60 @@ import scala.collection.mutable.ArrayBuffer
case object TaskRegistry {
private var mainThreadId = -1L
private var mainThreadRootTask: Option[RootTask] = None
- val threadTaskStack: ThreadLocal[ArrayBuffer[AbstractTask]] = ThreadLocal.withInitial(() => ArrayBuffer())
+ val threadTaskStack: ThreadLocal[ArrayBuffer[AbstractTask]] = ThreadLocal
+ .withInitial(() => ArrayBuffer())
def enabled: Boolean = mainThreadRootTask.isDefined
- def install(): Unit = synchronized {
- mainThreadId = Thread.currentThread().getId
- mainThreadRootTask = Some(RootTask())
- getRootTask.start()
- }
+ def install(): Unit =
+ synchronized {
+ mainThreadId = Thread.currentThread().getId
+ mainThreadRootTask = Some(RootTask())
+ getRootTask.start()
+ }
- def finish(): Unit = synchronized {
- getRootTask.end()
- mainThreadRootTask = None
- }
+ def finish(): Unit =
+ synchronized {
+ getRootTask.end()
+ mainThreadRootTask = None
+ }
- def abort(): Unit = synchronized {
- mainThreadRootTask.foreach(_.abort())
- mainThreadRootTask = None
- }
+ def abort(): Unit =
+ synchronized {
+ mainThreadRootTask.foreach(_.abort())
+ mainThreadRootTask = None
+ }
def isMainThread: Boolean = Thread.currentThread().getId == mainThreadId
def rootTask: Option[RootTask] = mainThreadRootTask
def getRootTask: RootTask = rootTask.get
- /**
- * SAFETY: If called from a non-main thread, a task with an explicit superTask must be started first. This is for
- * example the case when a thread is started as Progress.{foreach,map}(xs.par, _) { ... }: the superTask is
- * established in the thread setting up the parallel run.
- */
- def currentTaskInThread: AbstractTask =
- threadTaskStack.get().last
+ /** SAFETY: If called from a non-main thread, a task with an explicit
+ * superTask must be started first. This is for example the case when a
+ * thread is started as Progress.{foreach,map}(xs.par, _) { ... }: the
+ * superTask is established in the thread setting up the parallel run.
+ */
+ def currentTaskInThread: AbstractTask = threadTaskStack.get().last
def push(task: AbstractTask): Unit =
- if(enabled)
+ if (enabled)
threadTaskStack.get() += task
def pop(task: AbstractTask): Unit =
- if(enabled)
- if(Thread.currentThread().getId == task.getOwnerThread) {
+ if (enabled)
+ if (Thread.currentThread().getId == task.getOwnerThread) {
assert(threadTaskStack.get().lastOption.contains(task))
threadTaskStack.get() -= task
}
def ownUsage(): ResourceUsage =
- if(enabled) {
- if(isMainThread) ResourceUsage.getProcess
- else ResourceUsage.getCallingThread
- }
- else ResourceUsage.zero
+ if (enabled) {
+ if (isMainThread)
+ ResourceUsage.getProcess
+ else
+ ResourceUsage.getCallingThread
+ } else
+ ResourceUsage.zero
def reportUsage(usage: ResourceUsage, trail: Seq[String]): Unit =
Profile.update(trail, usage, doUpdateChildUsage = isMainThread)
diff --git a/src/hre/hre/progress/task/AbstractTask.scala b/src/hre/hre/progress/task/AbstractTask.scala
index ce82a35291..3bf3f10d3b 100644
--- a/src/hre/hre/progress/task/AbstractTask.scala
+++ b/src/hre/hre/progress/task/AbstractTask.scala
@@ -17,23 +17,30 @@ abstract class AbstractTask {
def progressWeight: Option[Double] = None
protected var progressDone: Double = 0.0
- def progress: Double = synchronized {
- val subtaksProgress = subTasks.map(t => t.progressWeight -> t.progress)
- val knownWeightProgress = subtaksProgress.collect { case Some(weight) -> progress => weight * progress }.sum[Double]
- val knownDone = progressDone + knownWeightProgress
- val unknownWeightProgress = subtaksProgress.collect { case None -> progress => progress }.sortBy(-_)
- val result = unknownWeightProgress.foldLeft(knownDone) {
- case (progress, subtaskProgress) => progress + ((1.0 - progress) * 0.1 * subtaskProgress)
- }
+ def progress: Double =
+ synchronized {
+ val subtaksProgress = subTasks.map(t => t.progressWeight -> t.progress)
+ val knownWeightProgress = subtaksProgress.collect {
+ case Some(weight) -> progress => weight * progress
+ }.sum[Double]
+ val knownDone = progressDone + knownWeightProgress
+ val unknownWeightProgress = subtaksProgress.collect {
+ case None -> progress => progress
+ }.sortBy(-_)
+ val result =
+ unknownWeightProgress.foldLeft(knownDone) {
+ case (progress, subtaskProgress) =>
+ progress + ((1.0 - progress) * 0.1 * subtaskProgress)
+ }
- if(result < 0.0 - EPILSON || result > 1.0 + EPILSON) {
- throw new ProgressLogicError(profilingTrail, result)
- }
+ if (result < 0.0 - EPILSON || result > 1.0 + EPILSON) {
+ throw new ProgressLogicError(profilingTrail, result)
+ }
- if(result > 1.0) {
- 1.0
- } else result
- }
+ if (result > 1.0) { 1.0 }
+ else
+ result
+ }
private var ownerThread = -1L
def getOwnerThread: Long = ownerThread
@@ -41,21 +48,23 @@ abstract class AbstractTask {
def superTaskOrRoot: Option[AbstractTask]
def profilingBreadcrumb: String
- def profilingTrail: Seq[String] = profilingBreadcrumb +: superTaskOrRoot.toSeq.flatMap(_.profilingTrail)
+ def profilingTrail: Seq[String] =
+ profilingBreadcrumb +: superTaskOrRoot.toSeq.flatMap(_.profilingTrail)
def renderHere: ProgressRender
def renderHereShort: ProgressRender = renderHere
- def poll(): ResourceUsage = synchronized {
- if(Thread.currentThread().getId != ownerThread)
- return TaskRegistry.ownUsage()
+ def poll(): ResourceUsage =
+ synchronized {
+ if (Thread.currentThread().getId != ownerThread)
+ return TaskRegistry.ownUsage()
- val usage = TaskRegistry.ownUsage()
- val delta = usage - startUsage.get - usageReported
- TaskRegistry.reportUsage(delta, profilingTrail)
- usageReported += delta
- usage
- }
+ val usage = TaskRegistry.ownUsage()
+ val delta = usage - startUsage.get - usageReported
+ TaskRegistry.reportUsage(delta, profilingTrail)
+ usageReported += delta
+ usage
+ }
def start(): Unit = {
ownerThread = Thread.currentThread().getId
@@ -86,7 +95,8 @@ abstract class AbstractTask {
superTask.synchronized {
superTask.subTasks -= this
superTask.usageReported += usageReported
- superTask.progressDone += progressWeight.getOrElse(0.1 * (1.0 - superTask.progressDone))
+ superTask.progressDone +=
+ progressWeight.getOrElse(0.1 * (1.0 - superTask.progressDone))
}
}
@@ -105,61 +115,62 @@ abstract class AbstractTask {
end()
}
- private def renderProgressWith(depthForDetail: Int): ProgressRender = synchronized {
- val here = if(depthForDetail <= 0) renderHere else renderHereShort
- val sub = subTasks.toIndexedSeq
-
- sub match {
- case Nil =>
- here
- case Seq(sub) =>
- val subRender = sub.renderProgressWith(depthForDetail - 1)
- if(subRender.lines.size == 1)
- here.postfix(ProgressRender.JOIN + subRender.lines.head)
- else if(here.lines.size == 1 && subRender.primaryLineIndex == 0)
- subRender.prefix(here.lines.head + ProgressRender.JOIN)
+ private def renderProgressWith(depthForDetail: Int): ProgressRender =
+ synchronized {
+ val here =
+ if (depthForDetail <= 0)
+ renderHere
else
- here.subRenders(Seq(f"[${sub.progress * 100}%.1f%%] " -> subRender))
- case subs =>
- here.subRenders(subs.map { sub =>
- f"[${sub.progress * 100}%.1f%%] " -> sub.renderProgressWith(depthForDetail - 1)
- })
+ renderHereShort
+ val sub = subTasks.toIndexedSeq
+
+ sub match {
+ case Nil => here
+ case Seq(sub) =>
+ val subRender = sub.renderProgressWith(depthForDetail - 1)
+ if (subRender.lines.size == 1)
+ here.postfix(ProgressRender.JOIN + subRender.lines.head)
+ else if (here.lines.size == 1 && subRender.primaryLineIndex == 0)
+ subRender.prefix(here.lines.head + ProgressRender.JOIN)
+ else
+ here.subRenders(Seq(f"[${sub.progress * 100}%.1f%%] " -> subRender))
+ case subs =>
+ here.subRenders(subs.map { sub =>
+ f"[${sub.progress * 100}%.1f%%] " ->
+ sub.renderProgressWith(depthForDetail - 1)
+ })
+ }
}
- }
def render(maxWidth: Int, maxHeight: Int): Seq[String] = {
- val progress = (0 until 10).to(LazyList).map(renderProgressWith).collectFirst {
- case render if render.lines.size <= maxHeight => render
- }.getOrElse(renderProgressWith(1000))
-
- progress.lines
- .takeRight(maxHeight)
- .map { line =>
- if(line.length <= maxWidth) line
- else {
- val avail = maxWidth - ProgressRender.ELLIPSIS.length
- val split = avail * 2 / 3
- line.take(split) + ProgressRender.ELLIPSIS + line.takeRight(avail - split)
- }
+ val progress = (0 until 10).to(LazyList).map(renderProgressWith)
+ .collectFirst { case render if render.lines.size <= maxHeight => render }
+ .getOrElse(renderProgressWith(1000))
+
+ progress.lines.takeRight(maxHeight).map { line =>
+ if (line.length <= maxWidth)
+ line
+ else {
+ val avail = maxWidth - ProgressRender.ELLIPSIS.length
+ val split = avail * 2 / 3
+ line.take(split) + ProgressRender.ELLIPSIS +
+ line.takeRight(avail - split)
}
+ }
}
def nonEmpty: Boolean = synchronized { subTasks.nonEmpty }
def frame[T](f: => T): T = {
start()
- try {
- f
- } finally {
- end()
- }
+ try { f }
+ finally { end() }
}
def frame1[I, O](f: I => O): I => O =
- (i) => try {
- start()
- f(i)
- } finally {
- end()
- }
-}
\ No newline at end of file
+ (i) =>
+ try {
+ start()
+ f(i)
+ } finally { end() }
+}
diff --git a/src/hre/hre/progress/task/NameSequenceTask.scala b/src/hre/hre/progress/task/NameSequenceTask.scala
index 288c6b626c..c75712f377 100644
--- a/src/hre/hre/progress/task/NameSequenceTask.scala
+++ b/src/hre/hre/progress/task/NameSequenceTask.scala
@@ -1,7 +1,11 @@
package hre.progress.task
import hre.progress.ProgressRender
-case class NameSequenceTask(superTask: AbstractTask, var names: Seq[String], var progressWeights: Seq[Double] = Nil) extends Task {
+case class NameSequenceTask(
+ superTask: AbstractTask,
+ var names: Seq[String],
+ var progressWeights: Seq[Double] = Nil,
+) extends Task {
override def profilingBreadcrumb: String = names.head
override def renderHere: ProgressRender = ProgressRender(names.head)
@@ -9,17 +13,18 @@ case class NameSequenceTask(superTask: AbstractTask, var names: Seq[String], var
def scope[T](f: (() => Unit) => T): T = {
start()
- try {
- f(next)
- } finally {
- end()
- }
+ try { f(next) }
+ finally { end() }
}
private def next(): Unit = {
end()
names = names.tail
- progressWeights = if(progressWeights.isEmpty) Nil else progressWeights.tail
+ progressWeights =
+ if (progressWeights.isEmpty)
+ Nil
+ else
+ progressWeights.tail
progressDone = 0.0
start()
}
diff --git a/src/hre/hre/progress/task/RootTask.scala b/src/hre/hre/progress/task/RootTask.scala
index 8bf29c1be1..e2dc76b707 100644
--- a/src/hre/hre/progress/task/RootTask.scala
+++ b/src/hre/hre/progress/task/RootTask.scala
@@ -9,8 +9,6 @@ case class RootTask() extends AbstractTask {
override def end(): Unit = {
poll()
val stack = TaskRegistry.threadTaskStack.get()
- if(stack.lastOption.contains(this)) {
- stack.remove(stack.length - 1)
- }
+ if (stack.lastOption.contains(this)) { stack.remove(stack.length - 1) }
}
}
diff --git a/src/hre/hre/progress/task/SimpleNamedTask.scala b/src/hre/hre/progress/task/SimpleNamedTask.scala
index 5d367c32b6..2c8ea839a0 100644
--- a/src/hre/hre/progress/task/SimpleNamedTask.scala
+++ b/src/hre/hre/progress/task/SimpleNamedTask.scala
@@ -1,7 +1,11 @@
package hre.progress.task
import hre.progress.ProgressRender
-case class SimpleNamedTask(superTask: AbstractTask, name: String, override val progressWeight: Option[Double] = None) extends Task {
+case class SimpleNamedTask(
+ superTask: AbstractTask,
+ name: String,
+ override val progressWeight: Option[Double] = None,
+) extends Task {
override def profilingBreadcrumb: String = name
override def renderHere: ProgressRender = ProgressRender(name)
}
diff --git a/src/hre/hre/progress/task/UpdateableTask.scala b/src/hre/hre/progress/task/UpdateableTask.scala
index b485cb3d3e..f956dc846e 100644
--- a/src/hre/hre/progress/task/UpdateableTask.scala
+++ b/src/hre/hre/progress/task/UpdateableTask.scala
@@ -1,25 +1,33 @@
package hre.progress.task
import hre.progress.ProgressRender
-case class UpdateableTask(superTask: AbstractTask, approxUpdates: Option[Int] = None) extends Task {
+case class UpdateableTask(
+ superTask: AbstractTask,
+ approxUpdates: Option[Int] = None,
+) extends Task {
private var currentName: Option[String] = None
private var updatesDone = 0
override def progressWeight: Option[Double] =
- approxUpdates.map(approxUpdates => if(updatesDone < approxUpdates) 1.0 / approxUpdates else 0.0)
+ approxUpdates.map(approxUpdates =>
+ if (updatesDone < approxUpdates)
+ 1.0 / approxUpdates
+ else
+ 0.0
+ )
override def profilingBreadcrumb: String = currentName.get
override def renderHere: ProgressRender = ProgressRender(currentName.get)
def scope[T](f: (String => Unit) => T): T =
- try {
- f(update)
- } finally {
- if(currentName.isDefined) end()
+ try { f(update) }
+ finally {
+ if (currentName.isDefined)
+ end()
}
private def update(name: String): Unit = {
- if(currentName.isDefined) {
+ if (currentName.isDefined) {
end()
progressDone = 0.0
}
diff --git a/src/hre/hre/resource/ResourceUtil.scala b/src/hre/hre/resource/ResourceUtil.scala
index a3b64881c0..16fe60faae 100644
--- a/src/hre/hre/resource/ResourceUtil.scala
+++ b/src/hre/hre/resource/ResourceUtil.scala
@@ -8,26 +8,28 @@ import java.nio.file.{Path, Paths}
case object ResourceUtil {
case class NoSuchResource(path: String) extends SystemError {
- override def text: String = s"Could not find required resource at path $path"
+ override def text: String =
+ s"Could not find required resource at path $path"
}
- def getResource(path: String): Path = try {
- Option(getClass.getResource(path)) match {
- case Some(url) => Paths.get(url.toURI)
- case None => throw NoSuchResource(path)
- }
- } catch {
- case _: URISyntaxException => throw NoSuchResource(path)
- }
+ def getResource(path: String): Path =
+ try {
+ Option(getClass.getResource(path)) match {
+ case Some(url) => Paths.get(url.toURI)
+ case None => throw NoSuchResource(path)
+ }
+ } catch { case _: URISyntaxException => throw NoSuchResource(path) }
- def getPlatformDep(tail: String): Path = Platform.getCurrent match {
- case Platform.Windows => getResource(s"/win/$tail")
- case Platform.Unix => getResource(s"/unix/$tail")
- case Platform.Mac => getResource(s"/darwin/$tail")
- }
+ def getPlatformDep(tail: String): Path =
+ Platform.getCurrent match {
+ case Platform.Windows => getResource(s"/win/$tail")
+ case Platform.Unix => getResource(s"/unix/$tail")
+ case Platform.Mac => getResource(s"/darwin/$tail")
+ }
- def getPlatformBinary(tail: String): Path = Platform.getCurrent match {
- case Platform.Windows => getPlatformDep(tail + ".exe")
- case _ => getPlatformDep(tail)
- }
+ def getPlatformBinary(tail: String): Path =
+ Platform.getCurrent match {
+ case Platform.Windows => getPlatformDep(tail + ".exe")
+ case _ => getPlatformDep(tail)
+ }
}
diff --git a/src/hre/hre/stages/Stages.scala b/src/hre/hre/stages/Stages.scala
index 9c3ca815e5..97380ef3b8 100644
--- a/src/hre/hre/stages/Stages.scala
+++ b/src/hre/hre/stages/Stages.scala
@@ -9,20 +9,23 @@ trait Stage[-Input, +Output] {
def run(in: Input): Output
- def thenRun[NewOutput](stage: Stage[Output, NewOutput]): Stages[Input, NewOutput] =
- UnitStages(this).thenRun(stage)
+ def thenRun[NewOutput](
+ stage: Stage[Output, NewOutput]
+ ): Stages[Input, NewOutput] = UnitStages(this).thenRun(stage)
- def thenRun[NewOutput](stages: Stages[Output, NewOutput]): Stages[Input, NewOutput] =
- UnitStages(this).thenRun(stages)
+ def thenRun[NewOutput](
+ stages: Stages[Output, NewOutput]
+ ): Stages[Input, NewOutput] = UnitStages(this).thenRun(stages)
- def saveInput: Stages[Input, (_ >: Input, Output)] = SaveInputStage(UnitStages(this))
+ def saveInput: Stages[Input, (_ >: Input, Output)] =
+ SaveInputStage(UnitStages(this))
def transform[Output2](f: Output => Output2): Stages[Input, Output2] = {
UnitStages(this).thenRun(FunctionStage(f))
}
def also(f: => Unit): Stages[Input, Output] = {
- UnitStages(this).thenRun(FunctionStage[Output, Output](x => { f; x }))
+ UnitStages(this).thenRun(FunctionStage[Output, Output](x => { f; x }))
}
def preprocess[Input2](f: Input2 => Input): Stages[Input2, Output] =
@@ -37,8 +40,9 @@ case class IdentityStage[T]() extends Stage[T, T] {
override def progressWeight: Int = 0
}
-abstract class WrapStage[InnerInput, InnerOutput, OuterInput, OuterOutput](stage: Stage[InnerInput, InnerOutput])
- extends Stage[OuterInput, OuterOutput] {
+abstract class WrapStage[InnerInput, InnerOutput, OuterInput, OuterOutput](
+ stage: Stage[InnerInput, InnerOutput]
+) extends Stage[OuterInput, OuterOutput] {
override def friendlyName: String = stage.friendlyName
override def progressWeight: Int = stage.progressWeight
@@ -50,14 +54,25 @@ abstract class WrapStage[InnerInput, InnerOutput, OuterInput, OuterOutput](stage
}
object Stages {
- def saveInput[Input, Output](stages: Stages[Input, Output]): Stages[Input, (Input, Output)] = SaveInputStage(stages)
-
- def skipIf[Input](condition: Boolean, stages: Stages[Input, Unit]): Stages[Input, Unit] = SkipIf(condition, stages)
-
- def branch[Input, Output](condition: Boolean, tt: Stages[Input, Output], ff: Stages[Input, Output]): Branch[Input, Output] = Branch[Input, Output](condition, tt, ff)
-
- def preprocess[Input2, Input, Output](f: Input2 => Input, stages: Stages[Input, Output]): Stages[Input2, Output] =
- UnitStages(FunctionStage(f)).thenRun(stages)
+ def saveInput[Input, Output](
+ stages: Stages[Input, Output]
+ ): Stages[Input, (Input, Output)] = SaveInputStage(stages)
+
+ def skipIf[Input](
+ condition: Boolean,
+ stages: Stages[Input, Unit],
+ ): Stages[Input, Unit] = SkipIf(condition, stages)
+
+ def branch[Input, Output](
+ condition: Boolean,
+ tt: Stages[Input, Output],
+ ff: Stages[Input, Output],
+ ): Branch[Input, Output] = Branch[Input, Output](condition, tt, ff)
+
+ def preprocess[Input2, Input, Output](
+ f: Input2 => Input,
+ stages: Stages[Input, Output],
+ ): Stages[Input2, Output] = UnitStages(FunctionStage(f)).thenRun(stages)
}
trait Stages[-Input, +Output] {
@@ -67,26 +82,28 @@ trait Stages[-Input, +Output] {
Progress.stages(flatNames) { progressNext =>
var cur: Any = in
- for((stage, idx) <- stages.zipWithIndex) {
- if(idx > 0) progressNext()
+ for ((stage, idx) <- stages.zipWithIndex) {
+ if (idx > 0)
+ progressNext()
cur = stage.run(cur)
}
Right(cur.asInstanceOf[Output])
}
- } catch {
- case err: VerificationError => Left(err)
- }
+ } catch { case err: VerificationError => Left(err) }
def collect: Seq[Stage[Nothing, Any]]
- def flatNames: Seq[(String, Int)] = collect.map(s => s.friendlyName -> s.progressWeight)
+ def flatNames: Seq[(String, Int)] =
+ collect.map(s => s.friendlyName -> s.progressWeight)
- def thenRun[NewOutput](stage: Stage[Output, NewOutput]): Stages[Input, NewOutput] =
- thenRun(UnitStages(stage))
+ def thenRun[NewOutput](
+ stage: Stage[Output, NewOutput]
+ ): Stages[Input, NewOutput] = thenRun(UnitStages(stage))
- def thenRun[NewOutput](stages: Stages[Output, NewOutput]): Stages[Input, NewOutput] =
- StagesPair(this, stages)
+ def thenRun[NewOutput](
+ stages: Stages[Output, NewOutput]
+ ): Stages[Input, NewOutput] = StagesPair(this, stages)
def transform[Output2](f: Output => Output2): Stages[Input, Output2] =
thenRun(FunctionStage(f))
@@ -101,16 +118,22 @@ case class FunctionStage[T, S](f: T => S) extends Stage[T, S] {
override def run(in: T): S = f(in)
}
-case class UnitStages[-Input, +Output](stage: Stage[Input, Output]) extends Stages[Input, Output] {
+case class UnitStages[-Input, +Output](stage: Stage[Input, Output])
+ extends Stages[Input, Output] {
override def collect: Seq[Stage[Nothing, Any]] = Seq(stage)
}
-case class StagesPair[-Input, Mid, +Output](left: Stages[Input, Mid], right: Stages[Mid, Output]) extends Stages[Input, Output] {
+case class StagesPair[-Input, Mid, +Output](
+ left: Stages[Input, Mid],
+ right: Stages[Mid, Output],
+) extends Stages[Input, Output] {
override def collect: Seq[Stage[Nothing, Any]] = left.collect ++ right.collect
}
-case class SaveInputStage[Input, Output](stages: Stages[Input, Output]) extends Stages[Input, (Input, Output)] {
- case class RetainInput[Input, Output](stage: Stage[Input, Output]) extends WrapStage[Input, Output, Input, (Input, Output)](stage) {
+case class SaveInputStage[Input, Output](stages: Stages[Input, Output])
+ extends Stages[Input, (Input, Output)] {
+ case class RetainInput[Input, Output](stage: Stage[Input, Output])
+ extends WrapStage[Input, Output, Input, (Input, Output)](stage) {
var in: Option[Input] = None
override def zoomIn(in: Input): Input = {
this.in = Some(in)
@@ -119,7 +142,8 @@ case class SaveInputStage[Input, Output](stages: Stages[Input, Output]) extends
override def zoomOut(out: Output): (Input, Output) = (in.get, out)
}
- case class Map_2[Left, Input, Output](stage: Stage[Input, Output]) extends WrapStage[Input, Output, (Left, Input), (Left, Output)](stage) {
+ case class Map_2[Left, Input, Output](stage: Stage[Input, Output])
+ extends WrapStage[Input, Output, (Left, Input), (Left, Output)](stage) {
var left: Option[Left] = None
override def zoomIn(in: (Left, Input)): Input = {
left = Some(in._1)
@@ -128,21 +152,34 @@ case class SaveInputStage[Input, Output](stages: Stages[Input, Output]) extends
override def zoomOut(out: Output): (Left, Output) = (left.get, out)
}
- override def collect: Seq[Stage[Nothing, Any]] = stages.collect match {
- case Seq() => Seq()
- case Seq(stage) => Seq(RetainInput[Nothing, Any](stage).asInstanceOf[Stage[Nothing, Any]])
- case stage +: stages =>
- RetainInput[Nothing, Any](stage).asInstanceOf[Stage[Nothing, Any]] +: stages.map(Map_2[Nothing, Nothing, Any])
- }
+ override def collect: Seq[Stage[Nothing, Any]] =
+ stages.collect match {
+ case Seq() => Seq()
+ case Seq(stage) =>
+ Seq(RetainInput[Nothing, Any](stage).asInstanceOf[Stage[Nothing, Any]])
+ case stage +: stages =>
+ RetainInput[Nothing, Any](stage).asInstanceOf[Stage[Nothing, Any]] +:
+ stages.map(Map_2[Nothing, Nothing, Any])
+ }
}
-case class SkipIf[Input](condition: Boolean, stages: Stages[Input, Unit]) extends Stages[Input, Unit] {
+case class SkipIf[Input](condition: Boolean, stages: Stages[Input, Unit])
+ extends Stages[Input, Unit] {
override def collect: Seq[Stage[Nothing, Any]] =
- if(condition)
+ if (condition)
Seq(FunctionStage((_: Input) => ()))
- else stages.collect
+ else
+ stages.collect
}
-case class Branch[Input, Output](condition: Boolean, tt: Stages[Input, Output], ff: Stages[Input, Output]) extends Stages[Input, Output] {
- override def collect: Seq[Stage[Nothing, Any]] = if(condition) tt.collect else ff.collect
+case class Branch[Input, Output](
+ condition: Boolean,
+ tt: Stages[Input, Output],
+ ff: Stages[Input, Output],
+) extends Stages[Input, Output] {
+ override def collect: Seq[Stage[Nothing, Any]] =
+ if (condition)
+ tt.collect
+ else
+ ff.collect
}
diff --git a/src/hre/hre/util/FuncTools.scala b/src/hre/hre/util/FuncTools.scala
index 454ffc3dc2..20286a0498 100644
--- a/src/hre/hre/util/FuncTools.scala
+++ b/src/hre/hre/util/FuncTools.scala
@@ -1,12 +1,14 @@
package hre.util
case object FuncTools {
- def repeat[T](f: T => T, n: Int, arg: T): T =
- (0 until n).foldLeft(arg)((res, _) => f(res))
+ def repeat[T](f: T => T, n: Int, arg: T): T = (0 until n)
+ .foldLeft(arg)((res, _) => f(res))
def firstOption[T](options: Seq[Option[T]]): Option[T] =
options.foldLeft(Option.empty[T])(_ orElse _)
- def firstOption[In, Out](data: Seq[In], func: Function[In, Option[Out]]): Option[Out] =
- data.foldLeft(Option.empty[Out])(_ orElse func(_))
+ def firstOption[In, Out](
+ data: Seq[In],
+ func: Function[In, Option[Out]],
+ ): Option[Out] = data.foldLeft(Option.empty[Out])(_ orElse func(_))
}
diff --git a/src/hre/hre/util/Interrupt.scala b/src/hre/hre/util/Interrupt.scala
index 172efd625b..f330b289bb 100644
--- a/src/hre/hre/util/Interrupt.scala
+++ b/src/hre/hre/util/Interrupt.scala
@@ -2,7 +2,5 @@ package hre.util
object Interrupt {
def check(): Unit =
- if(Thread.interrupted()) {
- throw new InterruptedException()
- }
+ if (Thread.interrupted()) { throw new InterruptedException() }
}
diff --git a/src/hre/hre/util/Notifier.scala b/src/hre/hre/util/Notifier.scala
index 4d5d2aa6e0..26eafca845 100644
--- a/src/hre/hre/util/Notifier.scala
+++ b/src/hre/hre/util/Notifier.scala
@@ -10,12 +10,13 @@ import java.nio.file.{Files, Paths}
import java.util.regex.Pattern
object Notifier {
- def notify(title: String, message: String): Boolean = Platform.getCurrent match {
- case Platform.Windows => notifyWindows10(title, message)
- case Platform.Mac => notifyMacOS(title, message)
- case Platform.Unix => notifyLibnotify(title, message)
- case _ => false
- }
+ def notify(title: String, message: String): Boolean =
+ Platform.getCurrent match {
+ case Platform.Windows => notifyWindows10(title, message)
+ case Platform.Mac => notifyMacOS(title, message)
+ case Platform.Unix => notifyLibnotify(title, message)
+ case _ => false
+ }
def notifyLibnotify(title: String, message: String): Boolean = {
if (commandExists("notify-send")) {
@@ -24,21 +25,21 @@ object Notifier {
case 0 => true
case _ => false
}
- } else {
- false
- }
+ } else { false }
}
def notifyMacOS(title: String, message: String): Boolean = {
if (commandExists("osascript")) {
- val cmd = Seq("osascript", "-e", s"""display notification "$message" with title "$title"""")
+ val cmd = Seq(
+ "osascript",
+ "-e",
+ s"""display notification "$message" with title "$title"""",
+ )
cmd ! ProcessLogger(_ => (), _ => ()) match {
case 0 => true
case _ => false
}
- } else {
- false
- }
+ } else { false }
}
val powershellNotificationScript: String =
@@ -73,9 +74,7 @@ object Notifier {
def notifyWindows10(title: String, message: String): Boolean = {
// Only allow safe characters
val ok = (x: String) => Pattern.matches("[a-zA-Z ]*", x)
- if (!ok(title) || !ok(message)) {
- return false
- }
+ if (!ok(title) || !ok(message)) { return false }
// Script comes from: https://gist.github.com/Windos/9aa6a684ac583e0d38a8fa68196bc2dc
val script = powershellNotificationScript.format(title, message)
@@ -86,8 +85,7 @@ object Notifier {
}
def commandExists(cmd: String): Boolean = {
- System.getenv().asScala.getOrElse("PATH", "")
- .split(PATH_SEPARATOR)
+ System.getenv().asScala.getOrElse("PATH", "").split(PATH_SEPARATOR)
.exists(path => {
val p = Paths.get(path).resolve(cmd)
Files.exists(p) && !Files.isDirectory(p) && Files.isExecutable(p)
diff --git a/src/hre/hre/util/ScopedStack.scala b/src/hre/hre/util/ScopedStack.scala
index 2a96e7b48a..1270cd14a1 100644
--- a/src/hre/hre/util/ScopedStack.scala
+++ b/src/hre/hre/util/ScopedStack.scala
@@ -14,7 +14,8 @@ case object ScopedStack {
}
case class ScopedStack[T]() {
- private val stacks: ThreadLocal[mutable.Stack[T]] = ThreadLocal.withInitial(() => mutable.Stack())
+ private val stacks: ThreadLocal[mutable.Stack[T]] = ThreadLocal
+ .withInitial(() => mutable.Stack())
def stack: mutable.Stack[T] = stacks.get()
@@ -32,10 +33,7 @@ case class ScopedStack[T]() {
def having[R](x: T)(f: => R): R = {
stack.push(x)
- try {
- f
- } finally {
- stack.pop()
- }
+ try { f }
+ finally { stack.pop() }
}
}
diff --git a/src/hre/hre/util/Time.scala b/src/hre/hre/util/Time.scala
index 2b935ec3df..48dd4ed049 100644
--- a/src/hre/hre/util/Time.scala
+++ b/src/hre/hre/util/Time.scala
@@ -10,7 +10,8 @@ object Time {
def formatTime(): String = formatTime(java.time.Instant.now())
def formatTime(when: Instant): String = {
- val formatter = DateTimeFormatter.ofPattern("HH:mm:ss").withZone(ZoneId.systemDefault())
+ val formatter = DateTimeFormatter.ofPattern("HH:mm:ss")
+ .withZone(ZoneId.systemDefault())
formatter.format(when)
}
}
diff --git a/src/hre/vct/result/HasContext.scala b/src/hre/vct/result/HasContext.scala
index 17897b7737..4760be848d 100644
--- a/src/hre/vct/result/HasContext.scala
+++ b/src/hre/vct/result/HasContext.scala
@@ -3,9 +3,9 @@ package vct.result
import vct.result.Message.{BOLD_HR, HR}
trait HasContext {
- /**
- * May contain newlines, but must not start or end with newlines.
- */
+
+ /** May contain newlines, but must not start or end with newlines.
+ */
def contextText: String
def bareMessageInContext(message: String): String =
@@ -13,4 +13,4 @@ trait HasContext {
def messageInContext(message: String): String =
BOLD_HR + bareMessageInContext(message) + "\n" + BOLD_HR
-}
\ No newline at end of file
+}
diff --git a/src/hre/vct/result/Message.scala b/src/hre/vct/result/Message.scala
index 3592802bed..c344cbb286 100644
--- a/src/hre/vct/result/Message.scala
+++ b/src/hre/vct/result/Message.scala
@@ -2,11 +2,11 @@ package vct.result
case object Message {
val BOLD_HR = "======================================\n"
- val HR = "--------------------------------------\n"
+ val HR = "--------------------------------------\n"
def messagesInContext(messages: (HasContext, String)*): String =
- messages.zipWithIndex.map {
- case ((origin, message), idx) =>
- origin.bareMessageInContext(s"[${idx + 1}/${messages.size}] $message") + "\n"
+ messages.zipWithIndex.map { case ((origin, message), idx) =>
+ origin.bareMessageInContext(s"[${idx + 1}/${messages.size}] $message") +
+ "\n"
}.mkString(BOLD_HR, HR, BOLD_HR)
}
diff --git a/src/hre/vct/result/VerificationError.scala b/src/hre/vct/result/VerificationError.scala
index 8811276f66..1c23ac98fd 100644
--- a/src/hre/vct/result/VerificationError.scala
+++ b/src/hre/vct/result/VerificationError.scala
@@ -12,15 +12,15 @@ sealed abstract class VerificationError extends RuntimeException {
val contexts: ArrayBuffer[VerificationError.Context] = ArrayBuffer()
def context[T](implicit tag: ClassTag[T]): Option[T] = {
- contexts.collectFirst {
- case x : T =>
- x
- }
+ contexts.collectFirst { case x: T => x }
}
def getContext[T](implicit tag: ClassTag[T]): T = context[T].get
- def messageContext(message: String, backupContext: String => String = identity): String =
+ def messageContext(
+ message: String,
+ backupContext: String => String = identity,
+ ): String =
// PB: note: the innermost context is added to contexts first, so we end up trying to use the most specific context
// for rendering the message context first, which is what we want.
contexts.foldLeft[Option[String]](None) {
@@ -51,14 +51,16 @@ object VerificationError {
}
trait Context {
- def tryMessageContext(message: String, err: VerificationError): Option[String] = None
+ def tryMessageContext(
+ message: String,
+ err: VerificationError,
+ ): Option[String] = None
}
def withContext[T](ctx: Context)(f: => T): T = {
- try {
- f
- } catch {
- case e : VerificationError =>
+ try { f }
+ catch {
+ case e: VerificationError =>
e.contexts += ctx
throw e
case NonFatal(e) =>
@@ -68,4 +70,4 @@ object VerificationError {
throw crash
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/vct/cache/Caches.scala b/src/main/vct/cache/Caches.scala
index 4d4c8af261..b68a7d079e 100644
--- a/src/main/vct/cache/Caches.scala
+++ b/src/main/vct/cache/Caches.scala
@@ -9,25 +9,27 @@ import java.nio.file.Path
case object Caches extends LazyLogging {
// Val's, so that multiple VerCors runs in one JVM (e.g. tests) benefit from a shared cache even when the cache is
// variate.
- lazy val getLibraryCache: Path = getDirectory(BuildInfo.currentCommit).resolve("library")
+ lazy val getLibraryCache: Path = getDirectory(BuildInfo.currentCommit)
+ .resolve("library")
- lazy val getCarbonDirectory: Path = getViperDirectory(BuildInfo.carbonCommit).resolve("carbon").resolve("verified")
- lazy val getSiliconDirectory: Path = getViperDirectory(BuildInfo.siliconCommit).resolve("silicon").resolve("verified")
+ lazy val getCarbonDirectory: Path = getViperDirectory(BuildInfo.carbonCommit)
+ .resolve("carbon").resolve("verified")
+ lazy val getSiliconDirectory: Path = getViperDirectory(
+ BuildInfo.siliconCommit
+ ).resolve("silicon").resolve("verified")
private def getDirectory(keys: String*): Path = {
val variate = BuildInfo.gitHasChanges != "false"
- if(variate) {
- logger.warn("Caching is enabled, but results will be discarded, since there were uncommitted changes at compilation time.")
+ if (variate) {
+ logger.warn(
+ "Caching is enabled, but results will be discarded, since there were uncommitted changes at compilation time."
+ )
}
Cache.getDirectory(variate, keys)
}
private def getViperDirectory(backendCommit: String): Path =
- getDirectory(
- BuildInfo.currentCommit,
- BuildInfo.silverCommit,
- backendCommit,
- )
+ getDirectory(BuildInfo.currentCommit, BuildInfo.silverCommit, backendCommit)
}
diff --git a/src/main/vct/debug/CrashReport.scala b/src/main/vct/debug/CrashReport.scala
index 71bcd2275d..cefc796523 100644
--- a/src/main/vct/debug/CrashReport.scala
+++ b/src/main/vct/debug/CrashReport.scala
@@ -11,32 +11,38 @@ import java.nio.charset.StandardCharsets
object CrashReport {
val GITHUB_URI = "https://github.com/utwente-fmt/vercors/issues/new"
- private def enc(s: String): String = URLEncoder.encode(s, StandardCharsets.UTF_8)
-
- def makeGithubLink(err: Throwable, args: Array[String], options: Options): String = {
+ private def enc(s: String): String =
+ URLEncoder.encode(s, StandardCharsets.UTF_8)
+
+ def makeGithubLink(
+ err: Throwable,
+ args: Array[String],
+ options: Options,
+ ): String = {
var (title, body) = make(err, args, options)
var uri: String = ""
var lastBody: String = ""
do {
- val params = s"labels=${enc("A-Bug")}&title=${enc(title)}&body=${enc(body)}"
+ val params =
+ s"labels=${enc("A-Bug")}&title=${enc(title)}&body=${enc(body)}"
uri = GITHUB_URI + "?" + params
lastBody = body
body = body.replaceFirst("\n[^\n]*$", "")
- } while(uri.length > 8000 && body.length < lastBody.length)
+ } while (uri.length > 8000 && body.length < lastBody.length)
uri
}
- def make(err: Throwable, args: Array[String], options: Options): (String, String) =
- s"Crash report: ${err.getMessage.take(100)}" -> (
- makeError(err) +
- makeVersion() +
- makeOptions(args) +
- makeInputs(options) +
- makeLog()
- )
+ def make(
+ err: Throwable,
+ args: Array[String],
+ options: Options,
+ ): (String, String) =
+ s"Crash report: ${err.getMessage.take(100)}" ->
+ (makeError(err) + makeVersion() + makeOptions(args) +
+ makeInputs(options) + makeLog())
def makeError(err: Throwable): String =
s"""# Crash Message
@@ -48,16 +54,18 @@ object CrashReport {
|""".stripMargin
def makeStackTrace(elems: Array[StackTraceElement]): String = {
- if(elems.length < 15)
+ if (elems.length < 15)
elems.map(elem => s" at $elem").mkString("\n")
else
- (elems.take(12).map(elem => s" at $elem") ++ Seq(" ...") ++ elems.takeRight(2).map(elem => s" at $elem")).mkString("\n")
+ (elems.take(12).map(elem => s" at $elem") ++ Seq(" ...") ++
+ elems.takeRight(2).map(elem => s" at $elem")).mkString("\n")
}
def makeVersion(): String =
s"""# Version Information
|* ${BuildInfo.name} version `${BuildInfo.version}`
- |* At commit ${BuildInfo.currentCommit} from branch `${BuildInfo.currentBranch}` (changes=${BuildInfo.gitHasChanges})
+ |* At commit ${BuildInfo.currentCommit} from branch `${BuildInfo
+ .currentBranch}` (changes=${BuildInfo.gitHasChanges})
|
|""".stripMargin
@@ -74,7 +82,7 @@ object CrashReport {
|""".stripMargin
def makeInput(readable: Readable): String =
- if(readable.isRereadable)
+ if (readable.isRereadable)
s"""
|${readable.fileName}
|
diff --git a/src/main/vct/importer/JavaLibraryLoader.scala b/src/main/vct/importer/JavaLibraryLoader.scala
index 40b5e9a98e..e7f652cf81 100644
--- a/src/main/vct/importer/JavaLibraryLoader.scala
+++ b/src/main/vct/importer/JavaLibraryLoader.scala
@@ -13,14 +13,23 @@ import vct.parsers.parser.ColJavaParser
import java.io.File.{separator => FILE_SEPARATOR}
import java.nio.file.Path
-case class JavaLibraryLoader(blameProvider: BlameProvider, debugOptions: DebugOptions) extends ExternalJavaLoader {
- override def load[G](base: Path, name: Seq[String]): Option[JavaNamespace[G]] = try {
- val f = RWFile(base.resolve((name.init :+ name.last + ".java").mkString(FILE_SEPARATOR)))
- parser.ColJavaParser(debugOptions, blameProvider).parse[G](f).decls match {
- case Seq(ns: JavaNamespace[G]) => Some(ns)
- case _ => None
- }
- } catch {
- case _: FileNotFound => None
- }
+case class JavaLibraryLoader(
+ blameProvider: BlameProvider,
+ debugOptions: DebugOptions,
+) extends ExternalJavaLoader {
+ override def load[G](
+ base: Path,
+ name: Seq[String],
+ ): Option[JavaNamespace[G]] =
+ try {
+ val f = RWFile(
+ base
+ .resolve((name.init :+ name.last + ".java").mkString(FILE_SEPARATOR))
+ )
+ parser.ColJavaParser(debugOptions, blameProvider).parse[G](f)
+ .decls match {
+ case Seq(ns: JavaNamespace[G]) => Some(ns)
+ case _ => None
+ }
+ } catch { case _: FileNotFound => None }
}
diff --git a/src/main/vct/importer/PathAdtImporter.scala b/src/main/vct/importer/PathAdtImporter.scala
index 9fd927594e..27ea298d35 100644
--- a/src/main/vct/importer/PathAdtImporter.scala
+++ b/src/main/vct/importer/PathAdtImporter.scala
@@ -7,7 +7,9 @@ import vct.parsers.debug.DebugOptions
import java.nio.file.Path
-case class PathAdtImporter(basePath: Path, debugOptions: DebugOptions) extends ImportADTImporter {
+case class PathAdtImporter(basePath: Path, debugOptions: DebugOptions)
+ extends ImportADTImporter {
override def loadAdt[G](name: String): Program[G] =
- Util.loadPVLLibraryFile(RWFile(basePath.resolve(name + ".pvl")), debugOptions)
+ Util
+ .loadPVLLibraryFile(RWFile(basePath.resolve(name + ".pvl")), debugOptions)
}
diff --git a/src/main/vct/importer/Util.scala b/src/main/vct/importer/Util.scala
index 7781b8cbfb..c007cf334b 100644
--- a/src/main/vct/importer/Util.scala
+++ b/src/main/vct/importer/Util.scala
@@ -25,10 +25,14 @@ case object Util extends LazyLogging {
case class LibraryFileError(error: VerificationFailure) extends UserError {
override def code: String = "lib"
override def text: String =
- "A verification condition failed inside a file loaded as a library file, which is never supposed to happen. The internal error is:\n" + error.toString
+ "A verification condition failed inside a file loaded as a library file, which is never supposed to happen. The internal error is:\n" +
+ error.toString
}
- def loadPVLLibraryFile[G](readable: Readable, debugOptions: DebugOptions): Program[G] = {
+ def loadPVLLibraryFile[G](
+ readable: Readable,
+ debugOptions: DebugOptions,
+ ): Program[G] = {
logger.debug("Loading PVL library file: " + readable.fileName)
val text = readable.readToCompletion()
@@ -36,10 +40,19 @@ case object Util extends LazyLogging {
val pinnedLibrary = cacheDir.resolve("library.in")
val result = cacheDir.resolve("library.colpb")
- if(!Files.exists(cacheDir) || RWFile(pinnedLibrary, doWatch = false).readToCompletion() != text) {
- val res = parser.ColPVLParser(debugOptions, ConstantBlameProvider(LibraryFileBlame)).parse(readable)
- val context = Resolution(ConstantBlameProvider(LibraryFileBlame), debugOptions).run(res)
- val unambiguousProgram: Program[_] = Disambiguate().dispatch(context.tasks.head.program)
+ if (
+ !Files.exists(cacheDir) ||
+ RWFile(pinnedLibrary, doWatch = false).readToCompletion() != text
+ ) {
+ val res = parser
+ .ColPVLParser(debugOptions, ConstantBlameProvider(LibraryFileBlame))
+ .parse(readable)
+ val context = Resolution(
+ ConstantBlameProvider(LibraryFileBlame),
+ debugOptions,
+ ).run(res)
+ val unambiguousProgram: Program[_] = Disambiguate()
+ .dispatch(context.tasks.head.program)
Files.createDirectories(cacheDir)
Using(Files.newOutputStream(pinnedLibrary)) { out =>
@@ -52,7 +65,8 @@ case object Util extends LazyLogging {
}
Using(Files.newInputStream(result)) { in =>
- Deserialize.deserializeProgram[G](vct.col.ast.serialize.Program.parseFrom(in), 0)
+ Deserialize
+ .deserializeProgram[G](vct.col.ast.serialize.Program.parseFrom(in), 0)
}.get
}
@@ -62,12 +76,23 @@ case object Util extends LazyLogging {
override def text: String = error
}
- def loadJavaClass[G](readable: Readable, debugOptions: DebugOptions): JavaClass[G] =
- parser.ColJavaParser(debugOptions, ConstantBlameProvider(LibraryFileBlame)).parse(readable).decls match {
- case Seq(javaNamespace: JavaNamespace[G @unchecked]) => javaNamespace.declarations match {
- case Seq(javaClass: JavaClass[G]) => javaClass
- case seq => throw JavaLoadError("Expected to load exactly one Java class but found " + seq.size)
- }
- case seq => throw JavaLoadError("Expected to load exactly one Java name space but found " + seq.size)
+ def loadJavaClass[G](
+ readable: Readable,
+ debugOptions: DebugOptions,
+ ): JavaClass[G] =
+ parser.ColJavaParser(debugOptions, ConstantBlameProvider(LibraryFileBlame))
+ .parse(readable).decls match {
+ case Seq(javaNamespace: JavaNamespace[G @unchecked]) =>
+ javaNamespace.declarations match {
+ case Seq(javaClass: JavaClass[G]) => javaClass
+ case seq =>
+ throw JavaLoadError(
+ "Expected to load exactly one Java class but found " + seq.size
+ )
+ }
+ case seq =>
+ throw JavaLoadError(
+ "Expected to load exactly one Java name space but found " + seq.size
+ )
}
}
diff --git a/src/main/vct/main/Main.scala b/src/main/vct/main/Main.scala
index 048258bfa2..50a7e6f497 100644
--- a/src/main/vct/main/Main.scala
+++ b/src/main/vct/main/Main.scala
@@ -22,72 +22,78 @@ case object Main extends LazyLogging {
val EXIT_CODE_VERIFICATION_FAILURE = 1
val EXIT_CODE_ERROR = 2
- case class TemporarilyUnsupported(feature: String, examples: Seq[Node[_]]) extends UserError {
+ case class TemporarilyUnsupported(feature: String, examples: Seq[Node[_]])
+ extends UserError {
override def code: String = "unsupported"
override def text: String =
- examples.head.o.messageInContext(
- s"The feature `$feature` is temporarily unsupported.")
+ examples.head.o
+ .messageInContext(s"The feature `$feature` is temporarily unsupported.")
}
- /**
- * The main entry point of the VerCors verifier.
- *
- * Parses the options, and decides from there what to do.
- * The exit code of VerCors determines the verification result: zero means all proof goals succeeded.
- *
- * @param args The command line argument
- */
- def main(args: Array[String]): Unit = try {
- Options.parse(args) match {
- case None => System.exit(EXIT_CODE_ERROR)
- case Some(options) =>
- try {
- System.exit(runOptions(options))
- } catch {
- case NonFatal(err) =>
- logger.error(CollectString(stream => err.printStackTrace(stream)))
- logger.error("!*!*!*!*!*!*!*!*!*!*!*!")
- logger.error("! VerCors has crashed !")
- logger.error("!*!*!*!*!*!*!*!*!*!*!*!")
- logger.error("")
- logger.error("Please report this as a bug here:")
- logger.error(CrashReport.makeGithubLink(err, args, options))
- System.exit(EXIT_CODE_ERROR)
- }
+ /** The main entry point of the VerCors verifier.
+ *
+ * Parses the options, and decides from there what to do. The exit code of
+ * VerCors determines the verification result: zero means all proof goals
+ * succeeded.
+ *
+ * @param args
+ * The command line argument
+ */
+ def main(args: Array[String]): Unit =
+ try {
+ Options.parse(args) match {
+ case None => System.exit(EXIT_CODE_ERROR)
+ case Some(options) =>
+ try { System.exit(runOptions(options)) }
+ catch {
+ case NonFatal(err) =>
+ logger.error(CollectString(stream => err.printStackTrace(stream)))
+ logger.error("!*!*!*!*!*!*!*!*!*!*!*!")
+ logger.error("! VerCors has crashed !")
+ logger.error("!*!*!*!*!*!*!*!*!*!*!*!")
+ logger.error("")
+ logger.error("Please report this as a bug here:")
+ logger.error(CrashReport.makeGithubLink(err, args, options))
+ System.exit(EXIT_CODE_ERROR)
+ }
+ }
+ } catch {
+ case t: Throwable =>
+ logger.error(s"Unrecoverable error: ${t.getMessage}", t)
+ throw t
}
- } catch {
- case t: Throwable =>
- logger.error(s"Unrecoverable error: ${t.getMessage}", t)
- throw t
- }
- /**
- * Decide what to do from the parsed options.
- *
- * If the help flag is enabled, the usage is printed.
- * Sets up the logging levels in slf4j, and enables progress logging.
- * Finally the method switches on the mode enabled in the options, deferring to the appropriate object in [[vct.main.modes]]
- *
- * @param options The parsed command line arguments. VerCors is not meant to be invoked with e.g. a tweaked [[Options]]
- * object. Rather, refer to [[Verify.verifyWithSilicon]] or [[vct.main.stages.Stages]]
- * @return The exit code, zero on verification success.
- */
+ /** Decide what to do from the parsed options.
+ *
+ * If the help flag is enabled, the usage is printed. Sets up the logging
+ * levels in slf4j, and enables progress logging. Finally the method switches
+ * on the mode enabled in the options, deferring to the appropriate object in
+ * [[vct.main.modes]]
+ *
+ * @param options
+ * The parsed command line arguments. VerCors is not meant to be invoked
+ * with e.g. a tweaked [[Options]] object. Rather, refer to
+ * [[Verify.verifyWithSilicon]] or [[vct.main.stages.Stages]]
+ * @return
+ * The exit code, zero on verification success.
+ */
def runOptions(options: Options): Int = {
- if(options.help) {
+ if (options.help) {
println(OParser.usage(Options.parser(hide = !options.showHidden)))
return 0
}
- for((key, logLevel) <- options.logLevels) {
- LoggerFactory.getLogger(key).asInstanceOf[Logger].setLevel(logLevel match {
- case Verbosity.Off => Level.OFF
- case Verbosity.Error => Level.ERROR
- case Verbosity.Warning => Level.WARN
- case Verbosity.Info => Level.INFO
- case Verbosity.Debug => Level.DEBUG
- case Verbosity.Trace => Level.TRACE
- case Verbosity.All => Level.ALL
- })
+ for ((key, logLevel) <- options.logLevels) {
+ LoggerFactory.getLogger(key).asInstanceOf[Logger]
+ .setLevel(logLevel match {
+ case Verbosity.Off => Level.OFF
+ case Verbosity.Error => Level.ERROR
+ case Verbosity.Warning => Level.WARN
+ case Verbosity.Info => Level.INFO
+ case Verbosity.Debug => Level.DEBUG
+ case Verbosity.Trace => Level.TRACE
+ case Verbosity.All => Level.ALL
+ })
}
Layout.install(options.progress)
@@ -96,9 +102,11 @@ case object Main extends LazyLogging {
// This causes data read between the start of reading and the interrupt to be lost.
System.setIn(new InterruptibleInputStream(System.in))
- Runtime.getRuntime.addShutdownHook(new Thread("[VerCors] Shutdown hook to abort progress on exit") {
- override def run(): Unit = Progress.abort()
- })
+ Runtime.getRuntime.addShutdownHook(
+ new Thread("[VerCors] Shutdown hook to abort progress on exit") {
+ override def run(): Unit = Progress.abort()
+ }
+ )
try {
Watch.booleanWithWatch(options.watch, default = EXIT_CODE_SUCCESS) {
@@ -106,7 +114,8 @@ case object Main extends LazyLogging {
try {
options.mode match {
case Mode.Verify =>
- logger.info(s"Starting verification at ${hre.util.Time.formatTime()}")
+ logger
+ .info(s"Starting verification at ${hre.util.Time.formatTime()}")
Verify.runOptions(options)
case Mode.HelpVerifyPasses =>
logger.info("Available passes:")
@@ -115,8 +124,7 @@ case object Main extends LazyLogging {
logger.info(s" ${pass.desc}")
}
EXIT_CODE_SUCCESS
- case Mode.VeyMont =>
- VeyMont.runOptions(options)
+ case Mode.VeyMont => VeyMont.runOptions(options)
case Mode.VeSUV =>
logger.info("Starting transformation")
VeSUV.runOptions(options)
@@ -124,20 +132,18 @@ case object Main extends LazyLogging {
logger.info("Starting control flow graph transformation")
CFG.runOptions(options)
}
- } finally {
- Progress.finish()
- }
+ } finally { Progress.finish() }
}
} finally {
val thisThread = Thread.currentThread()
- Thread.getAllStackTraces.keySet()
- .stream()
- .filter(_ != thisThread)
- .filter(!_.isDaemon)
- .forEach { thread =>
- logger.warn(s"Non-daemon thread ${thread.getThreadGroup.getName}.${thread.getName} (#${thread.getId}) is still running")
- logger.warn("Due to this VerCors will not exit and sit idly until that thread is done. You may want to stop the program manually.")
+ Thread.getAllStackTraces.keySet().stream().filter(_ != thisThread)
+ .filter(!_.isDaemon).forEach { thread =>
+ logger.warn(s"Non-daemon thread ${thread.getThreadGroup
+ .getName}.${thread.getName} (#${thread.getId}) is still running")
+ logger.warn(
+ "Due to this VerCors will not exit and sit idly until that thread is done. You may want to stop the program manually."
+ )
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/vct/main/modes/CFG.scala b/src/main/vct/main/modes/CFG.scala
index f28983a80a..2ba6befeba 100644
--- a/src/main/vct/main/modes/CFG.scala
+++ b/src/main/vct/main/modes/CFG.scala
@@ -9,9 +9,10 @@ import vct.parsers.transform.ConstantBlameProvider
import vct.result.VerificationError.{SystemError, UserError}
case object CFG extends LazyLogging {
- def runOptions(options: Options) : Int = {
+ def runOptions(options: Options): Int = {
val collector = BlameCollector()
- val stages = Stages.cfgTransformationOfOptions(options, ConstantBlameProvider(collector))
+ val stages = Stages
+ .cfgTransformationOfOptions(options, ConstantBlameProvider(collector))
stages.run(options.inputs) match {
case Left(err: UserError) => EXIT_CODE_ERROR
case Left(err: SystemError) => throw err
diff --git a/src/main/vct/main/modes/VeSUV.scala b/src/main/vct/main/modes/VeSUV.scala
index e55f034f3a..f460b9281a 100644
--- a/src/main/vct/main/modes/VeSUV.scala
+++ b/src/main/vct/main/modes/VeSUV.scala
@@ -9,9 +9,10 @@ import vct.parsers.transform.ConstantBlameProvider
import vct.result.VerificationError.{SystemError, UserError}
case object VeSUV extends LazyLogging {
- def runOptions(options: Options) : Int = {
+ def runOptions(options: Options): Int = {
val collector = BlameCollector()
- val stages = Stages.vesuvOfOptions(options, ConstantBlameProvider(collector))
+ val stages = Stages
+ .vesuvOfOptions(options, ConstantBlameProvider(collector))
stages.run(options.inputs) match {
case Left(_: UserError) => EXIT_CODE_ERROR
case Left(err: SystemError) => throw err
diff --git a/src/main/vct/main/modes/Verify.scala b/src/main/vct/main/modes/Verify.scala
index 2307279432..974731d263 100644
--- a/src/main/vct/main/modes/Verify.scala
+++ b/src/main/vct/main/modes/Verify.scala
@@ -8,7 +8,11 @@ import sun.misc.{Signal, SignalHandler}
import vct.col.origin.{BlameCollector, TableEntry, VerificationFailure}
import vct.col.rewrite.bip.BIP
import vct.col.rewrite.bip.BIP.Standalone.VerificationReport
-import vct.main.Main.{EXIT_CODE_ERROR, EXIT_CODE_SUCCESS, EXIT_CODE_VERIFICATION_FAILURE}
+import vct.main.Main.{
+ EXIT_CODE_ERROR,
+ EXIT_CODE_SUCCESS,
+ EXIT_CODE_VERIFICATION_FAILURE,
+}
import vct.main.stages.Stages
import vct.options.types.PathOrStd
import vct.parsers.transform.ConstantBlameProvider
@@ -19,7 +23,10 @@ import viper.silicon.logger.SymbExLogger
import java.time.Duration
case object Verify extends LazyLogging {
- def verifyWithSilicon(inputs: Seq[Readable]): Either[VerificationError, (Seq[VerificationFailure], VerificationReport)] = {
+ def verifyWithSilicon(inputs: Seq[Readable]): Either[
+ VerificationError,
+ (Seq[VerificationFailure], VerificationReport),
+ ] = {
val collector = BlameCollector()
val bipResults = BIP.VerificationResults()
val stages = Stages.silicon(ConstantBlameProvider(collector), bipResults)
@@ -30,7 +37,10 @@ case object Verify extends LazyLogging {
}
}
- def verifyWithCarbon(inputs: Seq[Readable]): Either[VerificationError, (Seq[VerificationFailure], VerificationReport)] = {
+ def verifyWithCarbon(inputs: Seq[Readable]): Either[
+ VerificationError,
+ (Seq[VerificationFailure], VerificationReport),
+ ] = {
val collector = BlameCollector()
val bipResults = BIP.VerificationResults()
val stages = Stages.carbon(ConstantBlameProvider(collector), bipResults)
@@ -41,10 +51,14 @@ case object Verify extends LazyLogging {
}
}
- def verifyWithOptions(options: Options, inputs: Seq[Readable]): Either[VerificationError, (Seq[VerificationFailure], BIP.Standalone.VerificationReport)] = {
+ def verifyWithOptions(options: Options, inputs: Seq[Readable]): Either[
+ VerificationError,
+ (Seq[VerificationFailure], BIP.Standalone.VerificationReport),
+ ] = {
val collector = BlameCollector()
val bipResults = BIP.VerificationResults()
- val stages = Stages.ofOptions(options, ConstantBlameProvider(collector), bipResults)
+ val stages = Stages
+ .ofOptions(options, ConstantBlameProvider(collector), bipResults)
logger.debug("Stages: " ++ stages.flatNames.map(_._1).mkString(", "))
stages.run(inputs) match {
case Left(error) => Left(error)
@@ -52,23 +66,28 @@ case object Verify extends LazyLogging {
}
}
- /**
- * Runs a normal verification run from the command line options.
- *
- * After some setup, most of the meat is in [[Stages.ofOptions]].
- *
- * @param options The command line options.
- * @return The exit code, zero on verification success.
- */
+ /** Runs a normal verification run from the command line options.
+ *
+ * After some setup, most of the meat is in [[Stages.ofOptions]].
+ *
+ * @param options
+ * The command line options.
+ * @return
+ * The exit code, zero on verification success.
+ */
def runOptions(options: Options): Int = {
try {
// Wrapped in try because this seems to crash on windows
- Signal.handle(new Signal("USR1"), _ => SiliconLogListener.synchronized {
- SiliconLogListener.logs.toSeq match {
- case Nil => logger.warn("Silicon is idle.")
- case listeners => listeners.foreach(_.printDetailedState())
- }
- })
+ Signal.handle(
+ new Signal("USR1"),
+ _ =>
+ SiliconLogListener.synchronized {
+ SiliconLogListener.logs.toSeq match {
+ case Nil => logger.warn("Silicon is idle.")
+ case listeners => listeners.foreach(_.printDetailedState())
+ }
+ },
+ )
} catch {
// Could not register USR1 debug hook. This is expected behaviour on windows.
case _: IllegalArgumentException =>
@@ -81,33 +100,42 @@ case object Verify extends LazyLogging {
case Left(err: VerificationError.UserError) =>
logger.error(err.text)
EXIT_CODE_ERROR
- case Left(err: VerificationError.SystemError) =>
- throw err
+ case Left(err: VerificationError.SystemError) => throw err
case Right((Nil, report)) =>
- if(options.skipBackend){
- logger.info("Verification skipped.")
- } else {
- logger.info("Verification completed successfully.")
- }
+ if (options.skipBackend) { logger.info("Verification skipped.") }
+ else { logger.info("Verification completed successfully.") }
friendlyHandleBipReport(report, options.bipReportFile)
EXIT_CODE_SUCCESS
case Right((fails, report)) =>
- if (options.more || fails.size <= 2) fails.foreach(fail => logger.error(fail.desc))
+ if (options.more || fails.size <= 2)
+ fails.foreach(fail => logger.error(fail.desc))
else {
- logger.info("Printing verification results as a compressed table. Run with `--more` for verbose verification results.")
+ logger.info(
+ "Printing verification results as a compressed table. Run with `--more` for verbose verification results."
+ )
logger.error(TableEntry.render(fails.map(_.asTableEntry)))
}
friendlyHandleBipReport(report, options.bipReportFile)
EXIT_CODE_VERIFICATION_FAILURE
}
} finally {
- logger.info(s"Finished verification at ${Time.formatTime()} (duration: ${Time.formatDuration(Duration.between(start, java.time.Instant.now()))})")
+ logger.info(
+ s"Finished verification at ${Time.formatTime()} (duration: ${Time
+ .formatDuration(Duration.between(start, java.time.Instant.now()))})"
+ )
}
}
- def friendlyHandleBipReport(report: VerificationReport, path: Option[PathOrStd]): Unit = (report, path) match {
- case (report, _) if report.isEmpty() =>
- case (report, Some(path)) => path.write(w => w.write(report.toJson()))
- case (report, None) => logger.warn("JavaBIP verification report was produced, but no output path was specified. Use `--bip-report-file` to specify an output. See `--help` for more info.")
- }
+ def friendlyHandleBipReport(
+ report: VerificationReport,
+ path: Option[PathOrStd],
+ ): Unit =
+ (report, path) match {
+ case (report, _) if report.isEmpty() =>
+ case (report, Some(path)) => path.write(w => w.write(report.toJson()))
+ case (report, None) =>
+ logger.warn(
+ "JavaBIP verification report was produced, but no output path was specified. Use `--bip-report-file` to specify an output. See `--help` for more info."
+ )
+ }
}
diff --git a/src/main/vct/main/modes/VeyMont.scala b/src/main/vct/main/modes/VeyMont.scala
index e68e24b894..be1007d178 100644
--- a/src/main/vct/main/modes/VeyMont.scala
+++ b/src/main/vct/main/modes/VeyMont.scala
@@ -11,7 +11,8 @@ import vct.result.VerificationError
import vct.result.VerificationError.UserError
object VeyMont extends LazyLogging {
- case class ChoreographyVerificationError(failures: Seq[VerificationFailure]) extends UserError {
+ case class ChoreographyVerificationError(failures: Seq[VerificationFailure])
+ extends UserError {
override def text: String = {
val fails = failures.map(_.desc).mkString("\n")
s"Verification of the input choreography failed because of the following failures:\n$fails"
@@ -20,7 +21,8 @@ object VeyMont extends LazyLogging {
override def code: String = "veymont:choreographyVerificationFailed"
}
- case class ImplementationVerificationError(failures: Seq[VerificationFailure]) extends UserError {
+ case class ImplementationVerificationError(failures: Seq[VerificationFailure])
+ extends UserError {
override def text: String = {
val fails = failures.map(_.desc).mkString("\n")
s"Verification of the generated implementation failed because of the following failuers:\n$fails"
@@ -29,13 +31,14 @@ object VeyMont extends LazyLogging {
override def code: String = "veymont:implementationVerificationFailed"
}
- case class NoVerificationFailures(collector: BlameCollector, error: Seq[VerificationFailure] => UserError) extends Stage[Unit, Unit] {
+ case class NoVerificationFailures(
+ collector: BlameCollector,
+ error: Seq[VerificationFailure] => UserError,
+ ) extends Stage[Unit, Unit] {
override def friendlyName: String = "noVerificationErrors"
override def progressWeight: Int = 1
override def run(in: Unit): Unit =
- if (collector.errs.nonEmpty) {
- throw error(collector.errs.toSeq)
- }
+ if (collector.errs.nonEmpty) { throw error(collector.errs.toSeq) }
}
def runOptions(options: Options): Int = {
@@ -54,4 +57,3 @@ object VeyMont extends LazyLogging {
}
}
-
diff --git a/src/main/vct/main/stages/Backend.scala b/src/main/vct/main/stages/Backend.scala
index 9b9622cf7d..eccdc2cbdc 100644
--- a/src/main/vct/main/stages/Backend.scala
+++ b/src/main/vct/main/stages/Backend.scala
@@ -20,50 +20,72 @@ import scala.util.Using
case object Backend {
- def ofOptions(options: Options): Backend = options.backend match {
- case types.Backend.Silicon =>
- val printRawQuantifier = options.siliconPrintQuantifierStats match {
- case Some(freq) => Seq(
- "smt.qi.profile" -> "true",
- "smt.qi.profile_freq" -> s"$freq"
+ def ofOptions(options: Options): Backend =
+ options.backend match {
+ case types.Backend.Silicon =>
+ val printRawQuantifier =
+ options.siliconPrintQuantifierStats match {
+ case Some(freq) =>
+ Seq("smt.qi.profile" -> "true", "smt.qi.profile_freq" -> s"$freq")
+ case None => Seq()
+ }
+ val z3LogFile =
+ options.devSiliconZ3LogFile match {
+ case Some(p) =>
+ Seq(
+ "trace" -> "true",
+ "proof" -> "true",
+ "trace-file-name" -> ("\"" + p.toString + "\""),
+ )
+ case None => Seq()
+ }
+ val numberOfParallelVerifiers =
+ if (
+ options.devSiliconZ3LogFile.isDefined ||
+ options.siliconPrintQuantifierStats.isDefined
+ ) { Some(1) }
+ else { options.devSiliconNumVerifiers }
+ SilverBackend(
+ Silicon(
+ z3Settings = (printRawQuantifier ++ z3LogFile).toMap,
+ z3Path = options.z3Path,
+ numberOfParallelVerifiers = numberOfParallelVerifiers,
+ timeoutValue = options.devSiliconAssertTimeout,
+ totalTimeOut = options.devSiliconTotalTimeout,
+ proverLogFile = options.devViperProverLogFile,
+ printQuantifierStatistics =
+ options.siliconPrintQuantifierStats.isDefined,
+ reportOnNoProgress = options.devSiliconReportOnNoProgress,
+ traceBranchConditions = options.devSiliconTraceBranchConditions,
+ branchConditionReportInterval =
+ options.devSiliconBranchConditionReportInterval,
+ options = options.backendFlags,
+ ),
+ options.backendFile,
+ if (options.devCache)
+ Some(Caches.getSiliconDirectory)
+ else
+ None,
+ options.skipBackend,
)
- case None => Seq()
- }
- val z3LogFile = options.devSiliconZ3LogFile match {
- case Some(p) => Seq(
- "trace" -> "true",
- "proof" -> "true",
- "trace-file-name" -> ("\"" + p.toString + "\"")
+
+ case types.Backend.Carbon =>
+ SilverBackend(
+ Carbon(
+ z3Path = options.z3Path,
+ boogiePath = options.boogiePath,
+ printFile = options.devViperProverLogFile,
+ proverLogFile = options.devCarbonBoogieLogFile,
+ options = options.backendFlags,
+ ),
+ options.backendFile,
+ if (options.devCache)
+ Some(Caches.getSiliconDirectory)
+ else
+ None,
+ options.skipBackend,
)
- case None => Seq()
- }
- val numberOfParallelVerifiers =
- if (options.devSiliconZ3LogFile.isDefined || options.siliconPrintQuantifierStats.isDefined) { Some(1) }
- else { options.devSiliconNumVerifiers }
- SilverBackend(Silicon(
- z3Settings = (printRawQuantifier ++ z3LogFile).toMap,
- z3Path = options.z3Path,
- numberOfParallelVerifiers = numberOfParallelVerifiers,
- timeoutValue = options.devSiliconAssertTimeout,
- totalTimeOut = options.devSiliconTotalTimeout,
- proverLogFile = options.devViperProverLogFile,
- printQuantifierStatistics = options.siliconPrintQuantifierStats.isDefined,
- reportOnNoProgress = options.devSiliconReportOnNoProgress,
- traceBranchConditions = options.devSiliconTraceBranchConditions,
- branchConditionReportInterval = options.devSiliconBranchConditionReportInterval,
- options = options.backendFlags,
- ), options.backendFile, if(options.devCache) Some(Caches.getSiliconDirectory) else None
- , options.skipBackend)
-
- case types.Backend.Carbon => SilverBackend(Carbon(
- z3Path = options.z3Path,
- boogiePath = options.boogiePath,
- printFile = options.devViperProverLogFile,
- proverLogFile = options.devCarbonBoogieLogFile,
- options = options.backendFlags,
- ), options.backendFile, if(options.devCache) Some(Caches.getSiliconDirectory) else None
- , options.skipBackend)
- }
+ }
}
trait Backend extends Stage[Verification[_ <: Generation], Seq[ExpectedError]] {
@@ -74,7 +96,10 @@ trait Backend extends Stage[Verification[_ <: Generation], Seq[ExpectedError]] {
def cacheDirectory: Option[Path]
- def cachedDefinitelyVerifiesOrElseUpdate(colProgram: Program[_], update: => Boolean): Unit = {
+ def cachedDefinitelyVerifiesOrElseUpdate(
+ colProgram: Program[_],
+ update: => Boolean,
+ ): Unit = {
val baseDir = cacheDirectory.getOrElse {
// There is no cache directory: not allowed to skip the update
update
@@ -90,40 +115,55 @@ trait Backend extends Stage[Verification[_ <: Generation], Seq[ExpectedError]] {
val path = baseDir.resolve("%02x" format program.hashCode())
val programFile = path.resolve("program.colpb")
- if(Files.exists(path)) {
+ if (Files.exists(path)) {
// The result is potentially cached in programFile
- val cachedProgram = Using(Files.newInputStream(programFile)) { is =>
- vct.col.ast.serialize.Program.parseFrom(is)
- }
+ val cachedProgram =
+ Using(Files.newInputStream(programFile)) { is =>
+ vct.col.ast.serialize.Program.parseFrom(is)
+ }
- if(cachedProgram != program) {
+ if (cachedProgram != program) {
// Unlikely: in case of a hash collision, just run the verification (permanently unlucky)
update
}
} else if (update) {
// If the result is not even potentially cached, run update, and if the program definitely verifies, store the result.
path.toFile.mkdirs()
- Using(Files.newOutputStream(programFile)) { os =>
- program.writeTo(os)
- }
+ Using(Files.newOutputStream(programFile)) { os => program.writeTo(os) }
}
}
override def run(in: Verification[_ <: Generation]): Seq[ExpectedError] = {
val stages = Seq("Translation" -> 1, "Proving" -> 10)
- Progress.stages(if(skipVerification) stages.init else stages) { next =>
+ Progress.stages(
+ if (skipVerification)
+ stages.init
+ else
+ stages
+ ) { next =>
val intermediates: Seq[(Program[_ <: Generation], Intermediate)] =
- Progress.map[(VerificationContext[_ <: Generation], Int), (Program[_ <: Generation], Intermediate)](
- in.tasks.zipWithIndex.par, t => s"Task ${t._2 + 1}") { case (task, idx) =>
- (task.program, transform(task.program, idx))}.iterator.to(Seq)
+ Progress
+ .map[
+ (VerificationContext[_ <: Generation], Int),
+ (Program[_ <: Generation], Intermediate),
+ ](in.tasks.zipWithIndex.par, t => s"Task ${t._2 + 1}") {
+ case (task, idx) => (task.program, transform(task.program, idx))
+ }.iterator.to(Seq)
- if(skipVerification) return Seq()
+ if (skipVerification)
+ return Seq()
next()
- Progress.foreach[((Program[_ <: Generation], Intermediate), Int)](intermediates.zipWithIndex.par, t => s"Task ${t._2 + 1}") { case (intermediate, _) =>
- cachedDefinitelyVerifiesOrElseUpdate(intermediate._1, verify(intermediate._2))
+ Progress.foreach[((Program[_ <: Generation], Intermediate), Int)](
+ intermediates.zipWithIndex.par,
+ t => s"Task ${t._2 + 1}",
+ ) { case (intermediate, _) =>
+ cachedDefinitelyVerifiesOrElseUpdate(
+ intermediate._1,
+ verify(intermediate._2),
+ )
}
in.expectedErrors
@@ -136,16 +176,28 @@ trait Backend extends Stage[Verification[_ <: Generation], Seq[ExpectedError]] {
}
trait Intermediate
-case class SilverIntermediate(intermediate: (silver.Program, Map[Int, vct.col.ast.Node[_]])) extends Intermediate
-
-case class SilverBackend(backend: viper.SilverBackend, output: Option[Path] = None, cacheDirectory: Option[Path] = None, override val skipVerification: Boolean = false) extends Backend {
- override def transform(program: Program[_ <: Generation], idx: Int): Intermediate =
- SilverIntermediate(backend.transform(program, output.map(p => p.resolveSibling(p.getFileName.toString + s"-$idx.vpr"))))
+case class SilverIntermediate(
+ intermediate: (silver.Program, Map[Int, vct.col.ast.Node[_]])
+) extends Intermediate
+
+case class SilverBackend(
+ backend: viper.SilverBackend,
+ output: Option[Path] = None,
+ cacheDirectory: Option[Path] = None,
+ override val skipVerification: Boolean = false,
+) extends Backend {
+ override def transform(
+ program: Program[_ <: Generation],
+ idx: Int,
+ ): Intermediate =
+ SilverIntermediate(backend.transform(
+ program,
+ output.map(p => p.resolveSibling(p.getFileName.toString + s"-$idx.vpr")),
+ ))
override def verify(intermediate: Intermediate): Boolean = {
val SilverIntermediate(intermediateProgram) = intermediate
backend.submit(intermediateProgram)
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/vct/main/stages/ExpectedErrors.scala b/src/main/vct/main/stages/ExpectedErrors.scala
index 442a0f393e..3e32e97514 100644
--- a/src/main/vct/main/stages/ExpectedErrors.scala
+++ b/src/main/vct/main/stages/ExpectedErrors.scala
@@ -6,14 +6,12 @@ import vct.options.Options
case object ExpectedErrors {
// Just to be uniform with the other stages
- def ofOptions(options: Options): ExpectedErrors =
- ExpectedErrors()
+ def ofOptions(options: Options): ExpectedErrors = ExpectedErrors()
}
case class ExpectedErrors() extends Stage[Seq[ExpectedError], Unit] {
override def friendlyName: String = "Check inverted errors"
override def progressWeight: Int = 1
- override def run(in: Seq[ExpectedError]): Unit =
- in.foreach(_.signalDone())
+ override def run(in: Seq[ExpectedError]): Unit = in.foreach(_.signalDone())
}
diff --git a/src/main/vct/main/stages/GenerateRASI.scala b/src/main/vct/main/stages/GenerateRASI.scala
index 2c5af6d79c..060aaf609f 100644
--- a/src/main/vct/main/stages/GenerateRASI.scala
+++ b/src/main/vct/main/stages/GenerateRASI.scala
@@ -4,7 +4,13 @@ import hre.stages.Stage
import vct.col.ast.{InstanceField, InstanceMethod, InstancePredicate, Node}
import vct.col.rewrite.Generation
import vct.options.Options
-import vct.rewrite.rasi.{ConcreteVariable, FieldVariable, IndexedVariable, RASIGenerator, SizeVariable}
+import vct.rewrite.rasi.{
+ ConcreteVariable,
+ FieldVariable,
+ IndexedVariable,
+ RASIGenerator,
+ SizeVariable,
+}
import java.nio.file.Path
@@ -14,36 +20,71 @@ case object GenerateRASI {
}
}
-case class GenerateRASI(vars: Option[Seq[String]], out: Path) extends Stage[Node[_ <: Generation], Unit] {
+case class GenerateRASI(vars: Option[Seq[String]], out: Path)
+ extends Stage[Node[_ <: Generation], Unit] {
- override def friendlyName: String = "Generate reachable abstract states invariant"
+ override def friendlyName: String =
+ "Generate reachable abstract states invariant"
override def progressWeight: Int = 0
override def run(in1: Node[_ <: Generation]): Unit = {
val in = in1.asInstanceOf[Node[Generation]]
- val main_method = in.transSubnodes.collectFirst{ case m: InstanceMethod[_] if m.o.getPreferredName.get.snake.equals("main") => m }.get
- val variables: Set[ConcreteVariable[Generation]] = vars.getOrElse(Seq()).map(s => resolve_variable(in, s)).toSet
- val parameter_invariant: InstancePredicate[Generation] = get_parameter_invariant(in)
+ val main_method =
+ in.transSubnodes.collectFirst {
+ case m: InstanceMethod[_]
+ if m.o.getPreferredName.get.snake.equals("main") =>
+ m
+ }.get
+ val variables: Set[ConcreteVariable[Generation]] =
+ vars.getOrElse(Seq()).map(s => resolve_variable(in, s)).toSet
+ val parameter_invariant: InstancePredicate[Generation] =
+ get_parameter_invariant(in)
new RASIGenerator().test(main_method, variables, parameter_invariant, out)
}
- private def resolve_variable(in: Node[Generation], name: String): ConcreteVariable[Generation] = {
+ private def resolve_variable(
+ in: Node[Generation],
+ name: String,
+ ): ConcreteVariable[Generation] = {
if (name.contains("|")) {
val var_name = name.substring(1, name.length - 1)
- return SizeVariable(in.transSubnodes.collectFirst{ case f: InstanceField[_] if f.o.getPreferredName.get.snake.equals(var_name) => f }.get)
+ return SizeVariable(in.transSubnodes.collectFirst {
+ case f: InstanceField[_]
+ if f.o.getPreferredName.get.snake.equals(var_name) =>
+ f
+ }.get)
}
val name_len = name.indexOf("[")
- val var_name = if (name_len == -1) name else name.substring(0, name_len)
- val index: Option[Integer] = if (name_len == -1) None else Some(Integer.valueOf(name.substring(name_len + 1, name.length - 1)))
- val instance_field = in.transSubnodes.collectFirst{ case f: InstanceField[_] if f.o.getPreferredName.get.snake.equals(var_name) => f }.get
+ val var_name =
+ if (name_len == -1)
+ name
+ else
+ name.substring(0, name_len)
+ val index: Option[Integer] =
+ if (name_len == -1)
+ None
+ else
+ Some(Integer.valueOf(name.substring(name_len + 1, name.length - 1)))
+ val instance_field =
+ in.transSubnodes.collectFirst {
+ case f: InstanceField[_]
+ if f.o.getPreferredName.get.snake.equals(var_name) =>
+ f
+ }.get
index match {
case Some(i) => IndexedVariable(instance_field, i)
case None => FieldVariable(instance_field)
}
}
- private def get_parameter_invariant(in: Node[Generation]): InstancePredicate[Generation] = {
- in.transSubnodes.collectFirst{ case p: InstancePredicate[_] if p.o.getPreferredName.get.snake.equals("parameter_invariant") => p }.get
+ private def get_parameter_invariant(
+ in: Node[Generation]
+ ): InstancePredicate[Generation] = {
+ in.transSubnodes.collectFirst {
+ case p: InstancePredicate[_]
+ if p.o.getPreferredName.get.snake.equals("parameter_invariant") =>
+ p
+ }.get
}
}
diff --git a/src/main/vct/main/stages/Output.scala b/src/main/vct/main/stages/Output.scala
index ff7641b9a8..9b8e435b42 100644
--- a/src/main/vct/main/stages/Output.scala
+++ b/src/main/vct/main/stages/Output.scala
@@ -16,70 +16,87 @@ import java.nio.file.{Files, Path}
/* TODO (RR): I messed this up for VeyMont & VeSUV, need to coordinate with Philip to get it in a nice shape
Philip does use the splitting up feature, so I'd need to rework that either into Output or into a separate stage
Also the writing to file feature he relies on.
-*/
-
+ */
case object Output {
- def vesuvOfOptions[G <: Generation](options: Options): Stages[ParseResult[G], Unit] = {
+ def vesuvOfOptions[G <: Generation](
+ options: Options
+ ): Stages[ParseResult[G], Unit] = {
// FunctionStage((pr: ParseResult[_ <: Generation]) => Program(pr.decls)(DiagnosticOrigin)(DiagnosticOrigin))
// .thenRun(??? /* Output(options.vesuvOutput, Ctx.PVL) */)
???
}
- def veymontOfOptions(options: Options): Stage[Verification[_ <: Generation], Seq[LiteralReadable]] =
+ def veymontOfOptions(
+ options: Options
+ ): Stage[Verification[_ <: Generation], Seq[LiteralReadable]] =
Output(options.veymontOutput, Ctx.PVL, false)
}
-case class Output(out: Option[Path], syntax: Ctx.Syntax, splitDecls: Boolean) extends Stage[Verification[_ <: Generation], Seq[LiteralReadable]] with LazyLogging {
+case class Output(out: Option[Path], syntax: Ctx.Syntax, splitDecls: Boolean)
+ extends Stage[Verification[_ <: Generation], Seq[LiteralReadable]]
+ with LazyLogging {
override def friendlyName: String = "Saving Output"
override def progressWeight: Int = 1
- def extension(syntax: Ctx.Syntax): String = syntax match {
- case Ctx.PVL => "pvl"
- case Ctx.Silver => "vpr"
- case Ctx.Java => "java"
- case Ctx.C => "c"
- case Ctx.CPP => "cpp"
- case Ctx.Cuda => "cu"
- case Ctx.OpenCL => "cl"
- }
+ def extension(syntax: Ctx.Syntax): String =
+ syntax match {
+ case Ctx.PVL => "pvl"
+ case Ctx.Silver => "vpr"
+ case Ctx.Java => "java"
+ case Ctx.C => "c"
+ case Ctx.CPP => "cpp"
+ case Ctx.Cuda => "cu"
+ case Ctx.OpenCL => "cl"
+ }
override def run(in: Verification[_ <: Generation]): Seq[LiteralReadable] = {
val namer = Namer[Generation](syntax)
- in.tasks.foreach(t => namer.name(t.program.asInstanceOf[Program[Generation]]))
+ in.tasks
+ .foreach(t => namer.name(t.program.asInstanceOf[Program[Generation]]))
val names = namer.finish
- val ctx = Ctx(syntax = syntax, names = names.asInstanceOf[Map[Declaration[_], String]])
+ val ctx = Ctx(
+ syntax = syntax,
+ names = names.asInstanceOf[Map[Declaration[_], String]],
+ )
- val txts: Seq[LiteralReadable] = if (splitDecls) {
- in.asInstanceOf[Program[_]].declarations.zipWithIndex.map { case (decl, i) =>
- val name = names.getOrElse(decl.asInstanceOf, s"unknown$i")
- val fileName = s"${name}.${extension(syntax)}"
+ val txts: Seq[LiteralReadable] =
+ if (splitDecls) {
+ in.asInstanceOf[Program[_]].declarations.zipWithIndex.map {
+ case (decl, i) =>
+ val name = names.getOrElse(decl.asInstanceOf, s"unknown$i")
+ val fileName = s"${name}.${extension(syntax)}"
+ val buf = new StringBuffer()
+ decl.write(buf)(ctx)
+ LiteralReadable(buf.toString, fileName)
+ }
+ } else {
val buf = new StringBuffer()
- decl.write(buf)(ctx)
- LiteralReadable(buf.toString, fileName)
+ in.write(buf)(ctx)
+ val path = s"unknown.${extension(syntax)}"
+ Seq(LiteralReadable(buf.toString, path))
}
- } else {
- val buf = new StringBuffer()
- in.write(buf)(ctx)
- val path = s"unknown.${extension(syntax)}"
- Seq(LiteralReadable(buf.toString, path))
- }
(out, txts) match {
case (Some(p), Seq()) =>
- logger.warn("Output stage was executed without any declarations to print")
+ logger
+ .warn("Output stage was executed without any declarations to print")
Files.write(p, "".getBytes(StandardCharsets.UTF_8))
case (Some(p), Seq(txt)) =>
logger.info(s"Writing ${txt.fileName} to $p")
Files.write(p, txt.data.getBytes(StandardCharsets.UTF_8))
- case (Some(p), txts) => txts.foreach { txt =>
- logger.info(s"Writing ${txt.fileName} to $p")
- Files.write(p.resolve(txt.fileName), txt.data.getBytes(StandardCharsets.UTF_8))
- }
+ case (Some(p), txts) =>
+ txts.foreach { txt =>
+ logger.info(s"Writing ${txt.fileName} to $p")
+ Files.write(
+ p.resolve(txt.fileName),
+ txt.data.getBytes(StandardCharsets.UTF_8),
+ )
+ }
case _ =>
}
txts
}
-}
\ No newline at end of file
+}
diff --git a/src/main/vct/main/stages/Parsing.scala b/src/main/vct/main/stages/Parsing.scala
index b2c070f247..3e8317ce40 100644
--- a/src/main/vct/main/stages/Parsing.scala
+++ b/src/main/vct/main/stages/Parsing.scala
@@ -9,7 +9,16 @@ import vct.main.stages.Parsing.{Language, UnknownFileExtension}
import vct.options.Options
import vct.parsers._
import vct.parsers.debug.DebugOptions
-import vct.parsers.parser.{ColCPPParser, ColCParser, ColIPPParser, ColIParser, ColJavaParser, ColLLVMParser, ColPVLParser, ColSystemCParser}
+import vct.parsers.parser.{
+ ColCPPParser,
+ ColCParser,
+ ColIPPParser,
+ ColIParser,
+ ColJavaParser,
+ ColLLVMParser,
+ ColPVLParser,
+ ColSystemCParser,
+}
import vct.parsers.transform.BlameProvider
import vct.resources.Resources
import vct.result.VerificationError.UserError
@@ -47,11 +56,15 @@ case object Parsing {
}
case class UnknownFileExtension(extension: String) extends UserError {
- override def text: String = s"Unknown file extension: $extension. Try altering the extension of the file, or specify a language explicitly with --lang."
+ override def text: String =
+ s"Unknown file extension: $extension. Try altering the extension of the file, or specify a language explicitly with --lang."
override def code: String = "unknownExt"
}
- def ofOptions[G <: Generation](options: Options, blameProvider: BlameProvider): Parsing[G] =
+ def ofOptions[G <: Generation](
+ options: Options,
+ blameProvider: BlameProvider,
+ ): Parsing[G] =
Parsing(
blameProvider = blameProvider,
debugOptions = options.getParserDebugOptions,
@@ -63,43 +76,67 @@ case object Parsing {
)
}
-case class Parsing[G <: Generation]
-(
- blameProvider: BlameProvider,
- forceLanguage: Option[Language] = None,
- debugOptions: DebugOptions = DebugOptions.NONE,
- cc: Path = Resources.getCcPath,
- cSystemInclude: Path = Resources.getCIncludePath,
- cOtherIncludes: Seq[Path] = Nil,
- cDefines: Map[String, String] = Map.empty,
- ccpp: Path = Resources.getCPPcPath,
- cppSystemInclude: Path = Resources.getCPPIncludePath,
- cppOtherIncludes: Seq[Path] = Nil,
- cppDefines: Map[String, String] = Map.empty,
+case class Parsing[G <: Generation](
+ blameProvider: BlameProvider,
+ forceLanguage: Option[Language] = None,
+ debugOptions: DebugOptions = DebugOptions.NONE,
+ cc: Path = Resources.getCcPath,
+ cSystemInclude: Path = Resources.getCIncludePath,
+ cOtherIncludes: Seq[Path] = Nil,
+ cDefines: Map[String, String] = Map.empty,
+ ccpp: Path = Resources.getCPPcPath,
+ cppSystemInclude: Path = Resources.getCPPIncludePath,
+ cppOtherIncludes: Seq[Path] = Nil,
+ cppDefines: Map[String, String] = Map.empty,
) extends Stage[Seq[Readable], ParseResult[G]] {
override def friendlyName: String = "Parsing"
override def progressWeight: Int = 4
override def run(in: Seq[Readable]): ParseResult[G] =
- ParseResult.reduce(Progress.map(in, (r: Readable) => r.fileName) { readable =>
- val language = forceLanguage
- .orElse(Language.fromFilename(readable.fileName))
- .getOrElse(throw UnknownFileExtension(readable.fileName))
+ ParseResult.reduce(
+ Progress.map(in, (r: Readable) => r.fileName) { readable =>
+ val language = forceLanguage
+ .orElse(Language.fromFilename(readable.fileName))
+ .getOrElse(throw UnknownFileExtension(readable.fileName))
- val origin = Origin(Seq(ReadableOrigin(readable)))
+ val origin = Origin(Seq(ReadableOrigin(readable)))
- val parser = language match {
- case Language.C => ColCParser(debugOptions, blameProvider, cc, cSystemInclude, Option(Paths.get(readable.fileName).getParent).toSeq ++ cOtherIncludes, cDefines)
- case Language.InterpretedC => ColIParser(debugOptions, blameProvider, cOrigin = None)
- case Language.CPP => ColCPPParser(debugOptions, blameProvider, ccpp, cppSystemInclude, Option(Paths.get(readable.fileName).getParent).toSeq ++ cppOtherIncludes, cppDefines)
- case Language.InterpretedCPP => ColIPPParser(debugOptions, blameProvider, cppOrigin = None)
- case Language.Java => ColJavaParser(debugOptions, blameProvider)
- case Language.PVL => ColPVLParser(debugOptions, blameProvider)
- case Language.Silver => ColSilverParser(blameProvider)
- case Language.SystemC => new ColSystemCParser(Resources.getSystemCConfig)
- case Language.LLVM => ColLLVMParser(debugOptions, blameProvider, Resources.getVCLLVM)
- }
+ val parser =
+ language match {
+ case Language.C =>
+ ColCParser(
+ debugOptions,
+ blameProvider,
+ cc,
+ cSystemInclude,
+ Option(Paths.get(readable.fileName).getParent).toSeq ++
+ cOtherIncludes,
+ cDefines,
+ )
+ case Language.InterpretedC =>
+ ColIParser(debugOptions, blameProvider, cOrigin = None)
+ case Language.CPP =>
+ ColCPPParser(
+ debugOptions,
+ blameProvider,
+ ccpp,
+ cppSystemInclude,
+ Option(Paths.get(readable.fileName).getParent).toSeq ++
+ cppOtherIncludes,
+ cppDefines,
+ )
+ case Language.InterpretedCPP =>
+ ColIPPParser(debugOptions, blameProvider, cppOrigin = None)
+ case Language.Java => ColJavaParser(debugOptions, blameProvider)
+ case Language.PVL => ColPVLParser(debugOptions, blameProvider)
+ case Language.Silver => ColSilverParser(blameProvider)
+ case Language.SystemC =>
+ new ColSystemCParser(Resources.getSystemCConfig)
+ case Language.LLVM =>
+ ColLLVMParser(debugOptions, blameProvider, Resources.getVCLLVM)
+ }
- parser.parse[G](readable)
- }.iterator.to(Seq))
+ parser.parse[G](readable)
+ }.iterator.to(Seq)
+ )
}
diff --git a/src/main/vct/main/stages/PrintCFG.scala b/src/main/vct/main/stages/PrintCFG.scala
index bc4adbd6b9..54bf7f7eeb 100644
--- a/src/main/vct/main/stages/PrintCFG.scala
+++ b/src/main/vct/main/stages/PrintCFG.scala
@@ -22,7 +22,12 @@ case class PrintCFG(out: Path) extends Stage[Node[_ <: Generation], Unit] {
override def run(in1: Node[_ <: Generation]): Unit = {
// TODO: Is there a better way to find a "main" method?
- val main_method = in1.transSubnodes.collectFirst{ case m: InstanceMethod[_] if m.o.getPreferredName.get.snake.equals("main") => m }.get
+ val main_method =
+ in1.transSubnodes.collectFirst {
+ case m: InstanceMethod[_]
+ if m.o.getPreferredName.get.snake.equals("main") =>
+ m
+ }.get
CFGPrinter().print_ast_as_cfg(main_method, out)
}
}
diff --git a/src/main/vct/main/stages/Resolution.scala b/src/main/vct/main/stages/Resolution.scala
index eeea43af13..64aa310b13 100644
--- a/src/main/vct/main/stages/Resolution.scala
+++ b/src/main/vct/main/stages/Resolution.scala
@@ -3,11 +3,29 @@ package vct.main.stages
import com.typesafe.scalalogging.LazyLogging
import hre.io.LiteralReadable
import hre.stages.Stage
-import vct.col.ast.{AddrOf, ApplicableContract, CGlobalDeclaration, Expr, GlobalDeclaration, LlvmFunctionContract, LlvmGlobal, Program, Refute, Verification, VerificationContext}
+import vct.col.ast.{
+ AddrOf,
+ ApplicableContract,
+ CGlobalDeclaration,
+ Expr,
+ GlobalDeclaration,
+ LlvmFunctionContract,
+ LlvmGlobal,
+ Program,
+ Refute,
+ Verification,
+ VerificationContext,
+}
import org.antlr.v4.runtime.CharStreams
import vct.col.ast._
import vct.col.check.CheckError
-import vct.col.origin.{FileSpanningOrigin, InlineBipContext, Origin, OriginFilename, ReadableOrigin}
+import vct.col.origin.{
+ FileSpanningOrigin,
+ InlineBipContext,
+ Origin,
+ OriginFilename,
+ ReadableOrigin,
+}
import vct.col.resolve.{Resolve, ResolveReferences, ResolveTypes}
import vct.col.rewrite.Generation
import vct.col.rewrite.bip.IsolateBipGlue
@@ -29,18 +47,25 @@ import java.nio.file.NoSuchFileException
case object Resolution {
case class InputResolutionError(errors: Seq[CheckError]) extends UserError {
- override def code: String = s"resolutionError:${errors.map(_.subcode).mkString(",")}"
+ override def code: String =
+ s"resolutionError:${errors.map(_.subcode).mkString(",")}"
override def text: String = errors.map(_.message(_.o)).mkString("\n")
}
- def ofOptions[G <: Generation](options: Options, blameProvider: BlameProvider): Resolution[G] =
+ def ofOptions[G <: Generation](
+ options: Options,
+ blameProvider: BlameProvider,
+ ): Resolution[G] =
Resolution(
blameProvider = blameProvider,
parserDebugOptions = options.getParserDebugOptions,
classPath = options.classPath.map {
- case ClassPathEntry.DefaultJre => ResolveTypes.JavaClassPathEntry.Path(Resources.getJrePath)
- case ClassPathEntry.SourcePackageRoot => ResolveTypes.JavaClassPathEntry.SourcePackageRoot
- case ClassPathEntry.SourcePath(root) => ResolveTypes.JavaClassPathEntry.Path(root)
+ case ClassPathEntry.DefaultJre =>
+ ResolveTypes.JavaClassPathEntry.Path(Resources.getJrePath)
+ case ClassPathEntry.SourcePackageRoot =>
+ ResolveTypes.JavaClassPathEntry.SourcePackageRoot
+ case ClassPathEntry.SourcePath(root) =>
+ ResolveTypes.JavaClassPathEntry.Path(root)
},
options.veymontGeneratePermissions,
options.devVeymontAllowAssign,
@@ -53,39 +78,49 @@ case class SpecExprParseError(msg: String) extends UserError {
override def text: String = msg
}
-case class MyLocalJavaParser(blameProvider: BlameProvider, debugOptions: DebugOptions) extends Resolve.SpecExprParser {
+case class MyLocalJavaParser(
+ blameProvider: BlameProvider,
+ debugOptions: DebugOptions,
+) extends Resolve.SpecExprParser {
override def parse[G](input: String, o: Origin): Expr[G] = {
val sr = LiteralReadable("", input)
val cjp = parser.ColJavaParser(debugOptions, blameProvider)
val x = cjp.parseExpr[G](sr)
- if (x._2.nonEmpty) {
- throw SpecExprParseError("...")
- }
+ if (x._2.nonEmpty) { throw SpecExprParseError("...") }
x._1
}
}
-case class MyLocalLLVMSpecParser(blameProvider: BlameProvider, debugOptions: DebugOptions) extends Resolve.SpecContractParser {
- override def parse[G](input: LlvmFunctionContract[G], o: Origin): ApplicableContract[G] =
+case class MyLocalLLVMSpecParser(
+ blameProvider: BlameProvider,
+ debugOptions: DebugOptions,
+) extends Resolve.SpecContractParser {
+ override def parse[G](
+ input: LlvmFunctionContract[G],
+ o: Origin,
+ ): ApplicableContract[G] =
parser.ColLLVMContractParser(debugOptions, blameProvider)
.parseFunctionContract[G](new StringReader(input.value), o)._1
- override def parse[G](input: LlvmGlobal[G], o: Origin): Seq[GlobalDeclaration[G]] =
+ override def parse[G](
+ input: LlvmGlobal[G],
+ o: Origin,
+ ): Seq[GlobalDeclaration[G]] =
parser.ColLLVMContractParser(debugOptions, blameProvider)
.parseReader[G](new StringReader(input.value), o).decls
}
-case class Resolution[G <: Generation]
-(
- blameProvider: BlameProvider,
- parserDebugOptions: DebugOptions,
- classPath: Seq[ResolveTypes.JavaClassPathEntry] = Seq(
- ResolveTypes.JavaClassPathEntry.Path(Resources.getJrePath),
- ResolveTypes.JavaClassPathEntry.SourcePackageRoot
- ),
- veymontGeneratePermissions: Boolean = false,
- veymontAllowAssign: Boolean = false,
-) extends Stage[ParseResult[G], Verification[_ <: Generation]] with LazyLogging {
+case class Resolution[G <: Generation](
+ blameProvider: BlameProvider,
+ parserDebugOptions: DebugOptions,
+ classPath: Seq[ResolveTypes.JavaClassPathEntry] = Seq(
+ ResolveTypes.JavaClassPathEntry.Path(Resources.getJrePath),
+ ResolveTypes.JavaClassPathEntry.SourcePackageRoot,
+ ),
+ veymontGeneratePermissions: Boolean = false,
+ veymontAllowAssign: Boolean = false,
+) extends Stage[ParseResult[G], Verification[_ <: Generation]]
+ with LazyLogging {
override def friendlyName: String = "Name Resolution"
override def progressWeight: Int = 1
@@ -95,15 +130,26 @@ case class Resolution[G <: Generation]
val parsedProgram = Program(in.decls)(blameProvider())
val isolatedBipProgram = IsolateBipGlue.isolate(parsedProgram)
- val extraDecls = ResolveTypes.resolve(isolatedBipProgram, Some(JavaLibraryLoader(blameProvider, parserDebugOptions)), classPath)
- val joinedProgram = Program(isolatedBipProgram.declarations ++ extraDecls)(blameProvider())
+ val extraDecls = ResolveTypes.resolve(
+ isolatedBipProgram,
+ Some(JavaLibraryLoader(blameProvider, parserDebugOptions)),
+ classPath,
+ )
+ val joinedProgram =
+ Program(isolatedBipProgram.declarations ++ extraDecls)(blameProvider())
val typedProgram = LangTypesToCol().dispatch(joinedProgram)
- ResolveReferences.resolve(typedProgram, MyLocalJavaParser(blameProvider, parserDebugOptions), MyLocalLLVMSpecParser(blameProvider, parserDebugOptions)) match {
+ ResolveReferences.resolve(
+ typedProgram,
+ MyLocalJavaParser(blameProvider, parserDebugOptions),
+ MyLocalLLVMSpecParser(blameProvider, parserDebugOptions),
+ ) match {
case Nil => // ok
- case some =>
- throw InputResolutionError(some)
+ case some => throw InputResolutionError(some)
}
- val resolvedProgram = LangSpecificToCol(veymontGeneratePermissions, veymontAllowAssign).dispatch(typedProgram)
+ val resolvedProgram = LangSpecificToCol(
+ veymontGeneratePermissions,
+ veymontAllowAssign,
+ ).dispatch(typedProgram)
resolvedProgram.check match {
case Nil => // ok
// PB: This explicitly allows LangSpecificToCol to generate invalid ASTs, and will blame the input for them. The
diff --git a/src/main/vct/main/stages/Stages.scala b/src/main/vct/main/stages/Stages.scala
index 22d8c4d5aa..beba65e6b2 100644
--- a/src/main/vct/main/stages/Stages.scala
+++ b/src/main/vct/main/stages/Stages.scala
@@ -20,42 +20,50 @@ import com.typesafe.scalalogging.LazyLogging
import scala.collection.mutable
case object Stages extends LazyLogging {
- def silicon(blameProvider: BlameProvider, bipResults: BIP.VerificationResults): Stages[Seq[Readable], Unit] = {
+ def silicon(
+ blameProvider: BlameProvider,
+ bipResults: BIP.VerificationResults,
+ ): Stages[Seq[Readable], Unit] = {
Parsing(blameProvider)
.thenRun(Resolution(blameProvider, vct.parsers.debug.DebugOptions.NONE))
.thenRun(SilverTransformation(bipResults = bipResults))
- .thenRun(SilverBackend(Silicon()))
- .thenRun(ExpectedErrors())
+ .thenRun(SilverBackend(Silicon())).thenRun(ExpectedErrors())
}
- def carbon(blameProvider: BlameProvider, bipResults: BIP.VerificationResults): Stages[Seq[Readable], Unit] = {
+ def carbon(
+ blameProvider: BlameProvider,
+ bipResults: BIP.VerificationResults,
+ ): Stages[Seq[Readable], Unit] = {
Parsing(blameProvider)
.thenRun(Resolution(blameProvider, vct.parsers.debug.DebugOptions.NONE))
.thenRun(SilverTransformation(bipResults = bipResults))
- .thenRun(SilverBackend(Carbon()))
- .thenRun(ExpectedErrors())
+ .thenRun(SilverBackend(Carbon())).thenRun(ExpectedErrors())
}
- /**
- * Constructs a normal verification run from the command line options.
- *
- * A normal verification run consists of five stages:
- *
- *
[[Parsing]], which transforms a set of input files to parse trees, and transforms the parse trees to an
- * unresolved abstract syntax tree (AST).
- *
[[Resolution]], which resolves names in the AST and translates them to cross-references.
- *
[[Transformation]], which reduces the number of features in the AST so that the verification backend
- * supports all the different kinds of nodes still present.
- *
[[Backend]], which takes in a wildly simplified AST, and verifies the specified properties. Any specified
- * properties that do not hold are reported to the respective [[vct.col.origin.Blame]] members of the nodes.
- *
[[ExpectedErrors]], which turns the absence of expected errors into errors.
- *
- *
- * @param options
- * @param blameProvider
- * @return
- */
- def ofOptions(options: Options, blameProvider: BlameProvider, bipResults: BIP.VerificationResults): Stages[Seq[Readable], Unit] = {
+ /** Constructs a normal verification run from the command line options.
+ *
+ * A normal verification run consists of five stages:
[[Parsing]],
+ * which transforms a set of input files to parse trees, and transforms the
+ * parse trees to an unresolved abstract syntax tree (AST).
+ *
[[Resolution]], which resolves names in the AST and translates them to
+ * cross-references.
[[Transformation]], which reduces the number of
+ * features in the AST so that the verification backend supports all the
+ * different kinds of nodes still present.
[[Backend]], which takes
+ * in a wildly simplified AST, and verifies the specified properties. Any
+ * specified properties that do not hold are reported to the respective
+ * [[vct.col.origin.Blame]] members of the nodes.
+ *
[[ExpectedErrors]], which turns the absence of expected errors into
+ * errors.
+ *
+ * @param options
+ * @param blameProvider
+ * @return
+ */
+ def ofOptions(
+ options: Options,
+ blameProvider: BlameProvider,
+ bipResults: BIP.VerificationResults,
+ ): Stages[Seq[Readable], Unit] = {
Parsing.ofOptions(options, blameProvider)
.thenRun(Resolution.ofOptions(options, blameProvider))
.thenRun(Transformation.ofOptions(options, bipResults))
@@ -64,31 +72,39 @@ case object Stages extends LazyLogging {
}
def veymontOfOptions(options: Options): Stages[Seq[Readable], Unit] = {
- val choreographyStage: Stages[Seq[Readable], Verification[_ <: Generation]] = {
+ val choreographyStage
+ : Stages[Seq[Readable], Verification[_ <: Generation]] = {
val collector = BlameCollector()
val bipResults = BIP.VerificationResults()
val blameProvider = ConstantBlameProvider(collector)
- IdentityStage().also(logger.info("VeyMont choreography verifier & code generator"))
- .thenRun(Parsing.ofOptions(options, blameProvider).also(logger.info("Finished parsing")))
- .thenRun(Resolution.ofOptions(options, blameProvider))
- .thenRun(
- saveInput[Verification[_ <: Generation], Any](
- branch(!options.veymontSkipChoreographyVerification,
- IdentityStage().also(logger.info("Verifying choreography with VerCors"))
- .thenRun(Transformation.ofOptions(options, bipResults))
- .thenRun(Backend.ofOptions(options))
- .thenRun(ExpectedErrors.ofOptions(options))
- .thenRun(VeyMont.NoVerificationFailures(collector, VeyMont.ChoreographyVerificationError)),
- IdentityStage().also(logger.warn("Skipping verifying choreography with VerCors"))
- ))
- ).transform(_._1)
+ IdentityStage()
+ .also(logger.info("VeyMont choreography verifier & code generator"))
+ .thenRun(Parsing.ofOptions(options, blameProvider).also(logger.info(
+ "Finished parsing"
+ ))).thenRun(Resolution.ofOptions(options, blameProvider))
+ .thenRun(saveInput[Verification[_ <: Generation], Any](branch(
+ !options.veymontSkipChoreographyVerification,
+ IdentityStage()
+ .also(logger.info("Verifying choreography with VerCors"))
+ .thenRun(Transformation.ofOptions(options, bipResults))
+ .thenRun(Backend.ofOptions(options))
+ .thenRun(ExpectedErrors.ofOptions(options))
+ .thenRun(VeyMont.NoVerificationFailures(
+ collector,
+ VeyMont.ChoreographyVerificationError,
+ )),
+ IdentityStage()
+ .also(logger.warn("Skipping verifying choreography with VerCors")),
+ ))).transform(_._1)
}
- val generationStage: Stages[Verification[_ <: Generation], Seq[LiteralReadable]] = {
+ val generationStage
+ : Stages[Verification[_ <: Generation], Seq[LiteralReadable]] = {
IdentityStage().also(logger.info("Generating endpoint implementations"))
- .thenRun(Transformation.veymontImplementationGenerationOfOptions(options))
- .thenRun(Output.veymontOfOptions(options))
+ .thenRun(Transformation.veymontImplementationGenerationOfOptions(
+ options
+ )).thenRun(Output.veymontOfOptions(options))
}
val implementationVerificationStage = {
@@ -101,29 +117,36 @@ case object Stages extends LazyLogging {
.thenRun(Transformation.ofOptions(options, bipResults))
.thenRun(Backend.ofOptions(options))
.thenRun(ExpectedErrors.ofOptions(options))
- .thenRun(VeyMont.NoVerificationFailures(collector, VeyMont.ImplementationVerificationError))
+ .thenRun(VeyMont.NoVerificationFailures(
+ collector,
+ VeyMont.ImplementationVerificationError,
+ ))
}
- choreographyStage
- .thenRun(generationStage)
+ choreographyStage.thenRun(generationStage)
.thenRun(implementationVerificationStage)
}
- def vesuvOfOptions(options: Options, blameProvider: BlameProvider) : Stages[Seq[Readable], Unit] = {
+ def vesuvOfOptions(
+ options: Options,
+ blameProvider: BlameProvider,
+ ): Stages[Seq[Readable], Unit] = {
if (options.vesuvGenerateRasi) {
Parsing.ofOptions(options, blameProvider)
.thenRun(Resolution.ofOptions(options, blameProvider))
.thenRun(GenerateRASI.ofOptions(options))
- }
- else {
+ } else {
Parsing.ofOptions(options, blameProvider)
.thenRun(Output.vesuvOfOptions(options))
}
}
- def cfgTransformationOfOptions(options: Options, blameProvider: BlameProvider): Stages[Seq[Readable], Unit] = {
+ def cfgTransformationOfOptions(
+ options: Options,
+ blameProvider: BlameProvider,
+ ): Stages[Seq[Readable], Unit] = {
Parsing.ofOptions(options, blameProvider)
.thenRun(Resolution.ofOptions(options, blameProvider))
.thenRun(PrintCFG.ofOptions(options))
}
-}
\ No newline at end of file
+}
diff --git a/src/main/vct/main/stages/Transformation.scala b/src/main/vct/main/stages/Transformation.scala
index 4de63ef48e..36fab123a0 100644
--- a/src/main/vct/main/stages/Transformation.scala
+++ b/src/main/vct/main/stages/Transformation.scala
@@ -18,48 +18,94 @@ import vct.rewrite.lang.NoSupportSelfLoop
import vct.col.rewrite.veymont.StructureCheck
import vct.importer.{PathAdtImporter, Util}
import vct.main.Main.TemporarilyUnsupported
-import vct.main.stages.Transformation.{PassEventHandler, TransformationCheckError}
+import vct.main.stages.Transformation.{
+ PassEventHandler,
+ TransformationCheckError,
+}
import vct.options.Options
import vct.options.types.{Backend, PathOrStd}
import vct.resources.Resources
import vct.result.VerificationError.SystemError
import vct.rewrite.adt.ImportSetCompat
-import vct.rewrite.{EncodeAutoValue, EncodeRange, EncodeResourceValues, ExplicitResourceValues, HeapVariableToRef, MonomorphizeClass, SmtlibToProverTypes}
+import vct.rewrite.{
+ EncodeAutoValue,
+ EncodeRange,
+ EncodeResourceValues,
+ ExplicitResourceValues,
+ HeapVariableToRef,
+ MonomorphizeClass,
+ SmtlibToProverTypes,
+}
import vct.rewrite.lang.ReplaceSYCLTypes
-import vct.rewrite.veymont.{DeduplicateChorGuards, EncodeChannels, EncodeChorBranchUnanimity, EncodeChoreography, EncodeChoreographyParameters, EncodeEndpointInequalities, EncodeUnpointedGuard, GenerateChoreographyPermissions, GenerateImplementation, InferEndpointContexts, SpecializeEndpointClasses, SplitChorGuards}
+import vct.rewrite.veymont.{
+ DeduplicateChorGuards,
+ EncodeChannels,
+ EncodeChorBranchUnanimity,
+ EncodeChoreography,
+ EncodeChoreographyParameters,
+ EncodeEndpointInequalities,
+ EncodeUnpointedGuard,
+ GenerateChoreographyPermissions,
+ GenerateImplementation,
+ InferEndpointContexts,
+ SpecializeEndpointClasses,
+ SplitChorGuards,
+}
import java.nio.file.Path
object Transformation extends LazyLogging {
- case class TransformationCheckError(pass: RewriterBuilder, errors: Seq[(Program[_], CheckError)]) extends SystemError {
+ case class TransformationCheckError(
+ pass: RewriterBuilder,
+ errors: Seq[(Program[_], CheckError)],
+ ) extends SystemError {
override def text: String =
- s"The ${pass.key} rewrite caused the AST to no longer typecheck:\n" + errors.map {
- case (program, err) => err.message(program.highlight)
- }.mkString("\n")
+ s"The ${pass.key} rewrite caused the AST to no longer typecheck:\n" +
+ errors.map { case (program, err) => err.message(program.highlight) }
+ .mkString("\n")
}
- private def writeOutFunctions(event: TransformationEvent, m: Map[String, PathOrStd]): Seq[PassEventHandler] = m.toSeq.map { case (key, out) =>
- (passes, currentEvent, currentKey, program: Verification[_ <: Generation]) => {
- if (key == currentKey && event == currentEvent) {
- out.write { writer =>
- program.write(writer)(Ctx().namesIn(program))
+ private def writeOutFunctions(
+ event: TransformationEvent,
+ m: Map[String, PathOrStd],
+ ): Seq[PassEventHandler] =
+ m.toSeq.map { case (key, out) =>
+ (
+ passes,
+ currentEvent,
+ currentKey,
+ program: Verification[_ <: Generation],
+ ) => {
+ if (key == currentKey && event == currentEvent) {
+ out.write { writer => program.write(writer)(Ctx().namesIn(program)) }
}
}
}
- }
- private def reportIntermediateProgram(out: Path, stageKey: String): PassEventHandler = {
+ private def reportIntermediateProgram(
+ out: Path,
+ stageKey: String,
+ ): PassEventHandler = {
out.toFile.mkdirs()
(passes, event, pass, program) => {
- val i = passes.map(_.key).indexOf(pass) * 2 + (if(event == before) 0 else 1)
- val target = PathOrStd.Path(out.resolve(f"$stageKey-$i%03d-$event-$pass.col"))
+ val i =
+ passes.map(_.key).indexOf(pass) * 2 +
+ (if (event == before)
+ 0
+ else
+ 1)
+ val target = PathOrStd
+ .Path(out.resolve(f"$stageKey-$i%03d-$event-$pass.col"))
target.write { writer => program.write(writer)(Ctx().namesIn(program)) }
}
}
def simplifierFor(path: PathOrStd, options: Options): RewriterBuilder =
ApplyTermRewriter.BuilderFor(
- ruleNodes = Util.loadPVLLibraryFile[InitialGeneration](path, options.getParserDebugOptions).declarations.collect {
+ ruleNodes = Util.loadPVLLibraryFile[InitialGeneration](
+ path,
+ options.getParserDebugOptions,
+ ).declarations.collect {
case rule: SimplificationRule[InitialGeneration] => rule
},
debugIn = options.devSimplifyDebugIn,
@@ -70,56 +116,87 @@ object Transformation extends LazyLogging {
debugFilterRule = options.devSimplifyDebugFilterRule,
)
- def ofOptions(options: Options, bipResults: BIP.VerificationResults = BIP.VerificationResults()): Transformation =
+ def ofOptions(
+ options: Options,
+ bipResults: BIP.VerificationResults = BIP.VerificationResults(),
+ ): Transformation =
options.backend match {
case Backend.Silicon | Backend.Carbon =>
SilverTransformation(
- adtImporter = PathAdtImporter(options.adtPath, options.getParserDebugOptions),
- onPassEvent = options.outputIntermediatePrograms.map(p => reportIntermediateProgram(p, "verify")).toSeq ++
- writeOutFunctions(Transformation.before, options.outputBeforePass) ++
- writeOutFunctions(Transformation.after, options.outputAfterPass),
- simplifyBeforeRelations = options.simplifyPaths.map(simplifierFor(_, options)),
- simplifyAfterRelations = options.simplifyPathsAfterRelations.map(simplifierFor(_, options)),
+ adtImporter = PathAdtImporter(
+ options.adtPath,
+ options.getParserDebugOptions,
+ ),
+ onPassEvent =
+ options.outputIntermediatePrograms
+ .map(p => reportIntermediateProgram(p, "verify")).toSeq ++
+ writeOutFunctions(
+ Transformation.before,
+ options.outputBeforePass,
+ ) ++
+ writeOutFunctions(Transformation.after, options.outputAfterPass),
+ simplifyBeforeRelations = options.simplifyPaths
+ .map(simplifierFor(_, options)),
+ simplifyAfterRelations = options.simplifyPathsAfterRelations
+ .map(simplifierFor(_, options)),
checkSat = options.devCheckSat,
inferHeapContextIntoFrame = options.inferHeapContextIntoFrame,
bipResults = bipResults,
- splitVerificationByProcedure = options.devSplitVerificationByProcedure,
+ splitVerificationByProcedure =
+ options.devSplitVerificationByProcedure,
veymontGeneratePermissions = options.veymontGeneratePermissions,
)
}
- def veymontImplementationGenerationOfOptions(options: Options): Transformation =
+ def veymontImplementationGenerationOfOptions(
+ options: Options
+ ): Transformation =
VeyMontImplementationGeneration(
- importer = PathAdtImporter(options.veymontResourcePath, options.getParserDebugOptions),
- onPassEvent = options.outputIntermediatePrograms.map(p => reportIntermediateProgram(p, "generate")).toSeq ++
- writeOutFunctions(before, options.outputBeforePass) ++
- writeOutFunctions(after, options.outputAfterPass),
+ importer = PathAdtImporter(
+ options.veymontResourcePath,
+ options.getParserDebugOptions,
+ ),
+ onPassEvent =
+ options.outputIntermediatePrograms
+ .map(p => reportIntermediateProgram(p, "generate")).toSeq ++
+ writeOutFunctions(before, options.outputBeforePass) ++
+ writeOutFunctions(after, options.outputAfterPass),
)
sealed trait TransformationEvent
case object before extends TransformationEvent
case object after extends TransformationEvent
- type PassEventHandler = (Seq[RewriterBuilder], TransformationEvent, String, Verification[_ <: Generation]) => Unit
+ type PassEventHandler =
+ (
+ Seq[RewriterBuilder],
+ TransformationEvent,
+ String,
+ Verification[_ <: Generation],
+ ) => Unit
}
-/**
- * Executes a sequence of rewriters. Currently the only concrete implementation is [[SilverTransformation]].
- *
- * Refer to [[RewriterBuilder]] and [[RewriterBuilderArg]] for information on how to use a [[Rewriter]] in the
- * pass chain.
- *
- * @param onPassEvent Execute a handler before/after a pass is executed.
- * @param passes The list of rewrite passes to execute.
- */
-class Transformation
-(
- val onPassEvent: Seq[PassEventHandler],
- val passes: Seq[RewriterBuilder],
-) extends Stage[Verification[_ <: Generation], Verification[_ <: Generation]] with LazyLogging {
+/** Executes a sequence of rewriters. Currently the only concrete implementation
+ * is [[SilverTransformation]].
+ *
+ * Refer to [[RewriterBuilder]] and [[RewriterBuilderArg]] for information on
+ * how to use a [[Rewriter]] in the pass chain.
+ *
+ * @param onPassEvent
+ * Execute a handler before/after a pass is executed.
+ * @param passes
+ * The list of rewrite passes to execute.
+ */
+class Transformation(
+ val onPassEvent: Seq[PassEventHandler],
+ val passes: Seq[RewriterBuilder],
+) extends Stage[Verification[_ <: Generation], Verification[_ <: Generation]]
+ with LazyLogging {
override def friendlyName: String = "Transformation"
override def progressWeight: Int = 10
- override def run(input: Verification[_ <: Generation]): Verification[_ <: Generation] = {
+ override def run(
+ input: Verification[_ <: Generation]
+ ): Verification[_ <: Generation] = {
val tempUnsupported = Set[feature.Feature](
feature.MatrixVector,
feature.NumericReductionOperator,
@@ -128,7 +205,10 @@ class Transformation
feature.Feature.examples(input).foreach {
case (feature, examples) if tempUnsupported.contains(feature) =>
- throw TemporarilyUnsupported(feature.getClass.getSimpleName.stripSuffix("$"), examples.toSeq)
+ throw TemporarilyUnsupported(
+ feature.getClass.getSimpleName.stripSuffix("$"),
+ examples.toSeq,
+ )
case (_, _) =>
}
@@ -136,19 +216,24 @@ class Transformation
var result: Verification[_ <: Generation] = input
Progress.foreach(passes, (pass: RewriterBuilder) => pass.key) { pass =>
- onPassEvent.foreach { action => action(passes, Transformation.before, pass.key, result) }
-
- result = try {
- pass().dispatch(result)
- } catch {
- case c @ CauseWithBadEffect(effect) =>
- logger.error(s"An error occurred in pass ${pass.key}")
- throw c
+ onPassEvent.foreach { action =>
+ action(passes, Transformation.before, pass.key, result)
}
- onPassEvent.foreach { action => action(passes, Transformation.after, pass.key, result) }
+ result =
+ try { pass().dispatch(result) }
+ catch {
+ case c @ CauseWithBadEffect(effect) =>
+ logger.error(s"An error occurred in pass ${pass.key}")
+ throw c
+ }
+
+ onPassEvent.foreach { action =>
+ action(passes, Transformation.after, pass.key, result)
+ }
- result.tasks.map(_.program).flatMap(program => program.check.map(program -> _)) match {
+ result.tasks.map(_.program)
+ .flatMap(program => program.check.map(program -> _)) match {
case Nil => // ok
case errors => throw TransformationCheckError(pass, errors)
}
@@ -169,191 +254,199 @@ class Transformation
}
}
-/**
- * Defines the rewrite chain appropriate for the Viper backends: Silicon and Carbon.
- *
- * @param adtImporter Decides how to import the definition of the built-in axiomatically-defined datatypes.
- * @param onBeforePassKey Execute a side effect just before a rewrite pass is executed.
- * @param onAfterPassKey Execute a side effect just after a rewrite pass is executed. The consistency check is done
- * before the side effect is performed.
- * @param simplifyBeforeRelations The list of passes to execute at the appropriate point for simplification, just before
- * quantified integer relations are simplified.
- * @param simplifyAfterRelations The list of passes to execute at the appropriate point for simplification, just after
- * quantified integer relations are simplified.
- * @param checkSat Check that non-trivial contracts are satisfiable.
- */
-case class SilverTransformation
-(
- adtImporter: ImportADTImporter = PathAdtImporter(Resources.getAdtPath, vct.parsers.debug.DebugOptions.NONE),
- override val onPassEvent: Seq[PassEventHandler] = Nil,
- simplifyBeforeRelations: Seq[RewriterBuilder] = Options().simplifyPaths.map(Transformation.simplifierFor(_, Options())),
- simplifyAfterRelations: Seq[RewriterBuilder] = Options().simplifyPathsAfterRelations.map(Transformation.simplifierFor(_, Options())),
- inferHeapContextIntoFrame: Boolean = true,
- bipResults: BIP.VerificationResults,
- checkSat: Boolean = true,
- splitVerificationByProcedure: Boolean = false,
- veymontGeneratePermissions: Boolean = false,
-) extends Transformation(onPassEvent, Seq(
- // Replace leftover SYCL types
- ReplaceSYCLTypes,
- CFloatIntCoercion,
-
- ComputeBipGlue,
- InstantiateBipSynchronizations,
- EncodeBipPermissions,
- EncodeBip.withArg(bipResults),
-
- // Remove the java.lang.Object -> java.lang.Object inheritance loop
- NoSupportSelfLoop,
-
- // Delete stuff that may be declared unsupported at a later stage
- FilterSpecIgnore,
-
- // Normalize AST
- // Make sure Disambiguate comes after CFloatIntCoercion, so CInts are gone
- Disambiguate, // Resolve overloaded operators (+, subscript, etc.)
- DisambiguateLocation, // Resolve location type
- EncodeRangedFor,
-
- // VeyMont sequential program encoding
- SplitChorGuards,
- EncodeUnpointedGuard,
- DeduplicateChorGuards,
- InferEndpointContexts,
- GenerateChoreographyPermissions.withArg(veymontGeneratePermissions),
- EncodeChorBranchUnanimity,
- EncodeEndpointInequalities,
- EncodeChoreography,
-
- EncodeString, // Encode spec string as seq
- EncodeChar,
-
- CollectLocalDeclarations, // all decls in Scope
- DesugarPermissionOperators, // no PointsTo, \pointer, etc.
- ReadToValue, // resolve wildcard into fractional permission
- TrivialAddrOf,
- DesugarCoalescingOperators, // no ?.
- PinCollectionTypes, // no anonymous sequences, sets, etc.
- QuantifySubscriptAny, // no arr[*]
- IterationContractToParBlock,
- PropagateContextEverywhere, // inline context_everywhere into loop invariants
- EncodeArrayValues, // maybe don't target shift lemmas on generated function for \values
- GivenYieldsToArgs,
-
- CheckProcessAlgebra,
- EncodeCurrentThread,
- EncodeIntrinsicLock,
- EncodeForkJoin,
- InlineApplicables,
- PureMethodsToFunctions,
- RefuteToInvertedAssert,
- ExplicitResourceValues,
- EncodeResourceValues,
-
- // Encode parallel blocks
- EncodeSendRecv,
- ParBlockEncoder,
-
- // Extract explicitly extracted code sections, which ban continue/break/return/goto outside them.
- SpecifyImplicitLabels,
- EncodeExtract,
-
- // Encode exceptional behaviour (no more continue/break/return/try/throw)
- SwitchToGoto,
- ContinueToBreak,
- EncodeBreakReturn,
-
- ) ++ simplifyBeforeRelations ++ Seq(
- SimplifyQuantifiedRelations,
- SimplifyNestedQuantifiers,
- TupledQuantifiers,
- ) ++ simplifyAfterRelations ++ Seq(
- UntupledQuantifiers,
-
- // Encode proof helpers
- EncodeProofHelpers.withArg(inferHeapContextIntoFrame),
- ImportSetCompat.withArg(adtImporter),
-
- // Make final fields constant functions. Explicitly before ResolveExpressionSideEffects, because that pass will
- // flatten out functions in the rhs of assignments, making it harder to detect final field assignments where the
- // value is pure and therefore be put in the contract of the constant function.
- ConstantifyFinalFields,
-
- // Resolve side effects including method invocations, for encodetrythrowsignals.
- ResolveExpressionSideChecks,
- ResolveExpressionSideEffects,
- EncodeTryThrowSignals,
-
- ResolveScale,
- MonomorphizeClass,
- // No more classes
- ClassToRef,
- HeapVariableToRef,
-
- CheckContractSatisfiability.withArg(checkSat),
-
- DesugarCollectionOperators,
- EncodeNdIndex,
-
- ExtractInlineQuantifierPatterns,
- // Translate internal types to domains
- FloatToRat,
- SmtlibToProverTypes,
- EnumToDomain,
- ImportArray.withArg(adtImporter),
- ImportPointer.withArg(adtImporter),
- ImportVector.withArg(adtImporter),
- ImportMapCompat.withArg(adtImporter),
- ImportEither.withArg(adtImporter),
- ImportTuple.withArg(adtImporter),
- ImportOption.withArg(adtImporter),
- ImportFrac.withArg(adtImporter),
- ImportNothing.withArg(adtImporter),
- ImportVoid.withArg(adtImporter),
- ImportNull.withArg(adtImporter),
- ImportAny.withArg(adtImporter),
- ImportViperOrder.withArg(adtImporter),
- EncodeRange.withArg(adtImporter),
-
- // After Disambiguate and ImportVector
- TruncDivMod,
-
- // All locations with a value should now be SilverField
- EncodeForPermWithValue,
- EncodeAutoValue,
-
- ExtractInlineQuantifierPatterns,
- RewriteTriggerADTFunctions,
- MonomorphizeContractApplicables,
-
- // Silver compat (basically no new nodes)
- FinalizeArguments,
- ExplicitADTTypeArgs,
- ForLoopToWhileLoop,
- BranchToIfElse,
- EvaluationTargetDummy,
-
- // Final translation to rigid silver nodes
- SilverIntRatCoercion,
- // PB TODO: PinSilverNodes has now become a collection of Silver oddities, it should be more structured / split out.
- PinSilverNodes,
-
- Explode.withArg(splitVerificationByProcedure),
- ))
-
-case class VeyMontImplementationGeneration(importer: ImportADTImporter = PathAdtImporter(Resources.getVeymontPath, vct.parsers.debug.DebugOptions.NONE),
- override val onPassEvent: Seq[PassEventHandler] = Nil)
- extends Transformation(onPassEvent, Seq(
- SplitChorGuards,
- EncodeUnpointedGuard,
- DeduplicateChorGuards,
- SpecializeEndpointClasses,
- InferEndpointContexts,
- EncodeChannels.withArg(importer),
-// EncodeChoreographyParameters,
- GenerateImplementation,
- PrettifyBlocks,
- ))
-
-
+/** Defines the rewrite chain appropriate for the Viper backends: Silicon and
+ * Carbon.
+ *
+ * @param adtImporter
+ * Decides how to import the definition of the built-in axiomatically-defined
+ * datatypes.
+ * @param onBeforePassKey
+ * Execute a side effect just before a rewrite pass is executed.
+ * @param onAfterPassKey
+ * Execute a side effect just after a rewrite pass is executed. The
+ * consistency check is done before the side effect is performed.
+ * @param simplifyBeforeRelations
+ * The list of passes to execute at the appropriate point for simplification,
+ * just before quantified integer relations are simplified.
+ * @param simplifyAfterRelations
+ * The list of passes to execute at the appropriate point for simplification,
+ * just after quantified integer relations are simplified.
+ * @param checkSat
+ * Check that non-trivial contracts are satisfiable.
+ */
+case class SilverTransformation(
+ adtImporter: ImportADTImporter = PathAdtImporter(
+ Resources.getAdtPath,
+ vct.parsers.debug.DebugOptions.NONE,
+ ),
+ override val onPassEvent: Seq[PassEventHandler] = Nil,
+ simplifyBeforeRelations: Seq[RewriterBuilder] = Options().simplifyPaths
+ .map(Transformation.simplifierFor(_, Options())),
+ simplifyAfterRelations: Seq[RewriterBuilder] = Options()
+ .simplifyPathsAfterRelations
+ .map(Transformation.simplifierFor(_, Options())),
+ inferHeapContextIntoFrame: Boolean = true,
+ bipResults: BIP.VerificationResults,
+ checkSat: Boolean = true,
+ splitVerificationByProcedure: Boolean = false,
+ veymontGeneratePermissions: Boolean = false,
+) extends Transformation(
+ onPassEvent,
+ Seq(
+ // Replace leftover SYCL types
+ ReplaceSYCLTypes,
+ CFloatIntCoercion,
+ ComputeBipGlue,
+ InstantiateBipSynchronizations,
+ EncodeBipPermissions,
+ EncodeBip.withArg(bipResults),
+
+ // Remove the java.lang.Object -> java.lang.Object inheritance loop
+ NoSupportSelfLoop,
+
+ // Delete stuff that may be declared unsupported at a later stage
+ FilterSpecIgnore,
+
+ // Normalize AST
+ // Make sure Disambiguate comes after CFloatIntCoercion, so CInts are gone
+ Disambiguate, // Resolve overloaded operators (+, subscript, etc.)
+ DisambiguateLocation, // Resolve location type
+ EncodeRangedFor,
+
+ // VeyMont sequential program encoding
+ SplitChorGuards,
+ EncodeUnpointedGuard,
+ DeduplicateChorGuards,
+ InferEndpointContexts,
+ GenerateChoreographyPermissions.withArg(veymontGeneratePermissions),
+ EncodeChorBranchUnanimity,
+ EncodeEndpointInequalities,
+ EncodeChoreography,
+ EncodeString, // Encode spec string as seq
+ EncodeChar,
+ CollectLocalDeclarations, // all decls in Scope
+ DesugarPermissionOperators, // no PointsTo, \pointer, etc.
+ ReadToValue, // resolve wildcard into fractional permission
+ TrivialAddrOf,
+ DesugarCoalescingOperators, // no ?.
+ PinCollectionTypes, // no anonymous sequences, sets, etc.
+ QuantifySubscriptAny, // no arr[*]
+ IterationContractToParBlock,
+ PropagateContextEverywhere, // inline context_everywhere into loop invariants
+ EncodeArrayValues, // maybe don't target shift lemmas on generated function for \values
+ GivenYieldsToArgs,
+ CheckProcessAlgebra,
+ EncodeCurrentThread,
+ EncodeIntrinsicLock,
+ EncodeForkJoin,
+ InlineApplicables,
+ PureMethodsToFunctions,
+ RefuteToInvertedAssert,
+ ExplicitResourceValues,
+ EncodeResourceValues,
+
+ // Encode parallel blocks
+ EncodeSendRecv,
+ ParBlockEncoder,
+
+ // Extract explicitly extracted code sections, which ban continue/break/return/goto outside them.
+ SpecifyImplicitLabels,
+ EncodeExtract,
+
+ // Encode exceptional behaviour (no more continue/break/return/try/throw)
+ SwitchToGoto,
+ ContinueToBreak,
+ EncodeBreakReturn,
+ ) ++ simplifyBeforeRelations ++ Seq(
+ SimplifyQuantifiedRelations,
+ SimplifyNestedQuantifiers,
+ TupledQuantifiers,
+ ) ++ simplifyAfterRelations ++ Seq(
+ UntupledQuantifiers,
+
+ // Encode proof helpers
+ EncodeProofHelpers.withArg(inferHeapContextIntoFrame),
+ ImportSetCompat.withArg(adtImporter),
+
+ // Make final fields constant functions. Explicitly before ResolveExpressionSideEffects, because that pass will
+ // flatten out functions in the rhs of assignments, making it harder to detect final field assignments where the
+ // value is pure and therefore be put in the contract of the constant function.
+ ConstantifyFinalFields,
+
+ // Resolve side effects including method invocations, for encodetrythrowsignals.
+ ResolveExpressionSideChecks,
+ ResolveExpressionSideEffects,
+ EncodeTryThrowSignals,
+ ResolveScale,
+ MonomorphizeClass,
+ // No more classes
+ ClassToRef,
+ HeapVariableToRef,
+ CheckContractSatisfiability.withArg(checkSat),
+ DesugarCollectionOperators,
+ EncodeNdIndex,
+ ExtractInlineQuantifierPatterns,
+ // Translate internal types to domains
+ FloatToRat,
+ SmtlibToProverTypes,
+ EnumToDomain,
+ ImportArray.withArg(adtImporter),
+ ImportPointer.withArg(adtImporter),
+ ImportVector.withArg(adtImporter),
+ ImportMapCompat.withArg(adtImporter),
+ ImportEither.withArg(adtImporter),
+ ImportTuple.withArg(adtImporter),
+ ImportOption.withArg(adtImporter),
+ ImportFrac.withArg(adtImporter),
+ ImportNothing.withArg(adtImporter),
+ ImportVoid.withArg(adtImporter),
+ ImportNull.withArg(adtImporter),
+ ImportAny.withArg(adtImporter),
+ ImportViperOrder.withArg(adtImporter),
+ EncodeRange.withArg(adtImporter),
+
+ // After Disambiguate and ImportVector
+ TruncDivMod,
+
+ // All locations with a value should now be SilverField
+ EncodeForPermWithValue,
+ EncodeAutoValue,
+ ExtractInlineQuantifierPatterns,
+ RewriteTriggerADTFunctions,
+ MonomorphizeContractApplicables,
+
+ // Silver compat (basically no new nodes)
+ FinalizeArguments,
+ ExplicitADTTypeArgs,
+ ForLoopToWhileLoop,
+ BranchToIfElse,
+ EvaluationTargetDummy,
+
+ // Final translation to rigid silver nodes
+ SilverIntRatCoercion,
+ // PB TODO: PinSilverNodes has now become a collection of Silver oddities, it should be more structured / split out.
+ PinSilverNodes,
+ Explode.withArg(splitVerificationByProcedure),
+ ),
+ )
+case class VeyMontImplementationGeneration(
+ importer: ImportADTImporter = PathAdtImporter(
+ Resources.getVeymontPath,
+ vct.parsers.debug.DebugOptions.NONE,
+ ),
+ override val onPassEvent: Seq[PassEventHandler] = Nil,
+) extends Transformation(
+ onPassEvent,
+ Seq(
+ SplitChorGuards,
+ EncodeUnpointedGuard,
+ DeduplicateChorGuards,
+ SpecializeEndpointClasses,
+ InferEndpointContexts,
+ EncodeChannels.withArg(importer),
+// EncodeChoreographyParameters,
+ GenerateImplementation,
+ PrettifyBlocks,
+ ),
+ )
diff --git a/src/main/vct/options/BashCompletion.scala b/src/main/vct/options/BashCompletion.scala
index 2b18426bfd..5f1678c1c6 100644
--- a/src/main/vct/options/BashCompletion.scala
+++ b/src/main/vct/options/BashCompletion.scala
@@ -14,7 +14,8 @@ case object BashCompletion {
private val abbrSymbol = tOptDef.info.decl(TermName("_shortOpt")).asTerm
def abbr[A, C](opt: OptionDef[A, C]): Option[String] =
- mirror.reflect(opt).reflectField(abbrSymbol).get.asInstanceOf[Option[String]]
+ mirror.reflect(opt).reflectField(abbrSymbol).get
+ .asInstanceOf[Option[String]]
def main(args: Array[String]): Unit = {
val (parser, tags) = Options.constructParser(hide = true)
@@ -26,7 +27,7 @@ case object BashCompletion {
var languageOpts = Seq.empty[String]
var unknownOpts = Seq.empty[String]
- for(option <- parser.toList if option.name.nonEmpty) {
+ for (option <- parser.toList if option.name.nonEmpty) {
val opts = Seq("--" + option.name) ++ abbr(option).map("-" + _).toSeq
// We only add types that have exactly one argument, and we can for sure know all the suggestions we should make.
@@ -48,7 +49,8 @@ case object BashCompletion {
}
}
- println("""
+ println(
+ """
|__vercors()
|{
|local cur prev pathOpts pathOrStdOpts stringOpts backendOpts languageOpts unknownOpts
@@ -89,7 +91,8 @@ case object BashCompletion {
unknownOpts.mkString("|"),
Backend.options.keys.mkString(" "),
ReadLanguage.options.keys.mkString(" "),
- (pathOpts ++ pathOrStdOpts ++ stringOpts ++ backendOpts ++ languageOpts ++ unknownOpts).mkString(" "),
+ (pathOpts ++ pathOrStdOpts ++ stringOpts ++ backendOpts ++
+ languageOpts ++ unknownOpts).mkString(" "),
).strip()
)
}
diff --git a/src/main/vct/options/Options.scala b/src/main/vct/options/Options.scala
index 566ab6e757..79e522f5e8 100644
--- a/src/main/vct/options/Options.scala
+++ b/src/main/vct/options/Options.scala
@@ -17,16 +17,24 @@ case object Options {
def parser(hide: Boolean = true): OParser[Unit, Options] =
constructParser(hide)._1
- def constructParser(hide: Boolean): (OParser[Unit, Options], Map[String, ClassTag[_]]) = {
+ def constructParser(
+ hide: Boolean
+ ): (OParser[Unit, Options], Map[String, ClassTag[_]]) = {
import builder._
implicit class Hideable[A, C](opt: OParser[A, C]) {
- def maybeHidden(): OParser[A, C] = if(hide) opt.hidden() else opt
+ def maybeHidden(): OParser[A, C] =
+ if (hide)
+ opt.hidden()
+ else
+ opt
}
val tags: mutable.Map[String, ClassTag[_]] = mutable.Map()
- def opt[T: scopt.Read](name: String)(implicit tag: ClassTag[T]): OParser[T, Options] = {
+ def opt[T: scopt.Read](
+ name: String
+ )(implicit tag: ClassTag[T]): OParser[T, Options] = {
val parser = builder.opt[T](name)
tags(parser.toList.head.name) = tag
parser
@@ -36,134 +44,145 @@ case object Options {
implicit val readLanguage: scopt.Read[Language] = ReadLanguage.read
import vct.options.types.Verbosity.read
- implicit val readPathOrStd: scopt.Read[PathOrStd] =
- scopt.Read.reads {
- case "-" => PathOrStd.StdInOrOut
- case other => PathOrStd.Path(Paths.get(other))
- }
+ implicit val readPathOrStd: scopt.Read[PathOrStd] = scopt.Read.reads {
+ case "-" => PathOrStd.StdInOrOut
+ case other => PathOrStd.Path(Paths.get(other))
+ }
implicit val readPath: scopt.Read[Path] = scopt.Read.reads(Paths.get(_))
val parser = OParser.sequence(
programName(BuildInfo.name),
head(BuildInfo.name, BuildInfo.version),
-
- opt[Unit]("help").abbr("h")
- .action((_, c) => c.copy(help = true))
+ opt[Unit]("help").abbr("h").action((_, c) => c.copy(help = true))
.text("Prints this usage text"),
- opt[Unit]("help-hidden")
- .action((_, c) => c.copy(showHidden = true))
- .text("Show hidden options (intended for VerCors experts, proceed with caution!)"),
+ opt[Unit]("help-hidden").action((_, c) => c.copy(showHidden = true)).text(
+ "Show hidden options (intended for VerCors experts, proceed with caution!)"
+ ),
version("version").text("Prints version and build information"),
- opt[Unit]("help-passes")
- .action((_, c) => c.copy(mode = Mode.HelpVerifyPasses))
- .text("Lists the pass keys available for options that take a pass key."),
- opt[Unit]("quiet").abbr("q")
- .action((_, c) => c.copy(logLevels = c.logLevels ++ Seq(("vct", Verbosity.Error), ("viper.api", Verbosity.Error))))
- .text("Instruct VerCors to only log errors."),
- opt[Unit]("verbose").abbr("v")
- .action((_, c) => c.copy(logLevels = c.logLevels ++ Seq(("vct", Verbosity.Debug), ("viper.api", Verbosity.Debug))))
- .text("Instruct VerCors to output debug information"),
- opt[Unit]("progress").abbr("p")
- .action((_, c) => c.copy(progress = true))
+ opt[Unit]("help-passes").action((_, c) =>
+ c.copy(mode = Mode.HelpVerifyPasses)
+ ).text("Lists the pass keys available for options that take a pass key."),
+ opt[Unit]("quiet").abbr("q").action((_, c) =>
+ c.copy(logLevels =
+ c.logLevels ++
+ Seq(("vct", Verbosity.Error), ("viper.api", Verbosity.Error))
+ )
+ ).text("Instruct VerCors to only log errors."),
+ opt[Unit]("verbose").abbr("v").action((_, c) =>
+ c.copy(logLevels =
+ c.logLevels ++
+ Seq(("vct", Verbosity.Debug), ("viper.api", Verbosity.Debug))
+ )
+ ).text("Instruct VerCors to output debug information"),
+ opt[Unit]("progress").abbr("p").action((_, c) => c.copy(progress = true))
.text("Print progress information, even if stdout is not a tty."),
- opt[Unit]("profile")
- .action((_, c) => c.copy(profile = true))
- .text("Output profiling information in the current directory in the pprof format (https://github.com/google/pprof)"),
- opt[Unit]("watch").abbr("w")
- .action((_, c) => c.copy(watch = true))
- .text("Run VerCors in an infinite loop, waiting for external changes between each run."),
-
- opt[(String, Verbosity)]("dev-log-verbosity").unbounded().maybeHidden().keyValueName("", "")
+ opt[Unit]("profile").action((_, c) => c.copy(profile = true)).text(
+ "Output profiling information in the current directory in the pprof format (https://github.com/google/pprof)"
+ ),
+ opt[Unit]("watch").abbr("w").action((_, c) => c.copy(watch = true)).text(
+ "Run VerCors in an infinite loop, waiting for external changes between each run."
+ ),
+ opt[(String, Verbosity)]("dev-log-verbosity").unbounded().maybeHidden()
+ .keyValueName("", "")
.action((tup, c) => c.copy(logLevels = c.logLevels :+ tup))
.text("Set the log level for a custom logger key"),
-
note(""),
note("Verification Mode"),
- opt[Unit]("verify")
- .action((_, c) => c.copy(mode = Mode.Verify))
- .text("Enable verification mode: instruct VerCors to verify the given files (default)"),
-
- opt[Unit]("more").abbr("m")
- .action((_, c) => c.copy(more = true))
+ opt[Unit]("verify").action((_, c) => c.copy(mode = Mode.Verify)).text(
+ "Enable verification mode: instruct VerCors to verify the given files (default)"
+ ),
+ opt[Unit]("more").abbr("m").action((_, c) => c.copy(more = true))
.text("Always print the maximum amount of information about errors."),
opt[Language]("lang").valueName(ReadLanguage.valueName)
- .action((lang, c) => c.copy(language = Some(lang)))
- .text("Do not detect the language from the file extension, but force a specific language parser for all files"),
+ .action((lang, c) => c.copy(language = Some(lang))).text(
+ "Do not detect the language from the file extension, but force a specific language parser for all files"
+ ),
opt[Backend]("backend").valueName(Backend.valueName)
.action((backend, c) => c.copy(backend = backend))
.text("Set the backend to verify with (default: silicon)"),
opt[Path]("backend-file-base").valueName("")
.action((backendFile, c) => c.copy(backendFile = Some(backendFile)))
- .text("In addition to verification, output the resulting ASTs for the backend to files, appended with -."),
- opt[Unit]("backend-debug")
- .action((_, c) => c.copy(logLevels = c.logLevels :+ ("viper", Verbosity.Debug)))
- .text("Instruct the backend to print as much debugging information as possible"),
-
- opt[(String, PathOrStd)]("output-after-pass").unbounded().keyValueName("", "")
- .action((output, c) => c.copy(outputAfterPass = c.outputAfterPass ++ Map(output)))
- .text("Print the AST after a pass key"),
- opt[(String, PathOrStd)]("output-before-pass").unbounded().keyValueName("", "")
- .action((output, c) => c.copy(outputBeforePass = c.outputBeforePass ++ Map(output)))
- .text("Print the AST before a pass key"),
- opt[Unit]("trace-col")
- .action((_, c) => c.copy(outputIntermediatePrograms = Some(Paths.get("tmp", "cols"))))
- .text("Writes all intermediate ASTs, labeled by pass, to tmp/cols/"),
+ .text(
+ "In addition to verification, output the resulting ASTs for the backend to files, appended with -."
+ ),
+ opt[Unit]("backend-debug").action((_, c) =>
+ c.copy(logLevels = c.logLevels :+ ("viper", Verbosity.Debug))
+ ).text(
+ "Instruct the backend to print as much debugging information as possible"
+ ),
+ opt[(String, PathOrStd)]("output-after-pass").unbounded()
+ .keyValueName("", "").action((output, c) =>
+ c.copy(outputAfterPass = c.outputAfterPass ++ Map(output))
+ ).text("Print the AST after a pass key"),
+ opt[(String, PathOrStd)]("output-before-pass").unbounded()
+ .keyValueName("", "").action((output, c) =>
+ c.copy(outputBeforePass = c.outputBeforePass ++ Map(output))
+ ).text("Print the AST before a pass key"),
+ opt[Unit]("trace-col").action((_, c) =>
+ c.copy(outputIntermediatePrograms = Some(Paths.get("tmp", "cols")))
+ ).text("Writes all intermediate ASTs, labeled by pass, to tmp/cols/"),
opt[Path]("trace-col-in")
- .action((p, c) => c.copy(outputIntermediatePrograms = Some(p)))
- .text("Writes all intermediate ASTs, labeled by pass, to a given folder"),
-
+ .action((p, c) => c.copy(outputIntermediatePrograms = Some(p))).text(
+ "Writes all intermediate ASTs, labeled by pass, to a given folder"
+ ),
opt[String]("backend-option").unbounded().keyName("