atom-1.0.13: An EDSL for embedded hard realtime applications.

Copyright(c) 2013 Tom Hawkins & Lee Pike
Safe HaskellNone



Sharing for UEs, based on IntMaps. The idea is to share subexpressions of UEs.



data MUV Source

Untyped variables map.


type UeMap = (Hash, Bimap Int UeElem) Source

An entry in the Map.

type Hash = Int Source

type UeState a = State UeMap a Source

Wrapped in the State Monad.

recoverUE :: UeMap -> Hash -> UE Source

Get a UE back out of the UeMap.

getUE :: Hash -> UeMap -> UeElem Source

Get the element associated with a Hash value. It's an error if the element is not in the map.

newUE :: UE -> UeMap -> (Hash, UeMap) Source

Put a new UE in the map, unless it's already in there, and return the hash pointing to the UE and a new map.

newUV :: UV -> UeMap -> (MUV, UeMap) Source

Transforms a UV into a MUV, returning the possibly updated map.

maybeUpdate :: UeElem -> UeState Hash Source

Lookup an element in the map, and if it's in there, do nothing, but return its hash value. Otherwise, update the map and return the new hash value for the inserted element.

ueUpstream :: Hash -> UeMap -> [Hash] Source

The list of Hashes to adjacent upstream of a UE.

nearestUVs :: Hash -> UeMap -> [MUV] Source

The list of all UVs that directly control the value of an expression.

arrayIndices :: Hash -> UeMap -> [(UA, Hash)] Source

All array indexing subexpressions.