morley-1.7.0: Developer tools for the Michelson Language
Safe HaskellNone
LanguageHaskell2010

Michelson.Analyzer

Description

Static analysis of Michelson code.

Synopsis

Documentation

data AnalyzerRes Source #

Constructors

AnalyzerRes 

Fields

  • arConstStrings :: HashMap MText Word

    All string constants and number of their occurrences.

  • arConstBytes :: HashMap ByteString Word

    All bytes constants and number of their occurrences.

  • arErrorTags :: HashMap MText Word

    Which strings are used as error tags and how many times. There is no notion of "error tag" in Michelson, so we use a heuristic to find out whether a string is an error tag. Specifically, we consider three patterns: 1. A constant string is pushed and then there is FAILWITH immediately. 2. A constant string is pushed, followed by PAIR instruction and then FAILWITH. 3. A constant pair is pushed where the first item is a string and then there is `FAILWITH.

analyze :: Instr inp out -> AnalyzerRes Source #

Statically analyze an instruction. Typed representation is used because it's easier to analyze. It means that we can't analyze ill-typed contracts, but hopefully it's not a serious limitation.